@vuetify/v0 0.1.5 → 0.1.7
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 +0 -1
- package/dist/{adapter-Cmeg49W9.mjs → adapter-B4zE-hA5.mjs} +10 -15
- package/dist/adapter-CqP9Z4JU.d.mts +1087 -0
- package/dist/{adapter-D2JoR-4d.d.mts → adapter-DIx4Rntl.d.mts} +6 -49
- package/dist/adapters-BjeDmKc6.mjs +1 -0
- package/dist/adapters-Bv5aRv3l.mjs +1 -0
- package/dist/adapters-C66XaKkw.mjs +1 -0
- package/dist/adapters-DkVblyML.mjs +1 -0
- package/dist/adapters-uJLWGQJl.mjs +1 -0
- package/dist/browser/index.js +2251 -826
- package/dist/components/index.d.mts +2 -20
- package/dist/components/index.mjs +34 -39
- package/dist/{components-BbbGkTcN.mjs → components-CACff-Lt.mjs} +1154 -317
- package/dist/composables/index.d.mts +18 -17
- package/dist/composables/index.mjs +34 -37
- package/dist/{consola-DiUk9j3y.d.mts → consola-BVzYzeLH.d.mts} +1 -1
- package/dist/{consola-GBy8XRuL.mjs → consola-Ceox8BWi.mjs} +1 -2
- package/dist/constants/index.d.mts +1 -1
- package/dist/constants/index.mjs +3 -5
- package/dist/{createDataTable-cNf6DdHz.mjs → createDataTable-CLI4TALE.mjs} +9 -11
- package/dist/{createGroup-BrZPZudL.mjs → createGroup-Cf6lK9BR.mjs} +7 -9
- package/dist/{createPagination-Wc_vRGNQ.mjs → createPagination-Bu8vE0JW.mjs} +3 -5
- package/dist/{createSelection-BURpoE3p.mjs → createSelection-DvOR2tKk.mjs} +216 -63
- package/dist/{createSingle-BE1vHaZy.mjs → createSingle-Bbcwcq4R.mjs} +3 -5
- package/dist/{createTokens-jwf8-iGn.mjs → createTokens-CMRBDlzN.mjs} +41 -26
- package/dist/{createTrinity-DkwPrPRS.mjs → createTrinity-C_c8eedz.mjs} +10 -13
- package/dist/data-table/adapters/client/index.d.mts +1 -2
- package/dist/data-table/adapters/client/index.mjs +7 -9
- package/dist/data-table/adapters/index.d.mts +4 -4
- package/dist/data-table/adapters/index.mjs +10 -12
- package/dist/data-table/adapters/server/index.d.mts +1 -2
- package/dist/data-table/adapters/server/index.mjs +5 -7
- package/dist/data-table/adapters/virtual/index.d.mts +1 -2
- package/dist/data-table/adapters/virtual/index.mjs +7 -9
- package/dist/data-table/index.d.mts +5 -6
- package/dist/data-table/index.mjs +22 -25
- package/dist/date/index.d.mts +1 -3
- package/dist/date/index.mjs +3932 -3943
- package/dist/features/adapters/flagsmith/index.d.mts +2 -4
- package/dist/features/adapters/flagsmith/index.mjs +2 -3
- package/dist/features/adapters/launchdarkly/index.d.mts +1 -3
- package/dist/features/adapters/launchdarkly/index.mjs +2 -3
- package/dist/features/adapters/posthog/index.d.mts +1 -3
- package/dist/features/adapters/posthog/index.mjs +3 -4
- package/dist/features/index.d.mts +2 -16
- package/dist/features/index.mjs +13 -18
- package/dist/{flagsmith-CHmpPGR7.mjs → flagsmith-CrWUeIhT.mjs} +1 -2
- package/dist/{globals-vN-O052q.mjs → globals-BqRH_jdr.mjs} +2 -3
- package/dist/{htmlElements-d8iBCGpO.mjs → htmlElements-DcYtv0hg.mjs} +7 -10
- package/dist/index-8sflFIN8.d.mts +856 -0
- package/dist/{index-BTMzRHep.d.mts → index-BE848tZ2.d.mts} +938 -889
- package/dist/{index-DRax9EgT.d.mts → index-CKbxWC4t.d.mts} +1358 -542
- package/dist/index-CeNfBYuo.d.mts +46 -0
- package/dist/{index-DdWxDPX3.d.mts → index-CmCMrlt3.d.mts} +3 -3
- package/dist/{index-BFBN5Zl3.d.mts → index-Dor6eAEc.d.mts} +0 -1
- package/dist/{index-UNwEBkQT.d.mts → index-MHkcqY_y.d.mts} +1 -2
- package/dist/{index-BuOz3Rgm.d.mts → index-dJKXAO5D.d.mts} +1 -2
- package/dist/index.d.mts +22 -20
- package/dist/index.mjs +38 -40
- package/dist/json/attributes.json +196 -12
- package/dist/json/importMap.json +40 -0
- package/dist/json/tags.json +86 -0
- package/dist/json/web-types.json +605 -13
- package/dist/{launchdarkly-W8t8ZANX.mjs → launchdarkly-jF2KZGoH.mjs} +1 -2
- package/dist/locale/adapters/index.d.mts +1 -2
- package/dist/locale/adapters/index.mjs +4 -6
- package/dist/locale/adapters/v0/index.d.mts +1 -2
- package/dist/locale/adapters/v0/index.mjs +3 -5
- package/dist/locale/index.d.mts +2 -16
- package/dist/locale/index.mjs +14 -17
- package/dist/logger/adapters/consola/index.d.mts +1 -2
- package/dist/logger/adapters/consola/index.mjs +2 -3
- package/dist/logger/adapters/index.d.mts +4 -4
- package/dist/logger/adapters/index.mjs +6 -8
- package/dist/logger/adapters/pino/index.d.mts +1 -2
- package/dist/logger/adapters/pino/index.mjs +3 -5
- package/dist/logger/adapters/v0/index.d.mts +1 -2
- package/dist/logger/adapters/v0/index.mjs +3 -5
- package/dist/logger/index.d.mts +5 -16
- package/dist/logger/index.mjs +8 -10
- package/dist/{memory-BsZGbGnG.mjs → memory-XCMtkld1.mjs} +1 -2
- package/dist/palettes/ant/generate/index.d.mts +9 -0
- package/dist/palettes/ant/generate/index.mjs +98 -0
- package/dist/palettes/ant/index.d.mts +6 -0
- package/dist/palettes/ant/index.mjs +149 -0
- package/dist/palettes/index.d.mts +12 -0
- package/dist/palettes/index.mjs +1 -0
- package/dist/palettes/leonardo/generate/index.d.mts +10 -0
- package/dist/palettes/leonardo/generate/index.mjs +120 -0
- package/dist/palettes/material/generate/index.d.mts +10 -0
- package/dist/palettes/material/generate/index.mjs +103 -0
- package/dist/palettes/material/index.d.mts +6 -0
- package/dist/palettes/material/index.mjs +173 -0
- package/dist/palettes/md1/index.d.mts +6 -0
- package/dist/palettes/md1/index.mjs +261 -0
- package/dist/palettes/md2/index.d.mts +6 -0
- package/dist/palettes/md2/index.mjs +297 -0
- package/dist/palettes/radix/index.d.mts +6 -0
- package/dist/palettes/radix/index.mjs +439 -0
- package/dist/palettes/tailwind/index.d.mts +6 -0
- package/dist/palettes/tailwind/index.mjs +291 -0
- package/dist/permissions/adapters/index.d.mts +2 -17
- package/dist/permissions/adapters/index.mjs +4 -6
- package/dist/permissions/adapters/v0/index.d.mts +1 -17
- package/dist/permissions/adapters/v0/index.mjs +3 -5
- package/dist/permissions/index.d.mts +1 -16
- package/dist/permissions/index.mjs +12 -15
- package/dist/{pino-DFxkZLiu.mjs → pino-B7tJ3m18.mjs} +2 -4
- package/dist/{pino-p-jDkNQd.d.mts → pino-Bzighnkd.d.mts} +1 -2
- package/dist/{posthog-BOUoZTTf.mjs → posthog-DbPqmaAp.mjs} +2 -4
- package/dist/rules/index.d.mts +2 -0
- package/dist/rules/index.mjs +15 -0
- package/dist/{server-C2R2POGE.mjs → server-CZ6ahbEH.mjs} +2 -4
- package/dist/{server-B-HWxaTQ.d.mts → server-Ch9J86tb.d.mts} +1 -2
- package/dist/storage/adapters/index.d.mts +2 -2
- package/dist/storage/adapters/index.mjs +2 -3
- package/dist/storage/adapters/memory/index.d.mts +1 -1
- package/dist/storage/adapters/memory/index.mjs +2 -3
- package/dist/storage/index.d.mts +3 -16
- package/dist/storage/index.mjs +33 -37
- package/dist/theme/adapters/index.d.mts +1 -16
- package/dist/theme/adapters/index.mjs +4 -6
- package/dist/theme/adapters/v0/index.d.mts +1 -16
- package/dist/theme/adapters/v0/index.mjs +3 -5
- package/dist/theme/index.d.mts +1 -16
- package/dist/theme/index.mjs +13 -16
- package/dist/{toArray-VIn8vYt3.mjs → toArray-VdROPpy-.mjs} +2 -4
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/{useClickOutside-DIi0kjN5.mjs → useClickOutside-YOGwKo7v.mjs} +603 -287
- package/dist/{useFeatures-6O7EPJUS.mjs → useFeatures-BGDgUrdr.mjs} +5 -8
- package/dist/{useLocale-DHjbekzS.mjs → useLocale-C8I_fNAS.mjs} +7 -9
- package/dist/{useLogger-BXqiUvt2.mjs → useLogger-B70T4SgK.mjs} +13 -16
- package/dist/{usePermissions-DFacFVqO.mjs → usePermissions-afVt2qR7.mjs} +5 -7
- package/dist/useRules-7C92Xzyt.mjs +144 -0
- package/dist/{useTheme-D0_1mjTw.mjs → useTheme-jp2wL2FJ.mjs} +11 -13
- package/dist/utilities/index.d.mts +1 -2
- package/dist/utilities/index.mjs +426 -4
- package/dist/{v0-BNXo1ecc.d.mts → v0-1bfmyZ5_.d.mts} +2 -2
- package/dist/{v0-BOxb3nD1.d.mts → v0-1xxC39wf.d.mts} +1 -2
- package/dist/{v0-BYqmw3qM.mjs → v0-B1QQGE4O.mjs} +2 -5
- package/dist/{v0-DHMoZ7dS.d.mts → v0-CAKa6tzG.d.mts} +1 -1
- package/dist/{v0-Dwufx8ae.mjs → v0-CGlkn5u7.mjs} +3 -6
- package/dist/{v0-CfSj99gF.mjs → v0-CHvU3jQE.mjs} +3 -5
- package/dist/{v0-BPzPP8C5.d.mts → v0-CdUL2eOn.d.mts} +1 -2
- package/dist/{v0-C8DBv9mh.mjs → v0-V-cQsuZD.mjs} +3 -5
- package/dist/{v0-Dc5mcpQs.mjs → v0-YAqbXudL.mjs} +3 -5
- package/dist/{virtual-A4e1yrdn.d.mts → virtual-DwBiFA25.d.mts} +1 -2
- package/dist/{virtual-BoTGK6HT.mjs → virtual-eDNVH1fz.mjs} +3 -5
- package/package.json +39 -11
- package/dist/adapter-DcwxFryd.d.mts +0 -97
- package/dist/adapters-BGJKsBrw.mjs +0 -1
- package/dist/adapters-BQ-Lr3PW.mjs +0 -1
- package/dist/adapters-DEXpW9If.mjs +0 -1
- package/dist/adapters-Q9WaOsJp.mjs +0 -1
- package/dist/adapters-SSDVth5e.mjs +0 -1
- package/dist/constants-B8pMSkcW.mjs +0 -1
- package/dist/utilities-Dx8wzGa5.mjs +0 -429
- /package/dist/{adapter-CJIj5ySf.d.mts → adapter-JTFG3Jn8.d.mts} +0 -0
- /package/dist/{index-Bv1VN_j5.d.mts → index-B5ZDDkXv.d.mts} +0 -0
- /package/dist/{index-BDTbJClL.d.mts → index-NsE5nARK.d.mts} +0 -0
- /package/dist/{memory-DVjquu_v.d.mts → memory-BTtRdnNn.d.mts} +0 -0
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
import { i as Extensible, o as ID } from "./index-Dor6eAEc.mjs";
|
|
2
|
+
import { t as ContextTrinity } from "./index-CeNfBYuo.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/composables/createRegistry/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* User-facing input shape for registry tickets.
|
|
7
|
+
*
|
|
8
|
+
* Extend this when defining custom ticket types passed to `register()` and `onboard()`.
|
|
9
|
+
* The registry adds the computed fields (`index`, `valueIsIndex`) automatically — those
|
|
10
|
+
* live on {@link RegistryTicket}, which is the output type returned by `get()` and `values()`.
|
|
11
|
+
*
|
|
12
|
+
* @template V The type of the ticket value.
|
|
13
|
+
*/
|
|
14
|
+
interface RegistryTicketInput<V = unknown> {
|
|
15
|
+
/** The unique identifier. Optional — auto-generated if not provided. */
|
|
16
|
+
id?: ID;
|
|
17
|
+
/** The value associated with the ticket. If not provided, it defaults to the index. */
|
|
18
|
+
value?: V;
|
|
19
|
+
}
|
|
20
|
+
interface RegistryTicket<V = unknown> {
|
|
21
|
+
/** The unique identifier. Is randomly generated if not provided. */
|
|
22
|
+
id: ID;
|
|
23
|
+
/**
|
|
24
|
+
* The index of the ticket in the registry.
|
|
25
|
+
*
|
|
26
|
+
* @remarks Automatically managed by the registry. Updated during reindexing. It's not recommended to manually set this.
|
|
27
|
+
*/
|
|
28
|
+
index: number;
|
|
29
|
+
/** The value associated with the ticket. If not provided, it defaults to the index. */
|
|
30
|
+
value: V;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the value is derived from index.
|
|
33
|
+
*
|
|
34
|
+
* @remarks Set to true when no explicit value is provided during registration. It's not recommended to manually set this.
|
|
35
|
+
*/
|
|
36
|
+
valueIsIndex: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Valid event names for registry operations */
|
|
39
|
+
type RegistryEventName = 'register:ticket' | 'unregister:ticket' | 'update:ticket' | 'clear:registry' | 'reindex:registry';
|
|
40
|
+
/** Maps event names to their payload types */
|
|
41
|
+
type RegistryEventMap<Z extends RegistryTicket> = {
|
|
42
|
+
'register:ticket': Z;
|
|
43
|
+
'unregister:ticket': Z;
|
|
44
|
+
'update:ticket': Z;
|
|
45
|
+
'clear:registry': undefined;
|
|
46
|
+
'reindex:registry': undefined;
|
|
47
|
+
};
|
|
48
|
+
/** Callback signature for registry event listeners */
|
|
49
|
+
type RegistryEventCallback<Z extends RegistryTicket = RegistryTicket, K extends RegistryEventName = RegistryEventName> = (data: RegistryEventMap<Z>[K]) => void;
|
|
50
|
+
/** Resolves callback type: typed for known events, unknown for custom events */
|
|
51
|
+
type EventHandler<Z extends RegistryTicket, K extends string> = K extends RegistryEventName ? (data: RegistryEventMap<Z>[K]) => void : (data: unknown) => void;
|
|
52
|
+
/** Resolves payload type: typed for known events, unknown for custom events */
|
|
53
|
+
type EventPayload<Z extends RegistryTicket, K extends string> = K extends RegistryEventName ? RegistryEventMap<Z>[K] : unknown;
|
|
54
|
+
interface RegistryContext<Z extends RegistryTicketInput = RegistryTicketInput, E extends RegistryTicket & Z = RegistryTicket & Z> {
|
|
55
|
+
/**
|
|
56
|
+
* The collection of tickets in the registry
|
|
57
|
+
*
|
|
58
|
+
* @template ID The type of the ticket ID.
|
|
59
|
+
* @template E The type of the registry ticket.
|
|
60
|
+
*
|
|
61
|
+
* @remarks Read-only view of the internal collection. Use `register`, `unregister`, `upsert`, and `clear` methods to modify.
|
|
62
|
+
*/
|
|
63
|
+
collection: ReadonlyMap<ID, E>;
|
|
64
|
+
/**
|
|
65
|
+
* Clear the entire registry
|
|
66
|
+
*
|
|
67
|
+
* @remarks Removes all tickets from the registry. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
68
|
+
*
|
|
69
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#clear
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
74
|
+
*
|
|
75
|
+
* const registry = createRegistry()
|
|
76
|
+
*
|
|
77
|
+
* registry.register({ id: 'ticket-1' })
|
|
78
|
+
* registry.register({ id: 'ticket-2' })
|
|
79
|
+
*
|
|
80
|
+
* console.log(registry.size) // 2
|
|
81
|
+
*
|
|
82
|
+
* registry.clear()
|
|
83
|
+
*
|
|
84
|
+
* console.log(registry.size) // 0
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
clear: () => void;
|
|
88
|
+
/**
|
|
89
|
+
* Check if a ticket exists by ID
|
|
90
|
+
*
|
|
91
|
+
* @param id The ID of the ticket to check.
|
|
92
|
+
* @remarks Calls `collection.has` internally.
|
|
93
|
+
*
|
|
94
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#has
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
99
|
+
*
|
|
100
|
+
* const registry = createRegistry()
|
|
101
|
+
*
|
|
102
|
+
* registry.register({ id: 'ticket-id' })
|
|
103
|
+
*
|
|
104
|
+
* const exists = registry.has('ticket-id') // true
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
has: (id: ID) => boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Get all registered IDs
|
|
110
|
+
*
|
|
111
|
+
* @remarks Calls `collection.keys` internally with caching. First call is O(n), subsequent calls are O(1) until cache invalidation.
|
|
112
|
+
*
|
|
113
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#keys
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
118
|
+
*
|
|
119
|
+
* const registry = createRegistry()
|
|
120
|
+
*
|
|
121
|
+
* registry.register({ id: 'ticket-1' })
|
|
122
|
+
* registry.register({ id: 'ticket-2' })
|
|
123
|
+
*
|
|
124
|
+
* const ids = registry.keys() // ['ticket-1', 'ticket-2']
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
keys: () => readonly ID[];
|
|
128
|
+
/**
|
|
129
|
+
* Browse for an ID(s) by value
|
|
130
|
+
*
|
|
131
|
+
* @param value The value to browse for.
|
|
132
|
+
* @remarks Returns an array of IDs that share the given value, or undefined if no match is found.
|
|
133
|
+
*
|
|
134
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#browse
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
139
|
+
*
|
|
140
|
+
* const registry = createRegistry()
|
|
141
|
+
*
|
|
142
|
+
* registry.register({ id: 'ticket-1', value: 'common-value' })
|
|
143
|
+
* registry.register({ id: 'ticket-2', value: 'common-value' })
|
|
144
|
+
* registry.register({ id: 'ticket-3', value: 'unique-value' })
|
|
145
|
+
*
|
|
146
|
+
* const common = registry.browse('common-value') // ['ticket-1', 'ticket-2']
|
|
147
|
+
* const unique = registry.browse('unique-value') // ['ticket-3']
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
browse: (value: E['value']) => ID[] | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* lookup a ticket by index number
|
|
153
|
+
*
|
|
154
|
+
* @param index The index number to lookup.
|
|
155
|
+
* @remarks Maps do not support indexing by default, this method provides a way to retrieve an ID based on its index in the registry.
|
|
156
|
+
*
|
|
157
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#lookup
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* const registry = createRegistry()
|
|
162
|
+
*
|
|
163
|
+
* registry.register({ id: 'ticket-1' })
|
|
164
|
+
* registry.register({ id: 'ticket-2' })
|
|
165
|
+
*
|
|
166
|
+
* const ticket1 = registry.lookup(0) // 'ticket-1'
|
|
167
|
+
* const ticket2 = registry.lookup(1) // 'ticket-2'
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
lookup: (index: number) => ID | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* Get a ticket by ID
|
|
173
|
+
*
|
|
174
|
+
* @param id The ID of the ticket to retrieve.
|
|
175
|
+
* @remarks Calls `collection.get` internally.
|
|
176
|
+
*
|
|
177
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#get
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
182
|
+
*
|
|
183
|
+
* const registry = createRegistry()
|
|
184
|
+
*
|
|
185
|
+
* registry.register({ id: 'ticket-id', value: 'some-value' })
|
|
186
|
+
*
|
|
187
|
+
* const ticket = registry.get('ticket-id') // { id: 'ticket-id', index: 0, value: 'some-value', ... }
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
get: (id: ID) => E | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Update or insert a ticket by ID
|
|
193
|
+
*
|
|
194
|
+
* @param id The ID of the ticket to upsert.
|
|
195
|
+
* @param ticket The partial ticket data to update or insert.
|
|
196
|
+
* @remarks If the ticket exists, it will be updated with the provided data. If it doesn't exist, a new ticket will be created with the given ID and data. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
197
|
+
*
|
|
198
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#upsert
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
203
|
+
*
|
|
204
|
+
* const registry = createRegistry()
|
|
205
|
+
*
|
|
206
|
+
* // Insert a new ticket
|
|
207
|
+
* const ticket = registry.upsert('ticket-id', { value: 'initial-value' })
|
|
208
|
+
*
|
|
209
|
+
* // Update the existing ticket
|
|
210
|
+
* const patched = registry.upsert('ticket-id', { value: 'updated-value' })
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
upsert: (id: ID, ticket?: Partial<Z>) => E;
|
|
214
|
+
/**
|
|
215
|
+
* Get all values of registered tickets
|
|
216
|
+
*
|
|
217
|
+
* @remarks Calls `collection.values` internally with caching. First call is O(n), subsequent calls are O(1) until cache invalidation.
|
|
218
|
+
*
|
|
219
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#values
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
224
|
+
*
|
|
225
|
+
* const registry = createRegistry()
|
|
226
|
+
*
|
|
227
|
+
* registry.register({ id: 'ticket-1', value: 'value-1' })
|
|
228
|
+
* registry.register({ id: 'ticket-2', value: 'value-2' })
|
|
229
|
+
*
|
|
230
|
+
* const values = registry.values() // [{ id: 'ticket-1', ... }, { id: 'ticket-2', ... }]
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
values: () => readonly E[];
|
|
234
|
+
/**
|
|
235
|
+
* Get all entries of registered tickets
|
|
236
|
+
*
|
|
237
|
+
* @remarks Calls `collection.entries` internally with caching. First call is O(n), subsequent calls are O(1) until cache invalidation.
|
|
238
|
+
*
|
|
239
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#entries
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
244
|
+
*
|
|
245
|
+
* const registry = createRegistry()
|
|
246
|
+
*
|
|
247
|
+
* registry.register({ id: 'ticket-1', value: 'value-1' })
|
|
248
|
+
* registry.register({ id: 'ticket-2', value: 'value-2' })
|
|
249
|
+
*
|
|
250
|
+
* const entries = registry.entries() // [['ticket-1', { id: 'ticket-1', ... }], ['ticket-2', { id: 'ticket-2', ... }]]
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
entries: () => readonly [ID, E][];
|
|
254
|
+
/**
|
|
255
|
+
* Register a new ticket
|
|
256
|
+
*
|
|
257
|
+
* @param ticket The partial ticket data to register.
|
|
258
|
+
* @remarks If no ID is provided, a unique ID will be generated automatically. If no value is provided, it defaults to the ticket's index. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
259
|
+
*
|
|
260
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#register
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
265
|
+
*
|
|
266
|
+
* const registry = createRegistry()
|
|
267
|
+
*
|
|
268
|
+
* const ticket = registry.register()
|
|
269
|
+
*
|
|
270
|
+
* console.log(ticket) // { id: 'generated-id', index: 0, value: 0, valueIsIndex: true }
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
register: (ticket?: Partial<Z & RegistryTicket>) => E;
|
|
274
|
+
/**
|
|
275
|
+
* Unregister a ticket by ID
|
|
276
|
+
*
|
|
277
|
+
* @param id The ID of the ticket to unregister.
|
|
278
|
+
* @remarks Removes the ticket from the registry and reindexes the remaining tickets. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
279
|
+
*
|
|
280
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#unregister
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
285
|
+
*
|
|
286
|
+
* const registry = createRegistry()
|
|
287
|
+
*
|
|
288
|
+
* registry.register({ id: 'ticket-id' })
|
|
289
|
+
*
|
|
290
|
+
* registry.unregister('ticket-id')
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
unregister: (id: ID) => void;
|
|
294
|
+
/**
|
|
295
|
+
* Reset the index directory and update all tickets
|
|
296
|
+
*
|
|
297
|
+
* @remarks Rebuilds the internal index mapping and ensures all tickets have correct index values. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
298
|
+
*
|
|
299
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#reindex
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
304
|
+
*
|
|
305
|
+
* const registry = createRegistry()
|
|
306
|
+
*
|
|
307
|
+
* registry.register({ id: 'ticket-1' })
|
|
308
|
+
* registry.register({ id: 'ticket-2' })
|
|
309
|
+
*
|
|
310
|
+
* // After some operations that may affect indexing
|
|
311
|
+
* registry.reindex()
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
reindex: () => void;
|
|
315
|
+
/**
|
|
316
|
+
* Seek for a ticket based on direction and optional predicate
|
|
317
|
+
*
|
|
318
|
+
* @param direction The direction to seek ('first' or 'last'). Defaults to 'first'.
|
|
319
|
+
* @param from The index to start seeking from. Defaults to the beginning or end based on direction.
|
|
320
|
+
* @param predicate An optional function to test each ticket. The first ticket that satisfies the predicate will be returned.
|
|
321
|
+
* @remarks This method allows for flexible searching within the registry, either from the start or end, and can filter tickets based on custom criteria.
|
|
322
|
+
*
|
|
323
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#seek
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
328
|
+
*
|
|
329
|
+
* const registry = createRegistry()
|
|
330
|
+
*
|
|
331
|
+
* registry.register({ id: 'ticket-1', value: 'apple' })
|
|
332
|
+
* registry.register({ id: 'ticket-2', value: 'banana' })
|
|
333
|
+
* registry.register({ id: 'ticket-3', value: 'cherry' })
|
|
334
|
+
*
|
|
335
|
+
* // Seek the first ticket
|
|
336
|
+
* const first = registry.seek('first')
|
|
337
|
+
*
|
|
338
|
+
* // Seek the last ticket
|
|
339
|
+
* const last = registry.seek('last')
|
|
340
|
+
*
|
|
341
|
+
* // Seek the first ticket with value 'banana'
|
|
342
|
+
* const banana = registry.seek('first', undefined, ticket => ticket.value === 'banana')
|
|
343
|
+
*
|
|
344
|
+
* // Seek from index 1 to find the next ticket with value starting with 'c'
|
|
345
|
+
* const cherry = registry.seek('first', 1, ticket => (ticket.value as string).startsWith('c'))
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
/**
|
|
349
|
+
* Move a ticket to a new index position
|
|
350
|
+
*
|
|
351
|
+
* @param id The ID of the ticket to move.
|
|
352
|
+
* @param toIndex The target index position. Clamped to valid range.
|
|
353
|
+
* @returns The moved ticket, or undefined if the ticket was not found.
|
|
354
|
+
*
|
|
355
|
+
* @remarks Rebuilds the internal collection order by removing and reinserting the entry at the target position. Triggers a full reindex after the move. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
356
|
+
*
|
|
357
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-registry#move
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
362
|
+
*
|
|
363
|
+
* const registry = createRegistry()
|
|
364
|
+
*
|
|
365
|
+
* registry.onboard([
|
|
366
|
+
* { id: 'a', value: 'alpha' },
|
|
367
|
+
* { id: 'b', value: 'beta' },
|
|
368
|
+
* { id: 'c', value: 'gamma' },
|
|
369
|
+
* ])
|
|
370
|
+
*
|
|
371
|
+
* // Move 'a' from index 0 to index 2
|
|
372
|
+
* registry.move('a', 2)
|
|
373
|
+
*
|
|
374
|
+
* console.log(registry.keys()) // ['b', 'c', 'a']
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
move: (id: ID, toIndex: number) => E | undefined;
|
|
378
|
+
seek: (direction?: 'first' | 'last', from?: number, predicate?: (ticket: E) => boolean) => E | undefined;
|
|
379
|
+
/**
|
|
380
|
+
* Listen for registry events
|
|
381
|
+
*
|
|
382
|
+
* @param event The name of the event to listen for.
|
|
383
|
+
* @param cb The callback function to invoke when the event is emitted.
|
|
384
|
+
* @remarks Must be enabled via the `events` option when creating the registry.
|
|
385
|
+
* Supported events:
|
|
386
|
+
* - `register:ticket` - Emitted when a ticket is registered, receives the ticket as argument
|
|
387
|
+
* - `unregister:ticket` - Emitted when a ticket is unregistered, receives the ticket as argument
|
|
388
|
+
* - `update:ticket` - Emitted when a ticket is updated, receives the updated ticket as argument
|
|
389
|
+
* - `clear:registry` - Emitted when the registry is cleared
|
|
390
|
+
* - `reindex:registry` - Emitted when the registry is reindexed
|
|
391
|
+
*
|
|
392
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#on
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```ts
|
|
396
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
397
|
+
*
|
|
398
|
+
* const registry = createRegistry({ events: true })
|
|
399
|
+
*
|
|
400
|
+
* registry.on('register:ticket', (ticket) => {
|
|
401
|
+
* console.log('Ticket registered:', ticket)
|
|
402
|
+
* })
|
|
403
|
+
*
|
|
404
|
+
* registry.register({ id: 'ticket-id' }) // Console: Ticket registered: { id: 'ticket-id', ... }
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
on: <K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<E, K>) => void;
|
|
408
|
+
/**
|
|
409
|
+
* Stop listening for registry events
|
|
410
|
+
*
|
|
411
|
+
* @param event The name of the event to stop listening for.
|
|
412
|
+
* @param cb The callback function to remove.
|
|
413
|
+
* @remarks Must be enabled via the `events` option when creating the registry.
|
|
414
|
+
*
|
|
415
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#off
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```ts
|
|
419
|
+
* import { onScopeDispose } from 'vue'
|
|
420
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
421
|
+
*
|
|
422
|
+
* const registry = createRegistry({ events: true })
|
|
423
|
+
*
|
|
424
|
+
* function onRegister(ticket) {
|
|
425
|
+
* console.log('Ticket registered:', ticket)
|
|
426
|
+
* }
|
|
427
|
+
*
|
|
428
|
+
* registry.on('register:ticket', onRegister)
|
|
429
|
+
*
|
|
430
|
+
* registry.register({ id: 'ticket-id' }) // Console: Ticket registered: { id: 'ticket-id', ... }
|
|
431
|
+
*
|
|
432
|
+
* onScopeDispose(() => {
|
|
433
|
+
* registry.off('register:ticket', onRegister)
|
|
434
|
+
* })
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
off: <K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<E, K>) => void;
|
|
438
|
+
/**
|
|
439
|
+
* Emit an event with data
|
|
440
|
+
*
|
|
441
|
+
* @param event The name of the event to emit.
|
|
442
|
+
* @param data The data to pass to event listeners.
|
|
443
|
+
* @remarks Must be enabled via the `events` option when creating the registry.
|
|
444
|
+
*
|
|
445
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#emit
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
450
|
+
*
|
|
451
|
+
* const registry = createRegistry({ events: true })
|
|
452
|
+
*
|
|
453
|
+
* registry.on('custom-event', (data) => {
|
|
454
|
+
* console.log('Custom event received:', data)
|
|
455
|
+
* })
|
|
456
|
+
*
|
|
457
|
+
* registry.emit('custom-event', { message: 'Hello, World!' }) // Console: Custom event received: { message: 'Hello, World!' }
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
emit: <K extends Extensible<RegistryEventName>>(event: K, data: EventPayload<E, K>) => void;
|
|
461
|
+
/**
|
|
462
|
+
* Clears the registry and removes all listeners
|
|
463
|
+
*
|
|
464
|
+
* @remarks Disposes of the registry by clearing all tickets and removing all event listeners.
|
|
465
|
+
*
|
|
466
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#dispose
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```ts
|
|
470
|
+
* import { onScopeDispose } from 'vue'
|
|
471
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
472
|
+
*
|
|
473
|
+
* const registry = createRegistry({ events: true })
|
|
474
|
+
*
|
|
475
|
+
* registry.register({ id: 'ticket-id' })
|
|
476
|
+
*
|
|
477
|
+
* onScopeDispose(() => {
|
|
478
|
+
* registry.dispose()
|
|
479
|
+
* })
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
dispose: () => void;
|
|
483
|
+
/**
|
|
484
|
+
* Onboard multiple tickets at once
|
|
485
|
+
*
|
|
486
|
+
* @param registrations An array of partial ticket data to register.
|
|
487
|
+
* @remarks Registers multiple tickets in a single operation and returns the array of registered tickets.
|
|
488
|
+
*
|
|
489
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#onboard
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```ts
|
|
493
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
494
|
+
*
|
|
495
|
+
* const registry = createRegistry()
|
|
496
|
+
*
|
|
497
|
+
* const tickets = registry.onboard([
|
|
498
|
+
* { id: 'ticket-1', value: 'value-1' },
|
|
499
|
+
* { id: 'ticket-2', value: 'value-2' },
|
|
500
|
+
* ])
|
|
501
|
+
*
|
|
502
|
+
* console.log(tickets) // [{ id: 'ticket-1', ... }, { id: 'ticket-2', ... }]
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
onboard: (registrations: Partial<Z & RegistryTicket>[]) => E[];
|
|
506
|
+
/**
|
|
507
|
+
* Offboard multiple tickets at once
|
|
508
|
+
*
|
|
509
|
+
* @param ids An array of ticket IDs to unregister.
|
|
510
|
+
* @remarks Unregisters multiple tickets in a single operation with optimized reindexing.
|
|
511
|
+
*
|
|
512
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#offboard
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```ts
|
|
516
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
517
|
+
*
|
|
518
|
+
* const registry = createRegistry()
|
|
519
|
+
*
|
|
520
|
+
* registry.onboard([
|
|
521
|
+
* { id: 'ticket-1', value: 'value-1' },
|
|
522
|
+
* { id: 'ticket-2', value: 'value-2' },
|
|
523
|
+
* { id: 'ticket-3', value: 'value-3' },
|
|
524
|
+
* ])
|
|
525
|
+
*
|
|
526
|
+
* registry.offboard(['ticket-1', 'ticket-3'])
|
|
527
|
+
*
|
|
528
|
+
* console.log(registry.size) // 1
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
offboard: (ids: ID[]) => void;
|
|
532
|
+
/**
|
|
533
|
+
* The number of tickets in the registry
|
|
534
|
+
*
|
|
535
|
+
* @remarks Reflects the current size of the internal ticket collection.
|
|
536
|
+
*
|
|
537
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#size
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
542
|
+
*
|
|
543
|
+
* const registry = createRegistry()
|
|
544
|
+
*
|
|
545
|
+
* registry.register({ id: 'ticket-1' })
|
|
546
|
+
* registry.register({ id: 'ticket-2' })
|
|
547
|
+
*
|
|
548
|
+
* console.log(registry.size) // 2
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
size: number;
|
|
552
|
+
/**
|
|
553
|
+
* Execute operations in a batch, deferring cache invalidation and event emission until complete
|
|
554
|
+
*
|
|
555
|
+
* @param fn The function containing batch operations.
|
|
556
|
+
* @returns The return value of the batch function.
|
|
557
|
+
* @remarks Useful for bulk operations like onboard(). Invalidation and events happen once at the end, not after each operation.
|
|
558
|
+
*
|
|
559
|
+
* @see https://0.vuetifyjs.com/composables/registration/use-registry#batch
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* ```ts
|
|
563
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
564
|
+
*
|
|
565
|
+
* const registry = createRegistry({ events: true })
|
|
566
|
+
*
|
|
567
|
+
* // Without batch: N invalidations + N events
|
|
568
|
+
* // With batch: 1 invalidation + N events (after all registrations)
|
|
569
|
+
* const tickets = registry.batch(() => {
|
|
570
|
+
* return [
|
|
571
|
+
* registry.register({ id: 'a' }),
|
|
572
|
+
* registry.register({ id: 'b' }),
|
|
573
|
+
* registry.register({ id: 'c' }),
|
|
574
|
+
* ]
|
|
575
|
+
* })
|
|
576
|
+
* ```
|
|
577
|
+
*/
|
|
578
|
+
batch: <R>(fn: () => R) => R;
|
|
579
|
+
}
|
|
580
|
+
interface RegistryOptions {
|
|
581
|
+
/**
|
|
582
|
+
* Enable event emission for registry operations
|
|
583
|
+
*
|
|
584
|
+
* @default false
|
|
585
|
+
* @remarks When enabled, the registry will emit events for operations like registration and unregistration. Listeners can be added using the `on` method.
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* ```ts
|
|
589
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
590
|
+
*
|
|
591
|
+
* const registry = createRegistry({ events: true })
|
|
592
|
+
*
|
|
593
|
+
* registry.on('register:ticket', (ticket) => {
|
|
594
|
+
* console.log('Ticket registered:', ticket)
|
|
595
|
+
* })
|
|
596
|
+
*
|
|
597
|
+
* registry.register({ id: 'ticket-id' }) // Console: Ticket registered: { id: 'ticket-id', ... }
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
events?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* Enable reactive behavior for registry operations
|
|
603
|
+
*
|
|
604
|
+
* @default false
|
|
605
|
+
* @remarks When enabled, the registry will use Vue's shallowReactive to track changes. This is useful for scenarios where you want to reactively update the registry state in response to changes.
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```ts
|
|
609
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
610
|
+
*
|
|
611
|
+
* const registry = createRegistry({ reactive: true })
|
|
612
|
+
*
|
|
613
|
+
* registry.register({ id: 'ticket-id' })
|
|
614
|
+
*
|
|
615
|
+
* console.log(registry.size) // 1
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
618
|
+
reactive?: boolean;
|
|
619
|
+
}
|
|
620
|
+
interface RegistryContextOptions extends RegistryOptions {
|
|
621
|
+
namespace?: string;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Creates a new registry instance.
|
|
625
|
+
*
|
|
626
|
+
* @param options The options for the registry instance.
|
|
627
|
+
* @template Z The type of registry ticket that extends RegistryTicket. Use this to add custom properties to tickets.
|
|
628
|
+
* @template E The type of registry context that extends RegistryContext<Z>. Use this when extending the registry with additional methods.
|
|
629
|
+
* @returns A new registry instance.
|
|
630
|
+
*
|
|
631
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-registry#create-registry
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```ts
|
|
635
|
+
* import { createRegistry } from '@vuetify/v0'
|
|
636
|
+
*
|
|
637
|
+
* const registry = createRegistry()
|
|
638
|
+
*
|
|
639
|
+
* const ticket1 = registry.register({ id: 'user-1', value: { name: 'John' } })
|
|
640
|
+
* const ticket2 = registry.register({ id: 'user-2', value: { name: 'Jane' } })
|
|
641
|
+
*
|
|
642
|
+
* console.log(registry.size) // 2
|
|
643
|
+
* console.log(registry.get('user-1')) // { id: 'user-1', index: 0, value: { name: 'John' }, ... }
|
|
644
|
+
* ```
|
|
645
|
+
*/
|
|
646
|
+
declare function createRegistry<Z extends RegistryTicketInput = RegistryTicketInput, E extends RegistryTicket & Z = RegistryTicket & Z>(options?: RegistryOptions): RegistryContext<Z, E>;
|
|
647
|
+
/**
|
|
648
|
+
* Creates a new registry context.
|
|
649
|
+
*
|
|
650
|
+
* @param options The options for the registry context, including `namespace` (defaults to `'v0:registry'`) and `events`.
|
|
651
|
+
* @template Z The type of registry ticket that extends RegistryTicket. Use this to add custom properties to tickets.
|
|
652
|
+
* @template E The type of registry context that extends RegistryContext<Z>. Use this when extending the registry with additional methods.
|
|
653
|
+
* @returns A new registry context.
|
|
654
|
+
*
|
|
655
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-registry#create-registry-context
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* ```ts
|
|
659
|
+
* import { createRegistryContext } from '@vuetify/v0'
|
|
660
|
+
*
|
|
661
|
+
* // With default namespace 'v0:registry'
|
|
662
|
+
* export const [useItems, provideItems, items] = createRegistryContext()
|
|
663
|
+
*
|
|
664
|
+
* // Or with custom namespace
|
|
665
|
+
* export const [useItems, provideItems, items] = createRegistryContext({ namespace: 'my-items' })
|
|
666
|
+
*
|
|
667
|
+
* // In a parent component:
|
|
668
|
+
* provideItems()
|
|
669
|
+
*
|
|
670
|
+
* // In a child component:
|
|
671
|
+
* const items = useItems()
|
|
672
|
+
* items.register({ id: 'item-1', value: 'Value 1' })
|
|
673
|
+
* ```
|
|
674
|
+
*/
|
|
675
|
+
declare function createRegistryContext<Z extends RegistryTicketInput = RegistryTicketInput, E extends RegistryTicket & Z = RegistryTicket & Z>(_options?: RegistryContextOptions): ContextTrinity<RegistryContext<Z, E>>;
|
|
676
|
+
/**
|
|
677
|
+
* Uses an existing registry from context.
|
|
678
|
+
*
|
|
679
|
+
* @param namespace The namespace for the registry context. Defaults to `'v0:registry'`.
|
|
680
|
+
* @template Z The type of registry ticket that extends RegistryTicket.
|
|
681
|
+
* @template E The type of registry context that extends RegistryContext<Z>.
|
|
682
|
+
* @returns The registry instance.
|
|
683
|
+
*
|
|
684
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-registry#use-registry
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* ```ts
|
|
688
|
+
* import { useRegistry } from '@vuetify/v0'
|
|
689
|
+
*
|
|
690
|
+
* // In a child component (after provideRegistry was called by an ancestor):
|
|
691
|
+
* const registry = useRegistry()
|
|
692
|
+
*
|
|
693
|
+
* registry.register({ id: 'item-1', value: 'Value 1' })
|
|
694
|
+
* ```
|
|
695
|
+
*/
|
|
696
|
+
declare function useRegistry<Z extends RegistryTicketInput = RegistryTicketInput, E extends RegistryTicket & Z = RegistryTicket & Z>(namespace?: string): RegistryContext<Z, E>;
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region src/composables/createTokens/index.d.ts
|
|
699
|
+
interface TokenAlias<T = unknown> {
|
|
700
|
+
[key: string]: unknown;
|
|
701
|
+
$value: T;
|
|
702
|
+
$type?: string;
|
|
703
|
+
$description?: string;
|
|
704
|
+
$extensions?: Record<string, unknown>;
|
|
705
|
+
$deprecated?: boolean | string;
|
|
706
|
+
}
|
|
707
|
+
type TokenPrimitive = string | number | boolean | null | Function;
|
|
708
|
+
type TokenValue = TokenPrimitive | TokenAlias;
|
|
709
|
+
interface TokenCollection {
|
|
710
|
+
[key: string]: TokenValue | TokenCollection;
|
|
711
|
+
}
|
|
712
|
+
type FlatTokenCollection = {
|
|
713
|
+
id: string;
|
|
714
|
+
value: TokenValue;
|
|
715
|
+
};
|
|
716
|
+
interface TokenTicket<Z extends TokenValue = TokenValue> extends RegistryTicket<Z> {}
|
|
717
|
+
interface TokenContext<Z extends TokenTicket> extends RegistryContext<Z> {
|
|
718
|
+
/**
|
|
719
|
+
* Checks if a token is an alias
|
|
720
|
+
*
|
|
721
|
+
* @param token The token to check.
|
|
722
|
+
* @returns True if the token is an alias, false otherwise.
|
|
723
|
+
* @remarks An alias is a string that starts with "{" and ends with "}".
|
|
724
|
+
*
|
|
725
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-tokens#is-alias
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
* ```ts
|
|
729
|
+
* const tokens = createTokens({
|
|
730
|
+
* colors: {
|
|
731
|
+
* primary: '#3b82f6',
|
|
732
|
+
* secondary: '{colors.primary}', // Alias reference
|
|
733
|
+
* },
|
|
734
|
+
* })
|
|
735
|
+
*
|
|
736
|
+
* console.log(tokens.isAlias('{colors.primary}')) // true
|
|
737
|
+
* console.log(tokens.isAlias('#3b82f6')) // false
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
isAlias: (token: unknown) => token is string;
|
|
741
|
+
/**
|
|
742
|
+
* Resolves a token or alias to its value.
|
|
743
|
+
*
|
|
744
|
+
* @param token The token or alias to resolve.
|
|
745
|
+
* @returns The resolved value of the token or alias, or undefined if not found.
|
|
746
|
+
* @remarks This function can resolve nested aliases and supports token paths using dot notation.
|
|
747
|
+
*
|
|
748
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-tokens#resolve
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```ts
|
|
752
|
+
* const tokens = createTokens({
|
|
753
|
+
* colors: {
|
|
754
|
+
* primary: '#3b82f6',
|
|
755
|
+
* secondary: '{colors.primary}', // Alias reference
|
|
756
|
+
* },
|
|
757
|
+
* })
|
|
758
|
+
*
|
|
759
|
+
* console.log(tokens.resolve('{colors.primary}')) // '#3b82f6'
|
|
760
|
+
* console.log(tokens.resolve('{colors.secondary}')) // '#3b82f6'
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
resolve: (token: string | TokenAlias) => unknown | undefined;
|
|
764
|
+
}
|
|
765
|
+
interface TokenOptions extends RegistryOptions {
|
|
766
|
+
/**
|
|
767
|
+
* Whether to flatten nested token structures.
|
|
768
|
+
*
|
|
769
|
+
* @default false
|
|
770
|
+
*/
|
|
771
|
+
flat?: boolean;
|
|
772
|
+
/**
|
|
773
|
+
* An optional prefix to prepend to each token ID during registration.
|
|
774
|
+
*
|
|
775
|
+
* @remarks This is useful for namespacing tokens.
|
|
776
|
+
*/
|
|
777
|
+
prefix?: string;
|
|
778
|
+
}
|
|
779
|
+
interface TokenContextOptions extends TokenOptions, RegistryContextOptions {
|
|
780
|
+
tokens?: TokenCollection;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Creates a new token instance.
|
|
784
|
+
*
|
|
785
|
+
* @param tokens The tokens to use.
|
|
786
|
+
* @param options The options for the token instance.
|
|
787
|
+
* @template Z The type of the token ticket.
|
|
788
|
+
* @template E The type of the token context.
|
|
789
|
+
* @returns A new token instance.
|
|
790
|
+
*
|
|
791
|
+
* @see https://www.designtokens.org/tr/drafts/format/
|
|
792
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-tokens
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* ```ts
|
|
796
|
+
* import { createTokens } from '@vuetify/v0'
|
|
797
|
+
*
|
|
798
|
+
* const tokens = createTokens({
|
|
799
|
+
* colors: {
|
|
800
|
+
* primary: '#3b82f6',
|
|
801
|
+
* secondary: '{colors.primary}', // Alias reference
|
|
802
|
+
* },
|
|
803
|
+
* })
|
|
804
|
+
*
|
|
805
|
+
* console.log(tokens.resolve('{colors.primary}')) // '#3b82f6'
|
|
806
|
+
* console.log(tokens.resolve('{colors.secondary}')) // '#3b82f6'
|
|
807
|
+
* ```
|
|
808
|
+
*/
|
|
809
|
+
declare function createTokens<Z extends TokenTicket = TokenTicket, E extends TokenContext<Z> = TokenContext<Z>>(tokens?: TokenCollection, options?: TokenOptions): E;
|
|
810
|
+
/**
|
|
811
|
+
* Creates a new token context.
|
|
812
|
+
*
|
|
813
|
+
* @param namespace The namespace for the token context.
|
|
814
|
+
* @param tokens The tokens to use.
|
|
815
|
+
* @template Z The type of the token ticket.
|
|
816
|
+
* @template E The type of the token context.
|
|
817
|
+
* @returns A new token context.
|
|
818
|
+
*
|
|
819
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-tokens
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* ```ts
|
|
823
|
+
* import { createTokensContext } from '@vuetify/v0'
|
|
824
|
+
*
|
|
825
|
+
* export const [useTokens, provideTokens, context] = createTokensContext({
|
|
826
|
+
* namespace: 'v0:tokens',
|
|
827
|
+
* tokens: {
|
|
828
|
+
* colors: {
|
|
829
|
+
* primary: '#3b82f6',
|
|
830
|
+
* secondary: '{colors.primary}', // Alias reference
|
|
831
|
+
* },
|
|
832
|
+
* },
|
|
833
|
+
* })
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
declare function createTokensContext<Z extends TokenTicket = TokenTicket, E extends TokenContext<Z> = TokenContext<Z>>(_options: TokenContextOptions): ContextTrinity<E>;
|
|
837
|
+
/**
|
|
838
|
+
* Returns the current tokens instance.
|
|
839
|
+
*
|
|
840
|
+
* @param namespace The namespace for the tokens context. Defaults to `'v0:tokens'`.
|
|
841
|
+
* @returns The current tokens instance.
|
|
842
|
+
*
|
|
843
|
+
* @see https://0.vuetifyjs.com/composables/registration/create-tokens
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```vue
|
|
847
|
+
* <script setup lang="ts">
|
|
848
|
+
* import { useTokens } from '@vuetify/v0'
|
|
849
|
+
*
|
|
850
|
+
* const tokens = useTokens()
|
|
851
|
+
* </script>
|
|
852
|
+
* ```
|
|
853
|
+
*/
|
|
854
|
+
declare function useTokens<Z extends TokenTicket = TokenTicket, E extends TokenContext<Z> = TokenContext<Z>>(namespace?: string): E;
|
|
855
|
+
//#endregion
|
|
856
|
+
export { useRegistry as C, createRegistryContext as S, RegistryEventName as _, TokenContextOptions as a, RegistryTicketInput as b, TokenTicket as c, createTokensContext as d, useTokens as f, RegistryEventMap as g, RegistryEventCallback as h, TokenContext as i, TokenValue as l, RegistryContextOptions as m, TokenAlias as n, TokenOptions as o, RegistryContext as p, TokenCollection as r, TokenPrimitive as s, FlatTokenCollection as t, createTokens as u, RegistryOptions as v, createRegistry as x, RegistryTicket as y };
|