@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.
Files changed (3) hide show
  1. package/dist/index.d.ts +132 -122
  2. package/dist/index.js +1460 -658
  3. package/package.json +9 -9
package/dist/index.d.ts CHANGED
@@ -1,17 +1,18 @@
1
- import { AppCollection, Field, Item, Query, LayoutConfig, RefRecord, AppExtensionConfigs } from '@directus/types';
2
- import { ComputedRef, Ref, WritableComputedRef, Component } from 'vue';
3
- import { DirectusClient, RestClient } from '@directus/sdk';
4
- 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";
5
5
 
6
+ //#region src/use-collection.d.ts
6
7
  type UsableCollection = {
7
- info: ComputedRef<AppCollection | null>;
8
- fields: ComputedRef<Field[]>;
9
- defaults: ComputedRef<Record<string, any>>;
10
- primaryKeyField: ComputedRef<Field | null>;
11
- userCreatedField: ComputedRef<Field | null>;
12
- sortField: ComputedRef<string | null>;
13
- isSingleton: ComputedRef<boolean>;
14
- accountabilityScope: ComputedRef<'all' | 'activity' | null>;
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
- otherValue: Ref<string | null>;
55
- usesOtherValue: ComputedRef<boolean>;
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
- key: string;
95
- value: string;
96
- focus?: boolean;
96
+ key: string;
97
+ value: string;
98
+ focus?: boolean;
97
99
  };
98
100
  type UsableCustomSelectionMultiple = {
99
- otherValues: Ref<OtherValue[]>;
100
- addOtherValue: (value?: string, focus?: boolean) => void;
101
- setOtherValue: (key: string, newValue: string | null) => void;
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
- interface Window {
147
- ResizeObserver: any;
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
- width: Ref<number>;
182
- height: Ref<number>;
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
- fieldGroups: ComputedRef<Record<Extract<T, string>, Field[]>>;
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
- /** Reactive reference to the active state of the item */
239
- active: Ref<boolean>;
240
- /** Unique identifier for the item within the group */
241
- value: string | number | undefined;
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
- /** Unique identifier for this groupable item */
250
- value?: string | number;
251
- /** Name of the group to inject from (defaults to 'item-group') */
252
- group?: string;
253
- /** External reactive reference to control the active state */
254
- active?: Ref<boolean>;
255
- /** Whether to watch the external active reference for changes */
256
- watch?: boolean;
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
- /** Reactive reference to the active state */
263
- active: Ref<boolean>;
264
- /** Toggle the active state of this item */
265
- toggle: () => void;
266
- /** Activate this item (if not already active) */
267
- activate: () => void;
268
- /** Deactivate this item (if currently active) */
269
- deactivate: () => void;
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
- /** External selection state (can be readonly) */
306
- selection?: Ref<(string | number)[] | undefined> | Ref<readonly (string | number)[] | undefined>;
307
- /** Callback fired when the selection changes */
308
- onSelectionChange?: (newSelectionValues: readonly (string | number)[]) => void;
309
- /** Callback fired when an item is toggled */
310
- onToggle?: (item: GroupableInstance) => void;
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
- /** Whether at least one item must always be selected */
317
- mandatory?: Ref<boolean>;
318
- /** Maximum number of items that can be selected (-1 for unlimited) */
319
- max?: Ref<number>;
320
- /** Whether multiple items can be selected simultaneously */
321
- multiple?: Ref<boolean>;
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
- /** Reactive array of all registered groupable items */
328
- items: Ref<GroupableInstance[]>;
329
- /** Computed selection array (readonly) */
330
- selection: Ref<readonly (string | number)[]>;
331
- /** Internal selection state */
332
- internalSelection: Ref<(string | number)[]>;
333
- /** Get the value identifier for a given item */
334
- getValueForItem: (item: GroupableInstance) => string | number;
335
- /** Synchronize children's active state with selection */
336
- updateChildren: () => void;
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
- item: string | number;
388
- to: string | number;
393
+ item: string | number;
394
+ to: string | number;
389
395
  };
390
396
  type UsableItems = {
391
- itemCount: Ref<number | null>;
392
- totalCount: Ref<number | null>;
393
- items: Ref<Item[]>;
394
- totalPages: ComputedRef<number>;
395
- loading: Ref<boolean>;
396
- error: Ref<any>;
397
- changeManualSort: (data: ManualSortData) => Promise<void>;
398
- getItems: () => Promise<void>;
399
- getTotalCount: () => Promise<void>;
400
- getItemCount: () => Promise<void>;
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
- fields: Ref<Query['fields']> | ComputedRef<Query['fields']> | WritableComputedRef<Query['fields']>;
404
- limit: Ref<Query['limit']> | ComputedRef<Query['limit']> | WritableComputedRef<Query['limit']>;
405
- sort: Ref<Query['sort']> | ComputedRef<Query['sort']> | WritableComputedRef<Query['sort']>;
406
- search: Ref<Query['search']> | ComputedRef<Query['search']> | WritableComputedRef<Query['search']>;
407
- filter: Ref<Query['filter']> | ComputedRef<Query['filter']> | WritableComputedRef<Query['filter']>;
408
- page: Ref<Query['page']> | WritableComputedRef<Query['page']>;
409
- /** System filter applied to total item count. */
410
- filterSystem?: Ref<Query['filter']> | ComputedRef<Query['filter']> | WritableComputedRef<Query['filter']>;
411
- alias?: Ref<Query['alias']> | ComputedRef<Query['alias']> | WritableComputedRef<Query['alias']>;
412
- deep?: Ref<Query['deep']> | ComputedRef<Query['deep']> | WritableComputedRef<Query['deep']>;
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
- layoutWrapper: ComputedRef<Component>;
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
- xSmall: {
539
- type: BooleanConstructor;
540
- default: boolean;
541
- };
542
- small: {
543
- type: BooleanConstructor;
544
- default: boolean;
545
- };
546
- large: {
547
- type: BooleanConstructor;
548
- default: boolean;
549
- };
550
- xLarge: {
551
- type: BooleanConstructor;
552
- default: boolean;
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
- xSmall?: boolean;
557
- small?: boolean;
558
- large?: boolean;
559
- xLarge?: boolean;
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 { type ComputedQuery, type GroupableInstance, type GroupableOptions, type ManualSortData, type OtherValue, type UsableCollection, type UsableCustomSelection, type UsableGroupable, type UsableItems, createLayoutWrapper, isWritableProp, sizeProps, useApi, useCollection, useCustomSelection, useCustomSelectionMultiple, useElementSize, useExtensions, useFilterFields, useGroupable, useGroupableParent, useItems, useLayout, useSdk, useSizeClass, useStores, useSync };
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 };