@vuetify/v0 0.0.14 → 0.0.15
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/dist/browser/index.js +2439 -820
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.mjs +5 -5
- package/dist/{components-CziOUEkN.mjs → components-Cf1h368z.mjs} +570 -44
- package/dist/composables/index.d.mts +2 -3
- package/dist/composables/index.mjs +4 -4
- package/dist/{composables-CGvbvF3U.mjs → composables-CrW3IMUM.mjs} +1813 -792
- package/dist/constants/index.d.mts +1 -1
- package/dist/constants/index.mjs +1 -1
- package/dist/{globals-D7kNBw5Q.mjs → globals-CqryJ9G3.mjs} +1 -1
- package/dist/index-BPAr2atm.d.mts +70 -0
- package/dist/index-CQcSUYj_.d.mts +1120 -0
- package/dist/{index-CQjOW_w5.d.mts → index-CkmnMjE3.d.mts} +1754 -162
- package/dist/index.d.mts +5 -6
- package/dist/index.mjs +5 -5
- package/dist/utilities/index.d.mts +2 -2
- package/dist/utilities/index.mjs +2 -2
- package/dist/utilities-C6o-keMm.mjs +135 -0
- package/package.json +1 -1
- package/dist/index-CSdGoUCI.d.mts +0 -17
- package/dist/index-CUnI4hGb.d.mts +0 -815
- package/dist/index-D-EP6KrS.d.mts +0 -812
- package/dist/utilities-C26nB74O.mjs +0 -63
- /package/dist/{index-8AIxAM2d.d.mts → index-BmxOG13-.d.mts} +0 -0
|
@@ -1,812 +0,0 @@
|
|
|
1
|
-
import { i as ID } from "./index-DY7-T630.mjs";
|
|
2
|
-
import { App, ComputedRef, InjectionKey, MaybeRef, Reactive, Ref } from "vue";
|
|
3
|
-
|
|
4
|
-
//#region src/composables/createTrinity/index.d.ts
|
|
5
|
-
|
|
6
|
-
type ContextTrinity<Z = unknown> = readonly [() => Z, (context?: Z, app?: App) => Z, Z];
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new trinity for a context composable and its provider.
|
|
9
|
-
*
|
|
10
|
-
* @param useContext The function that retrieves/uses the context (typically named `useContext`).
|
|
11
|
-
* @param provideContext The function that provides the context to descendants.
|
|
12
|
-
* @param context The default context instance to use when no custom context is provided.
|
|
13
|
-
* @template Z The type of the context.
|
|
14
|
-
* @returns A readonly tuple containing: [useContext function, provideContext wrapper function, default context instance].
|
|
15
|
-
*
|
|
16
|
-
* @remarks The trinity pattern is a foundational pattern used throughout the codebase for creating reusable context systems. It provides three related elements:
|
|
17
|
-
*
|
|
18
|
-
* 1. A function to retrieve/use the context
|
|
19
|
-
* 2. A function to provide the context (with default value support)
|
|
20
|
-
* 3. The default context instance
|
|
21
|
-
*
|
|
22
|
-
* The returned tuple is readonly (using `as const`) to ensure proper type inference.
|
|
23
|
-
*
|
|
24
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-trinity#create-trinity
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* interface MyContext {
|
|
29
|
-
* foo: string
|
|
30
|
-
* bar: number
|
|
31
|
-
* }
|
|
32
|
-
*
|
|
33
|
-
* export function createMyFeature<E extends MyContext = MyContext>() {
|
|
34
|
-
* const [useContext, _provideContext] = createContext<E>('my-context')
|
|
35
|
-
*
|
|
36
|
-
* const context = { foo: 'hello', bar: 42 }
|
|
37
|
-
*
|
|
38
|
-
* function provideContext (_context: E = context, app?: App): E {
|
|
39
|
-
* return _provideContext(_context, app)
|
|
40
|
-
* }
|
|
41
|
-
*
|
|
42
|
-
* return createTrinity<E>(useContext, provideContext, context)
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
declare function createTrinity<Z = unknown>(useContext: () => Z, provideContext: (_context?: Z, app?: App) => Z, context: Z): ContextTrinity<Z>;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/composables/useRegistry/index.d.ts
|
|
49
|
-
interface RegistryTicket {
|
|
50
|
-
/** The unique identifier. Is randomly generated if not provided. */
|
|
51
|
-
id: ID;
|
|
52
|
-
/**
|
|
53
|
-
* The index of the ticket in the registry.
|
|
54
|
-
*
|
|
55
|
-
* @remarks Automatically managed by the registry. Updated during reindexing. It's not recommended to manually set this.
|
|
56
|
-
*/
|
|
57
|
-
index: number;
|
|
58
|
-
/** The value associated with the ticket. If not provided, it defaults to the index. */
|
|
59
|
-
value: any;
|
|
60
|
-
/**
|
|
61
|
-
* Whether the value is derived from index.
|
|
62
|
-
*
|
|
63
|
-
* @remarks Set to true when no explicit value is provided during registration. It's not recommended to manually set this.
|
|
64
|
-
*/
|
|
65
|
-
valueIsIndex: boolean;
|
|
66
|
-
}
|
|
67
|
-
interface RegistryContext<Z extends RegistryTicket = RegistryTicket> {
|
|
68
|
-
/**
|
|
69
|
-
* The collection of tickets in the registry
|
|
70
|
-
*
|
|
71
|
-
* @template ID The type of the ticket ID.
|
|
72
|
-
* @template Z The type of the registry ticket.
|
|
73
|
-
*
|
|
74
|
-
* @remarks Exposed for read-only access and advanced use cases. **Warning:** Direct mutation may cause inconsistencies in indexes, catalogs, and caches. Always prefer using the provided methods (`register`, `unregister`, etc.) to maintain internal consistency.
|
|
75
|
-
*/
|
|
76
|
-
collection: Map<ID, Z>;
|
|
77
|
-
/**
|
|
78
|
-
* Clear the entire registry
|
|
79
|
-
*
|
|
80
|
-
* @remarks Removes all tickets from the registry. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
81
|
-
*
|
|
82
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#clear
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
87
|
-
*
|
|
88
|
-
* const registry = useRegistry()
|
|
89
|
-
*
|
|
90
|
-
* registry.register({ id: 'ticket-1' })
|
|
91
|
-
* registry.register({ id: 'ticket-2' })
|
|
92
|
-
*
|
|
93
|
-
* console.log(registry.size) // 2
|
|
94
|
-
*
|
|
95
|
-
* registry.clear()
|
|
96
|
-
*
|
|
97
|
-
* console.log(registry.size) // 0
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
clear: () => void;
|
|
101
|
-
/**
|
|
102
|
-
* Check if a ticket exists by ID
|
|
103
|
-
*
|
|
104
|
-
* @param id The ID of the ticket to check.
|
|
105
|
-
* @remarks Calls `collection.has` internally.
|
|
106
|
-
*
|
|
107
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#has
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```ts
|
|
111
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
112
|
-
*
|
|
113
|
-
* const registry = useRegistry()
|
|
114
|
-
*
|
|
115
|
-
* registry.register({ id: 'ticket-id' })
|
|
116
|
-
*
|
|
117
|
-
* const exists = registry.has('ticket-id') // true
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
has: (id: ID) => boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Get all registered IDs
|
|
123
|
-
*
|
|
124
|
-
* @remarks Calls `collection.keys` internally with caching. First call is O(n), subsequent calls are O(1) until cache invalidation.
|
|
125
|
-
*
|
|
126
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#keys
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```ts
|
|
130
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
131
|
-
*
|
|
132
|
-
* const registry = useRegistry()
|
|
133
|
-
*
|
|
134
|
-
* registry.register({ id: 'ticket-1' })
|
|
135
|
-
* registry.register({ id: 'ticket-2' })
|
|
136
|
-
*
|
|
137
|
-
* const ids = registry.keys() // ['ticket-1', 'ticket-2']
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
keys: () => ID[];
|
|
141
|
-
/**
|
|
142
|
-
* Browse for an ID(s) by value
|
|
143
|
-
*
|
|
144
|
-
* @param value The value to browse for.
|
|
145
|
-
* @remarks Returns a single ID or an array of IDs if multiple tickets share the same value.
|
|
146
|
-
*
|
|
147
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#browse
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
152
|
-
*
|
|
153
|
-
* const registry = useRegistry()
|
|
154
|
-
*
|
|
155
|
-
* registry.register({ id: 'ticket-1', value: 'common-value' })
|
|
156
|
-
* registry.register({ id: 'ticket-2', value: 'common-value' })
|
|
157
|
-
* registry.register({ id: 'ticket-3', value: 'unique-value' })
|
|
158
|
-
*
|
|
159
|
-
* const common = registry.browse('common-value') // ['ticket-1', 'ticket-2']
|
|
160
|
-
* const unique = registry.browse('unique-value') // 'ticket-3'
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
browse: (value: unknown) => ID | ID[] | undefined;
|
|
164
|
-
/**
|
|
165
|
-
* lookup a ticket by index number
|
|
166
|
-
*
|
|
167
|
-
* @param index The index number to lookup.
|
|
168
|
-
* @remarks Maps do not support indexing by default, this method provides a way to retrieve an ID based on its index in the registry.
|
|
169
|
-
*
|
|
170
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#lookup
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* const registry = useRegistry()
|
|
175
|
-
*
|
|
176
|
-
* registry.register({ id: 'ticket-1' })
|
|
177
|
-
* registry.register({ id: 'ticket-2' })
|
|
178
|
-
*
|
|
179
|
-
* const ticket1 = registry.lookup(0) // 'ticket-1'
|
|
180
|
-
* const ticket2 = registry.lookup(1) // 'ticket-2'
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
lookup: (index: number) => ID | undefined;
|
|
184
|
-
/**
|
|
185
|
-
* Get a ticket by ID
|
|
186
|
-
*
|
|
187
|
-
* @param id The ID of the ticket to retrieve.
|
|
188
|
-
* @remarks Calls `collection.get` internally.
|
|
189
|
-
*
|
|
190
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#get
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```ts
|
|
194
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
195
|
-
*
|
|
196
|
-
* const registry = useRegistry()
|
|
197
|
-
*
|
|
198
|
-
* registry.register({ id: 'ticket-id', value: 'some-value' })
|
|
199
|
-
*
|
|
200
|
-
* const ticket = registry.get('ticket-id') // { id: 'ticket-id', index: 0, value: 'some-value', ... }
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
get: (id: ID) => Z | undefined;
|
|
204
|
-
/**
|
|
205
|
-
* Update or insert a ticket by ID
|
|
206
|
-
*
|
|
207
|
-
* @param id The ID of the ticket to upsert.
|
|
208
|
-
* @param ticket The partial ticket data to update or insert.
|
|
209
|
-
* @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()`.
|
|
210
|
-
*
|
|
211
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#upsert
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```ts
|
|
215
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
216
|
-
*
|
|
217
|
-
* const registry = useRegistry()
|
|
218
|
-
*
|
|
219
|
-
* // Insert a new ticket
|
|
220
|
-
* const ticket = registry.upsert('ticket-id', { value: 'initial-value' })
|
|
221
|
-
*
|
|
222
|
-
* // Update the existing ticket
|
|
223
|
-
* const patched = registry.upsert('ticket-id', { value: 'updated-value' })
|
|
224
|
-
* ```
|
|
225
|
-
*/
|
|
226
|
-
upsert: (id: ID, ticket?: Partial<Z>) => Z;
|
|
227
|
-
/**
|
|
228
|
-
* Get all values of registered tickets
|
|
229
|
-
*
|
|
230
|
-
* @remarks Calls `collection.values` internally with caching. First call is O(n), subsequent calls are O(1) until cache invalidation.
|
|
231
|
-
*
|
|
232
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#values
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* ```ts
|
|
236
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
237
|
-
*
|
|
238
|
-
* const registry = useRegistry()
|
|
239
|
-
*
|
|
240
|
-
* registry.register({ id: 'ticket-1', value: 'value-1' })
|
|
241
|
-
* registry.register({ id: 'ticket-2', value: 'value-2' })
|
|
242
|
-
*
|
|
243
|
-
* const values = registry.values() // [{ id: 'ticket-1', ... }, { id: 'ticket-2', ... }]
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
values: () => Z[];
|
|
247
|
-
/**
|
|
248
|
-
* Get all entries of registered tickets
|
|
249
|
-
*
|
|
250
|
-
* @remarks Calls `collection.entries` internally with caching. First call is O(n), subsequent calls are O(1) until cache invalidation.
|
|
251
|
-
*
|
|
252
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#entries
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
257
|
-
*
|
|
258
|
-
* const registry = useRegistry()
|
|
259
|
-
*
|
|
260
|
-
* registry.register({ id: 'ticket-1', value: 'value-1' })
|
|
261
|
-
* registry.register({ id: 'ticket-2', value: 'value-2' })
|
|
262
|
-
*
|
|
263
|
-
* const entries = registry.entries() // [['ticket-1', { id: 'ticket-1', ... }], ['ticket-2', { id: 'ticket-2', ... }]]
|
|
264
|
-
* ```
|
|
265
|
-
*/
|
|
266
|
-
entries: () => [ID, Z][];
|
|
267
|
-
/**
|
|
268
|
-
* Register a new ticket
|
|
269
|
-
*
|
|
270
|
-
* @param ticket The partial ticket data to register.
|
|
271
|
-
* @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()`.
|
|
272
|
-
*
|
|
273
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#register
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```ts
|
|
277
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
278
|
-
*
|
|
279
|
-
* const registry = useRegistry()
|
|
280
|
-
*
|
|
281
|
-
* const ticket = registry.register()
|
|
282
|
-
*
|
|
283
|
-
* console.log(ticket) // { id: 'generated-id', index: 0, value: 0, valueIsIndex: true }
|
|
284
|
-
* ```
|
|
285
|
-
*/
|
|
286
|
-
register: (ticket?: Partial<Z>) => Z;
|
|
287
|
-
/**
|
|
288
|
-
* Unregister an ticket by ID
|
|
289
|
-
*
|
|
290
|
-
* @param id The ID of the ticket to unregister.
|
|
291
|
-
* @remarks Removes the ticket from the registry and reindexes the remaining tickets. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
292
|
-
*
|
|
293
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#unregister
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
* ```ts
|
|
297
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
298
|
-
*
|
|
299
|
-
* const registry = useRegistry()
|
|
300
|
-
*
|
|
301
|
-
* registry.register({ id: 'ticket-id' })
|
|
302
|
-
*
|
|
303
|
-
* registry.unregister('ticket-id')
|
|
304
|
-
* ```
|
|
305
|
-
*/
|
|
306
|
-
unregister: (id: ID) => void;
|
|
307
|
-
/**
|
|
308
|
-
* Reset the index directory and update all tickets
|
|
309
|
-
*
|
|
310
|
-
* @remarks Rebuilds the internal index mapping and ensures all tickets have correct index values. This operation invalidates cached results from `keys()`, `values()`, and `entries()`.
|
|
311
|
-
*
|
|
312
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#reindex
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* ```ts
|
|
316
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
317
|
-
*
|
|
318
|
-
* const registry = useRegistry()
|
|
319
|
-
*
|
|
320
|
-
* registry.register({ id: 'ticket-1' })
|
|
321
|
-
* registry.register({ id: 'ticket-2' })
|
|
322
|
-
*
|
|
323
|
-
* // After some operations that may affect indexing
|
|
324
|
-
* registry.reindex()
|
|
325
|
-
* ```
|
|
326
|
-
*/
|
|
327
|
-
reindex: () => void;
|
|
328
|
-
/**
|
|
329
|
-
* Seek for a ticket based on direction and optional predicate
|
|
330
|
-
*
|
|
331
|
-
* @param direction The direction to seek ('first' or 'last'). Defaults to 'first'.
|
|
332
|
-
* @param from The index to start seeking from. Defaults to the beginning or end based on direction.
|
|
333
|
-
* @param predicate An optional function to test each ticket. The first ticket that satisfies the predicate will be returned.
|
|
334
|
-
* @remarks This method allows for flexible searching within the registry, either from the start or end, and can filter tickets based on custom criteria.
|
|
335
|
-
*
|
|
336
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#seek
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* ```ts
|
|
340
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
341
|
-
*
|
|
342
|
-
* const registry = useRegistry()
|
|
343
|
-
*
|
|
344
|
-
* registry.register({ id: 'ticket-1', value: 'apple' })
|
|
345
|
-
* registry.register({ id: 'ticket-2', value: 'banana' })
|
|
346
|
-
* registry.register({ id: 'ticket-3', value: 'cherry' })
|
|
347
|
-
*
|
|
348
|
-
* // Seek the first ticket
|
|
349
|
-
* const first = registry.seek('first')
|
|
350
|
-
*
|
|
351
|
-
* // Seek the last ticket
|
|
352
|
-
* const last = registry.seek('last')
|
|
353
|
-
*
|
|
354
|
-
* // Seek the first ticket with value 'banana'
|
|
355
|
-
* const banana = registry.seek('first', undefined, ticket => ticket.value === 'banana')
|
|
356
|
-
*
|
|
357
|
-
* // Seek from index 1 to find the next ticket with value starting with 'c'
|
|
358
|
-
* const cherry = registry.seek('first', 1, ticket => (ticket.value as string).startsWith('c'))
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
seek: (direction?: 'first' | 'last', from?: number, predicate?: (ticket: Z) => boolean) => Z | undefined;
|
|
362
|
-
/**
|
|
363
|
-
* Listen for registry events
|
|
364
|
-
*
|
|
365
|
-
* @param event The name of the event to listen for.
|
|
366
|
-
* @param cb The callback function to invoke when the event is emitted.
|
|
367
|
-
* @remarks Must be enabled via the `events` option when creating the registry.
|
|
368
|
-
* Supported events:
|
|
369
|
-
* - `register:ticket` - Emitted when a ticket is registered, receives the ticket as argument
|
|
370
|
-
* - `unregister:ticket` - Emitted when a ticket is unregistered, receives the ticket as argument
|
|
371
|
-
* - `update:ticket` - Emitted when a ticket is updated, receives the updated ticket as argument
|
|
372
|
-
* - `clear:registry` - Emitted when the registry is cleared
|
|
373
|
-
*
|
|
374
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#on
|
|
375
|
-
*
|
|
376
|
-
* @example
|
|
377
|
-
* ```ts
|
|
378
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
379
|
-
*
|
|
380
|
-
* const registry = useRegistry({ events: true })
|
|
381
|
-
*
|
|
382
|
-
* registry.on('register:ticket', (ticket) => {
|
|
383
|
-
* console.log('Ticket registered:', ticket)
|
|
384
|
-
* })
|
|
385
|
-
*
|
|
386
|
-
* registry.register({ id: 'ticket-id' }) // Console: Ticket registered: { id: 'ticket-id', ... }
|
|
387
|
-
* ```
|
|
388
|
-
*/
|
|
389
|
-
on: (event: string, cb: Function) => void;
|
|
390
|
-
/**
|
|
391
|
-
* Stop listening for registry events
|
|
392
|
-
*
|
|
393
|
-
* @param event The name of the event to stop listening for.
|
|
394
|
-
* @param cb The callback function to remove.
|
|
395
|
-
* @remarks Must be enabled via the `events` option when creating the registry.
|
|
396
|
-
*
|
|
397
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#off
|
|
398
|
-
*
|
|
399
|
-
* @example
|
|
400
|
-
* ```ts
|
|
401
|
-
* import { onScopeDispose } from 'vue'
|
|
402
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
403
|
-
*
|
|
404
|
-
* const registry = useRegistry({ events: true })
|
|
405
|
-
*
|
|
406
|
-
* function onRegister(ticket) {
|
|
407
|
-
* console.log('Ticket registered:', ticket)
|
|
408
|
-
* }
|
|
409
|
-
*
|
|
410
|
-
* registry.on('register:ticket', onRegister)
|
|
411
|
-
*
|
|
412
|
-
* registry.register({ id: 'ticket-id' }) // Console: Ticket registered: { id: 'ticket-id', ... }
|
|
413
|
-
*
|
|
414
|
-
* onScopeDispose(() => {
|
|
415
|
-
* registry.off('register:ticket', onRegister)
|
|
416
|
-
* })
|
|
417
|
-
* ```
|
|
418
|
-
*/
|
|
419
|
-
off: (event: string, cb: Function) => void;
|
|
420
|
-
/**
|
|
421
|
-
* Emit an event with data
|
|
422
|
-
*
|
|
423
|
-
* @param event The name of the event to emit.
|
|
424
|
-
* @param data The data to pass to event listeners.
|
|
425
|
-
* @remarks Must be enabled via the `events` option when creating the registry.
|
|
426
|
-
*
|
|
427
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#emit
|
|
428
|
-
*
|
|
429
|
-
* @example
|
|
430
|
-
* ```ts
|
|
431
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
432
|
-
*
|
|
433
|
-
* const registry = useRegistry({ events: true })
|
|
434
|
-
*
|
|
435
|
-
* registry.on('custom-event', (data) => {
|
|
436
|
-
* console.log('Custom event received:', data)
|
|
437
|
-
* })
|
|
438
|
-
*
|
|
439
|
-
* registry.emit('custom-event', { message: 'Hello, World!' }) // Console: Custom event received: { message: 'Hello, World!' }
|
|
440
|
-
* ```
|
|
441
|
-
*/
|
|
442
|
-
emit: (event: string, data: unknown) => void;
|
|
443
|
-
/**
|
|
444
|
-
* Clears the registry and removes all listeners
|
|
445
|
-
*
|
|
446
|
-
* @remarks Disposes of the registry by clearing all tickets and removing all event listeners.
|
|
447
|
-
*
|
|
448
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#dispose
|
|
449
|
-
*
|
|
450
|
-
* @example
|
|
451
|
-
* ```ts
|
|
452
|
-
* import { onScopeDispose } from 'vue'
|
|
453
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
454
|
-
*
|
|
455
|
-
* const registry = useRegistry({ events: true })
|
|
456
|
-
*
|
|
457
|
-
* registry.register({ id: 'ticket-id' })
|
|
458
|
-
*
|
|
459
|
-
* onScopeDispose(() => {
|
|
460
|
-
* registry.dispose()
|
|
461
|
-
* })
|
|
462
|
-
* ```
|
|
463
|
-
*/
|
|
464
|
-
dispose: () => void;
|
|
465
|
-
/**
|
|
466
|
-
* Onboard multiple tickets at once
|
|
467
|
-
*
|
|
468
|
-
* @param registrations An array of partial ticket data to register.
|
|
469
|
-
* @remarks Registers multiple tickets in a single operation and returns the array of registered tickets.
|
|
470
|
-
*
|
|
471
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#onboard
|
|
472
|
-
*
|
|
473
|
-
* @example
|
|
474
|
-
* ```ts
|
|
475
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
476
|
-
*
|
|
477
|
-
* const registry = useRegistry()
|
|
478
|
-
*
|
|
479
|
-
* const tickets = registry.onboard([
|
|
480
|
-
* { id: 'ticket-1', value: 'value-1' },
|
|
481
|
-
* { id: 'ticket-2', value: 'value-2' },
|
|
482
|
-
* ])
|
|
483
|
-
*
|
|
484
|
-
* console.log(tickets) // [{ id: 'ticket-1', ... }, { id: 'ticket-2', ... }]
|
|
485
|
-
* ```
|
|
486
|
-
*/
|
|
487
|
-
onboard: (registrations: Partial<Z>[]) => Z[];
|
|
488
|
-
/**
|
|
489
|
-
* The number of tickets in the registry
|
|
490
|
-
*
|
|
491
|
-
* @remarks Reflects the current size of the internal ticket collection.
|
|
492
|
-
*
|
|
493
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#size
|
|
494
|
-
*
|
|
495
|
-
* @example
|
|
496
|
-
* ```ts
|
|
497
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
498
|
-
*
|
|
499
|
-
* const registry = useRegistry()
|
|
500
|
-
*
|
|
501
|
-
* registry.register({ id: 'ticket-1' })
|
|
502
|
-
* registry.register({ id: 'ticket-2' })
|
|
503
|
-
*
|
|
504
|
-
* console.log(registry.size) // 2
|
|
505
|
-
* ```
|
|
506
|
-
*/
|
|
507
|
-
size: number;
|
|
508
|
-
}
|
|
509
|
-
interface RegistryOptions {
|
|
510
|
-
/**
|
|
511
|
-
* Enable event emission for registry operations
|
|
512
|
-
*
|
|
513
|
-
* @default false
|
|
514
|
-
* @remarks When enabled, the registry will emit events for operations like registration and unregistration. Listeners can be added using the `on` method.
|
|
515
|
-
*
|
|
516
|
-
* @example
|
|
517
|
-
* ```ts
|
|
518
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
519
|
-
*
|
|
520
|
-
* const registry = useRegistry({ events: true })
|
|
521
|
-
*
|
|
522
|
-
* registry.on('register:ticket', (ticket) => {
|
|
523
|
-
* console.log('Ticket registered:', ticket)
|
|
524
|
-
* })
|
|
525
|
-
*
|
|
526
|
-
* registry.register({ id: 'ticket-id' }) // Console: Ticket registered: { id: 'ticket-id', ... }
|
|
527
|
-
* ```
|
|
528
|
-
*/
|
|
529
|
-
events?: boolean;
|
|
530
|
-
}
|
|
531
|
-
interface RegistryContextOptions extends RegistryOptions {
|
|
532
|
-
namespace: string;
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Creates a new registry instance.
|
|
536
|
-
*
|
|
537
|
-
* @param options The options for the registry instance.
|
|
538
|
-
* @template Z The type of registry ticket that extends RegistryTicket. Use this to add custom properties to tickets.
|
|
539
|
-
* @template E The type of registry context that extends RegistryContext<Z>. Use this when extending the registry with additional methods.
|
|
540
|
-
* @returns A new registry instance.
|
|
541
|
-
*
|
|
542
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#use-registry
|
|
543
|
-
*
|
|
544
|
-
* @example
|
|
545
|
-
* ```ts
|
|
546
|
-
* import { useRegistry } from '@vuetify/v0'
|
|
547
|
-
*
|
|
548
|
-
* const registry = useRegistry()
|
|
549
|
-
*
|
|
550
|
-
* const ticket1 = registry.register({ id: 'user-1', value: { name: 'John' } })
|
|
551
|
-
* const ticket2 = registry.register({ id: 'user-2', value: { name: 'Jane' } })
|
|
552
|
-
*
|
|
553
|
-
* console.log(registry.size) // 2
|
|
554
|
-
* console.log(registry.get('user-1')) // { id: 'user-1', index: 0, value: { name: 'John' }, ... }
|
|
555
|
-
* ```
|
|
556
|
-
*/
|
|
557
|
-
declare function useRegistry<Z extends RegistryTicket = RegistryTicket, E extends RegistryContext<Z> = RegistryContext<Z>>(options?: RegistryOptions): E;
|
|
558
|
-
/**
|
|
559
|
-
* Creates a new registry context.
|
|
560
|
-
*
|
|
561
|
-
* @param namespace The namespace for the registry context.
|
|
562
|
-
* @param options The options for the registry context.
|
|
563
|
-
* @template Z The type of registry ticket that extends RegistryTicket. Use this to add custom properties to tickets.
|
|
564
|
-
* @template E The type of registry context that extends RegistryContext<Z>. Use this when extending the registry with additional methods.
|
|
565
|
-
* @returns A new registry context.
|
|
566
|
-
*
|
|
567
|
-
* @see https://0.vuetifyjs.com/composables/registration/use-registry#create-registry-context
|
|
568
|
-
*
|
|
569
|
-
* @example
|
|
570
|
-
* ```ts
|
|
571
|
-
* import { createRegistryContext } from '@vuetify/v0'
|
|
572
|
-
*
|
|
573
|
-
* export const [useItems, provideItems, items] = createRegistryContext('items')
|
|
574
|
-
*
|
|
575
|
-
* // In a parent component:
|
|
576
|
-
* provideItems()
|
|
577
|
-
*
|
|
578
|
-
* // In a child component:
|
|
579
|
-
* const items = useItems()
|
|
580
|
-
* items.register({ id: 'item-1', value: 'Value 1' })
|
|
581
|
-
* ```
|
|
582
|
-
*/
|
|
583
|
-
declare function createRegistryContext<Z extends RegistryTicket = RegistryTicket, E extends RegistryContext<Z> = RegistryContext<Z>>(_options: RegistryContextOptions): ContextTrinity<E>;
|
|
584
|
-
//#endregion
|
|
585
|
-
//#region src/composables/useSelection/index.d.ts
|
|
586
|
-
interface SelectionTicket extends RegistryTicket {
|
|
587
|
-
/** Disabled state of the ticket */
|
|
588
|
-
disabled: MaybeRef<boolean>;
|
|
589
|
-
/** Whether the ticket is currently selected */
|
|
590
|
-
isSelected: Readonly<Ref<boolean, boolean>>;
|
|
591
|
-
/** Select self */
|
|
592
|
-
select: () => void;
|
|
593
|
-
/** Unselect self */
|
|
594
|
-
unselect: () => void;
|
|
595
|
-
/** Toggle self on and off */
|
|
596
|
-
toggle: () => void;
|
|
597
|
-
}
|
|
598
|
-
interface SelectionContext<Z extends SelectionTicket> extends RegistryContext<Z> {
|
|
599
|
-
/** Set of selected ticket IDs */
|
|
600
|
-
selectedIds: Reactive<Set<ID>>;
|
|
601
|
-
/** Set of selected ticket instances */
|
|
602
|
-
selectedItems: ComputedRef<Set<Z>>;
|
|
603
|
-
/** Set of selected ticket values */
|
|
604
|
-
selectedValues: ComputedRef<Set<unknown>>;
|
|
605
|
-
/** Disable state for the entire selection instance */
|
|
606
|
-
disabled: MaybeRef<boolean>;
|
|
607
|
-
/** Clear all selected IDs and reindexes */
|
|
608
|
-
reset: () => void;
|
|
609
|
-
/** Select a ticket by ID (Toggle ON) */
|
|
610
|
-
select: (id: ID) => void;
|
|
611
|
-
/** Unselect a ticket by ID (Toggle OFF) */
|
|
612
|
-
unselect: (id: ID) => void;
|
|
613
|
-
/** Toggles a ticket ON and OFF by ID */
|
|
614
|
-
toggle: (id: ID) => void;
|
|
615
|
-
/** Check if a ticket is selected by ID */
|
|
616
|
-
selected: (id: ID) => boolean;
|
|
617
|
-
/** Mandates selected ID based on "mandatory" Option */
|
|
618
|
-
mandate: () => void;
|
|
619
|
-
}
|
|
620
|
-
interface SelectionOptions extends RegistryOptions {
|
|
621
|
-
/** When true, the entire selection instance is disabled. */
|
|
622
|
-
disabled?: MaybeRef<boolean>;
|
|
623
|
-
/**
|
|
624
|
-
* When true, newly registered items are automatically selected if not disabled.
|
|
625
|
-
* Useful for pre-selecting items in multi-select scenarios.
|
|
626
|
-
*/
|
|
627
|
-
enroll?: boolean;
|
|
628
|
-
/**
|
|
629
|
-
* Controls mandatory selection behavior:
|
|
630
|
-
* - `false` (default): No mandatory selection enforcement
|
|
631
|
-
* - `true`: Prevents deselecting the last selected item (user must always have one selected)
|
|
632
|
-
* - `'force'`: Automatically selects the first non-disabled item on registration
|
|
633
|
-
*/
|
|
634
|
-
mandatory?: boolean | 'force';
|
|
635
|
-
/** When true, treats the selection as an array */
|
|
636
|
-
multiple?: boolean;
|
|
637
|
-
}
|
|
638
|
-
interface SelectionContextOptions extends SelectionOptions {
|
|
639
|
-
namespace: string;
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Creates a new selection instance for managing multiple selected items.
|
|
643
|
-
*
|
|
644
|
-
* Extends `useRegistry` with selection tracking via a reactive `Set` of selected IDs.
|
|
645
|
-
* Supports disabled items, mandatory selection enforcement, and auto-enrollment.
|
|
646
|
-
*
|
|
647
|
-
* @param options The options for the selection instance.
|
|
648
|
-
* @template Z The type of the selection ticket.
|
|
649
|
-
* @template E The type of the selection context.
|
|
650
|
-
* @returns A new selection instance with selection management methods.
|
|
651
|
-
*
|
|
652
|
-
* @remarks
|
|
653
|
-
* **Key Features:**
|
|
654
|
-
* - Multi-selection support (unlike `useSingle` which enforces single selection)
|
|
655
|
-
* - Set-based `selectedIds` tracking for efficient lookups
|
|
656
|
-
* - Computed `selectedItems` and `selectedValues` for reactive access
|
|
657
|
-
* - Each ticket gets `isSelected`, `select()`, `unselect()`, and `toggle()` methods
|
|
658
|
-
* - Disabled items cannot be selected
|
|
659
|
-
* - Mandatory mode prevents deselecting the last item
|
|
660
|
-
* - Force mode auto-selects first non-disabled item on registration
|
|
661
|
-
* - Enroll option auto-selects all non-disabled items on registration
|
|
662
|
-
*
|
|
663
|
-
* **Inheritance Chain:**
|
|
664
|
-
* `useRegistry` → `createSelection` → `createSingle`/`createGroup` → `createStep`
|
|
665
|
-
*
|
|
666
|
-
* @see https://0.vuetifyjs.com/composables/selection/use-selection
|
|
667
|
-
*
|
|
668
|
-
* @example
|
|
669
|
-
* ```ts
|
|
670
|
-
* import { createSelection } from '@vuetify/v0'
|
|
671
|
-
*
|
|
672
|
-
* const selection = createSelection({ mandatory: true })
|
|
673
|
-
*
|
|
674
|
-
* selection.onboard([
|
|
675
|
-
* { id: 'item-1', value: 'Item 1' },
|
|
676
|
-
* { id: 'item-2', value: 'Item 2', disabled: true },
|
|
677
|
-
* { id: 'item-3', value: 'Item 3' },
|
|
678
|
-
* ])
|
|
679
|
-
*
|
|
680
|
-
* selection.select('item-1')
|
|
681
|
-
* selection.select('item-3')
|
|
682
|
-
*
|
|
683
|
-
* console.log(selection.selectedIds) // Set { 'item-1', 'item-3' }
|
|
684
|
-
* console.log(Array.from(selection.selectedValues.value)) // ['Item 1', 'Item 3']
|
|
685
|
-
* ```
|
|
686
|
-
*/
|
|
687
|
-
declare function createSelection<Z extends SelectionTicket = SelectionTicket, E extends SelectionContext<Z> = SelectionContext<Z>>(_options?: SelectionOptions): E;
|
|
688
|
-
/**
|
|
689
|
-
* Creates a new selection context.
|
|
690
|
-
*
|
|
691
|
-
* @param namespace The namespace for the selection context.
|
|
692
|
-
* @param options The options for the selection context.
|
|
693
|
-
* @template Z The type of the selection ticket.
|
|
694
|
-
* @template E The type of the selection context.
|
|
695
|
-
* @returns A new selection context.
|
|
696
|
-
*
|
|
697
|
-
* @see https://0.vuetifyjs.com/composables/selection/use-selection
|
|
698
|
-
*
|
|
699
|
-
* @example
|
|
700
|
-
* ```ts
|
|
701
|
-
* import { createSelectionContext } from '@vuetify/v0'
|
|
702
|
-
*
|
|
703
|
-
* export const [useCheckboxes, provideCheckboxes, checkboxes] = createSelectionContext('checkboxes')
|
|
704
|
-
*
|
|
705
|
-
* // In a parent component:
|
|
706
|
-
* provideCheckboxes()
|
|
707
|
-
*
|
|
708
|
-
* // In a child component:
|
|
709
|
-
* const checkboxes = useCheckboxes()
|
|
710
|
-
* checkboxes.select('checkbox-1')
|
|
711
|
-
* ```
|
|
712
|
-
*/
|
|
713
|
-
declare function createSelectionContext<Z extends SelectionTicket = SelectionTicket, E extends SelectionContext<Z> = SelectionContext<Z>>(_options: SelectionContextOptions): ContextTrinity<E>;
|
|
714
|
-
/**
|
|
715
|
-
* Returns the current selection instance.
|
|
716
|
-
*
|
|
717
|
-
* @param namespace The namespace for the selection context. Defaults to `'v0:selection'`.
|
|
718
|
-
* @returns The current selection instance.
|
|
719
|
-
*
|
|
720
|
-
* @see https://0.vuetifyjs.com/composables/selection/use-selection
|
|
721
|
-
*
|
|
722
|
-
* @example
|
|
723
|
-
* ```vue
|
|
724
|
-
* <script setup lang="ts">
|
|
725
|
-
* import { useSelection } from '@vuetify/v0'
|
|
726
|
-
*
|
|
727
|
-
* const selection = useSelection()
|
|
728
|
-
* </script>
|
|
729
|
-
*
|
|
730
|
-
* <template>
|
|
731
|
-
* <div>
|
|
732
|
-
* <p>Selected: {{ selection.selectedIds.size }}</p>
|
|
733
|
-
* </div>
|
|
734
|
-
* </template>
|
|
735
|
-
* ```
|
|
736
|
-
*/
|
|
737
|
-
declare function useSelection<Z extends SelectionTicket = SelectionTicket, E extends SelectionContext<Z> = SelectionContext<Z>>(namespace?: string): E;
|
|
738
|
-
//#endregion
|
|
739
|
-
//#region src/composables/createContext/index.d.ts
|
|
740
|
-
type ContextKey<Z> = InjectionKey<Z> | string;
|
|
741
|
-
/**
|
|
742
|
-
* Injects a context provided by an ancestor component.
|
|
743
|
-
*
|
|
744
|
-
* @param key The key of the context to inject.
|
|
745
|
-
* @param defaultValue Optional default value if context is not found.
|
|
746
|
-
* @template Z The type of the context.
|
|
747
|
-
* @returns The injected context.
|
|
748
|
-
* @throws An error if the context is not found and no default is provided.
|
|
749
|
-
*
|
|
750
|
-
* @see https://vuejs.org/api/composition-api-dependency-injection.html#inject
|
|
751
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-context#use-context
|
|
752
|
-
*
|
|
753
|
-
* @example
|
|
754
|
-
* ```ts
|
|
755
|
-
* // Without default value
|
|
756
|
-
* const context = useContext<MyContext>('my-context')
|
|
757
|
-
*
|
|
758
|
-
* // With default value
|
|
759
|
-
* const context = useContext<MyContext>('my-context', defaultContext)
|
|
760
|
-
* ```
|
|
761
|
-
*/
|
|
762
|
-
declare function useContext<Z>(key: ContextKey<Z>, defaultValue?: Z): Z & ({} | null);
|
|
763
|
-
/**
|
|
764
|
-
* Provides a context to all descendant components.
|
|
765
|
-
*
|
|
766
|
-
* @param key The key of the context to provide.
|
|
767
|
-
* @param context The context to provide.
|
|
768
|
-
* @param app Optional Vue app instance to provide the context at app level instead of component level.
|
|
769
|
-
* @template Z The type of the context.
|
|
770
|
-
* @returns The provided context.
|
|
771
|
-
*
|
|
772
|
-
* @remarks
|
|
773
|
-
* When `app` parameter is provided, the context is made available to all components in the app.
|
|
774
|
-
* When omitted, the context is provided at the current component level and available to descendants only.
|
|
775
|
-
*
|
|
776
|
-
* @see https://vuejs.org/api/composition-api-dependency-injection.html#provide
|
|
777
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-context#provide-context
|
|
778
|
-
*
|
|
779
|
-
* @example
|
|
780
|
-
* ```ts
|
|
781
|
-
* // Component-level provision
|
|
782
|
-
* provideContext<MyContext>('my-context', context)
|
|
783
|
-
*
|
|
784
|
-
* // App-level provision (typically used in plugins)
|
|
785
|
-
* const app = createApp()
|
|
786
|
-
* provideContext<MyContext>('my-context', context, app)
|
|
787
|
-
* ```
|
|
788
|
-
*/
|
|
789
|
-
declare function provideContext<Z>(key: ContextKey<Z>, context: Z, app?: App): Z;
|
|
790
|
-
/**
|
|
791
|
-
* Creates a new context for providing and injecting data.
|
|
792
|
-
*
|
|
793
|
-
* @param key The key of the context to create.
|
|
794
|
-
* @param defaultValue Optional default value if context is not found.
|
|
795
|
-
* @template Z The type of the context.
|
|
796
|
-
* @returns A tuple containing the `useContext` and `provideContext` functions.
|
|
797
|
-
*
|
|
798
|
-
* @see https://vuejs.org/api/composition-api-dependency-injection.html
|
|
799
|
-
* @see https://0.vuetifyjs.com/composables/foundation/create-context#create-context
|
|
800
|
-
*
|
|
801
|
-
* @example
|
|
802
|
-
* ```ts
|
|
803
|
-
* // Without default value
|
|
804
|
-
* const [useMyContext, provideMyContext] = createContext<MyContext>('my-context')
|
|
805
|
-
*
|
|
806
|
-
* // With default value
|
|
807
|
-
* const [useMyContext, provideMyContext] = createContext<MyContext>('my-context', defaultContext)
|
|
808
|
-
* ```
|
|
809
|
-
*/
|
|
810
|
-
declare function createContext<Z>(_key: ContextKey<Z>, defaultValue?: Z): readonly [(key?: ContextKey<Z>) => Z & ({} | null), (context: Z, app?: App) => Z];
|
|
811
|
-
//#endregion
|
|
812
|
-
export { useRegistry as _, SelectionContext as a, SelectionTicket as c, useSelection as d, RegistryContext as f, createRegistryContext as g, RegistryTicket as h, useContext as i, createSelection as l, RegistryOptions as m, createContext as n, SelectionContextOptions as o, RegistryContextOptions as p, provideContext as r, SelectionOptions as s, ContextKey as t, createSelectionContext as u, ContextTrinity as v, createTrinity as y };
|