@vuetify/v0 0.0.2-beta.3 → 0.0.2-beta.4

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.
@@ -0,0 +1,614 @@
1
+ import { createContext, createPlugin, createTrinity, useContext } from "./createTrinity-CwGvQ2ng.mjs";
2
+ import { IN_BROWSER, createTokensContext, useGroup, useLogger, useRegistry, useSingle } from "./useTheme-tY7MoBKr.mjs";
3
+ import { isArray, isFunction } from "./utilities-lZSfrXgw.mjs";
4
+ import { toArray } from "./transformers-BTjuwbOV.mjs";
5
+ import { computed, getCurrentInstance, getCurrentScope, isRef, onMounted, onScopeDispose, onUnmounted, ref, shallowReactive, shallowRef, toRaw, toRef, toValue, unref, watch } from "vue";
6
+
7
+ //#region src/composables/useEventListener/index.ts
8
+ function useEventListener(target, event, listener, options) {
9
+ const cleanups = [];
10
+ function cleanup() {
11
+ for (const fn of cleanups) fn();
12
+ cleanups.length = 0;
13
+ }
14
+ const register = (el, event$1, listener$1, options$1) => {
15
+ el.addEventListener(event$1, listener$1, options$1);
16
+ return () => el.removeEventListener(event$1, listener$1, options$1);
17
+ };
18
+ const stopWatcher = watch(() => [
19
+ toValue(target),
20
+ toValue(event),
21
+ unref(listener),
22
+ toValue(options)
23
+ ], ([el, events, listeners, opts]) => {
24
+ cleanup();
25
+ if (!el) return;
26
+ const eventList = toArray(events);
27
+ const listenerList = toArray(listeners);
28
+ for (const event$1 of eventList) for (const listenerFn of listenerList) cleanups.push(register(el, event$1, listenerFn, opts));
29
+ }, {
30
+ immediate: true,
31
+ flush: "post"
32
+ });
33
+ function stop() {
34
+ stopWatcher();
35
+ cleanup();
36
+ }
37
+ onScopeDispose(stop, true);
38
+ return stop;
39
+ }
40
+ /**
41
+ * Convenience function for attaching event listeners to the window object.
42
+ * This function provides a simplified API by pre-binding the window target,
43
+ * making it easier to handle window-specific events with automatic cleanup.
44
+ *
45
+ * @param event Event name(s) to listen for from WindowEventMap.
46
+ * @param listener Event handler function(s) with proper window event typing.
47
+ * @param options Optional event listener configuration.
48
+ * @returns Function to manually remove all attached listeners.
49
+ */
50
+ function useWindowEventListener(event, listener, options) {
51
+ return useEventListener(window, event, listener, options);
52
+ }
53
+ /**
54
+ * Convenience function for attaching event listeners to the document object.
55
+ * This function provides a simplified API by pre-binding the document target,
56
+ * making it easier to handle document-specific events with automatic cleanup.
57
+ *
58
+ * @param event Event name(s) to listen for from DocumentEventMap.
59
+ * @param listener Event handler function(s) with proper document event typing.
60
+ * @param options Optional event listener configuration.
61
+ * @returns Function to manually remove all attached listeners.
62
+ */
63
+ function useDocumentEventListener(event, listener, options) {
64
+ return useEventListener(document, event, listener, options);
65
+ }
66
+
67
+ //#endregion
68
+ //#region src/composables/useFilter/index.ts
69
+ function defaultFilter(query, item, keys, mode = "some") {
70
+ const queries = Array.isArray(query) ? query.map((q) => String(q).toLowerCase()) : [String(query).toLowerCase()];
71
+ function match(value, q) {
72
+ return String(value).toLowerCase().includes(q);
73
+ }
74
+ const values = typeof item === "object" && item !== null ? keys?.length ? keys.map((k) => item[k]) : Object.values(item) : [item];
75
+ const stringValues = values.map((v) => String(v).toLowerCase());
76
+ if (mode === "some") return stringValues.some((val) => match(val, queries[0]));
77
+ if (mode === "every") return stringValues.every((val) => match(val, queries[0]));
78
+ if (mode === "union") return queries.some((q) => stringValues.some((val) => match(val, q)));
79
+ if (mode === "intersection") return queries.every((q) => stringValues.some((val) => match(val, q)));
80
+ return false;
81
+ }
82
+ function toRefOrGetter(value) {
83
+ return isRef(value) ? value : typeof value === "function" ? toRef(value) : toRef(() => value);
84
+ }
85
+ /**
86
+ * Creates a reactive filter for arrays based on query matching with configurable search modes.
87
+ * Supports 'some' (any field matches), 'every' (all fields match), 'union' (any query matches),
88
+ * and 'intersection' (all queries match) filtering strategies.
89
+ *
90
+ * @param query Filter query to match against items.
91
+ * @param items Collection of items to filter.
92
+ * @param options Optional configuration for the filter behavior.
93
+ * @template Z The type of the items being filtered.
94
+ * @returns A computed reference to the filtered items based on the query and options.
95
+ */
96
+ function useFilter(query, items, options = {}) {
97
+ const { customFilter, keys, mode = "some" } = options;
98
+ const filterFunction = customFilter ?? ((q, i) => defaultFilter(q, i, keys, mode));
99
+ const itemsRef = isRef(items) ? items : toRef(() => items);
100
+ const queryRef = toRefOrGetter(query);
101
+ const filteredItems = computed(() => {
102
+ const q = toValue(queryRef);
103
+ const queries = (Array.isArray(q) ? q : [q]).filter((q$1) => String(q$1).trim());
104
+ if (queries.length === 0) return itemsRef.value;
105
+ const queryParam = queries.length === 1 ? queries[0] : queries;
106
+ return itemsRef.value.filter((item) => filterFunction(queryParam, item));
107
+ });
108
+ return { items: filteredItems };
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/composables/useForm/index.ts
113
+ function useForm(options) {
114
+ const registry = useRegistry(options);
115
+ const validateOn = options?.validateOn || "submit";
116
+ function parse(value) {
117
+ return value.toLowerCase().split(/\s+/);
118
+ }
119
+ function validatesOn(event) {
120
+ return parse(validateOn).includes(event);
121
+ }
122
+ const isValidating = computed(() => {
123
+ for (const ticket of registry.collection.values()) if (ticket.isValidating.value) return true;
124
+ return false;
125
+ });
126
+ const isValid = computed(() => {
127
+ let hasFields = false;
128
+ for (const ticket of registry.values()) {
129
+ hasFields = true;
130
+ if (ticket.isValid.value === false) return false;
131
+ if (ticket.isValid.value === null) return null;
132
+ }
133
+ return hasFields ? true : null;
134
+ });
135
+ function reset() {
136
+ for (const ticket of registry.values()) ticket.reset();
137
+ }
138
+ async function submit() {
139
+ return validate(registry.keys());
140
+ }
141
+ async function validate(id) {
142
+ const validating = toArray(id);
143
+ if (validatesOn("submit")) {
144
+ const results = await Promise.all(validating.map(async (id$1) => await registry.get(id$1)?.validate() ?? true));
145
+ return results.every(Boolean);
146
+ }
147
+ const tickets = validating.map((id$1) => registry.get(id$1)).filter(Boolean);
148
+ return tickets.every((ticket) => ticket.isValid.value === true);
149
+ }
150
+ function register(registration) {
151
+ const model = shallowRef(registration.value == null ? "" : toValue(registration.value));
152
+ const rules = registration.rules || [];
153
+ const errors = shallowRef([]);
154
+ const isValidating$1 = shallowRef(false);
155
+ const initialValue = model.value;
156
+ const triggers = registration.validateOn || validateOn;
157
+ const isPristine = shallowRef(true);
158
+ const isValid$1 = shallowRef(null);
159
+ function _validatesOn(event) {
160
+ return parse(triggers).includes(event);
161
+ }
162
+ function _reset() {
163
+ model.value = initialValue;
164
+ errors.value = [];
165
+ isPristine.value = true;
166
+ isValid$1.value = null;
167
+ }
168
+ async function validate$1(silent = false) {
169
+ if (rules.length === 0) return true;
170
+ isValidating$1.value = true;
171
+ try {
172
+ const results = await Promise.all(rules.map((rule) => rule(model.value)));
173
+ const errorMessages = results.filter((result) => typeof result === "string");
174
+ if (!silent) {
175
+ errors.value = errorMessages;
176
+ isValid$1.value = errorMessages.length === 0;
177
+ isPristine.value = toValue(model) === initialValue;
178
+ }
179
+ return errorMessages.length === 0;
180
+ } finally {
181
+ isValidating$1.value = false;
182
+ }
183
+ }
184
+ const item = {
185
+ ...registration,
186
+ rules,
187
+ errors,
188
+ disabled: registration.disabled || false,
189
+ validateOn: triggers,
190
+ isValidating: isValidating$1,
191
+ isPristine,
192
+ isValid: isValid$1,
193
+ reset: _reset,
194
+ validate: validate$1
195
+ };
196
+ const ticket = registry.register(item);
197
+ Object.defineProperty(ticket, "value", {
198
+ get() {
199
+ return model.value;
200
+ },
201
+ set(val) {
202
+ model.value = val;
203
+ isPristine.value = val === initialValue;
204
+ isValid$1.value = null;
205
+ if (_validatesOn("change")) validate$1();
206
+ },
207
+ enumerable: true,
208
+ configurable: true
209
+ });
210
+ return ticket;
211
+ }
212
+ return {
213
+ ...registry,
214
+ register,
215
+ reset,
216
+ submit,
217
+ validateOn,
218
+ isValid,
219
+ isValidating
220
+ };
221
+ }
222
+
223
+ //#endregion
224
+ //#region src/composables/useKeydown/index.ts
225
+ /**
226
+ * Sets up global keyboard event listeners for specified key handlers with automatic cleanup.
227
+ * This composable automatically starts listening when mounted and cleans up when the scope
228
+ * is disposed, providing a clean way to handle global keyboard interactions.
229
+ *
230
+ * @param handlers A single handler or array of handlers to register for keydown events.
231
+ * @returns Object with methods to manually start and stop listening for keydown events.
232
+ */
233
+ function useKeydown(handlers) {
234
+ const keyHandlers = Array.isArray(handlers) ? handlers : [handlers];
235
+ function onKeydown(event) {
236
+ const handler = keyHandlers.find((h$1) => h$1.key === event.key);
237
+ if (handler) {
238
+ if (handler.preventDefault) event.preventDefault();
239
+ if (handler.stopPropagation) event.stopPropagation();
240
+ handler.handler(event);
241
+ }
242
+ }
243
+ function startListening() {
244
+ document.addEventListener("keydown", onKeydown);
245
+ }
246
+ function stopListening() {
247
+ document.removeEventListener("keydown", onKeydown);
248
+ }
249
+ if (getCurrentScope()) onMounted(startListening);
250
+ onScopeDispose(stopListening, true);
251
+ return {
252
+ startListening,
253
+ stopListening
254
+ };
255
+ }
256
+
257
+ //#endregion
258
+ //#region src/composables/useLayout/index.ts
259
+ function useLayout(_options = {}) {
260
+ const { enroll = true, events = true,...options } = _options;
261
+ const registry = useGroup({
262
+ enroll,
263
+ events,
264
+ ...options
265
+ });
266
+ const sizes = shallowReactive(/* @__PURE__ */ new Map());
267
+ const height = shallowRef(0);
268
+ const width = shallowRef(0);
269
+ const bounds = {
270
+ top: computed(() => sum("top")),
271
+ bottom: computed(() => sum("bottom")),
272
+ left: computed(() => sum("left")),
273
+ right: computed(() => sum("right"))
274
+ };
275
+ const main = {
276
+ x: computed(() => bounds.left.value),
277
+ y: computed(() => bounds.top.value),
278
+ width: computed(() => width.value - bounds.left.value - bounds.right.value),
279
+ height: computed(() => height.value - bounds.top.value - bounds.bottom.value)
280
+ };
281
+ function sum(position) {
282
+ let total = 0;
283
+ for (const item of registry.values()) if (item.position === position && item.isActive.value) total += sizes.get(item.id) ?? item.value ?? 0;
284
+ return total;
285
+ }
286
+ function register(registration) {
287
+ const item = {
288
+ position: registration.position,
289
+ order: registration.order ?? 0,
290
+ ...registration
291
+ };
292
+ const ticket = registry.register(item);
293
+ sizes.set(ticket.id, ticket.value);
294
+ return ticket;
295
+ }
296
+ if (IN_BROWSER && getCurrentInstance()) {
297
+ function resize() {
298
+ height.value = window.innerHeight;
299
+ width.value = window.innerWidth;
300
+ }
301
+ onMounted(() => {
302
+ resize();
303
+ window.addEventListener("resize", resize);
304
+ });
305
+ onUnmounted(() => {
306
+ window.removeEventListener("resize", resize);
307
+ });
308
+ }
309
+ registry.on("unregister", (item) => {
310
+ sizes.delete(item.id);
311
+ });
312
+ return {
313
+ ...registry,
314
+ register,
315
+ bounds,
316
+ main,
317
+ sizes,
318
+ height,
319
+ width
320
+ };
321
+ }
322
+
323
+ //#endregion
324
+ //#region src/composables/useLocale/adapters/v0.ts
325
+ /**
326
+ * Vuetify0.x locale adapter implementation
327
+ *
328
+ * This adapter provides translation and number formatting
329
+ * capabilities using the Intl API and supports both
330
+ * numbered and named variables in translation strings.
331
+ */
332
+ var Vuetify0LocaleAdapter = class {
333
+ t(message, ...params) {
334
+ let resolvedMessage = message;
335
+ if (params.length > 0 && typeof params[0] === "object" && params[0] !== null && !Array.isArray(params[0])) {
336
+ const variables = params[0];
337
+ resolvedMessage = resolvedMessage.replace(/{([a-zA-Z][a-zA-Z0-9_]*)}/g, (match, name) => {
338
+ return variables[name] === void 0 ? match : String(variables[name]);
339
+ });
340
+ params = params.slice(1);
341
+ }
342
+ resolvedMessage = resolvedMessage.replace(/\{(\d+)\}/g, (match, index) => {
343
+ const idx = Number.parseInt(index, 10);
344
+ if (params[idx] !== void 0) return String(params[idx]);
345
+ return match;
346
+ });
347
+ return resolvedMessage;
348
+ }
349
+ n(value, locale, ...params) {
350
+ if (!IN_BROWSER || !locale) return value.toString();
351
+ const options = params[0];
352
+ return new Intl.NumberFormat(String(locale), options).format(value);
353
+ }
354
+ };
355
+
356
+ //#endregion
357
+ //#region src/composables/useLocale/index.ts
358
+ /**
359
+ * Creates a locale registry for managing internationalization with translations and number formatting.
360
+ * Supports message resolution with token references and locale-specific number formatting.
361
+ *
362
+ * @param namespace The namespace for the locale context.
363
+ * @param options Configuration including adapter and messages.
364
+ * @template Z The type of the locale context.
365
+ * @template E The type of the locale items managed by the registry.
366
+ * @returns An array containing the inject function, provide function, and the locale context.
367
+ */
368
+ function createLocale(namespace = "v0:locale", options = {}) {
369
+ const { adapter = new Vuetify0LocaleAdapter(), messages = {} } = options;
370
+ const [useLocaleContext, _provideLocaleContext] = createContext(namespace);
371
+ const registry = useSingle();
372
+ for (const id in messages) {
373
+ registry.register({
374
+ value: messages[id],
375
+ id
376
+ });
377
+ if (id === options.default && !registry.selectedId.value) registry.select(id);
378
+ }
379
+ function t(key, ...params) {
380
+ const locale = registry.selectedId.value;
381
+ if (!locale) return key;
382
+ const message = messages[locale]?.[key];
383
+ const template = typeof message === "string" ? resolve(locale, message) : key;
384
+ return adapter.t(template, ...params);
385
+ }
386
+ function n(value, ...params) {
387
+ return adapter.n(value, registry.selectedId.value, ...params);
388
+ }
389
+ function resolve(locale, str) {
390
+ return str.replace(/{([a-zA-Z0-9.-_]+)}/g, (match, linkedKey) => {
391
+ const [linkedLocale, ...rest] = linkedKey.split(".");
392
+ const keyPath = rest.join(".");
393
+ const targetLocale = messages[linkedLocale] ? linkedLocale : locale;
394
+ const targetKey = messages[linkedLocale] ? keyPath : linkedKey;
395
+ const resolved = messages[targetLocale]?.[targetKey];
396
+ return typeof resolved === "string" ? resolve(targetLocale, resolved) : match;
397
+ });
398
+ }
399
+ const context = {
400
+ ...registry,
401
+ t,
402
+ n
403
+ };
404
+ function provideLocaleContext(_context = context, app) {
405
+ return _provideLocaleContext(_context, app);
406
+ }
407
+ return createTrinity(useLocaleContext, provideLocaleContext, context);
408
+ }
409
+ /**
410
+ * Simple hook to access the locale context.
411
+ *
412
+ * @returns The locale context containing translation and formatting functions.
413
+ */
414
+ function useLocale() {
415
+ return useContext("v0:locale")();
416
+ }
417
+ /**
418
+ * Creates a Vue plugin for internationalization with locale management and translation support.
419
+ * Integrates with token system for message resolution and provides app-wide locale context.
420
+ *
421
+ * @param options Configuration for adapter, default locale, and messages.
422
+ * @template Z The type of the locale context.
423
+ * @template E The type of the locale items managed by the registry.
424
+ * @template R The type of the token context.
425
+ * @template O The type of the token items managed by the registry.
426
+ * @returns Vue install function for the plugin
427
+ */
428
+ function createLocalePlugin(options = {}) {
429
+ const { adapter = new Vuetify0LocaleAdapter(), messages = {} } = options;
430
+ const [, provideLocaleTokenContext, tokensContext] = createTokensContext("v0:locale:tokens", messages);
431
+ const [, provideLocaleContext, localeContext] = createLocale("v0:locale", {
432
+ adapter,
433
+ messages
434
+ });
435
+ return createPlugin({
436
+ namespace: "v0:locale",
437
+ provide: (app) => {
438
+ provideLocaleContext(localeContext, app);
439
+ provideLocaleTokenContext(tokensContext, app);
440
+ }
441
+ });
442
+ }
443
+
444
+ //#endregion
445
+ //#region src/composables/useProxyModel/index.ts
446
+ /**
447
+ * Creates a proxy model for two-way binding with a selection context.
448
+ *
449
+ * @param registry SelectionContext | GroupContext | SingleContext | StepContext
450
+ * @template Z The type of items managed by the selection.
451
+ * @template E The type of the selection context.
452
+ * @returns The proxy model for two-way binding with the selection context.
453
+ */
454
+ function useProxyModel(registry, initial, options, _transformIn, _transformOut) {
455
+ const logger = useLogger();
456
+ const reactivity = options?.deep ? ref : shallowRef;
457
+ const internal = reactivity(initial ? toArray(initial) : []);
458
+ const isModelArray = isArray(initial);
459
+ function transformIn(val) {
460
+ if (isFunction(_transformIn)) return _transformIn(val);
461
+ return toArray(val);
462
+ }
463
+ function transformOut(val) {
464
+ if (isFunction(_transformOut)) return _transformOut(val);
465
+ return isModelArray ? val : val[0];
466
+ }
467
+ const model = computed({
468
+ get() {
469
+ return transformOut(internal.value);
470
+ },
471
+ set(val) {
472
+ internal.value = transformIn(val);
473
+ }
474
+ });
475
+ const watcher = watch(registry.selectedIds, (val, oldVal) => {
476
+ if (toRaw(val).symmetricDifference(toRaw(oldVal)).size === 0) return;
477
+ if (val.size === 0) {
478
+ model.value = [];
479
+ return;
480
+ }
481
+ model.value = Array.from(registry.selectedValues.value);
482
+ });
483
+ watch(model, (val) => {
484
+ const currentIds = new Set(toValue(registry.selectedIds));
485
+ const targetIds = /* @__PURE__ */ new Set();
486
+ for (const value of toArray(val)) {
487
+ const id = registry.browse(value);
488
+ if (id) targetIds.add(id);
489
+ else logger.warn("Unable to find id for value", value);
490
+ }
491
+ watcher.pause();
492
+ if (isModelArray) {
493
+ for (const id of currentIds.difference(targetIds)) registry.selectedIds.delete(id);
494
+ for (const id of targetIds.difference(currentIds)) registry.selectedIds.add(id);
495
+ } else {
496
+ const next = targetIds.values().next().value;
497
+ const last = currentIds.values().next().value;
498
+ registry.selectedIds.delete(last);
499
+ registry.selectedIds.add(next);
500
+ }
501
+ watcher.resume();
502
+ });
503
+ return model;
504
+ }
505
+
506
+ //#endregion
507
+ //#region src/composables/useStorage/adapters/memory.ts
508
+ /**
509
+ * In-memory storage adapter that implements the StorageAdapter interface.
510
+ * This adapter provides temporary storage that persists only for the current
511
+ * session and is useful for testing or when persistent storage is not available.
512
+ */
513
+ var MemoryAdapter = class {
514
+ store = /* @__PURE__ */ new Map();
515
+ get length() {
516
+ return this.store.size;
517
+ }
518
+ getItem(key) {
519
+ return this.store.get(key) ?? null;
520
+ }
521
+ setItem(key, value) {
522
+ this.store.set(key, value);
523
+ }
524
+ removeItem(key) {
525
+ this.store.delete(key);
526
+ }
527
+ key(index) {
528
+ return Array.from(this.store.keys())[index];
529
+ }
530
+ };
531
+
532
+ //#endregion
533
+ //#region src/composables/useStorage/index.ts
534
+ const [useStorageContext, provideStorageContext] = createContext("v0:storage");
535
+ /**
536
+ * Creates a reactive storage system with automatic persistence and cross-adapter support.
537
+ * This function provides a consistent interface for storing and retrieving reactive values
538
+ * that automatically sync with the underlying storage adapter (localStorage, memory, etc.).
539
+ *
540
+ * @param options Optional configuration for storage adapter, prefix, and serialization.
541
+ * @template E The type of the storage context.
542
+ * @returns A storage context object with get, set, remove, and clear methods.
543
+ */
544
+ function createStorage(options = {}) {
545
+ const { adapter = IN_BROWSER ? window.localStorage : new MemoryAdapter(), prefix = "v0:", serializer = {
546
+ read: JSON.parse,
547
+ write: JSON.stringify
548
+ } } = options;
549
+ const cache = /* @__PURE__ */ new Map();
550
+ function get(key, defaultValue) {
551
+ const prefixedKey = `${prefix}${key}`;
552
+ if (cache.has(prefixedKey)) return cache.get(prefixedKey);
553
+ const storedValue = adapter?.getItem(prefixedKey);
554
+ let initialValue = defaultValue;
555
+ if (storedValue) try {
556
+ initialValue = serializer.read(storedValue);
557
+ } catch (error) {
558
+ console.error(`[v0:storage] Failed to parse stored value for key "${prefixedKey}":`, error);
559
+ }
560
+ const valueRef = ref(initialValue);
561
+ watch(valueRef, (newValue) => {
562
+ if (newValue === void 0 || newValue === null) adapter?.removeItem(prefixedKey);
563
+ else adapter?.setItem(prefixedKey, serializer.write(newValue));
564
+ }, { deep: true });
565
+ cache.set(prefixedKey, valueRef);
566
+ return valueRef;
567
+ }
568
+ function set(key, value) {
569
+ const valueRef = get(key);
570
+ valueRef.value = value;
571
+ }
572
+ function remove(key) {
573
+ const prefixedKey = `${prefix}${key}`;
574
+ adapter?.removeItem(prefixedKey);
575
+ cache.delete(prefixedKey);
576
+ }
577
+ function clear() {
578
+ for (const key of cache.keys()) adapter?.removeItem(key);
579
+ cache.clear();
580
+ }
581
+ return {
582
+ get,
583
+ set,
584
+ remove,
585
+ clear
586
+ };
587
+ }
588
+ /**
589
+ * Simple hook to access the storage context.
590
+ *
591
+ * @returns The storage context containing reactive storage methods.
592
+ */
593
+ function useStorage() {
594
+ return useStorageContext();
595
+ }
596
+ /**
597
+ * Creates a Vue plugin for reactive storage capabilities with automatic persistence.
598
+ * Provides app-wide access to reactive storage that syncs with the configured adapter.
599
+ *
600
+ * @param options Optional configuration for the storage system.
601
+ * @returns A Vue plugin object with install method.
602
+ */
603
+ function createStoragePlugin(options = {}) {
604
+ const context = createStorage(options);
605
+ return createPlugin({
606
+ namespace: "v0:storage",
607
+ provide: (app) => {
608
+ provideStorageContext(context, app);
609
+ }
610
+ });
611
+ }
612
+
613
+ //#endregion
614
+ export { createLocale, createLocalePlugin, createStorage, createStoragePlugin, provideStorageContext, useDocumentEventListener, useEventListener, useFilter, useForm, useKeydown, useLayout, useLocale, useProxyModel, useStorage, useStorageContext, useWindowEventListener };
@@ -0,0 +1,79 @@
1
+ import { inject, provide } from "vue";
2
+
3
+ //#region src/factories/createContext/index.ts
4
+ /**
5
+ * A simple wrapper for tapping into a v0 namespace
6
+ * @param key The provided string or InjectionKey
7
+ * @template Z The type values for the context.
8
+ * @returns A function that retrieves context
9
+ * @throws Error if namespace is not found.
10
+ *
11
+ * @see https://vuejs.org/api/composition-api-dependency-injection.html#inject
12
+ */
13
+ function useContext(key) {
14
+ return function(namespace) {
15
+ const context = inject(namespace || key, void 0);
16
+ if (context === void 0) throw new Error(`Context "${String(key)}" not found. Ensure it's provided by an ancestor.`);
17
+ return context;
18
+ };
19
+ }
20
+ /**
21
+ * A simple wrapper for Vues provide & inject systems
22
+ * to create context for managing application state
23
+ * @param key The provided string or InjectionKey
24
+ * @template Z The type values for the context.
25
+ * @returns A tuple containing provide/inject
26
+ *
27
+ * @see https://vuejs.org/api/composition-api-dependency-injection.html#provide
28
+ * @see https://0.vuetifyjs.com/composables/foundation/create-context
29
+ */
30
+ function createContext(key) {
31
+ function provideContext(context, app) {
32
+ app?.provide(key, context) ?? provide(key, context);
33
+ return context;
34
+ }
35
+ return [useContext(key), provideContext];
36
+ }
37
+
38
+ //#endregion
39
+ //#region src/factories/createPlugin/index.ts
40
+ /**
41
+ * A universal plugin factory to reduce boilerplate code for Vue plugin creation
42
+ * @param options Configurable object with namespace and provide/setup methods
43
+ * @returns A Vue plugin object with install method that runs app w/ context
44
+ *
45
+ * @see https://vuejs.org/api/application.html#app-runwithcontext
46
+ * @see https://0.vuetifyjs.com/factories/create-plugin
47
+ */
48
+ function createPlugin(options) {
49
+ return { install(app) {
50
+ app.runWithContext(() => {
51
+ options.provide(app);
52
+ options.setup?.(app);
53
+ });
54
+ } };
55
+ }
56
+
57
+ //#endregion
58
+ //#region src/factories/createTrinity/index.ts
59
+ /**
60
+ * A tuple containing Vue's provide/inject and a context object
61
+ * @param createContext The function that creates the context
62
+ * @param provideContext The function that provides context
63
+ * @param context The underlying context object singleton
64
+ * @template Z The type parameter for the context value
65
+ * @template E The vmodel type for the context state.
66
+ * @returns [createContext, provideContext, context]
67
+ *
68
+ * @see https://0.vuetifyjs.com/composables/foundation/create-trinity
69
+ */
70
+ function createTrinity(createContext$1, provideContext, context) {
71
+ return [
72
+ createContext$1,
73
+ (_context = context, app) => provideContext(_context, app),
74
+ context
75
+ ];
76
+ }
77
+
78
+ //#endregion
79
+ export { createContext, createPlugin, createTrinity, useContext };
@@ -0,0 +1,3 @@
1
+ import { ContextTrinity, createTrinity } from "../index-DfahEz6s.mjs";
2
+ import { ContextKey, PluginOptions, createContext, createPlugin, useContext } from "../index-oCBJwhpG.mjs";
3
+ export { ContextKey, ContextTrinity, PluginOptions, createContext, createPlugin, createTrinity, useContext };
@@ -0,0 +1,4 @@
1
+ import { createContext, createPlugin, createTrinity, useContext } from "../createTrinity-CwGvQ2ng.mjs";
2
+ import "../factories-DOLmqhVS.mjs";
3
+
4
+ export { createContext, createPlugin, createTrinity, useContext };
File without changes