@vuetify/v0 0.0.3 → 0.0.6

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 (35) hide show
  1. package/dist/browser/index.js +2698 -1483
  2. package/dist/components/index.d.ts +4 -7
  3. package/dist/components/index.js +6 -7
  4. package/dist/{components-DVuB4lnH.js → components-B5k361i-.js} +164 -8
  5. package/dist/composables/index.d.ts +3 -7
  6. package/dist/composables/index.js +4 -7
  7. package/dist/composables-CAbYjAkR.js +3746 -0
  8. package/dist/constants/index.d.ts +1 -1
  9. package/dist/constants/index.js +3 -3
  10. package/dist/{globals-DZvNEOB4.js → globals-CHVv7nNV.js} +2 -2
  11. package/dist/{htmlElements-SjqYu0am.js → htmlElements-lF7PGahL.js} +1 -1
  12. package/dist/{index-DVKeyWc5.d.ts → index-BKc0YiL1.d.ts} +2 -2
  13. package/dist/index-BQfe0WBZ.d.ts +410 -0
  14. package/dist/index-BhPlroXd.d.ts +2764 -0
  15. package/dist/{index-LBy5OPMu.d.ts → index-C_lAPFXS.d.ts} +1 -1
  16. package/dist/{index-BozA2pze.d.ts → index-DIX3zaZG.d.ts} +3 -10
  17. package/dist/index.d.ts +6 -7
  18. package/dist/index.js +7 -10
  19. package/dist/types/index.d.ts +1 -1
  20. package/dist/utilities/index.d.ts +3 -3
  21. package/dist/utilities/index.js +2 -2
  22. package/dist/{utilities-D9rWEgQK.js → utilities-rsKHgU2m.js} +5 -32
  23. package/package.json +1 -3
  24. package/dist/composables-yeVk-ULz.js +0 -1270
  25. package/dist/factories/index.d.ts +0 -2
  26. package/dist/factories/index.js +0 -3
  27. package/dist/factories-BEpawPUw.js +0 -96
  28. package/dist/index-Ckt12ON6.d.ts +0 -75
  29. package/dist/index-D0L_ydyW.d.ts +0 -1396
  30. package/dist/index-tUyghL98.d.ts +0 -19
  31. package/dist/transformers/index.d.ts +0 -2
  32. package/dist/transformers/index.js +0 -4
  33. package/dist/transformers-CWrxLIkw.js +0 -122
  34. package/dist/useTheme-DCXkw_kv.js +0 -1208
  35. /package/dist/{constants-DiTCgvMU.js → constants-De5c3_aB.js} +0 -0
@@ -1,1208 +0,0 @@
1
- import { createContext, createPlugin, createTrinity, useContext } from "./factories-BEpawPUw.js";
2
- import { genId, isArray, isObject, isString, mergeDeep } from "./utilities-D9rWEgQK.js";
3
- import { IN_BROWSER, __LOGGER_ENABLED__ } from "./globals-DZvNEOB4.js";
4
- import { computed, getCurrentInstance, onMounted, onScopeDispose, readonly, shallowReactive, shallowReadonly, shallowRef, toRef, watch } from "vue";
5
-
6
- //#region src/composables/useHydration/index.ts
7
- const [useHydrationContext, provideHydrationContext] = createContext("v0:hydration");
8
- /**
9
- * Creates a hydration context for tracking client-side hydration state in SSR applications.
10
- * This function provides a way to determine when the application has been fully hydrated
11
- * on the client side, which is essential for SSR/SSG compatibility.
12
- *
13
- * @returns A hydration context object with reactive state and hydration control.
14
- */
15
- function createHydration() {
16
- const isHydrated = shallowRef(false);
17
- function hydrate() {
18
- isHydrated.value = true;
19
- }
20
- return {
21
- isHydrated: shallowReadonly(isHydrated),
22
- hydrate
23
- };
24
- }
25
- /**
26
- * Simple hook to access the hydration context.
27
- *
28
- * @returns The hydration context containing hydration state and controls.
29
- */
30
- function useHydration() {
31
- return useHydrationContext();
32
- }
33
- /**
34
- * Creates a Vue plugin for hydration state management in SSR/SSG applications.
35
- * This plugin automatically detects when the root component is mounted and
36
- * triggers the hydration process, ensuring proper client-side hydration timing.
37
- *
38
- * @returns A Vue plugin object with install method.
39
- */
40
- function createHydrationPlugin() {
41
- const context = createHydration();
42
- return createPlugin({
43
- namespace: "v0:hydration",
44
- provide: (app) => {
45
- provideHydrationContext(context, app);
46
- },
47
- setup: (app) => {
48
- app.mixin({ mounted() {
49
- if (this.$parent !== null) return;
50
- context.hydrate();
51
- } });
52
- }
53
- });
54
- }
55
-
56
- //#endregion
57
- //#region src/composables/useBreakpoints/index.ts
58
- const [useBreakpointsContext, provideBreakpointsContext] = createContext("v0:breakpoints");
59
- /**
60
- * Simple hook to access the breakpoints context.
61
- *
62
- * @returns The breakpoints context containing current breakpoint information.
63
- */
64
- function useBreakpoints() {
65
- return useBreakpointsContext();
66
- }
67
- /**
68
- * Creates default breakpoint configuration.
69
- *
70
- * @returns The default breakpoint configuration object.
71
- */
72
- function createDefaultBreakpoints() {
73
- return {
74
- mobileBreakpoint: "md",
75
- breakpoints: {
76
- xs: 0,
77
- sm: 600,
78
- md: 960,
79
- lg: 1280,
80
- xl: 1920,
81
- xxl: 2560
82
- }
83
- };
84
- }
85
- /**
86
- * Creates a reactive breakpoints system for responsive behavior management.
87
- * This function provides access to viewport dimensions, breakpoint detection, and helper flags
88
- * for determining current screen size and implementing responsive logic.
89
- *
90
- * @param options Optional configuration for breakpoint thresholds and mobile breakpoint.
91
- * @returns A breakpoints context object with reactive state and utility methods.
92
- */
93
- function createBreakpoints(options = {}) {
94
- const defaults = createDefaultBreakpoints();
95
- const { mobileBreakpoint, breakpoints } = mergeDeep(defaults, options);
96
- const sorted = Object.entries(breakpoints).sort((a, b) => a[1] - b[1]);
97
- const names = sorted.map(([n]) => n);
98
- const mb = typeof mobileBreakpoint === "number" ? mobileBreakpoint : breakpoints[mobileBreakpoint] ?? breakpoints.md;
99
- const name = shallowRef("xs");
100
- const width = shallowRef(0);
101
- const height = shallowRef(0);
102
- const isMobile = shallowRef(true);
103
- const xs = shallowRef(true);
104
- const sm = shallowRef(false);
105
- const md = shallowRef(false);
106
- const lg = shallowRef(false);
107
- const xl = shallowRef(false);
108
- const xxl = shallowRef(false);
109
- const smAndUp = shallowRef(false);
110
- const mdAndUp = shallowRef(false);
111
- const lgAndUp = shallowRef(false);
112
- const xlAndUp = shallowRef(false);
113
- const xxlAndUp = shallowRef(false);
114
- const smAndDown = shallowRef(true);
115
- const mdAndDown = shallowRef(true);
116
- const lgAndDown = shallowRef(true);
117
- const xlAndDown = shallowRef(true);
118
- const xxlAndDown = shallowRef(true);
119
- function update() {
120
- if (!IN_BROWSER) return;
121
- width.value = window.innerWidth;
122
- height.value = window.innerHeight;
123
- let current = "xs";
124
- for (let i = sorted.length - 1; i >= 0; i--) if (width.value >= sorted[i][1]) {
125
- current = sorted[i][0];
126
- break;
127
- }
128
- name.value = current;
129
- const index = names.indexOf(current);
130
- isMobile.value = width.value < mb;
131
- xs.value = index === 0;
132
- sm.value = index === 1;
133
- md.value = index === 2;
134
- lg.value = index === 3;
135
- xl.value = index === 4;
136
- xxl.value = index === 5;
137
- smAndUp.value = index >= 1;
138
- mdAndUp.value = index >= 2;
139
- lgAndUp.value = index >= 3;
140
- xlAndUp.value = index >= 4;
141
- xxlAndUp.value = index >= 5;
142
- smAndDown.value = index <= 1;
143
- mdAndDown.value = index <= 2;
144
- lgAndDown.value = index <= 3;
145
- xlAndDown.value = index <= 4;
146
- xxlAndDown.value = index <= 5;
147
- }
148
- if (getCurrentInstance()) onMounted(() => {
149
- const { isHydrated } = useHydration();
150
- if (isHydrated.value) update();
151
- watch(isHydrated, (hydrated) => {
152
- if (hydrated) update();
153
- }, { immediate: true });
154
- });
155
- if (IN_BROWSER) {
156
- function listener() {
157
- update();
158
- }
159
- window.addEventListener("resize", listener, { passive: true });
160
- if (getCurrentInstance()) onScopeDispose(() => window.removeEventListener("resize", listener));
161
- }
162
- return {
163
- breakpoints,
164
- name: readonly(name),
165
- width: readonly(width),
166
- height: readonly(height),
167
- isMobile: readonly(isMobile),
168
- xs: readonly(xs),
169
- sm: readonly(sm),
170
- md: readonly(md),
171
- lg: readonly(lg),
172
- xl: readonly(xl),
173
- xxl: readonly(xxl),
174
- smAndUp: readonly(smAndUp),
175
- mdAndUp: readonly(mdAndUp),
176
- lgAndUp: readonly(lgAndUp),
177
- xlAndUp: readonly(xlAndUp),
178
- xxlAndUp: readonly(xxlAndUp),
179
- smAndDown: readonly(smAndDown),
180
- mdAndDown: readonly(mdAndDown),
181
- lgAndDown: readonly(lgAndDown),
182
- xlAndDown: readonly(xlAndDown),
183
- xxlAndDown: readonly(xxlAndDown),
184
- update
185
- };
186
- }
187
- /**
188
- * Creates a Vue plugin for managing responsive breakpoints with automatic updates.
189
- * This plugin sets up breakpoint tracking and updates the context when the window
190
- * is resized, providing reactive breakpoint state throughout the application.
191
- *
192
- * @param options Optional configuration for breakpoint thresholds and mobile breakpoint.
193
- * @returns A Vue plugin object with install method.
194
- */
195
- function createBreakpointsPlugin(options = {}) {
196
- const context = createBreakpoints(options);
197
- return createPlugin({
198
- namespace: "v0:breakpoints",
199
- provide: (app) => {
200
- provideBreakpointsContext(context, app);
201
- },
202
- setup: (app) => {
203
- app.mixin({ mounted() {
204
- context.update();
205
- } });
206
- }
207
- });
208
- }
209
-
210
- //#endregion
211
- //#region src/composables/useLogger/adapters/consola.ts
212
- var ConsolaLoggerAdapter = class {
213
- consola;
214
- constructor(consolaInstance) {
215
- if (!consolaInstance) throw new Error("Consola instance is required for ConsolaLoggerAdapter");
216
- this.consola = consolaInstance;
217
- }
218
- debug(message, ...args) {
219
- this.consola.debug(message, ...args);
220
- }
221
- info(message, ...args) {
222
- this.consola.info(message, ...args);
223
- }
224
- warn(message, ...args) {
225
- this.consola.warn(message, ...args);
226
- }
227
- error(message, ...args) {
228
- this.consola.error(message, ...args);
229
- }
230
- trace(message, ...args) {
231
- if (this.consola.trace) this.consola.trace(message, ...args);
232
- else this.consola.debug(message, ...args);
233
- }
234
- fatal(message, ...args) {
235
- if (this.consola.fatal) this.consola.fatal(message, ...args);
236
- else this.consola.error("[FATAL]", message, ...args);
237
- }
238
- };
239
-
240
- //#endregion
241
- //#region src/composables/useLogger/adapters/pino.ts
242
- /**
243
- * Pino logger adapter implementation
244
- *
245
- * This adapter integrates with the Pino logging library,
246
- * providing high-performance structured logging optimized
247
- * for Node.js applications with minimal overhead.
248
- */
249
- var PinoLoggerAdapter = class {
250
- pino;
251
- constructor(pinoInstance) {
252
- if (!pinoInstance) throw new Error("Pino instance is required for PinoLoggerAdapter");
253
- this.pino = pinoInstance;
254
- }
255
- debug(message, ...args) {
256
- this.pino.debug(this.format(message, ...args));
257
- }
258
- info(message, ...args) {
259
- this.pino.info(this.format(message, ...args));
260
- }
261
- warn(message, ...args) {
262
- this.pino.warn(this.format(message, ...args));
263
- }
264
- error(message, ...args) {
265
- this.pino.error(this.format(message, ...args));
266
- }
267
- trace(message, ...args) {
268
- this.pino.trace(this.format(message, ...args));
269
- }
270
- fatal(message, ...args) {
271
- this.pino.fatal(this.format(message, ...args));
272
- }
273
- format(message, ...args) {
274
- if (args.length === 0) return { msg: message };
275
- if (args.length === 1 && typeof args[0] === "object" && args[0] !== null) return {
276
- ...args[0],
277
- msg: message
278
- };
279
- return {
280
- msg: message,
281
- args
282
- };
283
- }
284
- };
285
-
286
- //#endregion
287
- //#region src/composables/useLogger/adapters/v0.ts
288
- /**
289
- * Vuetify0.x logger adapter implementation
290
- *
291
- * This adapter provides console-based logging with proper formatting,
292
- * color coding, timestamps, and log level filtering for development
293
- * and production environments.
294
- */
295
- var Vuetify0LoggerAdapter = class {
296
- prefix;
297
- colors;
298
- timestamps;
299
- constructor(options = {}) {
300
- this.prefix = options.prefix || "v0";
301
- this.colors = options.colors !== false;
302
- this.timestamps = options.timestamps !== false;
303
- }
304
- debug(message, ...args) {
305
- this.log("debug", "debug", message, ...args);
306
- }
307
- info(message, ...args) {
308
- this.log("info", "info", message, ...args);
309
- }
310
- warn(message, ...args) {
311
- this.log("warn", "warn", message, ...args);
312
- }
313
- error(message, ...args) {
314
- this.log("error", "error", message, ...args);
315
- }
316
- trace(message, ...args) {
317
- this.log("trace", "trace", message, ...args);
318
- }
319
- fatal(message, ...args) {
320
- this.log("fatal", "error", message, ...args);
321
- }
322
- format(level, message, ...args) {
323
- const timestamp = this.timestamps ? this.timestamp() : "";
324
- const prefixTag = `[${this.prefix} ${level.toLowerCase()}]`;
325
- return [[
326
- timestamp,
327
- prefixTag,
328
- message
329
- ].filter(Boolean).join(" "), ...args];
330
- }
331
- timestamp() {
332
- if (!IN_BROWSER) return (/* @__PURE__ */ new Date()).toISOString();
333
- return (/* @__PURE__ */ new Date()).toTimeString().split(" ")[0] ?? "";
334
- }
335
- style(level) {
336
- if (!this.colors || !IN_BROWSER) return "";
337
- return {
338
- trace: "color: #64748b",
339
- debug: "color: #3b82f6",
340
- info: "color: #10b981",
341
- warn: "color: #f59e0b",
342
- error: "color: #ef4444",
343
- fatal: "color: #dc2626; font-weight: bold",
344
- silent: ""
345
- }[level] || "";
346
- }
347
- log(level, method, message, ...args) {
348
- const [formattedMessage, ...restArgs] = this.format(level, message, ...args);
349
- const style = this.style(level);
350
- if (IN_BROWSER && style && typeof console[method] === "function") console[method](`%c${formattedMessage}`, style, ...restArgs);
351
- else if (typeof console[method] === "function") console[method](formattedMessage, ...restArgs);
352
- }
353
- };
354
-
355
- //#endregion
356
- //#region src/composables/useLogger/index.ts
357
- const [useLoggerContext, provideLoggerContext] = createContext("v0:logger");
358
- /**
359
- * Creates a logger context for application logging with configurable adapters and levels.
360
- * This function provides a consistent logging interface that can be configured with
361
- * different adapters and optimized for production builds with conditional compilation.
362
- *
363
- * @param options Configuration for the logger adapter, level, and behavior.
364
- * @returns A logger context object with logging methods and controls.
365
- */
366
- function createLogger(options = {}) {
367
- const { adapter = new Vuetify0LoggerAdapter({ prefix: options.prefix }), level: initialLevel = "info", enabled: initialEnabled = __LOGGER_ENABLED__ } = options;
368
- const currentLevel = shallowRef(initialLevel);
369
- const isEnabled = shallowRef(initialEnabled);
370
- function value(level$1) {
371
- return {
372
- trace: 0,
373
- debug: 1,
374
- info: 2,
375
- warn: 3,
376
- error: 4,
377
- fatal: 5,
378
- silent: 6
379
- }[level$1] ?? 2;
380
- }
381
- function can(level$1) {
382
- if (!isEnabled.value) return false;
383
- return value(level$1) >= value(currentLevel.value);
384
- }
385
- function format(message) {
386
- return message;
387
- }
388
- function debug(message, ...args) {
389
- if (can("debug")) adapter.debug(format(message), ...args);
390
- }
391
- function info(message, ...args) {
392
- if (can("info")) adapter.info(format(message), ...args);
393
- }
394
- function warn(message, ...args) {
395
- if (can("warn")) adapter.warn(format(message), ...args);
396
- }
397
- function error(message, ...args) {
398
- if (can("error")) adapter.error(format(message), ...args);
399
- }
400
- function trace(message, ...args) {
401
- if (can("trace")) adapter.trace?.(format(message), ...args);
402
- }
403
- function fatal(message, ...args) {
404
- if (can("fatal")) adapter.fatal?.(format(message), ...args);
405
- }
406
- function level(newLevel) {
407
- currentLevel.value = newLevel;
408
- }
409
- function current() {
410
- return currentLevel.value;
411
- }
412
- function enabled() {
413
- return isEnabled.value;
414
- }
415
- function enable() {
416
- isEnabled.value = true;
417
- }
418
- function disable() {
419
- isEnabled.value = false;
420
- }
421
- return {
422
- debug,
423
- info,
424
- warn,
425
- error,
426
- trace,
427
- fatal,
428
- level,
429
- current,
430
- enabled,
431
- enable,
432
- disable
433
- };
434
- }
435
- function createFallbackLogger(namespace = "v0:logger") {
436
- function format(message, type) {
437
- return `[${namespace} ${type}] ${message}`;
438
- }
439
- return {
440
- debug: (message, ...args) => console.log(format(message, "debug"), ...args),
441
- info: (message, ...args) => console.log(format(message, "info"), ...args),
442
- warn: (message, ...args) => console.log(format(message, "warn"), ...args),
443
- error: (message, ...args) => console.log(format(message, "error"), ...args),
444
- trace: (message, ...args) => console.log(format(message, "trace"), ...args),
445
- fatal: (message, ...args) => console.log(format(message, "fatal"), ...args),
446
- level: () => {},
447
- current: () => "info",
448
- enabled: () => true,
449
- enable: () => {},
450
- disable: () => {}
451
- };
452
- }
453
- function useLogger(namespace) {
454
- if (getCurrentInstance()) try {
455
- return useLoggerContext(namespace);
456
- } catch (error) {
457
- if (process.env.NODE_ENV !== "production" && IN_BROWSER && namespace) console.warn(error);
458
- }
459
- return createFallbackLogger(namespace);
460
- }
461
- function createLoggerPlugin(options = {}) {
462
- const context = createLogger(options);
463
- return createPlugin({
464
- namespace: "v0:logger",
465
- provide: (app) => {
466
- provideLoggerContext(context, app);
467
- },
468
- setup: (_app) => {
469
- if (process.env.NODE_ENV !== "production" && IN_BROWSER) window.__v0Logger__ = context;
470
- }
471
- });
472
- }
473
-
474
- //#endregion
475
- //#region src/composables/useRegistry/index.ts
476
- /**
477
- * Creates a registry for managing collections of items with registration and lookup capabilities.
478
- * This function provides the foundation for item management systems with ID-based, value-based,
479
- * and index-based access patterns.
480
- *
481
- * @param options Optional configuration for enabling events.
482
- * @template Z The type of items managed by the registry.
483
- * @template E The type of the registry context.
484
- * @returns The registry context object.
485
- *
486
- * @see https://0.vuetifyjs.com/composables/registration/use-registry
487
- */
488
- function useRegistry(options) {
489
- const logger = useLogger();
490
- const collection = /* @__PURE__ */ new Map();
491
- const catalog = /* @__PURE__ */ new Map();
492
- const directory = /* @__PURE__ */ new Map();
493
- const cache = /* @__PURE__ */ new Map();
494
- const listeners = /* @__PURE__ */ new Map();
495
- function emit(event, data) {
496
- if (!options?.events) return;
497
- const cbs = listeners.get(event);
498
- if (!cbs) return;
499
- for (const cb of cbs) cb(data);
500
- }
501
- function on(event, cb) {
502
- if (!listeners.has(event)) listeners.set(event, /* @__PURE__ */ new Set());
503
- listeners.get(event).add(cb);
504
- }
505
- function off(event, cb) {
506
- listeners.get(event)?.delete(cb);
507
- }
508
- function dispose() {
509
- if (listeners.size > 0) listeners.clear();
510
- clear();
511
- }
512
- function get(id) {
513
- return collection.get(id);
514
- }
515
- function upsert(id, patch = {}) {
516
- const existing = get(id);
517
- if (!existing) return register({
518
- ...patch,
519
- id
520
- });
521
- const hasValue = Object.prototype.hasOwnProperty.call(patch, "value");
522
- let value = existing.value;
523
- let valueIsIndex = existing.valueIsIndex;
524
- if (hasValue) {
525
- if (patch.value === void 0) {
526
- value = existing.index;
527
- valueIsIndex = true;
528
- } else {
529
- value = patch.value;
530
- valueIsIndex = false;
531
- }
532
- if (!Object.is(value, existing.value)) {
533
- unassign(existing.value, id);
534
- assign(value, id);
535
- }
536
- }
537
- const updated = {
538
- ...existing,
539
- ...patch,
540
- id,
541
- index: existing.index,
542
- value,
543
- valueIsIndex
544
- };
545
- collection.set(id, updated);
546
- invalidate();
547
- return updated;
548
- }
549
- function browse(value) {
550
- return catalog.get(value);
551
- }
552
- function lookup(index) {
553
- return directory.get(index);
554
- }
555
- function has(id) {
556
- return collection.has(id);
557
- }
558
- function assign(value, id) {
559
- const bucket = catalog.get(value);
560
- if (bucket) {
561
- if (isArray(bucket)) {
562
- if (!bucket.includes(id)) bucket.push(id);
563
- } else if (bucket !== id) catalog.set(value, [bucket, id]);
564
- } else catalog.set(value, id);
565
- }
566
- function unassign(value, id) {
567
- const bucket = catalog.get(value);
568
- if (!bucket) return;
569
- if (isArray(bucket)) {
570
- const next = bucket.filter((v) => v !== id);
571
- if (next.length === 0) catalog.delete(value);
572
- else if (next.length === 1) catalog.set(value, next[0]);
573
- else catalog.set(value, next);
574
- } else if (bucket === id) catalog.delete(value);
575
- }
576
- function keys() {
577
- const cached = cache.get("keys");
578
- if (cached != void 0) return cached;
579
- const keys$1 = Array.from(collection.keys());
580
- cache.set("keys", keys$1);
581
- return keys$1;
582
- }
583
- function values() {
584
- const cached = cache.get("values");
585
- if (cached != void 0) return cached;
586
- const values$1 = Array.from(collection.values());
587
- cache.set("values", values$1);
588
- return values$1;
589
- }
590
- function entries() {
591
- const cached = cache.get("entries");
592
- if (cached != void 0) return cached;
593
- const entries$1 = Array.from(collection.entries());
594
- cache.set("entries", entries$1);
595
- return entries$1;
596
- }
597
- function clear() {
598
- if (collection.size > 0) collection.clear();
599
- if (catalog.size > 0) catalog.clear();
600
- if (directory.size > 0) directory.clear();
601
- invalidate();
602
- }
603
- function invalidate() {
604
- if (cache.size > 0) cache.clear();
605
- }
606
- function reindex() {
607
- if (catalog.size > 0) catalog.clear();
608
- if (directory.size > 0) directory.clear();
609
- let index = 0;
610
- for (const item of values()) {
611
- if (item.index !== index) {
612
- item.index = index;
613
- if (item.valueIsIndex) item.value = index;
614
- }
615
- directory.set(index, item.id);
616
- assign(item.value, item.id);
617
- index++;
618
- }
619
- invalidate();
620
- }
621
- function register(registration = {}) {
622
- const size = collection.size;
623
- const id = registration.id ?? genId();
624
- if (has(id)) {
625
- logger.warn(`Item with id "${id}" already exists in the registry. Skipping registration.`);
626
- return get(id);
627
- }
628
- const index = registration.index ?? size;
629
- const value = registration.value === void 0 ? index : registration.value;
630
- const valueIsIndex = registration.value === void 0;
631
- const item = {
632
- ...registration,
633
- id,
634
- index,
635
- value,
636
- valueIsIndex
637
- };
638
- collection.set(item.id, item);
639
- directory.set(item.index, item.id);
640
- assign(item.value, item.id);
641
- invalidate();
642
- emit("register", item);
643
- return item;
644
- }
645
- function unregister(id) {
646
- const item = collection.get(id);
647
- if (!item) return;
648
- collection.delete(item.id);
649
- directory.delete(item.index);
650
- unassign(item.value, item.id);
651
- emit("unregister", item);
652
- reindex();
653
- }
654
- return {
655
- collection,
656
- emit,
657
- on,
658
- off,
659
- dispose,
660
- has,
661
- keys,
662
- clear,
663
- browse,
664
- entries,
665
- values,
666
- lookup,
667
- get,
668
- upsert,
669
- register,
670
- unregister,
671
- reindex,
672
- onboard(registrations) {
673
- return registrations.map((registration) => this.register(registration));
674
- },
675
- get size() {
676
- return collection.size;
677
- }
678
- };
679
- }
680
- /**
681
- * Creates a registry context with full injection/provision control.
682
- * Returns the complete trinity for advanced usage scenarios.
683
- *
684
- * @param namespace The namespace for the registry context.
685
- * @param options Optional configuration for reactivity behavior.
686
- * @template Z The type of tickets managed by the registry.
687
- * @template E The type of the registry context.
688
- * @returns A tuple containing the inject function, provide function, and the registry context.
689
- */
690
- function createRegistryContext(namespace, options) {
691
- const [useRegistryContext, _provideRegistryContext] = createContext(namespace);
692
- const context = useRegistry(options);
693
- function provideRegistryContext(_context = context, app) {
694
- return _provideRegistryContext(_context, app);
695
- }
696
- return createTrinity(useRegistryContext, provideRegistryContext, context);
697
- }
698
-
699
- //#endregion
700
- //#region src/composables/useSelection/index.ts
701
- /**
702
- * Creates a selection context for managing collections of selectable items.
703
- * This function extends the registry functionality with selection state management.
704
- *
705
- * @param options Optional configuration for selection behavior.
706
- * @template Z The type of items managed by the selection.
707
- * @template E The type of the selection context.
708
- * @returns The selection context object.
709
- */
710
- function useSelection(options) {
711
- const registry = useRegistry(options);
712
- const selectedIds = shallowReactive(/* @__PURE__ */ new Set());
713
- const enroll = options?.enroll ?? false;
714
- const mandatory = options?.mandatory ?? false;
715
- const selectedItems = computed(() => {
716
- return new Set(Array.from(selectedIds).map((id) => registry.get(id)));
717
- });
718
- const selectedValues = computed(() => {
719
- return new Set(Array.from(selectedItems.value).map((item) => item?.value));
720
- });
721
- function mandate() {
722
- if (!mandatory || registry.selectedIds.size > 0 || registry.size === 0) return;
723
- select(registry.lookup(0));
724
- }
725
- function select(id) {
726
- const item = registry.get(id);
727
- if (!item || item.disabled) return;
728
- selectedIds.add(id);
729
- }
730
- function unselect(id) {
731
- if (mandatory && selectedIds.size === 1) return;
732
- selectedIds.delete(id);
733
- }
734
- function toggle(id) {
735
- if (selectedIds.has(id)) unselect(id);
736
- else select(id);
737
- }
738
- function selected(id) {
739
- return selectedIds.has(id);
740
- }
741
- function register(registration = {}) {
742
- const id = registration.id ?? genId();
743
- const item = {
744
- disabled: false,
745
- ...registration,
746
- id,
747
- isSelected: toRef(() => selectedIds.has(id)),
748
- select: () => select(id),
749
- unselect: () => unselect(id),
750
- toggle: () => toggle(id)
751
- };
752
- const ticket = registry.register(item);
753
- if (enroll && !item.disabled) selectedIds.add(ticket.id);
754
- if (mandatory === "force") mandate();
755
- return ticket;
756
- }
757
- function unregister(id) {
758
- selectedIds.delete(id);
759
- registry.unregister(id);
760
- }
761
- function reset() {
762
- registry.clear();
763
- registry.reindex();
764
- registry.mandate();
765
- }
766
- return {
767
- ...registry,
768
- selectedIds,
769
- selectedItems,
770
- selectedValues,
771
- register,
772
- unregister,
773
- reset,
774
- mandate,
775
- select,
776
- unselect,
777
- toggle,
778
- selected
779
- };
780
- }
781
- /**
782
- * Creates a selection registry context with full injection/provision control.
783
- * Returns the complete trinity for advanced usage scenarios.
784
- *
785
- * @param namespace The namespace for the selection registry context
786
- * @param options Optional configuration for selection behavior.
787
- * @template Z The structure of the registry selection items.
788
- * @template E The available methods for the selection's context.
789
- * @returns A tuple containing the inject function, provide function, and the selection context.
790
- */
791
- function createSelectionContext(namespace, options) {
792
- const [useSelectionContext, _provideSelectionContext] = createContext(namespace);
793
- const context = useSelection(options);
794
- function provideSelectionContext(_context = context, app) {
795
- return _provideSelectionContext(_context, app);
796
- }
797
- return createTrinity(useSelectionContext, provideSelectionContext, context);
798
- }
799
-
800
- //#endregion
801
- //#region src/composables/useSingle/index.ts
802
- /**
803
- * Creates a single selection context for managing collections where only one item can be selected.
804
- * This function extends the selection functionality with single-selection constraints.
805
- *
806
- * @param options Optional configuration for single selection behavior.
807
- * @template Z The type of items managed by the single selection.
808
- * @template E The type of the single selection context.
809
- * @returns The single selection context object.
810
- */
811
- function useSingle(options) {
812
- const registry = useSelection(options);
813
- const mandatory = options?.mandatory ?? false;
814
- const selectedId = computed(() => registry.selectedIds.values().next().value);
815
- const selectedItem = computed(() => registry.selectedItems.value.values().next().value);
816
- const selectedIndex = computed(() => selectedItem.value?.index ?? -1);
817
- const selectedValue = computed(() => selectedItem.value?.value);
818
- function select(id) {
819
- const item = registry.get(id);
820
- if (!item || item.disabled) return;
821
- registry.selectedIds.clear();
822
- registry.select(id);
823
- }
824
- function unselect(id) {
825
- if (mandatory && registry.selectedIds.size === 1) return;
826
- registry.selectedIds.delete(id);
827
- }
828
- function toggle(id) {
829
- if (registry.selectedIds.has(id)) unselect(id);
830
- else select(id);
831
- }
832
- return {
833
- ...registry,
834
- selectedId,
835
- selectedItem,
836
- selectedIndex,
837
- selectedValue,
838
- select,
839
- unselect,
840
- toggle
841
- };
842
- }
843
- /**
844
- * Creates a single selection registry context with full injection/provision control.
845
- * Returns the complete trinity for advanced usage scenarios.
846
- *
847
- * @param namespace The namespace for the single selection registry context
848
- * @param options Optional configuration for single selection behavior.
849
- * @template Z The structure of the registry single selection items.
850
- * @template E The available methods for the single's context.
851
- * @returns A tuple containing the inject function, provide function, and the single selection context.
852
- */
853
- function createSingleContext(namespace, options) {
854
- const [useSingleContext, _provideSingleContext] = createContext(namespace);
855
- const context = useSingle(options);
856
- function provideSingleContext(_context = context, app) {
857
- return _provideSingleContext(_context, app);
858
- }
859
- return createTrinity(useSingleContext, provideSingleContext, context);
860
- }
861
-
862
- //#endregion
863
- //#region src/composables/useTokens/index.ts
864
- /**
865
- * Creates a token registry for managing design token collections with alias resolution.
866
- * Returns the token context directly for simple usage.
867
- *
868
- * @param tokens A collection of tokens to initialize with
869
- * @template Z The structure of the registry token items.
870
- * @template E The available methods for the token's context.
871
- * @returns The token context object.
872
- *
873
- * @see https://0.vuetifyjs.com/composables/registration/use-tokens
874
- * @see https://www.designtokens.org/tr/drafts/format/
875
- */
876
- function useTokens(tokens = {}, options = {}) {
877
- const logger = useLogger();
878
- const registry = useRegistry();
879
- const cache = /* @__PURE__ */ new Map();
880
- registry.onboard(flatten(tokens, options.prefix, !!options.flat));
881
- function isAlias(token) {
882
- return isString(token) && token.length > 2 && token[0] === "{" && token.at(-1) === "}";
883
- }
884
- function isTokenAlias(value) {
885
- return isObject(value) && "$value" in value;
886
- }
887
- function resolve(token) {
888
- const cacheKey = isString(token) ? token : JSON.stringify(token);
889
- const cached = cache.get(cacheKey);
890
- if (cached !== void 0) return cached;
891
- const reference = isTokenAlias(token) ? token.$value : token;
892
- const clean = isString(reference) && isAlias(reference) ? reference.slice(1, -1) : String(reference);
893
- let found = registry.get(clean);
894
- let segments = [];
895
- if (!found && clean.includes(".")) {
896
- const parts = clean.split(".");
897
- for (let i = parts.length - 1; i > 0; i--) {
898
- const prefix = parts.slice(0, i).join(".");
899
- const suffix = parts.slice(i);
900
- const candidate = registry.get(prefix);
901
- if (candidate?.value !== void 0) {
902
- found = candidate;
903
- segments = suffix;
904
- break;
905
- }
906
- }
907
- }
908
- if (found?.value === void 0) {
909
- logger.warn(`Alias not found for "${String(reference)}"`);
910
- cache.set(cacheKey, void 0);
911
- return;
912
- }
913
- let result;
914
- let current = found.value;
915
- if (segments.length > 0) {
916
- if (isTokenAlias(current)) current = current.$value;
917
- for (const segment of segments) {
918
- if (!isObject(current) || !(segment in current)) {
919
- current = void 0;
920
- break;
921
- }
922
- current = current[segment];
923
- if (isTokenAlias(current)) current = current.$value;
924
- }
925
- if (current === void 0) {
926
- logger.warn(`Path not found inside "${clean}": ${segments.join(".")}`);
927
- cache.set(cacheKey, void 0);
928
- return;
929
- }
930
- result = current;
931
- } else if (isTokenAlias(current)) {
932
- const inner = current.$value;
933
- if (isString(inner) && isAlias(inner)) return resolve(inner);
934
- result = inner;
935
- } else if (isString(current) && isAlias(current)) return resolve(current);
936
- else result = current;
937
- cache.set(cacheKey, result);
938
- return result;
939
- }
940
- return {
941
- ...registry,
942
- resolve,
943
- isAlias
944
- };
945
- }
946
- /**
947
- * Creates a token registry context with full injection/provision control.
948
- * Returns the complete trinity for advanced usage scenarios.
949
- *
950
- * @param namespace The namespace for the token registry context
951
- * @param tokens An optional collection of tokens to initialize
952
- * @template Z The structure of the registry token items.
953
- * @template E The available methods for the token's context.
954
- * @returns A tuple containing the inject function, provide function, and the token context.
955
- */
956
- function createTokensContext(namespace, tokens = {}) {
957
- const [useTokensContext, _provideTokensContext] = createContext(namespace);
958
- const context = useTokens(tokens);
959
- function provideTokensContext(_context = context, app) {
960
- return _provideTokensContext(_context, app);
961
- }
962
- return createTrinity(useTokensContext, provideTokensContext, context);
963
- }
964
- /**
965
- * Flattens a nested collection of tokens into a flat array of tokens.
966
- * Each token is represented by an object containing its ID & value.
967
- * @param tokens The collection of tokens to flatten.
968
- * @param prefix An optional prefix to prepend to each token ID.
969
- * @returns An array of flattened tokens, each with an ID and value.
970
- */
971
- function flatten(tokens, prefix = "", flat = false) {
972
- const flattened = [];
973
- const stack = [{
974
- tokens,
975
- prefix,
976
- flat
977
- }];
978
- while (stack.length > 0) {
979
- const { tokens: currentTokens, prefix: currentPrefix, flat: flat$1 } = stack.pop();
980
- const meta = {};
981
- for (const k in currentTokens) if (k.startsWith("$")) meta[k] = currentTokens[k];
982
- if (Object.keys(meta).length > 0 && currentPrefix) flattened.push({
983
- id: currentPrefix,
984
- value: meta
985
- });
986
- for (const key in currentTokens) {
987
- if (key.startsWith("$")) continue;
988
- const value = currentTokens[key];
989
- const id = currentPrefix ? `${currentPrefix}.${key}` : key;
990
- if (!isObject(value)) {
991
- flattened.push({
992
- id,
993
- value
994
- });
995
- continue;
996
- }
997
- if ("$value" in value) {
998
- flattened.push({
999
- id,
1000
- value
1001
- });
1002
- const inner = value.$value;
1003
- if (isObject(inner) && !flat$1) for (const innerKey in inner) {
1004
- if (innerKey.startsWith("$")) continue;
1005
- const child = inner[innerKey];
1006
- const childId = `${id}.${innerKey}`;
1007
- if (!isObject(child)) flattened.push({
1008
- id: childId,
1009
- value: child
1010
- });
1011
- else if ("$value" in child) flattened.push({
1012
- id: childId,
1013
- value: child
1014
- });
1015
- else stack.push({
1016
- tokens: child,
1017
- prefix: childId,
1018
- flat: flat$1
1019
- });
1020
- }
1021
- continue;
1022
- }
1023
- if (flat$1) {
1024
- flattened.push({
1025
- id,
1026
- value
1027
- });
1028
- continue;
1029
- }
1030
- stack.push({
1031
- tokens: value,
1032
- prefix: id,
1033
- flat: flat$1
1034
- });
1035
- }
1036
- }
1037
- return flattened;
1038
- }
1039
-
1040
- //#endregion
1041
- //#region src/composables/useTheme/adapters/adapter.ts
1042
- var ThemeAdapter = class {
1043
- prefix;
1044
- constructor(prefix) {
1045
- this.prefix = prefix;
1046
- }
1047
- generate(colors) {
1048
- let css = "";
1049
- for (const theme in colors) {
1050
- const themeColors = colors[theme];
1051
- if (!themeColors) continue;
1052
- const vars = Object.entries(themeColors).map(([key, val]) => ` --${this.prefix}-${key}: ${val};`).join("\n");
1053
- css += `.${this.prefix}-theme--${theme} {\n${vars}\n}\n`;
1054
- }
1055
- return css;
1056
- }
1057
- };
1058
-
1059
- //#endregion
1060
- //#region src/composables/useTheme/adapters/v0.ts
1061
- /**
1062
- * Theme adapter implementation for Vuetify v0 design system.
1063
- * This adapter generates CSS custom properties and injects them into the DOM
1064
- * as a stylesheet, allowing themes to be applied globally.
1065
- */
1066
- var Vuetify0ThemeAdapter = class extends ThemeAdapter {
1067
- cspNonce;
1068
- stylesheetId = "v0-theme-stylesheet";
1069
- constructor(options = {}) {
1070
- super(options.prefix ?? "v0");
1071
- this.cspNonce = options.cspNonce;
1072
- this.stylesheetId = options.stylesheetId ?? this.stylesheetId;
1073
- }
1074
- update(colors) {
1075
- if (!IN_BROWSER) return;
1076
- this.upsert(this.generate(colors));
1077
- }
1078
- upsert(styles) {
1079
- if (!IN_BROWSER) return;
1080
- let styleEl = document.querySelector(`#${this.stylesheetId}`);
1081
- if (!styleEl) {
1082
- styleEl = document.createElement("style");
1083
- styleEl.id = this.stylesheetId.startsWith("#") ? this.stylesheetId.slice(1) : this.stylesheetId;
1084
- if (this.cspNonce) styleEl.setAttribute("nonce", this.cspNonce);
1085
- document.head.append(styleEl);
1086
- }
1087
- styleEl.textContent = styles;
1088
- }
1089
- };
1090
-
1091
- //#endregion
1092
- //#region src/composables/useTheme/index.ts
1093
- /**
1094
- * Creates a theme registry for managing theme selections with dynamic color resolution.
1095
- * Supports token-based color systems and lazy theme loading for optimal performance.
1096
- *
1097
- * @param namespace The namespace for the theme context.
1098
- * @param options Configuration including adapter and themes.
1099
- * @template Z The type of theme context.
1100
- * @template E The type of theme items managed by the registry.
1101
- * @returns A tuple containing inject, provide functions and the theme context.
1102
- *
1103
- * @see https://0.vuetifyjs.com/composables/plugins/use-theme
1104
- */
1105
- function createTheme(namespace = "v0:theme", options = {}) {
1106
- const { themes = {}, palette = {} } = options;
1107
- const [useThemeContext, _provideThemeContext] = createContext(namespace);
1108
- const tokens = useTokens({
1109
- palette,
1110
- ...themes
1111
- }, { flat: true });
1112
- const registry = useSingle();
1113
- for (const id in themes) {
1114
- const { colors: value,...theme } = themes[id];
1115
- register({
1116
- id,
1117
- value,
1118
- ...theme
1119
- });
1120
- if (id === options.default && !registry.selectedId.value) registry.select(id);
1121
- }
1122
- const names = computed(() => registry.keys());
1123
- const colors = computed(() => {
1124
- const resolved = {};
1125
- for (const theme of registry.values()) {
1126
- if (theme.lazy && theme.id !== registry.selectedId.value) continue;
1127
- resolved[theme.id] = resolve(theme.value);
1128
- }
1129
- return resolved;
1130
- });
1131
- function cycle(themes$1 = names.value) {
1132
- const current = themes$1.indexOf(registry.selectedId.value ?? "");
1133
- const next = current === -1 ? 0 : (current + 1) % themes$1.length;
1134
- registry.select(themes$1[next]);
1135
- }
1136
- function resolve(colors$1) {
1137
- const resolved = {};
1138
- for (const [key, value] of Object.entries(colors$1)) resolved[key] = tokens.isAlias(value) ? tokens.resolve(value) : value;
1139
- return resolved;
1140
- }
1141
- function register(registration = {}) {
1142
- const item = {
1143
- lazy: false,
1144
- dark: false,
1145
- ...registration
1146
- };
1147
- return registry.register(item);
1148
- }
1149
- const context = {
1150
- ...registry,
1151
- colors,
1152
- register,
1153
- cycle
1154
- };
1155
- function provideThemeContext(_context = context, app) {
1156
- return _provideThemeContext(_context, app);
1157
- }
1158
- return createTrinity(useThemeContext, provideThemeContext, context);
1159
- }
1160
- /**
1161
- * Simple hook to access the theme context.
1162
- *
1163
- * @returns The theme context containing current theme state and utilities.
1164
- *
1165
- * @see https://0.vuetifyjs.com/composables/plugins/use-theme
1166
- */
1167
- function useTheme() {
1168
- return useContext("v0:theme");
1169
- }
1170
- /**
1171
- * Creates a Vue plugin for theme management with automatic color system updates.
1172
- * Integrates with token system for dynamic color resolution and provides reactive
1173
- * theme switching capabilities throughout the application.
1174
- *
1175
- * @param options Configuration for themes, palette, and adapter.
1176
- * @template Z The type of theme context.
1177
- * @template E The type of theme items.
1178
- * @returns A Vue plugin object with install method.
1179
- *
1180
- * @see https://0.vuetifyjs.com/composables/plugins/use-theme
1181
- */
1182
- function createThemePlugin(_options = {}) {
1183
- const { adapter = new Vuetify0ThemeAdapter(), palette = {}, themes = {},...options } = _options;
1184
- const [, provideThemeContext, themeContext] = createTheme("v0:theme", {
1185
- ...options,
1186
- themes,
1187
- palette
1188
- });
1189
- function update(colors) {
1190
- adapter.update(colors);
1191
- }
1192
- return createPlugin({
1193
- namespace: "v0:theme",
1194
- provide: (app) => {
1195
- provideThemeContext(themeContext, app);
1196
- },
1197
- setup: () => {
1198
- if (IN_BROWSER) watch(themeContext.colors, update, {
1199
- immediate: true,
1200
- deep: true
1201
- });
1202
- else update(themeContext.colors.value);
1203
- }
1204
- });
1205
- }
1206
-
1207
- //#endregion
1208
- export { ConsolaLoggerAdapter, PinoLoggerAdapter, Vuetify0LoggerAdapter, createBreakpoints, createBreakpointsPlugin, createHydration, createHydrationPlugin, createLogger, createLoggerPlugin, createRegistryContext, createSelectionContext, createSingleContext, createTheme, createThemePlugin, createTokensContext, provideBreakpointsContext, provideHydrationContext, useBreakpoints, useBreakpointsContext, useHydration, useHydrationContext, useLogger, useRegistry, useSelection, useSingle, useTheme, useTokens };