@inertiaui/notifications-vue 0.0.0-stage → 1.0.1
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.
- package/LICENSE.md +21 -0
- package/dist/inertiaui-notifications.d.ts +1756 -0
- package/dist/inertiaui-notifications.js +5531 -0
- package/package.json +57 -3
- package/shadcn.css +37 -0
- package/theme.css +410 -0
- package/README.md +0 -3
|
@@ -0,0 +1,1756 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
3
|
+
import { ComponentProvideOptions } from 'vue';
|
|
4
|
+
import { ComputedRef } from 'vue';
|
|
5
|
+
import { DefineComponent } from 'vue';
|
|
6
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
7
|
+
import { Placement } from '@inertiaui/vanilla';
|
|
8
|
+
import { PublicProps } from 'vue';
|
|
9
|
+
|
|
10
|
+
declare const __VLS_base: DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
11
|
+
action: (item: InboxItem, action: ToastAction<InboxItem>, event: MouseEvent) => any;
|
|
12
|
+
itemClick: (item: InboxItem, event: MouseEvent) => any;
|
|
13
|
+
"update:open": (value: boolean) => any;
|
|
14
|
+
}, string, PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
15
|
+
onAction?: ((item: InboxItem, action: ToastAction<InboxItem>, event: MouseEvent) => any) | undefined;
|
|
16
|
+
onItemClick?: ((item: InboxItem, event: MouseEvent) => any) | undefined;
|
|
17
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
snooze: (now: Date) => SnoozeOption[];
|
|
20
|
+
group: boolean;
|
|
21
|
+
count: "unread" | "unseen";
|
|
22
|
+
href: string;
|
|
23
|
+
icons: Record<string, Component>;
|
|
24
|
+
iconResolver: IconResolverFn | null;
|
|
25
|
+
classes: InboxClasses;
|
|
26
|
+
placement: Placement;
|
|
27
|
+
labels: Partial<InboxLabels>;
|
|
28
|
+
locale: string;
|
|
29
|
+
maxCount: number;
|
|
30
|
+
badge: "count" | "none" | "dot";
|
|
31
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
32
|
+
|
|
33
|
+
declare const __VLS_base_2: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
34
|
+
action: (item: InboxItem, action: ToastAction<InboxItem>, event: MouseEvent) => any;
|
|
35
|
+
itemClick: (item: InboxItem, event: MouseEvent) => any;
|
|
36
|
+
}, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{
|
|
37
|
+
onAction?: ((item: InboxItem, action: ToastAction<InboxItem>, event: MouseEvent) => any) | undefined;
|
|
38
|
+
onItemClick?: ((item: InboxItem, event: MouseEvent) => any) | undefined;
|
|
39
|
+
}>, {
|
|
40
|
+
preserveUrl: boolean;
|
|
41
|
+
filter: InboxFilter;
|
|
42
|
+
snooze: (now: Date) => SnoozeOption[];
|
|
43
|
+
category: string | null;
|
|
44
|
+
group: boolean;
|
|
45
|
+
manual: boolean;
|
|
46
|
+
icons: Record<string, Component>;
|
|
47
|
+
iconResolver: IconResolverFn | null;
|
|
48
|
+
classes: InboxClasses;
|
|
49
|
+
labels: Partial<InboxLabels>;
|
|
50
|
+
locale: string;
|
|
51
|
+
maxCount: number;
|
|
52
|
+
buffer: number;
|
|
53
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
54
|
+
|
|
55
|
+
declare const __VLS_base_3: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {
|
|
56
|
+
classes: PreferencesClasses;
|
|
57
|
+
labels: Partial<PreferencesLabels>;
|
|
58
|
+
locale: string;
|
|
59
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
60
|
+
|
|
61
|
+
declare const __VLS_export: __VLS_WithSlots< DefineComponent<{
|
|
62
|
+
position?: ToastPosition;
|
|
63
|
+
/** Shows only the toasts whose `toaster` option has this name. */
|
|
64
|
+
name?: string;
|
|
65
|
+
/** The accessible name of the toast region, in place of the `toaster_label` translation; the shortcut is added to it. */
|
|
66
|
+
label?: string;
|
|
67
|
+
/** The accessible name of each dismiss button, in place of the `toast_dismiss` translation; `:title` is replaced with the toast's title. */
|
|
68
|
+
dismissLabel?: TranslationValue;
|
|
69
|
+
/** `KeyboardEvent.code` values and modifier names that focus the newest toast. Pass `[]` to disable. */
|
|
70
|
+
hotkey?: readonly string[];
|
|
71
|
+
/** The words that screen readers announce before a toast's title, in place of the `toast_type_` translations. */
|
|
72
|
+
typeLabels?: ToastTypeLabels;
|
|
73
|
+
/** How many toasts show in the collapsed stack. */
|
|
74
|
+
visibleToasts?: number;
|
|
75
|
+
/** Show every toast at full height instead of stacking them. */
|
|
76
|
+
expand?: boolean;
|
|
77
|
+
/** Show a bar that counts down the time left on timed toasts. */
|
|
78
|
+
progress?: boolean;
|
|
79
|
+
/** Components for icon names that toasts refer to, for toast types, and for the built-in icons, such as `dismiss`. */
|
|
80
|
+
icons?: Record<string, Component>;
|
|
81
|
+
/** Resolves the icons that `icons` does not have, in place of the global resolver of `setIconResolver()`. */
|
|
82
|
+
iconResolver?: IconResolverFn | null;
|
|
83
|
+
/** Class names added to the parts of each toast. */
|
|
84
|
+
classes?: ToastClasses;
|
|
85
|
+
/** Components that render the toasts of a type in place of the default markup, keyed by the type, such as `{ invite: InviteToast }`. */
|
|
86
|
+
components?: Record<string, Component>;
|
|
87
|
+
/** Keep the toasts usable above modal dialogs of other libraries, such as Radix and Reka, and above the notification center's panel. */
|
|
88
|
+
aboveModals?: boolean;
|
|
89
|
+
}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{
|
|
90
|
+
position?: ToastPosition;
|
|
91
|
+
/** Shows only the toasts whose `toaster` option has this name. */
|
|
92
|
+
name?: string;
|
|
93
|
+
/** The accessible name of the toast region, in place of the `toaster_label` translation; the shortcut is added to it. */
|
|
94
|
+
label?: string;
|
|
95
|
+
/** The accessible name of each dismiss button, in place of the `toast_dismiss` translation; `:title` is replaced with the toast's title. */
|
|
96
|
+
dismissLabel?: TranslationValue;
|
|
97
|
+
/** `KeyboardEvent.code` values and modifier names that focus the newest toast. Pass `[]` to disable. */
|
|
98
|
+
hotkey?: readonly string[];
|
|
99
|
+
/** The words that screen readers announce before a toast's title, in place of the `toast_type_` translations. */
|
|
100
|
+
typeLabels?: ToastTypeLabels;
|
|
101
|
+
/** How many toasts show in the collapsed stack. */
|
|
102
|
+
visibleToasts?: number;
|
|
103
|
+
/** Show every toast at full height instead of stacking them. */
|
|
104
|
+
expand?: boolean;
|
|
105
|
+
/** Show a bar that counts down the time left on timed toasts. */
|
|
106
|
+
progress?: boolean;
|
|
107
|
+
/** Components for icon names that toasts refer to, for toast types, and for the built-in icons, such as `dismiss`. */
|
|
108
|
+
icons?: Record<string, Component>;
|
|
109
|
+
/** Resolves the icons that `icons` does not have, in place of the global resolver of `setIconResolver()`. */
|
|
110
|
+
iconResolver?: IconResolverFn | null;
|
|
111
|
+
/** Class names added to the parts of each toast. */
|
|
112
|
+
classes?: ToastClasses;
|
|
113
|
+
/** Components that render the toasts of a type in place of the default markup, keyed by the type, such as `{ invite: InviteToast }`. */
|
|
114
|
+
components?: Record<string, Component>;
|
|
115
|
+
/** Keep the toasts usable above modal dialogs of other libraries, such as Radix and Reka, and above the notification center's panel. */
|
|
116
|
+
aboveModals?: boolean;
|
|
117
|
+
}> & Readonly<{}>, {
|
|
118
|
+
progress: boolean;
|
|
119
|
+
name: string;
|
|
120
|
+
label: string;
|
|
121
|
+
position: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
122
|
+
hotkey: readonly string[];
|
|
123
|
+
visibleToasts: number;
|
|
124
|
+
expand: boolean;
|
|
125
|
+
typeLabels: Partial<Record< ToastType, string>>;
|
|
126
|
+
icons: Record<string, Component>;
|
|
127
|
+
dismissLabel: TranslationValue;
|
|
128
|
+
iconResolver: IconResolverFn | null;
|
|
129
|
+
classes: Partial<Record<"progress" | "title" | "icon" | "actions" | "toast" | "action" | "description" | "dismiss", string>>;
|
|
130
|
+
components: Record<string, Component>;
|
|
131
|
+
aboveModals: boolean;
|
|
132
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>, {
|
|
133
|
+
/** Replaces the content of each toast. */
|
|
134
|
+
toast?(props: {
|
|
135
|
+
toast: Toast;
|
|
136
|
+
dismiss: () => void;
|
|
137
|
+
runAction: (index: number, event: MouseEvent) => void;
|
|
138
|
+
}): unknown;
|
|
139
|
+
/** Replaces the icon of each toast. */
|
|
140
|
+
icon?(props: {
|
|
141
|
+
toast: Toast;
|
|
142
|
+
}): unknown;
|
|
143
|
+
}>;
|
|
144
|
+
|
|
145
|
+
declare const __VLS_export_2: __VLS_WithSlots_2<typeof __VLS_base, __VLS_Slots>;
|
|
146
|
+
|
|
147
|
+
declare const __VLS_export_3: __VLS_WithSlots_3<typeof __VLS_base_2, __VLS_Slots_2>;
|
|
148
|
+
|
|
149
|
+
declare const __VLS_export_4: DefineComponent<NotificationItemProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<NotificationItemProps> & Readonly<{}>, {
|
|
150
|
+
snooze: (now: Date) => SnoozeOption[];
|
|
151
|
+
allowedActions: readonly InboxAction[];
|
|
152
|
+
selected: boolean;
|
|
153
|
+
pendingAction: number;
|
|
154
|
+
icons: Record<string, Component>;
|
|
155
|
+
iconResolver: IconResolverFn | null;
|
|
156
|
+
classes: InboxClasses;
|
|
157
|
+
labels: InboxLabels;
|
|
158
|
+
locale: string;
|
|
159
|
+
onSelectedChange: (selected: boolean) => void;
|
|
160
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
161
|
+
|
|
162
|
+
declare const __VLS_export_5: __VLS_WithSlots_4<typeof __VLS_base_3, __VLS_Slots_3>;
|
|
163
|
+
|
|
164
|
+
declare type __VLS_ModelProps = {
|
|
165
|
+
/** Whether the panel is open. Bind it with `v-model:open` to open and close the panel from elsewhere. */
|
|
166
|
+
'open'?: boolean;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
declare type __VLS_Props = {
|
|
170
|
+
/** Text of the notification center, in place of the `inbox_` translations; `:count` and `:title` are replaced. */
|
|
171
|
+
labels?: Partial<InboxLabels>;
|
|
172
|
+
/** What the bell shows when there are notifications: the number, a dot, or nothing. */
|
|
173
|
+
badge?: 'count' | 'dot' | 'none';
|
|
174
|
+
/** Which notifications the badge counts: those that arrived since the panel was last opened, or every unread one. */
|
|
175
|
+
count?: 'unseen' | 'unread';
|
|
176
|
+
/** The highest number the badge shows; larger counts show as this number with a plus, such as 99+. */
|
|
177
|
+
maxCount?: number;
|
|
178
|
+
/** The URL of a page with every notification; the panel then links to it. */
|
|
179
|
+
href?: string;
|
|
180
|
+
/** Components for the icon names that notifications refer to, and for the built-in icons, such as `bell`. */
|
|
181
|
+
icons?: Record<string, Component>;
|
|
182
|
+
/** Resolves the icons that `icons` does not have, in place of the global resolver of `setIconResolver()`. */
|
|
183
|
+
iconResolver?: IconResolverFn | null;
|
|
184
|
+
/** Class names added to the parts of the notification center. */
|
|
185
|
+
classes?: InboxClasses;
|
|
186
|
+
/** The locale of relative times and numbers; defaults to the browser's. */
|
|
187
|
+
locale?: string;
|
|
188
|
+
/** Show notifications with the same `InboxMessage::group()` key as one, with a button that shows the others. */
|
|
189
|
+
group?: boolean;
|
|
190
|
+
/** The snooze times to offer, from the current time, in place of the built-in ones. */
|
|
191
|
+
snooze?: (now: Date) => SnoozeOption[];
|
|
192
|
+
/** Where the panel opens next to the bell, such as `bottom-end`. It moves to the other side when there is no room. */
|
|
193
|
+
placement?: Placement;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
declare type __VLS_Props_2 = {
|
|
197
|
+
/** The name of the page prop that holds `Inbox::scroll()`. */
|
|
198
|
+
data: string;
|
|
199
|
+
/** The filter the page prop was loaded with, in place of the URL's `filter` query parameter; notifications that no longer match, such as archived ones in `all`, are hidden. */
|
|
200
|
+
filter?: InboxFilter;
|
|
201
|
+
/** Text of the list, in place of the `inbox_` translations; `:count` and `:title` are replaced. */
|
|
202
|
+
labels?: Partial<InboxLabels>;
|
|
203
|
+
/** Components for the icon names that notifications refer to, and for the built-in icons, such as `empty`. */
|
|
204
|
+
icons?: Record<string, Component>;
|
|
205
|
+
/** Resolves the icons that `icons` does not have, in place of the global resolver of `setIconResolver()`. */
|
|
206
|
+
iconResolver?: IconResolverFn | null;
|
|
207
|
+
classes?: InboxClasses;
|
|
208
|
+
locale?: string;
|
|
209
|
+
/** How far from the end of the list, in pixels, the next page starts loading. */
|
|
210
|
+
buffer?: number;
|
|
211
|
+
/** Load the next page with a button instead of when the end of the list scrolls into view. */
|
|
212
|
+
manual?: boolean;
|
|
213
|
+
/** Keep the URL when a page loads, instead of adding its cursor. */
|
|
214
|
+
preserveUrl?: boolean;
|
|
215
|
+
/** The category the page prop was loaded with, in place of the URL's `category` query parameter; notifications of other categories that arrive are hidden. */
|
|
216
|
+
category?: string | null;
|
|
217
|
+
/** Show notifications with the same `InboxMessage::group()` key as one, with a button that shows the others. */
|
|
218
|
+
group?: boolean;
|
|
219
|
+
/** The snooze times to offer, from the current time, in place of the built-in ones. */
|
|
220
|
+
snooze?: (now: Date) => SnoozeOption[];
|
|
221
|
+
/** The highest number the tabs and categories show; larger counts show as this number with a plus, such as 99+. */
|
|
222
|
+
maxCount?: number;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
declare type __VLS_Props_3 = {
|
|
226
|
+
/** Text of the component, in place of the `preferences_` translations; `:category`, `:channel`, `:day`, `:start`, `:end`, `:browser`, `:platform`, `:time`, and `:device` are replaced. */
|
|
227
|
+
labels?: Partial<PreferencesLabels>;
|
|
228
|
+
/** Class names added to the parts of the component. */
|
|
229
|
+
classes?: PreferencesClasses;
|
|
230
|
+
/** The locale of the weekday names of the notification hours and of when other devices were active; defaults to the browser's. */
|
|
231
|
+
locale?: string;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
declare type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
235
|
+
|
|
236
|
+
declare type __VLS_Slots = {
|
|
237
|
+
/** Replaces the content of each notification. It receives the props of the built-in `NotificationItem`. */
|
|
238
|
+
item?(props: NotificationItemProps): unknown;
|
|
239
|
+
/** Replaces the text shown when the selected tab has no notifications. */
|
|
240
|
+
empty?(props: {
|
|
241
|
+
filter: InboxFilter;
|
|
242
|
+
}): unknown;
|
|
243
|
+
/** Replaces the content of the bell button: the bell icon and the badge. */
|
|
244
|
+
trigger?(props: NotificationCenterTriggerProps): unknown;
|
|
245
|
+
/** Replaces the badge on the bell. It renders only while the count is above zero. */
|
|
246
|
+
badge?(props: NotificationCenterBadgeProps): unknown;
|
|
247
|
+
/** Replaces the top of the panel, with the title, the bulk actions, and the pause button. */
|
|
248
|
+
header?(props: NotificationCenterHeaderProps): unknown;
|
|
249
|
+
/** Replaces the content of each tab. */
|
|
250
|
+
tab?(props: NotificationCenterTabProps): unknown;
|
|
251
|
+
/** Replaces the spinner while the list loads. */
|
|
252
|
+
loading?(props: Record<string, never>): unknown;
|
|
253
|
+
/** Replaces the message and the button shown when loading the list, or its next page, failed. */
|
|
254
|
+
error?(props: NotificationCenterErrorProps): unknown;
|
|
255
|
+
/** Replaces the bottom of the panel, which links to `href` by default. */
|
|
256
|
+
footer?(props: NotificationCenterFooterProps): unknown;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
declare type __VLS_Slots_2 = {
|
|
260
|
+
/** Replaces the content of each notification. It receives the props of the built-in `NotificationItem`. */
|
|
261
|
+
item?(props: NotificationItemProps): unknown;
|
|
262
|
+
/** Replaces the text shown when there are no notifications. */
|
|
263
|
+
empty?(props: {
|
|
264
|
+
filter: InboxFilter;
|
|
265
|
+
}): unknown;
|
|
266
|
+
/** Replaces the top of the list, with the bulk actions and the pause button. */
|
|
267
|
+
header?(props: NotificationListHeaderProps): unknown;
|
|
268
|
+
/** Replaces the content of each tab. */
|
|
269
|
+
tab?(props: NotificationCenterTabProps): unknown;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
declare type __VLS_Slots_3 = {
|
|
273
|
+
/** Replaces the label, badge, and description of each category. */
|
|
274
|
+
category?(props: {
|
|
275
|
+
category: PreferenceCategory;
|
|
276
|
+
}): unknown;
|
|
277
|
+
/** Replaces the label and description of each group. */
|
|
278
|
+
group?(props: {
|
|
279
|
+
group: PreferenceGroup;
|
|
280
|
+
}): unknown;
|
|
281
|
+
/** Replaces the label of each channel's column. */
|
|
282
|
+
channel?(props: {
|
|
283
|
+
channel: PreferenceChannel;
|
|
284
|
+
}): unknown;
|
|
285
|
+
/** Replaces the text shown when there are no categories. */
|
|
286
|
+
empty?(): unknown;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
declare type __VLS_WithSlots<T, S> = T & {
|
|
290
|
+
new (): {
|
|
291
|
+
$slots: S;
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
declare type __VLS_WithSlots_2<T, S> = T & {
|
|
296
|
+
new (): {
|
|
297
|
+
$slots: S;
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
declare type __VLS_WithSlots_3<T, S> = T & {
|
|
302
|
+
new (): {
|
|
303
|
+
$slots: S;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
declare type __VLS_WithSlots_4<T, S> = T & {
|
|
308
|
+
new (): {
|
|
309
|
+
$slots: S;
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* A click on a notification or on an action, with what the package reads from it. Every handler takes this one type and
|
|
315
|
+
* each guard picks its parts from it, since a copy without `target` would take every click on a link for one on a button.
|
|
316
|
+
*/
|
|
317
|
+
declare type ActionClick = Pick<MouseEvent, 'button' | 'metaKey' | 'ctrlKey' | 'shiftKey' | 'altKey' | 'preventDefault'> & {
|
|
318
|
+
defaultPrevented?: boolean;
|
|
319
|
+
target?: EventTarget | null;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/** Which notifications that arrive in real time show as a toast. */
|
|
323
|
+
export declare type ArrivalToasts = 'requested' | 'all' | 'none';
|
|
324
|
+
|
|
325
|
+
declare const BATCH_ACTIONS: readonly ["read", "unread", "seen", "archive", "unarchive", "snooze", "unsnooze", "delete"];
|
|
326
|
+
|
|
327
|
+
/** The types that the Toaster has an icon and a color for. */
|
|
328
|
+
export declare type BuiltInToastType = 'default' | 'success' | 'info' | 'warning' | 'error' | 'loading';
|
|
329
|
+
|
|
330
|
+
export declare const DEFAULT_ERROR_MESSAGES: ErrorToastMessages;
|
|
331
|
+
|
|
332
|
+
/** Matches the default `flash_key` in `config/inertia-notifications.php`. */
|
|
333
|
+
declare const DEFAULT_FLASH_KEY = "inertiaui";
|
|
334
|
+
|
|
335
|
+
/** The English text of the notification center. Each label is the translation with the `inbox_` key, such as `inbox_mark_all_as_read` for `markAllAsRead`. */
|
|
336
|
+
export declare const DEFAULT_INBOX_LABELS: Record<"error" | "delete" | "all" | "unread" | "snoozed" | "archived" | "archive" | "unarchive" | "snooze" | "unsnooze" | "mute" | "pause" | "loading" | "snoozedUntil" | "title" | "muted" | "announcement" | "loadMore" | "markAsRead" | "markAsUnread" | "unmute" | "resume" | "markAllAsRead" | "archiveAll" | "pausedUntil" | "categories" | "retry" | "bell" | "bellNew" | "bellPaused" | "moreActions" | "itemControl" | "select" | "selectAll" | "selected" | "selection" | "readSelected" | "unreadSelected" | "snoozeSelected" | "unsnoozeSelected" | "archiveSelected" | "unarchiveSelected" | "deleteSelected" | "clearSelection" | "showNew" | "snoozeUntil" | "snoozeLaterToday" | "snoozeTomorrow" | "snoozeNextWeek" | "pauseFor" | "pauseTomorrow" | "showMore" | "showLess" | "unreadState" | "actorsAndOther" | "actorsAndOthers" | "empty" | "emptyUnread" | "emptyArchived" | "emptySnoozed" | "allCategories" | "viewAll", string>;
|
|
337
|
+
|
|
338
|
+
/** The English text of `<NotificationPreferences>`. Each label is the translation with the `preferences_` key, such as `preferences_locked` for `locked`. */
|
|
339
|
+
export declare const DEFAULT_PREFERENCES_LABELS: Record<"error" | "loading" | "title" | "category" | "retry" | "empty" | "toggle" | "frequency" | "notificationHours" | "locked" | "global" | "globalDescription" | "frequencyLabel" | "frequencyInstant" | "frequencyHourly" | "frequencyDaily" | "frequencyWeekly" | "pushDevice" | "pushOff" | "pushOn" | "pushTurnOn" | "pushTurnOff" | "pushTurningOn" | "pushTurningOff" | "pushBlocked" | "pushHomeScreen" | "pushInsecure" | "pushBrave" | "pushFailed" | "pushFailedOff" | "pushRetry" | "pushDevices" | "pushDeviceName" | "pushDeviceUnknown" | "pushDeviceActive" | "pushDeviceRemove" | "pushDeviceRemoveLabel" | "notificationHoursDescription" | "notificationHoursStart" | "notificationHoursEnd" | "notificationHoursDay" | "notificationHoursOff" | "notificationHoursAdd" | "notificationHoursAddLabel" | "notificationHoursRemove" | "notificationHoursRemoveLabel", string>;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* The English text of every built-in string. Each key starts with the part of the package it belongs to: `toaster_`,
|
|
343
|
+
* `toast_`, `error_toast_`, `inbox_` for the notification center and the `NotificationList`, and `preferences_`.
|
|
344
|
+
*/
|
|
345
|
+
declare const DEFAULT_TRANSLATIONS: {
|
|
346
|
+
toaster_label: string;
|
|
347
|
+
toaster_label_with_hotkey: string;
|
|
348
|
+
toaster_hotkey_alt: string;
|
|
349
|
+
toaster_hotkey_ctrl: string;
|
|
350
|
+
toaster_hotkey_meta: string;
|
|
351
|
+
toaster_hotkey_shift: string;
|
|
352
|
+
toaster_hotkey_separator: string;
|
|
353
|
+
toast_dismiss: string;
|
|
354
|
+
toast_count: string;
|
|
355
|
+
toast_type_default: string;
|
|
356
|
+
toast_type_success: string;
|
|
357
|
+
toast_type_info: string;
|
|
358
|
+
toast_type_warning: string;
|
|
359
|
+
toast_type_error: string;
|
|
360
|
+
toast_type_loading: string;
|
|
361
|
+
error_toast_403: string;
|
|
362
|
+
error_toast_419: string;
|
|
363
|
+
error_toast_419_description: string;
|
|
364
|
+
error_toast_429: string;
|
|
365
|
+
error_toast_429_description: string;
|
|
366
|
+
error_toast_5xx: string;
|
|
367
|
+
error_toast_5xx_description: string;
|
|
368
|
+
error_toast_network: string;
|
|
369
|
+
error_toast_network_description: string;
|
|
370
|
+
inbox_title: string;
|
|
371
|
+
inbox_bell: string;
|
|
372
|
+
inbox_bell_new: string;
|
|
373
|
+
inbox_bell_paused: string;
|
|
374
|
+
inbox_all: string;
|
|
375
|
+
inbox_unread: string;
|
|
376
|
+
inbox_archived: string;
|
|
377
|
+
inbox_snoozed: string;
|
|
378
|
+
inbox_mark_all_as_read: string;
|
|
379
|
+
inbox_archive_all: string;
|
|
380
|
+
inbox_more_actions: string;
|
|
381
|
+
inbox_item_control: string;
|
|
382
|
+
inbox_mark_as_read: string;
|
|
383
|
+
inbox_mark_as_unread: string;
|
|
384
|
+
inbox_archive: string;
|
|
385
|
+
inbox_unarchive: string;
|
|
386
|
+
inbox_snooze: string;
|
|
387
|
+
inbox_unsnooze: string;
|
|
388
|
+
inbox_mute: string;
|
|
389
|
+
inbox_unmute: string;
|
|
390
|
+
inbox_muted: string;
|
|
391
|
+
inbox_delete: string;
|
|
392
|
+
inbox_select: string;
|
|
393
|
+
inbox_select_all: string;
|
|
394
|
+
inbox_selected: string;
|
|
395
|
+
inbox_selection: string;
|
|
396
|
+
inbox_read_selected: string;
|
|
397
|
+
inbox_unread_selected: string;
|
|
398
|
+
inbox_snooze_selected: string;
|
|
399
|
+
inbox_unsnooze_selected: string;
|
|
400
|
+
inbox_archive_selected: string;
|
|
401
|
+
inbox_unarchive_selected: string;
|
|
402
|
+
inbox_delete_selected: string;
|
|
403
|
+
inbox_clear_selection: string;
|
|
404
|
+
inbox_show_new: string;
|
|
405
|
+
inbox_snooze_until: string;
|
|
406
|
+
inbox_snoozed_until: string;
|
|
407
|
+
inbox_snooze_later_today: string;
|
|
408
|
+
inbox_snooze_tomorrow: string;
|
|
409
|
+
inbox_snooze_next_week: string;
|
|
410
|
+
inbox_pause: string;
|
|
411
|
+
inbox_pause_for: string;
|
|
412
|
+
inbox_pause_tomorrow: string;
|
|
413
|
+
inbox_paused_until: string;
|
|
414
|
+
inbox_resume: string;
|
|
415
|
+
inbox_show_more: string;
|
|
416
|
+
inbox_show_less: string;
|
|
417
|
+
inbox_unread_state: string;
|
|
418
|
+
inbox_actors_and_other: string;
|
|
419
|
+
inbox_actors_and_others: string;
|
|
420
|
+
inbox_empty: string;
|
|
421
|
+
inbox_empty_unread: string;
|
|
422
|
+
inbox_empty_archived: string;
|
|
423
|
+
inbox_empty_snoozed: string;
|
|
424
|
+
inbox_error: string;
|
|
425
|
+
inbox_retry: string;
|
|
426
|
+
inbox_categories: string;
|
|
427
|
+
inbox_all_categories: string;
|
|
428
|
+
inbox_loading: string;
|
|
429
|
+
inbox_load_more: string;
|
|
430
|
+
inbox_view_all: string;
|
|
431
|
+
inbox_update_failed: string;
|
|
432
|
+
inbox_toast_view: string;
|
|
433
|
+
inbox_toast_view_alt: string;
|
|
434
|
+
inbox_title_count: string;
|
|
435
|
+
inbox_announcement: string;
|
|
436
|
+
preferences_title: string;
|
|
437
|
+
preferences_category: string;
|
|
438
|
+
preferences_toggle: string;
|
|
439
|
+
preferences_locked: string;
|
|
440
|
+
preferences_global: string;
|
|
441
|
+
preferences_global_description: string;
|
|
442
|
+
preferences_frequency: string;
|
|
443
|
+
preferences_frequency_label: string;
|
|
444
|
+
preferences_frequency_instant: string;
|
|
445
|
+
preferences_frequency_hourly: string;
|
|
446
|
+
preferences_frequency_daily: string;
|
|
447
|
+
preferences_frequency_weekly: string;
|
|
448
|
+
preferences_push_device: string;
|
|
449
|
+
preferences_push_off: string;
|
|
450
|
+
preferences_push_on: string;
|
|
451
|
+
preferences_push_turn_on: string;
|
|
452
|
+
preferences_push_turn_off: string;
|
|
453
|
+
preferences_push_turning_on: string;
|
|
454
|
+
preferences_push_turning_off: string;
|
|
455
|
+
preferences_push_blocked: string;
|
|
456
|
+
preferences_push_home_screen: string;
|
|
457
|
+
preferences_push_insecure: string;
|
|
458
|
+
preferences_push_brave: string;
|
|
459
|
+
preferences_push_failed: string;
|
|
460
|
+
preferences_push_failed_off: string;
|
|
461
|
+
preferences_push_retry: string;
|
|
462
|
+
preferences_push_devices: string;
|
|
463
|
+
preferences_push_device_name: string;
|
|
464
|
+
preferences_push_device_unknown: string;
|
|
465
|
+
preferences_push_device_active: string;
|
|
466
|
+
preferences_push_device_remove: string;
|
|
467
|
+
preferences_push_device_remove_label: string;
|
|
468
|
+
preferences_notification_hours: string;
|
|
469
|
+
preferences_notification_hours_description: string;
|
|
470
|
+
preferences_notification_hours_start: string;
|
|
471
|
+
preferences_notification_hours_end: string;
|
|
472
|
+
preferences_notification_hours_day: string;
|
|
473
|
+
preferences_notification_hours_off: string;
|
|
474
|
+
preferences_notification_hours_add: string;
|
|
475
|
+
preferences_notification_hours_add_label: string;
|
|
476
|
+
preferences_notification_hours_remove: string;
|
|
477
|
+
preferences_notification_hours_remove_label: string;
|
|
478
|
+
preferences_empty: string;
|
|
479
|
+
preferences_loading: string;
|
|
480
|
+
preferences_error: string;
|
|
481
|
+
preferences_retry: string;
|
|
482
|
+
preferences_save_failed: string;
|
|
483
|
+
preferences_push_device_remove_failed: string;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
export declare interface DurationOptions {
|
|
487
|
+
/**
|
|
488
|
+
* Milliseconds that toasts without a duration stay open. A function decides per toast, including errors.
|
|
489
|
+
* By default, the duration grows with the length of the toast, from 5 to 12 seconds.
|
|
490
|
+
*/
|
|
491
|
+
duration?: number | ((toast: ToastContent) => number | null);
|
|
492
|
+
/** Keep error toasts open until the user dismisses them. Defaults to `true`. */
|
|
493
|
+
persistentErrors?: boolean;
|
|
494
|
+
/** Multiplies the duration of every timed toast, such as for users who need more time to read. Defaults to `1`. */
|
|
495
|
+
durationScale?: number;
|
|
496
|
+
/** Set to `false` to keep every toast open until the user dismisses it. */
|
|
497
|
+
autoDismiss?: boolean;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/** The parts of a Laravel Echo channel that the notification center uses. */
|
|
501
|
+
export declare interface EchoChannelLike {
|
|
502
|
+
listen(event: string, callback: (payload: unknown) => void): unknown;
|
|
503
|
+
stopListening(event: string, callback?: (payload: unknown) => void): unknown;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** The parts of Laravel Echo that the notification center uses, from `laravel-echo` or an `@laravel/echo-*` package. */
|
|
507
|
+
export declare interface EchoLike {
|
|
508
|
+
private(channel: string): EchoChannelLike;
|
|
509
|
+
socketId(): string | null | undefined;
|
|
510
|
+
connector?: {
|
|
511
|
+
onConnectionChange?(callback: (status: string) => void): unknown;
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
export declare interface ErrorToastContent {
|
|
516
|
+
title: string;
|
|
517
|
+
description?: string;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Toasts for failed requests, instead of Inertia's error page dialog. Keys are HTTP status codes, `5xx` for any
|
|
522
|
+
* server error, and `network` for requests that got no response. `false` leaves a status to Inertia.
|
|
523
|
+
*/
|
|
524
|
+
export declare type ErrorToastMessages = Partial<Record<number | '5xx' | 'network', ErrorToastContent | false>>;
|
|
525
|
+
|
|
526
|
+
/** A toast as the server flashes it, under `toasts` in the package's flash data. */
|
|
527
|
+
export declare interface FlashedToast {
|
|
528
|
+
/** Unique per flash. */
|
|
529
|
+
uuid: string;
|
|
530
|
+
id?: string;
|
|
531
|
+
type: ToastType;
|
|
532
|
+
title: string;
|
|
533
|
+
description?: string;
|
|
534
|
+
/** Absent for the frontend default; `null` for a persistent toast. */
|
|
535
|
+
duration?: number | null;
|
|
536
|
+
actions?: Array<Omit<ToastAction, 'onClick'>>;
|
|
537
|
+
icon?: string | false;
|
|
538
|
+
/** Set with `->image()`. */
|
|
539
|
+
image?: string;
|
|
540
|
+
dismissible?: boolean;
|
|
541
|
+
position?: ToastPosition;
|
|
542
|
+
toaster?: string;
|
|
543
|
+
/** Set with `->with()`. */
|
|
544
|
+
data?: Record<string, unknown>;
|
|
545
|
+
/** Set with `->progress()`, from 0 to 1. */
|
|
546
|
+
progress?: number;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** Whether the frequency of the category changes anything: the user receives the category on a channel that digests hold. */
|
|
550
|
+
declare const frequencyApplies: (category: PreferenceCategory, channels: readonly PreferenceChannel[]) => boolean;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Groups notifications by their group key, at the place of the newest one. Notifications without a key stay alone, and
|
|
554
|
+
* so does every notification when `group` is false.
|
|
555
|
+
*/
|
|
556
|
+
export declare function groupItems(items: readonly InboxItem[], group?: boolean): InboxGroup[];
|
|
557
|
+
|
|
558
|
+
declare interface HttpResponseLike {
|
|
559
|
+
status?: number;
|
|
560
|
+
data: unknown;
|
|
561
|
+
headers: Record<string, string>;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/** Where an icon renders, such as `{ component: 'NotificationCenter', part: 'bell' }`, passed as the second argument of a resolver. */
|
|
565
|
+
export declare type IconContext = Record<string, unknown>;
|
|
566
|
+
|
|
567
|
+
/** Returns the component, or the name of a registered component, for an icon name, or `null` or `undefined` to keep the built-in icon. */
|
|
568
|
+
export declare type IconResolverFn = (icon: string, context: IconContext) => Component | string | null | undefined;
|
|
569
|
+
|
|
570
|
+
/** What users may do with their notifications besides reading them, as the server's `inbox.actions` config offers it. */
|
|
571
|
+
export declare type InboxAction = 'snooze' | 'archive' | 'mute' | 'delete';
|
|
572
|
+
|
|
573
|
+
/** The methods of the store that the `useNotifications()` hooks return, for building a custom bell or panel. */
|
|
574
|
+
declare type InboxActions = Omit<InboxStore, 'subscribe' | 'getSnapshot' | 'connect' | 'sync' | 'apply' | 'belongs' | 'remember' | 'onArrival' | 'onChange' | 'getServerSnapshot' | 'loadArrival'>;
|
|
575
|
+
|
|
576
|
+
/** The person or thing that caused a notification, such as the user who commented. */
|
|
577
|
+
export declare interface InboxActor {
|
|
578
|
+
name?: string;
|
|
579
|
+
avatar?: string;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/** What `batch()` does to the notifications it is given. */
|
|
583
|
+
export declare type InboxBatchAction = (typeof BATCH_ACTIONS)[number];
|
|
584
|
+
|
|
585
|
+
/** A change of the notification center, from the user's other sessions or from the server's response to a change. */
|
|
586
|
+
export declare type InboxChange = {
|
|
587
|
+
kind: 'item';
|
|
588
|
+
id: string;
|
|
589
|
+
readAt: string | null;
|
|
590
|
+
seenAt: string | null;
|
|
591
|
+
archivedAt: string | null;
|
|
592
|
+
snoozedUntil: string | null;
|
|
593
|
+
result: string | null;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Bulk changes cover the notifications created before `before`, and those created at that time whose IDs are in `ids`, or all of them
|
|
597
|
+
* when `ids` is null. A `category` limits them to the notifications of that category.
|
|
598
|
+
*/
|
|
599
|
+
| {
|
|
600
|
+
kind: 'read' | 'seen';
|
|
601
|
+
before: string;
|
|
602
|
+
ids: readonly string[] | null;
|
|
603
|
+
category: string | null;
|
|
604
|
+
} | {
|
|
605
|
+
kind: 'archive';
|
|
606
|
+
before: string;
|
|
607
|
+
ids: readonly string[] | null;
|
|
608
|
+
category: string | null;
|
|
609
|
+
onlyRead: boolean;
|
|
610
|
+
}
|
|
611
|
+
/** The notifications with these IDs were deleted, such as by the user or by `Inbox::retract()` on the server. */
|
|
612
|
+
| {
|
|
613
|
+
kind: 'delete';
|
|
614
|
+
ids: readonly string[];
|
|
615
|
+
}
|
|
616
|
+
/** The server replaced the message of the notification with `Inbox::update()`. The item holds its new title, body, and data. */
|
|
617
|
+
| {
|
|
618
|
+
kind: 'update';
|
|
619
|
+
item: InboxItem;
|
|
620
|
+
}
|
|
621
|
+
/** The notifications with these IDs were changed at `at`, such as marked as read with `batch()`. A snooze lasts `until`. */
|
|
622
|
+
| {
|
|
623
|
+
kind: 'items';
|
|
624
|
+
action: Exclude<InboxBatchAction, 'delete'>;
|
|
625
|
+
ids: readonly string[];
|
|
626
|
+
at: string;
|
|
627
|
+
until?: string;
|
|
628
|
+
}
|
|
629
|
+
/** The user muted or unmuted the thread of the group key, with `mute()` or `unmute()`. */
|
|
630
|
+
| {
|
|
631
|
+
kind: 'mute';
|
|
632
|
+
group: string;
|
|
633
|
+
muted: boolean;
|
|
634
|
+
}
|
|
635
|
+
/** The user paused notifications until `until` with `pause()`, or resumed them with `resume()`, when it is `null`. */
|
|
636
|
+
| {
|
|
637
|
+
kind: 'pause';
|
|
638
|
+
until: string | null;
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
/** Class names added to the parts of the notification center and its notifications. */
|
|
642
|
+
export declare interface InboxClasses {
|
|
643
|
+
bell?: string;
|
|
644
|
+
badge?: string;
|
|
645
|
+
panel?: string;
|
|
646
|
+
list?: string;
|
|
647
|
+
item?: string;
|
|
648
|
+
media?: string;
|
|
649
|
+
title?: string;
|
|
650
|
+
body?: string;
|
|
651
|
+
time?: string;
|
|
652
|
+
action?: string;
|
|
653
|
+
/** The result of an action that ran, such as "Approved", in place of the actions. */
|
|
654
|
+
result?: string;
|
|
655
|
+
/** The actors of a notification that later ones collapsed into, such as "Sophie and 3 others". */
|
|
656
|
+
actors?: string;
|
|
657
|
+
control?: string;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export declare interface InboxCounts {
|
|
661
|
+
/** Notifications in the inbox that the user has not read. */
|
|
662
|
+
unread: number;
|
|
663
|
+
/** Notifications in the inbox that arrived since the user last opened it. */
|
|
664
|
+
unseen: number;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** A built-in filter of the notification list, or the key of a tab that the application added in the `inbox.tabs` config. */
|
|
668
|
+
export declare type InboxFilter = 'all' | 'unread' | 'snoozed' | 'archived' | (string & {});
|
|
669
|
+
|
|
670
|
+
/** A notification with the notifications of the same group that follow it in the list. */
|
|
671
|
+
export declare interface InboxGroup {
|
|
672
|
+
/** The same while the group's notifications change: `group:` and the group key, or the notification's ID when it has no group. */
|
|
673
|
+
key: string;
|
|
674
|
+
item: InboxItem;
|
|
675
|
+
others: InboxItem[];
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/** A notification in the notification center, as the server sends it. */
|
|
679
|
+
export declare interface InboxItem {
|
|
680
|
+
id: string;
|
|
681
|
+
type: string;
|
|
682
|
+
title: string;
|
|
683
|
+
body: string | null;
|
|
684
|
+
icon: string | null;
|
|
685
|
+
image: string | null;
|
|
686
|
+
url: string | null;
|
|
687
|
+
actions: readonly ToastAction<InboxItem>[];
|
|
688
|
+
actor: InboxActor | null;
|
|
689
|
+
/** The newest actors of a notification that later ones collapsed into with `InboxMessage::collapse()`, newest first. */
|
|
690
|
+
actors: readonly InboxActor[];
|
|
691
|
+
/** The number of different actors, also those that `actors` leaves out. */
|
|
692
|
+
actorCount: number;
|
|
693
|
+
/** The number of notifications that collapsed into this one, including itself. */
|
|
694
|
+
total: number;
|
|
695
|
+
category: string | null;
|
|
696
|
+
group: string | null;
|
|
697
|
+
/** The type of the toast that `InboxMessage::toast()` asked for, shown when the notification arrives in real time. */
|
|
698
|
+
toast: ToastType | null;
|
|
699
|
+
/** Extra data from `InboxMessage::with()`. */
|
|
700
|
+
data: Record<string, unknown>;
|
|
701
|
+
readAt: string | null;
|
|
702
|
+
seenAt: string | null;
|
|
703
|
+
archivedAt: string | null;
|
|
704
|
+
/** The notification is left out of the inbox and its counts until this time. */
|
|
705
|
+
snoozedUntil: string | null;
|
|
706
|
+
/** The result of an action that ran, such as "Approved", which shows in place of the actions. */
|
|
707
|
+
result: string | null;
|
|
708
|
+
/** Whether the user muted the thread of the notification's group key, so later notifications in it no longer reach them. */
|
|
709
|
+
muted: boolean;
|
|
710
|
+
/** Sent outside the user's notification hours or while they paused, so it arrives without a toast, a sound, or a desktop notification. */
|
|
711
|
+
quiet?: true;
|
|
712
|
+
createdAt: string;
|
|
713
|
+
/** When the server read this copy of the notification, in microseconds, which orders it against other copies and changes. `null` when unknown. */
|
|
714
|
+
revision: number | null;
|
|
715
|
+
/** Whether this is an announcement, which `Announcement::publish()` stores once for every user in its audience. */
|
|
716
|
+
announcement: boolean;
|
|
717
|
+
/** The announcement leaves the notification center at this time. `null` for notifications and announcements without an expiry. */
|
|
718
|
+
expiresAt: string | null;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/** The text of the notification center: strings with placeholders, or functions that receive the parameters. */
|
|
722
|
+
export declare type InboxLabels = Record<keyof typeof DEFAULT_INBOX_LABELS, TranslationValue>;
|
|
723
|
+
|
|
724
|
+
export declare interface InboxState {
|
|
725
|
+
/** The URL of the inbox routes, from the shared prop; `undefined` until a signed-in page was shown. */
|
|
726
|
+
url: string | undefined;
|
|
727
|
+
/** An opaque identity of the signed-in user, from the shared prop. The store forgets everything when it changes. */
|
|
728
|
+
user: string | undefined;
|
|
729
|
+
/** The private channel that receives the user's broadcast notifications, from the shared prop. */
|
|
730
|
+
channel: string | null;
|
|
731
|
+
/** The private channel that announcements are broadcast on, from the shared prop. `null` unless the server broadcasts them. */
|
|
732
|
+
announcementsChannel: string | null;
|
|
733
|
+
/**
|
|
734
|
+
* What the user may do with notifications besides reading them, from the server's `inbox.actions` config. The panel
|
|
735
|
+
* shows no buttons or tabs for the other actions, and the store skips them.
|
|
736
|
+
*/
|
|
737
|
+
allowedActions: readonly InboxAction[];
|
|
738
|
+
/**
|
|
739
|
+
* Whether the user may select notifications to change them together, from the server's `inbox.selectable` config.
|
|
740
|
+
* While it is `false`, the panel has no checkboxes, and `batch()` only marks notifications as seen.
|
|
741
|
+
*/
|
|
742
|
+
selectable: boolean;
|
|
743
|
+
/** The categories that the panel filters by, with their labels, in order, from the server's `inbox.category_filter` config. */
|
|
744
|
+
categoryFilter: Readonly<Record<string, string>>;
|
|
745
|
+
/** The tabs that the application added in the server's `inbox.tabs` config, by key. */
|
|
746
|
+
tabs: Readonly<Record<string, InboxTab>>;
|
|
747
|
+
counts: InboxCounts;
|
|
748
|
+
/** The notifications the panel loaded for `filter`, and those that arrived since, with the user's changes applied. */
|
|
749
|
+
items: readonly InboxItem[];
|
|
750
|
+
/** Notifications that arrived in real time, newest first, without the user's changes. Lists from pages show them first. */
|
|
751
|
+
arrived: readonly InboxItem[];
|
|
752
|
+
filter: InboxFilter;
|
|
753
|
+
/** The category the panel's list shows, or `null` for every category. */
|
|
754
|
+
category: string | null;
|
|
755
|
+
/** The unread notifications in the inbox, by category. Categories without unread notifications are left out. */
|
|
756
|
+
categoryCounts: Readonly<Record<string, number>>;
|
|
757
|
+
status: 'idle' | 'loading' | 'ready' | 'error';
|
|
758
|
+
loadingMore: boolean;
|
|
759
|
+
/** Loading the next page failed; it loads again only when asked with `loadMore({ retry: true })` or when the list reloads. */
|
|
760
|
+
moreFailed: boolean;
|
|
761
|
+
hasMore: boolean;
|
|
762
|
+
/** The index of the running action, by notification ID. */
|
|
763
|
+
pendingActions: Readonly<Record<string, number>>;
|
|
764
|
+
/**
|
|
765
|
+
* Notifications are paused until this time, so they arrive without a toast, a sound, or a desktop notification, and
|
|
766
|
+
* emails wait. `null` while they are not paused, once the time has passed, and while the application does not offer pausing.
|
|
767
|
+
*/
|
|
768
|
+
pausedUntil: string | null;
|
|
769
|
+
/** Whether the application offers pausing notifications, from the shared prop. */
|
|
770
|
+
canPause: boolean;
|
|
771
|
+
/** The times of the pause button, from the server's `pause.presets` config: numbers of minutes, and `'tomorrow'`. */
|
|
772
|
+
pausePresets: readonly PausePreset[];
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
export declare interface InboxStore {
|
|
776
|
+
subscribe(listener: () => void): () => void;
|
|
777
|
+
getSnapshot(): InboxState;
|
|
778
|
+
/**
|
|
779
|
+
* The state before any page was shown, which the server renders. Components render it until they mount, so the
|
|
780
|
+
* first render in the browser matches the server's HTML even when the store received the first page before.
|
|
781
|
+
*/
|
|
782
|
+
getServerSnapshot(): InboxState;
|
|
783
|
+
connect(bindings: InertiaBindings, options?: {
|
|
784
|
+
prop?: string;
|
|
785
|
+
onFailure?: (error: unknown) => void;
|
|
786
|
+
}): void;
|
|
787
|
+
/**
|
|
788
|
+
* Reads the counts and URL from the shared prop of a page, and forgets everything when the user signed out or
|
|
789
|
+
* another user signed in. Ignores pages from history and the prefetch cache, whose props may be outdated.
|
|
790
|
+
*/
|
|
791
|
+
sync(props: Record<string, unknown> | undefined, type: NavigationType_2): void;
|
|
792
|
+
/** Loads the first page of the filter, in one category or every one. A filter without a category shows every category. */
|
|
793
|
+
load(filter?: InboxFilter, category?: string | null): Promise<void>;
|
|
794
|
+
/** Loads the next page. After a failure, only with `retry`, so a list that stays in view does not try again and again. */
|
|
795
|
+
loadMore(options?: {
|
|
796
|
+
retry?: boolean;
|
|
797
|
+
}): Promise<void>;
|
|
798
|
+
/** Requests the counts from the server. */
|
|
799
|
+
refresh(): Promise<void>;
|
|
800
|
+
/**
|
|
801
|
+
* Requests a notification or announcement that the server broadcast as new without its content, such as a published
|
|
802
|
+
* announcement, and adds it like `receive()`. The server only finds it for the users who see it, so for other users,
|
|
803
|
+
* and in another context than the item's own, nothing changes. Returns the notification, or `undefined`.
|
|
804
|
+
*/
|
|
805
|
+
loadArrival(id: string, context?: string | null): Promise<InboxItem | undefined>;
|
|
806
|
+
/**
|
|
807
|
+
* Adds a notification that arrived in real time, such as from Laravel Echo, and counts it unless the counts
|
|
808
|
+
* already include it. Returns the notification, or `undefined` when it is invalid or arrived before.
|
|
809
|
+
*
|
|
810
|
+
* A notification that collapsed into one the store already has comes with the `counts` after it, so it replaces
|
|
811
|
+
* the earlier copy in the counts instead of adding to them.
|
|
812
|
+
*/
|
|
813
|
+
receive(value: unknown, counts?: unknown): InboxItem | undefined;
|
|
814
|
+
/**
|
|
815
|
+
* Calls the listener once for each notification that `receive()` adds, such as one from Laravel Echo or a snoozed
|
|
816
|
+
* notification that came back, after the store shows it. Returns a function that stops it.
|
|
817
|
+
*/
|
|
818
|
+
onArrival(listener: (item: InboxItem) => void): () => void;
|
|
819
|
+
/** Applies a change from another session of the user, with the counts after it: an `InboxChanged` broadcast. */
|
|
820
|
+
receiveChange(value: unknown): void;
|
|
821
|
+
/**
|
|
822
|
+
* Calls the listener once for each change that `receiveChange()` applies, such as a notification that the server
|
|
823
|
+
* updated or retracted. Returns a function that stops it.
|
|
824
|
+
*/
|
|
825
|
+
onChange(listener: (change: InboxChange) => void): () => void;
|
|
826
|
+
/** Applies the user's changes, such as marking as read, to a notification from a page prop. */
|
|
827
|
+
apply(item: InboxItem): InboxItem;
|
|
828
|
+
/** Whether a notification belongs in the list for the filter and category, after the user's changes. */
|
|
829
|
+
belongs(item: InboxItem, filter: InboxFilter, category?: string | null): boolean;
|
|
830
|
+
/** Remembers notifications that a page shows, so bulk actions cover them. */
|
|
831
|
+
remember(items: readonly InboxItem[]): void;
|
|
832
|
+
/** Marks a notification as read: one that a list shows, or the ID of one, such as from a toast. */
|
|
833
|
+
markAsRead(item: InboxItem | string): Promise<void>;
|
|
834
|
+
markAsUnread(item: InboxItem): Promise<void>;
|
|
835
|
+
/** Archives the notification. Does nothing while the server's `inbox.actions` config leaves out archiving, like `unarchive()`. */
|
|
836
|
+
archive(item: InboxItem): Promise<void>;
|
|
837
|
+
unarchive(item: InboxItem): Promise<void>;
|
|
838
|
+
/**
|
|
839
|
+
* Leaves the notification out of the inbox and its counts until the given time. Does nothing while the server's
|
|
840
|
+
* `inbox.actions` config leaves out snoozing, like `unsnooze()`.
|
|
841
|
+
*/
|
|
842
|
+
snooze(item: InboxItem, until: Date | string): Promise<void>;
|
|
843
|
+
unsnooze(item: InboxItem): Promise<void>;
|
|
844
|
+
/** Deletes the notification for good. Does nothing unless the server's `inbox.actions` config offers deleting. */
|
|
845
|
+
delete(item: InboxItem): Promise<void>;
|
|
846
|
+
/**
|
|
847
|
+
* Saves the `result` of the notification's action at the index, such as "Approved", which then shows in place of its
|
|
848
|
+
* actions. Takes a notification that a list shows, or the ID of one, such as from a toast. `runAction()` calls it
|
|
849
|
+
* once an action with a result ran.
|
|
850
|
+
*/
|
|
851
|
+
complete(item: InboxItem | string, index: number): Promise<void>;
|
|
852
|
+
/**
|
|
853
|
+
* Mutes the thread of the notification's group key, so later notifications in it no longer reach the user, unless
|
|
854
|
+
* they mention the user. The notifications in it that the user has stay. Does nothing without a group key, and while
|
|
855
|
+
* the server's `inbox.actions` config leaves out muting, like `unmute()`.
|
|
856
|
+
*/
|
|
857
|
+
mute(item: InboxItem): Promise<void>;
|
|
858
|
+
/** Unmutes the thread of the notification's group key. */
|
|
859
|
+
unmute(item: InboxItem): Promise<void>;
|
|
860
|
+
/**
|
|
861
|
+
* Pauses notifications until the given time: they arrive without a toast, a sound, or a desktop notification, and
|
|
862
|
+
* emails wait. Does nothing while the application does not offer pausing.
|
|
863
|
+
*/
|
|
864
|
+
pause(until: Date | string): Promise<void>;
|
|
865
|
+
/** Resumes paused notifications. */
|
|
866
|
+
resume(): Promise<void>;
|
|
867
|
+
/**
|
|
868
|
+
* Marks the given notifications as read, unread, or seen, archives or unarchives them, snoozes them until the given
|
|
869
|
+
* time or unsnoozes them, or deletes them, in one request for every 100 notifications. Does nothing for an action
|
|
870
|
+
* that the server's `inbox.actions` config leaves out, such as deleting by default, and for every action but
|
|
871
|
+
* `'seen'` while the server's `inbox.selectable` config is off.
|
|
872
|
+
*/
|
|
873
|
+
batch(action: InboxBatchAction, items: readonly InboxItem[], until?: Date | string): Promise<void>;
|
|
874
|
+
/**
|
|
875
|
+
* Marks the notifications of the selected category, or of every category, as read. A `category` option, or `null`
|
|
876
|
+
* for every category, takes the place of the selected one, such as the category of a page's `NotificationList`.
|
|
877
|
+
*/
|
|
878
|
+
markAllAsRead(options?: {
|
|
879
|
+
category?: string | null;
|
|
880
|
+
}): Promise<void>;
|
|
881
|
+
/** Marks every notification as seen, whatever the selected category. */
|
|
882
|
+
markAllAsSeen(): Promise<void>;
|
|
883
|
+
/**
|
|
884
|
+
* Archives the notifications of the selected category, or of every category, or only the read ones. Like
|
|
885
|
+
* `markAllAsRead()`, it takes a `category` option. Does nothing while the server's `inbox.actions` config leaves
|
|
886
|
+
* out archiving.
|
|
887
|
+
*/
|
|
888
|
+
archiveAll(options?: {
|
|
889
|
+
onlyRead?: boolean;
|
|
890
|
+
category?: string | null;
|
|
891
|
+
}): Promise<void>;
|
|
892
|
+
/**
|
|
893
|
+
* Call when a panel that shows the list opens: loads the list when it is not loaded yet or new notifications
|
|
894
|
+
* arrived, then marks the loaded notifications as seen. Notifications that arrive while it is open are seen too.
|
|
895
|
+
* With the panel's tabs, a list of another filter switches to the first tab. With the panel's categories, a list
|
|
896
|
+
* of another category, which another panel selected, switches to every category. A panel that marks the
|
|
897
|
+
* notifications it shows as seen itself, such as the `NotificationCenter`, passes `markAllAsSeen: false`.
|
|
898
|
+
*/
|
|
899
|
+
opened(tabs?: readonly InboxFilter[], options?: {
|
|
900
|
+
markAllAsSeen?: boolean;
|
|
901
|
+
categories?: readonly string[];
|
|
902
|
+
}): Promise<void>;
|
|
903
|
+
/** Call when a panel that called `opened()` closes, with the same options. */
|
|
904
|
+
closed(options?: {
|
|
905
|
+
markAllAsSeen?: boolean;
|
|
906
|
+
}): void;
|
|
907
|
+
/**
|
|
908
|
+
* Marks the notification as read and visits its URL, if it has one. A modified click, such as one that opens a new
|
|
909
|
+
* tab, is left to the browser, and a click whose default was prevented, such as by an `onItemClick` listener, does
|
|
910
|
+
* nothing.
|
|
911
|
+
*/
|
|
912
|
+
open(item: InboxItem, event?: ActionClick): void;
|
|
913
|
+
/**
|
|
914
|
+
* Marks the notification as read and runs one of its actions. A click on a link that opens with a modifier key, in a
|
|
915
|
+
* new tab, or in the browser, or that leads to another origin, is left to the browser; everything else runs the
|
|
916
|
+
* action, such as a click on a button. A click whose default was prevented, such as by an `onAction` listener, does
|
|
917
|
+
* nothing. An action with a `result` saves it with `complete()` once it succeeded, and a link that the browser loads
|
|
918
|
+
* in this tab waits for the result to save.
|
|
919
|
+
*/
|
|
920
|
+
runAction(item: InboxItem, index: number, event?: ActionClick): void;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/** The store shared by every notification center and list in the application. */
|
|
924
|
+
export declare const inboxStore: InboxStore;
|
|
925
|
+
|
|
926
|
+
/** A tab that the application added in the `inbox.tabs` config: the notifications of a category, with the given data. */
|
|
927
|
+
export declare interface InboxTab {
|
|
928
|
+
label: string;
|
|
929
|
+
category: string | null;
|
|
930
|
+
/** Values of the `InboxMessage::with()` data that the notifications have. */
|
|
931
|
+
data: Readonly<Record<string, string | number | boolean>>;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/** The parts of the Inertia adapter the core uses; each framework package passes its own. */
|
|
935
|
+
declare interface InertiaBindings {
|
|
936
|
+
onFlash(listener: (flash: Record<string, unknown>) => void): void;
|
|
937
|
+
/** Returns the headers to send with a request. */
|
|
938
|
+
onRequest(listener: (config: {
|
|
939
|
+
url: string;
|
|
940
|
+
headers?: Record<string, unknown>;
|
|
941
|
+
}) => Record<string, unknown> | undefined): void;
|
|
942
|
+
onResponse(listener: (response: HttpResponseLike) => void): void;
|
|
943
|
+
onError(listener: (error: unknown) => void): void;
|
|
944
|
+
/** Return `false` to stop Inertia from showing the response in its error dialog. */
|
|
945
|
+
onHttpException(listener: (response: HttpResponseLike) => boolean | void): void;
|
|
946
|
+
/**
|
|
947
|
+
* Runs when a page is shown or updated: the first page, after every visit (including a redirect back to the same
|
|
948
|
+
* URL and a partial reload), and after back or forward navigation.
|
|
949
|
+
*/
|
|
950
|
+
onNavigate(listener: (props: Record<string, unknown>, type: NavigationType_2) => void): void;
|
|
951
|
+
visit(href: string, options: Record<string, unknown>): void;
|
|
952
|
+
/** Sends a JSON request through Inertia's HTTP client, which adds the CSRF token, and returns the parsed body. */
|
|
953
|
+
request(method: 'get' | 'post', url: string, data?: Record<string, unknown>): Promise<unknown>;
|
|
954
|
+
/**
|
|
955
|
+
* Sends the socket ID that `resolve` returns with Inertia's requests, as `X-Socket-Id`, so the server can leave
|
|
956
|
+
* this browser out of a broadcast with `toOthers()`. Ignored when the application chose its own resolver.
|
|
957
|
+
*/
|
|
958
|
+
useSocketId(resolve: () => string | null | undefined): void;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* The package's part of Inertia's flash data. Add it to your own flash data type; pass the `flash_key` from
|
|
963
|
+
* `config/inertia-notifications.php` when you changed it.
|
|
964
|
+
*
|
|
965
|
+
* @example
|
|
966
|
+
* declare module '@inertiajs/core' {
|
|
967
|
+
* export interface InertiaConfig {
|
|
968
|
+
* flashDataType: InertiaUIFlashData & { message?: string }
|
|
969
|
+
* }
|
|
970
|
+
* }
|
|
971
|
+
*/
|
|
972
|
+
export declare type InertiaUIFlashData<Key extends string = typeof DEFAULT_FLASH_KEY> = {
|
|
973
|
+
[K in Key]?: {
|
|
974
|
+
toasts?: FlashedToast[];
|
|
975
|
+
};
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Call before `createInertiaApp()` so toasts flashed on pages without a Toaster are kept until one renders.
|
|
980
|
+
* The Toaster also calls it, so it is only required to change options.
|
|
981
|
+
*/
|
|
982
|
+
export declare function initNotifications(options?: NotificationsOptions): void;
|
|
983
|
+
|
|
984
|
+
/** Whether the notification is snoozed until a time that has not come yet, by the given clock in milliseconds or else now. */
|
|
985
|
+
export declare const isSnoozed: (item: Pick<InboxItem, "snoozedUntil">, now?: number) => boolean;
|
|
986
|
+
|
|
987
|
+
/** How a page was shown. Pages from `history` and the prefetch cache (`cached`) may carry outdated props. */
|
|
988
|
+
declare type NavigationType_2 = 'initial' | 'visit' | 'history' | 'cached';
|
|
989
|
+
|
|
990
|
+
export declare const NotificationCenter: typeof __VLS_export_2;
|
|
991
|
+
|
|
992
|
+
/** What the `badge` slot and `renderBadge` prop receive. They render only while the count is above zero. */
|
|
993
|
+
export declare interface NotificationCenterBadgeProps {
|
|
994
|
+
count: number;
|
|
995
|
+
/** The count as the built-in badge shows it, such as "99+". */
|
|
996
|
+
text: string;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/** What the `error` slot and `renderError` prop receive: loading the list failed, or with `more`, its next page. */
|
|
1000
|
+
export declare interface NotificationCenterErrorProps {
|
|
1001
|
+
more: boolean;
|
|
1002
|
+
retry(): void;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/** What the `footer` slot and `renderFooter` prop receive: the bottom of the panel. */
|
|
1006
|
+
export declare interface NotificationCenterFooterProps {
|
|
1007
|
+
href: string | undefined;
|
|
1008
|
+
close(): void;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/** What the `header` slot and `renderHeader` prop receive: the top of the panel, with the title, the bulk actions, and the pause button. */
|
|
1012
|
+
export declare interface NotificationCenterHeaderProps {
|
|
1013
|
+
/** The ID that names the panel. Give it to your heading, so the panel keeps its accessible name. */
|
|
1014
|
+
titleId: string;
|
|
1015
|
+
title: string;
|
|
1016
|
+
filter: InboxFilter;
|
|
1017
|
+
category: string | null;
|
|
1018
|
+
/** The unread notifications of the selected category, or of every category, which `markAllAsRead()` changes. */
|
|
1019
|
+
unread: number;
|
|
1020
|
+
markAllAsRead(): void;
|
|
1021
|
+
/** Whether the built-in header shows the **Archive all** button: the All list shows, and the application offers archiving. */
|
|
1022
|
+
canArchiveAll: boolean;
|
|
1023
|
+
/** Archives the notifications of the selected category, or of every category. Does nothing while the application does not offer archiving. */
|
|
1024
|
+
archiveAll(): void;
|
|
1025
|
+
/** What the user may do with notifications besides reading them, from the server's `inbox.actions` config. */
|
|
1026
|
+
allowedActions: readonly InboxAction[];
|
|
1027
|
+
close(): void;
|
|
1028
|
+
/** Whether the built-in header shows the pause button: the application offers pausing. */
|
|
1029
|
+
canPause: boolean;
|
|
1030
|
+
/** The end of the pause, or `null` while notifications are not paused. */
|
|
1031
|
+
pausedUntil: string | null;
|
|
1032
|
+
/** The times of the pause button, from the server's `pause.presets` config. */
|
|
1033
|
+
pauseOptions: readonly PauseOption[];
|
|
1034
|
+
/** Pauses notifications for one of `pauseOptions`, counted from the call, like a click on a time of the pause button. */
|
|
1035
|
+
pause(option: PauseOption): void;
|
|
1036
|
+
resume(): void;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/** What the `tab` slot and `renderTab` prop receive: the content of each tab. */
|
|
1040
|
+
export declare interface NotificationCenterTabProps {
|
|
1041
|
+
filter: InboxFilter;
|
|
1042
|
+
label: string;
|
|
1043
|
+
selected: boolean;
|
|
1044
|
+
/** The unread count on the Unread tab, or `null` on the other tabs. */
|
|
1045
|
+
count: number | null;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/** What the `trigger` slot and `renderTrigger` prop receive: the content of the bell button. */
|
|
1049
|
+
export declare interface NotificationCenterTriggerProps {
|
|
1050
|
+
open: boolean;
|
|
1051
|
+
/** The count the badge shows, as chosen with the `count` prop. */
|
|
1052
|
+
count: number;
|
|
1053
|
+
counts: InboxCounts;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
export declare const NotificationItem: typeof __VLS_export_4;
|
|
1057
|
+
|
|
1058
|
+
export declare interface NotificationItemProps {
|
|
1059
|
+
item: InboxItem;
|
|
1060
|
+
/** The current time in milliseconds, for the relative time and whether the snooze has ended. Keep it current, or an ended snooze keeps showing. */
|
|
1061
|
+
now: number;
|
|
1062
|
+
/** The text of the item; defaults to the `inbox_` translations. */
|
|
1063
|
+
labels?: InboxLabels;
|
|
1064
|
+
/** Components for the icon names that notifications refer to, and for the built-in icons, such as `archive`. */
|
|
1065
|
+
icons?: Record<string, Component>;
|
|
1066
|
+
/** Resolves the icons that `icons` does not have, in place of the global resolver of `setIconResolver()`. */
|
|
1067
|
+
iconResolver?: IconResolverFn | null;
|
|
1068
|
+
classes?: InboxClasses;
|
|
1069
|
+
locale?: string;
|
|
1070
|
+
/** The index of the action that is running, from `pendingActions` of the inbox state. */
|
|
1071
|
+
pendingAction?: number;
|
|
1072
|
+
/** The snooze times to offer, from the current time, in place of the built-in ones. */
|
|
1073
|
+
snooze?: (now: Date) => SnoozeOption[];
|
|
1074
|
+
/**
|
|
1075
|
+
* The actions that the item shows buttons for, from `allowedActions` of the inbox state: snooze, archive, mute, and
|
|
1076
|
+
* delete. Defaults to every action but deleting, like the server's `inbox.actions` config.
|
|
1077
|
+
*/
|
|
1078
|
+
allowedActions?: readonly InboxAction[];
|
|
1079
|
+
/** Whether the notification is selected, for the actions of the selection bar. */
|
|
1080
|
+
selected?: boolean;
|
|
1081
|
+
/** Called when the user selects or deselects the notification. Without it, the item has no checkbox. */
|
|
1082
|
+
onSelectedChange?: (selected: boolean) => void;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
export declare const NotificationList: typeof __VLS_export_3;
|
|
1086
|
+
|
|
1087
|
+
/** What the `header` slot and `renderHeader` prop of the `NotificationList` receive: the bulk actions and the pause button above the list. */
|
|
1088
|
+
export declare type NotificationListHeaderProps = Omit<NotificationCenterHeaderProps, 'titleId' | 'title' | 'close'>;
|
|
1089
|
+
|
|
1090
|
+
export declare const NotificationPreferences: typeof __VLS_export_5;
|
|
1091
|
+
|
|
1092
|
+
export declare interface NotificationsOptions extends StoreOptions {
|
|
1093
|
+
/** The Inertia flash key that carries toasts. Must match `flash_key` in `config/inertia-notifications.php`. */
|
|
1094
|
+
flashKey?: string;
|
|
1095
|
+
/** Show a toast when a request fails. `true` uses the `error_toast_` translations; an object changes or adds messages. Defaults to `false`. */
|
|
1096
|
+
errorToasts?: boolean | ErrorToastMessages;
|
|
1097
|
+
inbox?: {
|
|
1098
|
+
/** The path of the shared prop with the counts. Must match `inbox.shared_prop` in `config/inertia-notifications.php`. */
|
|
1099
|
+
prop?: string;
|
|
1100
|
+
/**
|
|
1101
|
+
* Laravel Echo, to show notifications the moment they arrive and the changes the user makes in other sessions.
|
|
1102
|
+
* Pass the instance, or a function that returns it, such as `echo` from `@laravel/echo-vue`. `null` stops listening.
|
|
1103
|
+
*/
|
|
1104
|
+
echo?: EchoLike | (() => EchoLike | undefined) | null;
|
|
1105
|
+
/**
|
|
1106
|
+
* Which notifications that arrive in real time also show as a toast: those whose message calls `toast()`
|
|
1107
|
+
* (`requested`, the default), every notification (`all`), or none (`none`).
|
|
1108
|
+
*/
|
|
1109
|
+
arrivalToasts?: ArrivalToasts;
|
|
1110
|
+
/** Milliseconds between requests for the counts, such as for applications without Echo. Paused while the tab is hidden. Off by default. */
|
|
1111
|
+
poll?: number | false;
|
|
1112
|
+
/**
|
|
1113
|
+
* Runs once for each notification that arrives in real time, such as from Echo or a snoozed notification that
|
|
1114
|
+
* came back, after the notification center shows it and before its toast.
|
|
1115
|
+
*/
|
|
1116
|
+
onArrival?: (item: InboxItem) => void;
|
|
1117
|
+
/** Shows the unread count in the title of every tab, such as "(3) Dashboard", with the `inbox_title_count` translation. Off by default. */
|
|
1118
|
+
titleCount?: boolean;
|
|
1119
|
+
/** Shows the unread count on the icon of the installed app with `navigator.setAppBadge()`. Off by default. */
|
|
1120
|
+
appBadge?: boolean;
|
|
1121
|
+
/**
|
|
1122
|
+
* Shows a desktop notification for each notification that arrives in real time while the user is not looking at
|
|
1123
|
+
* any tab of the application. One tab shows it. Ask for permission with `requestNotificationPermission()`. Off by default.
|
|
1124
|
+
*/
|
|
1125
|
+
desktopNotifications?: boolean;
|
|
1126
|
+
/**
|
|
1127
|
+
* Plays a sound in one tab for each notification that arrives in real time: a short built-in chime with `true`, or
|
|
1128
|
+
* the audio file at a URL. Browsers only play sound once the user interacted with the page. Off by default.
|
|
1129
|
+
*/
|
|
1130
|
+
sound?: boolean | string;
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* When a pause of the preset ends, counted from `now`: after its number of minutes, or for `'tomorrow'`, at 08:00 the
|
|
1136
|
+
* next day in the browser's time zone. A custom header shows the end of each of its `pauseOptions` with `pauseTime()`.
|
|
1137
|
+
*/
|
|
1138
|
+
export declare function pauseEnd(preset: PausePreset, now?: Date): Date;
|
|
1139
|
+
|
|
1140
|
+
/** An option of the pause menu, such as "For 30 minutes", whose end counts from its preset when the menu shows it and when the user picks it. */
|
|
1141
|
+
export declare interface PauseOption {
|
|
1142
|
+
label: string;
|
|
1143
|
+
preset: PausePreset;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/** A preset of the pause menu: a number of minutes, or `'tomorrow'` for 08:00 the next day in the browser's time zone. */
|
|
1147
|
+
export declare type PausePreset = number | 'tomorrow';
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* The end of a pause in the locale, as the pause menu shows it: only the time when it is today, with the weekday within
|
|
1151
|
+
* six days, and else with the date, such as "Dec 24, 8:00 AM". `now` is the current time in milliseconds, such as `Date.now()`.
|
|
1152
|
+
*/
|
|
1153
|
+
export declare function pauseTime(date: Date | string, now: number, locale?: string): string;
|
|
1154
|
+
|
|
1155
|
+
/** The frequencies that the user may receive a category in on the channels that digests hold, in the order forms offer them. */
|
|
1156
|
+
declare const PREFERENCE_FREQUENCIES: readonly ["instant", "hourly", "daily", "weekly"];
|
|
1157
|
+
|
|
1158
|
+
/** The days of the notification hours, Monday first. */
|
|
1159
|
+
declare const PREFERENCE_WEEKDAYS: readonly ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
|
|
1160
|
+
|
|
1161
|
+
export declare interface PreferenceCategory {
|
|
1162
|
+
key: string;
|
|
1163
|
+
label: string;
|
|
1164
|
+
description: string | null;
|
|
1165
|
+
/** The key of the group that the category is shown in, or `null`. */
|
|
1166
|
+
group: string | null;
|
|
1167
|
+
/** A locked category always sends, so its channels cannot be turned off. */
|
|
1168
|
+
locked: boolean;
|
|
1169
|
+
/** The user's choice for each channel the category offers, by channel key. A channel that is off overrides it. */
|
|
1170
|
+
channels: Readonly<Record<string, boolean>>;
|
|
1171
|
+
/** How often the user receives the category on the channels that digests hold, or `null` when it is always sent right away. */
|
|
1172
|
+
frequency: PreferenceFrequency | null;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
export declare interface PreferenceChannel {
|
|
1176
|
+
key: string;
|
|
1177
|
+
label: string;
|
|
1178
|
+
/** Whether the user may turn the channel off for every category at once. */
|
|
1179
|
+
globalSwitch: boolean;
|
|
1180
|
+
/** Whether the channel is on. While it is off, the user receives only the locked categories on it. */
|
|
1181
|
+
enabled: boolean;
|
|
1182
|
+
/** Whether digests hold the channel, from the server's `digests.channels` config. */
|
|
1183
|
+
digest: boolean;
|
|
1184
|
+
/** Whether the channel covers the notification center, which the pushes of a category need. */
|
|
1185
|
+
inbox: boolean;
|
|
1186
|
+
/** Whether the channel sends web push, which reaches only the devices where the user turned push on. */
|
|
1187
|
+
push: boolean;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/** How often the user receives a category on the channels that digests hold: right away, or in an hourly, daily, or weekly digest. */
|
|
1191
|
+
export declare type PreferenceFrequency = (typeof PREFERENCE_FREQUENCIES)[number];
|
|
1192
|
+
|
|
1193
|
+
export declare interface PreferenceGroup {
|
|
1194
|
+
key: string;
|
|
1195
|
+
label: string;
|
|
1196
|
+
description: string | null;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* The hours, in the user's timezone, during which notifications reach the user on the channels that digests hold, and
|
|
1201
|
+
* with a toast, a sound, and a desktop notification. Outside them, those wait or arrive silently.
|
|
1202
|
+
*/
|
|
1203
|
+
export declare interface PreferenceNotificationHours {
|
|
1204
|
+
enabled: boolean;
|
|
1205
|
+
/**
|
|
1206
|
+
* The ranges of each day, such as `['09:00-12:00', '13:00-17:00']`, sorted by start. A day without ranges has no
|
|
1207
|
+
* notification hours. A range that ends before or when it starts runs past midnight, so `22:00-02:00` ends at 02:00
|
|
1208
|
+
* the next day, and `00:00-00:00` is the whole day.
|
|
1209
|
+
*/
|
|
1210
|
+
days: Record<PreferenceWeekday, string[]>;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/** Class names added to the parts of `<NotificationPreferences>`. */
|
|
1214
|
+
export declare interface PreferencesClasses {
|
|
1215
|
+
table?: string;
|
|
1216
|
+
/** Each column header: the categories and each channel. */
|
|
1217
|
+
head?: string;
|
|
1218
|
+
/** The heading of each group. */
|
|
1219
|
+
group?: string;
|
|
1220
|
+
/** Each row of switches: the **All notifications** row and each category. */
|
|
1221
|
+
row?: string;
|
|
1222
|
+
label?: string;
|
|
1223
|
+
description?: string;
|
|
1224
|
+
/** The badge of a locked category. */
|
|
1225
|
+
badge?: string;
|
|
1226
|
+
switch?: string;
|
|
1227
|
+
/** The frequency menu of each category that users may receive in a digest. */
|
|
1228
|
+
select?: string;
|
|
1229
|
+
/** The time fields of the notification hours. */
|
|
1230
|
+
time?: string;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/** The categories of one group, or those without a group when `group` is `null`. */
|
|
1234
|
+
export declare interface PreferenceSection {
|
|
1235
|
+
group: PreferenceGroup | null;
|
|
1236
|
+
categories: readonly PreferenceCategory[];
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
/** The text of `<NotificationPreferences>`: strings with placeholders, or functions that receive the parameters. */
|
|
1240
|
+
export declare type PreferencesLabels = Record<keyof typeof DEFAULT_PREFERENCES_LABELS, TranslationValue>;
|
|
1241
|
+
|
|
1242
|
+
export declare interface PreferencesState {
|
|
1243
|
+
status: 'idle' | 'loading' | 'ready' | 'error';
|
|
1244
|
+
channels: readonly PreferenceChannel[];
|
|
1245
|
+
/** The groups that have categories, in order. */
|
|
1246
|
+
groups: readonly PreferenceGroup[];
|
|
1247
|
+
categories: readonly PreferenceCategory[];
|
|
1248
|
+
/** The user's notification hours, or `null` when the application does not offer them. */
|
|
1249
|
+
notificationHours: PreferenceNotificationHours | null;
|
|
1250
|
+
/** The frequencies that the application offers, `instant` first. Every frequency when the server does not list them. */
|
|
1251
|
+
frequencies: readonly PreferenceFrequency[];
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
export declare interface PreferencesStore {
|
|
1255
|
+
subscribe(listener: () => void): () => void;
|
|
1256
|
+
getSnapshot(): PreferencesState;
|
|
1257
|
+
connect(bindings: InertiaBindings, options?: {
|
|
1258
|
+
onFailure?: (error: unknown) => void;
|
|
1259
|
+
}): void;
|
|
1260
|
+
/** Loads the preferences of the signed-in user from the notification center's routes, at the URL of the shared prop. */
|
|
1261
|
+
load(url: string | undefined): Promise<void>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Turns a category on or off for one channel. The change shows at once and is undone when saving fails. Each
|
|
1264
|
+
* switch saves one change at a time, so the server saves the user's newest choice last.
|
|
1265
|
+
*/
|
|
1266
|
+
set(category: string, channel: string, enabled: boolean): Promise<void>;
|
|
1267
|
+
/** Turns a channel off or on for every category, except the locked categories, which always send. Saves like `set()`. */
|
|
1268
|
+
setChannel(channel: string, enabled: boolean): Promise<void>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Sets how often the user receives a category that may be received in a digest, to one of the offered `frequencies`,
|
|
1271
|
+
* with the browser's timezone. Saves like `set()`.
|
|
1272
|
+
*/
|
|
1273
|
+
setFrequency(category: string, frequency: PreferenceFrequency): Promise<void>;
|
|
1274
|
+
/**
|
|
1275
|
+
* Changes the notification hours: whether they are on, and the ranges of the days that change, such as
|
|
1276
|
+
* `{ days: { saturday: ['10:00-14:00'] } }`. An empty list turns a day off. Saves like `setFrequency()`. A change with
|
|
1277
|
+
* a range that is not two times of day, or that leaves no range on any day, changes nothing.
|
|
1278
|
+
*/
|
|
1279
|
+
setNotificationHours(changes: {
|
|
1280
|
+
enabled?: boolean;
|
|
1281
|
+
days?: Partial<Record<PreferenceWeekday, string[]>>;
|
|
1282
|
+
}): Promise<void>;
|
|
1283
|
+
/** Forgets the preferences after the user signed out or another user signed in, and loads them again when they show. */
|
|
1284
|
+
reset(url: string | undefined): void;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
/** The store shared by every `<NotificationPreferences>` in the application. */
|
|
1288
|
+
export declare const preferencesStore: PreferencesStore;
|
|
1289
|
+
|
|
1290
|
+
/** A day of the week, as the notification hours name it. */
|
|
1291
|
+
export declare type PreferenceWeekday = (typeof PREFERENCE_WEEKDAYS)[number];
|
|
1292
|
+
|
|
1293
|
+
export declare interface PromiseToast<T> {
|
|
1294
|
+
id: string;
|
|
1295
|
+
/**
|
|
1296
|
+
* The original promise. `toast.promise()` returns this object instead of the promise, so a failure does not become an
|
|
1297
|
+
* unhandled rejection. A failed `Response` still resolves it, as it resolves `fetch()`.
|
|
1298
|
+
*/
|
|
1299
|
+
unwrap(): Promise<T>;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
export declare interface PromiseToastOptions<T> extends Omit<ToastOptions, 'type'> {
|
|
1303
|
+
loading: ToastInput;
|
|
1304
|
+
/** Replaces the loading toast when the promise resolves; omit to close it. */
|
|
1305
|
+
success?: ToastInput | ((value: T) => ToastInput);
|
|
1306
|
+
/** Replaces the loading toast when the promise rejects or resolves with a failed `Response`, which it receives; omit to close it. */
|
|
1307
|
+
error?: ToastInput | ((error: unknown) => ToastInput);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/** A device that receives the signed-in user's pushes, as the server stores its subscription. */
|
|
1311
|
+
declare interface PushDevice {
|
|
1312
|
+
/** The key of the subscription, which `removeDevice()` takes. */
|
|
1313
|
+
id: number;
|
|
1314
|
+
/** The name of the browser, such as `Chrome`, or `null` when its user agent tells no browser we know. */
|
|
1315
|
+
browser: string | null;
|
|
1316
|
+
/** The operating system of the browser, such as `macOS`, or `null` when its user agent tells none we know. */
|
|
1317
|
+
platform: string | null;
|
|
1318
|
+
/** When the device last opened a page of the application while push was on, or turned push on, as ISO 8601. */
|
|
1319
|
+
activeAt: string;
|
|
1320
|
+
/** Whether this is the device of the page. */
|
|
1321
|
+
current: boolean;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/** What the device control of `<NotificationPreferences>` shows, as its `data-state`. */
|
|
1325
|
+
export declare type PushDeviceState = 'off' | 'on' | 'busy' | 'blocked' | 'home-screen' | 'insecure' | 'brave' | 'failed';
|
|
1326
|
+
|
|
1327
|
+
/** Why push cannot turn on in this browser, or why the last request failed. */
|
|
1328
|
+
export declare type PushReason =
|
|
1329
|
+
/** The page is not served over HTTPS or from `localhost`, so the browser offers no service workers. */
|
|
1330
|
+
'insecure'
|
|
1331
|
+
/** The browser has no web push. */
|
|
1332
|
+
| 'unsupported'
|
|
1333
|
+
/** iOS and iPadOS only offer push to a site that the user added to the Home Screen and opened from there. */
|
|
1334
|
+
| 'home-screen'
|
|
1335
|
+
/** The user blocked notifications for the site. */
|
|
1336
|
+
| 'blocked'
|
|
1337
|
+
/** Brave could not subscribe, as its "Use Google services for push messaging" setting is off. */
|
|
1338
|
+
| 'brave'
|
|
1339
|
+
/** Registering the service worker, subscribing, or saving the subscription failed. */
|
|
1340
|
+
| 'failed';
|
|
1341
|
+
|
|
1342
|
+
export declare interface PushState {
|
|
1343
|
+
/** Whether the application sends pushes: the shared prop's `push` is not `null`. */
|
|
1344
|
+
available: boolean;
|
|
1345
|
+
/** Whether this browser can receive pushes. */
|
|
1346
|
+
supported: boolean;
|
|
1347
|
+
/** The browser's permission for notifications. */
|
|
1348
|
+
permission: NotificationPermission;
|
|
1349
|
+
/** Whether this device receives the signed-in user's pushes. */
|
|
1350
|
+
subscribed: boolean;
|
|
1351
|
+
/** Whether turning push on or off for this device is in progress. */
|
|
1352
|
+
busy: boolean;
|
|
1353
|
+
/** Why push cannot turn on in this browser, or why the last request failed. `null` when nothing is in the way. */
|
|
1354
|
+
reason: PushReason | null;
|
|
1355
|
+
/** The request that turns push on or off for this device while it runs, or after it failed. `null` once it succeeded. */
|
|
1356
|
+
request: {
|
|
1357
|
+
action: 'subscribe' | 'unsubscribe';
|
|
1358
|
+
status: 'pending' | 'brave' | 'failed';
|
|
1359
|
+
} | null;
|
|
1360
|
+
/**
|
|
1361
|
+
* The devices that receive the signed-in user's pushes, the most recently active first, once `loadDevices()` loaded
|
|
1362
|
+
* them, and `null` before. A device that `removeDevice()` removes leaves the list at once.
|
|
1363
|
+
*/
|
|
1364
|
+
devices: readonly PushDevice[] | null;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/** Formats a time relative to now, such as "5 minutes ago" or "yesterday", in the given locale. */
|
|
1368
|
+
export declare function relativeTime(iso: string, now: number, locale?: string): string;
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* Asks the user to allow desktop notifications, and returns their choice. Browsers only show the prompt after a user
|
|
1372
|
+
* gesture, so call it from a click handler. Browsers without desktop notifications return `denied`.
|
|
1373
|
+
*/
|
|
1374
|
+
export declare function requestNotificationPermission(): Promise<NotificationPermission>;
|
|
1375
|
+
|
|
1376
|
+
/** The component that the global resolver returns for an icon name, or `null`. */
|
|
1377
|
+
export declare const resolveIcon: (icon: string, context?: IconContext) => Component | string | null;
|
|
1378
|
+
|
|
1379
|
+
/** Registers the resolver that every component asks for its icons, or clears it with `null`. */
|
|
1380
|
+
export declare const setIconResolver: (resolver: IconResolverFn | null) => void;
|
|
1381
|
+
|
|
1382
|
+
/** Changes built-in strings for the whole application. Keys you leave out keep their current text. */
|
|
1383
|
+
export declare function setTranslations(overrides: Record<string, TranslationValue>): void;
|
|
1384
|
+
|
|
1385
|
+
export declare interface SnoozeOption {
|
|
1386
|
+
label: string;
|
|
1387
|
+
until: Date;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* The default snooze times: in three hours when that is still today, tomorrow at 9:00, and next Monday at 9:00 unless
|
|
1392
|
+
* that is tomorrow. Labels that are not given use the translations.
|
|
1393
|
+
*/
|
|
1394
|
+
export declare function snoozeOptions(overrides?: Readonly<Partial<Pick<InboxLabels, 'snoozeLaterToday' | 'snoozeTomorrow' | 'snoozeNextWeek'>>>, now?: Date): SnoozeOption[];
|
|
1395
|
+
|
|
1396
|
+
export declare interface StoreOptions extends DurationOptions {
|
|
1397
|
+
/** The most toasts each Toaster shows at once. Defaults to `5`. */
|
|
1398
|
+
limit?: number;
|
|
1399
|
+
/**
|
|
1400
|
+
* What happens when a toast arrives while the limit of toasts shows: it waits for room (`queue`, the default), the
|
|
1401
|
+
* least important showing toast closes (`drop-oldest`), or the least important showing toast hides until there is
|
|
1402
|
+
* room again (`hide`). The oldest goes first among toasts of the same importance.
|
|
1403
|
+
*/
|
|
1404
|
+
overflow?: 'queue' | 'drop-oldest' | 'hide';
|
|
1405
|
+
/** Show a counter on an open toast instead of adding the same toast again. Defaults to `true`. */
|
|
1406
|
+
dedupe?: boolean;
|
|
1407
|
+
/** Milliseconds a closing toast stays rendered for its exit animation. Defaults to `200`. */
|
|
1408
|
+
removeDelay?: number;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
export declare interface Toast {
|
|
1412
|
+
id: string;
|
|
1413
|
+
type: ToastType;
|
|
1414
|
+
title: string;
|
|
1415
|
+
description?: string;
|
|
1416
|
+
/** Milliseconds before the toast closes; `null` keeps it open until dismissed. */
|
|
1417
|
+
duration: number | null;
|
|
1418
|
+
actions: readonly ToastAction[];
|
|
1419
|
+
icon?: ToastIcon;
|
|
1420
|
+
/** The URL of an image, such as an avatar, that shows in place of the icon. */
|
|
1421
|
+
image?: string;
|
|
1422
|
+
/** Whether the user can dismiss it with its button, Escape, or a swipe. */
|
|
1423
|
+
dismissible: boolean;
|
|
1424
|
+
/** Overrides the position of the Toaster that shows it. */
|
|
1425
|
+
position?: ToastPosition;
|
|
1426
|
+
/** The `name` of the Toaster that shows it; the unnamed Toaster when omitted. */
|
|
1427
|
+
toaster?: string;
|
|
1428
|
+
/** Overrides how urgently screen readers announce it; errors are assertive, others polite. */
|
|
1429
|
+
politeness?: 'polite' | 'assertive';
|
|
1430
|
+
/** Data for the component that the Toaster's `components` prop has for the toast's type, such as from `->with()` in Laravel. */
|
|
1431
|
+
data?: Record<string, unknown>;
|
|
1432
|
+
/** How much of the work is done, from 0 to 1, shown as a bar that screen readers can read. */
|
|
1433
|
+
progress?: number;
|
|
1434
|
+
/** How often the same toast was shown while it was open. */
|
|
1435
|
+
count: number;
|
|
1436
|
+
/** Increases each time the content changes, so it is announced again. */
|
|
1437
|
+
revision: number;
|
|
1438
|
+
/** `queued` waits for room under the limit, also after a newer toast hid it; `closing` plays its exit animation. */
|
|
1439
|
+
state: ToastState;
|
|
1440
|
+
/** The index of the action that is running. */
|
|
1441
|
+
pendingAction?: number;
|
|
1442
|
+
onClose?: (reason: ToastCloseReason) => void;
|
|
1443
|
+
/** Runs after the exit animation, when the toast is removed. */
|
|
1444
|
+
onRemove?: () => void;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
export declare const toast: ToastFunction;
|
|
1448
|
+
|
|
1449
|
+
declare const TOAST_ACTION_METHODS: readonly ["get", "post", "put", "patch", "delete"];
|
|
1450
|
+
|
|
1451
|
+
declare const TOAST_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
1452
|
+
|
|
1453
|
+
/**
|
|
1454
|
+
* A button on a toast. Set one of `onClick`, `href`, or `event`. The toast closes after the action ran, unless
|
|
1455
|
+
* `keepOpen` is set; while `onClick`'s promise or the visit is pending, the button shows a loading state.
|
|
1456
|
+
* `Target` is what `onClick` receives: the toast, or the notification for the actions of a notification.
|
|
1457
|
+
*/
|
|
1458
|
+
export declare interface ToastAction<Target = Toast> {
|
|
1459
|
+
label: string;
|
|
1460
|
+
/** Runs when the action is clicked. Return a promise to keep the toast open, with a loading state, until it settles. */
|
|
1461
|
+
onClick?: (target: Target) => unknown;
|
|
1462
|
+
/** Visits this URL with Inertia. Actions that visit with GET render as links. */
|
|
1463
|
+
href?: string;
|
|
1464
|
+
method?: ToastActionMethod;
|
|
1465
|
+
data?: Record<string, unknown>;
|
|
1466
|
+
visit?: ToastActionVisitOptions;
|
|
1467
|
+
/** Load `href` in the browser instead of visiting it with Inertia, such as for a file download or another site. */
|
|
1468
|
+
external?: boolean;
|
|
1469
|
+
/** Open `href` in a new tab. */
|
|
1470
|
+
newTab?: boolean;
|
|
1471
|
+
/** Dispatches a `CustomEvent` with this name on `window`, with `payload` as its `detail`. */
|
|
1472
|
+
event?: string;
|
|
1473
|
+
payload?: unknown;
|
|
1474
|
+
/** Keep the toast open after the action ran. */
|
|
1475
|
+
keepOpen?: boolean;
|
|
1476
|
+
/** Tells screen reader users how to do the same without the toast, such as "Undo from the Trash page". */
|
|
1477
|
+
altText?: string;
|
|
1478
|
+
/**
|
|
1479
|
+
* What a notification shows in place of its actions once this action succeeded, such as "Approved". The notification
|
|
1480
|
+
* center saves it for the user. Toasts that do not show a notification ignore it.
|
|
1481
|
+
*/
|
|
1482
|
+
result?: string;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
export declare type ToastActionMethod = (typeof TOAST_ACTION_METHODS)[number];
|
|
1486
|
+
|
|
1487
|
+
/** Options for the Inertia visit of an action, such as `{ preserveScroll: true }`. */
|
|
1488
|
+
export declare interface ToastActionVisitOptions {
|
|
1489
|
+
preserveScroll?: boolean;
|
|
1490
|
+
preserveState?: boolean;
|
|
1491
|
+
replace?: boolean;
|
|
1492
|
+
only?: string[];
|
|
1493
|
+
except?: string[];
|
|
1494
|
+
headers?: Record<string, string>;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
/** Class names added to the parts of each toast. */
|
|
1498
|
+
export declare type ToastClasses = Partial<Record<'toast' | 'icon' | 'title' | 'description' | 'actions' | 'action' | 'dismiss' | 'progress', string>>;
|
|
1499
|
+
|
|
1500
|
+
/** Why a toast closed, passed to `onClose`. */
|
|
1501
|
+
export declare type ToastCloseReason =
|
|
1502
|
+
/** Its duration ran out. */
|
|
1503
|
+
'timeout'
|
|
1504
|
+
/** The user pressed its dismiss button. */
|
|
1505
|
+
| 'user'
|
|
1506
|
+
/** The user swiped it away. */
|
|
1507
|
+
| 'swipe'
|
|
1508
|
+
/** The user ran one of its actions. */
|
|
1509
|
+
| 'action'
|
|
1510
|
+
/** The user pressed Escape while it had focus. */
|
|
1511
|
+
| 'escape'
|
|
1512
|
+
/** Code called `toast.dismiss()`. */
|
|
1513
|
+
| 'programmatic'
|
|
1514
|
+
/** A new toast with the same ID took its place. */
|
|
1515
|
+
| 'replaced'
|
|
1516
|
+
/** The limit was reached and a newer toast pushed it out. */
|
|
1517
|
+
| 'evicted';
|
|
1518
|
+
|
|
1519
|
+
/** The props of a component in the Toaster's `components` prop, which renders the toasts of one type. */
|
|
1520
|
+
export declare interface ToastComponentProps {
|
|
1521
|
+
toast: Toast;
|
|
1522
|
+
/** Closes the toast, as its dismiss button does. */
|
|
1523
|
+
dismiss: () => void;
|
|
1524
|
+
/** Runs an action of the toast. Pass the click event, so a modified click on a link opens it in a new tab. */
|
|
1525
|
+
runAction: (index: number, event: MouseEvent) => void;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/** What a `duration` function receives: the content of the toast that it times. */
|
|
1529
|
+
export declare type ToastContent = Pick<Toast, 'type' | 'title' | 'description'> & {
|
|
1530
|
+
actions?: readonly ToastAction[];
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
export declare const Toaster: typeof __VLS_export;
|
|
1534
|
+
|
|
1535
|
+
export declare interface ToastFunction {
|
|
1536
|
+
(title: string, options?: ToastOptions): string;
|
|
1537
|
+
success: TypedToast;
|
|
1538
|
+
info: TypedToast;
|
|
1539
|
+
warning: TypedToast;
|
|
1540
|
+
error: TypedToast;
|
|
1541
|
+
/** A toast with a spinner that stays open; replace it by passing its ID to another toast. */
|
|
1542
|
+
loading: TypedToast;
|
|
1543
|
+
/** Changes an open toast; omitted fields keep their value. */
|
|
1544
|
+
update(id: string, changes: ToastUpdate): void;
|
|
1545
|
+
/** Closes one toast, or every toast when no ID is given. */
|
|
1546
|
+
dismiss(id?: string): void;
|
|
1547
|
+
/** Shows a loading toast until the promise settles, then replaces it with a success or error toast. */
|
|
1548
|
+
promise<T>(promise: Promise<T> | (() => Promise<T>), options: PromiseToastOptions<T>): PromiseToast<T>;
|
|
1549
|
+
/**
|
|
1550
|
+
* Returns callbacks for an Inertia visit, such as `router.post(url, data, toast.track({ loading: 'Saving…' }))`,
|
|
1551
|
+
* that show a loading toast while the visit runs, with the progress of a file upload. Pass visit options as the
|
|
1552
|
+
* second argument to keep their callbacks.
|
|
1553
|
+
*/
|
|
1554
|
+
track<T extends object = Record<never, never>>(options: TrackToastOptions, visitOptions?: T): T & Required<VisitCallbacks>;
|
|
1555
|
+
/** Shows the toasts in the headers of a response that did not come through Inertia, such as from `fetch()`. */
|
|
1556
|
+
fromHeaders(headers: Headers | Record<string, string>): void;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/** A name the Toaster looks up in its `icons` prop, a framework component, or `false` for no icon. */
|
|
1560
|
+
export declare type ToastIcon = string | false | object;
|
|
1561
|
+
|
|
1562
|
+
/** A toast's title, or its title with options. */
|
|
1563
|
+
export declare type ToastInput = string | (ToastOptions & {
|
|
1564
|
+
title: string;
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
export declare interface ToastOptions {
|
|
1568
|
+
/** Updates the open toast with this ID instead of adding another one. */
|
|
1569
|
+
id?: string;
|
|
1570
|
+
type?: ToastType;
|
|
1571
|
+
description?: string;
|
|
1572
|
+
/** Milliseconds before the toast closes, or `null` to keep it open. Omit to use the default for its type and length. */
|
|
1573
|
+
duration?: number | null;
|
|
1574
|
+
/** Shorthand for a single action. */
|
|
1575
|
+
action?: ToastAction;
|
|
1576
|
+
actions?: readonly ToastAction[];
|
|
1577
|
+
icon?: ToastIcon;
|
|
1578
|
+
/** The URL of an image, such as an avatar, that shows in place of the icon. Screen readers still announce the type. */
|
|
1579
|
+
image?: string;
|
|
1580
|
+
/** Set to `false` to remove the dismiss button and Escape, such as for a toast that is replaced when work finishes. */
|
|
1581
|
+
dismissible?: boolean;
|
|
1582
|
+
position?: ToastPosition;
|
|
1583
|
+
toaster?: string;
|
|
1584
|
+
politeness?: 'polite' | 'assertive';
|
|
1585
|
+
/** Data for the component that the Toaster's `components` prop has for the toast's type. Toasts with data are never counted as duplicates. */
|
|
1586
|
+
data?: Record<string, unknown>;
|
|
1587
|
+
/** How much of the work is done, from 0 to 1, such as the share of an upload. The toast shows it as a bar. */
|
|
1588
|
+
progress?: number;
|
|
1589
|
+
onClose?: (reason: ToastCloseReason) => void;
|
|
1590
|
+
onRemove?: () => void;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
export declare type ToastPosition = (typeof TOAST_POSITIONS)[number];
|
|
1594
|
+
|
|
1595
|
+
export declare type ToastState = 'queued' | 'visible' | 'closing';
|
|
1596
|
+
|
|
1597
|
+
export declare interface ToastStore {
|
|
1598
|
+
/** Subscribe to changes; compatible with React's `useSyncExternalStore`. Also called when timers pause or resume. */
|
|
1599
|
+
subscribe(listener: () => void): () => void;
|
|
1600
|
+
/** Every toast in the order it was added, including queued and closing toasts. */
|
|
1601
|
+
getSnapshot(): readonly Toast[];
|
|
1602
|
+
/** Adds a toast and returns its ID. With the ID of an open toast, replaces that toast in place. */
|
|
1603
|
+
add(title: string, options?: ToastOptions): string;
|
|
1604
|
+
/** Changes an open or queued toast; omitted fields keep their value. Content changes restart its timer. */
|
|
1605
|
+
update(id: string, changes: ToastUpdate): void;
|
|
1606
|
+
/** Closes one toast, or every toast when no ID is given. */
|
|
1607
|
+
dismiss(id?: string, reason?: ToastCloseReason): void;
|
|
1608
|
+
/**
|
|
1609
|
+
* Stops close timers for the given reason: every timer, or only the timer of one toast. Timers run again
|
|
1610
|
+
* once every reason is resumed.
|
|
1611
|
+
*/
|
|
1612
|
+
pause(reason?: string, id?: string): void;
|
|
1613
|
+
/** Removes a pause reason. Each toast continues with the time it had left, but at least a second. */
|
|
1614
|
+
resume(reason?: string, id?: string): void;
|
|
1615
|
+
timer(id: string): ToastTimer | undefined;
|
|
1616
|
+
/** Marks the action that is running, which also stops the toast's timer. */
|
|
1617
|
+
setPendingAction(id: string, index: number | undefined): void;
|
|
1618
|
+
/** Changes the defaults of toasts added from now on, and the limit. */
|
|
1619
|
+
configure(options: StoreOptions): void;
|
|
1620
|
+
/**
|
|
1621
|
+
* Records a mounted Toaster that shows the toasts of the given name, or the unnamed toasts, and returns how to record
|
|
1622
|
+
* that it unmounted. A toast's timer runs only while a Toaster of its name is mounted.
|
|
1623
|
+
*/
|
|
1624
|
+
attach(toaster: string | undefined): () => void;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
export declare interface ToastTimer {
|
|
1628
|
+
duration: number;
|
|
1629
|
+
/** Milliseconds left, counted down while the timer runs. */
|
|
1630
|
+
remaining: number;
|
|
1631
|
+
running: boolean;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
/**
|
|
1635
|
+
* A built-in type, or the name of a custom type, such as `deployment`: lowercase letters, digits, and dashes, starting
|
|
1636
|
+
* with a letter. A toast of a custom type shows the icon and screen reader label that the Toaster has for it, and
|
|
1637
|
+
* otherwise looks like a `default` toast.
|
|
1638
|
+
*/
|
|
1639
|
+
export declare type ToastType = BuiltInToastType | (string & {});
|
|
1640
|
+
|
|
1641
|
+
/** Labels that screen readers announce before a toast's title, such as "Error: Payment failed". They take the place of the `toast_type_` translations. */
|
|
1642
|
+
export declare type ToastTypeLabels = Partial<Record<ToastType, string>>;
|
|
1643
|
+
|
|
1644
|
+
/** Changes for `toast.update()`; omitted fields keep their value. */
|
|
1645
|
+
export declare type ToastUpdate = Omit<ToastOptions, 'id'> & {
|
|
1646
|
+
title?: string;
|
|
1647
|
+
};
|
|
1648
|
+
|
|
1649
|
+
export declare interface TrackToastOptions extends Omit<ToastOptions, 'type'> {
|
|
1650
|
+
/** Shown while the visit runs. */
|
|
1651
|
+
loading?: ToastInput;
|
|
1652
|
+
/** Shown when the visit succeeds; omit when the server flashes its own toast. */
|
|
1653
|
+
success?: ToastInput | ((page: unknown) => ToastInput);
|
|
1654
|
+
/** Shown when the visit fails validation, with the errors; omit to only close the loading toast. */
|
|
1655
|
+
error?: ToastInput | ((errors: Record<string, string>) => ToastInput);
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
/** The text of a key with its parameters. A key without a translation renders as the key, so it is easy to spot. */
|
|
1659
|
+
export declare function trans(key: string, params?: TranslationParams): string;
|
|
1660
|
+
|
|
1661
|
+
export declare type TranslationKey = keyof typeof DEFAULT_TRANSLATIONS;
|
|
1662
|
+
|
|
1663
|
+
export declare type TranslationParams = Record<string, string | number>;
|
|
1664
|
+
|
|
1665
|
+
/** A string with `:name` placeholders, or a function that receives the parameters and returns the text, such as for plurals. */
|
|
1666
|
+
export declare type TranslationValue = string | ((params: TranslationParams) => string);
|
|
1667
|
+
|
|
1668
|
+
declare type TypedToast = (title: string, options?: Omit<ToastOptions, 'type'>) => string;
|
|
1669
|
+
|
|
1670
|
+
export declare type UseNotifications = {
|
|
1671
|
+
[Key in keyof InboxState]: ComputedRef<InboxState[Key]>;
|
|
1672
|
+
} & InboxActions & {
|
|
1673
|
+
/** Shows a toast. */
|
|
1674
|
+
toast: ToastFunction;
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
/**
|
|
1678
|
+
* The notification center's state, such as the counts and the loaded notifications, and its actions, for building
|
|
1679
|
+
* a custom bell or panel. Every component shares the same state.
|
|
1680
|
+
*/
|
|
1681
|
+
export declare function useNotifications(): UseNotifications;
|
|
1682
|
+
|
|
1683
|
+
export declare type UsePreferences = {
|
|
1684
|
+
[Key in keyof PreferencesState]: ComputedRef<PreferencesState[Key]>;
|
|
1685
|
+
} & Pick<PreferencesStore, 'set' | 'setChannel' | 'setFrequency' | 'setNotificationHours'> & {
|
|
1686
|
+
/** The categories by group: first those without a group, then each group in order. */
|
|
1687
|
+
sections: ComputedRef<PreferenceSection[]>;
|
|
1688
|
+
/** Loads the preferences of the signed-in user again. */
|
|
1689
|
+
load(): Promise<void>;
|
|
1690
|
+
/** Whether the user receives the category on the channel: always if locked, else while both are on, and pushes only with the notification center. */
|
|
1691
|
+
receives(category: PreferenceCategory, channel: PreferenceChannel): boolean;
|
|
1692
|
+
/** Whether the frequency of the category changes anything: the user receives the category on a channel that digests hold. */
|
|
1693
|
+
frequencyApplies: typeof frequencyApplies;
|
|
1694
|
+
/** Whether the choice for the category on the channel cannot change: it is locked, the channel is off, or pushes wait for the notification center. */
|
|
1695
|
+
isDisabled(category: PreferenceCategory, channel: PreferenceChannel): boolean;
|
|
1696
|
+
};
|
|
1697
|
+
|
|
1698
|
+
/**
|
|
1699
|
+
* The notification preferences of the signed-in user and the actions that change them, for building your own preferences
|
|
1700
|
+
* page. Loads the preferences when the component mounts. Every component shares the same state.
|
|
1701
|
+
*/
|
|
1702
|
+
export declare function usePreferences(): UsePreferences;
|
|
1703
|
+
|
|
1704
|
+
export declare type UsePush = {
|
|
1705
|
+
[Key in keyof PushState]: ComputedRef<PushState[Key]>;
|
|
1706
|
+
} & {
|
|
1707
|
+
/**
|
|
1708
|
+
* The `data-state` of the device control of `<NotificationPreferences>` in this state, or `null` while the
|
|
1709
|
+
* application sends no pushes or the browser has no web push. The component also hides its control while no channel
|
|
1710
|
+
* of the preferences sends push, such as while they load.
|
|
1711
|
+
*/
|
|
1712
|
+
deviceState: ComputedRef<PushDeviceState | null>;
|
|
1713
|
+
/** Turns push on for this device. Call it from a click handler, as browsers only ask for permission after a user gesture. */
|
|
1714
|
+
subscribe(): Promise<void>;
|
|
1715
|
+
/** Turns push off for this device. */
|
|
1716
|
+
unsubscribe(): Promise<void>;
|
|
1717
|
+
/** Loads the devices that receive the signed-in user's pushes into `devices`, such as when your list of them shows. */
|
|
1718
|
+
loadDevices(): Promise<void>;
|
|
1719
|
+
/** Removes the subscription of another device, which leaves `devices` at once. Use `unsubscribe()` for this device. */
|
|
1720
|
+
removeDevice(id: number): Promise<void>;
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* Whether this device receives push notifications, why it cannot, the actions that turn push on and off, and the user's
|
|
1725
|
+
* other devices, for building your own device control. Every component shares the same state.
|
|
1726
|
+
*/
|
|
1727
|
+
export declare function usePush(): UsePush;
|
|
1728
|
+
|
|
1729
|
+
export declare type UseToasts = Pick<ToastStore, 'update' | 'dismiss' | 'pause' | 'resume' | 'timer'> & {
|
|
1730
|
+
/**
|
|
1731
|
+
* The toasts of this Toaster in the order they were added. Render the `visible` ones; `closing` toasts play their
|
|
1732
|
+
* exit animation, and `queued` toasts wait for room under the limit.
|
|
1733
|
+
*/
|
|
1734
|
+
toasts: ComputedRef<readonly Toast[]>;
|
|
1735
|
+
/** Shows a toast. */
|
|
1736
|
+
toast: ToastFunction;
|
|
1737
|
+
/** Runs an action of a toast. Pass the click event, so a modified click on a link opens it in a new tab. */
|
|
1738
|
+
runAction: (id: string, index: number, event?: MouseEvent) => void;
|
|
1739
|
+
};
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* The toasts of the Toaster with the given name, or of the unnamed Toaster, and what to do with them, for a Toaster
|
|
1743
|
+
* with markup of your own. While a component uses it, the toasts' timers run, as they do while a `<Toaster>` is mounted.
|
|
1744
|
+
* Pauses made with its `pause()` end when the component unmounts. Pass a ref or a getter to follow a name that changes.
|
|
1745
|
+
*/
|
|
1746
|
+
export declare function useToasts(name?: MaybeRefOrGetter<string | undefined>): UseToasts;
|
|
1747
|
+
|
|
1748
|
+
declare interface VisitCallbacks {
|
|
1749
|
+
onStart?: (visit: unknown) => void;
|
|
1750
|
+
onProgress?: (progress: unknown) => void;
|
|
1751
|
+
onSuccess?: (page: unknown) => void;
|
|
1752
|
+
onError?: (errors: unknown) => void;
|
|
1753
|
+
onFinish?: (visit: unknown) => void;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
export { }
|