@directus/composables 11.2.3 → 11.2.4
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 +2 -2
- package/dist/index.js +26 -31
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -474,7 +474,7 @@ declare function isWritableProp(prop: string): prop is WritableProp;
|
|
|
474
474
|
* const LayoutWrapper = createLayoutWrapper<MyLayoutOptions, MyLayoutQuery>(layoutConfig);
|
|
475
475
|
* ```
|
|
476
476
|
*/
|
|
477
|
-
declare function createLayoutWrapper<Options, Query>(layout: LayoutConfig): Component;
|
|
477
|
+
declare function createLayoutWrapper<Options, Query$1>(layout: LayoutConfig): Component;
|
|
478
478
|
/**
|
|
479
479
|
* Composable for managing layout components in Directus.
|
|
480
480
|
*
|
|
@@ -516,7 +516,7 @@ declare function createLayoutWrapper<Options, Query>(layout: LayoutConfig): Comp
|
|
|
516
516
|
* const { layoutWrapper } = useLayout<TableOptions, TableQuery>(layoutId);
|
|
517
517
|
* ```
|
|
518
518
|
*/
|
|
519
|
-
declare function useLayout<Options = any, Query = any>(layoutId: Ref<string | null>): {
|
|
519
|
+
declare function useLayout<Options = any, Query$1 = any>(layoutId: Ref<string | null>): {
|
|
520
520
|
layoutWrapper: ComputedRef<Component>;
|
|
521
521
|
};
|
|
522
522
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { computed, defineComponent, inject, isRef, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, reactive, ref, shallowRef, toRef, toRefs, unref, watch } from "vue";
|
|
2
2
|
import { API_INJECT, EXTENSIONS_INJECT, SDK_INJECT, STORES_INJECT } from "@directus/constants";
|
|
3
3
|
import { nanoid } from "nanoid";
|
|
4
|
-
import { isEqual, isNil
|
|
4
|
+
import { debounce, isEqual, isNil } from "lodash-es";
|
|
5
5
|
import { getEndpoint, moveInArray } from "@directus/utils";
|
|
6
6
|
import axios from "axios";
|
|
7
7
|
|
|
@@ -372,36 +372,30 @@ function useCollection(collectionKey) {
|
|
|
372
372
|
if (!collection.value) return [];
|
|
373
373
|
return fieldsStore.getFieldsForCollectionSorted(collection.value);
|
|
374
374
|
});
|
|
375
|
-
const defaults = computed(() => {
|
|
376
|
-
if (!fields.value) return {};
|
|
377
|
-
const defaults$1 = {};
|
|
378
|
-
for (const field of fields.value) if (field.schema !== null && "default_value" in field.schema) defaults$1[field.field] = field.schema.default_value;
|
|
379
|
-
return defaults$1;
|
|
380
|
-
});
|
|
381
|
-
const primaryKeyField = computed(() => {
|
|
382
|
-
return fields.value.find((field) => field.collection === collection.value && field.schema?.is_primary_key === true) || null;
|
|
383
|
-
});
|
|
384
|
-
const userCreatedField = computed(() => {
|
|
385
|
-
return fields.value?.find((field) => (field.meta?.special || []).includes("user_created")) || null;
|
|
386
|
-
});
|
|
387
|
-
const sortField = computed(() => {
|
|
388
|
-
return info.value?.meta?.sort_field || null;
|
|
389
|
-
});
|
|
390
|
-
const isSingleton = computed(() => {
|
|
391
|
-
return info.value?.meta?.singleton === true;
|
|
392
|
-
});
|
|
393
|
-
const accountabilityScope = computed(() => {
|
|
394
|
-
return info.value?.meta?.accountability || null;
|
|
395
|
-
});
|
|
396
375
|
return {
|
|
397
376
|
info,
|
|
398
377
|
fields,
|
|
399
|
-
defaults
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
378
|
+
defaults: computed(() => {
|
|
379
|
+
if (!fields.value) return {};
|
|
380
|
+
const defaults = {};
|
|
381
|
+
for (const field of fields.value) if (field.schema !== null && "default_value" in field.schema) defaults[field.field] = field.schema.default_value;
|
|
382
|
+
return defaults;
|
|
383
|
+
}),
|
|
384
|
+
primaryKeyField: computed(() => {
|
|
385
|
+
return fields.value.find((field) => field.collection === collection.value && field.schema?.is_primary_key === true) || null;
|
|
386
|
+
}),
|
|
387
|
+
userCreatedField: computed(() => {
|
|
388
|
+
return fields.value?.find((field) => (field.meta?.special || []).includes("user_created")) || null;
|
|
389
|
+
}),
|
|
390
|
+
sortField: computed(() => {
|
|
391
|
+
return info.value?.meta?.sort_field || null;
|
|
392
|
+
}),
|
|
393
|
+
isSingleton: computed(() => {
|
|
394
|
+
return info.value?.meta?.singleton === true;
|
|
395
|
+
}),
|
|
396
|
+
accountabilityScope: computed(() => {
|
|
397
|
+
return info.value?.meta?.accountability || null;
|
|
398
|
+
})
|
|
405
399
|
};
|
|
406
400
|
}
|
|
407
401
|
|
|
@@ -895,7 +889,9 @@ function useItems(collection, query) {
|
|
|
895
889
|
filter: null
|
|
896
890
|
};
|
|
897
891
|
let loadingTimeout = null;
|
|
898
|
-
const fetchItems =
|
|
892
|
+
const fetchItems = debounce((shouldUpdateCount) => {
|
|
893
|
+
Promise.all([getItems(), shouldUpdateCount ? getItemCount() : Promise.resolve()]);
|
|
894
|
+
}, 350);
|
|
899
895
|
watch([
|
|
900
896
|
collection,
|
|
901
897
|
limit,
|
|
@@ -915,8 +911,7 @@ function useItems(collection, query) {
|
|
|
915
911
|
if (!isEqual(newFilter, oldFilter) || !isEqual(newSort, oldSort) || newLimit !== oldLimit || newSearch !== oldSearch) {
|
|
916
912
|
if (oldCollection) page.value = 1;
|
|
917
913
|
}
|
|
918
|
-
|
|
919
|
-
fetchItems();
|
|
914
|
+
fetchItems(newCollection !== oldCollection || !isEqual(newFilter, oldFilter) || newSearch !== oldSearch);
|
|
920
915
|
}, {
|
|
921
916
|
deep: true,
|
|
922
917
|
immediate: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/composables",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.4",
|
|
4
4
|
"description": "Shared Vue composables for Directus use",
|
|
5
5
|
"homepage": "https://directus.io",
|
|
6
6
|
"repository": {
|
|
@@ -22,27 +22,27 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"axios": "1.
|
|
25
|
+
"axios": "1.12.2",
|
|
26
26
|
"lodash-es": "4.17.21",
|
|
27
|
-
"nanoid": "5.1.
|
|
28
|
-
"@directus/
|
|
29
|
-
"@directus/
|
|
27
|
+
"nanoid": "5.1.6",
|
|
28
|
+
"@directus/constants": "14.0.0",
|
|
29
|
+
"@directus/utils": "13.0.11"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@directus/tsconfig": "3.0.0",
|
|
33
33
|
"@types/lodash-es": "4.17.12",
|
|
34
34
|
"@vitest/coverage-v8": "3.2.4",
|
|
35
35
|
"@vue/test-utils": "2.4.6",
|
|
36
|
-
"tsdown": "0.
|
|
37
|
-
"typescript": "5.
|
|
36
|
+
"tsdown": "0.15.11",
|
|
37
|
+
"typescript": "5.9.3",
|
|
38
38
|
"vitest": "3.2.4",
|
|
39
|
-
"vue": "3.5.
|
|
40
|
-
"@directus/extensions": "3.0.
|
|
41
|
-
"@directus/
|
|
42
|
-
"@directus/
|
|
39
|
+
"vue": "3.5.22",
|
|
40
|
+
"@directus/extensions": "3.0.12",
|
|
41
|
+
"@directus/types": "13.3.0",
|
|
42
|
+
"@directus/sdk": "20.1.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"vue": "3.5.
|
|
45
|
+
"vue": "3.5.22"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsdown src/index.ts --dts",
|