@arbidocs/react 0.4.137 → 0.4.139

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,31 +15,42 @@ interface AppNotification {
15
15
  /** Optional in-app link the entry deep-links to (passed to the bell's onNavigate). */
16
16
  href?: string;
17
17
  /** Optional click action — wins over `href` when both are present. Session
18
- * history only; entries are never serialized, so a closure is safe here. */
18
+ * history only: never persisted, so a closure is safe here. */
19
19
  onSelect?: () => void;
20
+ /** The label of the action `onSelect` runs ("Reply", "View"). */
21
+ actionLabel?: string;
22
+ /** Workspace the entry belongs to. */
23
+ workspaceId?: string;
24
+ /** Markup of a rich (non-string) toast message, for a log that shows it as it was toasted. */
25
+ html?: string;
20
26
  /** Routine session activity ("Opening workspace…", "Saved") — kept for the
21
27
  * log but not something that demands attention: excluded from the unread
22
- * badge and from the bell's default list (shown under "All activity"). */
28
+ * badge and from the bell's list. */
23
29
  ambient?: boolean;
24
- /** Where the entry comes from. Session entries (`record`) have none; a
30
+ /** Where the entry comes from. Session entries (`notify.*`) have none; a
25
31
  * backend bridge stamps its own (e.g. 'server') so {@link syncSource} can
26
32
  * replace exactly its slice on every refetch without touching the rest. */
27
33
  source?: string;
28
34
  }
29
35
  interface NotifyOptions {
30
- /** Shown under the title in the toast; a string description is also recorded in the centre. */
36
+ /** Shown under the title in the toast; a string description is also recorded. */
31
37
  description?: ReactNode;
32
- /** Also record a persistent notification-centre entry (default true). */
38
+ /** Record an entry in the history (default true). False pops the toast only — for an event
39
+ * whose entry arrives another way (a server-persisted notification synced by a bridge). */
33
40
  record?: boolean;
34
- /** Pop the transient toast (default true). False records the centre entry only, e.g. while
35
- * the user has muted toasts: the centre is the history they come back to. */
41
+ /** Pop the transient toast (default true unless muted). False records the entry only. */
36
42
  toast?: boolean;
37
- /** Centre title for a rich (non-string) toast title. Default: the string title, else
38
- * "Notification". */
43
+ /** Recorded title for a rich (non-string) toast title. Default: the string title, else the
44
+ * rich title's text. */
39
45
  recordTitle?: string;
46
+ /** Recorded markup for a rich toast title (default: the title rendered to static markup). */
47
+ html?: string;
40
48
  href?: string;
49
+ /** Workspace the notification belongs to: its glyph shows in the toast and its link is the
50
+ * entry's default `href` (both as configured with {@link configureNotify}). */
51
+ workspaceId?: string;
41
52
  duration?: number;
42
- /** A toast action button (sonner). Clicking the centre entry runs it too. */
53
+ /** A toast action button (sonner). Clicking the entry runs it too. */
43
54
  action?: {
44
55
  label: ReactNode;
45
56
  onClick: () => void;
@@ -51,15 +62,22 @@ interface NotifyOptions {
51
62
  /** Record as routine session activity (see {@link AppNotification.ambient}): born read. */
52
63
  ambient?: boolean;
53
64
  }
65
+ /** Session entries kept (oldest dropped first) — a safety net against pathological growth; a
66
+ * large upload can log many entries, so it is generous. Source slices are bounded by their source. */
67
+ declare const MAX_SESSION_NOTIFICATIONS = 5000;
54
68
  interface NotifyState {
55
69
  notifications: AppNotification[];
70
+ /** Toasts are muted: entries are still recorded — the history is what the user comes back to. */
71
+ muted: boolean;
72
+ setMuted: (muted: boolean) => void;
56
73
  markRead: (id: string) => void;
57
74
  markAllRead: () => void;
58
75
  removeNotification: (id: string) => void;
76
+ removeNotifications: (ids: readonly string[]) => void;
59
77
  clearNotifications: () => void;
60
- /** Replace the centre's history (e.g. seed a demo/initial set). */
78
+ /** Replace the history (e.g. seed a demo/initial set). */
61
79
  seed: (items: AppNotification[]) => void;
62
- /** Record a centre entry (used by `notify.*`; sonner renders the toast). */
80
+ /** Record an entry (used by `notify.*`; sonner renders the toast). */
63
81
  record: (note: AppNotification) => void;
64
82
  /** Reconcile one source's slice with fresh truth (e.g. a backend list on
65
83
  * every refetch): entries stamped with `source` are replaced wholesale —
@@ -68,14 +86,33 @@ interface NotifyState {
68
86
  syncSource: (source: string, items: AppNotification[]) => void;
69
87
  }
70
88
  declare const useNotify: zustand.UseBoundStore<zustand.StoreApi<NotifyState>>;
89
+ /** What a host configures once for every `notify.*` call. */
90
+ interface NotifyConfig {
91
+ /** The toast glyph of a notification that names a workspace. */
92
+ workspaceIcon?: (workspaceId: string) => ReactNode;
93
+ /** The default link of an entry that names a workspace. */
94
+ workspaceHref?: (workspaceId: string) => string | undefined;
95
+ /** The default of {@link NotifyOptions.ambient} for calls that do not say: a host whose own
96
+ * toasts are mostly confirmations ("Saved") records them as log lines, and passes
97
+ * `ambient: false` for what should claim attention. Default false. */
98
+ ambient?: boolean;
99
+ }
100
+ /** Set the host's workspace glyph and link (merged into what is configured). */
101
+ declare function configureNotify(next: NotifyConfig): void;
71
102
  declare const notify: {
72
103
  success: (title: ReactNode, opts?: NotifyOptions) => string;
73
104
  error: (title: ReactNode, opts?: NotifyOptions) => string;
74
105
  info: (title: ReactNode, opts?: NotifyOptions) => string;
75
106
  warning: (title: ReactNode, opts?: NotifyOptions) => string;
76
107
  };
77
- /** Replace the notification centre's history — inject a seed/initial set. */
108
+ /** Replace the history — inject a seed/initial set. */
78
109
  declare function seedNotifications(items: AppNotification[]): void;
110
+ /**
111
+ * Keep the session history and the mute switch across reloads in `storage` under `key`: restores
112
+ * them now and saves every change. Source slices are not saved (their source re-syncs them), and
113
+ * neither are actions — a closure does not survive a reload. Returns the unsubscribe.
114
+ */
115
+ declare function persistNotifyHistory(key: string, storage?: Pick<Storage, 'getItem' | 'setItem'> | undefined): () => void;
79
116
  /** Unread count selector for the topbar bell — ambient session activity never
80
117
  * demands attention, so it never counts. */
81
118
  declare const selectUnread: (s: NotifyState) => number;
@@ -105,10 +142,9 @@ interface NotificationBellProps {
105
142
  onMarkRead?: (id: string) => void;
106
143
  /** Called after "Mark all read" — same upstream-propagation hook. */
107
144
  onMarkAllRead?: () => void;
108
- /** Toast muting — the bell is where notification behaviour is controlled, so
109
- * the mute switch lives in its header. Omit `onToggleMute` to hide it. */
110
- muted?: boolean;
111
- onToggleMute?: () => void;
145
+ /** Show the store's toast mute switch in the header — the bell is where notification
146
+ * behaviour is controlled. */
147
+ showMuteToggle?: boolean;
112
148
  /** Override per-variant glyph colours (e.g. brand emerald for success). */
113
149
  toneClassNames?: Partial<Record<NotifyVariant, string>>;
114
150
  emptyText?: string;
@@ -120,8 +156,8 @@ interface NotificationBellProps {
120
156
  side?: 'top' | 'right' | 'bottom' | 'left';
121
157
  align?: 'start' | 'center' | 'end';
122
158
  }
123
- declare function NotificationBell({ renderTrigger, onNavigate, onSelectNotification, onMarkRead, onMarkAllRead, muted, onToggleMute, toneClassNames, emptyText, onViewAll, viewAllLabel, testId, side, align, }: NotificationBellProps): React.JSX.Element;
159
+ declare function NotificationBell({ renderTrigger, onNavigate, onSelectNotification, onMarkRead, onMarkAllRead, showMuteToggle, toneClassNames, emptyText, onViewAll, viewAllLabel, testId, side, align, }: NotificationBellProps): React.JSX.Element;
124
160
 
125
161
  declare function Toaster({ toastOptions, ...props }: ToasterProps): React.JSX.Element;
126
162
 
127
- export { type AppNotification as A, DEFAULT_NOTIFY_TONE as D, NotificationBell as N, Toaster as T, type NotificationBellProps as a, type NotificationBellTriggerState as b, type NotifyOptions as c, type NotifyVariant as d, selectUnread as e, notify as n, seedNotifications as s, useNotify as u };
163
+ export { type AppNotification as A, DEFAULT_NOTIFY_TONE as D, MAX_SESSION_NOTIFICATIONS as M, NotificationBell as N, Toaster as T, type NotificationBellProps as a, type NotificationBellTriggerState as b, type NotifyConfig as c, type NotifyOptions as d, type NotifyVariant as e, configureNotify as f, selectUnread as g, notify as n, persistNotifyHistory as p, seedNotifications as s, useNotify as u };