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