@xwiki/cristal-dsvuetify 0.9.0 → 0.10.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.
@@ -0,0 +1,49 @@
1
+ import { defineComponent as f, ref as i, resolveComponent as n, openBlock as V, createBlock as b, withCtx as a, createVNode as s, renderSlot as u } from "vue";
2
+ const x = /* @__PURE__ */ f({
3
+ __name: "x-tab-group",
4
+ emits: ["change"],
5
+ setup(g, { emit: d }) {
6
+ const t = i(null), m = d;
7
+ function r(e) {
8
+ typeof e == "string" && m("change", e);
9
+ }
10
+ return (e, o) => {
11
+ const _ = n("v-tabs"), c = n("v-tabs-window"), p = n("v-card-text"), v = n("v-card");
12
+ return V(), b(v, { class: "mx-auto" }, {
13
+ default: a(() => [
14
+ s(_, {
15
+ modelValue: t.value,
16
+ "onUpdate:modelValue": [
17
+ o[0] || (o[0] = (l) => t.value = l),
18
+ r
19
+ ]
20
+ }, {
21
+ default: a(() => [
22
+ u(e.$slots, "tabs")
23
+ ]),
24
+ _: 3
25
+ }, 8, ["modelValue"]),
26
+ s(p, null, {
27
+ default: a(() => [
28
+ s(c, {
29
+ modelValue: t.value,
30
+ "onUpdate:modelValue": o[1] || (o[1] = (l) => t.value = l)
31
+ }, {
32
+ default: a(() => [
33
+ u(e.$slots, "panels")
34
+ ]),
35
+ _: 3
36
+ }, 8, ["modelValue"])
37
+ ]),
38
+ _: 3
39
+ })
40
+ ]),
41
+ _: 3
42
+ });
43
+ };
44
+ }
45
+ });
46
+ export {
47
+ x as default
48
+ };
49
+ //# sourceMappingURL=x-tab-group-ngNByee3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"x-tab-group-DTR-H8Sn.js","sources":["../src/vue/x-tab-group.vue"],"sourcesContent":["<!--\nSee the LICENSE file distributed with this work for additional\ninformation regarding copyright ownership.\n\nThis is free software; you can redistribute it and/or modify it\nunder the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation; either version 2.1 of\nthe License, or (at your option) any later version.\n\nThis software is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this software; if not, write to the Free\nSoftware Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n<script setup lang=\"ts\">\nimport { ref } from \"vue\";\nconst tab = ref(null);\n\nconst emits = defineEmits([\"change\"]);\n\nfunction change(tabId: string) {\n emits(\"change\", tabId);\n}\n</script>\n\n<template>\n <v-card class=\"mx-auto\">\n <v-tabs v-model=\"tab\" @update:model-value=\"change\">\n <slot name=\"tabs\"></slot>\n </v-tabs>\n <v-card-text>\n <v-tabs-window v-model=\"tab\">\n <slot name=\"panels\"></slot>\n </v-tabs-window>\n </v-card-text>\n </v-card>\n</template>\n\n<style scoped></style>\n"],"names":["tab","ref","emits","__emit","change","tabId"],"mappings":";;;;;AAqBM,UAAAA,IAAMC,EAAI,IAAI,GAEdC,IAAQC;AAEd,aAASC,EAAOC,GAAe;AAC7B,MAAAH,EAAM,UAAUG,CAAK;AAAA,IACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"x-tab-group-ngNByee3.js","sources":["../src/vue/x-tab-group.vue"],"sourcesContent":["<!--\nSee the LICENSE file distributed with this work for additional\ninformation regarding copyright ownership.\n\nThis is free software; you can redistribute it and/or modify it\nunder the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation; either version 2.1 of\nthe License, or (at your option) any later version.\n\nThis software is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this software; if not, write to the Free\nSoftware Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n<script setup lang=\"ts\">\nimport { ref } from \"vue\";\nconst tab = ref(null);\n\nconst emits = defineEmits([\"change\"]);\n\nfunction change(tabId: unknown) {\n if (typeof tabId == \"string\") {\n emits(\"change\", tabId);\n }\n}\n</script>\n\n<template>\n <v-card class=\"mx-auto\">\n <v-tabs v-model=\"tab\" @update:model-value=\"change\">\n <slot name=\"tabs\"></slot>\n </v-tabs>\n <v-card-text>\n <v-tabs-window v-model=\"tab\">\n <slot name=\"panels\"></slot>\n </v-tabs-window>\n </v-card-text>\n </v-card>\n</template>\n\n<style scoped></style>\n"],"names":["tab","ref","emits","__emit","change","tabId"],"mappings":";;;;;AAqBM,UAAAA,IAAMC,EAAI,IAAI,GAEdC,IAAQC;AAEd,aAASC,EAAOC,GAAgB;AAC1B,MAAA,OAAOA,KAAS,YAClBH,EAAM,UAAUG,CAAK;AAAA,IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as a, computed as l, openBlock as u, createBlock as m, unref as p } from "vue";
2
2
  import { m as i } from "./translations-CFfpgNrx.js";
3
3
  import { useI18n as f } from "vue-i18n";
4
- import { a as c } from "./index-CkW0K4NP.js";
4
+ import { a as c } from "./index-BjjXwAdJ.js";
5
5
  const y = /* @__PURE__ */ a({
6
6
  __name: "x-text-field",
7
7
  props: {
@@ -26,4 +26,4 @@ const y = /* @__PURE__ */ a({
26
26
  export {
27
27
  y as default
28
28
  };
29
- //# sourceMappingURL=x-text-field-Ccv2SH00.js.map
29
+ //# sourceMappingURL=x-text-field-B88odaud.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"x-text-field-Ccv2SH00.js","sources":["../src/vue/form/x-text-field.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { type TextFieldProps } from \"@xwiki/cristal-dsapi\";\nimport { computed } from \"vue\";\nimport { VTextField } from \"vuetify/components/VTextField\";\nimport messages from \"../../translations\";\nimport { useI18n } from \"vue-i18n\";\n\nconst { t } = useI18n({\n messages,\n});\nconst props = defineProps<TextFieldProps>();\n\nconst rules = computed(() => {\n const rulesList = [];\n if (props.required) {\n rulesList.push((value: unknown) => {\n if (value) {\n return true;\n } else {\n return t(\"vuetify.text.input.mandatory\");\n }\n });\n }\n return rulesList;\n});\n</script>\n\n<template>\n <v-text-field :label=\"label\" :name=\"name\" :rules=\"rules\"></v-text-field>\n</template>\n\n<style scoped></style>\n"],"names":["t","useI18n","messages","props","__props","rules","computed","rulesList","value"],"mappings":";;;;;;;;;;;;AAOM,UAAA,EAAE,GAAAA,EAAE,IAAIC,EAAQ;AAAA,MACpB,UAAAC;AAAA,IAAA,CACD,GACKC,IAAQC,GAERC,IAAQC,EAAS,MAAM;AAC3B,YAAMC,IAAY,CAAA;AAClB,aAAIJ,EAAM,YACEI,EAAA,KAAK,CAACC,MACVA,IACK,KAEAR,EAAE,8BAA8B,CAE1C,GAEIO;AAAA,IAAA,CACR;;;;;;;;"}
1
+ {"version":3,"file":"x-text-field-B88odaud.js","sources":["../src/vue/form/x-text-field.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { type TextFieldProps } from \"@xwiki/cristal-dsapi\";\nimport { computed } from \"vue\";\nimport { VTextField } from \"vuetify/components/VTextField\";\nimport messages from \"../../translations\";\nimport { useI18n } from \"vue-i18n\";\n\nconst { t } = useI18n({\n messages,\n});\nconst props = defineProps<TextFieldProps>();\n\nconst rules = computed(() => {\n const rulesList = [];\n if (props.required) {\n rulesList.push((value: unknown) => {\n if (value) {\n return true;\n } else {\n return t(\"vuetify.text.input.mandatory\");\n }\n });\n }\n return rulesList;\n});\n</script>\n\n<template>\n <v-text-field :label=\"label\" :name=\"name\" :rules=\"rules\"></v-text-field>\n</template>\n\n<style scoped></style>\n"],"names":["t","useI18n","messages","props","__props","rules","computed","rulesList","value"],"mappings":";;;;;;;;;;;;AAOM,UAAA,EAAE,GAAAA,EAAE,IAAIC,EAAQ;AAAA,MACpB,UAAAC;AAAA,IAAA,CACD,GACKC,IAAQC,GAERC,IAAQC,EAAS,MAAM;AAC3B,YAAMC,IAAY,CAAA;AAClB,aAAIJ,EAAM,YACEI,EAAA,KAAK,CAACC,MACVA,IACK,KAEAR,EAAE,8BAA8B,CAE1C,GAEIO;AAAA,IAAA,CACR;;;;;;;;"}
@@ -0,0 +1 @@
1
+ {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwiki/cristal-dsvuetify",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "license": "LGPL 2.1",
5
5
  "author": "XWiki Org Community <contact@xwiki.org>",
6
6
  "homepage": "https://cristal.xwiki.org/",
@@ -23,15 +23,15 @@
23
23
  "main": "./dist/index.es.js",
24
24
  "dependencies": {
25
25
  "inversify": "6.0.2",
26
- "vue": "3.4.29",
26
+ "vue": "3.4.31",
27
27
  "vue-i18n": "9.13.1",
28
- "vuetify": "3.6.10",
29
- "@xwiki/cristal-api": "0.9.0",
30
- "@xwiki/cristal-dsapi": "0.9.0"
28
+ "vuetify": "3.6.15",
29
+ "@xwiki/cristal-api": "0.10.0",
30
+ "@xwiki/cristal-dsapi": "0.10.0",
31
+ "@xwiki/cristal-navigation-tree-api": "0.10.0"
31
32
  },
32
33
  "devDependencies": {
33
- "rimraf": "5.0.7",
34
- "vue-tsc": "2.0.21"
34
+ "vue-tsc": "2.0.22"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "pnpm compile",
@@ -115,5 +115,10 @@ export class VuetifyDesignSystemLoader implements DesignSystemLoader {
115
115
  "XFileInput",
116
116
  () => import("../vue/form/x-file-input.vue"),
117
117
  );
118
+ registerAsyncComponent(
119
+ app,
120
+ "XNavigationTree",
121
+ () => import("../vue/x-navigation-tree.vue"),
122
+ );
118
123
  }
119
124
  }
@@ -26,9 +26,9 @@
26
26
 
27
27
  :root {
28
28
  --cr-sizes-max-page-width: 960px; /*This value controls the width of the main content. It should be 100% for spanning text along the whole width or an arbitraty value*/
29
- --cr-sizes-left-sidebar-width: 15%; /*The default width of the sidebar*/
30
- --cr-sizes-left-sidebar-min-width: 250px; /*The minimum width of the sidebar*/
31
- --cr-sizes-collapsed-sidebar-width: 32px; /*The width of the bar that gets shown containing the menu button to reopen the standard left sidebar*/
29
+ --cr-sizes-main-sidebar-width: 15%; /*The default width of the main sidebar*/
30
+ --cr-sizes-main-sidebar-min-width: 250px; /*The minimum width of the main sidebar*/
31
+ --cr-sizes-collapsed-main-sidebar-width: 32px; /*The width of the bar that gets shown containing the menu button to reopen the standard main main sidebar*/
32
32
  --cr-base-font-size: 16px;
33
33
 
34
34
 
@@ -0,0 +1,165 @@
1
+ <!--
2
+ See the LICENSE file distributed with this work for additional
3
+ information regarding copyright ownership.
4
+
5
+ This is free software; you can redistribute it and/or modify it
6
+ under the terms of the GNU Lesser General Public License as
7
+ published by the Free Software Foundation; either version 2.1 of
8
+ the License, or (at your option) any later version.
9
+
10
+ This software is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this software; if not, write to the Free
17
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
+ -->
20
+ <script setup lang="ts">
21
+ import { Ref, onBeforeMount, ref, watch } from "vue";
22
+ import { VTreeview } from "vuetify/labs/VTreeview";
23
+ import { type PageData } from "@xwiki/cristal-api";
24
+ import type {
25
+ NavigationTreeSource,
26
+ NavigationTreeNode,
27
+ } from "@xwiki/cristal-navigation-tree-api";
28
+
29
+ type TreeItem = {
30
+ id: string;
31
+ title: string;
32
+ href: string;
33
+ children?: Array<TreeItem>;
34
+ _location: string;
35
+ };
36
+
37
+ type OnClickAction = (node: NavigationTreeNode) => void;
38
+
39
+ const rootNodes: Ref<Array<TreeItem>> = ref([]);
40
+ const tree: Ref<VTreeview | undefined> = ref(undefined);
41
+
42
+ const activatedNodes: Ref<Array<string>> = ref(new Array<string>());
43
+ const expandedNodes: Ref<Array<string>> = ref(new Array<string>());
44
+
45
+ const props = defineProps<{
46
+ treeSource: NavigationTreeSource;
47
+ clickAction?: OnClickAction;
48
+ currentPage?: PageData;
49
+ }>();
50
+
51
+ onBeforeMount(async () => {
52
+ for (const node of await props.treeSource.getChildNodes("")) {
53
+ rootNodes.value.push({
54
+ id: node.id,
55
+ title: node.label,
56
+ href: node.url,
57
+ children: node.has_children ? [] : undefined,
58
+ _location: node.location,
59
+ });
60
+ }
61
+ if (props.currentPage !== undefined) {
62
+ await expandTree();
63
+ }
64
+ });
65
+
66
+ watch(
67
+ () => props.currentPage,
68
+ async () => {
69
+ if (props.currentPage) {
70
+ await expandTree();
71
+ }
72
+ },
73
+ );
74
+
75
+ async function expandTree() {
76
+ const newExpandedNodes = props.treeSource.getParentNodesId(props.currentPage);
77
+ let i;
78
+ let currentNodes = rootNodes.value;
79
+ for (i = 0; i < newExpandedNodes.length - 1; i++) {
80
+ if (currentNodes) {
81
+ for (const node of currentNodes) {
82
+ if (node.id == newExpandedNodes[i]) {
83
+ if (node.children?.length == 0) {
84
+ await lazyLoadChildren(node);
85
+ }
86
+ if (!expandedNodes.value.includes(node.id)) {
87
+ expandedNodes.value.push(node.id);
88
+ }
89
+ currentNodes = node.children!;
90
+ }
91
+ }
92
+ }
93
+ }
94
+ if (currentNodes) {
95
+ for (const node of currentNodes) {
96
+ if (node.id == newExpandedNodes[i]) {
97
+ activatedNodes.value = [node.id];
98
+ // If we have a custom click action, we want to use it on dynamic
99
+ // selection.
100
+ if (props.clickAction) {
101
+ props.clickAction({
102
+ id: node.id,
103
+ label: node.title,
104
+ location: node._location,
105
+ url: node.href,
106
+ has_children: node.children !== undefined,
107
+ });
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ async function lazyLoadChildren(item: unknown) {
115
+ const treeItem = item as TreeItem;
116
+ const childNodes = await props.treeSource.getChildNodes(treeItem.id);
117
+ for (const child of childNodes) {
118
+ treeItem.children?.push({
119
+ id: child.id,
120
+ title: child.label,
121
+ href: child.url,
122
+ children: child.has_children ? [] : undefined,
123
+ _location: child.location,
124
+ });
125
+ }
126
+ // If the node doesn't have any children, we update it.
127
+ if (childNodes.length == 0) {
128
+ treeItem.children = undefined;
129
+ }
130
+ }
131
+ </script>
132
+
133
+ <template>
134
+ <v-treeview
135
+ ref="tree"
136
+ v-model:activated="activatedNodes"
137
+ v-model:opened="expandedNodes"
138
+ :items="rootNodes"
139
+ :load-children="lazyLoadChildren"
140
+ activatable
141
+ active-strategy="single-independent"
142
+ item-value="id"
143
+ open-strategy="multiple"
144
+ >
145
+ <template #title="{ item }: { item: any }">
146
+ <a
147
+ v-if="props.clickAction"
148
+ :href="item.href"
149
+ @click.prevent="
150
+ clickAction!({
151
+ id: item.id,
152
+ label: item.title,
153
+ location: item._location,
154
+ url: item.href,
155
+ has_children: item.children !== undefined,
156
+ })
157
+ "
158
+ >{{ item.title }}</a
159
+ >
160
+ <a v-else :href="item.href">{{ item.title }}</a>
161
+ </template>
162
+ </v-treeview>
163
+ </template>
164
+
165
+ <style scoped></style>
@@ -23,8 +23,10 @@ const tab = ref(null);
23
23
 
24
24
  const emits = defineEmits(["change"]);
25
25
 
26
- function change(tabId: string) {
27
- emits("change", tabId);
26
+ function change(tabId: unknown) {
27
+ if (typeof tabId == "string") {
28
+ emits("change", tabId);
29
+ }
28
30
  }
29
31
  </script>
30
32