@vuetify/v0 0.0.2-beta.4 → 0.0.3

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.
Files changed (52) hide show
  1. package/README.md +251 -0
  2. package/dist/browser/index.js +3199 -0
  3. package/dist/components/index.d.ts +7 -0
  4. package/dist/components/index.js +8 -0
  5. package/dist/{components-B5iiovK7.mjs → components-DVuB4lnH.js} +16 -217
  6. package/dist/composables/index.d.ts +7 -0
  7. package/dist/composables/index.js +8 -0
  8. package/dist/composables-yeVk-ULz.js +1270 -0
  9. package/dist/constants/index.d.ts +2 -0
  10. package/dist/constants/index.js +5 -0
  11. package/dist/constants-DiTCgvMU.js +1 -0
  12. package/dist/factories/index.d.ts +2 -0
  13. package/dist/factories/index.js +3 -0
  14. package/dist/{createTrinity-CwGvQ2ng.mjs → factories-BEpawPUw.js} +32 -15
  15. package/dist/globals-DZvNEOB4.js +12 -0
  16. package/dist/htmlElements-SjqYu0am.js +78 -0
  17. package/dist/{index-D4Grk5x1.d.mts → index-BozA2pze.d.ts} +1 -1
  18. package/dist/index-Ckt12ON6.d.ts +75 -0
  19. package/dist/index-D0L_ydyW.d.ts +1396 -0
  20. package/dist/index-DVKeyWc5.d.ts +79 -0
  21. package/dist/index.d.ts +7 -0
  22. package/dist/index.js +11 -0
  23. package/dist/transformers/index.d.ts +2 -0
  24. package/dist/transformers/index.js +4 -0
  25. package/dist/{transformers-BTjuwbOV.mjs → transformers-CWrxLIkw.js} +2 -2
  26. package/dist/types/{index.d.mts → index.d.ts} +1 -1
  27. package/dist/types/index.js +1 -0
  28. package/dist/{useTheme-tY7MoBKr.mjs → useTheme-DCXkw_kv.js} +214 -204
  29. package/dist/utilities/{index.d.mts → index.d.ts} +2 -2
  30. package/dist/utilities/{index.mjs → index.js} +1 -1
  31. package/package.json +20 -35
  32. package/dist/components/index.d.mts +0 -5
  33. package/dist/components/index.mjs +0 -7
  34. package/dist/composables/index.d.mts +0 -5
  35. package/dist/composables/index.mjs +0 -7
  36. package/dist/composables-C6dl5kjP.mjs +0 -614
  37. package/dist/factories/index.d.mts +0 -3
  38. package/dist/factories/index.mjs +0 -4
  39. package/dist/factories-DOLmqhVS.mjs +0 -0
  40. package/dist/index-ChaaTPKp.d.mts +0 -421
  41. package/dist/index-Cya5Y9pB.d.mts +0 -412
  42. package/dist/index-DfahEz6s.d.mts +0 -18
  43. package/dist/index-jG0yrC1F.d.mts +0 -467
  44. package/dist/index-oCBJwhpG.d.mts +0 -43
  45. package/dist/index.d.mts +0 -9
  46. package/dist/index.mjs +0 -9
  47. package/dist/transformers/index.d.mts +0 -2
  48. package/dist/transformers/index.mjs +0 -4
  49. package/dist/types/index.mjs +0 -0
  50. /package/dist/{index-BA3ZFBnL.d.mts → index-LBy5OPMu.d.ts} +0 -0
  51. /package/dist/{index-CZRh0I2w.d.mts → index-tUyghL98.d.ts} +0 -0
  52. /package/dist/{utilities-lZSfrXgw.mjs → utilities-D9rWEgQK.js} +0 -0
@@ -1,7 +1,7 @@
1
- import { createContext, createPlugin, createTrinity, useContext } from "./createTrinity-CwGvQ2ng.mjs";
2
- import { genId, isArray, isObject, isString, mergeDeep } from "./utilities-lZSfrXgw.mjs";
3
- import { toArray } from "./transformers-BTjuwbOV.mjs";
4
- import { computed, getCurrentInstance, onMounted, onScopeDispose, shallowReactive, shallowReadonly, shallowRef, toRef, watch } from "vue";
1
+ import { createContext, createPlugin, createTrinity, useContext } from "./factories-BEpawPUw.js";
2
+ import { genId, isArray, isObject, isString, mergeDeep } from "./utilities-D9rWEgQK.js";
3
+ import { IN_BROWSER, __LOGGER_ENABLED__ } from "./globals-DZvNEOB4.js";
4
+ import { computed, getCurrentInstance, onMounted, onScopeDispose, readonly, shallowReactive, shallowReadonly, shallowRef, toRef, watch } from "vue";
5
5
 
6
6
  //#region src/composables/useHydration/index.ts
7
7
  const [useHydrationContext, provideHydrationContext] = createContext("v0:hydration");
@@ -53,16 +53,6 @@ function createHydrationPlugin() {
53
53
  });
54
54
  }
55
55
 
56
- //#endregion
57
- //#region src/constants/globals.ts
58
- const IN_BROWSER = typeof window !== "undefined";
59
- const SUPPORTS_TOUCH = IN_BROWSER && ("ontouchstart" in window || window.navigator.maxTouchPoints > 0);
60
- const SUPPORTS_MATCH_MEDIA = IN_BROWSER && "matchMedia" in window && typeof window.matchMedia === "function";
61
- const SUPPORTS_OBSERVER = IN_BROWSER && "ResizeObserver" in window;
62
- const SUPPORTS_INTERSECTION_OBSERVER = IN_BROWSER && "IntersectionObserver" in window;
63
- const SUPPORTS_MUTATION_OBSERVER = IN_BROWSER && "MutationObserver" in window;
64
- const __LOGGER_ENABLED__ = process.env.NODE_ENV !== "production" || process.env.VITE_LOGGER_ENABLED === "true";
65
-
66
56
  //#endregion
67
57
  //#region src/composables/useBreakpoints/index.ts
68
58
  const [useBreakpointsContext, provideBreakpointsContext] = createContext("v0:breakpoints");
@@ -106,58 +96,54 @@ function createBreakpoints(options = {}) {
106
96
  const sorted = Object.entries(breakpoints).sort((a, b) => a[1] - b[1]);
107
97
  const names = sorted.map(([n]) => n);
108
98
  const mb = typeof mobileBreakpoint === "number" ? mobileBreakpoint : breakpoints[mobileBreakpoint] ?? breakpoints.md;
109
- const state = shallowReactive({
110
- breakpoints,
111
- name: "xs",
112
- width: 0,
113
- height: 0,
114
- isMobile: true,
115
- xs: true,
116
- sm: false,
117
- md: false,
118
- lg: false,
119
- xl: false,
120
- xxl: false,
121
- smAndUp: false,
122
- mdAndUp: false,
123
- lgAndUp: false,
124
- xlAndUp: false,
125
- xxlAndUp: false,
126
- smAndDown: true,
127
- mdAndDown: true,
128
- lgAndDown: true,
129
- xlAndDown: true,
130
- xxlAndDown: true,
131
- update
132
- });
99
+ const name = shallowRef("xs");
100
+ const width = shallowRef(0);
101
+ const height = shallowRef(0);
102
+ const isMobile = shallowRef(true);
103
+ const xs = shallowRef(true);
104
+ const sm = shallowRef(false);
105
+ const md = shallowRef(false);
106
+ const lg = shallowRef(false);
107
+ const xl = shallowRef(false);
108
+ const xxl = shallowRef(false);
109
+ const smAndUp = shallowRef(false);
110
+ const mdAndUp = shallowRef(false);
111
+ const lgAndUp = shallowRef(false);
112
+ const xlAndUp = shallowRef(false);
113
+ const xxlAndUp = shallowRef(false);
114
+ const smAndDown = shallowRef(true);
115
+ const mdAndDown = shallowRef(true);
116
+ const lgAndDown = shallowRef(true);
117
+ const xlAndDown = shallowRef(true);
118
+ const xxlAndDown = shallowRef(true);
133
119
  function update() {
134
120
  if (!IN_BROWSER) return;
135
- state.width = window.innerWidth;
136
- state.height = window.innerHeight;
121
+ width.value = window.innerWidth;
122
+ height.value = window.innerHeight;
137
123
  let current = "xs";
138
- for (let i = sorted.length - 1; i >= 0; i--) if (state.width >= sorted[i][1]) {
124
+ for (let i = sorted.length - 1; i >= 0; i--) if (width.value >= sorted[i][1]) {
139
125
  current = sorted[i][0];
140
126
  break;
141
127
  }
142
- state.name = current;
128
+ name.value = current;
143
129
  const index = names.indexOf(current);
144
- state.isMobile = state.width < mb;
145
- state.xs = index === 0;
146
- state.sm = index === 1;
147
- state.md = index === 2;
148
- state.lg = index === 3;
149
- state.xl = index === 4;
150
- state.xxl = index === 5;
151
- state.smAndUp = index >= 1;
152
- state.mdAndUp = index >= 2;
153
- state.lgAndUp = index >= 3;
154
- state.xlAndUp = index >= 4;
155
- state.xxlAndUp = index >= 5;
156
- state.smAndDown = index <= 1;
157
- state.mdAndDown = index <= 2;
158
- state.lgAndDown = index <= 3;
159
- state.xlAndDown = index <= 4;
160
- state.xxlAndDown = index <= 5;
130
+ isMobile.value = width.value < mb;
131
+ xs.value = index === 0;
132
+ sm.value = index === 1;
133
+ md.value = index === 2;
134
+ lg.value = index === 3;
135
+ xl.value = index === 4;
136
+ xxl.value = index === 5;
137
+ smAndUp.value = index >= 1;
138
+ mdAndUp.value = index >= 2;
139
+ lgAndUp.value = index >= 3;
140
+ xlAndUp.value = index >= 4;
141
+ xxlAndUp.value = index >= 5;
142
+ smAndDown.value = index <= 1;
143
+ mdAndDown.value = index <= 2;
144
+ lgAndDown.value = index <= 3;
145
+ xlAndDown.value = index <= 4;
146
+ xxlAndDown.value = index <= 5;
161
147
  }
162
148
  if (getCurrentInstance()) onMounted(() => {
163
149
  const { isHydrated } = useHydration();
@@ -173,7 +159,30 @@ function createBreakpoints(options = {}) {
173
159
  window.addEventListener("resize", listener, { passive: true });
174
160
  if (getCurrentInstance()) onScopeDispose(() => window.removeEventListener("resize", listener));
175
161
  }
176
- return state;
162
+ return {
163
+ breakpoints,
164
+ name: readonly(name),
165
+ width: readonly(width),
166
+ height: readonly(height),
167
+ isMobile: readonly(isMobile),
168
+ xs: readonly(xs),
169
+ sm: readonly(sm),
170
+ md: readonly(md),
171
+ lg: readonly(lg),
172
+ xl: readonly(xl),
173
+ xxl: readonly(xxl),
174
+ smAndUp: readonly(smAndUp),
175
+ mdAndUp: readonly(mdAndUp),
176
+ lgAndUp: readonly(lgAndUp),
177
+ xlAndUp: readonly(xlAndUp),
178
+ xxlAndUp: readonly(xxlAndUp),
179
+ smAndDown: readonly(smAndDown),
180
+ mdAndDown: readonly(mdAndDown),
181
+ lgAndDown: readonly(lgAndDown),
182
+ xlAndDown: readonly(xlAndDown),
183
+ xxlAndDown: readonly(xxlAndDown),
184
+ update
185
+ };
177
186
  }
178
187
  /**
179
188
  * Creates a Vue plugin for managing responsive breakpoints with automatic updates.
@@ -313,21 +322,19 @@ var Vuetify0LoggerAdapter = class {
313
322
  format(level, message, ...args) {
314
323
  const timestamp = this.timestamps ? this.timestamp() : "";
315
324
  const prefixTag = `[${this.prefix} ${level.toLowerCase()}]`;
316
- const formattedMessage = [
325
+ return [[
317
326
  timestamp,
318
327
  prefixTag,
319
328
  message
320
- ].filter(Boolean).join(" ");
321
- return [formattedMessage, ...args];
329
+ ].filter(Boolean).join(" "), ...args];
322
330
  }
323
331
  timestamp() {
324
332
  if (!IN_BROWSER) return (/* @__PURE__ */ new Date()).toISOString();
325
- const now = /* @__PURE__ */ new Date();
326
- return now.toTimeString().split(" ")[0];
333
+ return (/* @__PURE__ */ new Date()).toTimeString().split(" ")[0] ?? "";
327
334
  }
328
335
  style(level) {
329
336
  if (!this.colors || !IN_BROWSER) return "";
330
- const styles = {
337
+ return {
331
338
  trace: "color: #64748b",
332
339
  debug: "color: #3b82f6",
333
340
  info: "color: #10b981",
@@ -335,8 +342,7 @@ var Vuetify0LoggerAdapter = class {
335
342
  error: "color: #ef4444",
336
343
  fatal: "color: #dc2626; font-weight: bold",
337
344
  silent: ""
338
- };
339
- return styles[level] || "";
345
+ }[level] || "";
340
346
  }
341
347
  log(level, method, message, ...args) {
342
348
  const [formattedMessage, ...restArgs] = this.format(level, message, ...args);
@@ -362,7 +368,7 @@ function createLogger(options = {}) {
362
368
  const currentLevel = shallowRef(initialLevel);
363
369
  const isEnabled = shallowRef(initialEnabled);
364
370
  function value(level$1) {
365
- const levels = {
371
+ return {
366
372
  trace: 0,
367
373
  debug: 1,
368
374
  info: 2,
@@ -370,8 +376,7 @@ function createLogger(options = {}) {
370
376
  error: 4,
371
377
  fatal: 5,
372
378
  silent: 6
373
- };
374
- return levels[level$1] ?? 2;
379
+ }[level$1] ?? 2;
375
380
  }
376
381
  function can(level$1) {
377
382
  if (!isEnabled.value) return false;
@@ -477,6 +482,8 @@ function createLoggerPlugin(options = {}) {
477
482
  * @template Z The type of items managed by the registry.
478
483
  * @template E The type of the registry context.
479
484
  * @returns The registry context object.
485
+ *
486
+ * @see https://0.vuetifyjs.com/composables/registration/use-registry
480
487
  */
481
488
  function useRegistry(options) {
482
489
  const logger = useLogger();
@@ -505,6 +512,40 @@ function useRegistry(options) {
505
512
  function get(id) {
506
513
  return collection.get(id);
507
514
  }
515
+ function upsert(id, patch = {}) {
516
+ const existing = get(id);
517
+ if (!existing) return register({
518
+ ...patch,
519
+ id
520
+ });
521
+ const hasValue = Object.prototype.hasOwnProperty.call(patch, "value");
522
+ let value = existing.value;
523
+ let valueIsIndex = existing.valueIsIndex;
524
+ if (hasValue) {
525
+ if (patch.value === void 0) {
526
+ value = existing.index;
527
+ valueIsIndex = true;
528
+ } else {
529
+ value = patch.value;
530
+ valueIsIndex = false;
531
+ }
532
+ if (!Object.is(value, existing.value)) {
533
+ unassign(existing.value, id);
534
+ assign(value, id);
535
+ }
536
+ }
537
+ const updated = {
538
+ ...existing,
539
+ ...patch,
540
+ id,
541
+ index: existing.index,
542
+ value,
543
+ valueIsIndex
544
+ };
545
+ collection.set(id, updated);
546
+ invalidate();
547
+ return updated;
548
+ }
508
549
  function browse(value) {
509
550
  return catalog.get(value);
510
551
  }
@@ -560,8 +601,7 @@ function useRegistry(options) {
560
601
  invalidate();
561
602
  }
562
603
  function invalidate() {
563
- if (cache.size === 0) return;
564
- cache.clear();
604
+ if (cache.size > 0) cache.clear();
565
605
  }
566
606
  function reindex() {
567
607
  if (catalog.size > 0) catalog.clear();
@@ -585,12 +625,15 @@ function useRegistry(options) {
585
625
  logger.warn(`Item with id "${id}" already exists in the registry. Skipping registration.`);
586
626
  return get(id);
587
627
  }
628
+ const index = registration.index ?? size;
629
+ const value = registration.value === void 0 ? index : registration.value;
630
+ const valueIsIndex = registration.value === void 0;
588
631
  const item = {
589
632
  ...registration,
590
633
  id,
591
- index: registration.index ?? size,
592
- value: registration.value ?? size,
593
- valueIsIndex: registration.valueIsIndex ?? registration.value == null
634
+ index,
635
+ value,
636
+ valueIsIndex
594
637
  };
595
638
  collection.set(item.id, item);
596
639
  directory.set(item.index, item.id);
@@ -622,6 +665,7 @@ function useRegistry(options) {
622
665
  values,
623
666
  lookup,
624
667
  get,
668
+ upsert,
625
669
  register,
626
670
  unregister,
627
671
  reindex,
@@ -633,6 +677,24 @@ function useRegistry(options) {
633
677
  }
634
678
  };
635
679
  }
680
+ /**
681
+ * Creates a registry context with full injection/provision control.
682
+ * Returns the complete trinity for advanced usage scenarios.
683
+ *
684
+ * @param namespace The namespace for the registry context.
685
+ * @param options Optional configuration for reactivity behavior.
686
+ * @template Z The type of tickets managed by the registry.
687
+ * @template E The type of the registry context.
688
+ * @returns A tuple containing the inject function, provide function, and the registry context.
689
+ */
690
+ function createRegistryContext(namespace, options) {
691
+ const [useRegistryContext, _provideRegistryContext] = createContext(namespace);
692
+ const context = useRegistry(options);
693
+ function provideRegistryContext(_context = context, app) {
694
+ return _provideRegistryContext(_context, app);
695
+ }
696
+ return createTrinity(useRegistryContext, provideRegistryContext, context);
697
+ }
636
698
 
637
699
  //#endregion
638
700
  //#region src/composables/useSelection/index.ts
@@ -673,13 +735,16 @@ function useSelection(options) {
673
735
  if (selectedIds.has(id)) unselect(id);
674
736
  else select(id);
675
737
  }
738
+ function selected(id) {
739
+ return selectedIds.has(id);
740
+ }
676
741
  function register(registration = {}) {
677
742
  const id = registration.id ?? genId();
678
743
  const item = {
679
744
  disabled: false,
680
745
  ...registration,
681
746
  id,
682
- isActive: toRef(() => selectedIds.has(id)),
747
+ isSelected: toRef(() => selectedIds.has(id)),
683
748
  select: () => select(id),
684
749
  unselect: () => unselect(id),
685
750
  toggle: () => toggle(id)
@@ -709,42 +774,27 @@ function useSelection(options) {
709
774
  mandate,
710
775
  select,
711
776
  unselect,
712
- toggle
777
+ toggle,
778
+ selected
713
779
  };
714
780
  }
715
-
716
- //#endregion
717
- //#region src/composables/useGroup/index.ts
718
781
  /**
719
- * Creates a group selection context for managing collections of items where multiple selections can be made.
720
- * This function extends the selection functionality with group selection capabilities.
782
+ * Creates a selection registry context with full injection/provision control.
783
+ * Returns the complete trinity for advanced usage scenarios.
721
784
  *
722
- * @param options Optional configuration for group selection behavior.
723
- * @template Z The type of items managed by the group selection.
724
- * @template E The type of the group selection context.
725
- * @returns The group selection context object.
785
+ * @param namespace The namespace for the selection registry context
786
+ * @param options Optional configuration for selection behavior.
787
+ * @template Z The structure of the registry selection items.
788
+ * @template E The available methods for the selection's context.
789
+ * @returns A tuple containing the inject function, provide function, and the selection context.
726
790
  */
727
- function useGroup(options) {
728
- const registry = useSelection(options);
729
- const selectedIndexes = computed(() => {
730
- return new Set(Array.from(registry.selectedItems.value).map((item) => item?.index));
731
- });
732
- function select(ids) {
733
- for (const id of toArray(ids)) registry.select(id);
734
- }
735
- function unselect(ids) {
736
- for (const id of toArray(ids)) registry.unselect(id);
737
- }
738
- function toggle(ids) {
739
- for (const id of toArray(ids)) registry.toggle(id);
791
+ function createSelectionContext(namespace, options) {
792
+ const [useSelectionContext, _provideSelectionContext] = createContext(namespace);
793
+ const context = useSelection(options);
794
+ function provideSelectionContext(_context = context, app) {
795
+ return _provideSelectionContext(_context, app);
740
796
  }
741
- return {
742
- ...registry,
743
- select,
744
- unselect,
745
- toggle,
746
- selectedIndexes
747
- };
797
+ return createTrinity(useSelectionContext, provideSelectionContext, context);
748
798
  }
749
799
 
750
800
  //#endregion
@@ -760,7 +810,7 @@ function useGroup(options) {
760
810
  */
761
811
  function useSingle(options) {
762
812
  const registry = useSelection(options);
763
- const mandatory = options?.mandatory ?? true;
813
+ const mandatory = options?.mandatory ?? false;
764
814
  const selectedId = computed(() => registry.selectedIds.values().next().value);
765
815
  const selectedItem = computed(() => registry.selectedItems.value.values().next().value);
766
816
  const selectedIndex = computed(() => selectedItem.value?.index ?? -1);
@@ -769,7 +819,7 @@ function useSingle(options) {
769
819
  const item = registry.get(id);
770
820
  if (!item || item.disabled) return;
771
821
  registry.selectedIds.clear();
772
- registry.selectedIds.add(id);
822
+ registry.select(id);
773
823
  }
774
824
  function unselect(id) {
775
825
  if (mandatory && registry.selectedIds.size === 1) return;
@@ -790,64 +840,23 @@ function useSingle(options) {
790
840
  toggle
791
841
  };
792
842
  }
793
-
794
- //#endregion
795
- //#region src/composables/useStep/index.ts
796
843
  /**
797
- * Creates a step selection context for managing collections where users can navigate through items sequentially.
798
- * This function extends the single selection functionality with stepping navigation.
844
+ * Creates a single selection registry context with full injection/provision control.
845
+ * Returns the complete trinity for advanced usage scenarios.
799
846
  *
800
- * @param options Optional configuration for step behavior.
801
- * @template Z The type of items managed by the step selection.
802
- * @template E The type of the step selection context.
803
- * @returns The step selection context object.
847
+ * @param namespace The namespace for the single selection registry context
848
+ * @param options Optional configuration for single selection behavior.
849
+ * @template Z The structure of the registry single selection items.
850
+ * @template E The available methods for the single's context.
851
+ * @returns A tuple containing the inject function, provide function, and the single selection context.
804
852
  */
805
- function useStep(options) {
806
- const registry = useSingle(options);
807
- function first() {
808
- if (registry.size === 0) return;
809
- registry.selectedIds.clear();
810
- registry.select(registry.lookup(0));
811
- }
812
- function last() {
813
- const size = registry.size;
814
- if (size === 0) return;
815
- registry.selectedIds.clear();
816
- registry.select(registry.lookup(size - 1));
817
- }
818
- function next() {
819
- step(1);
820
- }
821
- function prev() {
822
- step(-1);
823
- }
824
- function wrapped(length, index) {
825
- return (index + length) % length;
826
- }
827
- function step(count = 1) {
828
- const length = registry.size;
829
- if (!length) return;
830
- const direction = Math.sign(count || 1);
831
- let hops = 0;
832
- let index = wrapped(length, registry.selectedIndex.value + count);
833
- let id = registry.lookup(index);
834
- while (id !== void 0 && registry.get(id)?.disabled && hops < length) {
835
- index = wrapped(length, index + direction);
836
- id = registry.lookup(index);
837
- hops++;
838
- }
839
- if (id === void 0 || hops === length) return;
840
- registry.selectedIds.clear();
841
- registry.select(id);
853
+ function createSingleContext(namespace, options) {
854
+ const [useSingleContext, _provideSingleContext] = createContext(namespace);
855
+ const context = useSingle(options);
856
+ function provideSingleContext(_context = context, app) {
857
+ return _provideSingleContext(_context, app);
842
858
  }
843
- return {
844
- ...registry,
845
- first,
846
- last,
847
- next,
848
- prev,
849
- step
850
- };
859
+ return createTrinity(useSingleContext, provideSingleContext, context);
851
860
  }
852
861
 
853
862
  //#endregion
@@ -860,13 +869,15 @@ function useStep(options) {
860
869
  * @template Z The structure of the registry token items.
861
870
  * @template E The available methods for the token's context.
862
871
  * @returns The token context object.
872
+ *
873
+ * @see https://0.vuetifyjs.com/composables/registration/use-tokens
863
874
  * @see https://www.designtokens.org/tr/drafts/format/
864
875
  */
865
- function useTokens(tokens = {}) {
876
+ function useTokens(tokens = {}, options = {}) {
866
877
  const logger = useLogger();
867
878
  const registry = useRegistry();
868
879
  const cache = /* @__PURE__ */ new Map();
869
- registry.onboard(flatten(tokens));
880
+ registry.onboard(flatten(tokens, options.prefix, !!options.flat));
870
881
  function isAlias(token) {
871
882
  return isString(token) && token.length > 2 && token[0] === "{" && token.at(-1) === "}";
872
883
  }
@@ -897,7 +908,7 @@ function useTokens(tokens = {}) {
897
908
  if (found?.value === void 0) {
898
909
  logger.warn(`Alias not found for "${String(reference)}"`);
899
910
  cache.set(cacheKey, void 0);
900
- return void 0;
911
+ return;
901
912
  }
902
913
  let result;
903
914
  let current = found.value;
@@ -914,7 +925,7 @@ function useTokens(tokens = {}) {
914
925
  if (current === void 0) {
915
926
  logger.warn(`Path not found inside "${clean}": ${segments.join(".")}`);
916
927
  cache.set(cacheKey, void 0);
917
- return void 0;
928
+ return;
918
929
  }
919
930
  result = current;
920
931
  } else if (isTokenAlias(current)) {
@@ -928,7 +939,8 @@ function useTokens(tokens = {}) {
928
939
  }
929
940
  return {
930
941
  ...registry,
931
- resolve
942
+ resolve,
943
+ isAlias
932
944
  };
933
945
  }
934
946
  /**
@@ -956,14 +968,15 @@ function createTokensContext(namespace, tokens = {}) {
956
968
  * @param prefix An optional prefix to prepend to each token ID.
957
969
  * @returns An array of flattened tokens, each with an ID and value.
958
970
  */
959
- function flatten(tokens, prefix = "") {
971
+ function flatten(tokens, prefix = "", flat = false) {
960
972
  const flattened = [];
961
973
  const stack = [{
962
974
  tokens,
963
- prefix
975
+ prefix,
976
+ flat
964
977
  }];
965
978
  while (stack.length > 0) {
966
- const { tokens: currentTokens, prefix: currentPrefix } = stack.pop();
979
+ const { tokens: currentTokens, prefix: currentPrefix, flat: flat$1 } = stack.pop();
967
980
  const meta = {};
968
981
  for (const k in currentTokens) if (k.startsWith("$")) meta[k] = currentTokens[k];
969
982
  if (Object.keys(meta).length > 0 && currentPrefix) flattened.push({
@@ -987,7 +1000,7 @@ function flatten(tokens, prefix = "") {
987
1000
  value
988
1001
  });
989
1002
  const inner = value.$value;
990
- if (isObject(inner)) for (const innerKey in inner) {
1003
+ if (isObject(inner) && !flat$1) for (const innerKey in inner) {
991
1004
  if (innerKey.startsWith("$")) continue;
992
1005
  const child = inner[innerKey];
993
1006
  const childId = `${id}.${innerKey}`;
@@ -1001,14 +1014,23 @@ function flatten(tokens, prefix = "") {
1001
1014
  });
1002
1015
  else stack.push({
1003
1016
  tokens: child,
1004
- prefix: childId
1017
+ prefix: childId,
1018
+ flat: flat$1
1005
1019
  });
1006
1020
  }
1007
1021
  continue;
1008
1022
  }
1023
+ if (flat$1) {
1024
+ flattened.push({
1025
+ id,
1026
+ value
1027
+ });
1028
+ continue;
1029
+ }
1009
1030
  stack.push({
1010
1031
  tokens: value,
1011
- prefix: id
1032
+ prefix: id,
1033
+ flat: flat$1
1012
1034
  });
1013
1035
  }
1014
1036
  }
@@ -1077,17 +1099,23 @@ var Vuetify0ThemeAdapter = class extends ThemeAdapter {
1077
1099
  * @template Z The type of theme context.
1078
1100
  * @template E The type of theme items managed by the registry.
1079
1101
  * @returns A tuple containing inject, provide functions and the theme context.
1102
+ *
1103
+ * @see https://0.vuetifyjs.com/composables/plugins/use-theme
1080
1104
  */
1081
1105
  function createTheme(namespace = "v0:theme", options = {}) {
1082
1106
  const { themes = {}, palette = {} } = options;
1083
1107
  const [useThemeContext, _provideThemeContext] = createContext(namespace);
1108
+ const tokens = useTokens({
1109
+ palette,
1110
+ ...themes
1111
+ }, { flat: true });
1084
1112
  const registry = useSingle();
1085
1113
  for (const id in themes) {
1114
+ const { colors: value,...theme } = themes[id];
1086
1115
  register({
1087
1116
  id,
1088
- value: themes[id].colors,
1089
- dark: themes[id].dark ?? false,
1090
- lazy: themes[id].lazy ?? false
1117
+ value,
1118
+ ...theme
1091
1119
  });
1092
1120
  if (id === options.default && !registry.selectedId.value) registry.select(id);
1093
1121
  }
@@ -1096,7 +1124,7 @@ function createTheme(namespace = "v0:theme", options = {}) {
1096
1124
  const resolved = {};
1097
1125
  for (const theme of registry.values()) {
1098
1126
  if (theme.lazy && theme.id !== registry.selectedId.value) continue;
1099
- resolved[String(theme.id)] = resolve(theme.id, theme.value);
1127
+ resolved[theme.id] = resolve(theme.value);
1100
1128
  }
1101
1129
  return resolved;
1102
1130
  });
@@ -1105,26 +1133,11 @@ function createTheme(namespace = "v0:theme", options = {}) {
1105
1133
  const next = current === -1 ? 0 : (current + 1) % themes$1.length;
1106
1134
  registry.select(themes$1[next]);
1107
1135
  }
1108
- function resolve(themeId, colors$1) {
1136
+ function resolve(colors$1) {
1109
1137
  const resolved = {};
1110
- for (const [key, value] of Object.entries(colors$1)) resolved[key] = resolveTokenReference(themeId, value);
1138
+ for (const [key, value] of Object.entries(colors$1)) resolved[key] = tokens.isAlias(value) ? tokens.resolve(value) : value;
1111
1139
  return resolved;
1112
1140
  }
1113
- function resolveTokenReference(themeId, value) {
1114
- return value.replace(/{([a-zA-Z0-9.-_]+)}/g, (match, tokenKey) => {
1115
- if (palette[tokenKey]) return isString(palette[tokenKey]) ? palette[tokenKey] : match;
1116
- const [targetTheme, ...colorPath] = tokenKey.split(".");
1117
- const colorKey = colorPath.join(".");
1118
- if (targetTheme && colorKey) {
1119
- const targetColors = themes[targetTheme];
1120
- const resolved$1 = targetColors?.[colorKey];
1121
- return isString(resolved$1) ? resolveTokenReference(targetTheme, resolved$1) : match;
1122
- }
1123
- const currentColors = themes[themeId];
1124
- const resolved = currentColors?.[tokenKey];
1125
- return isString(resolved) ? resolveTokenReference(themeId, resolved) : match;
1126
- });
1127
- }
1128
1141
  function register(registration = {}) {
1129
1142
  const item = {
1130
1143
  lazy: false,
@@ -1148,9 +1161,11 @@ function createTheme(namespace = "v0:theme", options = {}) {
1148
1161
  * Simple hook to access the theme context.
1149
1162
  *
1150
1163
  * @returns The theme context containing current theme state and utilities.
1164
+ *
1165
+ * @see https://0.vuetifyjs.com/composables/plugins/use-theme
1151
1166
  */
1152
1167
  function useTheme() {
1153
- return useContext("v0:theme")();
1168
+ return useContext("v0:theme");
1154
1169
  }
1155
1170
  /**
1156
1171
  * Creates a Vue plugin for theme management with automatic color system updates.
@@ -1160,16 +1175,12 @@ function useTheme() {
1160
1175
  * @param options Configuration for themes, palette, and adapter.
1161
1176
  * @template Z The type of theme context.
1162
1177
  * @template E The type of theme items.
1163
- * @template R The type of token context.
1164
- * @template O The type of token items.
1165
1178
  * @returns A Vue plugin object with install method.
1179
+ *
1180
+ * @see https://0.vuetifyjs.com/composables/plugins/use-theme
1166
1181
  */
1167
1182
  function createThemePlugin(_options = {}) {
1168
1183
  const { adapter = new Vuetify0ThemeAdapter(), palette = {}, themes = {},...options } = _options;
1169
- const [, provideThemeTokenContext, tokensContext] = createTokensContext("v0:theme:tokens", {
1170
- palette,
1171
- ...themes
1172
- });
1173
1184
  const [, provideThemeContext, themeContext] = createTheme("v0:theme", {
1174
1185
  ...options,
1175
1186
  themes,
@@ -1182,7 +1193,6 @@ function createThemePlugin(_options = {}) {
1182
1193
  namespace: "v0:theme",
1183
1194
  provide: (app) => {
1184
1195
  provideThemeContext(themeContext, app);
1185
- provideThemeTokenContext(tokensContext, app);
1186
1196
  },
1187
1197
  setup: () => {
1188
1198
  if (IN_BROWSER) watch(themeContext.colors, update, {
@@ -1195,4 +1205,4 @@ function createThemePlugin(_options = {}) {
1195
1205
  }
1196
1206
 
1197
1207
  //#endregion
1198
- export { ConsolaLoggerAdapter, IN_BROWSER, PinoLoggerAdapter, Vuetify0LoggerAdapter, createBreakpoints, createBreakpointsPlugin, createHydration, createHydrationPlugin, createLogger, createLoggerPlugin, createTheme, createThemePlugin, createTokensContext, provideBreakpointsContext, provideHydrationContext, useBreakpoints, useBreakpointsContext, useGroup, useHydration, useHydrationContext, useLogger, useRegistry, useSelection, useSingle, useStep, useTheme, useTokens };
1208
+ export { ConsolaLoggerAdapter, PinoLoggerAdapter, Vuetify0LoggerAdapter, createBreakpoints, createBreakpointsPlugin, createHydration, createHydrationPlugin, createLogger, createLoggerPlugin, createRegistryContext, createSelectionContext, createSingleContext, createTheme, createThemePlugin, createTokensContext, provideBreakpointsContext, provideHydrationContext, useBreakpoints, useBreakpointsContext, useHydration, useHydrationContext, useLogger, useRegistry, useSelection, useSingle, useTheme, useTokens };