@vuetify/v0 0.0.6 → 0.0.8
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/README.md +62 -189
- package/dist/browser/index.js +1091 -547
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +4 -4
- package/dist/{components-B5k361i-.js → components-BJF0Dsww.js} +4 -188
- package/dist/composables/index.d.ts +2 -2
- package/dist/composables/index.js +3 -3
- package/dist/{composables-CAbYjAkR.js → composables-D-M1DZRo.js} +1090 -364
- package/dist/constants/index.js +1 -1
- package/dist/{globals-CHVv7nNV.js → globals-B2jAuapu.js} +1 -1
- package/dist/{index-BhPlroXd.d.ts → index-Bcj8Vovs.d.ts} +1106 -252
- package/dist/index-DoTdnxOm.d.ts +241 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/dist/index-BQfe0WBZ.d.ts +0 -410
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as isNullOrUndefined, d as mergeDeep, i as isFunction, l as isString, n as isArray, r as isBoolean, s as isObject, t as genId, u as isUndefined } from "./utilities-rsKHgU2m.js";
|
|
2
|
-
import { a as SUPPORTS_OBSERVER, i as SUPPORTS_MUTATION_OBSERVER, n as SUPPORTS_INTERSECTION_OBSERVER, s as __LOGGER_ENABLED__, t as IN_BROWSER } from "./globals-
|
|
1
|
+
import { a as isNullOrUndefined, d as mergeDeep, i as isFunction, l as isString, n as isArray, o as isNumber, r as isBoolean, s as isObject, t as genId, u as isUndefined } from "./utilities-rsKHgU2m.js";
|
|
2
|
+
import { a as SUPPORTS_OBSERVER, i as SUPPORTS_MUTATION_OBSERVER, n as SUPPORTS_INTERSECTION_OBSERVER, s as __LOGGER_ENABLED__, t as IN_BROWSER } from "./globals-B2jAuapu.js";
|
|
3
3
|
import { computed, getCurrentInstance, getCurrentScope, inject, isRef, onMounted, onScopeDispose, onUnmounted, provide, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRef, toValue, unref, watch } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/composables/createContext/index.ts
|
|
@@ -7,20 +7,25 @@ import { computed, getCurrentInstance, getCurrentScope, inject, isRef, onMounted
|
|
|
7
7
|
* Injects a context provided by an ancestor component.
|
|
8
8
|
*
|
|
9
9
|
* @param key The key of the context to inject.
|
|
10
|
+
* @param defaultValue Optional default value if context is not found.
|
|
10
11
|
* @template Z The type of the context.
|
|
11
12
|
* @returns The injected context.
|
|
12
|
-
* @throws An error if the context is not found.
|
|
13
|
+
* @throws An error if the context is not found and no default is provided.
|
|
13
14
|
*
|
|
14
15
|
* @see https://vuejs.org/api/composition-api-dependency-injection.html#inject
|
|
15
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-context
|
|
16
|
+
* @see https://0.vuetifyjs.com/composables/foundation/create-context#use-context
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```ts
|
|
19
|
-
*
|
|
20
|
+
* // Without default value
|
|
21
|
+
* const context = useContext<MyContext>('my-context')
|
|
22
|
+
*
|
|
23
|
+
* // With default value
|
|
24
|
+
* const context = useContext<MyContext>('my-context', defaultContext)
|
|
20
25
|
* ```
|
|
21
26
|
*/
|
|
22
|
-
function useContext(key) {
|
|
23
|
-
const context = inject(key,
|
|
27
|
+
function useContext(key, defaultValue) {
|
|
28
|
+
const context = inject(key, defaultValue);
|
|
24
29
|
if (context === void 0) throw new Error(`Context "${String(key)}" not found. Ensure it's provided by an ancestor.`);
|
|
25
30
|
return context;
|
|
26
31
|
}
|
|
@@ -29,43 +34,58 @@ function useContext(key) {
|
|
|
29
34
|
*
|
|
30
35
|
* @param key The key of the context to provide.
|
|
31
36
|
* @param context The context to provide.
|
|
32
|
-
* @param app
|
|
37
|
+
* @param app Optional Vue app instance to provide the context at app level instead of component level.
|
|
33
38
|
* @template Z The type of the context.
|
|
34
39
|
* @returns The provided context.
|
|
35
40
|
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* When `app` parameter is provided, the context is made available to all components in the app.
|
|
43
|
+
* When omitted, the context is provided at the current component level and available to descendants only.
|
|
44
|
+
*
|
|
36
45
|
* @see https://vuejs.org/api/composition-api-dependency-injection.html#provide
|
|
37
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-context
|
|
46
|
+
* @see https://0.vuetifyjs.com/composables/foundation/create-context#provide-context
|
|
38
47
|
*
|
|
39
48
|
* @example
|
|
40
49
|
* ```ts
|
|
41
|
-
*
|
|
50
|
+
* // Component-level provision
|
|
51
|
+
* provideContext<MyContext>('my-context', context)
|
|
52
|
+
*
|
|
53
|
+
* // App-level provision (typically used in plugins)
|
|
54
|
+
* const app = createApp()
|
|
55
|
+
* provideContext<MyContext>('my-context', context, app)
|
|
42
56
|
* ```
|
|
43
57
|
*/
|
|
44
58
|
function provideContext(key, context, app) {
|
|
45
|
-
app
|
|
59
|
+
if (app) app.provide(key, context);
|
|
60
|
+
else provide(key, context);
|
|
46
61
|
return context;
|
|
47
62
|
}
|
|
48
63
|
/**
|
|
49
64
|
* Creates a new context for providing and injecting data.
|
|
50
65
|
*
|
|
51
66
|
* @param key The key of the context to create.
|
|
67
|
+
* @param defaultValue Optional default value if context is not found.
|
|
52
68
|
* @template Z The type of the context.
|
|
53
69
|
* @returns A tuple containing the `useContext` and `provideContext` functions.
|
|
54
70
|
*
|
|
55
71
|
* @see https://vuejs.org/api/composition-api-dependency-injection.html
|
|
56
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-context
|
|
72
|
+
* @see https://0.vuetifyjs.com/composables/foundation/create-context#create-context
|
|
57
73
|
*
|
|
58
74
|
* @example
|
|
59
75
|
* ```ts
|
|
60
|
-
*
|
|
76
|
+
* // Without default value
|
|
77
|
+
* const [useMyContext, provideMyContext] = createContext<MyContext>('my-context')
|
|
78
|
+
*
|
|
79
|
+
* // With default value
|
|
80
|
+
* const [useMyContext, provideMyContext] = createContext<MyContext>('my-context', defaultContext)
|
|
61
81
|
* ```
|
|
62
82
|
*/
|
|
63
|
-
function createContext(_key) {
|
|
83
|
+
function createContext(_key, defaultValue) {
|
|
64
84
|
function _provideContext(context, app) {
|
|
65
85
|
return provideContext(_key, context, app);
|
|
66
86
|
}
|
|
67
87
|
function _useContext(key = _key) {
|
|
68
|
-
return useContext(key);
|
|
88
|
+
return useContext(key, defaultValue);
|
|
69
89
|
}
|
|
70
90
|
return [_useContext, _provideContext];
|
|
71
91
|
}
|
|
@@ -78,8 +98,7 @@ function createContext(_key) {
|
|
|
78
98
|
* @param options The plugin options.
|
|
79
99
|
* @returns A new Vue plugin.
|
|
80
100
|
*
|
|
81
|
-
* @see https://
|
|
82
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-plugin
|
|
101
|
+
* @see https://0.vuetifyjs.com/composables/foundation/create-plugin#create-plugin
|
|
83
102
|
*
|
|
84
103
|
* @example
|
|
85
104
|
* ```ts
|
|
@@ -111,13 +130,21 @@ function createPlugin(options) {
|
|
|
111
130
|
/**
|
|
112
131
|
* Creates a new trinity for a context composable and its provider.
|
|
113
132
|
*
|
|
114
|
-
* @param createContext The function that
|
|
115
|
-
* @param provideContext The function that provides the context.
|
|
116
|
-
* @param context The context to
|
|
133
|
+
* @param createContext The function that retrieves/uses the context (typically named `useContext`).
|
|
134
|
+
* @param provideContext The function that provides the context to descendants.
|
|
135
|
+
* @param context The default context instance to use when no custom context is provided.
|
|
117
136
|
* @template Z The type of the context.
|
|
118
|
-
* @returns A
|
|
137
|
+
* @returns A readonly tuple containing: [useContext function, provideContext wrapper function, default context instance].
|
|
138
|
+
*
|
|
139
|
+
* @remarks The trinity pattern is a foundational pattern used throughout the codebase for creating reusable context systems. It provides three related elements:
|
|
140
|
+
*
|
|
141
|
+
* 1. A function to retrieve/use the context
|
|
142
|
+
* 2. A function to provide the context (with default value support)
|
|
143
|
+
* 3. The default context instance
|
|
144
|
+
*
|
|
145
|
+
* The returned tuple is readonly (using `as const`) to ensure proper type inference.
|
|
119
146
|
*
|
|
120
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-trinity
|
|
147
|
+
* @see https://0.vuetifyjs.com/composables/foundation/create-trinity#create-trinity
|
|
121
148
|
*
|
|
122
149
|
* @example
|
|
123
150
|
* ```ts
|
|
@@ -137,6 +164,7 @@ function createPlugin(options) {
|
|
|
137
164
|
*
|
|
138
165
|
* return createTrinity<E>(useContext, provideContext, context)
|
|
139
166
|
* }
|
|
167
|
+
* ```
|
|
140
168
|
*/
|
|
141
169
|
function createTrinity(createContext$1, provideContext$1, context) {
|
|
142
170
|
return [
|
|
@@ -180,7 +208,7 @@ function toArray(value) {
|
|
|
180
208
|
* @template Z The type of the object.
|
|
181
209
|
* @returns The converted object.
|
|
182
210
|
*
|
|
183
|
-
* @see https://
|
|
211
|
+
* @see https://0.vuetifyjs.com/composables/transformers/to-reactive
|
|
184
212
|
*
|
|
185
213
|
* @example
|
|
186
214
|
* ```ts
|
|
@@ -293,7 +321,6 @@ function toReactive(objectRef) {
|
|
|
293
321
|
|
|
294
322
|
//#endregion
|
|
295
323
|
//#region src/composables/useHydration/index.ts
|
|
296
|
-
const [useHydrationContext, provideHydrationContext] = createContext("v0:hydration");
|
|
297
324
|
/**
|
|
298
325
|
* Creates a new hydration instance.
|
|
299
326
|
*
|
|
@@ -305,7 +332,10 @@ const [useHydrationContext, provideHydrationContext] = createContext("v0:hydrati
|
|
|
305
332
|
* ```ts
|
|
306
333
|
* import { createHydration } from '@vuetify/v0'
|
|
307
334
|
*
|
|
308
|
-
* const
|
|
335
|
+
* const hydration = createHydration()
|
|
336
|
+
* console.log(hydration.isHydrated.value) // false
|
|
337
|
+
* hydration.hydrate()
|
|
338
|
+
* console.log(hydration.isHydrated.value) // true
|
|
309
339
|
* ```
|
|
310
340
|
*/
|
|
311
341
|
function createHydration() {
|
|
@@ -319,33 +349,37 @@ function createHydration() {
|
|
|
319
349
|
};
|
|
320
350
|
}
|
|
321
351
|
/**
|
|
322
|
-
*
|
|
352
|
+
* Creates a new hydration context trinity.
|
|
323
353
|
*
|
|
324
|
-
* @
|
|
354
|
+
* @param options Options for creating the hydration context.
|
|
355
|
+
* @template E The type of the hydration context.
|
|
356
|
+
* @returns A new hydration context trinity.
|
|
325
357
|
*
|
|
326
358
|
* @see https://0.vuetifyjs.com/composables/plugins/use-hydration
|
|
327
359
|
*
|
|
328
360
|
* @example
|
|
329
|
-
* ```
|
|
330
|
-
*
|
|
331
|
-
* import { useHydration } from '@vuetify/v0'
|
|
332
|
-
*
|
|
333
|
-
* const hydration = useHydration()
|
|
334
|
-
* <\/script>
|
|
361
|
+
* ```ts
|
|
362
|
+
* import { createHydrationContext } from '@vuetify/v0'
|
|
335
363
|
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
* </div>
|
|
340
|
-
* </template>
|
|
364
|
+
* export const [useHydrationContext, provideHydrationContext, context] = createHydrationContext({
|
|
365
|
+
* namespace: 'app:hydration',
|
|
366
|
+
* })
|
|
341
367
|
* ```
|
|
342
368
|
*/
|
|
343
|
-
function
|
|
344
|
-
|
|
369
|
+
function createHydrationContext(_options = {}) {
|
|
370
|
+
const { namespace = "v0:hydration" } = _options;
|
|
371
|
+
const [useHydrationContext, _provideHydrationContext] = createContext(namespace);
|
|
372
|
+
const context = createHydration();
|
|
373
|
+
function provideHydrationContext(_context = context, app) {
|
|
374
|
+
return _provideHydrationContext(_context, app);
|
|
375
|
+
}
|
|
376
|
+
return createTrinity(useHydrationContext, provideHydrationContext, context);
|
|
345
377
|
}
|
|
346
378
|
/**
|
|
347
379
|
* Creates a new hydration plugin.
|
|
348
380
|
*
|
|
381
|
+
* @param options The options for the hydration plugin.
|
|
382
|
+
* @template E The type of the hydration context.
|
|
349
383
|
* @returns A new hydration plugin.
|
|
350
384
|
*
|
|
351
385
|
* @see https://0.vuetifyjs.com/composables/plugins/use-hydration
|
|
@@ -356,19 +390,21 @@ function useHydration() {
|
|
|
356
390
|
* import { createHydrationPlugin } from '@vuetify/v0'
|
|
357
391
|
* import App from './App.vue'
|
|
358
392
|
*
|
|
359
|
-
* const plugin = createHydrationPlugin()
|
|
360
|
-
*
|
|
361
393
|
* const app = createApp(App)
|
|
362
394
|
*
|
|
363
|
-
* app.use(
|
|
395
|
+
* app.use(createHydrationPlugin())
|
|
364
396
|
*
|
|
365
397
|
* app.mount('#app')
|
|
366
398
|
* ```
|
|
367
399
|
*/
|
|
368
|
-
function createHydrationPlugin() {
|
|
369
|
-
const
|
|
400
|
+
function createHydrationPlugin(_options = {}) {
|
|
401
|
+
const { namespace = "v0:hydration",...options } = _options;
|
|
402
|
+
const [, provideHydrationContext, context] = createHydrationContext({
|
|
403
|
+
...options,
|
|
404
|
+
namespace
|
|
405
|
+
});
|
|
370
406
|
return createPlugin({
|
|
371
|
-
namespace
|
|
407
|
+
namespace,
|
|
372
408
|
provide: (app) => {
|
|
373
409
|
provideHydrationContext(context, app);
|
|
374
410
|
},
|
|
@@ -380,6 +416,32 @@ function createHydrationPlugin() {
|
|
|
380
416
|
}
|
|
381
417
|
});
|
|
382
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Returns the current hydration instance.
|
|
421
|
+
*
|
|
422
|
+
* @param namespace The namespace for the hydration context. Defaults to `v0:hydration`.
|
|
423
|
+
* @returns The current hydration instance.
|
|
424
|
+
*
|
|
425
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-hydration
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* ```vue
|
|
429
|
+
* <script setup lang="ts">
|
|
430
|
+
* import { useHydration } from '@vuetify/v0'
|
|
431
|
+
*
|
|
432
|
+
* const hydration = useHydration()
|
|
433
|
+
* <\/script>
|
|
434
|
+
*
|
|
435
|
+
* <template>
|
|
436
|
+
* <div>
|
|
437
|
+
* <p>Is hydrated: {{ hydration.isHydrated.value }}</p>
|
|
438
|
+
* </div>
|
|
439
|
+
* </template>
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
function useHydration(namespace = "v0:hydration") {
|
|
443
|
+
return useContext(namespace);
|
|
444
|
+
}
|
|
383
445
|
|
|
384
446
|
//#endregion
|
|
385
447
|
//#region src/composables/useBreakpoints/index.ts
|
|
@@ -404,7 +466,6 @@ function createDefaultBreakpoints() {
|
|
|
404
466
|
/**
|
|
405
467
|
* Creates a new breakpoints instance.
|
|
406
468
|
*
|
|
407
|
-
* @param namespace The namespace to use for the breakpoints instance.
|
|
408
469
|
* @param options The options for the breakpoints instance.
|
|
409
470
|
* @template E The type of the breakpoints context.
|
|
410
471
|
* @returns A new breakpoints instance.
|
|
@@ -415,7 +476,8 @@ function createDefaultBreakpoints() {
|
|
|
415
476
|
* ```ts
|
|
416
477
|
* import { createBreakpoints } from '@vuetify/v0'
|
|
417
478
|
*
|
|
418
|
-
* export const [useBreakpoints, provideBreakpoints] = createBreakpoints(
|
|
479
|
+
* export const [useBreakpoints, provideBreakpoints] = createBreakpoints({
|
|
480
|
+
* namespace: 'v0:breakpoints',
|
|
419
481
|
* mobileBreakpoint: 'sm',
|
|
420
482
|
* breakpoints: {
|
|
421
483
|
* xs: 0,
|
|
@@ -428,12 +490,11 @@ function createDefaultBreakpoints() {
|
|
|
428
490
|
* })
|
|
429
491
|
* ```
|
|
430
492
|
*/
|
|
431
|
-
function createBreakpoints(
|
|
432
|
-
const
|
|
433
|
-
const
|
|
434
|
-
const sorted = Object.entries(breakpoints).sort((a, b) => a[1] - b[1]);
|
|
493
|
+
function createBreakpoints(_options = {}) {
|
|
494
|
+
const { mobileBreakpoint, breakpoints } = /* @__PURE__ */ mergeDeep(createDefaultBreakpoints(), _options);
|
|
495
|
+
const sorted = Object.entries(breakpoints).toSorted((a, b) => a[1] - b[1]);
|
|
435
496
|
const names = sorted.map(([n]) => n);
|
|
436
|
-
const mb =
|
|
497
|
+
const mb = /* @__PURE__ */ isNumber(mobileBreakpoint) ? mobileBreakpoint : breakpoints[mobileBreakpoint] ?? breakpoints.md;
|
|
437
498
|
const name = shallowRef("xs");
|
|
438
499
|
const width = shallowRef(0);
|
|
439
500
|
const height = shallowRef(0);
|
|
@@ -483,21 +544,7 @@ function createBreakpoints(namespace = "v0:breakpoints", options = {}) {
|
|
|
483
544
|
xlAndDown.value = index <= 4;
|
|
484
545
|
xxlAndDown.value = index <= 5;
|
|
485
546
|
}
|
|
486
|
-
|
|
487
|
-
const { isHydrated } = useHydration();
|
|
488
|
-
if (isHydrated.value) update();
|
|
489
|
-
watch(isHydrated, (hydrated) => {
|
|
490
|
-
if (hydrated) update();
|
|
491
|
-
}, { immediate: true });
|
|
492
|
-
});
|
|
493
|
-
if (IN_BROWSER) {
|
|
494
|
-
function listener() {
|
|
495
|
-
update();
|
|
496
|
-
}
|
|
497
|
-
window.addEventListener("resize", listener, { passive: true });
|
|
498
|
-
onScopeDispose(() => window.removeEventListener("resize", listener), true);
|
|
499
|
-
}
|
|
500
|
-
const context = {
|
|
547
|
+
return {
|
|
501
548
|
breakpoints,
|
|
502
549
|
name: readonly(name),
|
|
503
550
|
width: readonly(width),
|
|
@@ -521,36 +568,34 @@ function createBreakpoints(namespace = "v0:breakpoints", options = {}) {
|
|
|
521
568
|
xxlAndDown: readonly(xxlAndDown),
|
|
522
569
|
update
|
|
523
570
|
};
|
|
524
|
-
function provideBreakpointsContext(_context = context, app) {
|
|
525
|
-
return _provideBreakpointsContext(_context, app);
|
|
526
|
-
}
|
|
527
|
-
return createTrinity(useBreakpointsContext, provideBreakpointsContext, context);
|
|
528
571
|
}
|
|
529
572
|
/**
|
|
530
|
-
*
|
|
573
|
+
* Creates a new breakpoints context.
|
|
531
574
|
*
|
|
532
|
-
* @
|
|
575
|
+
* @param options The options for the breakpoints context.
|
|
576
|
+
* @template E The type of the breakpoints context.
|
|
577
|
+
* @returns A new breakpoints context.
|
|
533
578
|
*
|
|
534
579
|
* @see https://0.vuetifyjs.com/composables/plugins/use-breakpoints
|
|
535
580
|
*
|
|
536
581
|
* @example
|
|
537
|
-
* ```
|
|
538
|
-
*
|
|
539
|
-
* import { useBreakpoints } from '@vuetify/v0'
|
|
540
|
-
*
|
|
541
|
-
* const { isMobile, mdAndUp } = useBreakpoints()
|
|
542
|
-
* <\/script>
|
|
582
|
+
* ```ts
|
|
583
|
+
* import { createBreakpointsContext } from '@vuetify/v0'
|
|
543
584
|
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
* </div>
|
|
549
|
-
* </template>
|
|
585
|
+
* export const [useBreakpoints, provideBreakpoints, context] = createBreakpointsContext({
|
|
586
|
+
* namespace: 'v0:breakpoints',
|
|
587
|
+
* mobileBreakpoint: 'sm',
|
|
588
|
+
* })
|
|
550
589
|
* ```
|
|
551
590
|
*/
|
|
552
|
-
function
|
|
553
|
-
|
|
591
|
+
function createBreakpointsContext(_options = {}) {
|
|
592
|
+
const { namespace = "v0:breakpoints",...options } = _options;
|
|
593
|
+
const [useBreakpointsContext, _provideBreakpointsContext] = createContext(namespace);
|
|
594
|
+
const context = createBreakpoints(options);
|
|
595
|
+
function provideBreakpointsContext(_context = context, app) {
|
|
596
|
+
return _provideBreakpointsContext(_context, app);
|
|
597
|
+
}
|
|
598
|
+
return createTrinity(useBreakpointsContext, provideBreakpointsContext, context);
|
|
554
599
|
}
|
|
555
600
|
/**
|
|
556
601
|
* Creates a new breakpoints plugin.
|
|
@@ -571,6 +616,7 @@ function useBreakpoints() {
|
|
|
571
616
|
*
|
|
572
617
|
* app.use(
|
|
573
618
|
* createBreakpointsPlugin({
|
|
619
|
+
* namespace: 'v0:breakpoints',
|
|
574
620
|
* mobileBreakpoint: 'sm',
|
|
575
621
|
* breakpoints: {
|
|
576
622
|
* xs: 0,
|
|
@@ -586,20 +632,63 @@ function useBreakpoints() {
|
|
|
586
632
|
* app.mount('#app')
|
|
587
633
|
* ```
|
|
588
634
|
*/
|
|
589
|
-
function createBreakpointsPlugin(
|
|
590
|
-
const
|
|
635
|
+
function createBreakpointsPlugin(_options = {}) {
|
|
636
|
+
const { namespace = "v0:breakpoints",...options } = _options;
|
|
637
|
+
const [, provideBreakpointsContext, context] = createBreakpointsContext({
|
|
638
|
+
...options,
|
|
639
|
+
namespace
|
|
640
|
+
});
|
|
591
641
|
return createPlugin({
|
|
592
|
-
namespace
|
|
642
|
+
namespace,
|
|
593
643
|
provide: (app) => {
|
|
594
644
|
provideBreakpointsContext(context, app);
|
|
595
645
|
},
|
|
596
646
|
setup: (app) => {
|
|
597
647
|
app.mixin({ mounted() {
|
|
598
|
-
|
|
648
|
+
if (this.$parent !== null) return;
|
|
649
|
+
const hydration = useHydration();
|
|
650
|
+
function listener() {
|
|
651
|
+
context.update();
|
|
652
|
+
}
|
|
653
|
+
const unwatch = watch(hydration.isHydrated, (hydrated) => {
|
|
654
|
+
if (hydrated) listener();
|
|
655
|
+
}, { immediate: true });
|
|
656
|
+
window.addEventListener("resize", listener, { passive: true });
|
|
657
|
+
onScopeDispose(() => {
|
|
658
|
+
window.removeEventListener("resize", listener);
|
|
659
|
+
unwatch();
|
|
660
|
+
}, true);
|
|
599
661
|
} });
|
|
600
662
|
}
|
|
601
663
|
});
|
|
602
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* Returns the current breakpoints instance.
|
|
667
|
+
*
|
|
668
|
+
* @param namespace The namespace for the breakpoints context. Defaults to `v0:breakpoints`.
|
|
669
|
+
* @returns The current breakpoints instance.
|
|
670
|
+
*
|
|
671
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-breakpoints
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```vue
|
|
675
|
+
* <script setup lang="ts">
|
|
676
|
+
* import { useBreakpoints } from '@vuetify/v0'
|
|
677
|
+
*
|
|
678
|
+
* const { isMobile, mdAndUp } = useBreakpoints()
|
|
679
|
+
* <\/script>
|
|
680
|
+
*
|
|
681
|
+
* <template>
|
|
682
|
+
* <div class="pa-4">
|
|
683
|
+
* <p v-if="isMobile.value">Mobile layout active</p>
|
|
684
|
+
* <p v-else-if="mdAndUp.value">Medium and up layout active</p>
|
|
685
|
+
* </div>
|
|
686
|
+
* </template>
|
|
687
|
+
* ```
|
|
688
|
+
*/
|
|
689
|
+
function useBreakpoints(namespace = "v0:breakpoints") {
|
|
690
|
+
return useContext(namespace);
|
|
691
|
+
}
|
|
603
692
|
|
|
604
693
|
//#endregion
|
|
605
694
|
//#region src/composables/useEventListener/index.ts
|
|
@@ -740,7 +829,7 @@ var PinoLoggerAdapter = class {
|
|
|
740
829
|
}
|
|
741
830
|
format(message, ...args) {
|
|
742
831
|
if (args.length === 0) return { msg: message };
|
|
743
|
-
if (args.length === 1 &&
|
|
832
|
+
if (args.length === 1 && /* @__PURE__ */ isObject(args[0])) return {
|
|
744
833
|
...args[0],
|
|
745
834
|
msg: message
|
|
746
835
|
};
|
|
@@ -813,14 +902,13 @@ var Vuetify0LoggerAdapter = class {
|
|
|
813
902
|
log(level, method, message, ...args) {
|
|
814
903
|
const [formattedMessage, ...restArgs] = this.format(level, message, ...args);
|
|
815
904
|
const style = this.style(level);
|
|
816
|
-
if (IN_BROWSER && style &&
|
|
817
|
-
else if (
|
|
905
|
+
if (IN_BROWSER && style && /* @__PURE__ */ isFunction(console[method])) console[method](`%c${formattedMessage}`, style, ...restArgs);
|
|
906
|
+
else if (/* @__PURE__ */ isFunction(console[method])) console[method](formattedMessage, ...restArgs);
|
|
818
907
|
}
|
|
819
908
|
};
|
|
820
909
|
|
|
821
910
|
//#endregion
|
|
822
911
|
//#region src/composables/useLogger/index.ts
|
|
823
|
-
const [useLoggerContext, provideLoggerContext] = createContext("v0:logger");
|
|
824
912
|
/**
|
|
825
913
|
* Creates a new logger instance.
|
|
826
914
|
*
|
|
@@ -828,6 +916,22 @@ const [useLoggerContext, provideLoggerContext] = createContext("v0:logger");
|
|
|
828
916
|
* @returns A new logger instance.
|
|
829
917
|
*
|
|
830
918
|
* @see https://0.vuetifyjs.com/composables/plugins/use-logger
|
|
919
|
+
*
|
|
920
|
+
* @example
|
|
921
|
+
* ```ts
|
|
922
|
+
* import { createLogger } from '@vuetify/v0'
|
|
923
|
+
*
|
|
924
|
+
* const logger = createLogger({
|
|
925
|
+
* level: 'debug',
|
|
926
|
+
* prefix: '[MyApp]',
|
|
927
|
+
* })
|
|
928
|
+
*
|
|
929
|
+
* logger.info('This is an info message')
|
|
930
|
+
* logger.debug('This is a debug message')
|
|
931
|
+
* logger.error('This is an error message')
|
|
932
|
+
* logger.level('debug')
|
|
933
|
+
* logger.debug('This debug message will now be logged')
|
|
934
|
+
* ```
|
|
831
935
|
*/
|
|
832
936
|
function createLogger(options = {}) {
|
|
833
937
|
const { adapter = new Vuetify0LoggerAdapter({ prefix: options.prefix }), level: initialLevel = "info", enabled: initialEnabled = __LOGGER_ENABLED__ } = options;
|
|
@@ -917,20 +1021,32 @@ function createFallbackLogger(namespace = "v0:logger") {
|
|
|
917
1021
|
};
|
|
918
1022
|
}
|
|
919
1023
|
/**
|
|
920
|
-
*
|
|
1024
|
+
* Creates a new logger context.
|
|
921
1025
|
*
|
|
922
|
-
* @param
|
|
923
|
-
* @
|
|
1026
|
+
* @param options The options for the logger context.
|
|
1027
|
+
* @template E The type of the logger context.
|
|
1028
|
+
* @returns A new logger context.
|
|
924
1029
|
*
|
|
925
1030
|
* @see https://0.vuetifyjs.com/composables/plugins/use-logger
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```ts
|
|
1034
|
+
* import { createLoggerContext } from '@vuetify/v0'
|
|
1035
|
+
*
|
|
1036
|
+
* export const [useAppLogger, provideAppLogger, appLogger] = createLoggerContext({
|
|
1037
|
+
* namespace: 'app:logger',
|
|
1038
|
+
* level: 'debug',
|
|
1039
|
+
* })
|
|
1040
|
+
* ```
|
|
926
1041
|
*/
|
|
927
|
-
function
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1042
|
+
function createLoggerContext(_options = {}) {
|
|
1043
|
+
const { namespace = "v0:logger",...options } = _options;
|
|
1044
|
+
const [useLoggerContext, _provideLoggerContext] = createContext(namespace);
|
|
1045
|
+
const context = createLogger(options);
|
|
1046
|
+
function provideLoggerContext(_context = context, app) {
|
|
1047
|
+
return _provideLoggerContext(_context, app);
|
|
932
1048
|
}
|
|
933
|
-
return
|
|
1049
|
+
return createTrinity(useLoggerContext, provideLoggerContext, context);
|
|
934
1050
|
}
|
|
935
1051
|
/**
|
|
936
1052
|
* Creates a new logger plugin.
|
|
@@ -939,11 +1055,33 @@ function useLogger(namespace) {
|
|
|
939
1055
|
* @returns A new logger plugin.
|
|
940
1056
|
*
|
|
941
1057
|
* @see https://0.vuetifyjs.com/composables/plugins/use-logger
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```ts
|
|
1061
|
+
* import { createApp } from 'vue'
|
|
1062
|
+
* import { createLoggerPlugin } from '@vuetify/v0'
|
|
1063
|
+
* import App from './App.vue'
|
|
1064
|
+
*
|
|
1065
|
+
* const app = createApp(App)
|
|
1066
|
+
*
|
|
1067
|
+
* app.use(
|
|
1068
|
+
* createLoggerPlugin({
|
|
1069
|
+
* level: 'debug',
|
|
1070
|
+
* prefix: '[MyApp]',
|
|
1071
|
+
* })
|
|
1072
|
+
* )
|
|
1073
|
+
*
|
|
1074
|
+
* app.mount('#app')
|
|
1075
|
+
* ```
|
|
942
1076
|
*/
|
|
943
|
-
function createLoggerPlugin(
|
|
944
|
-
const
|
|
1077
|
+
function createLoggerPlugin(_options = {}) {
|
|
1078
|
+
const { namespace = "v0:logger",...options } = _options;
|
|
1079
|
+
const [, provideLoggerContext, context] = createLoggerContext({
|
|
1080
|
+
...options,
|
|
1081
|
+
namespace
|
|
1082
|
+
});
|
|
945
1083
|
return createPlugin({
|
|
946
|
-
namespace
|
|
1084
|
+
namespace,
|
|
947
1085
|
provide: (app) => {
|
|
948
1086
|
provideLoggerContext(context, app);
|
|
949
1087
|
},
|
|
@@ -952,6 +1090,36 @@ function createLoggerPlugin(options = {}) {
|
|
|
952
1090
|
}
|
|
953
1091
|
});
|
|
954
1092
|
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Uses an existing or creates a new logger instance.
|
|
1095
|
+
*
|
|
1096
|
+
* @param namespace The namespace for the logger context. Defaults to `'v0:logger'`.
|
|
1097
|
+
* @returns The logger instance.
|
|
1098
|
+
*
|
|
1099
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-logger
|
|
1100
|
+
*
|
|
1101
|
+
* @example
|
|
1102
|
+
* ```ts
|
|
1103
|
+
* import { useLogger } from '@vuetify/v0'
|
|
1104
|
+
*
|
|
1105
|
+
* const logger = useLogger()
|
|
1106
|
+
*
|
|
1107
|
+
* logger.info('This is an info message')
|
|
1108
|
+
* logger.debug('This is a debug message')
|
|
1109
|
+
* logger.error('This is an error message')
|
|
1110
|
+
* logger.level('debug')
|
|
1111
|
+
* logger.debug('This debug message will now be logged')
|
|
1112
|
+
* ```
|
|
1113
|
+
*/
|
|
1114
|
+
function useLogger(namespace = "v0:logger") {
|
|
1115
|
+
const fallback = createFallbackLogger(namespace);
|
|
1116
|
+
if (!getCurrentInstance()) return fallback;
|
|
1117
|
+
try {
|
|
1118
|
+
return useContext(namespace, fallback);
|
|
1119
|
+
} catch {
|
|
1120
|
+
return fallback;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
955
1123
|
|
|
956
1124
|
//#endregion
|
|
957
1125
|
//#region src/composables/useRegistry/index.ts
|
|
@@ -963,7 +1131,7 @@ function createLoggerPlugin(options = {}) {
|
|
|
963
1131
|
* @template E The type of registry context that extends RegistryContext<Z>. Use this when extending the registry with additional methods.
|
|
964
1132
|
* @returns A new registry instance.
|
|
965
1133
|
*
|
|
966
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry
|
|
1134
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#use-registry
|
|
967
1135
|
*
|
|
968
1136
|
* @example
|
|
969
1137
|
* ```ts
|
|
@@ -1202,11 +1370,11 @@ function useRegistry(options) {
|
|
|
1202
1370
|
*
|
|
1203
1371
|
* @param namespace The namespace for the registry context.
|
|
1204
1372
|
* @param options The options for the registry context.
|
|
1205
|
-
*
|
|
1206
1373
|
* @template Z The type of registry ticket that extends RegistryTicket. Use this to add custom properties to tickets.
|
|
1207
1374
|
* @template E The type of registry context that extends RegistryContext<Z>. Use this when extending the registry with additional methods.
|
|
1375
|
+
* @returns A new registry context.
|
|
1208
1376
|
*
|
|
1209
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry
|
|
1377
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#create-registry-context
|
|
1210
1378
|
*
|
|
1211
1379
|
* @example
|
|
1212
1380
|
* ```ts
|
|
@@ -1222,7 +1390,8 @@ function useRegistry(options) {
|
|
|
1222
1390
|
* items.register({ id: 'item-1', value: 'Value 1' })
|
|
1223
1391
|
* ```
|
|
1224
1392
|
*/
|
|
1225
|
-
function createRegistryContext(
|
|
1393
|
+
function createRegistryContext(_options) {
|
|
1394
|
+
const { namespace,...options } = _options;
|
|
1226
1395
|
const [useRegistryContext, _provideRegistryContext] = createContext(namespace);
|
|
1227
1396
|
const context = useRegistry(options);
|
|
1228
1397
|
function provideRegistryContext(_context = context, app) {
|
|
@@ -1234,20 +1403,37 @@ function createRegistryContext(namespace, options) {
|
|
|
1234
1403
|
//#endregion
|
|
1235
1404
|
//#region src/composables/useSelection/index.ts
|
|
1236
1405
|
/**
|
|
1237
|
-
* Creates a new selection instance.
|
|
1406
|
+
* Creates a new selection instance for managing multiple selected items.
|
|
1407
|
+
*
|
|
1408
|
+
* Extends `useRegistry` with selection tracking via a reactive `Set` of selected IDs.
|
|
1409
|
+
* Supports disabled items, mandatory selection enforcement, and auto-enrollment.
|
|
1238
1410
|
*
|
|
1239
1411
|
* @param options The options for the selection instance.
|
|
1240
1412
|
* @template Z The type of the selection ticket.
|
|
1241
1413
|
* @template E The type of the selection context.
|
|
1242
|
-
* @returns A new selection instance.
|
|
1414
|
+
* @returns A new selection instance with selection management methods.
|
|
1415
|
+
*
|
|
1416
|
+
* @remarks
|
|
1417
|
+
* **Key Features:**
|
|
1418
|
+
* - Multi-selection support (unlike `useSingle` which enforces single selection)
|
|
1419
|
+
* - Set-based `selectedIds` tracking for efficient lookups
|
|
1420
|
+
* - Computed `selectedItems` and `selectedValues` for reactive access
|
|
1421
|
+
* - Each ticket gets `isSelected`, `select()`, `unselect()`, and `toggle()` methods
|
|
1422
|
+
* - Disabled items cannot be selected
|
|
1423
|
+
* - Mandatory mode prevents deselecting the last item
|
|
1424
|
+
* - Force mode auto-selects first non-disabled item on registration
|
|
1425
|
+
* - Enroll option auto-selects all non-disabled items on registration
|
|
1426
|
+
*
|
|
1427
|
+
* **Inheritance Chain:**
|
|
1428
|
+
* `useRegistry` → `createSelection` → `createSingle`/`createGroup` → `createStep`
|
|
1243
1429
|
*
|
|
1244
1430
|
* @see https://0.vuetifyjs.com/composables/selection/use-selection
|
|
1245
1431
|
*
|
|
1246
1432
|
* @example
|
|
1247
1433
|
* ```ts
|
|
1248
|
-
* import {
|
|
1434
|
+
* import { createSelection } from '@vuetify/v0'
|
|
1249
1435
|
*
|
|
1250
|
-
* const selection =
|
|
1436
|
+
* const selection = createSelection({ mandatory: true })
|
|
1251
1437
|
*
|
|
1252
1438
|
* selection.onboard([
|
|
1253
1439
|
* { id: 'item-1', value: 'Item 1' },
|
|
@@ -1259,9 +1445,10 @@ function createRegistryContext(namespace, options) {
|
|
|
1259
1445
|
* selection.select('item-3')
|
|
1260
1446
|
*
|
|
1261
1447
|
* console.log(selection.selectedIds) // Set { 'item-1', 'item-3' }
|
|
1448
|
+
* console.log(Array.from(selection.selectedValues.value)) // ['Item 1', 'Item 3']
|
|
1262
1449
|
* ```
|
|
1263
1450
|
*/
|
|
1264
|
-
function
|
|
1451
|
+
function createSelection(options) {
|
|
1265
1452
|
const registry = useRegistry(options);
|
|
1266
1453
|
const selectedIds = shallowReactive(/* @__PURE__ */ new Set());
|
|
1267
1454
|
const enroll = options?.enroll ?? false;
|
|
@@ -1365,46 +1552,103 @@ function useSelection(options) {
|
|
|
1365
1552
|
* checkboxes.select('checkbox-1')
|
|
1366
1553
|
* ```
|
|
1367
1554
|
*/
|
|
1368
|
-
function createSelectionContext(
|
|
1555
|
+
function createSelectionContext(_options) {
|
|
1556
|
+
const { namespace,...options } = _options;
|
|
1369
1557
|
const [useSelectionContext, _provideSelectionContext] = createContext(namespace);
|
|
1370
|
-
const context =
|
|
1558
|
+
const context = createSelection(options);
|
|
1371
1559
|
function provideSelectionContext(_context = context, app) {
|
|
1372
1560
|
return _provideSelectionContext(_context, app);
|
|
1373
1561
|
}
|
|
1374
1562
|
return createTrinity(useSelectionContext, provideSelectionContext, context);
|
|
1375
1563
|
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Returns the current selection instance.
|
|
1566
|
+
*
|
|
1567
|
+
* @param namespace The namespace for the selection context. Defaults to `'v0:selection'`.
|
|
1568
|
+
* @returns The current selection instance.
|
|
1569
|
+
*
|
|
1570
|
+
* @see https://0.vuetifyjs.com/composables/selection/use-selection
|
|
1571
|
+
*
|
|
1572
|
+
* @example
|
|
1573
|
+
* ```vue
|
|
1574
|
+
* <script setup lang="ts">
|
|
1575
|
+
* import { useSelection } from '@vuetify/v0'
|
|
1576
|
+
*
|
|
1577
|
+
* const selection = useSelection()
|
|
1578
|
+
* <\/script>
|
|
1579
|
+
*
|
|
1580
|
+
* <template>
|
|
1581
|
+
* <div>
|
|
1582
|
+
* <p>Selected: {{ selection.selectedIds.size }}</p>
|
|
1583
|
+
* </div>
|
|
1584
|
+
* </template>
|
|
1585
|
+
* ```
|
|
1586
|
+
*/
|
|
1587
|
+
function useSelection(namespace = "v0:selection") {
|
|
1588
|
+
return useContext(namespace);
|
|
1589
|
+
}
|
|
1376
1590
|
|
|
1377
1591
|
//#endregion
|
|
1378
1592
|
//#region src/composables/useGroup/index.ts
|
|
1379
1593
|
/**
|
|
1380
|
-
* Creates a new group instance.
|
|
1594
|
+
* Creates a new group instance with batch selection operations.
|
|
1595
|
+
*
|
|
1596
|
+
* Extends `createSelection` to support selecting, unselecting, and toggling multiple items
|
|
1597
|
+
* at once by passing an array of IDs. Adds `selectedIndexes` computed property.
|
|
1381
1598
|
*
|
|
1382
1599
|
* @param options The options for the group instance.
|
|
1383
1600
|
* @template Z The type of the group ticket.
|
|
1384
1601
|
* @template E The type of the group context.
|
|
1385
|
-
* @returns A new group instance.
|
|
1602
|
+
* @returns A new group instance with batch selection support.
|
|
1603
|
+
*
|
|
1604
|
+
* @remarks
|
|
1605
|
+
* **Key Differences from `createSelection`:**
|
|
1606
|
+
* - `select()` accepts `ID | ID[]` for batch operations
|
|
1607
|
+
* - `unselect()` accepts `ID | ID[]` for batch operations
|
|
1608
|
+
* - `toggle()` accepts `ID | ID[]` for batch operations
|
|
1609
|
+
* - Adds `selectedIndexes` computed Set for getting selected item indexes
|
|
1610
|
+
* - Perfect for checkboxes, multi-select dropdowns, and bulk operations
|
|
1611
|
+
*
|
|
1612
|
+
* **Batch Operations:**
|
|
1613
|
+
* - Single ID: `group.select('item-1')`
|
|
1614
|
+
* - Array of IDs: `group.select(['item-1', 'item-2', 'item-3'])`
|
|
1615
|
+
* - Uses `toArray()` utility internally to normalize input
|
|
1616
|
+
* - Disabled items are automatically skipped in batch operations
|
|
1617
|
+
* - Non-existent IDs are silently ignored
|
|
1618
|
+
*
|
|
1619
|
+
* **Inheritance Chain:**
|
|
1620
|
+
* `useRegistry` → `createSelection` → `createGroup`
|
|
1621
|
+
*
|
|
1622
|
+
* **Used By:**
|
|
1623
|
+
* - `createFeatures` for feature flag management with multiple selections
|
|
1386
1624
|
*
|
|
1387
1625
|
* @see https://0.vuetifyjs.com/composables/selection/use-group
|
|
1388
1626
|
*
|
|
1389
1627
|
* @example
|
|
1390
1628
|
* ```ts
|
|
1391
|
-
* import {
|
|
1629
|
+
* import { createGroup } from '@vuetify/v0'
|
|
1392
1630
|
*
|
|
1393
|
-
* const
|
|
1631
|
+
* const checkboxes = createGroup()
|
|
1394
1632
|
*
|
|
1395
|
-
*
|
|
1396
|
-
* { id: '
|
|
1397
|
-
* { id: '
|
|
1398
|
-
* { id: '
|
|
1633
|
+
* checkboxes.onboard([
|
|
1634
|
+
* { id: 'option-a', value: 'Option A' },
|
|
1635
|
+
* { id: 'option-b', value: 'Option B' },
|
|
1636
|
+
* { id: 'option-c', value: 'Option C' },
|
|
1399
1637
|
* ])
|
|
1400
1638
|
*
|
|
1401
|
-
*
|
|
1639
|
+
* // Select multiple items at once
|
|
1640
|
+
* checkboxes.select(['option-a', 'option-c'])
|
|
1402
1641
|
*
|
|
1403
|
-
* console.log(
|
|
1642
|
+
* console.log(checkboxes.selectedIds) // Set { 'option-a', 'option-c' }
|
|
1643
|
+
* console.log(Array.from(checkboxes.selectedIndexes.value)) // [0, 2]
|
|
1644
|
+
*
|
|
1645
|
+
* // Toggle operations
|
|
1646
|
+
* checkboxes.toggle(['option-a', 'option-b'])
|
|
1647
|
+
* console.log(checkboxes.selectedIds) // Set { 'option-b', 'option-c' }
|
|
1404
1648
|
* ```
|
|
1405
1649
|
*/
|
|
1406
|
-
function
|
|
1407
|
-
const registry =
|
|
1650
|
+
function createGroup(options) {
|
|
1651
|
+
const registry = createSelection(options);
|
|
1408
1652
|
const selectedIndexes = computed(() => {
|
|
1409
1653
|
return new Set(Array.from(registry.selectedItems.value).map((item) => item?.index));
|
|
1410
1654
|
});
|
|
@@ -1452,14 +1696,41 @@ function useGroup(options) {
|
|
|
1452
1696
|
* const group = useMyGroup()
|
|
1453
1697
|
* ```
|
|
1454
1698
|
*/
|
|
1455
|
-
function createGroupContext(
|
|
1699
|
+
function createGroupContext(_options) {
|
|
1700
|
+
const { namespace,...options } = _options;
|
|
1456
1701
|
const [useGroupContext, _provideGroupContext] = createContext(namespace);
|
|
1457
|
-
const context =
|
|
1702
|
+
const context = createGroup(options);
|
|
1458
1703
|
function provideGroupContext(_context = context, app) {
|
|
1459
1704
|
return _provideGroupContext(_context, app);
|
|
1460
1705
|
}
|
|
1461
1706
|
return createTrinity(useGroupContext, provideGroupContext, context);
|
|
1462
1707
|
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Returns the current group instance.
|
|
1710
|
+
*
|
|
1711
|
+
* @param namespace The namespace for the group context. Defaults to `'v0:group'`.
|
|
1712
|
+
* @returns The current group instance.
|
|
1713
|
+
*
|
|
1714
|
+
* @see https://0.vuetifyjs.com/composables/selection/use-group
|
|
1715
|
+
*
|
|
1716
|
+
* @example
|
|
1717
|
+
* ```vue
|
|
1718
|
+
* <script setup lang="ts">
|
|
1719
|
+
* import { useGroup } from '@vuetify/v0'
|
|
1720
|
+
*
|
|
1721
|
+
* const group = useGroup()
|
|
1722
|
+
* <\/script>
|
|
1723
|
+
*
|
|
1724
|
+
* <template>
|
|
1725
|
+
* <div>
|
|
1726
|
+
* <p>Selected: {{ group.selectedIds.size }}</p>
|
|
1727
|
+
* </div>
|
|
1728
|
+
* </template>
|
|
1729
|
+
* ```
|
|
1730
|
+
*/
|
|
1731
|
+
function useGroup(namespace) {
|
|
1732
|
+
return useContext(namespace);
|
|
1733
|
+
}
|
|
1463
1734
|
|
|
1464
1735
|
//#endregion
|
|
1465
1736
|
//#region src/composables/useTokens/index.ts
|
|
@@ -1490,9 +1761,9 @@ function createGroupContext(namespace, options) {
|
|
|
1490
1761
|
* console.log(tokens.resolve('{colors.secondary}')) // '#3b82f6'
|
|
1491
1762
|
* ```
|
|
1492
1763
|
*/
|
|
1493
|
-
function
|
|
1764
|
+
function createTokens(tokens = {}, options = {}) {
|
|
1494
1765
|
const logger = useLogger();
|
|
1495
|
-
const registry = useRegistry();
|
|
1766
|
+
const registry = useRegistry(options);
|
|
1496
1767
|
const cache = /* @__PURE__ */ new Map();
|
|
1497
1768
|
registry.onboard(flatten(tokens, options.prefix, !!options.flat));
|
|
1498
1769
|
function isAlias(token) {
|
|
@@ -1501,12 +1772,18 @@ function useTokens(tokens = {}, options = {}) {
|
|
|
1501
1772
|
function isTokenAlias(value) {
|
|
1502
1773
|
return /* @__PURE__ */ isObject(value) && "$value" in value;
|
|
1503
1774
|
}
|
|
1504
|
-
function resolve(token) {
|
|
1775
|
+
function resolve(token, visited = /* @__PURE__ */ new Set()) {
|
|
1505
1776
|
const cacheKey = /* @__PURE__ */ isString(token) ? token : JSON.stringify(token);
|
|
1506
1777
|
const cached = cache.get(cacheKey);
|
|
1507
1778
|
if (cached !== void 0) return cached;
|
|
1508
1779
|
const reference = isTokenAlias(token) ? token.$value : token;
|
|
1509
1780
|
const clean = /* @__PURE__ */ isString(reference) && isAlias(reference) ? reference.slice(1, -1) : String(reference);
|
|
1781
|
+
if (visited.has(clean)) {
|
|
1782
|
+
logger.warn(`Circular alias detected for "${clean}"`);
|
|
1783
|
+
cache.set(cacheKey, void 0);
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
visited.add(clean);
|
|
1510
1787
|
let found = registry.get(clean);
|
|
1511
1788
|
let segments = [];
|
|
1512
1789
|
if (!found && clean.includes(".")) {
|
|
@@ -1547,9 +1824,9 @@ function useTokens(tokens = {}, options = {}) {
|
|
|
1547
1824
|
result = current;
|
|
1548
1825
|
} else if (isTokenAlias(current)) {
|
|
1549
1826
|
const inner = current.$value;
|
|
1550
|
-
if (/* @__PURE__ */ isString(inner) && isAlias(inner)) return resolve(inner);
|
|
1827
|
+
if (/* @__PURE__ */ isString(inner) && isAlias(inner)) return resolve(inner, visited);
|
|
1551
1828
|
result = inner;
|
|
1552
|
-
} else if (/* @__PURE__ */ isString(current) && isAlias(current)) return resolve(current);
|
|
1829
|
+
} else if (/* @__PURE__ */ isString(current) && isAlias(current)) return resolve(current, visited);
|
|
1553
1830
|
else result = current;
|
|
1554
1831
|
cache.set(cacheKey, result);
|
|
1555
1832
|
return result;
|
|
@@ -1578,34 +1855,47 @@ function useTokens(tokens = {}, options = {}) {
|
|
|
1578
1855
|
* ```ts
|
|
1579
1856
|
* import { createTokensContext } from '@vuetify/v0'
|
|
1580
1857
|
*
|
|
1581
|
-
* const
|
|
1582
|
-
*
|
|
1583
|
-
*
|
|
1584
|
-
*
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1588
|
-
*
|
|
1589
|
-
*
|
|
1590
|
-
*
|
|
1591
|
-
* // In a parent component:
|
|
1592
|
-
* provideDesignTokens()
|
|
1593
|
-
*
|
|
1594
|
-
* // In a child component:
|
|
1595
|
-
* const tokens = useDesignTokens()
|
|
1596
|
-
*
|
|
1597
|
-
* console.log(tokens.resolve('{spacing.md}')) // '16px'
|
|
1858
|
+
* export const [useTokens, provideTokens, context] = createTokensContext({
|
|
1859
|
+
* namespace: 'v0:tokens',
|
|
1860
|
+
* tokens: {
|
|
1861
|
+
* colors: {
|
|
1862
|
+
* primary: '#3b82f6',
|
|
1863
|
+
* secondary: '{colors.primary}', // Alias reference
|
|
1864
|
+
* },
|
|
1865
|
+
* },
|
|
1866
|
+
* })
|
|
1598
1867
|
* ```
|
|
1599
1868
|
*/
|
|
1600
|
-
function createTokensContext(
|
|
1869
|
+
function createTokensContext(_options) {
|
|
1870
|
+
const { namespace, tokens = {},...options } = _options;
|
|
1601
1871
|
const [useTokensContext, _provideTokensContext] = createContext(namespace);
|
|
1602
|
-
const context =
|
|
1872
|
+
const context = createTokens(tokens, options);
|
|
1603
1873
|
function provideTokensContext(_context = context, app) {
|
|
1604
1874
|
return _provideTokensContext(_context, app);
|
|
1605
1875
|
}
|
|
1606
1876
|
return createTrinity(useTokensContext, provideTokensContext, context);
|
|
1607
1877
|
}
|
|
1608
1878
|
/**
|
|
1879
|
+
* Returns the current tokens instance.
|
|
1880
|
+
*
|
|
1881
|
+
* @param namespace The namespace for the tokens context. Defaults to `'v0:tokens'`.
|
|
1882
|
+
* @returns The current tokens instance.
|
|
1883
|
+
*
|
|
1884
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-tokens
|
|
1885
|
+
*
|
|
1886
|
+
* @example
|
|
1887
|
+
* ```vue
|
|
1888
|
+
* <script setup lang="ts">
|
|
1889
|
+
* import { useTokens } from '@vuetify/v0'
|
|
1890
|
+
*
|
|
1891
|
+
* const tokens = useTokens()
|
|
1892
|
+
* <\/script>
|
|
1893
|
+
* ```
|
|
1894
|
+
*/
|
|
1895
|
+
function useTokens(namespace = "v0:tokens") {
|
|
1896
|
+
return useContext(namespace);
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1609
1899
|
* Flattens a nested collection of tokens into a flat array of tokens.
|
|
1610
1900
|
* Each token is represented by an object containing its ID & value.
|
|
1611
1901
|
* @param tokens The collection of tokens to flatten.
|
|
@@ -1686,19 +1976,19 @@ function flatten(tokens, prefix = "", flat = false) {
|
|
|
1686
1976
|
/**
|
|
1687
1977
|
* Creates a new features instance.
|
|
1688
1978
|
*
|
|
1689
|
-
* @param namespace The namespace to use for the features instance.
|
|
1690
1979
|
* @param options The options for the features instance.
|
|
1691
1980
|
* @template Z The type of the feature ticket.
|
|
1692
1981
|
* @template E The type of the feature context.
|
|
1693
1982
|
* @returns A new features instance.
|
|
1694
1983
|
*
|
|
1695
|
-
* @see https://0.vuetifyjs.com/composables/plugins/
|
|
1984
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-features
|
|
1696
1985
|
*
|
|
1697
1986
|
* @example
|
|
1698
1987
|
* ```ts
|
|
1699
1988
|
* import { createFeatures } from '@vuetify/v0'
|
|
1700
1989
|
*
|
|
1701
|
-
* const [useFeatures, provideFeaturesContext] = createFeatures(
|
|
1990
|
+
* const [useFeatures, provideFeaturesContext, context] = createFeatures({
|
|
1991
|
+
* namespace: 'v0:features',
|
|
1702
1992
|
* features: {
|
|
1703
1993
|
* 'dark-mode': true,
|
|
1704
1994
|
* 'theme-color': { $variation: 'blue' },
|
|
@@ -1706,10 +1996,10 @@ function flatten(tokens, prefix = "", flat = false) {
|
|
|
1706
1996
|
* })
|
|
1707
1997
|
* ```
|
|
1708
1998
|
*/
|
|
1709
|
-
function createFeatures(
|
|
1710
|
-
const
|
|
1711
|
-
const tokens =
|
|
1712
|
-
const registry =
|
|
1999
|
+
function createFeatures(_options = {}) {
|
|
2000
|
+
const { features,...options } = _options;
|
|
2001
|
+
const tokens = createTokens(features, { flat: true });
|
|
2002
|
+
const registry = createGroup(options);
|
|
1713
2003
|
for (const [id, { value }] of tokens.entries()) register({
|
|
1714
2004
|
id,
|
|
1715
2005
|
value
|
|
@@ -1728,7 +2018,7 @@ function createFeatures(namespace = "v0:features", options = {}) {
|
|
|
1728
2018
|
if (/* @__PURE__ */ isBoolean(ticket.value) && ticket.value === true || /* @__PURE__ */ isObject(ticket.value) && /* @__PURE__ */ isBoolean(ticket.value.$value) && ticket.value.$value === true) registry.select(ticket.id);
|
|
1729
2019
|
return ticket;
|
|
1730
2020
|
}
|
|
1731
|
-
|
|
2021
|
+
return {
|
|
1732
2022
|
...registry,
|
|
1733
2023
|
variation,
|
|
1734
2024
|
register,
|
|
@@ -1736,37 +2026,38 @@ function createFeatures(namespace = "v0:features", options = {}) {
|
|
|
1736
2026
|
return registry.size;
|
|
1737
2027
|
}
|
|
1738
2028
|
};
|
|
1739
|
-
function provideFeaturesContext(_context = context, app) {
|
|
1740
|
-
return _provideFeaturesContext(_context, app);
|
|
1741
|
-
}
|
|
1742
|
-
return createTrinity(useFeaturesContext, provideFeaturesContext, context);
|
|
1743
2029
|
}
|
|
1744
2030
|
/**
|
|
1745
|
-
*
|
|
2031
|
+
* Creates a new features context.
|
|
1746
2032
|
*
|
|
2033
|
+
* @param options The options for the features context.
|
|
1747
2034
|
* @template Z The type of the feature ticket.
|
|
1748
|
-
* @
|
|
2035
|
+
* @template E The type of the feature context.
|
|
2036
|
+
* @returns A new features context.
|
|
1749
2037
|
*
|
|
1750
|
-
* @see https://0.vuetifyjs.com/composables/plugins/
|
|
2038
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-features
|
|
1751
2039
|
*
|
|
1752
2040
|
* @example
|
|
1753
|
-
* ```
|
|
1754
|
-
*
|
|
1755
|
-
* import { useFeatures } from '@vuetify/v0'
|
|
1756
|
-
*
|
|
1757
|
-
* const features = useFeatures()
|
|
1758
|
-
* <\/script>
|
|
2041
|
+
* ```ts
|
|
2042
|
+
* import { createFeaturesContext } from '@vuetify/v0'
|
|
1759
2043
|
*
|
|
1760
|
-
*
|
|
1761
|
-
*
|
|
1762
|
-
*
|
|
1763
|
-
*
|
|
1764
|
-
*
|
|
1765
|
-
*
|
|
1766
|
-
*
|
|
2044
|
+
* export const [useFeatures, provideFeatures, context] = createFeaturesContext({
|
|
2045
|
+
* namespace: 'app:features',
|
|
2046
|
+
* features: {
|
|
2047
|
+
* 'dark-mode': true,
|
|
2048
|
+
* 'theme-color': { $variation: 'blue' },
|
|
2049
|
+
* },
|
|
2050
|
+
* })
|
|
2051
|
+
* ```
|
|
1767
2052
|
*/
|
|
1768
|
-
function
|
|
1769
|
-
|
|
2053
|
+
function createFeaturesContext(_options = {}) {
|
|
2054
|
+
const { namespace = "v0:features",...options } = _options;
|
|
2055
|
+
const [useFeaturesContext, _provideFeaturesContext] = createContext(namespace);
|
|
2056
|
+
const context = createFeatures(options);
|
|
2057
|
+
function provideFeaturesContext(_context = context, app) {
|
|
2058
|
+
return _provideFeaturesContext(_context, app);
|
|
2059
|
+
}
|
|
2060
|
+
return createTrinity(useFeaturesContext, provideFeaturesContext, context);
|
|
1770
2061
|
}
|
|
1771
2062
|
/**
|
|
1772
2063
|
* Creates a new features plugin.
|
|
@@ -1776,7 +2067,7 @@ function useFeatures() {
|
|
|
1776
2067
|
* @template E The type of the feature context.
|
|
1777
2068
|
* @returns A new features plugin.
|
|
1778
2069
|
*
|
|
1779
|
-
* @see https://0.vuetifyjs.com/composables/plugins/
|
|
2070
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-features
|
|
1780
2071
|
*
|
|
1781
2072
|
* @example
|
|
1782
2073
|
* ```ts
|
|
@@ -1798,15 +2089,47 @@ function useFeatures() {
|
|
|
1798
2089
|
* app.mount('#app')
|
|
1799
2090
|
* ```
|
|
1800
2091
|
*/
|
|
1801
|
-
function createFeaturesPlugin(
|
|
1802
|
-
const
|
|
2092
|
+
function createFeaturesPlugin(_options = {}) {
|
|
2093
|
+
const { namespace = "v0:features",...options } = _options;
|
|
2094
|
+
const [, provideFeaturesContext, context] = createFeaturesContext({
|
|
2095
|
+
...options,
|
|
2096
|
+
namespace
|
|
2097
|
+
});
|
|
1803
2098
|
return createPlugin({
|
|
1804
|
-
namespace
|
|
2099
|
+
namespace,
|
|
1805
2100
|
provide: (app) => {
|
|
1806
2101
|
provideFeaturesContext(context, app);
|
|
1807
2102
|
}
|
|
1808
2103
|
});
|
|
1809
2104
|
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Returns the current features instance.
|
|
2107
|
+
*
|
|
2108
|
+
* @param namespace The namespace for the features context. Defaults to `v0:features`.
|
|
2109
|
+
* @template Z The type of the feature ticket.
|
|
2110
|
+
* @returns The current features instance.
|
|
2111
|
+
*
|
|
2112
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-features
|
|
2113
|
+
*
|
|
2114
|
+
* @example
|
|
2115
|
+
* ```vue
|
|
2116
|
+
* <script setup lang="ts">
|
|
2117
|
+
* import { useFeatures } from '@vuetify/v0'
|
|
2118
|
+
*
|
|
2119
|
+
* const features = useFeatures()
|
|
2120
|
+
* <\/script>
|
|
2121
|
+
*
|
|
2122
|
+
* <template>
|
|
2123
|
+
* <div>
|
|
2124
|
+
* <p>Features: {{ features.get('dark-mode') }}</p>
|
|
2125
|
+
* <p>Theme Color: {{ features.variation('theme-color') }}</p>
|
|
2126
|
+
* </div>
|
|
2127
|
+
* </template>
|
|
2128
|
+
* ```
|
|
2129
|
+
*/
|
|
2130
|
+
function useFeatures(namespace = "v0:features") {
|
|
2131
|
+
return useContext(namespace);
|
|
2132
|
+
}
|
|
1810
2133
|
|
|
1811
2134
|
//#endregion
|
|
1812
2135
|
//#region src/composables/useFilter/index.ts
|
|
@@ -1815,7 +2138,7 @@ function defaultFilter(query, item, keys, mode = "some") {
|
|
|
1815
2138
|
function match(value, q) {
|
|
1816
2139
|
return String(value).toLowerCase().includes(q);
|
|
1817
2140
|
}
|
|
1818
|
-
const stringValues = (
|
|
2141
|
+
const stringValues = (/* @__PURE__ */ isObject(item) ? keys?.length ? keys.map((k) => item[k]) : Object.values(item) : [item]).map((v) => String(v).toLowerCase());
|
|
1819
2142
|
if (mode === "some") return stringValues.some((val) => match(val, queries[0]));
|
|
1820
2143
|
if (mode === "every") return stringValues.every((val) => match(val, queries[0]));
|
|
1821
2144
|
if (mode === "union") return queries.some((q) => stringValues.some((val) => match(val, q)));
|
|
@@ -1878,9 +2201,9 @@ function useFilter(query, items, options = {}) {
|
|
|
1878
2201
|
*
|
|
1879
2202
|
* @example
|
|
1880
2203
|
* ```ts
|
|
1881
|
-
* import {
|
|
2204
|
+
* import { createForm } from '@vuetify/v0'
|
|
1882
2205
|
*
|
|
1883
|
-
* const form =
|
|
2206
|
+
* const form = createForm()
|
|
1884
2207
|
*
|
|
1885
2208
|
* const username = form.register({
|
|
1886
2209
|
* id: 'username',
|
|
@@ -1895,7 +2218,7 @@ function useFilter(query, items, options = {}) {
|
|
|
1895
2218
|
* form.reset()
|
|
1896
2219
|
* ```
|
|
1897
2220
|
*/
|
|
1898
|
-
function
|
|
2221
|
+
function createForm(options) {
|
|
1899
2222
|
const registry = useRegistry(options);
|
|
1900
2223
|
const validateOn = options?.validateOn || "submit";
|
|
1901
2224
|
function parse(value) {
|
|
@@ -1915,7 +2238,7 @@ function useForm(options) {
|
|
|
1915
2238
|
if (ticket.isValid.value === false) return false;
|
|
1916
2239
|
if (ticket.isValid.value === null) return null;
|
|
1917
2240
|
}
|
|
1918
|
-
return hasFields
|
|
2241
|
+
return hasFields || null;
|
|
1919
2242
|
});
|
|
1920
2243
|
function reset() {
|
|
1921
2244
|
for (const ticket of registry.values()) ticket.reset();
|
|
@@ -1947,10 +2270,10 @@ function useForm(options) {
|
|
|
1947
2270
|
isValid$1.value = null;
|
|
1948
2271
|
}
|
|
1949
2272
|
async function validate$1(silent = false) {
|
|
1950
|
-
if (rules.length === 0) return true;
|
|
2273
|
+
if (rules.length === 0) return isValid$1.value = true;
|
|
1951
2274
|
isValidating$1.value = true;
|
|
1952
2275
|
try {
|
|
1953
|
-
const errorMessages = (await Promise.all(rules.map((rule) => rule(model.value)))).filter((result) =>
|
|
2276
|
+
const errorMessages = (await Promise.all(rules.map((rule) => rule(model.value)))).filter((result) => /* @__PURE__ */ isString(result));
|
|
1954
2277
|
if (!silent) {
|
|
1955
2278
|
errors.value = errorMessages;
|
|
1956
2279
|
isValid$1.value = errorMessages.length === 0;
|
|
@@ -2002,6 +2325,68 @@ function useForm(options) {
|
|
|
2002
2325
|
}
|
|
2003
2326
|
};
|
|
2004
2327
|
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Creates a new form context.
|
|
2330
|
+
*
|
|
2331
|
+
* @param namespace The namespace for the form context.
|
|
2332
|
+
* @param options The options for the form context.
|
|
2333
|
+
* @template Z The type of the form ticket.
|
|
2334
|
+
* @template E The type of the form context.
|
|
2335
|
+
* @returns A new form context.
|
|
2336
|
+
*
|
|
2337
|
+
* @see https://0.vuetifyjs.com/composables/forms/use-form
|
|
2338
|
+
*
|
|
2339
|
+
* @example
|
|
2340
|
+
* ```ts
|
|
2341
|
+
* import { createFormContext } from '@vuetify/v0'
|
|
2342
|
+
*
|
|
2343
|
+
* export const [useMyForm, provideMyForm, myForm] = createFormContext('my-form', {
|
|
2344
|
+
* validateOn: 'change',
|
|
2345
|
+
* })
|
|
2346
|
+
*
|
|
2347
|
+
* // In a parent component:
|
|
2348
|
+
* provideMyForm()
|
|
2349
|
+
*
|
|
2350
|
+
* // In a child component:
|
|
2351
|
+
* const form = useMyForm()
|
|
2352
|
+
* form.register({ id: 'field', value: ref(''), rules: [...] })
|
|
2353
|
+
* ```
|
|
2354
|
+
*/
|
|
2355
|
+
function createFormContext(_options) {
|
|
2356
|
+
const { namespace,...options } = _options;
|
|
2357
|
+
const [useFormContext, _provideFormContext] = createContext(namespace);
|
|
2358
|
+
const context = createForm(options);
|
|
2359
|
+
function provideFormContext(_context = context, app) {
|
|
2360
|
+
return _provideFormContext(_context, app);
|
|
2361
|
+
}
|
|
2362
|
+
return createTrinity(useFormContext, provideFormContext, context);
|
|
2363
|
+
}
|
|
2364
|
+
/**
|
|
2365
|
+
* Returns the current form instance.
|
|
2366
|
+
*
|
|
2367
|
+
* @param namespace The namespace for the form context. Defaults to `'v0:form'`.
|
|
2368
|
+
* @returns The current form instance.
|
|
2369
|
+
*
|
|
2370
|
+
* @see https://0.vuetifyjs.com/composables/forms/use-form
|
|
2371
|
+
*
|
|
2372
|
+
* @example
|
|
2373
|
+
* ```vue
|
|
2374
|
+
* <script setup lang="ts">
|
|
2375
|
+
* import { useForm } from '@vuetify/v0'
|
|
2376
|
+
*
|
|
2377
|
+
* const form = useForm()
|
|
2378
|
+
* <\/script>
|
|
2379
|
+
*
|
|
2380
|
+
* <template>
|
|
2381
|
+
* <div>
|
|
2382
|
+
* <p>Form is {{ form.isValid.value ? 'valid' : 'invalid' }}</p>
|
|
2383
|
+
* </div>
|
|
2384
|
+
* </template>
|
|
2385
|
+
* ```
|
|
2386
|
+
*/
|
|
2387
|
+
function useForm(namespace = "v0:form") {
|
|
2388
|
+
return useContext(namespace);
|
|
2389
|
+
}
|
|
2005
2390
|
|
|
2006
2391
|
//#endregion
|
|
2007
2392
|
//#region src/composables/useIntersectionObserver/index.ts
|
|
@@ -2217,33 +2602,57 @@ function useKeydown(handlers) {
|
|
|
2217
2602
|
//#endregion
|
|
2218
2603
|
//#region src/composables/useSingle/index.ts
|
|
2219
2604
|
/**
|
|
2220
|
-
* Creates a new single selection instance.
|
|
2605
|
+
* Creates a new single selection instance that enforces only one selected item at a time.
|
|
2606
|
+
*
|
|
2607
|
+
* Extends `createSelection` by automatically clearing previous selections when a new item is selected.
|
|
2608
|
+
* Adds computed singular properties: `selectedId`, `selectedItem`, `selectedIndex`, `selectedValue`.
|
|
2221
2609
|
*
|
|
2222
2610
|
* @param options The options for the single selection instance.
|
|
2223
2611
|
* @template Z The type of the single selection ticket.
|
|
2224
2612
|
* @template E The type of the single selection context.
|
|
2225
|
-
* @returns A new single selection instance.
|
|
2613
|
+
* @returns A new single selection instance with single-selection enforcement.
|
|
2614
|
+
*
|
|
2615
|
+
* @remarks
|
|
2616
|
+
* **Key Differences from `createSelection`:**
|
|
2617
|
+
* - Automatically clears `selectedIds` before selecting a new item (enforces single selection)
|
|
2618
|
+
* - Provides singular computed properties instead of plural sets
|
|
2619
|
+
* - Perfect for tabs, radio buttons, theme selectors, and other single-choice UI components
|
|
2620
|
+
*
|
|
2621
|
+
* **Computed Properties:**
|
|
2622
|
+
* - `selectedId`: The ID of the selected item (undefined if none selected)
|
|
2623
|
+
* - `selectedItem`: The selected ticket object (undefined if none selected)
|
|
2624
|
+
* - `selectedIndex`: The index of the selected item (-1 if none selected)
|
|
2625
|
+
* - `selectedValue`: The value of the selected item (undefined if none selected)
|
|
2626
|
+
*
|
|
2627
|
+
* **Inheritance Chain:**
|
|
2628
|
+
* `useRegistry` → `createSelection` → `createSingle` → `createStep`
|
|
2226
2629
|
*
|
|
2227
2630
|
* @see https://0.vuetifyjs.com/composables/selection/use-single
|
|
2228
2631
|
*
|
|
2229
2632
|
* @example
|
|
2230
2633
|
* ```ts
|
|
2231
|
-
* import {
|
|
2634
|
+
* import { createSingle } from '@vuetify/v0'
|
|
2232
2635
|
*
|
|
2233
|
-
* const
|
|
2636
|
+
* const tabs = createSingle({ mandatory: true })
|
|
2234
2637
|
*
|
|
2235
|
-
*
|
|
2236
|
-
* { id: '
|
|
2237
|
-
* { id: '
|
|
2638
|
+
* tabs.onboard([
|
|
2639
|
+
* { id: 'home', value: 'Home' },
|
|
2640
|
+
* { id: 'about', value: 'About' },
|
|
2641
|
+
* { id: 'contact', value: 'Contact' },
|
|
2238
2642
|
* ])
|
|
2239
2643
|
*
|
|
2240
|
-
*
|
|
2644
|
+
* tabs.first() // Select first tab
|
|
2645
|
+
*
|
|
2646
|
+
* console.log(tabs.selectedId.value) // 'home'
|
|
2647
|
+
* console.log(tabs.selectedIndex.value) // 0
|
|
2241
2648
|
*
|
|
2242
|
-
*
|
|
2649
|
+
* tabs.select('about') // Switch to about tab
|
|
2650
|
+
* console.log(tabs.selectedId.value) // 'about'
|
|
2651
|
+
* console.log(tabs.selectedIds.size) // 1 (always enforces single selection)
|
|
2243
2652
|
* ```
|
|
2244
2653
|
*/
|
|
2245
|
-
function
|
|
2246
|
-
const registry =
|
|
2654
|
+
function createSingle(options) {
|
|
2655
|
+
const registry = createSelection(options);
|
|
2247
2656
|
const mandatory = options?.mandatory ?? false;
|
|
2248
2657
|
const selectedId = computed(() => registry.selectedIds.values().next().value);
|
|
2249
2658
|
const selectedItem = computed(() => registry.selectedItems.value.values().next().value);
|
|
@@ -2302,14 +2711,41 @@ function useSingle(options) {
|
|
|
2302
2711
|
* tabs.select('tab-1')
|
|
2303
2712
|
* ```
|
|
2304
2713
|
*/
|
|
2305
|
-
function createSingleContext(
|
|
2714
|
+
function createSingleContext(_options) {
|
|
2715
|
+
const { namespace,...options } = _options;
|
|
2306
2716
|
const [useSingleContext, _provideSingleContext] = createContext(namespace);
|
|
2307
|
-
const context =
|
|
2717
|
+
const context = createSingle(options);
|
|
2308
2718
|
function provideSingleContext(_context = context, app) {
|
|
2309
2719
|
return _provideSingleContext(_context, app);
|
|
2310
2720
|
}
|
|
2311
2721
|
return createTrinity(useSingleContext, provideSingleContext, context);
|
|
2312
2722
|
}
|
|
2723
|
+
/**
|
|
2724
|
+
* Returns the current single selection instance.
|
|
2725
|
+
*
|
|
2726
|
+
* @param namespace The namespace for the single selection context. Defaults to `'v0:single'`.
|
|
2727
|
+
* @returns The current single selection instance.
|
|
2728
|
+
*
|
|
2729
|
+
* @see https://0.vuetifyjs.com/composables/selection/use-single
|
|
2730
|
+
*
|
|
2731
|
+
* @example
|
|
2732
|
+
* ```vue
|
|
2733
|
+
* <script setup lang="ts">
|
|
2734
|
+
* import { useSingle } from '@vuetify/v0'
|
|
2735
|
+
*
|
|
2736
|
+
* const tabs = useSingle()
|
|
2737
|
+
* <\/script>
|
|
2738
|
+
*
|
|
2739
|
+
* <template>
|
|
2740
|
+
* <div>
|
|
2741
|
+
* <p>Selected: {{ tabs.selectedId }}</p>
|
|
2742
|
+
* </div>
|
|
2743
|
+
* </template>
|
|
2744
|
+
* ```
|
|
2745
|
+
*/
|
|
2746
|
+
function useSingle(namespace = "v0:single") {
|
|
2747
|
+
return useContext(namespace);
|
|
2748
|
+
}
|
|
2313
2749
|
|
|
2314
2750
|
//#endregion
|
|
2315
2751
|
//#region src/composables/useLocale/adapters/v0.ts
|
|
@@ -2323,7 +2759,7 @@ function createSingleContext(namespace, options) {
|
|
|
2323
2759
|
var Vuetify0LocaleAdapter = class {
|
|
2324
2760
|
t(message, ...params) {
|
|
2325
2761
|
let resolvedMessage = message;
|
|
2326
|
-
if (params.length > 0 &&
|
|
2762
|
+
if (params.length > 0 && /* @__PURE__ */ isObject(params[0])) {
|
|
2327
2763
|
const variables = params[0];
|
|
2328
2764
|
resolvedMessage = resolvedMessage.replace(/{([a-zA-Z][a-zA-Z0-9_]*)}/g, (match, name) => {
|
|
2329
2765
|
return variables[name] === void 0 ? match : String(variables[name]);
|
|
@@ -2349,7 +2785,6 @@ var Vuetify0LocaleAdapter = class {
|
|
|
2349
2785
|
/**
|
|
2350
2786
|
* Creates a new locale instance.
|
|
2351
2787
|
*
|
|
2352
|
-
* @param namespace The namespace for the locale instance.
|
|
2353
2788
|
* @param options The options for the locale instance.
|
|
2354
2789
|
* @template Z The type of the locale ticket.
|
|
2355
2790
|
* @template E The type of the locale context.
|
|
@@ -2357,38 +2792,45 @@ var Vuetify0LocaleAdapter = class {
|
|
|
2357
2792
|
*
|
|
2358
2793
|
* @see https://0.vuetifyjs.com/composables/plugins/use-locale
|
|
2359
2794
|
*/
|
|
2360
|
-
function createLocale(
|
|
2361
|
-
const { adapter = new Vuetify0LocaleAdapter(), messages = {} } =
|
|
2362
|
-
const
|
|
2363
|
-
const registry =
|
|
2795
|
+
function createLocale(_options = {}) {
|
|
2796
|
+
const { adapter = new Vuetify0LocaleAdapter(), messages = {},...options } = _options;
|
|
2797
|
+
const tokens = createTokens(messages, { flat: true });
|
|
2798
|
+
const registry = createSingle(options);
|
|
2364
2799
|
for (const id in messages) {
|
|
2365
2800
|
registry.register({
|
|
2366
|
-
|
|
2367
|
-
id
|
|
2801
|
+
id,
|
|
2802
|
+
value: messages[id]
|
|
2368
2803
|
});
|
|
2369
2804
|
if (id === options.default && !registry.selectedId.value) registry.select(id);
|
|
2370
2805
|
}
|
|
2371
2806
|
function t(key, ...params) {
|
|
2372
2807
|
const locale = registry.selectedId.value;
|
|
2373
2808
|
if (!locale) return key;
|
|
2374
|
-
const message =
|
|
2375
|
-
const template =
|
|
2809
|
+
const message = (registry.get(locale)?.value)?.[key];
|
|
2810
|
+
const template = /* @__PURE__ */ isString(message) ? resolve(locale, message) : key;
|
|
2376
2811
|
return adapter.t(template, ...params);
|
|
2377
2812
|
}
|
|
2378
2813
|
function n(value, ...params) {
|
|
2379
2814
|
return adapter.n(value, registry.selectedId.value, ...params);
|
|
2380
2815
|
}
|
|
2381
2816
|
function resolve(locale, str) {
|
|
2382
|
-
return str.replace(/{([a-zA-Z0-9.-_]+)}/g, (match,
|
|
2383
|
-
const [
|
|
2384
|
-
const
|
|
2385
|
-
const
|
|
2386
|
-
const
|
|
2387
|
-
const
|
|
2388
|
-
|
|
2817
|
+
return str.replace(/{([a-zA-Z0-9.-_]+)}/g, (match, key) => {
|
|
2818
|
+
const [prefix, ...rest] = key.split(".");
|
|
2819
|
+
const path = rest.join(".");
|
|
2820
|
+
const prefixTicket = registry.get(prefix);
|
|
2821
|
+
const target = prefixTicket ? prefix : locale;
|
|
2822
|
+
const name = prefixTicket ? path : key;
|
|
2823
|
+
const resolved = (registry.get(target)?.value)?.[name];
|
|
2824
|
+
if (/* @__PURE__ */ isString(resolved)) return resolve(target, resolved);
|
|
2825
|
+
const alias = `{${key}}`;
|
|
2826
|
+
if (tokens.isAlias(alias)) {
|
|
2827
|
+
const result = tokens.resolve(alias);
|
|
2828
|
+
return /* @__PURE__ */ isString(result) ? result : match;
|
|
2829
|
+
}
|
|
2830
|
+
return match;
|
|
2389
2831
|
});
|
|
2390
2832
|
}
|
|
2391
|
-
|
|
2833
|
+
return {
|
|
2392
2834
|
...registry,
|
|
2393
2835
|
t,
|
|
2394
2836
|
n,
|
|
@@ -2396,20 +2838,45 @@ function createLocale(namespace = "v0:locale", options = {}) {
|
|
|
2396
2838
|
return registry.size;
|
|
2397
2839
|
}
|
|
2398
2840
|
};
|
|
2399
|
-
function provideLocaleContext(_context = context, app) {
|
|
2400
|
-
return _provideLocaleContext(_context, app);
|
|
2401
|
-
}
|
|
2402
|
-
return createTrinity(useLocaleContext, provideLocaleContext, context);
|
|
2403
2841
|
}
|
|
2404
2842
|
/**
|
|
2405
|
-
*
|
|
2843
|
+
* Creates a new locale context.
|
|
2406
2844
|
*
|
|
2407
|
-
* @
|
|
2845
|
+
* @param options The options for the locale context.
|
|
2846
|
+
* @template Z The type of the locale ticket.
|
|
2847
|
+
* @template E The type of the locale context.
|
|
2848
|
+
* @returns A new locale context.
|
|
2408
2849
|
*
|
|
2409
2850
|
* @see https://0.vuetifyjs.com/composables/plugins/use-locale
|
|
2851
|
+
*
|
|
2852
|
+
* @example
|
|
2853
|
+
* ```ts
|
|
2854
|
+
* import { createLocaleContext } from '@vuetify/v0'
|
|
2855
|
+
*
|
|
2856
|
+
* export const [useAppLocale, provideAppLocale, appLocale] = createLocaleContext({
|
|
2857
|
+
* namespace: 'app:locale',
|
|
2858
|
+
* messages: {
|
|
2859
|
+
* en: { hello: 'Hello' },
|
|
2860
|
+
* es: { hello: 'Hola' },
|
|
2861
|
+
* },
|
|
2862
|
+
* })
|
|
2863
|
+
*
|
|
2864
|
+
* // In a parent component:
|
|
2865
|
+
* provideAppLocale()
|
|
2866
|
+
*
|
|
2867
|
+
* // In a child component:
|
|
2868
|
+
* const locale = useAppLocale()
|
|
2869
|
+
* locale.select('es')
|
|
2870
|
+
* ```
|
|
2410
2871
|
*/
|
|
2411
|
-
function
|
|
2412
|
-
|
|
2872
|
+
function createLocaleContext(_options = {}) {
|
|
2873
|
+
const { namespace = "v0:locale",...options } = _options;
|
|
2874
|
+
const [useLocaleContext, _provideLocaleContext] = createContext(namespace);
|
|
2875
|
+
const context = createLocale(options);
|
|
2876
|
+
function provideLocaleContext(_context = context, app) {
|
|
2877
|
+
return _provideLocaleContext(_context, app);
|
|
2878
|
+
}
|
|
2879
|
+
return createTrinity(useLocaleContext, provideLocaleContext, context);
|
|
2413
2880
|
}
|
|
2414
2881
|
/**
|
|
2415
2882
|
* Creates a new locale plugin.
|
|
@@ -2423,21 +2890,31 @@ function useLocale() {
|
|
|
2423
2890
|
*
|
|
2424
2891
|
* @see https://0.vuetifyjs.com/composables/plugins/use-locale
|
|
2425
2892
|
*/
|
|
2426
|
-
function createLocalePlugin(
|
|
2427
|
-
const { adapter = new Vuetify0LocaleAdapter(), messages = {} } =
|
|
2428
|
-
const [,
|
|
2429
|
-
|
|
2893
|
+
function createLocalePlugin(_options = {}) {
|
|
2894
|
+
const { namespace = "v0:locale", adapter = new Vuetify0LocaleAdapter(), messages = {},...options } = _options;
|
|
2895
|
+
const [, provideLocaleContext, context] = createLocaleContext({
|
|
2896
|
+
...options,
|
|
2897
|
+
namespace,
|
|
2430
2898
|
adapter,
|
|
2431
2899
|
messages
|
|
2432
2900
|
});
|
|
2433
2901
|
return createPlugin({
|
|
2434
|
-
namespace
|
|
2902
|
+
namespace,
|
|
2435
2903
|
provide: (app) => {
|
|
2436
|
-
provideLocaleContext(
|
|
2437
|
-
provideLocaleTokenContext(tokensContext, app);
|
|
2904
|
+
provideLocaleContext(context, app);
|
|
2438
2905
|
}
|
|
2439
2906
|
});
|
|
2440
2907
|
}
|
|
2908
|
+
/**
|
|
2909
|
+
* Returns the current locale instance.
|
|
2910
|
+
*
|
|
2911
|
+
* @returns The current locale instance.
|
|
2912
|
+
*
|
|
2913
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-locale
|
|
2914
|
+
*/
|
|
2915
|
+
function useLocale(namespace = "v0:locale") {
|
|
2916
|
+
return useContext(namespace);
|
|
2917
|
+
}
|
|
2441
2918
|
|
|
2442
2919
|
//#endregion
|
|
2443
2920
|
//#region src/composables/useMutationObserver/index.ts
|
|
@@ -2586,19 +3063,19 @@ var Vuetify0PermissionAdapter = class extends PermissionAdapter {
|
|
|
2586
3063
|
/**
|
|
2587
3064
|
* Creates a new permissions instance.
|
|
2588
3065
|
*
|
|
2589
|
-
* @param namespace The namespace for the permissions instance.
|
|
2590
3066
|
* @param options The options for the permissions instance.
|
|
2591
3067
|
* @template Z The type of the permission ticket.
|
|
2592
3068
|
* @template E The type of the permission context.
|
|
2593
3069
|
* @returns A new permissions instance.
|
|
2594
3070
|
*
|
|
2595
|
-
* @see https://0.vuetifyjs.com/composables/plugins/
|
|
3071
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-permissions
|
|
2596
3072
|
*
|
|
2597
3073
|
* @example
|
|
2598
3074
|
* ```ts
|
|
2599
3075
|
* import { createPermissions } from '@vuetify/v0'
|
|
2600
3076
|
*
|
|
2601
|
-
* const [usePermissions, providePermissions] = createPermissions(
|
|
3077
|
+
* const [usePermissions, providePermissions] = createPermissions({
|
|
3078
|
+
* namespace: 'v0:permissions',
|
|
2602
3079
|
* permissions: {
|
|
2603
3080
|
* admin: [['read', 'users']],
|
|
2604
3081
|
* editor: [['edit', 'posts']],
|
|
@@ -2606,9 +3083,8 @@ var Vuetify0PermissionAdapter = class extends PermissionAdapter {
|
|
|
2606
3083
|
* })
|
|
2607
3084
|
* ```
|
|
2608
3085
|
*/
|
|
2609
|
-
function createPermissions(
|
|
2610
|
-
const { adapter = new Vuetify0PermissionAdapter(), permissions = {} } =
|
|
2611
|
-
const [usePermissionsContext, _providePermissionsContext] = createContext(namespace);
|
|
3086
|
+
function createPermissions(_options = {}) {
|
|
3087
|
+
const { adapter = new Vuetify0PermissionAdapter(), permissions = {},...options } = _options;
|
|
2612
3088
|
const record = {};
|
|
2613
3089
|
for (const role in permissions) {
|
|
2614
3090
|
if (!record[role]) record[role] = {};
|
|
@@ -2617,44 +3093,46 @@ function createPermissions(namespace = "v0:permissions", options = {}) {
|
|
|
2617
3093
|
record[role][action][subject] = condition;
|
|
2618
3094
|
}
|
|
2619
3095
|
}
|
|
2620
|
-
const tokens =
|
|
2621
|
-
function can(id, action, subject, context
|
|
2622
|
-
return adapter.can(id, action, subject, context
|
|
3096
|
+
const tokens = createTokens(record, options);
|
|
3097
|
+
function can(id, action, subject, context = {}) {
|
|
3098
|
+
return adapter.can(id, action, subject, context, tokens);
|
|
2623
3099
|
}
|
|
2624
|
-
|
|
3100
|
+
return {
|
|
2625
3101
|
...tokens,
|
|
2626
3102
|
can
|
|
2627
3103
|
};
|
|
2628
|
-
function providePermissionsContext(_context = context, app) {
|
|
2629
|
-
return _providePermissionsContext(_context, app);
|
|
2630
|
-
}
|
|
2631
|
-
return createTrinity(usePermissionsContext, providePermissionsContext, context);
|
|
2632
3104
|
}
|
|
2633
3105
|
/**
|
|
2634
|
-
*
|
|
3106
|
+
* Creates a new permissions context.
|
|
2635
3107
|
*
|
|
3108
|
+
* @param options The options for the permissions context.
|
|
2636
3109
|
* @template Z The type of the permission ticket.
|
|
2637
|
-
* @
|
|
3110
|
+
* @template E The type of the permission context.
|
|
3111
|
+
* @returns A new permissions context.
|
|
2638
3112
|
*
|
|
2639
3113
|
* @see https://0.vuetifyjs.com/composables/plugins/use-permissions
|
|
2640
3114
|
*
|
|
2641
3115
|
* @example
|
|
2642
|
-
* ```
|
|
2643
|
-
*
|
|
2644
|
-
* import { usePermissions } from '@vuetify/v0'
|
|
2645
|
-
*
|
|
2646
|
-
* const { can } = usePermissions()
|
|
2647
|
-
* <\/script>
|
|
3116
|
+
* ```ts
|
|
3117
|
+
* import { createPermissionsContext } from '@vuetify/v0'
|
|
2648
3118
|
*
|
|
2649
|
-
*
|
|
2650
|
-
*
|
|
2651
|
-
*
|
|
2652
|
-
*
|
|
2653
|
-
*
|
|
3119
|
+
* export const [usePermissions, providePermissions, context] = createPermissionsContext({
|
|
3120
|
+
* namespace: 'app:permissions',
|
|
3121
|
+
* permissions: {
|
|
3122
|
+
* admin: [['read', 'users'], ['edit', 'users']],
|
|
3123
|
+
* editor: [['edit', 'posts']],
|
|
3124
|
+
* },
|
|
3125
|
+
* })
|
|
2654
3126
|
* ```
|
|
2655
3127
|
*/
|
|
2656
|
-
function
|
|
2657
|
-
|
|
3128
|
+
function createPermissionsContext(_options = {}) {
|
|
3129
|
+
const { namespace = "v0:permissions",...options } = _options;
|
|
3130
|
+
const [usePermissionsContext, _providePermissionsContext] = createContext(namespace);
|
|
3131
|
+
const context = createPermissions(options);
|
|
3132
|
+
function providePermissionsContext(_context = context, app) {
|
|
3133
|
+
return _providePermissionsContext(_context, app);
|
|
3134
|
+
}
|
|
3135
|
+
return createTrinity(usePermissionsContext, providePermissionsContext, context);
|
|
2658
3136
|
}
|
|
2659
3137
|
/**
|
|
2660
3138
|
* Creates a new permissions plugin.
|
|
@@ -2686,15 +3164,45 @@ function usePermissions() {
|
|
|
2686
3164
|
* app.mount('#app')
|
|
2687
3165
|
* ```
|
|
2688
3166
|
*/
|
|
2689
|
-
function createPermissionsPlugin(
|
|
2690
|
-
const
|
|
3167
|
+
function createPermissionsPlugin(_options = {}) {
|
|
3168
|
+
const { namespace = "v0:permissions",...options } = _options;
|
|
3169
|
+
const [, providePermissionContext, context] = createPermissionsContext({
|
|
3170
|
+
...options,
|
|
3171
|
+
namespace
|
|
3172
|
+
});
|
|
2691
3173
|
return createPlugin({
|
|
2692
|
-
namespace
|
|
3174
|
+
namespace,
|
|
2693
3175
|
provide: (app) => {
|
|
2694
3176
|
providePermissionContext(context, app);
|
|
2695
3177
|
}
|
|
2696
3178
|
});
|
|
2697
3179
|
}
|
|
3180
|
+
/**
|
|
3181
|
+
* Returns the current permissions instance.
|
|
3182
|
+
*
|
|
3183
|
+
* @template Z The type of the permission ticket.
|
|
3184
|
+
* @returns The current permissions instance.
|
|
3185
|
+
*
|
|
3186
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-permissions
|
|
3187
|
+
*
|
|
3188
|
+
* @example
|
|
3189
|
+
* ```vue
|
|
3190
|
+
* <script setup lang="ts">
|
|
3191
|
+
* import { usePermissions } from '@vuetify/v0'
|
|
3192
|
+
*
|
|
3193
|
+
* const { can } = usePermissions()
|
|
3194
|
+
* <\/script>
|
|
3195
|
+
*
|
|
3196
|
+
* <template>
|
|
3197
|
+
* <div>
|
|
3198
|
+
* <p v-if="can('admin', 'read', 'users')">Admin access</p>
|
|
3199
|
+
* </div>
|
|
3200
|
+
* </template>
|
|
3201
|
+
* ```
|
|
3202
|
+
*/
|
|
3203
|
+
function usePermissions(namespace = "v0:permissions") {
|
|
3204
|
+
return useContext(namespace);
|
|
3205
|
+
}
|
|
2698
3206
|
|
|
2699
3207
|
//#endregion
|
|
2700
3208
|
//#region src/composables/useProxyModel/index.ts
|
|
@@ -2713,9 +3221,9 @@ function createPermissionsPlugin(options = {}) {
|
|
|
2713
3221
|
*
|
|
2714
3222
|
* @example
|
|
2715
3223
|
* ```ts
|
|
2716
|
-
* import {
|
|
3224
|
+
* import { createSelection, useProxyModel } from '@vuetify/v0'
|
|
2717
3225
|
*
|
|
2718
|
-
* const registry =
|
|
3226
|
+
* const registry = createSelection({ events: true })
|
|
2719
3227
|
* registry.onboard([
|
|
2720
3228
|
* { id: 'item-1', value: 'Item 1' },
|
|
2721
3229
|
* { id: 'item-2', value: 'Item 2' },
|
|
@@ -2852,7 +3360,7 @@ function useProxyRegistry(registry, options) {
|
|
|
2852
3360
|
registry.on("update:ticket", update);
|
|
2853
3361
|
registry.on("clear:registry", update);
|
|
2854
3362
|
onScopeDispose(() => {
|
|
2855
|
-
registry.off("register:
|
|
3363
|
+
registry.off("register:ticket", update);
|
|
2856
3364
|
registry.off("unregister:ticket", update);
|
|
2857
3365
|
registry.off("update:ticket", update);
|
|
2858
3366
|
registry.off("clear:registry", update);
|
|
@@ -2893,8 +3401,8 @@ function useProxyRegistry(registry, options) {
|
|
|
2893
3401
|
* console.log(queue.size) // 2
|
|
2894
3402
|
* ```
|
|
2895
3403
|
*/
|
|
2896
|
-
function
|
|
2897
|
-
const { timeout: _timeout = 3e3,...options } = _options
|
|
3404
|
+
function createQueue(_options = {}) {
|
|
3405
|
+
const { timeout: _timeout = 3e3,...options } = _options;
|
|
2898
3406
|
const registry = useRegistry({
|
|
2899
3407
|
...options,
|
|
2900
3408
|
events: true
|
|
@@ -2975,6 +3483,55 @@ function useQueue(_options) {
|
|
|
2975
3483
|
}
|
|
2976
3484
|
};
|
|
2977
3485
|
}
|
|
3486
|
+
/**
|
|
3487
|
+
* Creates a new queue context.
|
|
3488
|
+
*
|
|
3489
|
+
* @param namespace The namespace for the queue context.
|
|
3490
|
+
* @param options The options for the queue context.
|
|
3491
|
+
* @template Z The type of the queue ticket.
|
|
3492
|
+
* @template E The type of the queue context.
|
|
3493
|
+
* @returns A new queue context.
|
|
3494
|
+
*
|
|
3495
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-queue
|
|
3496
|
+
*
|
|
3497
|
+
* @example
|
|
3498
|
+
* ```ts
|
|
3499
|
+
* import { createQueueContext } from '@vuetify/v0'
|
|
3500
|
+
*
|
|
3501
|
+
* export const [useQueue, provideQueue] = createQueueContext('v0:queue', {
|
|
3502
|
+
* timeout: 5000,
|
|
3503
|
+
* })
|
|
3504
|
+
* ```
|
|
3505
|
+
*/
|
|
3506
|
+
function createQueueContext(_options) {
|
|
3507
|
+
const { namespace,...options } = _options;
|
|
3508
|
+
const [useQueueContext, _provideQueueContext] = createContext(namespace);
|
|
3509
|
+
const context = createQueue(options);
|
|
3510
|
+
function provideQueueContext(_context = context, app) {
|
|
3511
|
+
return _provideQueueContext(_context, app);
|
|
3512
|
+
}
|
|
3513
|
+
return createTrinity(useQueueContext, provideQueueContext, context);
|
|
3514
|
+
}
|
|
3515
|
+
/**
|
|
3516
|
+
* Returns the current queue instance.
|
|
3517
|
+
*
|
|
3518
|
+
* @param namespace The namespace for the queue context. Defaults to `'v0:queue'`.
|
|
3519
|
+
* @returns The current queue instance.
|
|
3520
|
+
*
|
|
3521
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-queue
|
|
3522
|
+
*
|
|
3523
|
+
* @example
|
|
3524
|
+
* ```vue
|
|
3525
|
+
* <script setup lang="ts">
|
|
3526
|
+
* import { useQueue } from '@vuetify/v0'
|
|
3527
|
+
*
|
|
3528
|
+
* const queue = useQueue()
|
|
3529
|
+
* <\/script>
|
|
3530
|
+
* ```
|
|
3531
|
+
*/
|
|
3532
|
+
function useQueue(namespace = "v0:queue") {
|
|
3533
|
+
return useContext(namespace);
|
|
3534
|
+
}
|
|
2978
3535
|
|
|
2979
3536
|
//#endregion
|
|
2980
3537
|
//#region src/composables/useResizeObserver/index.ts
|
|
@@ -3130,35 +3687,66 @@ function useElementSize(target) {
|
|
|
3130
3687
|
//#endregion
|
|
3131
3688
|
//#region src/composables/useStep/index.ts
|
|
3132
3689
|
/**
|
|
3133
|
-
* Creates a new step instance.
|
|
3690
|
+
* Creates a new step instance with circular navigation through items.
|
|
3691
|
+
*
|
|
3692
|
+
* Extends `createSingle` with `first()`, `last()`, `next()`, `prev()`, and `step(count)` methods
|
|
3693
|
+
* for sequential navigation. Automatically wraps around at boundaries (circular navigation).
|
|
3134
3694
|
*
|
|
3135
3695
|
* @param options The options for the step instance.
|
|
3136
3696
|
* @template Z The type of the step ticket.
|
|
3137
3697
|
* @template E The type of the step context.
|
|
3138
|
-
* @returns A new step instance.
|
|
3698
|
+
* @returns A new step instance with navigation methods.
|
|
3699
|
+
*
|
|
3700
|
+
* @remarks
|
|
3701
|
+
* **Key Features:**
|
|
3702
|
+
* - **Circular Navigation**: Wrapping at start/end boundaries
|
|
3703
|
+
* - **Disabled Item Skipping**: Automatically skips disabled items during navigation
|
|
3704
|
+
* - **Bidirectional**: Forward (`next`, positive `step`) and backward (`prev`, negative `step`)
|
|
3705
|
+
* - **Safe Edge Cases**: Handles empty registries and all-disabled scenarios gracefully
|
|
3706
|
+
*
|
|
3707
|
+
* **Navigation Methods:**
|
|
3708
|
+
* - `first()`: Select first non-disabled item
|
|
3709
|
+
* - `last()`: Select last non-disabled item
|
|
3710
|
+
* - `next()`: Move to next item (wraps to first)
|
|
3711
|
+
* - `prev()`: Move to previous item (wraps to last)
|
|
3712
|
+
* - `step(count)`: Move by `count` positions (negative for backward)
|
|
3713
|
+
*
|
|
3714
|
+
* **Wrapping Behavior:**
|
|
3715
|
+
* - Uses modulo arithmetic for circular wrapping: `((index % length) + length) % length`
|
|
3716
|
+
* - Works correctly with negative indexes and large step counts
|
|
3717
|
+
* - Continues searching if landing on disabled items (up to registry length iterations)
|
|
3718
|
+
* - Returns early if all items are disabled to prevent infinite loops
|
|
3719
|
+
*
|
|
3720
|
+
* **Inheritance Chain:**
|
|
3721
|
+
* `useRegistry` → `createSelection` → `createSingle` → `createStep`
|
|
3139
3722
|
*
|
|
3140
3723
|
* @see https://0.vuetifyjs.com/composables/selection/use-step
|
|
3141
3724
|
*
|
|
3142
3725
|
* @example
|
|
3143
3726
|
* ```ts
|
|
3144
|
-
* import {
|
|
3727
|
+
* import { createStep } from '@vuetify/v0'
|
|
3145
3728
|
*
|
|
3146
|
-
* const
|
|
3729
|
+
* const wizard = createStep({ mandatory: true })
|
|
3147
3730
|
*
|
|
3148
|
-
*
|
|
3149
|
-
* { id: '
|
|
3150
|
-
* { id: '
|
|
3151
|
-
* { id: '
|
|
3731
|
+
* wizard.onboard([
|
|
3732
|
+
* { id: 'account', value: 'Account Info' },
|
|
3733
|
+
* { id: 'payment', value: 'Payment Details' },
|
|
3734
|
+
* { id: 'review', value: 'Review', disabled: true },
|
|
3735
|
+
* { id: 'confirm', value: 'Confirmation' },
|
|
3152
3736
|
* ])
|
|
3153
3737
|
*
|
|
3154
|
-
*
|
|
3155
|
-
*
|
|
3738
|
+
* wizard.first() // Select 'account'
|
|
3739
|
+
* console.log(wizard.selectedId.value) // 'account'
|
|
3740
|
+
*
|
|
3741
|
+
* wizard.next() // Move to 'payment'
|
|
3742
|
+
* wizard.next() // Skip disabled 'review', move to 'confirm'
|
|
3743
|
+
* wizard.next() // Wrap around to 'account'
|
|
3156
3744
|
*
|
|
3157
|
-
*
|
|
3745
|
+
* wizard.step(-2) // Go back 2 steps (wraps correctly)
|
|
3158
3746
|
* ```
|
|
3159
3747
|
*/
|
|
3160
|
-
function
|
|
3161
|
-
const registry =
|
|
3748
|
+
function createStep(options) {
|
|
3749
|
+
const registry = createSingle(options);
|
|
3162
3750
|
function first() {
|
|
3163
3751
|
const ticket = registry.seek("first");
|
|
3164
3752
|
if (ticket) registry.select(ticket.id);
|
|
@@ -3229,14 +3817,42 @@ function useStep(options) {
|
|
|
3229
3817
|
* wizard.next() // Progress to next step
|
|
3230
3818
|
* ```
|
|
3231
3819
|
*/
|
|
3232
|
-
function createStepContext(
|
|
3820
|
+
function createStepContext(_options) {
|
|
3821
|
+
const { namespace,...options } = _options;
|
|
3233
3822
|
const [useStepContext, _provideStepContext] = createContext(namespace);
|
|
3234
|
-
const context =
|
|
3823
|
+
const context = createStep(options);
|
|
3235
3824
|
function provideStepContext(_context = context, app) {
|
|
3236
3825
|
return _provideStepContext(_context, app);
|
|
3237
3826
|
}
|
|
3238
3827
|
return createTrinity(useStepContext, provideStepContext, context);
|
|
3239
3828
|
}
|
|
3829
|
+
/**
|
|
3830
|
+
* Returns the current step instance.
|
|
3831
|
+
*
|
|
3832
|
+
* @param namespace The namespace for the step context. Defaults to `'v0:step'`.
|
|
3833
|
+
* @returns The current step instance.
|
|
3834
|
+
*
|
|
3835
|
+
* @see https://0.vuetifyjs.com/composables/selection/use-step
|
|
3836
|
+
*
|
|
3837
|
+
* @example
|
|
3838
|
+
* ```vue
|
|
3839
|
+
* <script setup lang="ts">
|
|
3840
|
+
* import { useStep } from '@vuetify/v0'
|
|
3841
|
+
*
|
|
3842
|
+
* const wizard = useStep()
|
|
3843
|
+
* <\/script>
|
|
3844
|
+
*
|
|
3845
|
+
* <template>
|
|
3846
|
+
* <div>
|
|
3847
|
+
* <p>Current step: {{ wizard.selectedIndex }}</p>
|
|
3848
|
+
* <button @click="wizard.next()">Next</button>
|
|
3849
|
+
* </div>
|
|
3850
|
+
* </template>
|
|
3851
|
+
* ```
|
|
3852
|
+
*/
|
|
3853
|
+
function useStep(namespace = "v0:step") {
|
|
3854
|
+
return useContext(namespace);
|
|
3855
|
+
}
|
|
3240
3856
|
|
|
3241
3857
|
//#endregion
|
|
3242
3858
|
//#region src/composables/useStorage/adapters/memory.ts
|
|
@@ -3352,31 +3968,14 @@ function createStorage(options = {}) {
|
|
|
3352
3968
|
clear
|
|
3353
3969
|
};
|
|
3354
3970
|
}
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
* ```vue
|
|
3364
|
-
* <script setup lang="ts">
|
|
3365
|
-
* import { useStorage } from '@vuetify/v0'
|
|
3366
|
-
*
|
|
3367
|
-
* const storage = useStorage()
|
|
3368
|
-
* const username = storage.get('username', 'Guest')
|
|
3369
|
-
* <\/script>
|
|
3370
|
-
*
|
|
3371
|
-
* <template>
|
|
3372
|
-
* <div>
|
|
3373
|
-
* <p>Username: {{ username }}</p>
|
|
3374
|
-
* </div>
|
|
3375
|
-
* </template>
|
|
3376
|
-
* ```
|
|
3377
|
-
*/
|
|
3378
|
-
function useStorage() {
|
|
3379
|
-
return useStorageContext();
|
|
3971
|
+
function createStorageContext(_options = {}) {
|
|
3972
|
+
const { namespace = "v0:storage",...options } = _options;
|
|
3973
|
+
const [useStorageContext$1, _provideStorageContext] = createContext(namespace);
|
|
3974
|
+
const context = createStorage(options);
|
|
3975
|
+
function provideStorageContext$1(_context = context, app) {
|
|
3976
|
+
return _provideStorageContext(_context, app);
|
|
3977
|
+
}
|
|
3978
|
+
return createTrinity(useStorageContext$1, provideStorageContext$1, context);
|
|
3380
3979
|
}
|
|
3381
3980
|
/**
|
|
3382
3981
|
* Creates a new storage plugin.
|
|
@@ -3399,15 +3998,46 @@ function useStorage() {
|
|
|
3399
3998
|
* app.mount('#app')
|
|
3400
3999
|
* ```
|
|
3401
4000
|
*/
|
|
3402
|
-
function createStoragePlugin(
|
|
3403
|
-
const
|
|
4001
|
+
function createStoragePlugin(_options = {}) {
|
|
4002
|
+
const { namespace = "v0:storage",...options } = _options;
|
|
4003
|
+
const [, provideStorageContext$1, context] = createStorageContext({
|
|
4004
|
+
...options,
|
|
4005
|
+
namespace
|
|
4006
|
+
});
|
|
3404
4007
|
return createPlugin({
|
|
3405
|
-
namespace
|
|
4008
|
+
namespace,
|
|
3406
4009
|
provide: (app) => {
|
|
3407
|
-
provideStorageContext(context, app);
|
|
4010
|
+
provideStorageContext$1(context, app);
|
|
3408
4011
|
}
|
|
3409
4012
|
});
|
|
3410
4013
|
}
|
|
4014
|
+
/**
|
|
4015
|
+
* Returns the current storage instance.
|
|
4016
|
+
*
|
|
4017
|
+
* @param namespace The namespace for the storage context. Defaults to `'v0:storage'`.
|
|
4018
|
+
* @returns The current storage instance.
|
|
4019
|
+
*
|
|
4020
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-storage
|
|
4021
|
+
*
|
|
4022
|
+
* @example
|
|
4023
|
+
* ```vue
|
|
4024
|
+
* <script setup lang="ts">
|
|
4025
|
+
* import { useStorage } from '@vuetify/v0'
|
|
4026
|
+
*
|
|
4027
|
+
* const storage = useStorage()
|
|
4028
|
+
* const username = storage.get('username', 'Guest')
|
|
4029
|
+
* <\/script>
|
|
4030
|
+
*
|
|
4031
|
+
* <template>
|
|
4032
|
+
* <div>
|
|
4033
|
+
* <p>Username: {{ username }}</p>
|
|
4034
|
+
* </div>
|
|
4035
|
+
* </template>
|
|
4036
|
+
* ```
|
|
4037
|
+
*/
|
|
4038
|
+
function useStorage(namespace = "v0:storage") {
|
|
4039
|
+
return useContext(namespace);
|
|
4040
|
+
}
|
|
3411
4041
|
|
|
3412
4042
|
//#endregion
|
|
3413
4043
|
//#region src/composables/useTheme/adapters/adapter.ts
|
|
@@ -3465,7 +4095,6 @@ var Vuetify0ThemeAdapter = class extends ThemeAdapter {
|
|
|
3465
4095
|
/**
|
|
3466
4096
|
* Creates a new theme instance.
|
|
3467
4097
|
*
|
|
3468
|
-
* @param namespace The namespace for the theme instance.
|
|
3469
4098
|
* @param options The options for the theme instance.
|
|
3470
4099
|
* @template Z The type of the theme ticket.
|
|
3471
4100
|
* @template E The type of the theme context.
|
|
@@ -3477,7 +4106,8 @@ var Vuetify0ThemeAdapter = class extends ThemeAdapter {
|
|
|
3477
4106
|
* ```ts
|
|
3478
4107
|
* import { createTheme } from '@vuetify/v0'
|
|
3479
4108
|
*
|
|
3480
|
-
* export const [useTheme, provideTheme] = createTheme(
|
|
4109
|
+
* export const [useTheme, provideTheme] = createTheme({
|
|
4110
|
+
* namespace: 'v0:theme',
|
|
3481
4111
|
* default: 'light',
|
|
3482
4112
|
* themes: {
|
|
3483
4113
|
* light: {
|
|
@@ -3496,14 +4126,13 @@ var Vuetify0ThemeAdapter = class extends ThemeAdapter {
|
|
|
3496
4126
|
* })
|
|
3497
4127
|
* ```
|
|
3498
4128
|
*/
|
|
3499
|
-
function createTheme(
|
|
3500
|
-
const { themes = {}, palette = {} } =
|
|
3501
|
-
const
|
|
3502
|
-
const tokens = useTokens({
|
|
4129
|
+
function createTheme(_options = {}) {
|
|
4130
|
+
const { themes = {}, palette = {},...options } = _options;
|
|
4131
|
+
const tokens = createTokens({
|
|
3503
4132
|
palette,
|
|
3504
4133
|
...themes
|
|
3505
4134
|
}, { flat: true });
|
|
3506
|
-
const registry =
|
|
4135
|
+
const registry = createSingle(options);
|
|
3507
4136
|
for (const id in themes) {
|
|
3508
4137
|
const { colors: value,...theme } = themes[id];
|
|
3509
4138
|
register({
|
|
@@ -3540,7 +4169,7 @@ function createTheme(namespace = "v0:theme", options = {}) {
|
|
|
3540
4169
|
};
|
|
3541
4170
|
return registry.register(item);
|
|
3542
4171
|
}
|
|
3543
|
-
|
|
4172
|
+
return {
|
|
3544
4173
|
...registry,
|
|
3545
4174
|
colors,
|
|
3546
4175
|
register,
|
|
@@ -3549,40 +4178,54 @@ function createTheme(namespace = "v0:theme", options = {}) {
|
|
|
3549
4178
|
return registry.size;
|
|
3550
4179
|
}
|
|
3551
4180
|
};
|
|
3552
|
-
function provideThemeContext(_context = context, app) {
|
|
3553
|
-
return _provideThemeContext(_context, app);
|
|
3554
|
-
}
|
|
3555
|
-
return createTrinity(useThemeContext, provideThemeContext, context);
|
|
3556
4181
|
}
|
|
3557
4182
|
/**
|
|
3558
|
-
*
|
|
4183
|
+
* Creates a new theme context trinity.
|
|
3559
4184
|
*
|
|
3560
|
-
* @
|
|
4185
|
+
* @param options The options for the theme context.
|
|
4186
|
+
* @template Z The type of the theme ticket.
|
|
4187
|
+
* @template E The type of the theme context.
|
|
4188
|
+
* @returns A new theme context trinity.
|
|
3561
4189
|
*
|
|
3562
4190
|
* @see https://0.vuetifyjs.com/composables/plugins/use-theme
|
|
3563
4191
|
*
|
|
3564
4192
|
* @example
|
|
3565
|
-
* ```
|
|
3566
|
-
*
|
|
3567
|
-
* import { useTheme } from '@vuetify/v0'
|
|
3568
|
-
*
|
|
3569
|
-
* const theme = useTheme()
|
|
3570
|
-
* <\/script>
|
|
4193
|
+
* ```ts
|
|
4194
|
+
* import { createThemeContext } from '@vuetify/v0'
|
|
3571
4195
|
*
|
|
3572
|
-
*
|
|
3573
|
-
*
|
|
3574
|
-
*
|
|
3575
|
-
*
|
|
3576
|
-
*
|
|
4196
|
+
* export const [useThemeContext, provideThemeContext, context] = createThemeContext({
|
|
4197
|
+
* namespace: 'v0:theme',
|
|
4198
|
+
* default: 'light',
|
|
4199
|
+
* themes: {
|
|
4200
|
+
* light: {
|
|
4201
|
+
* dark: false,
|
|
4202
|
+
* colors: {
|
|
4203
|
+
* primary: '#3b82f6',
|
|
4204
|
+
* },
|
|
4205
|
+
* },
|
|
4206
|
+
* dark: {
|
|
4207
|
+
* dark: true,
|
|
4208
|
+
* colors: {
|
|
4209
|
+
* primary: '#675496',
|
|
4210
|
+
* },
|
|
4211
|
+
* },
|
|
4212
|
+
* },
|
|
4213
|
+
* })
|
|
3577
4214
|
* ```
|
|
3578
4215
|
*/
|
|
3579
|
-
function
|
|
3580
|
-
|
|
4216
|
+
function createThemeContext(_options = {}) {
|
|
4217
|
+
const { namespace = "v0:theme",...options } = _options;
|
|
4218
|
+
const [useThemeContext, _provideThemeContext] = createContext(namespace);
|
|
4219
|
+
const context = createTheme(options);
|
|
4220
|
+
function provideThemeContext(_context = context, app) {
|
|
4221
|
+
return _provideThemeContext(_context, app);
|
|
4222
|
+
}
|
|
4223
|
+
return createTrinity(useThemeContext, provideThemeContext, context);
|
|
3581
4224
|
}
|
|
3582
4225
|
/**
|
|
3583
4226
|
* Creates a new theme plugin.
|
|
3584
4227
|
*
|
|
3585
|
-
* @param
|
|
4228
|
+
* @param options The options for the theme plugin.
|
|
3586
4229
|
* @template Z The type of the theme ticket.
|
|
3587
4230
|
* @template E The type of the theme context.
|
|
3588
4231
|
* @returns A new theme plugin.
|
|
@@ -3621,27 +4264,28 @@ function useTheme() {
|
|
|
3621
4264
|
* ```
|
|
3622
4265
|
*/
|
|
3623
4266
|
function createThemePlugin(_options = {}) {
|
|
3624
|
-
const { adapter = new Vuetify0ThemeAdapter(), palette = {}, themes = {}, target,...options } = _options;
|
|
3625
|
-
const [, provideThemeContext,
|
|
4267
|
+
const { adapter = new Vuetify0ThemeAdapter(), namespace = "v0:theme", palette = {}, themes = {}, target,...options } = _options;
|
|
4268
|
+
const [, provideThemeContext, context] = createThemeContext({
|
|
3626
4269
|
...options,
|
|
4270
|
+
namespace,
|
|
3627
4271
|
themes,
|
|
3628
4272
|
palette
|
|
3629
4273
|
});
|
|
3630
4274
|
return createPlugin({
|
|
3631
|
-
namespace
|
|
4275
|
+
namespace,
|
|
3632
4276
|
provide: (app) => {
|
|
3633
|
-
provideThemeContext(
|
|
4277
|
+
provideThemeContext(context, app);
|
|
3634
4278
|
},
|
|
3635
4279
|
setup: (app) => {
|
|
3636
4280
|
if (IN_BROWSER) {
|
|
3637
|
-
onScopeDispose(watch(
|
|
4281
|
+
onScopeDispose(watch(context.colors, (colors) => {
|
|
3638
4282
|
adapter.update(colors);
|
|
3639
4283
|
}, { immediate: true }), true);
|
|
3640
4284
|
if (target === null) return;
|
|
3641
|
-
const targetEl = target instanceof HTMLElement ? target :
|
|
4285
|
+
const targetEl = target instanceof HTMLElement ? target : /* @__PURE__ */ isString(target) ? document.querySelector(target) : app._container || document.querySelector("#app") || document.body;
|
|
3642
4286
|
if (!targetEl) return;
|
|
3643
4287
|
let prevClass = "";
|
|
3644
|
-
onScopeDispose(watch(
|
|
4288
|
+
onScopeDispose(watch(context.selectedId, (id) => {
|
|
3645
4289
|
if (!id) return;
|
|
3646
4290
|
const themeClass = `${adapter.prefix}-theme--${id}`;
|
|
3647
4291
|
if (prevClass) targetEl.classList.remove(prevClass);
|
|
@@ -3651,11 +4295,11 @@ function createThemePlugin(_options = {}) {
|
|
|
3651
4295
|
} else {
|
|
3652
4296
|
const head = app._context?.provides?.usehead ?? app._context?.provides?.head;
|
|
3653
4297
|
if (head?.push) {
|
|
3654
|
-
const id =
|
|
4298
|
+
const id = context.selectedId.value;
|
|
3655
4299
|
head.push({
|
|
3656
4300
|
htmlAttrs: { class: id ? `${adapter.prefix}-theme--${id}` : "" },
|
|
3657
4301
|
style: [{
|
|
3658
|
-
innerHTML: adapter.generate(
|
|
4302
|
+
innerHTML: adapter.generate(context.colors.value),
|
|
3659
4303
|
id: adapter.stylesheetId
|
|
3660
4304
|
}]
|
|
3661
4305
|
});
|
|
@@ -3664,6 +4308,32 @@ function createThemePlugin(_options = {}) {
|
|
|
3664
4308
|
}
|
|
3665
4309
|
});
|
|
3666
4310
|
}
|
|
4311
|
+
/**
|
|
4312
|
+
* Returns the current theme instance.
|
|
4313
|
+
*
|
|
4314
|
+
* @param namespace The namespace for the theme context. Defaults to `v0:theme`.
|
|
4315
|
+
* @returns The current theme instance.
|
|
4316
|
+
*
|
|
4317
|
+
* @see https://0.vuetifyjs.com/composables/plugins/use-theme
|
|
4318
|
+
*
|
|
4319
|
+
* @example
|
|
4320
|
+
* ```vue
|
|
4321
|
+
* <script setup lang="ts">
|
|
4322
|
+
* import { useTheme } from '@vuetify/v0'
|
|
4323
|
+
*
|
|
4324
|
+
* const theme = useTheme()
|
|
4325
|
+
* <\/script>
|
|
4326
|
+
*
|
|
4327
|
+
* <template>
|
|
4328
|
+
* <div>
|
|
4329
|
+
* <p>Current theme: {{ theme.selected.value }}</p>
|
|
4330
|
+
* </div>
|
|
4331
|
+
* </template>
|
|
4332
|
+
* ```
|
|
4333
|
+
*/
|
|
4334
|
+
function useTheme(namespace = "v0:theme") {
|
|
4335
|
+
return useContext(namespace);
|
|
4336
|
+
}
|
|
3667
4337
|
|
|
3668
4338
|
//#endregion
|
|
3669
4339
|
//#region src/composables/useTimeline/index.ts
|
|
@@ -3694,7 +4364,7 @@ function createThemePlugin(_options = {}) {
|
|
|
3694
4364
|
* console.log(timeline.values()) // [{ id: 'one' }, { id: 'two' }, { id: 'three' }]
|
|
3695
4365
|
* ```
|
|
3696
4366
|
*/
|
|
3697
|
-
function
|
|
4367
|
+
function createTimeline(_options = {}) {
|
|
3698
4368
|
const { size = 10,...options } = _options;
|
|
3699
4369
|
const registry = useRegistry(options);
|
|
3700
4370
|
const stack = [];
|
|
@@ -3741,6 +4411,62 @@ function useTimeline(_options = {}) {
|
|
|
3741
4411
|
}
|
|
3742
4412
|
};
|
|
3743
4413
|
}
|
|
4414
|
+
/**
|
|
4415
|
+
* Creates a new timeline plugin.
|
|
4416
|
+
*
|
|
4417
|
+
* @param namespace The namespace for the timeline plugin.
|
|
4418
|
+
* @param options The options for the timeline plugin.
|
|
4419
|
+
* @template Z The type of the timeline ticket.
|
|
4420
|
+
* @template E The type of the timeline context.
|
|
4421
|
+
* @returns A new timeline plugin.
|
|
4422
|
+
*
|
|
4423
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-timeline
|
|
4424
|
+
*
|
|
4425
|
+
* @example
|
|
4426
|
+
* ```ts
|
|
4427
|
+
* import { createTimelineContext } from '@vuetify/v0'
|
|
4428
|
+
*
|
|
4429
|
+
* export const [useTimeline, provideTimeline, context] = createTimelineContext('v0:timeline', { size: 5 })
|
|
4430
|
+
* context.register({ id: 'example' })
|
|
4431
|
+
*
|
|
4432
|
+
* // In a parent component
|
|
4433
|
+
* provideTimeline()
|
|
4434
|
+
*
|
|
4435
|
+
* // In a child component
|
|
4436
|
+
* const timeline = useTimeline()
|
|
4437
|
+
*
|
|
4438
|
+
* console.log(timeline.values()) // [{ id: 'example' }]
|
|
4439
|
+
* ```
|
|
4440
|
+
*/
|
|
4441
|
+
function createTimelineContext(_options) {
|
|
4442
|
+
const { namespace,...options } = _options;
|
|
4443
|
+
const [useTimelineContext, _provideTimelineContext] = createContext(namespace);
|
|
4444
|
+
const context = createTimeline(options);
|
|
4445
|
+
function provideTimelineContext(_context = context, app) {
|
|
4446
|
+
return _provideTimelineContext(_context, app);
|
|
4447
|
+
}
|
|
4448
|
+
return createTrinity(useTimelineContext, provideTimelineContext, context);
|
|
4449
|
+
}
|
|
4450
|
+
/**
|
|
4451
|
+
* Returns the current timeline instance.
|
|
4452
|
+
*
|
|
4453
|
+
* @param namespace The namespace for the timeline context. Defaults to `'v0:timeline'`.
|
|
4454
|
+
* @returns The current timeline instance.
|
|
4455
|
+
*
|
|
4456
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-timeline
|
|
4457
|
+
*
|
|
4458
|
+
* @example
|
|
4459
|
+
* ```vue
|
|
4460
|
+
* <script setup lang="ts">
|
|
4461
|
+
* import { useTimeline } from '@vuetify/v0'
|
|
4462
|
+
*
|
|
4463
|
+
* const timeline = useTimeline()
|
|
4464
|
+
* <\/script>
|
|
4465
|
+
* ```
|
|
4466
|
+
*/
|
|
4467
|
+
function useTimeline(namespace = "v0:timeline") {
|
|
4468
|
+
return useContext(namespace);
|
|
4469
|
+
}
|
|
3744
4470
|
|
|
3745
4471
|
//#endregion
|
|
3746
|
-
export {
|
|
4472
|
+
export { useTokens as $, PermissionAdapter as A, createContext as At, useKeydown as B, useQueue as C, createHydrationContext as Ct, createPermissionsContext as D, toArray as Dt, createPermissions as E, toReactive as Et, useLocale as F, useForm as G, useIntersectionObserver as H, Vuetify0LocaleAdapter as I, createFeaturesContext as J, useFilter as K, createSingle as L, createLocale as M, useContext as Mt, createLocaleContext as N, createPermissionsPlugin as O, createTrinity as Ot, createLocalePlugin as P, createTokensContext as Q, createSingleContext as R, createQueueContext as S, createHydration as St, useProxyModel as T, useHydration as Tt, createForm as U, useElementIntersection as V, createFormContext as W, useFeatures as X, createFeaturesPlugin as Y, createTokens as Z, createStepContext as _, useWindowEventListener as _t, createThemeContext as a, useSelection as at, useResizeObserver as b, createBreakpointsPlugin as bt, Vuetify0ThemeAdapter as c, createLogger as ct, createStoragePlugin as d, useLogger as dt, createGroup as et, provideStorageContext as f, Vuetify0LoggerAdapter as ft, createStep as g, useEventListener as gt, MemoryAdapter as h, useDocumentEventListener as ht, createTheme as i, createSelectionContext as it, useMutationObserver as j, provideContext as jt, usePermissions as k, createPlugin as kt, createStorage as l, createLoggerContext as lt, useStorageContext as m, ConsolaLoggerAdapter as mt, createTimelineContext as n, useGroup as nt, createThemePlugin as o, createRegistryContext as ot, useStorage as p, PinoLoggerAdapter as pt, createFeatures as q, useTimeline as r, createSelection as rt, useTheme as s, useRegistry as st, createTimeline as t, createGroupContext as tt, createStorageContext as u, createLoggerPlugin as ut, useStep as v, createBreakpoints as vt, useProxyRegistry as w, createHydrationPlugin as wt, createQueue as x, useBreakpoints as xt, useElementSize as y, createBreakpointsContext as yt, useSingle as z };
|