@vuetify/v0 1.1.0 → 1.2.0

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 (162) hide show
  1. package/README.md +8 -0
  2. package/dist/{adapter-Butx_2UU.d.mts → adapter-BXunW_mw.d.mts} +1 -1
  3. package/dist/{createPagination-B5dfqY-a.mjs → adapter-BiQV5j8B.mjs} +98 -3
  4. package/dist/adapter-ClB-53_F.d.mts +62 -0
  5. package/dist/{adapter-hq9YlPOF.d.mts → adapter-CqS8xexO.d.mts} +2 -2
  6. package/dist/adapter-CrRJuxRk.mjs +21 -0
  7. package/dist/{adapter-_srNCBEi.d.mts → adapter-PDTe5nFT.d.mts} +6 -7
  8. package/dist/browser/index.d.ts +15101 -12955
  9. package/dist/browser/index.js +16553 -14035
  10. package/dist/components/index.d.mts +2 -2
  11. package/dist/components/index.mjs +2 -2
  12. package/dist/{components-B2BZ1B3K.mjs → components-DBhVg-t1.mjs} +8210 -6301
  13. package/dist/composables/index.d.mts +22 -20
  14. package/dist/composables/index.mjs +37 -34
  15. package/dist/{composables-DONBl_c9.mjs → composables-ZGhVN2EJ.mjs} +32 -1061
  16. package/dist/{consola-BPGkJp_q.d.mts → consola-CdMU53rU.d.mts} +1 -1
  17. package/dist/constants/index.d.mts +1 -1
  18. package/dist/constants/index.mjs +1 -1
  19. package/dist/{createDataTable-DgyHBfAr.mjs → createDataTable-VmQEDn-7.mjs} +23 -7
  20. package/dist/{createGroup-BXKKcb9-.mjs → createGroup-B_LL7xRr.mjs} +2 -2
  21. package/dist/createPlugin-Oo6t-vBw.mjs +157 -0
  22. package/dist/{createRegistry-B9cOWny2.mjs → createRegistry-DVdvep0v.mjs} +1 -1
  23. package/dist/{createSelection-CWE554_g.mjs → createSelection-BNdDz8oY.mjs} +1 -1
  24. package/dist/{createSingle-Dz-1Iv7u.mjs → createSingle-DHyIQ9Cj.mjs} +1 -1
  25. package/dist/{createTokens-C4qcW2Kv.mjs → createTokens-DoISbwd7.mjs} +2 -2
  26. package/dist/data-table/adapters/client/index.d.mts +1 -1
  27. package/dist/data-table/adapters/client/index.mjs +1 -1
  28. package/dist/data-table/adapters/index.d.mts +4 -4
  29. package/dist/data-table/adapters/index.mjs +4 -4
  30. package/dist/data-table/adapters/server/index.d.mts +1 -1
  31. package/dist/data-table/adapters/server/index.mjs +1 -1
  32. package/dist/data-table/adapters/virtual/index.d.mts +1 -1
  33. package/dist/data-table/adapters/virtual/index.mjs +1 -1
  34. package/dist/data-table/index.d.mts +5 -5
  35. package/dist/data-table/index.mjs +5 -5
  36. package/dist/date/index.d.mts +1 -1
  37. package/dist/date/index.mjs +2 -2
  38. package/dist/features/adapters/flagsmith/index.d.mts +1 -1
  39. package/dist/features/adapters/flagsmith/index.mjs +1 -1
  40. package/dist/features/adapters/launchdarkly/index.d.mts +1 -1
  41. package/dist/features/adapters/launchdarkly/index.mjs +1 -1
  42. package/dist/features/adapters/posthog/index.d.mts +1 -1
  43. package/dist/features/adapters/posthog/index.mjs +2 -2
  44. package/dist/features/index.d.mts +2 -2
  45. package/dist/features/index.mjs +2 -2
  46. package/dist/{flagsmith-DA2GCyGv.d.mts → flagsmith-DcIDrI7_.d.mts} +1 -1
  47. package/dist/{globals-CtaXlEOI.mjs → globals-DaoKtIGF.mjs} +1 -1
  48. package/dist/{index-CTl0cGH6.d.mts → index-Cm6CbqI6.d.mts} +7258 -5609
  49. package/dist/{index-Dc7lKT6q.d.mts → index-Cx0cWGlx.d.mts} +461 -130
  50. package/dist/{index-QnpcDsV7.d.mts → index-D0ub61GV.d.mts} +2 -2
  51. package/dist/{index-RGiSdjYt.d.mts → index-DSPkZ0ql.d.mts} +2 -2
  52. package/dist/{index-DCtHbY0a.d.mts → index-Di9e8sOm.d.mts} +24 -19
  53. package/dist/{index-DF0tMI2_.d.mts → index-DjRE4lLl.d.mts} +108 -2
  54. package/dist/index.d.mts +25 -24
  55. package/dist/index.mjs +40 -37
  56. package/dist/json/attributes.json +488 -0
  57. package/dist/json/importMap.json +92 -0
  58. package/dist/json/tags.json +234 -0
  59. package/dist/json/web-types.json +1540 -113
  60. package/dist/{launchdarkly-Bp8p9PMD.d.mts → launchdarkly-CUzunYol.d.mts} +1 -1
  61. package/dist/locale/adapters/index.d.mts +2 -2
  62. package/dist/locale/adapters/index.mjs +2 -2
  63. package/dist/locale/adapters/v0/index.d.mts +1 -1
  64. package/dist/locale/adapters/v0/index.mjs +1 -1
  65. package/dist/locale/adapters/vue-i18n/index.d.mts +1 -1
  66. package/dist/locale/adapters/vue-i18n/index.mjs +1 -1
  67. package/dist/locale/index.d.mts +3 -3
  68. package/dist/locale/index.mjs +3 -3
  69. package/dist/locale/messages/en/index.d.mts +3 -0
  70. package/dist/locale/messages/en/index.mjs +1 -0
  71. package/dist/logger/adapters/consola/index.d.mts +1 -1
  72. package/dist/logger/adapters/index.d.mts +4 -4
  73. package/dist/logger/adapters/index.mjs +1 -1
  74. package/dist/logger/adapters/pino/index.d.mts +1 -1
  75. package/dist/logger/adapters/v0/index.d.mts +1 -1
  76. package/dist/logger/adapters/v0/index.mjs +1 -1
  77. package/dist/logger/index.d.mts +5 -5
  78. package/dist/logger/index.mjs +2 -2
  79. package/dist/notifications/index.d.mts +1 -1
  80. package/dist/notifications/index.mjs +2 -2
  81. package/dist/palettes/ant/index.d.mts +1 -1
  82. package/dist/palettes/index.d.mts +3 -3
  83. package/dist/palettes/material/index.d.mts +1 -1
  84. package/dist/palettes/md1/index.d.mts +1 -1
  85. package/dist/palettes/md2/index.d.mts +1 -1
  86. package/dist/palettes/radix/index.d.mts +1 -1
  87. package/dist/palettes/tailwind/index.d.mts +1 -1
  88. package/dist/permissions/adapters/index.d.mts +1 -1
  89. package/dist/permissions/adapters/index.mjs +1 -1
  90. package/dist/permissions/adapters/v0/index.d.mts +1 -1
  91. package/dist/permissions/adapters/v0/index.mjs +1 -1
  92. package/dist/permissions/index.d.mts +1 -1
  93. package/dist/permissions/index.mjs +2 -2
  94. package/dist/{pino-B6BI1AOK.d.mts → pino-DjeWBFnj.d.mts} +1 -1
  95. package/dist/popover/adapters/floating-ui/index.d.mts +25 -0
  96. package/dist/popover/adapters/floating-ui/index.mjs +98 -0
  97. package/dist/popover/index.d.mts +3 -0
  98. package/dist/popover/index.mjs +3 -0
  99. package/dist/{posthog-sFqk0bGy.d.mts → posthog-CJAYssdr.d.mts} +1 -1
  100. package/dist/rules/index.d.mts +1 -1
  101. package/dist/rules/index.mjs +1 -1
  102. package/dist/{server-DbtTGb67.d.mts → server-5vbJ7GGs.d.mts} +2 -2
  103. package/dist/{server-D5BJBjB0.mjs → server-m7iD1vOr.mjs} +1 -2
  104. package/dist/storage/adapters/index.d.mts +2 -2
  105. package/dist/storage/adapters/index.mjs +1 -1
  106. package/dist/storage/adapters/memory/index.d.mts +1 -1
  107. package/dist/storage/adapters/memory/index.mjs +1 -1
  108. package/dist/storage/index.d.mts +3 -3
  109. package/dist/storage/index.mjs +2 -2
  110. package/dist/theme/adapters/index.d.mts +1 -1
  111. package/dist/theme/adapters/index.mjs +3 -3
  112. package/dist/theme/adapters/unhead/index.d.mts +1 -1
  113. package/dist/theme/adapters/unhead/index.mjs +1 -1
  114. package/dist/theme/adapters/v0/index.d.mts +1 -1
  115. package/dist/theme/adapters/v0/index.mjs +1 -1
  116. package/dist/theme/index.d.mts +2 -2
  117. package/dist/theme/index.mjs +4 -4
  118. package/dist/types/index.d.mts +1 -1
  119. package/dist/{unhead-BAWCwNOF.mjs → unhead-C8zbWr45.mjs} +2 -2
  120. package/dist/{useEventListener-DSOeDtC-.mjs → useEventListener-2eAMwUdw.mjs} +2 -2
  121. package/dist/useFeatures-DLafCOWt.mjs +221 -0
  122. package/dist/{useLocale-D-V0DENN.mjs → useLocale-K_45ulPt.mjs} +4 -4
  123. package/dist/{useLogger-CbvzXCWb.mjs → useLogger-YyWuYvrH.mjs} +5 -159
  124. package/dist/{useNotifications-Cqg3uDz0.mjs → useNotifications-Kh_KvM7j.mjs} +57 -154
  125. package/dist/{usePermissions-BTdUVyQe.mjs → usePermissions-BCGwsOES.mjs} +4 -4
  126. package/dist/usePopover-BTo0AGIQ.mjs +420 -0
  127. package/dist/{useRovingFocus-g6ifibLg.mjs → useRovingFocus-CkRnVmJ1.mjs} +1122 -531
  128. package/dist/{useRules-DEiHd_eY.mjs → useRules-BuE5ffOJ.mjs} +3 -2
  129. package/dist/{useStorage-BSfQfDbg.mjs → useStorage-BT8-mjVs.mjs} +5 -4
  130. package/dist/useTheme-DkK6tPqY.mjs +445 -0
  131. package/dist/useTimer-CGVXk397.mjs +151 -0
  132. package/dist/utilities/index.d.mts +2 -2
  133. package/dist/utilities/index.mjs +181 -2
  134. package/dist/{v0-CveVV6On.mjs → v0-B_53w7Fu.mjs} +2 -2
  135. package/dist/{v0-BnUwMaOv.d.mts → v0-CDW1Ktk-.d.mts} +1 -1
  136. package/dist/{v0-CZBkpQjr.mjs → v0-D0Exc2bO.mjs} +2 -2
  137. package/dist/{v0-rSxMW8FJ.d.mts → v0-DfFK-p4X.d.mts} +1 -1
  138. package/dist/{v0-DotXXGXU.d.mts → v0-GI9U-rPA.d.mts} +2 -2
  139. package/dist/{v0-CCWHeKJM.mjs → v0-SuxTihEe.mjs} +1 -1
  140. package/dist/{v0-A4GLojAr.mjs → v0-yZ2ZUtVF.mjs} +1 -2
  141. package/dist/{virtual-DFvOoeG6.mjs → virtual-Bbu26O_h.mjs} +1 -2
  142. package/dist/{virtual-C-NsLue0.d.mts → virtual-JIdFLpTQ.d.mts} +2 -2
  143. package/package.json +8 -1
  144. package/dist/adapter-CVoWg0sw.mjs +0 -99
  145. package/dist/useFeatures-YJmONiU7.mjs +0 -124
  146. package/dist/useTheme-C0_i__N6.mjs +0 -162
  147. /package/dist/{adapter-CTsckKAR.mjs → adapter-8UADsA3-.mjs} +0 -0
  148. /package/dist/{adapter-BCtceV3b.mjs → adapter-BuSfpxur.mjs} +0 -0
  149. /package/dist/{adapter-Bc0yPSfo.d.mts → adapter-D5nT3bLw.d.mts} +0 -0
  150. /package/dist/{adapter-bwZo7b5p.mjs → adapter-D8zizQVP.mjs} +0 -0
  151. /package/dist/{adapter-q1sRACUc.mjs → adapter-TiGrumDi.mjs} +0 -0
  152. /package/dist/{adapter-BYzU4Ey5.d.mts → adapter-ryk5H6YZ.d.mts} +0 -0
  153. /package/dist/{index-CROz1VSV.d.mts → index-CX869wwk.d.mts} +0 -0
  154. /package/dist/{index-FtE8MXJ_.d.mts → index-CsuikFeJ.d.mts} +0 -0
  155. /package/dist/{index-DidZKN6S.d.mts → index-Djhiy3nS.d.mts} +0 -0
  156. /package/dist/{index-CyNk9FpR.d.mts → index-DtiaWx5U.d.mts} +0 -0
  157. /package/dist/{index-DXMlYoiQ.d.mts → index-H_hl6-4b.d.mts} +0 -0
  158. /package/dist/{index-BgCkepP_.d.mts → index-u_qSc2xS.d.mts} +0 -0
  159. /package/dist/{memory-DbyZeNjg.d.mts → memory-B7z1RR9r.d.mts} +0 -0
  160. /package/dist/{memory-BJjkQzxs.mjs → memory-CR6zvuaP.mjs} +0 -0
  161. /package/dist/{toArray-C89ZaEuF.mjs → toArray-MY9Kb1Qy.mjs} +0 -0
  162. /package/dist/{v0-UNyykD27.mjs → v0-Ch0yBKEj.mjs} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { instanceExists, isFunction, isObject } from "./utilities/index.mjs";
2
- import { i as useLogger, o as createPluginContext } from "./useLogger-CbvzXCWb.mjs";
3
- import { a as useLocale } from "./useLocale-D-V0DENN.mjs";
2
+ import { n as createPluginContext } from "./createPlugin-Oo6t-vBw.mjs";
3
+ import { i as useLogger } from "./useLogger-YyWuYvrH.mjs";
4
+ import { a as useLocale } from "./useLocale-K_45ulPt.mjs";
4
5
  //#region src/composables/useRules/adapters/standard.ts
5
6
  /**
6
7
  * Type guard for Standard Schema objects.
@@ -1,8 +1,9 @@
1
- import { t as IN_BROWSER } from "./globals-CtaXlEOI.mjs";
1
+ import { t as IN_BROWSER } from "./globals-DaoKtIGF.mjs";
2
2
  import { isArray, isNullOrUndefined, isObject } from "./utilities/index.mjs";
3
- import { i as useLogger, o as createPluginContext } from "./useLogger-CbvzXCWb.mjs";
4
- import { r as useWindowEventListener } from "./useEventListener-DSOeDtC-.mjs";
5
- import { t as MemoryStorageAdapter } from "./memory-BJjkQzxs.mjs";
3
+ import { n as createPluginContext } from "./createPlugin-Oo6t-vBw.mjs";
4
+ import { i as useLogger } from "./useLogger-YyWuYvrH.mjs";
5
+ import { r as useWindowEventListener } from "./useEventListener-2eAMwUdw.mjs";
6
+ import { t as MemoryStorageAdapter } from "./memory-CR6zvuaP.mjs";
6
7
  import { ref, watch } from "vue";
7
8
  //#region src/composables/useStorage/index.ts
8
9
  /**
@@ -0,0 +1,445 @@
1
+ import { r as SUPPORTS_MATCH_MEDIA, t as IN_BROWSER } from "./globals-DaoKtIGF.mjs";
2
+ import { foreground, isNumber, isString } from "./utilities/index.mjs";
3
+ import { n as createPluginContext } from "./createPlugin-Oo6t-vBw.mjs";
4
+ import { i as useLogger } from "./useLogger-YyWuYvrH.mjs";
5
+ import { t as createSingle } from "./createSingle-DHyIQ9Cj.mjs";
6
+ import { r as flatten, t as createTokens } from "./createTokens-DoISbwd7.mjs";
7
+ import { t as V0StyleSheetThemeAdapter } from "./v0-B_53w7Fu.mjs";
8
+ import { computed, nextTick, onScopeDispose, shallowReadonly, shallowRef, toRef, toValue, watch } from "vue";
9
+ //#region src/composables/useHydration/index.ts
10
+ /**
11
+ * @module useHydration
12
+ *
13
+ * @see https://0.vuetifyjs.com/composables/plugins/use-hydration
14
+ *
15
+ * @remarks
16
+ * SSR hydration state management composable.
17
+ *
18
+ * Key features:
19
+ * - Hydration state detection (browser vs SSR)
20
+ * - Root component detection
21
+ * - Readonly hydration state refs
22
+ * - Plugin installation support
23
+ * - Perfect for hydration-safe rendering
24
+ *
25
+ * Essential for composables that need to behave differently during SSR vs client-side.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { useHydration } from '@vuetify/v0'
30
+ *
31
+ * const { isHydrated } = useHydration()
32
+ * if (isHydrated.value) {
33
+ * // safe for client-only logic
34
+ * }
35
+ * ```
36
+ */
37
+ /**
38
+ * Creates a new hydration instance.
39
+ *
40
+ * @returns A new hydration instance.
41
+ *
42
+ * @see https://0.vuetifyjs.com/composables/plugins/use-hydration
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { createHydration } from '@vuetify/v0'
47
+ *
48
+ * const hydration = createHydration()
49
+ * console.log(hydration.isHydrated.value) // false
50
+ * hydration.hydrate()
51
+ * console.log(hydration.isHydrated.value) // true
52
+ * ```
53
+ */
54
+ function createHydration() {
55
+ const isHydrated = shallowRef(false);
56
+ const isSettled = shallowRef(false);
57
+ function hydrate() {
58
+ isHydrated.value = true;
59
+ }
60
+ function settle() {
61
+ isSettled.value = true;
62
+ }
63
+ return {
64
+ isHydrated: shallowReadonly(isHydrated),
65
+ isSettled: shallowReadonly(isSettled),
66
+ hydrate,
67
+ settle
68
+ };
69
+ }
70
+ function createFallbackHydration() {
71
+ return {
72
+ isHydrated: shallowReadonly(shallowRef(true)),
73
+ isSettled: shallowReadonly(shallowRef(true)),
74
+ hydrate: () => {},
75
+ settle: () => {}
76
+ };
77
+ }
78
+ /**
79
+ * Creates a new hydration context trinity.
80
+ *
81
+ * @param options Options for creating the hydration context.
82
+ * @template E The type of the hydration context.
83
+ * @returns A new hydration context trinity.
84
+ *
85
+ * @see https://0.vuetifyjs.com/composables/plugins/use-hydration
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * import { createHydrationContext } from '@vuetify/v0'
90
+ *
91
+ * export const [useHydrationContext, provideHydrationContext, context] = createHydrationContext({
92
+ * namespace: 'app:hydration',
93
+ * })
94
+ * ```
95
+ */
96
+ const [createHydrationContext, createHydrationPlugin, useHydration] = createPluginContext("v0:hydration", () => createHydration(), {
97
+ fallback: () => createFallbackHydration(),
98
+ setup: (context, app) => {
99
+ const { mount } = app;
100
+ app.mount = (...args) => {
101
+ const vm = mount(...args);
102
+ nextTick().then(() => {
103
+ context.hydrate();
104
+ nextTick().then(() => context.settle());
105
+ });
106
+ app.mount = mount;
107
+ return vm;
108
+ };
109
+ }
110
+ });
111
+ //#endregion
112
+ //#region src/composables/useMediaQuery/index.ts
113
+ /**
114
+ * @module useMediaQuery
115
+ *
116
+ * @see https://0.vuetifyjs.com/composables/system/use-media-query
117
+ *
118
+ * @remarks
119
+ * Reactive media query composable with automatic cleanup.
120
+ *
121
+ * Key features:
122
+ * - Synchronous matchMedia read on client mount (prevents FOUC)
123
+ * - Window matchMedia integration
124
+ * - Reactive query string support
125
+ * - SSR-safe (returns false on server)
126
+ * - Hydration-aware (defers client updates until hydrated)
127
+ * - Automatic listener cleanup on scope disposal
128
+ * - Supports both static and dynamic queries
129
+ *
130
+ * Perfect for responsive conditionals beyond breakpoint detection.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * import { useMediaQuery } from '@vuetify/v0'
135
+ *
136
+ * const { matches } = useMediaQuery('(prefers-color-scheme: dark)')
137
+ * console.log(matches.value) // true/false
138
+ * ```
139
+ */
140
+ /**
141
+ * Reactive media query matching.
142
+ *
143
+ * @param query CSS media query string (reactive).
144
+ * @returns The media query context.
145
+ *
146
+ * @see https://0.vuetifyjs.com/composables/system/use-media-query
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * // Static query
151
+ * const { matches } = useMediaQuery('(prefers-color-scheme: dark)')
152
+ *
153
+ * // Dynamic query
154
+ * const minWidth = ref(768)
155
+ * const { matches } = useMediaQuery(() => `(min-width: ${minWidth.value}px)`)
156
+ *
157
+ * // Manual cleanup
158
+ * const { matches, stop } = useMediaQuery('(hover: hover)')
159
+ * stop() // Remove listener early
160
+ * ```
161
+ */
162
+ function useMediaQuery(query) {
163
+ const resolvedQuery = toRef(() => toValue(query));
164
+ const initialQuery = toValue(query);
165
+ const initialMql = IN_BROWSER && SUPPORTS_MATCH_MEDIA ? window.matchMedia(initialQuery) : null;
166
+ const matches = shallowRef(initialMql?.matches ?? false);
167
+ const mediaQueryList = shallowRef(initialMql);
168
+ const hydration = useHydration();
169
+ let cleanup = null;
170
+ function listen() {
171
+ if (!IN_BROWSER || !SUPPORTS_MATCH_MEDIA) return;
172
+ cleanup?.();
173
+ cleanup = null;
174
+ const mql = window.matchMedia(resolvedQuery.value);
175
+ mediaQueryList.value = mql;
176
+ matches.value = mql.matches;
177
+ function handler(e) {
178
+ matches.value = e.matches;
179
+ }
180
+ mql.addEventListener("change", handler);
181
+ cleanup = () => mql.removeEventListener("change", handler);
182
+ }
183
+ const stopWatch = watch([resolvedQuery, () => hydration.isHydrated.value], ([_, hydrated]) => {
184
+ if (hydrated) listen();
185
+ }, { immediate: true });
186
+ function stop() {
187
+ stopWatch();
188
+ cleanup?.();
189
+ cleanup = null;
190
+ }
191
+ onScopeDispose(stop, true);
192
+ return {
193
+ matches: shallowReadonly(matches),
194
+ query: resolvedQuery,
195
+ mediaQueryList: shallowReadonly(mediaQueryList),
196
+ stop
197
+ };
198
+ }
199
+ /**
200
+ * Check if the user prefers dark color scheme.
201
+ *
202
+ * @returns The media query context.
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * const { matches: prefersDark } = usePrefersDark()
207
+ * ```
208
+ */
209
+ function usePrefersDark() {
210
+ return useMediaQuery("(prefers-color-scheme: dark)");
211
+ }
212
+ /**
213
+ * Check if the user prefers reduced motion.
214
+ *
215
+ * @returns The media query context.
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * const { matches: prefersReducedMotion } = usePrefersReducedMotion()
220
+ * ```
221
+ */
222
+ function usePrefersReducedMotion() {
223
+ return useMediaQuery("(prefers-reduced-motion: reduce)");
224
+ }
225
+ /**
226
+ * Check if the user prefers more contrast.
227
+ *
228
+ * @returns The media query context.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * const { matches: prefersContrast } = usePrefersContrast()
233
+ * ```
234
+ */
235
+ function usePrefersContrast() {
236
+ return useMediaQuery("(prefers-contrast: more)");
237
+ }
238
+ //#endregion
239
+ //#region src/composables/useTheme/index.ts
240
+ /**
241
+ * @module useTheme
242
+ *
243
+ * @see https://0.vuetifyjs.com/composables/plugins/use-theme
244
+ *
245
+ * @remarks
246
+ * Theme management composable with token resolution and CSS variable injection.
247
+ *
248
+ * Key features:
249
+ * - Single-selection theme switching (extends createSingle)
250
+ * - Token alias resolution via createTokens
251
+ * - Lazy theme loading (compute colors only when selected)
252
+ * - CSS variable generation via adapter pattern
253
+ * - `isDark` reactive flag on the theme context
254
+ * - Optional `system` pair that follows `prefers-color-scheme` until an explicit `select`
255
+ * - SSR support with head integration
256
+ * - Theme cycling
257
+ *
258
+ * Integrates with createSingle for selection and createTokens for color resolution.
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * import { useTheme } from '@vuetify/v0'
263
+ *
264
+ * const theme = useTheme()
265
+ * theme.select('dark')
266
+ * console.log(theme.isDark.value) // true
267
+ * ```
268
+ */
269
+ /**
270
+ * Creates a new theme instance.
271
+ *
272
+ * @param options The options for the theme instance.
273
+ * @returns A new theme instance.
274
+ *
275
+ * @see https://0.vuetifyjs.com/composables/plugins/use-theme
276
+ *
277
+ * @example
278
+ * ```ts
279
+ * import { createTheme } from '@vuetify/v0'
280
+ *
281
+ * const theme = createTheme({
282
+ * default: 'light',
283
+ * themes: {
284
+ * light: {
285
+ * dark: false,
286
+ * colors: {
287
+ * primary: '#3b82f6',
288
+ * },
289
+ * },
290
+ * dark: {
291
+ * dark: true,
292
+ * colors: {
293
+ * primary: '#675496',
294
+ * },
295
+ * },
296
+ * },
297
+ * })
298
+ * ```
299
+ */
300
+ function createTheme(_options = {}) {
301
+ const { themes = {}, palette = {}, foreground: genForeground, system, ...options } = _options;
302
+ const tokens = createTokens({
303
+ palette,
304
+ ...themes
305
+ }, { flat: true });
306
+ const registry = createSingle({
307
+ ...options,
308
+ reactive: true
309
+ });
310
+ const logger = useLogger();
311
+ for (const id in themes) {
312
+ const { colors: value, ...theme } = themes[id];
313
+ register({
314
+ id,
315
+ value,
316
+ ...theme
317
+ });
318
+ }
319
+ const pair = resolveSystemPair(system, registry, logger);
320
+ const following = shallowRef(Boolean(pair));
321
+ if (!pair && options.default && !registry.selectedId.value) registry.select(options.default);
322
+ const names = toRef(() => registry.keys());
323
+ const colors = computed(() => {
324
+ const resolved = {};
325
+ const currentId = registry.selectedId.value;
326
+ for (const theme of registry.values()) {
327
+ if (theme.lazy && theme.id !== currentId) continue;
328
+ const themeColors = resolve(theme.value);
329
+ if (genForeground) for (const [key, value] of Object.entries(themeColors)) {
330
+ const onKey = `on-${key}`;
331
+ if (!key.startsWith("on-") && !(onKey in themeColors)) themeColors[onKey] = /* @__PURE__ */ foreground(value);
332
+ }
333
+ resolved[theme.id] = themeColors;
334
+ }
335
+ return resolved;
336
+ });
337
+ const isDark = toRef(() => registry.selectedItem.value?.dark ?? false);
338
+ const isSystem = toRef(() => following.value);
339
+ const media = pair ? usePrefersDark() : void 0;
340
+ function follow() {
341
+ if (!pair || !media) return;
342
+ const id = media.matches.value ? pair.dark : pair.light;
343
+ if (registry.has(id)) registry.select(id);
344
+ }
345
+ if (pair) {
346
+ if (IN_BROWSER) follow();
347
+ else if (options.default && !registry.selectedId.value) registry.select(options.default);
348
+ watch(() => media.matches.value, () => {
349
+ if (following.value) follow();
350
+ });
351
+ }
352
+ function select(id) {
353
+ following.value = false;
354
+ registry.select(id);
355
+ }
356
+ function reset() {
357
+ if (pair) {
358
+ following.value = true;
359
+ follow();
360
+ return;
361
+ }
362
+ if (options.default) registry.select(options.default);
363
+ }
364
+ function cycle(themes = names.value) {
365
+ const current = themes.indexOf(registry.selectedId.value ?? "");
366
+ select(themes[current === -1 ? 0 : (current + 1) % themes.length]);
367
+ }
368
+ function resolve(colors) {
369
+ const resolved = {};
370
+ for (const [key, value] of Object.entries(colors)) resolved[key] = tokens.isAlias(value) ? tokens.resolve(value) : value;
371
+ return resolved;
372
+ }
373
+ function register(registration = {}) {
374
+ const { colors, ...rest } = registration;
375
+ if (colors && rest.id && !registry.has(rest.id)) tokens.onboard(/* @__PURE__ */ flatten({ [rest.id]: { colors } }, "", true));
376
+ const item = {
377
+ lazy: false,
378
+ dark: false,
379
+ ...rest,
380
+ ...colors ? { value: colors } : {}
381
+ };
382
+ return registry.register(item);
383
+ }
384
+ function onboard(registrations) {
385
+ return registry.batch(() => registrations.map((registration) => register(registration)));
386
+ }
387
+ return {
388
+ ...registry,
389
+ colors,
390
+ isDark,
391
+ isSystem,
392
+ select,
393
+ reset,
394
+ register,
395
+ onboard,
396
+ cycle,
397
+ dispose: () => {
398
+ media?.stop();
399
+ },
400
+ get size() {
401
+ return registry.size;
402
+ }
403
+ };
404
+ }
405
+ function resolveSystemPair(system, registry, logger) {
406
+ if (!system) return void 0;
407
+ const light = registry.get(system.light);
408
+ const dark = registry.get(system.dark);
409
+ if (!light) {
410
+ logger.warn(`[v0:theme] system.light "${String(system.light)}" is not registered`);
411
+ return;
412
+ }
413
+ if (!dark) {
414
+ logger.warn(`[v0:theme] system.dark "${String(system.dark)}" is not registered`);
415
+ return;
416
+ }
417
+ if (!dark.dark) logger.warn(`[v0:theme] system.dark "${String(system.dark)}" should have dark: true`);
418
+ return system;
419
+ }
420
+ function createThemeFallback() {
421
+ return {
422
+ size: 0,
423
+ colors: computed(() => ({})),
424
+ isDark: shallowRef(false),
425
+ isSystem: shallowRef(false),
426
+ cycle: () => {},
427
+ reset: () => {},
428
+ onboard: () => [],
429
+ dispose: () => {}
430
+ };
431
+ }
432
+ const [createThemeContext, createThemePlugin, useTheme] = createPluginContext("v0:theme", (options) => createTheme(options), {
433
+ fallback: () => createThemeFallback(),
434
+ setup: (context, app, { adapter = new V0StyleSheetThemeAdapter(), target, rgb }) => {
435
+ if (rgb) adapter.rgb = true;
436
+ adapter.setup(app, context, target);
437
+ app.onUnmount(() => adapter.dispose?.());
438
+ },
439
+ persist: (ctx) => ctx.isSystem.value ? null : ctx.selectedId.value,
440
+ restore: (ctx, saved) => {
441
+ if (/* @__PURE__ */ isString(saved) || /* @__PURE__ */ isNumber(saved)) ctx.select(saved);
442
+ }
443
+ });
444
+ //#endregion
445
+ export { useMediaQuery as a, usePrefersReducedMotion as c, createHydrationContext as d, createHydrationPlugin as f, useTheme as i, createFallbackHydration as l, createThemeContext as n, usePrefersContrast as o, useHydration as p, createThemePlugin as r, usePrefersDark as s, createTheme as t, createHydration as u };
@@ -0,0 +1,151 @@
1
+ import { t as IN_BROWSER } from "./globals-DaoKtIGF.mjs";
2
+ import { isUndefined } from "./utilities/index.mjs";
3
+ import { onScopeDispose, shallowRef, toValue } from "vue";
4
+ //#region src/composables/useTimer/index.ts
5
+ /**
6
+ * @module useTimer
7
+ *
8
+ * @see https://0.vuetifyjs.com/composables/system/use-timer
9
+ *
10
+ * @remarks
11
+ * A reactive timer composable with pause/resume support.
12
+ *
13
+ * Key features:
14
+ * - Start/stop/pause/resume controls
15
+ * - Reactive remaining time tracking
16
+ * - Reactive `duration` via `MaybeRefOrGetter` — read fresh on each `start()`
17
+ * - One-shot (default) or repeating mode
18
+ * - Automatic cleanup on scope disposal
19
+ * - SSR-safe
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { useTimer } from '@vuetify/v0'
24
+ *
25
+ * const timer = useTimer(() => console.log('fired'), { duration: 5000 })
26
+ * timer.start()
27
+ * ```
28
+ */
29
+ /**
30
+ * Creates a reactive timer with pause/resume support.
31
+ *
32
+ * @param handler Callback invoked when the timer fires.
33
+ * @param options Timer configuration.
34
+ * @returns Timer controls and reactive state.
35
+ *
36
+ * @see https://0.vuetifyjs.com/composables/system/use-timer
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const timer = useTimer(() => console.log('fired'), { duration: 5000 })
41
+ *
42
+ * timer.start()
43
+ * timer.pause()
44
+ * timer.resume()
45
+ * timer.stop()
46
+ *
47
+ * // Reactive duration — re-read on each start()
48
+ * const duration = shallowRef(1000)
49
+ * const reactive = useTimer(handler, { duration })
50
+ * duration.value = 2000
51
+ * reactive.start() // fires after 2000ms
52
+ * ```
53
+ */
54
+ function useTimer(handler, options = {}) {
55
+ const { duration = 1e3, repeat = false } = options;
56
+ function resolveDuration() {
57
+ return toValue(duration);
58
+ }
59
+ const remaining = shallowRef(resolveDuration());
60
+ const isActive = shallowRef(false);
61
+ const isPaused = shallowRef(false);
62
+ let timeoutId;
63
+ let trackingId;
64
+ let startedAt = 0;
65
+ let budget = remaining.value;
66
+ function clearTimer() {
67
+ if (!/* @__PURE__ */ isUndefined(timeoutId)) {
68
+ globalThis.clearTimeout(timeoutId);
69
+ timeoutId = void 0;
70
+ }
71
+ }
72
+ function startTracking() {
73
+ stopTracking();
74
+ if (!IN_BROWSER) return;
75
+ trackingId = globalThis.setInterval(() => {
76
+ if (!isActive.value || isPaused.value) return;
77
+ const elapsed = Date.now() - startedAt;
78
+ remaining.value = Math.max(0, budget - elapsed);
79
+ }, 100);
80
+ }
81
+ function stopTracking() {
82
+ if (!/* @__PURE__ */ isUndefined(trackingId)) {
83
+ globalThis.clearInterval(trackingId);
84
+ trackingId = void 0;
85
+ }
86
+ }
87
+ function fire() {
88
+ clearTimer();
89
+ stopTracking();
90
+ handler();
91
+ if (repeat) begin(resolveDuration());
92
+ else {
93
+ isActive.value = false;
94
+ remaining.value = 0;
95
+ }
96
+ }
97
+ function begin(ms) {
98
+ clearTimer();
99
+ stopTracking();
100
+ budget = ms;
101
+ startedAt = Date.now();
102
+ remaining.value = ms;
103
+ isActive.value = true;
104
+ isPaused.value = false;
105
+ timeoutId = globalThis.setTimeout(fire, ms);
106
+ startTracking();
107
+ }
108
+ function start() {
109
+ const ms = resolveDuration();
110
+ if (ms < 0) return;
111
+ begin(ms);
112
+ }
113
+ function stop() {
114
+ clearTimer();
115
+ stopTracking();
116
+ isActive.value = false;
117
+ isPaused.value = false;
118
+ remaining.value = resolveDuration();
119
+ }
120
+ function pause() {
121
+ if (!isActive.value || isPaused.value) return;
122
+ const elapsed = Date.now() - startedAt;
123
+ budget = Math.max(0, budget - elapsed);
124
+ remaining.value = budget;
125
+ clearTimer();
126
+ stopTracking();
127
+ isPaused.value = true;
128
+ }
129
+ function resume() {
130
+ if (!isPaused.value) return;
131
+ isPaused.value = false;
132
+ startedAt = Date.now();
133
+ timeoutId = globalThis.setTimeout(fire, budget);
134
+ startTracking();
135
+ }
136
+ onScopeDispose(() => {
137
+ clearTimer();
138
+ stopTracking();
139
+ }, true);
140
+ return {
141
+ start,
142
+ stop,
143
+ pause,
144
+ resume,
145
+ remaining,
146
+ isActive,
147
+ isPaused
148
+ };
149
+ }
150
+ //#endregion
151
+ export { useTimer as t };
@@ -1,2 +1,2 @@
1
- import { A as rgbToHex, C as useId, D as foreground, E as apca, O as RGB, S as resolveIndexes, T as isV0Error, _ as isThenable, a as isArray, b as range, c as isFunction, d as isNullOrUndefined, f as isNumber, g as isSymbol, h as isString, i as clamp, k as hexToRgb, l as isNaN, m as isPrimitive, n as instanceName, o as isBoolean, p as isObject, r as UNSAFE_KEYS, s as isElement, t as instanceExists, u as isNull, v as isUndefined, w as V0Error, x as resolveIds, y as mergeDeep } from "../index-DF0tMI2_.mjs";
2
- export { RGB, UNSAFE_KEYS, V0Error, apca, clamp, foreground, hexToRgb, instanceExists, instanceName, isArray, isBoolean, isElement, isFunction, isNaN, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isString, isSymbol, isThenable, isUndefined, isV0Error, mergeDeep, range, resolveIds, resolveIndexes, rgbToHex, useId };
1
+ import { A as MatchRange, C as resolveIds, D as isV0Error, E as V0Error, F as hexToRgb, I as rgbToHex, M as apca, N as foreground, O as FindMatchRangesOptions, P as RGB, S as range, T as useId, _ as isSymbol, a as getActiveElement, b as mergeDeep, c as isElement, d as isNull, f as isNullOrUndefined, g as isString, h as isPrimitive, i as clamp, j as findMatchRanges, k as IgnoreAccents, l as isFunction, m as isObject, n as instanceName, o as isArray, p as isNumber, r as UNSAFE_KEYS, s as isBoolean, t as instanceExists, u as isNaN, v as isThenable, w as resolveIndexes, x as pxToNumber, y as isUndefined } from "../index-DjRE4lLl.mjs";
2
+ export { FindMatchRangesOptions, IgnoreAccents, MatchRange, RGB, UNSAFE_KEYS, V0Error, apca, clamp, findMatchRanges, foreground, getActiveElement, hexToRgb, instanceExists, instanceName, isArray, isBoolean, isElement, isFunction, isNaN, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isString, isSymbol, isThenable, isUndefined, isV0Error, mergeDeep, pxToNumber, range, resolveIds, resolveIndexes, rgbToHex, useId };