@directus/composables 11.4.1 → 11.5.0-rc.1
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 +3 -2
- package/dist/index.js +24 -14
- package/license +1 -1
- package/package.json +8 -8
- package/readme.md +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -403,8 +403,8 @@ type UsableItems = {
|
|
|
403
403
|
error: Ref<any>;
|
|
404
404
|
changeManualSort: (data: ManualSortData) => Promise<void>;
|
|
405
405
|
getItems: () => Promise<void>;
|
|
406
|
-
getTotalCount: () => Promise<void>;
|
|
407
|
-
getItemCount: () => Promise<void>;
|
|
406
|
+
getTotalCount: (force?: boolean) => Promise<void>;
|
|
407
|
+
getItemCount: (force?: boolean) => Promise<void>;
|
|
408
408
|
};
|
|
409
409
|
type ComputedQuery = {
|
|
410
410
|
fields: Ref<Query['fields']> | ComputedRef<Query['fields']> | WritableComputedRef<Query['fields']>;
|
|
@@ -417,6 +417,7 @@ type ComputedQuery = {
|
|
|
417
417
|
filterSystem?: Ref<Query['filter']> | ComputedRef<Query['filter']> | WritableComputedRef<Query['filter']>;
|
|
418
418
|
alias?: Ref<Query['alias']> | ComputedRef<Query['alias']> | WritableComputedRef<Query['alias']>;
|
|
419
419
|
deep?: Ref<Query['deep']> | ComputedRef<Query['deep']> | WritableComputedRef<Query['deep']>;
|
|
420
|
+
version?: Ref<Query['version']> | ComputedRef<Query['version']> | WritableComputedRef<Query['version']>;
|
|
420
421
|
};
|
|
421
422
|
declare function useItems(collection: Ref<string | null>, query: ComputedQuery): UsableItems;
|
|
422
423
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -869,7 +869,7 @@ function useGroupableParent(state = {}, options = {}, group = "item-group") {
|
|
|
869
869
|
function useItems(collection, query) {
|
|
870
870
|
const api = useApi();
|
|
871
871
|
const { primaryKeyField } = useCollection(collection);
|
|
872
|
-
const { fields, limit, sort, search, filter, page, filterSystem, alias, deep } = query;
|
|
872
|
+
const { fields, limit, sort, search, filter, page, filterSystem, alias, deep, version } = query;
|
|
873
873
|
const endpoint = computed(() => {
|
|
874
874
|
if (!collection.value) return null;
|
|
875
875
|
return getEndpoint(collection.value);
|
|
@@ -904,7 +904,7 @@ function useItems(collection, query) {
|
|
|
904
904
|
return JSON.stringify(key);
|
|
905
905
|
} });
|
|
906
906
|
const fetchItems = throttle((shouldUpdateCount) => {
|
|
907
|
-
Promise.all([getItems(), shouldUpdateCount ? getItemCount() : Promise.resolve()]);
|
|
907
|
+
Promise.all([getItems(), shouldUpdateCount && !unref(version) ? getItemCount() : Promise.resolve()]);
|
|
908
908
|
}, 500);
|
|
909
909
|
watch([
|
|
910
910
|
collection,
|
|
@@ -912,27 +912,32 @@ function useItems(collection, query) {
|
|
|
912
912
|
sort,
|
|
913
913
|
search,
|
|
914
914
|
filter,
|
|
915
|
+
toRef(version),
|
|
915
916
|
fields,
|
|
916
917
|
page,
|
|
917
918
|
toRef(alias),
|
|
918
919
|
toRef(deep)
|
|
919
920
|
], async (after, before) => {
|
|
920
921
|
if (isEqual(after, before)) return;
|
|
921
|
-
const [newCollection, newLimit, newSort, newSearch, newFilter] = after;
|
|
922
|
-
const [oldCollection, oldLimit, oldSort, oldSearch, oldFilter] = before;
|
|
922
|
+
const [newCollection, newLimit, newSort, newSearch, newFilter, newVersion] = after;
|
|
923
|
+
const [oldCollection, oldLimit, oldSort, oldSearch, oldFilter, oldVersion] = before;
|
|
923
924
|
if (!newCollection || !query) return;
|
|
924
925
|
if (newCollection !== oldCollection) reset();
|
|
925
926
|
if (!isEqual(newFilter, oldFilter) || !isEqual(newSort, oldSort) || newLimit !== oldLimit || newSearch !== oldSearch) {
|
|
926
927
|
if (oldCollection) page.value = 1;
|
|
927
928
|
}
|
|
928
|
-
fetchItems(newCollection !== oldCollection || !isEqual(newFilter, oldFilter) || newSearch !== oldSearch);
|
|
929
|
+
fetchItems(newCollection !== oldCollection || !isEqual(newFilter, oldFilter) || newSearch !== oldSearch || !isEqual(newVersion, oldVersion));
|
|
929
930
|
}, {
|
|
930
931
|
deep: true,
|
|
931
932
|
immediate: true
|
|
932
933
|
});
|
|
933
|
-
watch([
|
|
934
|
+
watch([
|
|
935
|
+
collection,
|
|
936
|
+
toRef(filterSystem),
|
|
937
|
+
toRef(version)
|
|
938
|
+
], async (after, before) => {
|
|
934
939
|
if (isEqual(after, before)) return;
|
|
935
|
-
getTotalCount();
|
|
940
|
+
if (!unref(version)) getTotalCount();
|
|
936
941
|
}, {
|
|
937
942
|
deep: true,
|
|
938
943
|
immediate: true
|
|
@@ -973,7 +978,8 @@ function useItems(collection, query) {
|
|
|
973
978
|
page: unref(page),
|
|
974
979
|
search: unref(search),
|
|
975
980
|
filter: unref(filter),
|
|
976
|
-
deep: unref(deep)
|
|
981
|
+
deep: unref(deep),
|
|
982
|
+
version: unref(version)
|
|
977
983
|
},
|
|
978
984
|
signal: itemsAbort.signal
|
|
979
985
|
})).data.data;
|
|
@@ -993,6 +999,10 @@ function useItems(collection, query) {
|
|
|
993
999
|
$thumbnail: file
|
|
994
1000
|
}));
|
|
995
1001
|
items.value = fetchedItems;
|
|
1002
|
+
if (unref(version)) {
|
|
1003
|
+
itemCount.value = fetchedItems.length;
|
|
1004
|
+
totalCount.value = fetchedItems.length;
|
|
1005
|
+
}
|
|
996
1006
|
if (page && fetchedItems.length === 0 && page?.value !== 1) page.value = 1;
|
|
997
1007
|
} catch (err) {
|
|
998
1008
|
if (axios.isCancel(err)) isCurrentRequestCanceled = true;
|
|
@@ -1011,6 +1021,7 @@ function useItems(collection, query) {
|
|
|
1011
1021
|
itemCount.value = null;
|
|
1012
1022
|
}
|
|
1013
1023
|
async function changeManualSort({ item, to }) {
|
|
1024
|
+
if (unref(version)) return;
|
|
1014
1025
|
const pk = primaryKeyField.value?.field;
|
|
1015
1026
|
if (!pk) return;
|
|
1016
1027
|
const fromIndex = items.value.findIndex((existing) => existing[pk] === item);
|
|
@@ -1022,23 +1033,23 @@ function useItems(collection, query) {
|
|
|
1022
1033
|
to
|
|
1023
1034
|
});
|
|
1024
1035
|
}
|
|
1025
|
-
async function getTotalCount() {
|
|
1036
|
+
async function getTotalCount(force = false) {
|
|
1026
1037
|
if (!endpoint.value) return;
|
|
1027
1038
|
const currentGeneration = ++totalCountGeneration;
|
|
1028
1039
|
try {
|
|
1029
|
-
const count = await fetchAggregate(endpoint.value, filterSystem?.value, void 0);
|
|
1040
|
+
const count = await (force ? fetchAggregate.load : fetchAggregate)(endpoint.value, filterSystem?.value, void 0);
|
|
1030
1041
|
if (currentGeneration !== totalCountGeneration) return;
|
|
1031
1042
|
totalCount.value = count;
|
|
1032
1043
|
} catch (err) {
|
|
1033
1044
|
if (!axios.isCancel(err)) throw err;
|
|
1034
1045
|
}
|
|
1035
1046
|
}
|
|
1036
|
-
async function getItemCount() {
|
|
1047
|
+
async function getItemCount(force = false) {
|
|
1037
1048
|
if (!endpoint.value) return;
|
|
1038
1049
|
const currentGeneration = ++itemCountGeneration;
|
|
1039
1050
|
loadingItemCount.value = true;
|
|
1040
1051
|
try {
|
|
1041
|
-
const count = await fetchAggregate(endpoint.value, filter.value, search.value);
|
|
1052
|
+
const count = await (force ? fetchAggregate.load : fetchAggregate)(endpoint.value, filter.value, search.value);
|
|
1042
1053
|
if (currentGeneration !== itemCountGeneration) return;
|
|
1043
1054
|
itemCount.value = count;
|
|
1044
1055
|
} catch (err) {
|
|
@@ -1176,8 +1187,7 @@ function createLayoutWrapper(layout) {
|
|
|
1176
1187
|
setup(props, { emit }) {
|
|
1177
1188
|
const state = reactive({
|
|
1178
1189
|
...layout.setup(props, { emit }),
|
|
1179
|
-
...toRefs(props)
|
|
1180
|
-
sidebarShadow: layout.sidebarShadow ?? false
|
|
1190
|
+
...toRefs(props)
|
|
1181
1191
|
});
|
|
1182
1192
|
for (const key in state) state[`onUpdate:${key}`] = (value) => {
|
|
1183
1193
|
if (isWritableProp(key)) emit(`update:${key}`, value);
|
package/license
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright 2026 Monospace, Inc.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
6
|
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/composables",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.0-rc.1",
|
|
4
4
|
"description": "Shared Vue composables for Directus use",
|
|
5
|
-
"homepage": "https://directus.
|
|
5
|
+
"homepage": "https://directus.com",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/directus/directus.git",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@vueuse/core": "14.0.0",
|
|
26
|
-
"axios": "1.
|
|
26
|
+
"axios": "1.16.1",
|
|
27
27
|
"lodash-es": "4.18.1",
|
|
28
28
|
"nanoid": "5.1.6",
|
|
29
|
-
"@directus/constants": "14.
|
|
30
|
-
"@directus/utils": "13.
|
|
29
|
+
"@directus/constants": "14.4.0-rc.1",
|
|
30
|
+
"@directus/utils": "13.5.0-rc.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@directus/tsconfig": "4.0.0",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"typescript": "5.9.3",
|
|
39
39
|
"vitest": "3.2.4",
|
|
40
40
|
"vue": "3.5.24",
|
|
41
|
-
"@directus/extensions": "
|
|
42
|
-
"@directus/
|
|
43
|
-
"@directus/
|
|
41
|
+
"@directus/extensions": "4.0.0-rc.1",
|
|
42
|
+
"@directus/sdk": "22.0.0-rc.1",
|
|
43
|
+
"@directus/types": "16.0.0-rc.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"vue": "3.5.24"
|
package/readme.md
CHANGED
|
@@ -6,7 +6,7 @@ Shared Vue composables for Directus use
|
|
|
6
6
|
|
|
7
7
|
This package provides shared Vue composables for use within Directus, an open-source headless CMS.
|
|
8
8
|
|
|
9
|
-
For more information about Directus, visit the [official website](https://directus.
|
|
9
|
+
For more information about Directus, visit the [official website](https://directus.com).
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
@@ -21,5 +21,5 @@ This package is licensed under the MIT License. See the
|
|
|
21
21
|
|
|
22
22
|
## Additional Resources
|
|
23
23
|
|
|
24
|
-
- [Directus Website](https://directus.
|
|
24
|
+
- [Directus Website](https://directus.com)
|
|
25
25
|
- [Directus GitHub Repository](https://github.com/directus/directus)
|