@directus/composables 11.2.2 → 11.2.3
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/index.d.ts +132 -122
- package/dist/index.js +1460 -658
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Component, ComputedRef, Ref, WritableComputedRef } from "vue";
|
|
2
|
+
import { AxiosInstance } from "axios";
|
|
3
|
+
import { AppCollection, AppExtensionConfigs, Field, Item, LayoutConfig, Query, RefRecord } from "@directus/types";
|
|
4
|
+
import { DirectusClient, RestClient } from "@directus/sdk";
|
|
5
5
|
|
|
6
|
+
//#region src/use-collection.d.ts
|
|
6
7
|
type UsableCollection = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
info: ComputedRef<AppCollection | null>;
|
|
9
|
+
fields: ComputedRef<Field[]>;
|
|
10
|
+
defaults: ComputedRef<Record<string, any>>;
|
|
11
|
+
primaryKeyField: ComputedRef<Field | null>;
|
|
12
|
+
userCreatedField: ComputedRef<Field | null>;
|
|
13
|
+
sortField: ComputedRef<string | null>;
|
|
14
|
+
isSingleton: ComputedRef<boolean>;
|
|
15
|
+
accountabilityScope: ComputedRef<'all' | 'activity' | null>;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* A Vue composable that provides reactive access to collection metadata, fields, and computed properties.
|
|
@@ -49,10 +50,11 @@ type UsableCollection = {
|
|
|
49
50
|
* ```
|
|
50
51
|
*/
|
|
51
52
|
declare function useCollection(collectionKey: string | Ref<string | null>): UsableCollection;
|
|
52
|
-
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/use-custom-selection.d.ts
|
|
53
55
|
type UsableCustomSelection = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
otherValue: Ref<string | null>;
|
|
57
|
+
usesOtherValue: ComputedRef<boolean>;
|
|
56
58
|
};
|
|
57
59
|
/**
|
|
58
60
|
* A Vue composable for managing custom selection values that aren't present in a predefined list of items.
|
|
@@ -91,14 +93,14 @@ type UsableCustomSelection = {
|
|
|
91
93
|
*/
|
|
92
94
|
declare function useCustomSelection(currentValue: Ref<string | null>, items: Ref<any[]>, emit: (event: string | null) => void): UsableCustomSelection;
|
|
93
95
|
type OtherValue = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
key: string;
|
|
97
|
+
value: string;
|
|
98
|
+
focus?: boolean;
|
|
97
99
|
};
|
|
98
100
|
type UsableCustomSelectionMultiple = {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
otherValues: Ref<OtherValue[]>;
|
|
102
|
+
addOtherValue: (value?: string, focus?: boolean) => void;
|
|
103
|
+
setOtherValue: (key: string, newValue: string | null) => void;
|
|
102
104
|
};
|
|
103
105
|
/**
|
|
104
106
|
* A Vue composable for managing multiple custom selection values that aren't present in a predefined list of items.
|
|
@@ -141,11 +143,12 @@ type UsableCustomSelectionMultiple = {
|
|
|
141
143
|
* ```
|
|
142
144
|
*/
|
|
143
145
|
declare function useCustomSelectionMultiple(currentValues: Ref<string[] | null>, items: Ref<any[]>, emit: (event: string[] | null) => void): UsableCustomSelectionMultiple;
|
|
144
|
-
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/use-element-size.d.ts
|
|
145
148
|
declare global {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
interface Window {
|
|
150
|
+
ResizeObserver: any;
|
|
151
|
+
}
|
|
149
152
|
}
|
|
150
153
|
/**
|
|
151
154
|
* A Vue composable that reactively tracks the size of a DOM element using ResizeObserver.
|
|
@@ -178,10 +181,11 @@ declare global {
|
|
|
178
181
|
* - Handles cases where the target element might be undefined
|
|
179
182
|
*/
|
|
180
183
|
declare function useElementSize<T extends Element>(target: T | Ref<T> | Ref<undefined>): {
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
width: Ref<number>;
|
|
185
|
+
height: Ref<number>;
|
|
183
186
|
};
|
|
184
|
-
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/use-filter-fields.d.ts
|
|
185
189
|
/**
|
|
186
190
|
* A Vue composable that filters and groups fields based on multiple filter criteria.
|
|
187
191
|
*
|
|
@@ -228,17 +232,18 @@ declare function useElementSize<T extends Element>(target: T | Ref<T> | Ref<unde
|
|
|
228
232
|
* - Groups are initialized as empty arrays even if no fields match the criteria
|
|
229
233
|
*/
|
|
230
234
|
declare function useFilterFields<T extends string>(fields: Ref<Field[]>, filters: Record<T, (field: Field) => boolean>): {
|
|
231
|
-
|
|
235
|
+
fieldGroups: ComputedRef<Record<Extract<T, string>, Field[]>>;
|
|
232
236
|
};
|
|
233
|
-
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/use-groupable.d.ts
|
|
234
239
|
/**
|
|
235
240
|
* Represents a groupable item instance with its active state and value.
|
|
236
241
|
*/
|
|
237
242
|
type GroupableInstance = {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
243
|
+
/** Reactive reference to the active state of the item */
|
|
244
|
+
active: Ref<boolean>;
|
|
245
|
+
/** Unique identifier for the item within the group */
|
|
246
|
+
value: string | number | undefined;
|
|
242
247
|
};
|
|
243
248
|
/**
|
|
244
249
|
* Configuration options for the useGroupable composable.
|
|
@@ -246,27 +251,27 @@ type GroupableInstance = {
|
|
|
246
251
|
* of a component that has the `useGroupableParent` composition enabled.
|
|
247
252
|
*/
|
|
248
253
|
type GroupableOptions = {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
/** Unique identifier for this groupable item */
|
|
255
|
+
value?: string | number;
|
|
256
|
+
/** Name of the group to inject from (defaults to 'item-group') */
|
|
257
|
+
group?: string;
|
|
258
|
+
/** External reactive reference to control the active state */
|
|
259
|
+
active?: Ref<boolean>;
|
|
260
|
+
/** Whether to watch the external active reference for changes */
|
|
261
|
+
watch?: boolean;
|
|
257
262
|
};
|
|
258
263
|
/**
|
|
259
264
|
* Return type for the useGroupable composable.
|
|
260
265
|
*/
|
|
261
266
|
type UsableGroupable = {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
/** Reactive reference to the active state */
|
|
268
|
+
active: Ref<boolean>;
|
|
269
|
+
/** Toggle the active state of this item */
|
|
270
|
+
toggle: () => void;
|
|
271
|
+
/** Activate this item (if not already active) */
|
|
272
|
+
activate: () => void;
|
|
273
|
+
/** Deactivate this item (if currently active) */
|
|
274
|
+
deactivate: () => void;
|
|
270
275
|
};
|
|
271
276
|
/**
|
|
272
277
|
* Vue composable for creating groupable child items that can participate in group selection.
|
|
@@ -302,38 +307,38 @@ declare function useGroupable(options?: GroupableOptions): UsableGroupable;
|
|
|
302
307
|
* State configuration for the groupable parent.
|
|
303
308
|
*/
|
|
304
309
|
type GroupableParentState = {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
310
|
+
/** External selection state (can be readonly) */
|
|
311
|
+
selection?: Ref<(string | number)[] | undefined> | Ref<readonly (string | number)[] | undefined>;
|
|
312
|
+
/** Callback fired when the selection changes */
|
|
313
|
+
onSelectionChange?: (newSelectionValues: readonly (string | number)[]) => void;
|
|
314
|
+
/** Callback fired when an item is toggled */
|
|
315
|
+
onToggle?: (item: GroupableInstance) => void;
|
|
311
316
|
};
|
|
312
317
|
/**
|
|
313
318
|
* Configuration options for the groupable parent.
|
|
314
319
|
*/
|
|
315
320
|
type GroupableParentOptions = {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
321
|
+
/** Whether at least one item must always be selected */
|
|
322
|
+
mandatory?: Ref<boolean>;
|
|
323
|
+
/** Maximum number of items that can be selected (-1 for unlimited) */
|
|
324
|
+
max?: Ref<number>;
|
|
325
|
+
/** Whether multiple items can be selected simultaneously */
|
|
326
|
+
multiple?: Ref<boolean>;
|
|
322
327
|
};
|
|
323
328
|
/**
|
|
324
329
|
* Return type for the useGroupableParent composable.
|
|
325
330
|
*/
|
|
326
331
|
type UsableGroupableParent = {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
332
|
+
/** Reactive array of all registered groupable items */
|
|
333
|
+
items: Ref<GroupableInstance[]>;
|
|
334
|
+
/** Computed selection array (readonly) */
|
|
335
|
+
selection: Ref<readonly (string | number)[]>;
|
|
336
|
+
/** Internal selection state */
|
|
337
|
+
internalSelection: Ref<(string | number)[]>;
|
|
338
|
+
/** Get the value identifier for a given item */
|
|
339
|
+
getValueForItem: (item: GroupableInstance) => string | number;
|
|
340
|
+
/** Synchronize children's active state with selection */
|
|
341
|
+
updateChildren: () => void;
|
|
337
342
|
};
|
|
338
343
|
/**
|
|
339
344
|
* Vue composable for creating a group parent that manages multiple groupable child items.
|
|
@@ -382,37 +387,39 @@ type UsableGroupableParent = {
|
|
|
382
387
|
* ```
|
|
383
388
|
*/
|
|
384
389
|
declare function useGroupableParent(state?: GroupableParentState, options?: GroupableParentOptions, group?: string): UsableGroupableParent;
|
|
385
|
-
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/use-items.d.ts
|
|
386
392
|
type ManualSortData = {
|
|
387
|
-
|
|
388
|
-
|
|
393
|
+
item: string | number;
|
|
394
|
+
to: string | number;
|
|
389
395
|
};
|
|
390
396
|
type UsableItems = {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
397
|
+
itemCount: Ref<number | null>;
|
|
398
|
+
totalCount: Ref<number | null>;
|
|
399
|
+
items: Ref<Item[]>;
|
|
400
|
+
totalPages: ComputedRef<number>;
|
|
401
|
+
loading: Ref<boolean>;
|
|
402
|
+
error: Ref<any>;
|
|
403
|
+
changeManualSort: (data: ManualSortData) => Promise<void>;
|
|
404
|
+
getItems: () => Promise<void>;
|
|
405
|
+
getTotalCount: () => Promise<void>;
|
|
406
|
+
getItemCount: () => Promise<void>;
|
|
401
407
|
};
|
|
402
408
|
type ComputedQuery = {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
409
|
+
fields: Ref<Query['fields']> | ComputedRef<Query['fields']> | WritableComputedRef<Query['fields']>;
|
|
410
|
+
limit: Ref<Query['limit']> | ComputedRef<Query['limit']> | WritableComputedRef<Query['limit']>;
|
|
411
|
+
sort: Ref<Query['sort']> | ComputedRef<Query['sort']> | WritableComputedRef<Query['sort']>;
|
|
412
|
+
search: Ref<Query['search']> | ComputedRef<Query['search']> | WritableComputedRef<Query['search']>;
|
|
413
|
+
filter: Ref<Query['filter']> | ComputedRef<Query['filter']> | WritableComputedRef<Query['filter']>;
|
|
414
|
+
page: Ref<Query['page']> | WritableComputedRef<Query['page']>;
|
|
415
|
+
/** System filter applied to total item count. */
|
|
416
|
+
filterSystem?: Ref<Query['filter']> | ComputedRef<Query['filter']> | WritableComputedRef<Query['filter']>;
|
|
417
|
+
alias?: Ref<Query['alias']> | ComputedRef<Query['alias']> | WritableComputedRef<Query['alias']>;
|
|
418
|
+
deep?: Ref<Query['deep']> | ComputedRef<Query['deep']> | WritableComputedRef<Query['deep']>;
|
|
413
419
|
};
|
|
414
420
|
declare function useItems(collection: Ref<string | null>, query: ComputedQuery): UsableItems;
|
|
415
|
-
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/use-layout.d.ts
|
|
416
423
|
declare const WRITABLE_PROPS: readonly ["selection", "layoutOptions", "layoutQuery"];
|
|
417
424
|
type WritableProp = (typeof WRITABLE_PROPS)[number];
|
|
418
425
|
/**
|
|
@@ -510,9 +517,10 @@ declare function createLayoutWrapper<Options, Query>(layout: LayoutConfig): Comp
|
|
|
510
517
|
* ```
|
|
511
518
|
*/
|
|
512
519
|
declare function useLayout<Options = any, Query = any>(layoutId: Ref<string | null>): {
|
|
513
|
-
|
|
520
|
+
layoutWrapper: ComputedRef<Component>;
|
|
514
521
|
};
|
|
515
|
-
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region src/use-size-class.d.ts
|
|
516
524
|
/**
|
|
517
525
|
* Vue props definition for size-related boolean properties.
|
|
518
526
|
*
|
|
@@ -535,28 +543,28 @@ declare function useLayout<Options = any, Query = any>(layoutId: Ref<string | nu
|
|
|
535
543
|
* ```
|
|
536
544
|
*/
|
|
537
545
|
declare const sizeProps: {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
546
|
+
xSmall: {
|
|
547
|
+
type: BooleanConstructor;
|
|
548
|
+
default: boolean;
|
|
549
|
+
};
|
|
550
|
+
small: {
|
|
551
|
+
type: BooleanConstructor;
|
|
552
|
+
default: boolean;
|
|
553
|
+
};
|
|
554
|
+
large: {
|
|
555
|
+
type: BooleanConstructor;
|
|
556
|
+
default: boolean;
|
|
557
|
+
};
|
|
558
|
+
xLarge: {
|
|
559
|
+
type: BooleanConstructor;
|
|
560
|
+
default: boolean;
|
|
561
|
+
};
|
|
554
562
|
};
|
|
555
563
|
interface SizeProps {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
564
|
+
xSmall?: boolean;
|
|
565
|
+
small?: boolean;
|
|
566
|
+
large?: boolean;
|
|
567
|
+
xLarge?: boolean;
|
|
560
568
|
}
|
|
561
569
|
/**
|
|
562
570
|
* Composable for generating CSS size class names based on size props.
|
|
@@ -617,7 +625,8 @@ interface SizeProps {
|
|
|
617
625
|
* ```
|
|
618
626
|
*/
|
|
619
627
|
declare function useSizeClass<T>(props: T & SizeProps): ComputedRef<string | null>;
|
|
620
|
-
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region src/use-sync.d.ts
|
|
621
630
|
/**
|
|
622
631
|
* Composable for creating two-way binding between parent and child components.
|
|
623
632
|
*
|
|
@@ -752,7 +761,8 @@ declare function useSizeClass<T>(props: T & SizeProps): ComputedRef<string | nul
|
|
|
752
761
|
* ```
|
|
753
762
|
*/
|
|
754
763
|
declare function useSync<T, K extends keyof T & string, E extends (event: `update:${K}`, ...args: any[]) => void>(props: T, key: K, emit: E): Ref<T[K]>;
|
|
755
|
-
|
|
764
|
+
//#endregion
|
|
765
|
+
//#region src/use-system.d.ts
|
|
756
766
|
/**
|
|
757
767
|
* Vue composable that provides access to the global Directus stores through dependency injection.
|
|
758
768
|
*
|
|
@@ -1053,5 +1063,5 @@ declare function useSdk<Schema extends object = any>(): DirectusClient<Schema> &
|
|
|
1053
1063
|
* ```
|
|
1054
1064
|
*/
|
|
1055
1065
|
declare function useExtensions(): RefRecord<AppExtensionConfigs>;
|
|
1056
|
-
|
|
1057
|
-
export {
|
|
1066
|
+
//#endregion
|
|
1067
|
+
export { ComputedQuery, GroupableInstance, GroupableOptions, ManualSortData, OtherValue, UsableCollection, UsableCustomSelection, UsableGroupable, UsableItems, createLayoutWrapper, isWritableProp, sizeProps, useApi, useCollection, useCustomSelection, useCustomSelectionMultiple, useElementSize, useExtensions, useFilterFields, useGroupable, useGroupableParent, useItems, useLayout, useSdk, useSizeClass, useStores, useSync };
|