@xwiki/cristal-dsvuetify 0.14.0 → 0.16.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 +32 -0
- package/dist/{index-C4ioHAez.js → index-CLqR2xXr.js} +5946 -5812
- package/dist/index-CLqR2xXr.js.map +1 -0
- package/dist/index.es.js +7 -5
- package/dist/index.umd.js +11 -9
- 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 +3 -3
- package/dist/vue/form/x-navigation-tree-select.vue.d.ts +14 -0
- package/dist/vue/x-navigation-tree.vue.d.ts +4 -8
- package/dist/{x-alert-CTAhsN6L.js → x-alert-CRdF8zFB.js} +4 -4
- package/dist/x-alert-CRdF8zFB.js.map +1 -0
- package/dist/{x-btn-BsiSIiiO.js → x-btn-DwTcXGgx.js} +2 -2
- package/dist/{x-btn-BsiSIiiO.js.map → x-btn-DwTcXGgx.js.map} +1 -1
- package/dist/{x-checkbox-CJ3_IJ-Y.js → x-checkbox-BMonacnS.js} +7 -7
- package/dist/{x-checkbox-CJ3_IJ-Y.js.map → x-checkbox-BMonacnS.js.map} +1 -1
- package/dist/x-dialog-DCEnccuq.js +48 -0
- package/dist/x-dialog-DCEnccuq.js.map +1 -0
- package/dist/{x-file-input-CMM5DWJc.js → x-file-input-CUcSVuxz.js} +14 -11
- package/dist/{x-file-input-CMM5DWJc.js.map → x-file-input-CUcSVuxz.js.map} +1 -1
- package/dist/x-form-DWpzuKe6.js +25 -0
- package/dist/x-form-DWpzuKe6.js.map +1 -0
- package/dist/x-navigation-tree-CeAKceG7.js +543 -0
- package/dist/x-navigation-tree-CeAKceG7.js.map +1 -0
- package/dist/x-navigation-tree-select-C6j0iSBP.js +99 -0
- package/dist/x-navigation-tree-select-C6j0iSBP.js.map +1 -0
- package/dist/{x-tab-group-Bp7V46k9.js → x-tab-group-D1jmHXyJ.js} +2 -2
- package/dist/x-tab-group-D1jmHXyJ.js.map +1 -0
- package/dist/x-text-field-D94TCr6e.js +45 -0
- package/dist/{x-text-field-BxSiyeFc.js.map → x-text-field-D94TCr6e.js.map} +1 -1
- package/langs/translation-de.json +3 -1
- package/langs/translation-en.json +3 -1
- package/langs/translation-fr.json +3 -1
- package/package.json +15 -13
- package/src/components/componentsInit.ts +1 -1
- package/src/components/vuetifyDesignSystemLoader.ts +7 -2
- package/src/translations.ts +4 -0
- package/src/vue/__tests__/utils/vuetify.ts +0 -1
- package/src/vue/css/style.css +1 -1
- package/src/vue/form/x-checkbox.vue +1 -1
- package/src/vue/form/x-form.vue +8 -4
- package/src/vue/form/x-navigation-tree-select.vue +125 -0
- package/src/vue/form/x-text-field.vue +4 -0
- package/src/vue/x-navigation-tree.vue +43 -37
- package/src/vue/x-tab-group.vue +2 -2
- package/dist/index-C4ioHAez.js.map +0 -1
- package/dist/translations-BNEIsfPR.js +0 -10
- package/dist/x-alert-CTAhsN6L.js.map +0 -1
- package/dist/x-dialog-C4gz0mOu.js +0 -48
- package/dist/x-dialog-C4gz0mOu.js.map +0 -1
- package/dist/x-form-BLg386BG.js +0 -32
- package/dist/x-form-BLg386BG.js.map +0 -1
- package/dist/x-navigation-tree-BW05Yivz.js +0 -502
- package/dist/x-navigation-tree-BW05Yivz.js.map +0 -1
- package/dist/x-tab-group-Bp7V46k9.js.map +0 -1
- package/dist/x-text-field-BxSiyeFc.js +0 -38
|
@@ -29,13 +29,17 @@ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
29
29
|
* item was disabled. Default hover effects, such as darkening or changing
|
|
30
30
|
* the cursor on items, were also disabled.
|
|
31
31
|
*/
|
|
32
|
+
import { navigationTreePropsDefaults } from "@xwiki/cristal-dsapi";
|
|
32
33
|
import { inject, onBeforeMount, ref, watch } from "vue";
|
|
33
34
|
import { VTreeview } from "vuetify/labs/VTreeview";
|
|
34
|
-
import type { CristalApp
|
|
35
|
+
import type { CristalApp } from "@xwiki/cristal-api";
|
|
35
36
|
import type { DocumentService } from "@xwiki/cristal-document-api";
|
|
36
|
-
import type {
|
|
37
|
+
import type { NavigationTreeProps } from "@xwiki/cristal-dsapi";
|
|
38
|
+
import type {
|
|
39
|
+
DocumentReference,
|
|
40
|
+
SpaceReference,
|
|
41
|
+
} from "@xwiki/cristal-model-api";
|
|
37
42
|
import type {
|
|
38
|
-
NavigationTreeNode,
|
|
39
43
|
NavigationTreeSource,
|
|
40
44
|
NavigationTreeSourceProvider,
|
|
41
45
|
} from "@xwiki/cristal-navigation-tree-api";
|
|
@@ -47,10 +51,9 @@ type TreeItem = {
|
|
|
47
51
|
href: string;
|
|
48
52
|
children?: Array<TreeItem>;
|
|
49
53
|
_location: SpaceReference;
|
|
54
|
+
_is_terminal: boolean;
|
|
50
55
|
};
|
|
51
56
|
|
|
52
|
-
type OnClickAction = (node: NavigationTreeNode) => void;
|
|
53
|
-
|
|
54
57
|
const cristal: CristalApp = inject<CristalApp>("cristal")!;
|
|
55
58
|
const documentService: DocumentService = cristal
|
|
56
59
|
.getContainer()
|
|
@@ -63,22 +66,23 @@ const treeSource: NavigationTreeSource = cristal
|
|
|
63
66
|
const rootNodes: Ref<Array<TreeItem>> = ref([]);
|
|
64
67
|
|
|
65
68
|
const activatedNodes: Ref<Array<string>> = ref(new Array<string>());
|
|
66
|
-
const expandedNodes: Ref<
|
|
69
|
+
const expandedNodes: Ref<unknown> = ref([]);
|
|
67
70
|
var isExpanding: boolean = false;
|
|
68
71
|
|
|
69
|
-
const props =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
const props = withDefaults(
|
|
73
|
+
defineProps<NavigationTreeProps>(),
|
|
74
|
+
navigationTreePropsDefaults,
|
|
75
|
+
);
|
|
73
76
|
|
|
74
77
|
onBeforeMount(async () => {
|
|
75
|
-
for (const node of await
|
|
78
|
+
for (const node of await getChildNodes("")) {
|
|
76
79
|
rootNodes.value.push({
|
|
77
80
|
id: node.id,
|
|
78
81
|
title: node.label,
|
|
79
82
|
href: node.url,
|
|
80
83
|
children: node.has_children ? [] : undefined,
|
|
81
84
|
_location: node.location,
|
|
85
|
+
_is_terminal: node.is_terminal,
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
88
|
await expandTree();
|
|
@@ -87,14 +91,17 @@ onBeforeMount(async () => {
|
|
|
87
91
|
documentService.registerDocumentChangeListener("update", onDocumentUpdate);
|
|
88
92
|
});
|
|
89
93
|
|
|
90
|
-
watch(() => props.
|
|
94
|
+
watch(() => props.currentPageReference, expandTree);
|
|
91
95
|
|
|
92
96
|
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
93
97
|
// eslint-disable-next-line max-statements
|
|
94
98
|
async function expandTree() {
|
|
95
|
-
if (props.
|
|
99
|
+
if (props.currentPageReference && !isExpanding) {
|
|
96
100
|
isExpanding = true;
|
|
97
|
-
const newExpandedNodes = treeSource.getParentNodesId(
|
|
101
|
+
const newExpandedNodes = treeSource.getParentNodesId(
|
|
102
|
+
props.currentPageReference!,
|
|
103
|
+
props.includeTerminals,
|
|
104
|
+
);
|
|
98
105
|
let i;
|
|
99
106
|
let currentNodes = rootNodes.value;
|
|
100
107
|
for (i = 0; i < newExpandedNodes.length - 1; i++) {
|
|
@@ -104,8 +111,8 @@ async function expandTree() {
|
|
|
104
111
|
if (node.children?.length == 0) {
|
|
105
112
|
await lazyLoadChildren(node);
|
|
106
113
|
}
|
|
107
|
-
if (!expandedNodes.value.includes(node.id)) {
|
|
108
|
-
expandedNodes.value.push(node.id);
|
|
114
|
+
if (!(expandedNodes.value as unknown[]).includes(node.id)) {
|
|
115
|
+
(expandedNodes.value as unknown[]).push(node.id);
|
|
109
116
|
}
|
|
110
117
|
currentNodes = node.children!;
|
|
111
118
|
}
|
|
@@ -125,6 +132,7 @@ async function expandTree() {
|
|
|
125
132
|
location: node._location,
|
|
126
133
|
url: node.href,
|
|
127
134
|
has_children: node.children !== undefined,
|
|
135
|
+
is_terminal: node._is_terminal,
|
|
128
136
|
});
|
|
129
137
|
}
|
|
130
138
|
}
|
|
@@ -136,7 +144,7 @@ async function expandTree() {
|
|
|
136
144
|
|
|
137
145
|
async function lazyLoadChildren(item: unknown) {
|
|
138
146
|
const treeItem = item as TreeItem;
|
|
139
|
-
const childNodes = await
|
|
147
|
+
const childNodes = await getChildNodes(treeItem.id);
|
|
140
148
|
for (const child of childNodes) {
|
|
141
149
|
treeItem.children?.push({
|
|
142
150
|
id: child.id,
|
|
@@ -144,6 +152,7 @@ async function lazyLoadChildren(item: unknown) {
|
|
|
144
152
|
href: child.url,
|
|
145
153
|
children: child.has_children ? [] : undefined,
|
|
146
154
|
_location: child.location,
|
|
155
|
+
_is_terminal: child.is_terminal,
|
|
147
156
|
});
|
|
148
157
|
}
|
|
149
158
|
// If the node doesn't have any children, we update it.
|
|
@@ -163,8 +172,8 @@ function clearSelection() {
|
|
|
163
172
|
|
|
164
173
|
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
165
174
|
// eslint-disable-next-line max-statements
|
|
166
|
-
async function onDocumentDelete(page:
|
|
167
|
-
const parents = treeSource.getParentNodesId(page);
|
|
175
|
+
async function onDocumentDelete(page: DocumentReference) {
|
|
176
|
+
const parents = treeSource.getParentNodesId(page, props.includeTerminals);
|
|
168
177
|
let currentItem: TreeItem | undefined = undefined;
|
|
169
178
|
let currentItemChildren: TreeItem[] | undefined = rootNodes.value;
|
|
170
179
|
let notFound = false;
|
|
@@ -192,8 +201,8 @@ async function onDocumentDelete(page: PageData) {
|
|
|
192
201
|
|
|
193
202
|
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
194
203
|
// eslint-disable-next-line max-statements
|
|
195
|
-
async function onDocumentUpdate(page:
|
|
196
|
-
const parents = treeSource.getParentNodesId(page);
|
|
204
|
+
async function onDocumentUpdate(page: DocumentReference) {
|
|
205
|
+
const parents = treeSource.getParentNodesId(page, props.includeTerminals);
|
|
197
206
|
let currentParent: string | undefined = undefined;
|
|
198
207
|
let currentItems: TreeItem[] | undefined = rootNodes.value;
|
|
199
208
|
let notFound = false;
|
|
@@ -204,7 +213,7 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
204
213
|
if (currentItems[i].id == parents[0]) {
|
|
205
214
|
if (parents.length == 1) {
|
|
206
215
|
// Page update
|
|
207
|
-
const newItems = await
|
|
216
|
+
const newItems = await getChildNodes(
|
|
208
217
|
currentParent ? currentParent : "",
|
|
209
218
|
);
|
|
210
219
|
for (const newItem of newItems) {
|
|
@@ -235,10 +244,11 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
235
244
|
// We don't do anything because this node will be loaded lazily anyway.
|
|
236
245
|
return;
|
|
237
246
|
}
|
|
238
|
-
const newItems = await
|
|
239
|
-
|
|
247
|
+
const newItems = await getChildNodes(currentParent ? currentParent : "");
|
|
248
|
+
const currentPageParents = treeSource.getParentNodesId(
|
|
249
|
+
props.currentPageReference!,
|
|
250
|
+
props.includeTerminals,
|
|
240
251
|
);
|
|
241
|
-
const currentPageParents = treeSource.getParentNodesId(props.currentPage);
|
|
242
252
|
newItemsLoop: for (const newItem of newItems) {
|
|
243
253
|
for (const i of currentItems!.keys()) {
|
|
244
254
|
if (newItem.id == currentItems![i].id) {
|
|
@@ -251,6 +261,7 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
251
261
|
href: newItem.url,
|
|
252
262
|
children: newItem.has_children ? [] : undefined,
|
|
253
263
|
_location: newItem.location,
|
|
264
|
+
_is_terminal: newItem.is_terminal,
|
|
254
265
|
});
|
|
255
266
|
if (
|
|
256
267
|
currentPageParents.length > 0 &&
|
|
@@ -261,6 +272,12 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
261
272
|
}
|
|
262
273
|
}
|
|
263
274
|
}
|
|
275
|
+
|
|
276
|
+
async function getChildNodes(id: string) {
|
|
277
|
+
return (await treeSource.getChildNodes(id)).filter(
|
|
278
|
+
(c) => props.includeTerminals || !c.is_terminal,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
264
281
|
</script>
|
|
265
282
|
|
|
266
283
|
<template>
|
|
@@ -287,6 +304,7 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
287
304
|
location: item._location,
|
|
288
305
|
url: item.href,
|
|
289
306
|
has_children: item.children !== undefined,
|
|
307
|
+
is_terminal: item._is_terminal,
|
|
290
308
|
});
|
|
291
309
|
"
|
|
292
310
|
>{{ item.title }}</a
|
|
@@ -312,16 +330,4 @@ async function onDocumentUpdate(page: PageData) {
|
|
|
312
330
|
:deep(.v-list-item--link) {
|
|
313
331
|
cursor: default;
|
|
314
332
|
}
|
|
315
|
-
/*TODO: This section needs to be removed when the oficial fix is released on Vuetify
|
|
316
|
-
https://github.com/vuetifyjs/vuetify/issues/20421#event-16001533054
|
|
317
|
-
START FIX
|
|
318
|
-
*/
|
|
319
|
-
:deep(.v-treeview-item:not(.v-list-group__header)) {
|
|
320
|
-
padding-inline-start: calc(39px + 6px) !important;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
:deep(.v-treeview-item .v-list-item__spacer) {
|
|
324
|
-
width: 4px !important;
|
|
325
|
-
}
|
|
326
|
-
/*END FIX*/
|
|
327
333
|
</style>
|
package/src/vue/x-tab-group.vue
CHANGED
|
@@ -18,8 +18,8 @@ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
18
18
|
02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
19
19
|
-->
|
|
20
20
|
<script setup lang="ts">
|
|
21
|
-
import { ref } from "vue";
|
|
22
|
-
const tab = ref(
|
|
21
|
+
import { Ref, ref } from "vue";
|
|
22
|
+
const tab: Ref<unknown> = ref();
|
|
23
23
|
|
|
24
24
|
const emits = defineEmits(["tab-change"]);
|
|
25
25
|
|