@directus/composables 10.1.3 → 10.1.5

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 CHANGED
@@ -1,10 +1,156 @@
1
- export * from './use-collection.js';
2
- export * from './use-custom-selection.js';
3
- export * from './use-element-size.js';
4
- export * from './use-filter-fields.js';
5
- export * from './use-groupable.js';
6
- export * from './use-items.js';
7
- export * from './use-layout.js';
8
- export * from './use-size-class.js';
9
- export * from './use-sync.js';
10
- export * from './use-system.js';
1
+ import { AppCollection, Field, Item, Query, RefRecord } from '@directus/types';
2
+ import { ComputedRef, Ref, WritableComputedRef, Component } from 'vue';
3
+ import { AppExtensionConfigs } from '@directus/extensions';
4
+ import { AxiosInstance } from 'axios';
5
+
6
+ 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>;
15
+ };
16
+ declare function useCollection(collectionKey: string | Ref<string | null>): UsableCollection;
17
+
18
+ type UsableCustomSelection = {
19
+ otherValue: Ref<string | null>;
20
+ usesOtherValue: ComputedRef<boolean>;
21
+ };
22
+ declare function useCustomSelection(currentValue: Ref<string | null>, items: Ref<any[]>, emit: (event: string | null) => void): UsableCustomSelection;
23
+ type OtherValue = {
24
+ key: string;
25
+ value: string;
26
+ };
27
+ type UsableCustomSelectionMultiple = {
28
+ otherValues: Ref<OtherValue[]>;
29
+ addOtherValue: (value?: string) => void;
30
+ setOtherValue: (key: string, newValue: string | null) => void;
31
+ };
32
+ declare function useCustomSelectionMultiple(currentValues: Ref<string[] | null>, items: Ref<any[]>, emit: (event: string[] | null) => void): UsableCustomSelectionMultiple;
33
+
34
+ declare global {
35
+ interface Window {
36
+ ResizeObserver: any;
37
+ }
38
+ }
39
+ declare function useElementSize<T extends Element>(target: T | Ref<T> | Ref<undefined>): {
40
+ width: Ref<number>;
41
+ height: Ref<number>;
42
+ };
43
+
44
+ declare function useFilterFields<T extends string>(fields: Ref<Field[]>, filters: Record<T, (field: Field) => boolean>): {
45
+ fieldGroups: ComputedRef<Record<Extract<T, string>, Field[]>>;
46
+ };
47
+
48
+ type GroupableInstance = {
49
+ active: Ref<boolean>;
50
+ value: string | number | undefined;
51
+ };
52
+ /**
53
+ * Used to make child item part of the group context. Needs to be used in a component that is a child
54
+ * of a component that has the `useGroupableParent` composition enabled
55
+ */
56
+ type GroupableOptions = {
57
+ value?: string | number;
58
+ group?: string;
59
+ active?: Ref<boolean>;
60
+ watch?: boolean;
61
+ };
62
+ type UsableGroupable = {
63
+ active: Ref<boolean>;
64
+ toggle: () => void;
65
+ activate: () => void;
66
+ deactivate: () => void;
67
+ };
68
+ declare function useGroupable(options?: GroupableOptions): UsableGroupable;
69
+ type GroupableParentState = {
70
+ selection?: Ref<(string | number)[] | undefined> | Ref<readonly (string | number)[] | undefined>;
71
+ onSelectionChange?: (newSelectionValues: readonly (string | number)[]) => void;
72
+ onToggle?: (item: GroupableInstance) => void;
73
+ };
74
+ type GroupableParentOptions = {
75
+ mandatory?: Ref<boolean>;
76
+ max?: Ref<number>;
77
+ multiple?: Ref<boolean>;
78
+ };
79
+ type UsableGroupableParent = {
80
+ items: Ref<GroupableInstance[]>;
81
+ selection: Ref<readonly (string | number)[]>;
82
+ internalSelection: Ref<(string | number)[]>;
83
+ getValueForItem: (item: GroupableInstance) => string | number;
84
+ updateChildren: () => void;
85
+ };
86
+ /**
87
+ * Used to make a component a group parent component. Provides the registration / toggle functions
88
+ * to its group children
89
+ */
90
+ declare function useGroupableParent(state?: GroupableParentState, options?: GroupableParentOptions, group?: string): UsableGroupableParent;
91
+
92
+ type ManualSortData = {
93
+ item: string | number;
94
+ to: string | number;
95
+ };
96
+ type UsableItems = {
97
+ itemCount: Ref<number | null>;
98
+ totalCount: Ref<number | null>;
99
+ items: Ref<Item[]>;
100
+ totalPages: ComputedRef<number>;
101
+ loading: Ref<boolean>;
102
+ error: Ref<any>;
103
+ changeManualSort: (data: ManualSortData) => Promise<void>;
104
+ getItems: () => Promise<void>;
105
+ getTotalCount: () => Promise<void>;
106
+ getItemCount: () => Promise<void>;
107
+ };
108
+ type ComputedQuery = {
109
+ fields: Ref<Query['fields']> | ComputedRef<Query['fields']> | WritableComputedRef<Query['fields']>;
110
+ limit: Ref<Query['limit']> | ComputedRef<Query['limit']> | WritableComputedRef<Query['limit']>;
111
+ sort: Ref<Query['sort']> | ComputedRef<Query['sort']> | WritableComputedRef<Query['sort']>;
112
+ search: Ref<Query['search']> | ComputedRef<Query['search']> | WritableComputedRef<Query['search']>;
113
+ filter: Ref<Query['filter']> | ComputedRef<Query['filter']> | WritableComputedRef<Query['filter']>;
114
+ page: Ref<Query['page']> | WritableComputedRef<Query['page']>;
115
+ alias?: Ref<Query['alias']> | ComputedRef<Query['alias']> | WritableComputedRef<Query['alias']>;
116
+ deep?: Ref<Query['deep']> | ComputedRef<Query['deep']> | WritableComputedRef<Query['deep']>;
117
+ };
118
+ declare function useItems(collection: Ref<string | null>, query: ComputedQuery): UsableItems;
119
+
120
+ declare function useLayout<Options = any, Query = any>(layoutId: Ref<string | null>): {
121
+ layoutWrapper: ComputedRef<Component>;
122
+ };
123
+
124
+ declare const sizeProps: {
125
+ xSmall: {
126
+ type: BooleanConstructor;
127
+ default: boolean;
128
+ };
129
+ small: {
130
+ type: BooleanConstructor;
131
+ default: boolean;
132
+ };
133
+ large: {
134
+ type: BooleanConstructor;
135
+ default: boolean;
136
+ };
137
+ xLarge: {
138
+ type: BooleanConstructor;
139
+ default: boolean;
140
+ };
141
+ };
142
+ interface SizeProps {
143
+ xSmall?: boolean;
144
+ small?: boolean;
145
+ large?: boolean;
146
+ xLarge?: boolean;
147
+ }
148
+ declare function useSizeClass<T>(props: T & SizeProps): ComputedRef<string | null>;
149
+
150
+ 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]>;
151
+
152
+ declare function useStores(): Record<string, any>;
153
+ declare function useApi(): AxiosInstance;
154
+ declare function useExtensions(): RefRecord<AppExtensionConfigs>;
155
+
156
+ export { ComputedQuery, GroupableInstance, GroupableOptions, ManualSortData, UsableCollection, UsableCustomSelection, UsableGroupable, UsableItems, sizeProps, useApi, useCollection, useCustomSelection, useCustomSelectionMultiple, useElementSize, useExtensions, useFilterFields, useGroupable, useGroupableParent, useItems, useLayout, useSizeClass, useStores, useSync };