@vuetify/v0 1.0.0-alpha.0 → 1.0.0-alpha.2
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/README.md +5 -1
- package/dist/{adapter-T7AedXkz.d.mts → adapter-58IvIfAZ.d.mts} +1 -1
- package/dist/{adapter-Drq1v5wV.mjs → adapter-Be9zUc-n.mjs} +6 -3
- package/dist/{adapter-CcHB7rs3.d.mts → adapter-BvWEd9w-.d.mts} +2 -2
- package/dist/{adapter-BZjmDNJF.d.mts → adapter-DlX3FA3A.d.mts} +2 -2
- package/dist/{adapter-CCIeOzqr.mjs → adapter-gQ2SNKZq.mjs} +31 -22
- package/dist/{adapters-D49L7m2R.mjs → adapters-BJ5n7rgh.mjs} +1 -1
- package/dist/adapters-BnKW0BF_.mjs +2 -0
- package/dist/adapters-CBrvizWb.mjs +4 -0
- package/dist/adapters-CMJGA1k7.mjs +2 -0
- package/dist/adapters-Dse4bPxk.mjs +5 -0
- package/dist/browser/index.js +4845 -3272
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.mjs +2 -2
- package/dist/{components-Dc7sUTsg.mjs → components-CqDewYTU.mjs} +1407 -411
- package/dist/composables/index.d.mts +19 -19
- package/dist/composables/index.mjs +28 -26
- package/dist/{consola-Byg0ybzh.d.mts → consola-BdgyPEfx.d.mts} +1 -1
- package/dist/constants/index.d.mts +2 -2
- package/dist/constants/index.mjs +3 -3
- package/dist/{createDataTable-BbUL9Vva.mjs → createDataTable-rXBqGglI.mjs} +105 -32
- package/dist/{createGroup-C2WCfYPB.mjs → createGroup-BU4olYtB.mjs} +29 -14
- package/dist/{createPagination-Tp4C4He8.mjs → createPagination-CHF7SmmK.mjs} +11 -7
- package/dist/{createTokens-qv02qq4_.mjs → createRegistry-Dl-bSSTr.mjs} +21 -302
- package/dist/{createSelection-AmMX6sjc.mjs → createSelection-Csaa-C8p.mjs} +28 -21
- package/dist/{createSingle-CffpxK__.mjs → createSingle-8xbHAIpY.mjs} +13 -17
- package/dist/createTokens-lNg2M_P_.mjs +302 -0
- package/dist/{createTrinity-vvXk0ARD.mjs → createTrinity-BTCs1pYx.mjs} +34 -31
- package/dist/data-table/adapters/client/index.d.mts +1 -1
- package/dist/data-table/adapters/client/index.mjs +1 -1
- package/dist/data-table/adapters/index.d.mts +4 -4
- package/dist/data-table/adapters/index.mjs +5 -5
- package/dist/data-table/adapters/server/index.d.mts +1 -1
- package/dist/data-table/adapters/server/index.mjs +1 -1
- package/dist/data-table/adapters/virtual/index.d.mts +1 -1
- package/dist/data-table/adapters/virtual/index.mjs +1 -1
- package/dist/data-table/index.d.mts +6 -6
- package/dist/data-table/index.mjs +6 -6
- package/dist/date/index.d.mts +2 -2
- package/dist/date/index.mjs +4 -4
- package/dist/features/adapters/flagsmith/index.d.mts +1 -1
- package/dist/features/adapters/flagsmith/index.mjs +1 -1
- package/dist/features/adapters/launchdarkly/index.d.mts +1 -1
- package/dist/features/adapters/launchdarkly/index.mjs +1 -1
- package/dist/features/adapters/posthog/index.d.mts +1 -1
- package/dist/features/adapters/posthog/index.mjs +1 -1
- package/dist/features/index.d.mts +2 -2
- package/dist/features/index.mjs +1 -1
- package/dist/{globals-CAv9vqkP.mjs → globals-CKdzjeLe.mjs} +1 -1
- package/dist/htmlElements-D4oMQZPJ.mjs +28 -0
- package/dist/{index-M8EpGjjA.d.mts → index-1XdASTjp.d.mts} +1 -1
- package/dist/{index-D26_u_WI.d.mts → index-B7cqgTBL.d.mts} +1599 -468
- package/dist/{index-DoGxDgdN.d.mts → index-BJGcVy7e.d.mts} +57 -6
- package/dist/index-BgCkepP_.d.mts +31 -0
- package/dist/{index-B_XLHftL.d.mts → index-BxKMMWnQ.d.mts} +301 -263
- package/dist/{index-tyzwWFHS.d.mts → index-BzFHTW59.d.mts} +1 -1
- package/dist/{index-CDcl4wPo.d.mts → index-CT5SCLzW.d.mts} +1 -1
- package/dist/{index-BUsrN1vL.d.mts → index-DE3bWw11.d.mts} +2 -2
- package/dist/{index-76fQGkkO.d.mts → index-DTvqw22G.d.mts} +8 -11
- package/dist/{index-F2Fmxnzi.d.mts → index-Dp1HjBxJ.d.mts} +1 -1
- package/dist/{index-B_AlCD7t.d.mts → index-DuddF-NR.d.mts} +2 -9
- package/dist/{index-Dxx0eMLi.d.mts → index-GOpjKzaJ.d.mts} +1 -1
- package/dist/index.d.mts +23 -23
- package/dist/index.mjs +31 -29
- package/dist/json/attributes.json +280 -4
- package/dist/json/importMap.json +60 -0
- package/dist/json/tags.json +136 -2
- package/dist/json/web-types.json +1186 -347
- package/dist/locale/adapters/index.d.mts +2 -2
- package/dist/locale/adapters/index.mjs +2 -2
- package/dist/locale/adapters/v0/index.d.mts +1 -1
- package/dist/locale/adapters/v0/index.mjs +1 -1
- package/dist/locale/adapters/vue-i18n/index.d.mts +1 -1
- package/dist/locale/index.d.mts +3 -3
- package/dist/locale/index.mjs +2 -2
- package/dist/logger/adapters/consola/index.d.mts +1 -1
- package/dist/logger/adapters/index.d.mts +4 -4
- package/dist/logger/adapters/index.mjs +2 -2
- package/dist/logger/adapters/pino/index.d.mts +1 -1
- package/dist/logger/adapters/v0/index.d.mts +1 -1
- package/dist/logger/adapters/v0/index.mjs +1 -1
- package/dist/logger/index.d.mts +5 -5
- package/dist/logger/index.mjs +2 -2
- package/dist/notifications/index.d.mts +2 -2
- package/dist/notifications/index.mjs +3 -54
- package/dist/palettes/ant/generate/index.mjs +1 -0
- package/dist/palettes/ant/index.d.mts +1 -1
- package/dist/palettes/index.d.mts +3 -3
- package/dist/palettes/leonardo/generate/index.mjs +1 -0
- package/dist/palettes/material/generate/index.mjs +1 -0
- package/dist/palettes/material/index.d.mts +1 -1
- package/dist/palettes/md1/index.d.mts +1 -1
- package/dist/palettes/md2/index.d.mts +1 -1
- package/dist/palettes/radix/index.d.mts +1 -1
- package/dist/palettes/tailwind/index.d.mts +1 -1
- package/dist/permissions/adapters/index.d.mts +1 -1
- package/dist/permissions/adapters/index.mjs +2 -2
- package/dist/permissions/adapters/v0/index.d.mts +1 -1
- package/dist/permissions/adapters/v0/index.mjs +1 -1
- package/dist/permissions/index.d.mts +1 -1
- package/dist/permissions/index.mjs +2 -2
- package/dist/{pino-BxddSW2l.d.mts → pino-DNfCEb0p.d.mts} +1 -1
- package/dist/{posthog-B8PEtlFr.mjs → posthog-DZNnPXxS.mjs} +1 -1
- package/dist/rules/index.d.mts +1 -1
- package/dist/rules/index.mjs +1 -1
- package/dist/{server-DNUTnISs.d.mts → server-3ilWFwqe.d.mts} +1 -1
- package/dist/{server-CIftA0pK.mjs → server-y7zLSCSx.mjs} +1 -1
- package/dist/storage/adapters/index.d.mts +2 -2
- package/dist/storage/adapters/index.mjs +1 -1
- package/dist/storage/adapters/memory/index.d.mts +1 -1
- package/dist/storage/adapters/memory/index.mjs +1 -1
- package/dist/storage/index.d.mts +3 -3
- package/dist/storage/index.mjs +2 -2
- package/dist/theme/adapters/index.d.mts +1 -1
- package/dist/theme/adapters/index.mjs +4 -4
- package/dist/theme/adapters/unhead/index.d.mts +1 -1
- package/dist/theme/adapters/unhead/index.mjs +1 -1
- package/dist/theme/adapters/v0/index.d.mts +1 -1
- package/dist/theme/adapters/v0/index.mjs +1 -1
- package/dist/theme/index.d.mts +1 -1
- package/dist/theme/index.mjs +3 -3
- package/dist/{toArray-doLQVI56.mjs → toArray-as9BWxBK.mjs} +10 -0
- package/dist/types/index.d.mts +2 -2
- package/dist/{unhead-BYw3a366.mjs → unhead-DZiD-4Tx.mjs} +2 -2
- package/dist/{useClickOutside-CnCQkh7M.mjs → useClickOutside-CmCUD_Pf.mjs} +577 -1024
- package/dist/{useFeatures-CMpkbU8Q.mjs → useFeatures-ZIvzzuEV.mjs} +16 -6
- package/dist/{useLocale-BYmoHpo6.mjs → useLocale-DTJx3aKR.mjs} +19 -7
- package/dist/{useLogger-BfaFH-Bi.mjs → useLogger-BBTcMN61.mjs} +33 -16
- package/dist/useNotifications-H4knpvNw.mjs +869 -0
- package/dist/{usePermissions-y3Uum3nO.mjs → usePermissions-B_G12Dwd.mjs} +14 -6
- package/dist/{useRules-eqSXpP9V.mjs → useRules--7Qoo60I.mjs} +15 -5
- package/dist/{useTheme-CFH6I91x.mjs → useTheme-Co05TEeD.mjs} +20 -8
- package/dist/utilities/index.d.mts +1 -1
- package/dist/utilities/index.mjs +14 -9
- package/dist/{v0-DXqYgj7J.mjs → v0-BrTEO5sv.mjs} +2 -2
- package/dist/{v0-BAG8p0si.d.mts → v0-CdusXjY_.d.mts} +1 -1
- package/dist/{v0-CFV8A5PF.mjs → v0-D0Mh3EVG.mjs} +1 -1
- package/dist/{v0-BpgPZ1qB.d.mts → v0-D7Fm2C3Y.d.mts} +1 -1
- package/dist/{v0-BqikIgl0.mjs → v0-DeiZuexg.mjs} +1 -1
- package/dist/{v0-DOq_Ia5H.mjs → v0-Dq3zhexO.mjs} +2 -2
- package/dist/{v0-C2UMaHUa.d.mts → v0-DrOub-e1.d.mts} +1 -1
- package/dist/{virtual-D1HwNBLS.mjs → virtual-C0yHf1DC.mjs} +2 -2
- package/dist/{virtual-BaQWQ9ji.d.mts → virtual-D4fckewC.d.mts} +1 -1
- package/package.json +10 -7
- package/SKILL.md +0 -95
- package/dist/adapters-BOVGPozf.mjs +0 -2
- package/dist/adapters-BbNfjyvY.mjs +0 -5
- package/dist/adapters-BhNTUuxE.mjs +0 -2
- package/dist/adapters-RwNU3wNj.mjs +0 -4
- package/dist/htmlElements-DcYtv0hg.mjs +0 -75
- package/dist/index-D6mQAEs2.d.mts +0 -79
- /package/dist/{adapter-DNKjooxI.d.mts → adapter-Dhq68tz0.d.mts} +0 -0
- /package/dist/{flagsmith-DQnnahG5.mjs → flagsmith-Dbh1h8WF.mjs} +0 -0
- /package/dist/{index-DxruGeVY.d.mts → index-C6rdXZ7j.d.mts} +0 -0
- /package/dist/{index-PWQavSPf.d.mts → index-CFhUdAHM.d.mts} +0 -0
- /package/dist/{index-c55Utzva.d.mts → index-CROz1VSV.d.mts} +0 -0
- /package/dist/{launchdarkly-2_48EJ1_.mjs → launchdarkly-BKtW-idu.mjs} +0 -0
- /package/dist/{memory-DUyWthic.d.mts → memory-CeSQE-QV.d.mts} +0 -0
- /package/dist/{memory-XCMtkld1.mjs → memory-oYBvtkgx.mjs} +0 -0
- /package/dist/{v0-4OQBCeda.mjs → v0-Bmow1q_x.mjs} +0 -0
|
@@ -0,0 +1,869 @@
|
|
|
1
|
+
import { t as IN_BROWSER } from "./globals-CKdzjeLe.mjs";
|
|
2
|
+
import { isFunction, isNull, isUndefined, useId as useId$1 } from "./utilities/index.mjs";
|
|
3
|
+
import { i as useContext, t as createTrinity } from "./createTrinity-BTCs1pYx.mjs";
|
|
4
|
+
import { o as createPluginContext } from "./useLogger-BBTcMN61.mjs";
|
|
5
|
+
import { t as createRegistry } from "./createRegistry-Dl-bSSTr.mjs";
|
|
6
|
+
import { onScopeDispose, shallowRef } from "vue";
|
|
7
|
+
//#region src/composables/useTimer/index.ts
|
|
8
|
+
/**
|
|
9
|
+
* @module useTimer
|
|
10
|
+
*
|
|
11
|
+
* @see https://0.vuetifyjs.com/composables/system/use-timer
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* A reactive timer composable with pause/resume support.
|
|
15
|
+
*
|
|
16
|
+
* Key features:
|
|
17
|
+
* - Start/stop/pause/resume controls
|
|
18
|
+
* - Reactive remaining time tracking
|
|
19
|
+
* - One-shot (default) or repeating mode
|
|
20
|
+
* - Automatic cleanup on scope disposal
|
|
21
|
+
* - SSR-safe
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { useTimer } from '@vuetify/v0'
|
|
26
|
+
*
|
|
27
|
+
* const timer = useTimer(() => console.log('fired'), { duration: 5000 })
|
|
28
|
+
* timer.start()
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Creates a reactive timer with pause/resume support.
|
|
33
|
+
*
|
|
34
|
+
* @param handler Callback invoked when the timer fires.
|
|
35
|
+
* @param options Timer configuration.
|
|
36
|
+
* @returns Timer controls and reactive state.
|
|
37
|
+
*
|
|
38
|
+
* @see https://0.vuetifyjs.com/composables/system/use-timer
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const timer = useTimer(() => console.log('fired'), { duration: 5000 })
|
|
43
|
+
*
|
|
44
|
+
* timer.start()
|
|
45
|
+
* timer.pause()
|
|
46
|
+
* timer.resume()
|
|
47
|
+
* timer.stop()
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function useTimer(handler, options = {}) {
|
|
51
|
+
const { duration = 1e3, repeat = false } = options;
|
|
52
|
+
const remaining = shallowRef(duration);
|
|
53
|
+
const isActive = shallowRef(false);
|
|
54
|
+
const isPaused = shallowRef(false);
|
|
55
|
+
let timeoutId;
|
|
56
|
+
let trackingId;
|
|
57
|
+
let startedAt = 0;
|
|
58
|
+
let budget = duration;
|
|
59
|
+
function clearTimer() {
|
|
60
|
+
if (!/* @__PURE__ */ isUndefined(timeoutId)) {
|
|
61
|
+
globalThis.clearTimeout(timeoutId);
|
|
62
|
+
timeoutId = void 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function startTracking() {
|
|
66
|
+
stopTracking();
|
|
67
|
+
if (!IN_BROWSER) return;
|
|
68
|
+
trackingId = globalThis.setInterval(() => {
|
|
69
|
+
if (!isActive.value || isPaused.value) return;
|
|
70
|
+
const elapsed = Date.now() - startedAt;
|
|
71
|
+
remaining.value = Math.max(0, budget - elapsed);
|
|
72
|
+
}, 100);
|
|
73
|
+
}
|
|
74
|
+
function stopTracking() {
|
|
75
|
+
if (!/* @__PURE__ */ isUndefined(trackingId)) {
|
|
76
|
+
globalThis.clearInterval(trackingId);
|
|
77
|
+
trackingId = void 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function fire() {
|
|
81
|
+
clearTimer();
|
|
82
|
+
stopTracking();
|
|
83
|
+
handler();
|
|
84
|
+
if (repeat) begin(duration);
|
|
85
|
+
else {
|
|
86
|
+
isActive.value = false;
|
|
87
|
+
remaining.value = 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function begin(ms) {
|
|
91
|
+
clearTimer();
|
|
92
|
+
stopTracking();
|
|
93
|
+
budget = ms;
|
|
94
|
+
startedAt = Date.now();
|
|
95
|
+
remaining.value = ms;
|
|
96
|
+
isActive.value = true;
|
|
97
|
+
isPaused.value = false;
|
|
98
|
+
timeoutId = globalThis.setTimeout(fire, ms);
|
|
99
|
+
startTracking();
|
|
100
|
+
}
|
|
101
|
+
function start() {
|
|
102
|
+
if (duration < 0) return;
|
|
103
|
+
begin(duration);
|
|
104
|
+
}
|
|
105
|
+
function stop() {
|
|
106
|
+
clearTimer();
|
|
107
|
+
stopTracking();
|
|
108
|
+
isActive.value = false;
|
|
109
|
+
isPaused.value = false;
|
|
110
|
+
remaining.value = duration;
|
|
111
|
+
}
|
|
112
|
+
function pause() {
|
|
113
|
+
if (!isActive.value || isPaused.value) return;
|
|
114
|
+
const elapsed = Date.now() - startedAt;
|
|
115
|
+
budget = Math.max(0, budget - elapsed);
|
|
116
|
+
remaining.value = budget;
|
|
117
|
+
clearTimer();
|
|
118
|
+
stopTracking();
|
|
119
|
+
isPaused.value = true;
|
|
120
|
+
}
|
|
121
|
+
function resume() {
|
|
122
|
+
if (!isPaused.value) return;
|
|
123
|
+
isPaused.value = false;
|
|
124
|
+
startedAt = Date.now();
|
|
125
|
+
timeoutId = globalThis.setTimeout(fire, budget);
|
|
126
|
+
startTracking();
|
|
127
|
+
}
|
|
128
|
+
onScopeDispose(() => {
|
|
129
|
+
clearTimer();
|
|
130
|
+
stopTracking();
|
|
131
|
+
}, true);
|
|
132
|
+
return {
|
|
133
|
+
start,
|
|
134
|
+
stop,
|
|
135
|
+
pause,
|
|
136
|
+
resume,
|
|
137
|
+
remaining,
|
|
138
|
+
isActive,
|
|
139
|
+
isPaused
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/composables/createQueue/index.ts
|
|
144
|
+
/**
|
|
145
|
+
* @module createQueue
|
|
146
|
+
*
|
|
147
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-queue
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
* A queue composable for managing time-based collections with:
|
|
151
|
+
* - Automatic timeout-based removal
|
|
152
|
+
* - Pause/resume functionality
|
|
153
|
+
* - FIFO (First In, First Out) ordering
|
|
154
|
+
* - Manual dismissal support
|
|
155
|
+
* - Queue progression management
|
|
156
|
+
*
|
|
157
|
+
* Built on top of createRegistry, the queue automatically manages timeouts for tickets,
|
|
158
|
+
* ensuring only the first ticket in the queue is active at any time. When a ticket
|
|
159
|
+
* expires or is removed, the next ticket in the queue automatically becomes active.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { createQueue } from '@vuetify/v0'
|
|
164
|
+
*
|
|
165
|
+
* const queue = createQueue()
|
|
166
|
+
* queue.register({ value: 'Notification 1', timeout: 3000 })
|
|
167
|
+
* queue.register({ value: 'Notification 2', timeout: 3000 })
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
/**
|
|
171
|
+
* Creates a new queue instance
|
|
172
|
+
*
|
|
173
|
+
* @param options The options for the queue instance
|
|
174
|
+
* @returns A new queue instance
|
|
175
|
+
*
|
|
176
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-queue
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { useQueue } from '@vuetify/v0'
|
|
181
|
+
*
|
|
182
|
+
* const queue = useQueue()
|
|
183
|
+
*
|
|
184
|
+
* // Register an ticket with default timeout (3000ms)
|
|
185
|
+
* const ticket1 = queue.register({ value: 'Ticket 1' })
|
|
186
|
+
*
|
|
187
|
+
* // Register an ticket with custom timeout
|
|
188
|
+
* const ticket2 = queue.register({ value: 'Ticket 2', timeout: 5000 })
|
|
189
|
+
*
|
|
190
|
+
* // Register a persistent ticket that must be manually dismissed
|
|
191
|
+
* const ticket3 = queue.register({ value: 'Ticket 3', timeout: -1 })
|
|
192
|
+
*
|
|
193
|
+
* // Dismiss an ticket using the convenience method
|
|
194
|
+
* ticket3.dismiss()
|
|
195
|
+
*
|
|
196
|
+
* console.log(queue.size) // 2
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
function createQueue(_options = {}) {
|
|
200
|
+
const { timeout: _timeout = 3e3, ...options } = _options;
|
|
201
|
+
const registry = createRegistry({
|
|
202
|
+
...options,
|
|
203
|
+
events: true
|
|
204
|
+
});
|
|
205
|
+
const timers = /* @__PURE__ */ new Map();
|
|
206
|
+
function createTicketTimer(ticket) {
|
|
207
|
+
if (/* @__PURE__ */ isUndefined(ticket.timeout) || ticket.timeout < 0 || ticket.isPaused) return;
|
|
208
|
+
const timer = useTimer(() => {
|
|
209
|
+
timers.delete(ticket.id);
|
|
210
|
+
registry.unregister(ticket.id);
|
|
211
|
+
resume();
|
|
212
|
+
}, { duration: ticket.timeout });
|
|
213
|
+
timers.set(ticket.id, timer);
|
|
214
|
+
timer.start();
|
|
215
|
+
}
|
|
216
|
+
function stopTimer(id) {
|
|
217
|
+
const timer = timers.get(id);
|
|
218
|
+
if (timer) {
|
|
219
|
+
timer.stop();
|
|
220
|
+
timers.delete(id);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function register(registration = {}) {
|
|
224
|
+
const id = registration.id ?? /* @__PURE__ */ useId$1();
|
|
225
|
+
const timeout = Object.prototype.hasOwnProperty.call(registration, "timeout") ? registration.timeout : _timeout;
|
|
226
|
+
const ticket = {
|
|
227
|
+
...registration,
|
|
228
|
+
id,
|
|
229
|
+
timeout,
|
|
230
|
+
isPaused: registry.size > 0,
|
|
231
|
+
dismiss: () => unregister(id)
|
|
232
|
+
};
|
|
233
|
+
const registered = registry.register(ticket);
|
|
234
|
+
createTicketTimer(registered);
|
|
235
|
+
return registered;
|
|
236
|
+
}
|
|
237
|
+
function unregister(id) {
|
|
238
|
+
const ticket = /* @__PURE__ */ isUndefined(id) ? registry.seek("first") : registry.get(id);
|
|
239
|
+
if (!ticket) return void 0;
|
|
240
|
+
const wasFirst = ticket.index === 0;
|
|
241
|
+
stopTimer(ticket.id);
|
|
242
|
+
registry.unregister(ticket.id);
|
|
243
|
+
if (wasFirst) resume();
|
|
244
|
+
return ticket;
|
|
245
|
+
}
|
|
246
|
+
function offboard(ids) {
|
|
247
|
+
let hadFirst = false;
|
|
248
|
+
for (const id of ids) {
|
|
249
|
+
const ticket = registry.get(id);
|
|
250
|
+
if (!ticket) continue;
|
|
251
|
+
if (ticket.index === 0) hadFirst = true;
|
|
252
|
+
stopTimer(ticket.id);
|
|
253
|
+
}
|
|
254
|
+
registry.offboard(ids);
|
|
255
|
+
if (hadFirst) resume();
|
|
256
|
+
}
|
|
257
|
+
function pause() {
|
|
258
|
+
const ticket = registry.seek("first");
|
|
259
|
+
if (!ticket || ticket.isPaused) return void 0;
|
|
260
|
+
timers.get(ticket.id)?.pause();
|
|
261
|
+
return registry.upsert(ticket.id, { isPaused: true });
|
|
262
|
+
}
|
|
263
|
+
function resume() {
|
|
264
|
+
const ticket = registry.seek("first");
|
|
265
|
+
if (!ticket || ticket.index !== 0 || !ticket.isPaused) return void 0;
|
|
266
|
+
const updated = registry.upsert(ticket.id, { isPaused: false });
|
|
267
|
+
const timer = timers.get(updated.id);
|
|
268
|
+
if (timer) timer.start();
|
|
269
|
+
else createTicketTimer(updated);
|
|
270
|
+
return updated;
|
|
271
|
+
}
|
|
272
|
+
function clear() {
|
|
273
|
+
for (const timer of timers.values()) timer.stop();
|
|
274
|
+
timers.clear();
|
|
275
|
+
registry.clear();
|
|
276
|
+
}
|
|
277
|
+
function dispose() {
|
|
278
|
+
clear();
|
|
279
|
+
registry.dispose();
|
|
280
|
+
}
|
|
281
|
+
onScopeDispose(dispose, true);
|
|
282
|
+
function onboard(registrations) {
|
|
283
|
+
return registry.batch(() => registrations.map((registration) => register(registration)));
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
...registry,
|
|
287
|
+
register,
|
|
288
|
+
unregister,
|
|
289
|
+
onboard,
|
|
290
|
+
offboard,
|
|
291
|
+
pause,
|
|
292
|
+
resume,
|
|
293
|
+
clear,
|
|
294
|
+
dispose,
|
|
295
|
+
get size() {
|
|
296
|
+
return registry.size;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Creates a new queue context.
|
|
302
|
+
*
|
|
303
|
+
* @param options The options for the queue context.
|
|
304
|
+
* @returns A new queue context.
|
|
305
|
+
*
|
|
306
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-queue
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* import { createQueueContext } from '@vuetify/v0'
|
|
311
|
+
*
|
|
312
|
+
* export const [useQueue, provideQueue, context] = createQueueContext({
|
|
313
|
+
* timeout: 5000,
|
|
314
|
+
* })
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
function createQueueContext(_options = {}) {
|
|
318
|
+
const { namespace = "v0:queue", ...options } = _options;
|
|
319
|
+
return createTrinity(namespace, createQueue(options));
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Returns the current queue instance.
|
|
323
|
+
*
|
|
324
|
+
* @param namespace The namespace for the queue context. Defaults to `'v0:queue'`.
|
|
325
|
+
* @returns The current queue instance.
|
|
326
|
+
*
|
|
327
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-queue
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```vue
|
|
331
|
+
* <script setup lang="ts">
|
|
332
|
+
* import { useQueue } from '@vuetify/v0'
|
|
333
|
+
*
|
|
334
|
+
* const queue = useQueue()
|
|
335
|
+
* <\/script>
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
function useQueue(namespace = "v0:queue") {
|
|
339
|
+
return useContext(namespace);
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/composables/useNotifications/index.ts
|
|
343
|
+
/**
|
|
344
|
+
* @module useNotifications
|
|
345
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
346
|
+
*
|
|
347
|
+
* @remarks
|
|
348
|
+
* Notification management composable built on createRegistry and createQueue.
|
|
349
|
+
* Registry stores the full notification lifecycle (permanent record).
|
|
350
|
+
* Queue manages the display surface (toasts) with FIFO ordering and auto-dismiss.
|
|
351
|
+
*
|
|
352
|
+
* Supports:
|
|
353
|
+
* - Push notifications with severity levels and configurable timeouts
|
|
354
|
+
* - State mutations: read, seen, archived, snoozed
|
|
355
|
+
* - Bulk operations: readAll, archiveAll, clear
|
|
356
|
+
* - Toast queue with pause/resume and auto-dismiss
|
|
357
|
+
* - Adapter integration via event system
|
|
358
|
+
* - Plugin installation via createNotificationsPlugin
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```ts
|
|
362
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
363
|
+
*
|
|
364
|
+
* const notifications = useNotifications()
|
|
365
|
+
* notifications.send({ subject: 'Saved', severity: 'success' })
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
function createNotifications(options = {}) {
|
|
369
|
+
const { timeout = 3e3, ...registryOptions } = options;
|
|
370
|
+
const registry = createRegistry({
|
|
371
|
+
...registryOptions,
|
|
372
|
+
events: true,
|
|
373
|
+
reactive: true
|
|
374
|
+
});
|
|
375
|
+
const queue = createQueue({
|
|
376
|
+
timeout,
|
|
377
|
+
events: true,
|
|
378
|
+
reactive: true
|
|
379
|
+
});
|
|
380
|
+
registry.on("unregister:ticket", (ticket) => {
|
|
381
|
+
if (queue.has(ticket.id)) queue.unregister(ticket.id);
|
|
382
|
+
});
|
|
383
|
+
/**
|
|
384
|
+
* Build a full {@link NotificationTicket} from raw input
|
|
385
|
+
*
|
|
386
|
+
* @param input The notification input to hydrate.
|
|
387
|
+
* @returns A partial ticket with timestamps, lifecycle methods, and an ID.
|
|
388
|
+
* @internal Used by {@link send}, {@link register}, and {@link onboard}.
|
|
389
|
+
*/
|
|
390
|
+
function hydrate(input) {
|
|
391
|
+
const id = input.id ?? /* @__PURE__ */ useId$1();
|
|
392
|
+
const now = /* @__PURE__ */ new Date();
|
|
393
|
+
return {
|
|
394
|
+
...input,
|
|
395
|
+
id,
|
|
396
|
+
createdAt: now,
|
|
397
|
+
readAt: null,
|
|
398
|
+
seenAt: null,
|
|
399
|
+
archivedAt: null,
|
|
400
|
+
snoozedUntil: null,
|
|
401
|
+
read: () => read(id),
|
|
402
|
+
unread: () => unread(id),
|
|
403
|
+
seen: () => seen(id),
|
|
404
|
+
archive: () => archive(id),
|
|
405
|
+
unarchive: () => unarchive(id),
|
|
406
|
+
snooze: (until) => snooze(id, until),
|
|
407
|
+
wake: () => wake(id),
|
|
408
|
+
dismiss: () => queue.unregister(id)
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Create a notification and enqueue it for toast display
|
|
413
|
+
*
|
|
414
|
+
* @param input The notification input to create.
|
|
415
|
+
* @returns The hydrated notification ticket.
|
|
416
|
+
* @remarks Hydrates the input with timestamps and lifecycle methods, registers
|
|
417
|
+
* it in the registry, adds it to the display queue, and emits
|
|
418
|
+
* `notification:received`. The ticket auto-dismisses after the configured
|
|
419
|
+
* timeout unless paused.
|
|
420
|
+
*
|
|
421
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts
|
|
425
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
426
|
+
*
|
|
427
|
+
* const notifications = useNotifications()
|
|
428
|
+
*
|
|
429
|
+
* // Basic toast
|
|
430
|
+
* notifications.send({ subject: 'Changes saved', severity: 'success' })
|
|
431
|
+
*
|
|
432
|
+
* // With custom timeout
|
|
433
|
+
* const ticket = notifications.send({ subject: 'Connection lost', severity: 'error', timeout: 10000 })
|
|
434
|
+
*
|
|
435
|
+
* console.log(ticket.id) // 'generated-id'
|
|
436
|
+
* console.log(ticket.createdAt) // Date
|
|
437
|
+
* console.log(ticket.readAt) // null
|
|
438
|
+
*
|
|
439
|
+
* // Ticket convenience methods
|
|
440
|
+
* ticket.read() // marks as read
|
|
441
|
+
* ticket.dismiss() // removes from toast queue, keeps in registry
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
function send(input) {
|
|
445
|
+
const ticket = registry.register(hydrate(input));
|
|
446
|
+
queue.register(/* @__PURE__ */ isUndefined(input.timeout) ? { id: ticket.id } : {
|
|
447
|
+
id: ticket.id,
|
|
448
|
+
timeout: input.timeout
|
|
449
|
+
});
|
|
450
|
+
registry.emit("notification:received", ticket);
|
|
451
|
+
return ticket;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Register a notification in the registry without adding it to the toast queue
|
|
455
|
+
*
|
|
456
|
+
* @param input The notification input to register.
|
|
457
|
+
* @returns The hydrated notification ticket.
|
|
458
|
+
* @remarks Overrides the base registry `register` to hydrate the input with
|
|
459
|
+
* timestamps and lifecycle methods. Use for historical or pre-existing items
|
|
460
|
+
* that should appear in an inbox but not pop up as toasts.
|
|
461
|
+
*
|
|
462
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```ts
|
|
466
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
467
|
+
*
|
|
468
|
+
* const notifications = useNotifications()
|
|
469
|
+
*
|
|
470
|
+
* // Register a historical item (appears in inbox, not as toast)
|
|
471
|
+
* const ticket = notifications.register({ id: 'old-1', subject: 'Deployed v2.1' })
|
|
472
|
+
*
|
|
473
|
+
* console.log(ticket.createdAt) // Date
|
|
474
|
+
* console.log(ticket.readAt) // null
|
|
475
|
+
*
|
|
476
|
+
* // Lifecycle methods work the same as send()
|
|
477
|
+
* ticket.read()
|
|
478
|
+
* ticket.archive()
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
function register(input) {
|
|
482
|
+
return registry.register(hydrate(input));
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Bulk version of {@link register}
|
|
486
|
+
*
|
|
487
|
+
* @param inputs Array of notification inputs to register.
|
|
488
|
+
* @returns Array of hydrated notification tickets.
|
|
489
|
+
* @remarks Registers multiple notifications into the registry without toast
|
|
490
|
+
* display. Wraps all registrations in a single `registry.batch()` call so
|
|
491
|
+
* reactive updates are deferred until the entire batch completes.
|
|
492
|
+
*
|
|
493
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
498
|
+
*
|
|
499
|
+
* const notifications = useNotifications()
|
|
500
|
+
*
|
|
501
|
+
* // Load historical items on mount
|
|
502
|
+
* const tickets = notifications.onboard([
|
|
503
|
+
* { id: 'n1', subject: 'Welcome to the team' },
|
|
504
|
+
* { id: 'n2', subject: 'Setup complete', severity: 'success' },
|
|
505
|
+
* ])
|
|
506
|
+
*
|
|
507
|
+
* console.log(tickets.length) // 2
|
|
508
|
+
* console.log(notifications.queue.values()) // [] (no toasts)
|
|
509
|
+
* console.log(notifications.values().length) // 2 (in registry)
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
function onboard(inputs) {
|
|
513
|
+
return registry.batch(() => inputs.map((input) => register(input)));
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Mark a notification as read
|
|
517
|
+
*
|
|
518
|
+
* @param id The ID of the notification to mark as read.
|
|
519
|
+
* @remarks Sets `readAt` to the current time and emits `notification:read`.
|
|
520
|
+
* Adapters listen to this event for outbound sync.
|
|
521
|
+
*
|
|
522
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```ts
|
|
526
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
527
|
+
*
|
|
528
|
+
* const notifications = useNotifications()
|
|
529
|
+
*
|
|
530
|
+
* const ticket = notifications.send({ subject: 'New message' })
|
|
531
|
+
*
|
|
532
|
+
* notifications.read(ticket.id)
|
|
533
|
+
* console.log(ticket.readAt) // Date
|
|
534
|
+
*
|
|
535
|
+
* // Or via ticket convenience method
|
|
536
|
+
* ticket.read()
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
function read(id) {
|
|
540
|
+
registry.upsert(id, { readAt: /* @__PURE__ */ new Date() }, "notification:read");
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Mark a notification as unread
|
|
544
|
+
*
|
|
545
|
+
* @param id The ID of the notification to mark as unread.
|
|
546
|
+
* @remarks Clears `readAt` and emits `notification:unread`.
|
|
547
|
+
*
|
|
548
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* ```ts
|
|
552
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
553
|
+
*
|
|
554
|
+
* const notifications = useNotifications()
|
|
555
|
+
*
|
|
556
|
+
* notifications.unread('notif-1')
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
function unread(id) {
|
|
560
|
+
registry.upsert(id, { readAt: null }, "notification:unread");
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Mark a notification as seen
|
|
564
|
+
*
|
|
565
|
+
* @param id The ID of the notification to mark as seen.
|
|
566
|
+
* @remarks Sets `seenAt` to the current time and emits `notification:seen`.
|
|
567
|
+
* Distinct from read — seen tracks whether the notification appeared in the
|
|
568
|
+
* user's viewport, while read indicates the user actively engaged with it.
|
|
569
|
+
*
|
|
570
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```ts
|
|
574
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
575
|
+
*
|
|
576
|
+
* const notifications = useNotifications()
|
|
577
|
+
*
|
|
578
|
+
* // Mark as seen when visible in inbox viewport
|
|
579
|
+
* notifications.seen('notif-1')
|
|
580
|
+
* ```
|
|
581
|
+
*/
|
|
582
|
+
function seen(id) {
|
|
583
|
+
registry.upsert(id, { seenAt: /* @__PURE__ */ new Date() }, "notification:seen");
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Archive a notification
|
|
587
|
+
*
|
|
588
|
+
* @param id The ID of the notification to archive.
|
|
589
|
+
* @remarks Sets `archivedAt` to the current time and emits `notification:archived`.
|
|
590
|
+
*
|
|
591
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ```ts
|
|
595
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
596
|
+
*
|
|
597
|
+
* const notifications = useNotifications()
|
|
598
|
+
*
|
|
599
|
+
* notifications.archive('notif-1')
|
|
600
|
+
* ```
|
|
601
|
+
*/
|
|
602
|
+
function archive(id) {
|
|
603
|
+
registry.upsert(id, { archivedAt: /* @__PURE__ */ new Date() }, "notification:archived");
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Restore an archived notification
|
|
607
|
+
*
|
|
608
|
+
* @param id The ID of the notification to unarchive.
|
|
609
|
+
* @remarks Clears `archivedAt` and emits `notification:unarchived`.
|
|
610
|
+
*
|
|
611
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```ts
|
|
615
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
616
|
+
*
|
|
617
|
+
* const notifications = useNotifications()
|
|
618
|
+
*
|
|
619
|
+
* notifications.unarchive('notif-1')
|
|
620
|
+
* ```
|
|
621
|
+
*/
|
|
622
|
+
function unarchive(id) {
|
|
623
|
+
registry.upsert(id, { archivedAt: null }, "notification:unarchived");
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Snooze a notification until a given time
|
|
627
|
+
*
|
|
628
|
+
* @param id The ID of the notification to snooze.
|
|
629
|
+
* @param until The time at which the snooze expires.
|
|
630
|
+
* @remarks Sets `snoozedUntil` and emits `notification:snoozed`. The composable
|
|
631
|
+
* does not auto-wake — consumers are responsible for calling {@link wake} when
|
|
632
|
+
* the snooze expires (e.g., via a timer or server push).
|
|
633
|
+
*
|
|
634
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* ```ts
|
|
638
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
639
|
+
*
|
|
640
|
+
* const notifications = useNotifications()
|
|
641
|
+
*
|
|
642
|
+
* const tomorrow = new Date(Date.now() + 86_400_000)
|
|
643
|
+
* notifications.snooze('notif-1', tomorrow)
|
|
644
|
+
* ```
|
|
645
|
+
*/
|
|
646
|
+
function snooze(id, until) {
|
|
647
|
+
registry.upsert(id, { snoozedUntil: until }, "notification:snoozed");
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Cancel a snooze
|
|
651
|
+
*
|
|
652
|
+
* @param id The ID of the notification to wake.
|
|
653
|
+
* @remarks Clears `snoozedUntil` and emits `notification:unsnoozed`.
|
|
654
|
+
*
|
|
655
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* ```ts
|
|
659
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
660
|
+
*
|
|
661
|
+
* const notifications = useNotifications()
|
|
662
|
+
*
|
|
663
|
+
* notifications.wake('notif-1')
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
function wake(id) {
|
|
667
|
+
registry.upsert(id, { snoozedUntil: null }, "notification:unsnoozed");
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Mark all unread notifications as read
|
|
671
|
+
*
|
|
672
|
+
* @remarks Iterates all notifications and marks unread ones as read in a single
|
|
673
|
+
* batch. Skips already-read notifications to preserve their original `readAt`
|
|
674
|
+
* timestamp. Emits `notification:read` for each affected notification.
|
|
675
|
+
*
|
|
676
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* ```ts
|
|
680
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
681
|
+
*
|
|
682
|
+
* const notifications = useNotifications()
|
|
683
|
+
*
|
|
684
|
+
* notifications.send({ subject: 'Message 1' })
|
|
685
|
+
* notifications.send({ subject: 'Message 2' })
|
|
686
|
+
*
|
|
687
|
+
* notifications.readAll()
|
|
688
|
+
*
|
|
689
|
+
* console.log(notifications.values().every(t => t.readAt !== null)) // true
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
692
|
+
function readAll() {
|
|
693
|
+
const now = /* @__PURE__ */ new Date();
|
|
694
|
+
registry.batch(() => {
|
|
695
|
+
for (const ticket of registry.values()) if (/* @__PURE__ */ isNull(ticket.readAt)) registry.upsert(ticket.id, { readAt: now }, "notification:read");
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Archive all unarchived notifications
|
|
700
|
+
*
|
|
701
|
+
* @remarks Iterates all notifications and archives unarchived ones in a single
|
|
702
|
+
* batch. Skips already-archived notifications to preserve their original
|
|
703
|
+
* `archivedAt` timestamp. Emits `notification:archived` for each affected notification.
|
|
704
|
+
*
|
|
705
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
706
|
+
*
|
|
707
|
+
* @example
|
|
708
|
+
* ```ts
|
|
709
|
+
* import { useNotifications } from '@vuetify/v0'
|
|
710
|
+
*
|
|
711
|
+
* const notifications = useNotifications()
|
|
712
|
+
*
|
|
713
|
+
* notifications.send({ subject: 'Alert 1' })
|
|
714
|
+
* notifications.send({ subject: 'Alert 2' })
|
|
715
|
+
*
|
|
716
|
+
* notifications.archiveAll()
|
|
717
|
+
*
|
|
718
|
+
* console.log(notifications.values().every(t => t.archivedAt !== null)) // true
|
|
719
|
+
* ```
|
|
720
|
+
*/
|
|
721
|
+
function archiveAll() {
|
|
722
|
+
const now = /* @__PURE__ */ new Date();
|
|
723
|
+
registry.batch(() => {
|
|
724
|
+
for (const ticket of registry.values()) if (/* @__PURE__ */ isNull(ticket.archivedAt)) registry.upsert(ticket.id, { archivedAt: now }, "notification:archived");
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
return {
|
|
728
|
+
...registry,
|
|
729
|
+
send,
|
|
730
|
+
register,
|
|
731
|
+
onboard,
|
|
732
|
+
queue,
|
|
733
|
+
read,
|
|
734
|
+
unread,
|
|
735
|
+
seen,
|
|
736
|
+
archive,
|
|
737
|
+
unarchive,
|
|
738
|
+
snooze,
|
|
739
|
+
wake,
|
|
740
|
+
readAll,
|
|
741
|
+
archiveAll,
|
|
742
|
+
get size() {
|
|
743
|
+
return registry.size;
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
function noop() {}
|
|
748
|
+
const EMPTY = [];
|
|
749
|
+
function createNotificationsFallback() {
|
|
750
|
+
const stub = {
|
|
751
|
+
id: "",
|
|
752
|
+
index: 0,
|
|
753
|
+
value: 0,
|
|
754
|
+
valueIsIndex: true,
|
|
755
|
+
createdAt: /* @__PURE__ */ new Date(0),
|
|
756
|
+
readAt: null,
|
|
757
|
+
seenAt: null,
|
|
758
|
+
archivedAt: null,
|
|
759
|
+
snoozedUntil: null,
|
|
760
|
+
read: noop,
|
|
761
|
+
unread: noop,
|
|
762
|
+
seen: noop,
|
|
763
|
+
archive: noop,
|
|
764
|
+
unarchive: noop,
|
|
765
|
+
snooze: noop,
|
|
766
|
+
wake: noop,
|
|
767
|
+
dismiss: noop,
|
|
768
|
+
unregister: noop
|
|
769
|
+
};
|
|
770
|
+
return {
|
|
771
|
+
collection: /* @__PURE__ */ new Map(),
|
|
772
|
+
size: 0,
|
|
773
|
+
send: () => stub,
|
|
774
|
+
queue: {
|
|
775
|
+
collection: /* @__PURE__ */ new Map(),
|
|
776
|
+
size: 0,
|
|
777
|
+
register: () => ({}),
|
|
778
|
+
unregister: () => void 0,
|
|
779
|
+
has: () => false,
|
|
780
|
+
get: () => void 0,
|
|
781
|
+
keys: () => EMPTY,
|
|
782
|
+
values: () => EMPTY,
|
|
783
|
+
entries: () => EMPTY,
|
|
784
|
+
browse: () => void 0,
|
|
785
|
+
lookup: () => void 0,
|
|
786
|
+
upsert: () => ({}),
|
|
787
|
+
seek: () => void 0,
|
|
788
|
+
move: () => void 0,
|
|
789
|
+
on: noop,
|
|
790
|
+
off: noop,
|
|
791
|
+
emit: noop,
|
|
792
|
+
dispose: noop,
|
|
793
|
+
clear: noop,
|
|
794
|
+
reindex: noop,
|
|
795
|
+
batch: (fn) => fn(),
|
|
796
|
+
onboard: () => EMPTY,
|
|
797
|
+
offboard: noop,
|
|
798
|
+
pause: () => void 0,
|
|
799
|
+
resume: () => void 0
|
|
800
|
+
},
|
|
801
|
+
read: noop,
|
|
802
|
+
unread: noop,
|
|
803
|
+
seen: noop,
|
|
804
|
+
archive: noop,
|
|
805
|
+
unarchive: noop,
|
|
806
|
+
snooze: noop,
|
|
807
|
+
wake: noop,
|
|
808
|
+
readAll: noop,
|
|
809
|
+
archiveAll: noop,
|
|
810
|
+
clear: noop,
|
|
811
|
+
has: () => false,
|
|
812
|
+
get: () => void 0,
|
|
813
|
+
keys: () => EMPTY,
|
|
814
|
+
values: () => EMPTY,
|
|
815
|
+
entries: () => EMPTY,
|
|
816
|
+
browse: () => void 0,
|
|
817
|
+
lookup: () => void 0,
|
|
818
|
+
upsert: () => stub,
|
|
819
|
+
register: () => stub,
|
|
820
|
+
unregister: noop,
|
|
821
|
+
reindex: noop,
|
|
822
|
+
move: () => void 0,
|
|
823
|
+
seek: () => void 0,
|
|
824
|
+
on: noop,
|
|
825
|
+
off: noop,
|
|
826
|
+
emit: noop,
|
|
827
|
+
dispose: noop,
|
|
828
|
+
batch: (fn) => fn(),
|
|
829
|
+
onboard: () => EMPTY,
|
|
830
|
+
offboard: noop
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Notification management with registry, event system, and optional adapters.
|
|
835
|
+
*
|
|
836
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-notifications
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
* ```ts
|
|
840
|
+
* import { createNotificationsPlugin, useNotifications } from '@vuetify/v0'
|
|
841
|
+
*
|
|
842
|
+
* // Install as plugin
|
|
843
|
+
* app.use(createNotificationsPlugin())
|
|
844
|
+
*
|
|
845
|
+
* // Use in components
|
|
846
|
+
* const notifications = useNotifications()
|
|
847
|
+
* notifications.send({ subject: 'Saved', severity: 'success' })
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
const [createNotificationsContext, createNotificationsPlugin, useNotifications] = createPluginContext("v0:notifications", (options) => createNotifications(options), {
|
|
851
|
+
fallback: () => createNotificationsFallback(),
|
|
852
|
+
setup: (context, app, options) => {
|
|
853
|
+
app.onUnmount(() => {
|
|
854
|
+
context.dispose();
|
|
855
|
+
context.queue.dispose();
|
|
856
|
+
});
|
|
857
|
+
const { adapter } = options;
|
|
858
|
+
if (!adapter) return;
|
|
859
|
+
adapter.setup({
|
|
860
|
+
send: context.send,
|
|
861
|
+
register: context.register,
|
|
862
|
+
on: context.on,
|
|
863
|
+
off: context.off
|
|
864
|
+
});
|
|
865
|
+
if (/* @__PURE__ */ isFunction(adapter.dispose)) app.onUnmount(() => adapter.dispose());
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
//#endregion
|
|
869
|
+
export { createQueue as a, useTimer as c, useNotifications as i, createNotificationsContext as n, createQueueContext as o, createNotificationsPlugin as r, useQueue as s, createNotifications as t };
|