diff --git a/packages/widgets/src/feedback/NotificationQueue.ts b/packages/widgets/src/feedback/NotificationQueue.ts new file mode 100644 index 00000000..bed07d03 --- /dev/null +++ b/packages/widgets/src/feedback/NotificationQueue.ts @@ -0,0 +1,57 @@ +export type NotificationPriority = "low" | "medium" | "high"; + +export interface Notification { + id: string; + message: string; + priority?: NotificationPriority; + duration?: number; +} + +export class NotificationQueue { + private queue: Notification[] = []; + private paused = false; + + add(notification: Notification): void { + this.queue.push({ + priority: "medium", + duration: 3000, + ...notification, + }); + + this.queue.sort((a, b) => { + const order = { + high: 3, + medium: 2, + low: 1, + }; + + return order[b.priority!] - order[a.priority!]; + }); + } + + getAll(): Notification[] { + return this.queue; + } + + remove(id: string): void { + this.queue = this.queue.filter( + item => item.id !== id + ); + } + + clear(): void { + this.queue = []; + } + + pause(): void { + this.paused = true; + } + + resume(): void { + this.paused = false; + } + + isPaused(): boolean { + return this.paused; + } +} \ No newline at end of file diff --git a/packages/widgets/src/index.ts b/packages/widgets/src/index.ts index 9ea26fbc..45486c89 100644 --- a/packages/widgets/src/index.ts +++ b/packages/widgets/src/index.ts @@ -129,6 +129,13 @@ export type { DraggableOptions, DroppableOptions } from './layout/DragAndDrop.js export { Fill } from './layout/Fill.js'; export type { FillOptions } from './layout/Fill.js'; export { SplitPane } from './layout/SplitPane.js'; +export type { SplitPaneOptions } from './layout/SplitPane.js'; +export { NotificationQueue } from "./feedback/NotificationQueue.js"; + +export type { + Notification, + NotificationPriority +} from "./feedback/NotificationQueue.js"; export type { SplitPaneOptions, SplitDirection } from './layout/SplitPane.js'; // ── Feedback Widgets ──────────────────────────────────