@vuetify/v0 1.0.0-alpha.0 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +5 -1
  2. package/dist/{adapter-T7AedXkz.d.mts → adapter-58IvIfAZ.d.mts} +1 -1
  3. package/dist/{adapter-Drq1v5wV.mjs → adapter-Be9zUc-n.mjs} +6 -3
  4. package/dist/{adapter-CcHB7rs3.d.mts → adapter-BvWEd9w-.d.mts} +2 -2
  5. package/dist/{adapter-BZjmDNJF.d.mts → adapter-DlX3FA3A.d.mts} +2 -2
  6. package/dist/{adapter-CCIeOzqr.mjs → adapter-gQ2SNKZq.mjs} +31 -22
  7. package/dist/{adapters-D49L7m2R.mjs → adapters-BJ5n7rgh.mjs} +1 -1
  8. package/dist/adapters-BnKW0BF_.mjs +2 -0
  9. package/dist/adapters-CBrvizWb.mjs +4 -0
  10. package/dist/adapters-CMJGA1k7.mjs +2 -0
  11. package/dist/adapters-Dse4bPxk.mjs +5 -0
  12. package/dist/browser/index.js +4845 -3272
  13. package/dist/components/index.d.mts +3 -3
  14. package/dist/components/index.mjs +2 -2
  15. package/dist/{components-Dc7sUTsg.mjs → components-CqDewYTU.mjs} +1407 -411
  16. package/dist/composables/index.d.mts +19 -19
  17. package/dist/composables/index.mjs +28 -26
  18. package/dist/{consola-Byg0ybzh.d.mts → consola-BdgyPEfx.d.mts} +1 -1
  19. package/dist/constants/index.d.mts +2 -2
  20. package/dist/constants/index.mjs +3 -3
  21. package/dist/{createDataTable-BbUL9Vva.mjs → createDataTable-rXBqGglI.mjs} +105 -32
  22. package/dist/{createGroup-C2WCfYPB.mjs → createGroup-BU4olYtB.mjs} +29 -14
  23. package/dist/{createPagination-Tp4C4He8.mjs → createPagination-CHF7SmmK.mjs} +11 -7
  24. package/dist/{createTokens-qv02qq4_.mjs → createRegistry-Dl-bSSTr.mjs} +21 -302
  25. package/dist/{createSelection-AmMX6sjc.mjs → createSelection-Csaa-C8p.mjs} +28 -21
  26. package/dist/{createSingle-CffpxK__.mjs → createSingle-8xbHAIpY.mjs} +13 -17
  27. package/dist/createTokens-lNg2M_P_.mjs +302 -0
  28. package/dist/{createTrinity-vvXk0ARD.mjs → createTrinity-BTCs1pYx.mjs} +34 -31
  29. package/dist/data-table/adapters/client/index.d.mts +1 -1
  30. package/dist/data-table/adapters/client/index.mjs +1 -1
  31. package/dist/data-table/adapters/index.d.mts +4 -4
  32. package/dist/data-table/adapters/index.mjs +5 -5
  33. package/dist/data-table/adapters/server/index.d.mts +1 -1
  34. package/dist/data-table/adapters/server/index.mjs +1 -1
  35. package/dist/data-table/adapters/virtual/index.d.mts +1 -1
  36. package/dist/data-table/adapters/virtual/index.mjs +1 -1
  37. package/dist/data-table/index.d.mts +6 -6
  38. package/dist/data-table/index.mjs +6 -6
  39. package/dist/date/index.d.mts +2 -2
  40. package/dist/date/index.mjs +4 -4
  41. package/dist/features/adapters/flagsmith/index.d.mts +1 -1
  42. package/dist/features/adapters/flagsmith/index.mjs +1 -1
  43. package/dist/features/adapters/launchdarkly/index.d.mts +1 -1
  44. package/dist/features/adapters/launchdarkly/index.mjs +1 -1
  45. package/dist/features/adapters/posthog/index.d.mts +1 -1
  46. package/dist/features/adapters/posthog/index.mjs +1 -1
  47. package/dist/features/index.d.mts +2 -2
  48. package/dist/features/index.mjs +1 -1
  49. package/dist/{globals-CAv9vqkP.mjs → globals-CKdzjeLe.mjs} +1 -1
  50. package/dist/htmlElements-D4oMQZPJ.mjs +28 -0
  51. package/dist/{index-M8EpGjjA.d.mts → index-1XdASTjp.d.mts} +1 -1
  52. package/dist/{index-D26_u_WI.d.mts → index-B7cqgTBL.d.mts} +1599 -468
  53. package/dist/{index-DoGxDgdN.d.mts → index-BJGcVy7e.d.mts} +57 -6
  54. package/dist/index-BgCkepP_.d.mts +31 -0
  55. package/dist/{index-B_XLHftL.d.mts → index-BxKMMWnQ.d.mts} +301 -263
  56. package/dist/{index-tyzwWFHS.d.mts → index-BzFHTW59.d.mts} +1 -1
  57. package/dist/{index-CDcl4wPo.d.mts → index-CT5SCLzW.d.mts} +1 -1
  58. package/dist/{index-BUsrN1vL.d.mts → index-DE3bWw11.d.mts} +2 -2
  59. package/dist/{index-76fQGkkO.d.mts → index-DTvqw22G.d.mts} +8 -11
  60. package/dist/{index-F2Fmxnzi.d.mts → index-Dp1HjBxJ.d.mts} +1 -1
  61. package/dist/{index-B_AlCD7t.d.mts → index-DuddF-NR.d.mts} +2 -9
  62. package/dist/{index-Dxx0eMLi.d.mts → index-GOpjKzaJ.d.mts} +1 -1
  63. package/dist/index.d.mts +23 -23
  64. package/dist/index.mjs +31 -29
  65. package/dist/json/attributes.json +280 -4
  66. package/dist/json/importMap.json +60 -0
  67. package/dist/json/tags.json +136 -2
  68. package/dist/json/web-types.json +1186 -347
  69. package/dist/locale/adapters/index.d.mts +2 -2
  70. package/dist/locale/adapters/index.mjs +2 -2
  71. package/dist/locale/adapters/v0/index.d.mts +1 -1
  72. package/dist/locale/adapters/v0/index.mjs +1 -1
  73. package/dist/locale/adapters/vue-i18n/index.d.mts +1 -1
  74. package/dist/locale/index.d.mts +3 -3
  75. package/dist/locale/index.mjs +2 -2
  76. package/dist/logger/adapters/consola/index.d.mts +1 -1
  77. package/dist/logger/adapters/index.d.mts +4 -4
  78. package/dist/logger/adapters/index.mjs +2 -2
  79. package/dist/logger/adapters/pino/index.d.mts +1 -1
  80. package/dist/logger/adapters/v0/index.d.mts +1 -1
  81. package/dist/logger/adapters/v0/index.mjs +1 -1
  82. package/dist/logger/index.d.mts +5 -5
  83. package/dist/logger/index.mjs +2 -2
  84. package/dist/notifications/index.d.mts +2 -2
  85. package/dist/notifications/index.mjs +3 -54
  86. package/dist/palettes/ant/generate/index.mjs +1 -0
  87. package/dist/palettes/ant/index.d.mts +1 -1
  88. package/dist/palettes/index.d.mts +3 -3
  89. package/dist/palettes/leonardo/generate/index.mjs +1 -0
  90. package/dist/palettes/material/generate/index.mjs +1 -0
  91. package/dist/palettes/material/index.d.mts +1 -1
  92. package/dist/palettes/md1/index.d.mts +1 -1
  93. package/dist/palettes/md2/index.d.mts +1 -1
  94. package/dist/palettes/radix/index.d.mts +1 -1
  95. package/dist/palettes/tailwind/index.d.mts +1 -1
  96. package/dist/permissions/adapters/index.d.mts +1 -1
  97. package/dist/permissions/adapters/index.mjs +2 -2
  98. package/dist/permissions/adapters/v0/index.d.mts +1 -1
  99. package/dist/permissions/adapters/v0/index.mjs +1 -1
  100. package/dist/permissions/index.d.mts +1 -1
  101. package/dist/permissions/index.mjs +2 -2
  102. package/dist/{pino-BxddSW2l.d.mts → pino-DNfCEb0p.d.mts} +1 -1
  103. package/dist/{posthog-B8PEtlFr.mjs → posthog-DZNnPXxS.mjs} +1 -1
  104. package/dist/rules/index.d.mts +1 -1
  105. package/dist/rules/index.mjs +1 -1
  106. package/dist/{server-DNUTnISs.d.mts → server-3ilWFwqe.d.mts} +1 -1
  107. package/dist/{server-CIftA0pK.mjs → server-y7zLSCSx.mjs} +1 -1
  108. package/dist/storage/adapters/index.d.mts +2 -2
  109. package/dist/storage/adapters/index.mjs +1 -1
  110. package/dist/storage/adapters/memory/index.d.mts +1 -1
  111. package/dist/storage/adapters/memory/index.mjs +1 -1
  112. package/dist/storage/index.d.mts +3 -3
  113. package/dist/storage/index.mjs +2 -2
  114. package/dist/theme/adapters/index.d.mts +1 -1
  115. package/dist/theme/adapters/index.mjs +4 -4
  116. package/dist/theme/adapters/unhead/index.d.mts +1 -1
  117. package/dist/theme/adapters/unhead/index.mjs +1 -1
  118. package/dist/theme/adapters/v0/index.d.mts +1 -1
  119. package/dist/theme/adapters/v0/index.mjs +1 -1
  120. package/dist/theme/index.d.mts +1 -1
  121. package/dist/theme/index.mjs +3 -3
  122. package/dist/{toArray-doLQVI56.mjs → toArray-as9BWxBK.mjs} +10 -0
  123. package/dist/types/index.d.mts +2 -2
  124. package/dist/{unhead-BYw3a366.mjs → unhead-DZiD-4Tx.mjs} +2 -2
  125. package/dist/{useClickOutside-CnCQkh7M.mjs → useClickOutside-CmCUD_Pf.mjs} +577 -1024
  126. package/dist/{useFeatures-CMpkbU8Q.mjs → useFeatures-ZIvzzuEV.mjs} +16 -6
  127. package/dist/{useLocale-BYmoHpo6.mjs → useLocale-DTJx3aKR.mjs} +19 -7
  128. package/dist/{useLogger-BfaFH-Bi.mjs → useLogger-BBTcMN61.mjs} +33 -16
  129. package/dist/useNotifications-H4knpvNw.mjs +869 -0
  130. package/dist/{usePermissions-y3Uum3nO.mjs → usePermissions-B_G12Dwd.mjs} +14 -6
  131. package/dist/{useRules-eqSXpP9V.mjs → useRules--7Qoo60I.mjs} +15 -5
  132. package/dist/{useTheme-CFH6I91x.mjs → useTheme-Co05TEeD.mjs} +20 -8
  133. package/dist/utilities/index.d.mts +1 -1
  134. package/dist/utilities/index.mjs +14 -9
  135. package/dist/{v0-DXqYgj7J.mjs → v0-BrTEO5sv.mjs} +2 -2
  136. package/dist/{v0-BAG8p0si.d.mts → v0-CdusXjY_.d.mts} +1 -1
  137. package/dist/{v0-CFV8A5PF.mjs → v0-D0Mh3EVG.mjs} +1 -1
  138. package/dist/{v0-BpgPZ1qB.d.mts → v0-D7Fm2C3Y.d.mts} +1 -1
  139. package/dist/{v0-BqikIgl0.mjs → v0-DeiZuexg.mjs} +1 -1
  140. package/dist/{v0-DOq_Ia5H.mjs → v0-Dq3zhexO.mjs} +2 -2
  141. package/dist/{v0-C2UMaHUa.d.mts → v0-DrOub-e1.d.mts} +1 -1
  142. package/dist/{virtual-D1HwNBLS.mjs → virtual-C0yHf1DC.mjs} +2 -2
  143. package/dist/{virtual-BaQWQ9ji.d.mts → virtual-D4fckewC.d.mts} +1 -1
  144. package/package.json +10 -7
  145. package/SKILL.md +0 -95
  146. package/dist/adapters-BOVGPozf.mjs +0 -2
  147. package/dist/adapters-BbNfjyvY.mjs +0 -5
  148. package/dist/adapters-BhNTUuxE.mjs +0 -2
  149. package/dist/adapters-RwNU3wNj.mjs +0 -4
  150. package/dist/htmlElements-DcYtv0hg.mjs +0 -75
  151. package/dist/index-D6mQAEs2.d.mts +0 -79
  152. /package/dist/{adapter-DNKjooxI.d.mts → adapter-Dhq68tz0.d.mts} +0 -0
  153. /package/dist/{flagsmith-DQnnahG5.mjs → flagsmith-Dbh1h8WF.mjs} +0 -0
  154. /package/dist/{index-DxruGeVY.d.mts → index-C6rdXZ7j.d.mts} +0 -0
  155. /package/dist/{index-PWQavSPf.d.mts → index-CFhUdAHM.d.mts} +0 -0
  156. /package/dist/{index-c55Utzva.d.mts → index-CROz1VSV.d.mts} +0 -0
  157. /package/dist/{launchdarkly-2_48EJ1_.mjs → launchdarkly-BKtW-idu.mjs} +0 -0
  158. /package/dist/{memory-DUyWthic.d.mts → memory-CeSQE-QV.d.mts} +0 -0
  159. /package/dist/{memory-XCMtkld1.mjs → memory-oYBvtkgx.mjs} +0 -0
  160. /package/dist/{v0-4OQBCeda.mjs → v0-Bmow1q_x.mjs} +0 -0
@@ -1,6 +1,6 @@
1
- import { clamp, isObject, isString, isUndefined, useId as useId$1 } from "./utilities/index.mjs";
2
- import { i as useContext, n as createContext, t as createTrinity } from "./createTrinity-vvXk0ARD.mjs";
3
- import { i as useLogger } from "./useLogger-BfaFH-Bi.mjs";
1
+ import { clamp, isUndefined, useId as useId$1 } from "./utilities/index.mjs";
2
+ import { i as useContext, t as createTrinity } from "./createTrinity-BTCs1pYx.mjs";
3
+ import { i as useLogger } from "./useLogger-BBTcMN61.mjs";
4
4
  import { shallowReactive } from "vue";
5
5
  //#region src/composables/createRegistry/index.ts
6
6
  /**
@@ -20,6 +20,16 @@ import { shallowReactive } from "vue";
20
20
  *
21
21
  * The registry serves as the base for many other composables in the system,
22
22
  * including createSelection, createForm, createTimeline, and more.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { createRegistry } from '@vuetify/v0'
27
+ *
28
+ * const registry = createRegistry()
29
+ * const ticket = registry.register({ value: 'item-1' })
30
+ * console.log(registry.size) // 1
31
+ * registry.unregister(ticket.id)
32
+ * ```
23
33
  */
24
34
  /**
25
35
  * Creates a new registry instance.
@@ -80,7 +90,9 @@ function createRegistry(options) {
80
90
  return;
81
91
  }
82
92
  if (!listeners.has(event)) listeners.set(event, /* @__PURE__ */ new Set());
83
- listeners.get(event).add(cb);
93
+ const cbs = listeners.get(event);
94
+ cbs.add(cb);
95
+ if (process.env.NODE_ENV !== "production" && cbs.size === 101) logger.warn(`Event "${event}" has ${cbs.size} listeners. Possible memory leak.`);
84
96
  }
85
97
  function off(event, cb) {
86
98
  if (!events) {
@@ -159,6 +171,7 @@ function createRegistry(options) {
159
171
  else catalog.set(value, next);
160
172
  }
161
173
  function keys() {
174
+ if (reactive) return Array.from(collection.keys());
162
175
  const cached = cache.get("keys");
163
176
  if (!/* @__PURE__ */ isUndefined(cached)) return cached;
164
177
  const keys = Array.from(collection.keys());
@@ -166,6 +179,7 @@ function createRegistry(options) {
166
179
  return keys;
167
180
  }
168
181
  function values() {
182
+ if (reactive) return Array.from(collection.values());
169
183
  const cached = cache.get("values");
170
184
  if (!/* @__PURE__ */ isUndefined(cached)) return cached;
171
185
  const values = Array.from(collection.values());
@@ -173,6 +187,7 @@ function createRegistry(options) {
173
187
  return values;
174
188
  }
175
189
  function entries() {
190
+ if (reactive) return Array.from(collection.entries());
176
191
  const cached = cache.get("entries");
177
192
  if (!/* @__PURE__ */ isUndefined(cached)) return cached;
178
193
  const entries = Array.from(collection.entries());
@@ -394,12 +409,7 @@ function createRegistry(options) {
394
409
  */
395
410
  function createRegistryContext(_options = {}) {
396
411
  const { namespace = "v0:registry", ...options } = _options;
397
- const [useRegistryContext, _provideRegistryContext] = createContext(namespace);
398
- const context = createRegistry(options);
399
- function provideRegistryContext(_context = context, app) {
400
- return _provideRegistryContext(_context, app);
401
- }
402
- return createTrinity(useRegistryContext, provideRegistryContext, context);
412
+ return createTrinity(namespace, createRegistry(options));
403
413
  }
404
414
  /**
405
415
  * Uses an existing registry from context.
@@ -425,295 +435,4 @@ function useRegistry(namespace = "v0:registry") {
425
435
  return useContext(namespace);
426
436
  }
427
437
  //#endregion
428
- //#region src/composables/createTokens/index.ts
429
- /**
430
- * @module createTokens
431
- *
432
- * @see https://0.vuetifyjs.com/composables/registration/create-tokens
433
- *
434
- * @remarks
435
- * Design token registry with alias resolution and W3C Design Tokens format support.
436
- *
437
- * Key features:
438
- * - Alias resolution with circular reference detection
439
- * - Nested token flattening with dot notation
440
- * - W3C Design Tokens format ($value, $type, $description, $extensions)
441
- * - Path-based resolution (e.g., {colors}.blue.500)
442
- * - Resolution caching for performance (~28,590 ops/sec)
443
- *
444
- * Used by useTheme, useLocale, and useFeatures for token-based configuration.
445
- */
446
- /**
447
- * Creates a new token instance.
448
- *
449
- * @param tokens The tokens to use.
450
- * @param options The options for the token instance.
451
- * @template Z The type of the token ticket.
452
- * @template E The type of the token context.
453
- * @returns A new token instance.
454
- *
455
- * @see https://www.designtokens.org/tr/drafts/format/
456
- * @see https://0.vuetifyjs.com/composables/registration/create-tokens
457
- *
458
- * @example
459
- * ```ts
460
- * import { createTokens } from '@vuetify/v0'
461
- *
462
- * const tokens = createTokens({
463
- * colors: {
464
- * primary: '#3b82f6',
465
- * secondary: '{colors.primary}', // Alias reference
466
- * },
467
- * })
468
- *
469
- * console.log(tokens.resolve('{colors.primary}')) // '#3b82f6'
470
- * console.log(tokens.resolve('{colors.secondary}')) // '#3b82f6'
471
- * ```
472
- */
473
- function createTokens(tokens = {}, options = {}) {
474
- const logger = useLogger();
475
- const registry = createRegistry(options);
476
- const cache = /* @__PURE__ */ new Map();
477
- registry.onboard(flatten(tokens, options.prefix, !!options.flat));
478
- function isAlias(token) {
479
- return /* @__PURE__ */ isString(token) && token.length > 2 && token[0] === "{" && token.at(-1) === "}";
480
- }
481
- function isTokenAlias(value) {
482
- return /* @__PURE__ */ isObject(value) && "$value" in value;
483
- }
484
- function resolve(token, visited = /* @__PURE__ */ new Set()) {
485
- const cacheKey = /* @__PURE__ */ isString(token) ? token : JSON.stringify(token);
486
- if (cache.has(cacheKey)) return cache.get(cacheKey);
487
- const reference = isTokenAlias(token) ? token.$value : token;
488
- const isAliasReference = /* @__PURE__ */ isString(reference) && isAlias(reference);
489
- const clean = isAliasReference ? reference.slice(1, -1) : String(reference);
490
- if (visited.has(clean)) {
491
- logger.warn(`Circular alias detected for "${clean}"`);
492
- cache.set(cacheKey, void 0);
493
- return;
494
- }
495
- visited.add(clean);
496
- let found = registry.get(clean);
497
- let segments = [];
498
- if (!found && clean.includes(".")) {
499
- const parts = clean.split(".");
500
- for (let i = parts.length - 1; i > 0; i--) {
501
- const prefix = parts.slice(0, i).join(".");
502
- const suffix = parts.slice(i);
503
- const candidate = registry.get(prefix);
504
- if (!/* @__PURE__ */ isUndefined(candidate?.value)) {
505
- found = candidate;
506
- segments = suffix;
507
- break;
508
- }
509
- }
510
- }
511
- if (/* @__PURE__ */ isUndefined(found?.value)) {
512
- if (isAliasReference) logger.warn(`Alias not found for "${String(reference)}"`);
513
- cache.set(cacheKey, void 0);
514
- return;
515
- }
516
- let result;
517
- let current = found.value;
518
- if (segments.length > 0) {
519
- if (isTokenAlias(current)) current = current.$value;
520
- for (const segment of segments) {
521
- if (!/* @__PURE__ */ isObject(current) || !(segment in current)) {
522
- current = void 0;
523
- break;
524
- }
525
- current = current[segment];
526
- if (isTokenAlias(current)) current = current.$value;
527
- }
528
- if (/* @__PURE__ */ isUndefined(current)) {
529
- logger.warn(`Path not found inside "${clean}": ${segments.join(".")}`);
530
- cache.set(cacheKey, void 0);
531
- return;
532
- }
533
- result = current;
534
- } else if (isTokenAlias(current)) {
535
- const inner = current.$value;
536
- if (/* @__PURE__ */ isString(inner) && isAlias(inner)) return resolve(inner, visited);
537
- result = inner;
538
- } else if (/* @__PURE__ */ isString(current) && isAlias(current)) return resolve(current, visited);
539
- else result = current;
540
- cache.set(cacheKey, result);
541
- return result;
542
- }
543
- const { register: _register, upsert: _upsert, unregister: _unregister, onboard: _onboard, offboard: _offboard, move: _move, clear: _clear } = registry;
544
- function register(registration) {
545
- cache.clear();
546
- return _register(registration);
547
- }
548
- function upsert(id, registration) {
549
- cache.clear();
550
- return _upsert(id, registration);
551
- }
552
- function unregister(id) {
553
- cache.clear();
554
- return _unregister(id);
555
- }
556
- function onboard(registrations) {
557
- cache.clear();
558
- return _onboard(registrations);
559
- }
560
- function offboard(ids) {
561
- cache.clear();
562
- return _offboard(ids);
563
- }
564
- function move(id, index) {
565
- cache.clear();
566
- return _move(id, index);
567
- }
568
- function clear() {
569
- cache.clear();
570
- return _clear();
571
- }
572
- return {
573
- ...registry,
574
- register,
575
- upsert,
576
- unregister,
577
- onboard,
578
- offboard,
579
- move,
580
- clear,
581
- resolve,
582
- isAlias,
583
- get size() {
584
- return registry.size;
585
- }
586
- };
587
- }
588
- /**
589
- * Creates a new token context.
590
- *
591
- * @param namespace The namespace for the token context.
592
- * @param tokens The tokens to use.
593
- * @template Z The type of the token ticket.
594
- * @template E The type of the token context.
595
- * @returns A new token context.
596
- *
597
- * @see https://0.vuetifyjs.com/composables/registration/create-tokens
598
- *
599
- * @example
600
- * ```ts
601
- * import { createTokensContext } from '@vuetify/v0'
602
- *
603
- * export const [useTokens, provideTokens, context] = createTokensContext({
604
- * namespace: 'v0:tokens',
605
- * tokens: {
606
- * colors: {
607
- * primary: '#3b82f6',
608
- * secondary: '{colors.primary}', // Alias reference
609
- * },
610
- * },
611
- * })
612
- * ```
613
- */
614
- function createTokensContext(_options) {
615
- const { namespace = "v0:tokens", tokens = {}, ...options } = _options;
616
- const [useTokensContext, _provideTokensContext] = createContext(namespace);
617
- const context = createTokens(tokens, options);
618
- function provideTokensContext(_context = context, app) {
619
- return _provideTokensContext(_context, app);
620
- }
621
- return createTrinity(useTokensContext, provideTokensContext, context);
622
- }
623
- /**
624
- * Returns the current tokens instance.
625
- *
626
- * @param namespace The namespace for the tokens context. Defaults to `'v0:tokens'`.
627
- * @returns The current tokens instance.
628
- *
629
- * @see https://0.vuetifyjs.com/composables/registration/create-tokens
630
- *
631
- * @example
632
- * ```vue
633
- * <script setup lang="ts">
634
- * import { useTokens } from '@vuetify/v0'
635
- *
636
- * const tokens = useTokens()
637
- * <\/script>
638
- * ```
639
- */
640
- function useTokens(namespace = "v0:tokens") {
641
- return useContext(namespace);
642
- }
643
- /**
644
- * Flattens a nested collection of tokens into a flat array of tokens.
645
- * Each token is represented by an object containing its ID & value.
646
- * @param tokens The collection of tokens to flatten.
647
- * @param prefix An optional prefix to prepend to each token ID.
648
- * @returns An array of flattened tokens, each with an ID and value.
649
- */
650
- function flatten(tokens, prefix = "", flat = false) {
651
- const flattened = [];
652
- const stack = [{
653
- tokens,
654
- prefix,
655
- flat
656
- }];
657
- while (stack.length > 0) {
658
- const { tokens: currentTokens, prefix: currentPrefix, flat } = stack.pop();
659
- const meta = {};
660
- for (const k in currentTokens) if (k.startsWith("$")) meta[k] = currentTokens[k];
661
- if (Object.keys(meta).length > 0 && currentPrefix) flattened.push({
662
- id: currentPrefix,
663
- value: meta
664
- });
665
- for (const key in currentTokens) {
666
- if (key.startsWith("$")) continue;
667
- const value = currentTokens[key];
668
- const id = currentPrefix ? `${currentPrefix}.${key}` : key;
669
- if (!/* @__PURE__ */ isObject(value)) {
670
- flattened.push({
671
- id,
672
- value
673
- });
674
- continue;
675
- }
676
- if ("$value" in value) {
677
- flattened.push({
678
- id,
679
- value
680
- });
681
- const inner = value.$value;
682
- if (/* @__PURE__ */ isObject(inner) && !flat) for (const innerKey in inner) {
683
- if (innerKey.startsWith("$")) continue;
684
- const child = inner[innerKey];
685
- const childId = `${id}.${innerKey}`;
686
- if (!/* @__PURE__ */ isObject(child)) flattened.push({
687
- id: childId,
688
- value: child
689
- });
690
- else if ("$value" in child) flattened.push({
691
- id: childId,
692
- value: child
693
- });
694
- else stack.push({
695
- tokens: child,
696
- prefix: childId,
697
- flat
698
- });
699
- }
700
- continue;
701
- }
702
- if (flat) {
703
- flattened.push({
704
- id,
705
- value
706
- });
707
- continue;
708
- }
709
- stack.push({
710
- tokens: value,
711
- prefix: id,
712
- flat
713
- });
714
- }
715
- }
716
- return flattened;
717
- }
718
- //#endregion
719
- export { createRegistry as a, useTokens as i, createTokensContext as n, createRegistryContext as o, flatten as r, useRegistry as s, createTokens as t };
438
+ export { createRegistryContext as n, useRegistry as r, createRegistry as t };
@@ -1,6 +1,6 @@
1
1
  import { isUndefined, resolveIds, useId as useId$1 } from "./utilities/index.mjs";
2
- import { i as useContext, n as createContext, t as createTrinity } from "./createTrinity-vvXk0ARD.mjs";
3
- import { a as createRegistry } from "./createTokens-qv02qq4_.mjs";
2
+ import { i as useContext, t as createTrinity } from "./createTrinity-BTCs1pYx.mjs";
3
+ import { t as createRegistry } from "./createRegistry-Dl-bSSTr.mjs";
4
4
  import { computed, isRef, shallowReactive, toRaw, toRef, toValue } from "vue";
5
5
  //#region src/composables/createModel/index.ts
6
6
  /**
@@ -21,6 +21,15 @@ import { computed, isRef, shallowReactive, toRaw, toRef, toValue } from "vue";
21
21
  * Both Selection and Slider extend this layer:
22
22
  * - createRegistry → createModel → createSelection → createSingle/createGroup/createStep
23
23
  * - createRegistry → createModel → createSlider (values override)
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { createModel } from '@vuetify/v0'
28
+ *
29
+ * const model = createModel({ multiple: false })
30
+ * model.register({ value: 'apple' })
31
+ * model.select(model.values()[0]!.id)
32
+ * ```
24
33
  */
25
34
  /**
26
35
  * Creates a new model instance for storing a single value.
@@ -185,6 +194,16 @@ function createModel(_options = {}) {
185
194
  * - Ticket self-methods: select(), unselect(), toggle()
186
195
  *
187
196
  * Extends createModel and serves as the base for createSingle, createGroup, createStep, and useFeatures.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * import { createSelection } from '@vuetify/v0'
201
+ *
202
+ * const selection = createSelection({ multiple: true })
203
+ * const a = selection.register({ value: 'a' })
204
+ * const b = selection.register({ value: 'b' })
205
+ * selection.select([a.id, b.id])
206
+ * ```
188
207
  */
189
208
  /**
190
209
  * Creates a new selection instance for managing multiple selected items.
@@ -256,6 +275,7 @@ function createSelection(_options = {}) {
256
275
  const { enroll = false, mandatory = false, multiple = false, ...options } = _options;
257
276
  const model = createModel({
258
277
  ...options,
278
+ multiple,
259
279
  enroll: false
260
280
  });
261
281
  function seek(direction = "first", from) {
@@ -264,14 +284,7 @@ function createSelection(_options = {}) {
264
284
  function mandate() {
265
285
  if (!toValue(mandatory) || model.size === 0 || model.selectedIds.size > 0) return;
266
286
  const ticket = seek("first");
267
- if (ticket) select(ticket.id);
268
- }
269
- function select(id) {
270
- if (toValue(model.disabled)) return;
271
- const item = model.get(id);
272
- if (!item || toValue(item.disabled)) return;
273
- if (!toValue(multiple)) model.selectedIds.clear();
274
- model.selectedIds.add(id);
287
+ if (ticket) model.select(ticket.id);
275
288
  }
276
289
  function unselect(id) {
277
290
  if (toValue(model.disabled)) return;
@@ -281,7 +294,7 @@ function createSelection(_options = {}) {
281
294
  function toggle(id) {
282
295
  if (toValue(model.disabled)) return;
283
296
  if (model.selectedIds.has(id)) unselect(id);
284
- else select(id);
297
+ else model.select(id);
285
298
  }
286
299
  function apply(values, options) {
287
300
  const isMultiple = options?.multiple ?? toValue(multiple);
@@ -298,20 +311,20 @@ function createSelection(_options = {}) {
298
311
  const next = targetIds.values().next().value;
299
312
  const last = currentIds.values().next().value;
300
313
  if (!/* @__PURE__ */ isUndefined(last)) unselect(last);
301
- if (!/* @__PURE__ */ isUndefined(next)) select(next);
314
+ if (!/* @__PURE__ */ isUndefined(next)) model.select(next);
302
315
  }
303
316
  }
304
317
  function register(registration = {}) {
305
318
  const id = registration.id ?? /* @__PURE__ */ useId$1();
306
319
  const decorated = {
307
- select: () => select(id),
320
+ select: () => model.select(id),
308
321
  unselect: () => unselect(id),
309
322
  toggle: () => toggle(id),
310
323
  ...registration,
311
324
  id
312
325
  };
313
326
  const ticket = model.register(decorated);
314
- if (toValue(enroll) && !toValue(model.disabled) && !toValue(ticket.disabled)) select(ticket.id);
327
+ if (toValue(enroll) && !toValue(model.disabled) && !toValue(ticket.disabled)) model.select(ticket.id);
315
328
  if (toValue(mandatory) === "force") mandate();
316
329
  return ticket;
317
330
  }
@@ -325,7 +338,6 @@ function createSelection(_options = {}) {
325
338
  multiple,
326
339
  register,
327
340
  onboard,
328
- select,
329
341
  unselect,
330
342
  toggle,
331
343
  apply,
@@ -378,12 +390,7 @@ function createSelection(_options = {}) {
378
390
  */
379
391
  function createSelectionContext(_options = {}) {
380
392
  const { namespace = "v0:selection", ...options } = _options;
381
- const [useSelectionContext, _provideSelectionContext] = createContext(namespace);
382
- const context = createSelection(options);
383
- function provideSelectionContext(_context = context, app) {
384
- return _provideSelectionContext(_context, app);
385
- }
386
- return createTrinity(useSelectionContext, provideSelectionContext, context);
393
+ return createTrinity(namespace, createSelection(options));
387
394
  }
388
395
  /**
389
396
  * Returns the current selection instance.
@@ -1,5 +1,5 @@
1
- import { i as useContext, n as createContext, t as createTrinity } from "./createTrinity-vvXk0ARD.mjs";
2
- import { t as createSelection } from "./createSelection-AmMX6sjc.mjs";
1
+ import { i as useContext, t as createTrinity } from "./createTrinity-BTCs1pYx.mjs";
2
+ import { t as createSelection } from "./createSelection-Csaa-C8p.mjs";
3
3
  import { toRef } from "vue";
4
4
  //#region src/composables/createSingle/index.ts
5
5
  /**
@@ -16,6 +16,16 @@ import { toRef } from "vue";
16
16
  * - Perfect for tabs, radio buttons, theme selectors
17
17
  *
18
18
  * Inheritance chain: createRegistry → createSelection → createSingle
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { createSingle } from '@vuetify/v0'
23
+ *
24
+ * const single = createSingle()
25
+ * const ticket = single.register({ value: 'tab-1' })
26
+ * single.select(ticket.id)
27
+ * console.log(single.selectedValue.value) // 'tab-1'
28
+ * ```
19
29
  */
20
30
  /**
21
31
  * Creates a new single selection instance that enforces only one selected item at a time.
@@ -91,21 +101,12 @@ function createSingle(_options = {}) {
91
101
  const selectedItem = toRef(() => registry.selectedItems.value.values().next().value);
92
102
  const selectedIndex = toRef(() => selectedItem.value?.index ?? -1);
93
103
  const selectedValue = toRef(() => selectedItem.value?.value);
94
- function unselect(id) {
95
- registry.unselect(id);
96
- }
97
- function toggle(id) {
98
- if (registry.selectedIds.has(id)) unselect(id);
99
- else registry.select(id);
100
- }
101
104
  return {
102
105
  ...registry,
103
106
  selectedId,
104
107
  selectedItem,
105
108
  selectedIndex,
106
109
  selectedValue,
107
- unselect,
108
- toggle,
109
110
  get size() {
110
111
  return registry.size;
111
112
  }
@@ -139,12 +140,7 @@ function createSingle(_options = {}) {
139
140
  */
140
141
  function createSingleContext(_options = {}) {
141
142
  const { namespace = "v0:single", ...options } = _options;
142
- const [useSingleContext, _provideSingleContext] = createContext(namespace);
143
- const context = createSingle(options);
144
- function provideSingleContext(_context = context, app) {
145
- return _provideSingleContext(_context, app);
146
- }
147
- return createTrinity(useSingleContext, provideSingleContext, context);
143
+ return createTrinity(namespace, createSingle(options));
148
144
  }
149
145
  /**
150
146
  * Returns the current single selection instance.