@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.
- package/README.md +5 -1
- package/dist/{adapter-T7AedXkz.d.mts → adapter-58IvIfAZ.d.mts} +1 -1
- package/dist/{adapter-Drq1v5wV.mjs → adapter-Be9zUc-n.mjs} +6 -3
- package/dist/{adapter-CcHB7rs3.d.mts → adapter-BvWEd9w-.d.mts} +2 -2
- package/dist/{adapter-BZjmDNJF.d.mts → adapter-DlX3FA3A.d.mts} +2 -2
- package/dist/{adapter-CCIeOzqr.mjs → adapter-gQ2SNKZq.mjs} +31 -22
- package/dist/{adapters-D49L7m2R.mjs → adapters-BJ5n7rgh.mjs} +1 -1
- package/dist/adapters-BnKW0BF_.mjs +2 -0
- package/dist/adapters-CBrvizWb.mjs +4 -0
- package/dist/adapters-CMJGA1k7.mjs +2 -0
- package/dist/adapters-Dse4bPxk.mjs +5 -0
- package/dist/browser/index.js +4845 -3272
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.mjs +2 -2
- package/dist/{components-Dc7sUTsg.mjs → components-CqDewYTU.mjs} +1407 -411
- package/dist/composables/index.d.mts +19 -19
- package/dist/composables/index.mjs +28 -26
- package/dist/{consola-Byg0ybzh.d.mts → consola-BdgyPEfx.d.mts} +1 -1
- package/dist/constants/index.d.mts +2 -2
- package/dist/constants/index.mjs +3 -3
- package/dist/{createDataTable-BbUL9Vva.mjs → createDataTable-rXBqGglI.mjs} +105 -32
- package/dist/{createGroup-C2WCfYPB.mjs → createGroup-BU4olYtB.mjs} +29 -14
- package/dist/{createPagination-Tp4C4He8.mjs → createPagination-CHF7SmmK.mjs} +11 -7
- package/dist/{createTokens-qv02qq4_.mjs → createRegistry-Dl-bSSTr.mjs} +21 -302
- package/dist/{createSelection-AmMX6sjc.mjs → createSelection-Csaa-C8p.mjs} +28 -21
- package/dist/{createSingle-CffpxK__.mjs → createSingle-8xbHAIpY.mjs} +13 -17
- package/dist/createTokens-lNg2M_P_.mjs +302 -0
- package/dist/{createTrinity-vvXk0ARD.mjs → createTrinity-BTCs1pYx.mjs} +34 -31
- package/dist/data-table/adapters/client/index.d.mts +1 -1
- package/dist/data-table/adapters/client/index.mjs +1 -1
- package/dist/data-table/adapters/index.d.mts +4 -4
- package/dist/data-table/adapters/index.mjs +5 -5
- package/dist/data-table/adapters/server/index.d.mts +1 -1
- package/dist/data-table/adapters/server/index.mjs +1 -1
- package/dist/data-table/adapters/virtual/index.d.mts +1 -1
- package/dist/data-table/adapters/virtual/index.mjs +1 -1
- package/dist/data-table/index.d.mts +6 -6
- package/dist/data-table/index.mjs +6 -6
- package/dist/date/index.d.mts +2 -2
- package/dist/date/index.mjs +4 -4
- package/dist/features/adapters/flagsmith/index.d.mts +1 -1
- package/dist/features/adapters/flagsmith/index.mjs +1 -1
- package/dist/features/adapters/launchdarkly/index.d.mts +1 -1
- package/dist/features/adapters/launchdarkly/index.mjs +1 -1
- package/dist/features/adapters/posthog/index.d.mts +1 -1
- package/dist/features/adapters/posthog/index.mjs +1 -1
- package/dist/features/index.d.mts +2 -2
- package/dist/features/index.mjs +1 -1
- package/dist/{globals-CAv9vqkP.mjs → globals-CKdzjeLe.mjs} +1 -1
- package/dist/htmlElements-D4oMQZPJ.mjs +28 -0
- package/dist/{index-M8EpGjjA.d.mts → index-1XdASTjp.d.mts} +1 -1
- package/dist/{index-D26_u_WI.d.mts → index-B7cqgTBL.d.mts} +1599 -468
- package/dist/{index-DoGxDgdN.d.mts → index-BJGcVy7e.d.mts} +57 -6
- package/dist/index-BgCkepP_.d.mts +31 -0
- package/dist/{index-B_XLHftL.d.mts → index-BxKMMWnQ.d.mts} +301 -263
- package/dist/{index-tyzwWFHS.d.mts → index-BzFHTW59.d.mts} +1 -1
- package/dist/{index-CDcl4wPo.d.mts → index-CT5SCLzW.d.mts} +1 -1
- package/dist/{index-BUsrN1vL.d.mts → index-DE3bWw11.d.mts} +2 -2
- package/dist/{index-76fQGkkO.d.mts → index-DTvqw22G.d.mts} +8 -11
- package/dist/{index-F2Fmxnzi.d.mts → index-Dp1HjBxJ.d.mts} +1 -1
- package/dist/{index-B_AlCD7t.d.mts → index-DuddF-NR.d.mts} +2 -9
- package/dist/{index-Dxx0eMLi.d.mts → index-GOpjKzaJ.d.mts} +1 -1
- package/dist/index.d.mts +23 -23
- package/dist/index.mjs +31 -29
- package/dist/json/attributes.json +280 -4
- package/dist/json/importMap.json +60 -0
- package/dist/json/tags.json +136 -2
- package/dist/json/web-types.json +1186 -347
- package/dist/locale/adapters/index.d.mts +2 -2
- package/dist/locale/adapters/index.mjs +2 -2
- package/dist/locale/adapters/v0/index.d.mts +1 -1
- package/dist/locale/adapters/v0/index.mjs +1 -1
- package/dist/locale/adapters/vue-i18n/index.d.mts +1 -1
- package/dist/locale/index.d.mts +3 -3
- package/dist/locale/index.mjs +2 -2
- package/dist/logger/adapters/consola/index.d.mts +1 -1
- package/dist/logger/adapters/index.d.mts +4 -4
- package/dist/logger/adapters/index.mjs +2 -2
- package/dist/logger/adapters/pino/index.d.mts +1 -1
- package/dist/logger/adapters/v0/index.d.mts +1 -1
- package/dist/logger/adapters/v0/index.mjs +1 -1
- package/dist/logger/index.d.mts +5 -5
- package/dist/logger/index.mjs +2 -2
- package/dist/notifications/index.d.mts +2 -2
- package/dist/notifications/index.mjs +3 -54
- package/dist/palettes/ant/generate/index.mjs +1 -0
- package/dist/palettes/ant/index.d.mts +1 -1
- package/dist/palettes/index.d.mts +3 -3
- package/dist/palettes/leonardo/generate/index.mjs +1 -0
- package/dist/palettes/material/generate/index.mjs +1 -0
- package/dist/palettes/material/index.d.mts +1 -1
- package/dist/palettes/md1/index.d.mts +1 -1
- package/dist/palettes/md2/index.d.mts +1 -1
- package/dist/palettes/radix/index.d.mts +1 -1
- package/dist/palettes/tailwind/index.d.mts +1 -1
- package/dist/permissions/adapters/index.d.mts +1 -1
- package/dist/permissions/adapters/index.mjs +2 -2
- package/dist/permissions/adapters/v0/index.d.mts +1 -1
- package/dist/permissions/adapters/v0/index.mjs +1 -1
- package/dist/permissions/index.d.mts +1 -1
- package/dist/permissions/index.mjs +2 -2
- package/dist/{pino-BxddSW2l.d.mts → pino-DNfCEb0p.d.mts} +1 -1
- package/dist/{posthog-B8PEtlFr.mjs → posthog-DZNnPXxS.mjs} +1 -1
- package/dist/rules/index.d.mts +1 -1
- package/dist/rules/index.mjs +1 -1
- package/dist/{server-DNUTnISs.d.mts → server-3ilWFwqe.d.mts} +1 -1
- package/dist/{server-CIftA0pK.mjs → server-y7zLSCSx.mjs} +1 -1
- package/dist/storage/adapters/index.d.mts +2 -2
- package/dist/storage/adapters/index.mjs +1 -1
- package/dist/storage/adapters/memory/index.d.mts +1 -1
- package/dist/storage/adapters/memory/index.mjs +1 -1
- package/dist/storage/index.d.mts +3 -3
- package/dist/storage/index.mjs +2 -2
- package/dist/theme/adapters/index.d.mts +1 -1
- package/dist/theme/adapters/index.mjs +4 -4
- package/dist/theme/adapters/unhead/index.d.mts +1 -1
- package/dist/theme/adapters/unhead/index.mjs +1 -1
- package/dist/theme/adapters/v0/index.d.mts +1 -1
- package/dist/theme/adapters/v0/index.mjs +1 -1
- package/dist/theme/index.d.mts +1 -1
- package/dist/theme/index.mjs +3 -3
- package/dist/{toArray-doLQVI56.mjs → toArray-as9BWxBK.mjs} +10 -0
- package/dist/types/index.d.mts +2 -2
- package/dist/{unhead-BYw3a366.mjs → unhead-DZiD-4Tx.mjs} +2 -2
- package/dist/{useClickOutside-CnCQkh7M.mjs → useClickOutside-CmCUD_Pf.mjs} +577 -1024
- package/dist/{useFeatures-CMpkbU8Q.mjs → useFeatures-ZIvzzuEV.mjs} +16 -6
- package/dist/{useLocale-BYmoHpo6.mjs → useLocale-DTJx3aKR.mjs} +19 -7
- package/dist/{useLogger-BfaFH-Bi.mjs → useLogger-BBTcMN61.mjs} +33 -16
- package/dist/useNotifications-H4knpvNw.mjs +869 -0
- package/dist/{usePermissions-y3Uum3nO.mjs → usePermissions-B_G12Dwd.mjs} +14 -6
- package/dist/{useRules-eqSXpP9V.mjs → useRules--7Qoo60I.mjs} +15 -5
- package/dist/{useTheme-CFH6I91x.mjs → useTheme-Co05TEeD.mjs} +20 -8
- package/dist/utilities/index.d.mts +1 -1
- package/dist/utilities/index.mjs +14 -9
- package/dist/{v0-DXqYgj7J.mjs → v0-BrTEO5sv.mjs} +2 -2
- package/dist/{v0-BAG8p0si.d.mts → v0-CdusXjY_.d.mts} +1 -1
- package/dist/{v0-CFV8A5PF.mjs → v0-D0Mh3EVG.mjs} +1 -1
- package/dist/{v0-BpgPZ1qB.d.mts → v0-D7Fm2C3Y.d.mts} +1 -1
- package/dist/{v0-BqikIgl0.mjs → v0-DeiZuexg.mjs} +1 -1
- package/dist/{v0-DOq_Ia5H.mjs → v0-Dq3zhexO.mjs} +2 -2
- package/dist/{v0-C2UMaHUa.d.mts → v0-DrOub-e1.d.mts} +1 -1
- package/dist/{virtual-D1HwNBLS.mjs → virtual-C0yHf1DC.mjs} +2 -2
- package/dist/{virtual-BaQWQ9ji.d.mts → virtual-D4fckewC.d.mts} +1 -1
- package/package.json +10 -7
- package/SKILL.md +0 -95
- package/dist/adapters-BOVGPozf.mjs +0 -2
- package/dist/adapters-BbNfjyvY.mjs +0 -5
- package/dist/adapters-BhNTUuxE.mjs +0 -2
- package/dist/adapters-RwNU3wNj.mjs +0 -4
- package/dist/htmlElements-DcYtv0hg.mjs +0 -75
- package/dist/index-D6mQAEs2.d.mts +0 -79
- /package/dist/{adapter-DNKjooxI.d.mts → adapter-Dhq68tz0.d.mts} +0 -0
- /package/dist/{flagsmith-DQnnahG5.mjs → flagsmith-Dbh1h8WF.mjs} +0 -0
- /package/dist/{index-DxruGeVY.d.mts → index-C6rdXZ7j.d.mts} +0 -0
- /package/dist/{index-PWQavSPf.d.mts → index-CFhUdAHM.d.mts} +0 -0
- /package/dist/{index-c55Utzva.d.mts → index-CROz1VSV.d.mts} +0 -0
- /package/dist/{launchdarkly-2_48EJ1_.mjs → launchdarkly-BKtW-idu.mjs} +0 -0
- /package/dist/{memory-DUyWthic.d.mts → memory-CeSQE-QV.d.mts} +0 -0
- /package/dist/{memory-XCMtkld1.mjs → memory-oYBvtkgx.mjs} +0 -0
- /package/dist/{v0-4OQBCeda.mjs → v0-Bmow1q_x.mjs} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clamp,
|
|
2
|
-
import { i as useContext,
|
|
3
|
-
import { i as useLogger } from "./useLogger-
|
|
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)
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
3
|
-
import {
|
|
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
|
-
|
|
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,
|
|
2
|
-
import { t as createSelection } from "./createSelection-
|
|
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
|
-
|
|
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.
|