@xwiki/cristal-dsvuetify 0.13.0 → 0.15.0
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/CHANGELOG.md +30 -0
- package/dist/{index-UP1o6s9t.js → index-BAakw3UY.js} +6415 -6339
- package/dist/index-BAakw3UY.js.map +1 -0
- package/dist/index.es.js +9 -6
- package/dist/index.umd.js +13 -10
- package/dist/index.umd.js.map +1 -1
- package/dist/translations-k4crOAds.js +24 -0
- package/dist/{translations-BNEIsfPR.js.map → translations-k4crOAds.js.map} +1 -1
- package/dist/vue/form/x-checkbox.vue.d.ts +11 -0
- package/dist/vue/form/x-file-input.vue.d.ts +6 -6
- package/dist/vue/form/x-form.vue.d.ts +2 -1
- package/dist/vue/form/x-navigation-tree-select.vue.d.ts +12 -0
- package/dist/vue/form/x-text-field.vue.d.ts +9 -1
- package/dist/vue/x-alert.vue.d.ts +2 -1
- package/dist/vue/x-avatar.vue.d.ts +2 -19
- package/dist/vue/x-btn.vue.d.ts +2 -1
- package/dist/vue/x-dialog.vue.d.ts +7 -8
- package/dist/vue/x-load.vue.d.ts +1 -1
- package/dist/vue/x-menu-item.vue.d.ts +6 -6
- package/dist/vue/x-menu-label.vue.d.ts +2 -1
- package/dist/vue/x-menu.vue.d.ts +2 -1
- package/dist/vue/x-navigation-tree.vue.d.ts +2 -10
- package/dist/vue/x-tab-group.vue.d.ts +4 -3
- package/dist/vue/x-tab-panel.vue.d.ts +2 -1
- package/dist/vue/x-tab.vue.d.ts +2 -1
- package/dist/x-alert-CRdF8zFB.js +46 -0
- package/dist/x-alert-CRdF8zFB.js.map +1 -0
- package/dist/x-avatar-Ds9aYRI9.js +28 -0
- package/dist/x-avatar-Ds9aYRI9.js.map +1 -0
- package/dist/{x-btn-DNlhiqjD.js → x-btn-DwTcXGgx.js} +8 -6
- package/dist/{x-btn-DNlhiqjD.js.map → x-btn-DwTcXGgx.js.map} +1 -1
- package/dist/x-checkbox-Fro597Ax.js +28 -0
- package/dist/x-checkbox-Fro597Ax.js.map +1 -0
- package/dist/x-dialog-DCEnccuq.js +48 -0
- package/dist/x-dialog-DCEnccuq.js.map +1 -0
- package/dist/x-file-input-CvH0AC3G.js +39 -0
- package/dist/{x-file-input-BsaodA0p.js.map → x-file-input-CvH0AC3G.js.map} +1 -1
- package/dist/x-form-DCHdDC6W.js +25 -0
- package/dist/x-form-DCHdDC6W.js.map +1 -0
- package/dist/x-navigation-tree-D_fUW-gW.js +520 -0
- package/dist/x-navigation-tree-D_fUW-gW.js.map +1 -0
- package/dist/x-navigation-tree-select-DaiYF3ux.js +95 -0
- package/dist/x-navigation-tree-select-DaiYF3ux.js.map +1 -0
- package/dist/{x-tab-group-ngNByee3.js → x-tab-group-Bp7V46k9.js} +5 -5
- package/dist/{x-tab-group-ngNByee3.js.map → x-tab-group-Bp7V46k9.js.map} +1 -1
- package/dist/x-text-field-2Sv6HUGW.js +43 -0
- package/dist/x-text-field-2Sv6HUGW.js.map +1 -0
- package/langs/translation-de.json +3 -1
- package/langs/translation-en.json +3 -1
- package/langs/translation-fr.json +6 -1
- package/package.json +15 -13
- package/src/components/vuetifyDesignSystemLoader.ts +12 -1
- package/src/translations.ts +4 -0
- package/src/vue/css/style.css +6 -0
- package/src/vue/form/x-checkbox.vue +35 -0
- package/src/vue/form/x-file-input.vue +2 -2
- package/src/vue/form/x-form.vue +8 -4
- package/src/vue/form/x-navigation-tree-select.vue +120 -0
- package/src/vue/form/x-text-field.vue +5 -0
- package/src/vue/x-alert.vue +8 -0
- package/src/vue/x-avatar.vue +9 -9
- package/src/vue/x-dialog.vue +1 -7
- package/src/vue/x-navigation-tree.vue +47 -24
- package/src/vue/x-tab-group.vue +2 -2
- package/src/vue/x-tab-panel.vue +0 -2
- package/dist/index-UP1o6s9t.js.map +0 -1
- package/dist/translations-BNEIsfPR.js +0 -10
- package/dist/x-alert-Bmt4mXHQ.js +0 -45
- package/dist/x-alert-Bmt4mXHQ.js.map +0 -1
- package/dist/x-avatar-But_Z7ic.js +0 -20
- package/dist/x-avatar-But_Z7ic.js.map +0 -1
- package/dist/x-dialog-C-dMkFJk.js +0 -49
- package/dist/x-dialog-C-dMkFJk.js.map +0 -1
- package/dist/x-file-input-BsaodA0p.js +0 -36
- package/dist/x-form-iQFXj1PW.js +0 -32
- package/dist/x-form-iQFXj1PW.js.map +0 -1
- package/dist/x-navigation-tree-DN2Qz7Sm.js +0 -501
- package/dist/x-navigation-tree-DN2Qz7Sm.js.map +0 -1
- package/dist/x-text-field-CTsLZhLE.js +0 -31
- package/dist/x-text-field-CTsLZhLE.js.map +0 -1
|
@@ -31,11 +31,14 @@ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
31
31
|
*/
|
|
32
32
|
import { inject, onBeforeMount, ref, watch } from "vue";
|
|
33
33
|
import { VTreeview } from "vuetify/labs/VTreeview";
|
|
34
|
-
import type { CristalApp
|
|
34
|
+
import type { CristalApp } from "@xwiki/cristal-api";
|
|
35
35
|
import type { DocumentService } from "@xwiki/cristal-document-api";
|
|
36
|
-
import type {
|
|
36
|
+
import type { NavigationTreeProps } from "@xwiki/cristal-dsapi";
|
|
37
|
+
import type {
|
|
38
|
+
DocumentReference,
|
|
39
|
+
SpaceReference,
|
|
40
|
+
} from "@xwiki/cristal-model-api";
|
|
37
41
|
import type {
|
|
38
|
-
NavigationTreeNode,
|
|
39
42
|
NavigationTreeSource,
|
|
40
43
|
NavigationTreeSourceProvider,
|
|
41
44
|
} from "@xwiki/cristal-navigation-tree-api";
|
|
@@ -49,8 +52,6 @@ type TreeItem = {
|
|
|
49
52
|
_location: SpaceReference;
|
|
50
53
|
};
|
|
51
54
|
|
|
52
|
-
type OnClickAction = (node: NavigationTreeNode) => void;
|
|
53
|
-
|
|
54
55
|
const cristal: CristalApp = inject<CristalApp>("cristal")!;
|
|
55
56
|
const documentService: DocumentService = cristal
|
|
56
57
|
.getContainer()
|
|
@@ -61,16 +62,12 @@ const treeSource: NavigationTreeSource = cristal
|
|
|
61
62
|
.get();
|
|
62
63
|
|
|
63
64
|
const rootNodes: Ref<Array<TreeItem>> = ref([]);
|
|
64
|
-
const tree: Ref<VTreeview | undefined> = ref(undefined);
|
|
65
65
|
|
|
66
66
|
const activatedNodes: Ref<Array<string>> = ref(new Array<string>());
|
|
67
67
|
const expandedNodes: Ref<Array<string>> = ref(new Array<string>());
|
|
68
68
|
var isExpanding: boolean = false;
|
|
69
69
|
|
|
70
|
-
const props = defineProps<
|
|
71
|
-
clickAction?: OnClickAction;
|
|
72
|
-
currentPage?: PageData;
|
|
73
|
-
}>();
|
|
70
|
+
const props = defineProps<NavigationTreeProps>();
|
|
74
71
|
|
|
75
72
|
onBeforeMount(async () => {
|
|
76
73
|
for (const node of await treeSource.getChildNodes("")) {
|
|
@@ -88,14 +85,16 @@ onBeforeMount(async () => {
|
|
|
88
85
|
documentService.registerDocumentChangeListener("update", onDocumentUpdate);
|
|
89
86
|
});
|
|
90
87
|
|
|
91
|
-
watch(() => props.
|
|
88
|
+
watch(() => props.currentPageReference, expandTree);
|
|
92
89
|
|
|
93
90
|
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
94
91
|
// eslint-disable-next-line max-statements
|
|
95
92
|
async function expandTree() {
|
|
96
|
-
if (props.
|
|
93
|
+
if (props.currentPageReference && !isExpanding) {
|
|
97
94
|
isExpanding = true;
|
|
98
|
-
const newExpandedNodes = treeSource.getParentNodesId(
|
|
95
|
+
const newExpandedNodes = treeSource.getParentNodesId(
|
|
96
|
+
props.currentPageReference,
|
|
97
|
+
);
|
|
99
98
|
let i;
|
|
100
99
|
let currentNodes = rootNodes.value;
|
|
101
100
|
for (i = 0; i < newExpandedNodes.length - 1; i++) {
|
|
@@ -164,32 +163,41 @@ function clearSelection() {
|
|
|
164
163
|
|
|
165
164
|
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
166
165
|
// eslint-disable-next-line max-statements
|
|
167
|
-
async function onDocumentDelete(page:
|
|
166
|
+
async function onDocumentDelete(page: DocumentReference) {
|
|
168
167
|
const parents = treeSource.getParentNodesId(page);
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
let currentItem: TreeItem | undefined = undefined;
|
|
169
|
+
let currentItemChildren: TreeItem[] | undefined = rootNodes.value;
|
|
170
|
+
let notFound = false;
|
|
171
|
+
|
|
172
|
+
currentItemsLoop: while (currentItemChildren && !notFound) {
|
|
173
|
+
for (const i of currentItemChildren.keys()) {
|
|
174
|
+
if (currentItemChildren[i].id == parents[0]) {
|
|
173
175
|
if (parents.length == 1) {
|
|
174
|
-
|
|
176
|
+
currentItemChildren.splice(i, 1);
|
|
177
|
+
if (currentItem && currentItemChildren.length == 0) {
|
|
178
|
+
currentItem!.children = undefined;
|
|
179
|
+
}
|
|
175
180
|
return;
|
|
176
181
|
} else {
|
|
177
|
-
|
|
182
|
+
currentItem = currentItemChildren[i];
|
|
183
|
+
currentItemChildren = currentItem.children;
|
|
178
184
|
parents.shift();
|
|
179
|
-
|
|
185
|
+
continue currentItemsLoop;
|
|
180
186
|
}
|
|
181
187
|
}
|
|
182
188
|
}
|
|
189
|
+
notFound = true;
|
|
183
190
|
}
|
|
184
191
|
}
|
|
185
192
|
|
|
186
193
|
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
187
194
|
// eslint-disable-next-line max-statements
|
|
188
|
-
async function onDocumentUpdate(page:
|
|
195
|
+
async function onDocumentUpdate(page: DocumentReference) {
|
|
189
196
|
const parents = treeSource.getParentNodesId(page);
|
|
190
197
|
let currentParent: string | undefined = undefined;
|
|
191
198
|
let currentItems: TreeItem[] | undefined = rootNodes.value;
|
|
192
199
|
let notFound = false;
|
|
200
|
+
let isRoot = true;
|
|
193
201
|
|
|
194
202
|
currentItemsLoop: while (currentItems && !notFound) {
|
|
195
203
|
for (const i of currentItems.keys()) {
|
|
@@ -208,10 +216,13 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
208
216
|
} else {
|
|
209
217
|
currentParent = currentItems[i].id;
|
|
210
218
|
if (!currentItems[i].children) {
|
|
219
|
+
// This node had no children, we reset this so new ones can be
|
|
220
|
+
// loaded lazily.
|
|
211
221
|
currentItems[i].children = [];
|
|
212
222
|
}
|
|
213
223
|
currentItems = currentItems[i].children;
|
|
214
224
|
parents.shift();
|
|
225
|
+
isRoot = false;
|
|
215
226
|
continue currentItemsLoop;
|
|
216
227
|
}
|
|
217
228
|
}
|
|
@@ -220,9 +231,16 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
220
231
|
}
|
|
221
232
|
|
|
222
233
|
// New page
|
|
234
|
+
if (currentItems.length == 0 && !isRoot) {
|
|
235
|
+
// We don't do anything because this node will be loaded lazily anyway.
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
223
238
|
const newItems = await treeSource.getChildNodes(
|
|
224
239
|
currentParent ? currentParent : "",
|
|
225
240
|
);
|
|
241
|
+
const currentPageParents = treeSource.getParentNodesId(
|
|
242
|
+
props.currentPageReference,
|
|
243
|
+
);
|
|
226
244
|
newItemsLoop: for (const newItem of newItems) {
|
|
227
245
|
for (const i of currentItems!.keys()) {
|
|
228
246
|
if (newItem.id == currentItems![i].id) {
|
|
@@ -236,13 +254,19 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
236
254
|
children: newItem.has_children ? [] : undefined,
|
|
237
255
|
_location: newItem.location,
|
|
238
256
|
});
|
|
257
|
+
if (
|
|
258
|
+
currentPageParents.length > 0 &&
|
|
259
|
+
currentPageParents[currentPageParents.length - 1] === newItem.id
|
|
260
|
+
) {
|
|
261
|
+
// If we add a node, and it's the current page, it should be activated.
|
|
262
|
+
activatedNodes.value = [newItem.id];
|
|
263
|
+
}
|
|
239
264
|
}
|
|
240
265
|
}
|
|
241
266
|
</script>
|
|
242
267
|
|
|
243
268
|
<template>
|
|
244
269
|
<v-treeview
|
|
245
|
-
ref="tree"
|
|
246
270
|
v-model:opened="expandedNodes"
|
|
247
271
|
density="compact"
|
|
248
272
|
:activated="activatedNodes"
|
|
@@ -251,7 +275,6 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
251
275
|
activatable
|
|
252
276
|
active-strategy="independent"
|
|
253
277
|
item-value="id"
|
|
254
|
-
open-strategy="multiple"
|
|
255
278
|
@update:activated="clearSelection"
|
|
256
279
|
>
|
|
257
280
|
<template #title="{ item }: { item: any }">
|
package/src/vue/x-tab-group.vue
CHANGED
|
@@ -21,11 +21,11 @@ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
21
21
|
import { ref } from "vue";
|
|
22
22
|
const tab = ref(null);
|
|
23
23
|
|
|
24
|
-
const emits = defineEmits(["change"]);
|
|
24
|
+
const emits = defineEmits(["tab-change"]);
|
|
25
25
|
|
|
26
26
|
function change(tabId: unknown) {
|
|
27
27
|
if (typeof tabId == "string") {
|
|
28
|
-
emits("change", tabId);
|
|
28
|
+
emits("tab-change", tabId);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
</script>
|