@windwalker-io/unicorn-next 0.1.19 → 0.1.21

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.
Files changed (107) hide show
  1. package/dist/chunks/_arrayPush.js +325 -108
  2. package/dist/chunks/_arrayPush.js.map +1 -1
  3. package/dist/chunks/_baseRest.js +155 -60
  4. package/dist/chunks/_baseRest.js.map +1 -1
  5. package/dist/chunks/_baseUnary.js +463 -0
  6. package/dist/chunks/_baseUnary.js.map +1 -0
  7. package/dist/chunks/_getPrototype.js +292 -100
  8. package/dist/chunks/_getPrototype.js.map +1 -1
  9. package/dist/chunks/alert-adapter.js +29 -0
  10. package/dist/chunks/alert-adapter.js.map +1 -0
  11. package/dist/chunks/alert.js +21 -0
  12. package/dist/chunks/alert.js.map +1 -0
  13. package/dist/chunks/arr.js +24 -0
  14. package/dist/chunks/arr.js.map +1 -0
  15. package/dist/chunks/button-radio.js +127 -145
  16. package/dist/chunks/button-radio.js.map +1 -1
  17. package/dist/chunks/checkboxes-multi-select.js +44 -43
  18. package/dist/chunks/checkboxes-multi-select.js.map +1 -1
  19. package/dist/chunks/chunk.js +24 -0
  20. package/dist/chunks/cloneDeep.js +679 -212
  21. package/dist/chunks/cloneDeep.js.map +1 -1
  22. package/dist/chunks/cropper.min.js +6 -5
  23. package/dist/chunks/cropper.min.js.map +1 -1
  24. package/dist/chunks/crypto.js +26 -0
  25. package/dist/chunks/crypto.js.map +1 -0
  26. package/dist/chunks/data.js +49 -0
  27. package/dist/chunks/data.js.map +1 -0
  28. package/dist/chunks/dom.js +128 -0
  29. package/dist/chunks/dom.js.map +1 -0
  30. package/dist/chunks/events.js +270 -0
  31. package/dist/chunks/events.js.map +1 -0
  32. package/dist/chunks/field-cascade-select.js +207 -250
  33. package/dist/chunks/field-cascade-select.js.map +1 -1
  34. package/dist/chunks/field-file-drag.js +175 -209
  35. package/dist/chunks/field-file-drag.js.map +1 -1
  36. package/dist/chunks/field-flatpickr.js +94 -898
  37. package/dist/chunks/field-flatpickr.js.map +1 -1
  38. package/dist/chunks/field-modal-select.js +728 -467
  39. package/dist/chunks/field-modal-select.js.map +1 -1
  40. package/dist/chunks/field-modal-tree.js +771 -766
  41. package/dist/chunks/field-modal-tree.js.map +1 -1
  42. package/dist/chunks/field-multi-uploader.js +249 -256
  43. package/dist/chunks/field-multi-uploader.js.map +1 -1
  44. package/dist/chunks/field-repeatable.js +111 -127
  45. package/dist/chunks/field-repeatable.js.map +1 -1
  46. package/dist/chunks/field-single-image-drag.js +286 -338
  47. package/dist/chunks/field-single-image-drag.js.map +1 -1
  48. package/dist/chunks/form.js +146 -159
  49. package/dist/chunks/form.js.map +1 -1
  50. package/dist/chunks/grid.js +349 -418
  51. package/dist/chunks/grid.js.map +1 -1
  52. package/dist/chunks/helper.js +39 -0
  53. package/dist/chunks/helper.js.map +1 -0
  54. package/dist/chunks/http-client.js +221 -211
  55. package/dist/chunks/http-client.js.map +1 -1
  56. package/dist/chunks/iframe-modal.js +95 -115
  57. package/dist/chunks/iframe-modal.js.map +1 -1
  58. package/dist/chunks/keep-tab.js +92 -101
  59. package/dist/chunks/keep-tab.js.map +1 -1
  60. package/dist/chunks/lang.js +250 -0
  61. package/dist/chunks/lang.js.map +1 -0
  62. package/dist/chunks/legacy.js +197 -201
  63. package/dist/chunks/legacy.js.map +1 -1
  64. package/dist/chunks/list-dependent.js +195 -228
  65. package/dist/chunks/list-dependent.js.map +1 -1
  66. package/dist/chunks/loader.js +106 -0
  67. package/dist/chunks/loader.js.map +1 -0
  68. package/dist/chunks/monthSelect.js +251 -0
  69. package/dist/chunks/monthSelect.js.map +1 -0
  70. package/dist/chunks/router.js +111 -0
  71. package/dist/chunks/router.js.map +1 -0
  72. package/dist/chunks/s3-multipart-uploader.js +183 -210
  73. package/dist/chunks/s3-multipart-uploader.js.map +1 -1
  74. package/dist/chunks/s3-uploader.js +106 -128
  75. package/dist/chunks/s3-uploader.js.map +1 -1
  76. package/dist/chunks/show-on.js +358 -205
  77. package/dist/chunks/show-on.js.map +1 -1
  78. package/dist/chunks/timing.js +10 -0
  79. package/dist/chunks/timing.js.map +1 -0
  80. package/dist/chunks/tinymce.js +153 -203
  81. package/dist/chunks/tinymce.js.map +1 -1
  82. package/dist/chunks/ui-bootstrap5.js +58 -72
  83. package/dist/chunks/ui-bootstrap5.js.map +1 -1
  84. package/dist/chunks/ui.js +320 -0
  85. package/dist/chunks/ui.js.map +1 -0
  86. package/dist/chunks/unicorn.js.map +1 -1
  87. package/dist/chunks/useQueue.js +111 -0
  88. package/dist/chunks/useQueue.js.map +1 -0
  89. package/dist/chunks/useStack.js +76 -0
  90. package/dist/chunks/useStack.js.map +1 -0
  91. package/dist/chunks/validation.js +761 -853
  92. package/dist/chunks/validation.js.map +1 -1
  93. package/dist/editor.css +1 -1
  94. package/dist/index.d.ts +10 -8
  95. package/dist/multi-level-menu.css +1 -1
  96. package/dist/switcher.css +1 -1
  97. package/dist/unicorn.js +805 -130
  98. package/dist/unicorn.js.map +1 -1
  99. package/package.json +3 -3
  100. package/src/composable/useBsModalAlert.ts +29 -0
  101. package/src/composable/useHttp.ts +13 -1
  102. package/src/module/s3-uploader.ts +1 -1
  103. package/vite.config.ts +5 -1
  104. package/dist/chunks/_commonjsHelpers.js +0 -7
  105. package/dist/chunks/index.js +0 -314
  106. package/dist/chunks/isArguments.js +0 -146
  107. package/dist/chunks/unicorn.js +0 -2621
@@ -1,796 +1,801 @@
1
- import { af as forceArray, u as useHttpClient, ad as useCssImport, ae as data } from "./unicorn.js";
2
- import { defineComponent, ref, computed, h, Transition, withDirectives, mergeProps, vShow, unref, inject, watch, onBeforeUpdate, nextTick, onMounted, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, vModelDynamic, withModifiers, createTextVNode, toDisplayString, createCommentVNode, createBlock, withCtx, Fragment, renderList, useTemplateRef, onUnmounted, provide, vModelText, createVNode, TransitionGroup, createApp } from "vue";
1
+ import { t as data } from "./data.js";
2
+ import { t as cloneDeep } from "./cloneDeep.js";
3
+ import { n as forceArray } from "./helper.js";
4
+ import { n as useCssImport } from "./loader.js";
5
+ import { useHttpClient } from "../unicorn.js";
3
6
  import { Modal } from "bootstrap";
4
- import { c as cloneDeep } from "./cloneDeep.js";
7
+ import { Fragment, Transition, TransitionGroup, computed, createApp, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, h, inject, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUpdate, onMounted, onUnmounted, openBlock, provide, ref, renderList, toDisplayString, unref, useTemplateRef, vModelDynamic, vModelText, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
8
+ //#region src/utilities/tree.ts
5
9
  function flattenChildren(children) {
6
- const flat = [];
7
- function loopChildren(children2) {
8
- for (const child of children2) {
9
- if (child.children.length === 0) {
10
- flat.push(child);
11
- continue;
12
- }
13
- loopChildren(child.children);
14
- }
15
- }
16
- loopChildren(children);
17
- return flat;
10
+ const flat = [];
11
+ function loopChildren(children) {
12
+ for (const child of children) {
13
+ if (child.children.length === 0) {
14
+ flat.push(child);
15
+ continue;
16
+ }
17
+ loopChildren(child.children);
18
+ }
19
+ }
20
+ loopChildren(children);
21
+ return flat;
18
22
  }
23
+ //#endregion
24
+ //#region ../../../../node_modules/vue3-slide-up-down/dist/vue3-slide-up-down.js
19
25
  function y(t) {
20
- return {
21
- height: t.style.height,
22
- width: t.style.width,
23
- position: t.style.position,
24
- visibility: t.style.visibility,
25
- overflow: t.style.overflow,
26
- paddingTop: t.style.paddingTop,
27
- paddingBottom: t.style.paddingBottom,
28
- borderTopWidth: t.style.borderTopWidth,
29
- borderBottomWidth: t.style.borderBottomWidth,
30
- marginTop: t.style.marginTop,
31
- marginBottom: t.style.marginBottom
32
- };
26
+ return {
27
+ height: t.style.height,
28
+ width: t.style.width,
29
+ position: t.style.position,
30
+ visibility: t.style.visibility,
31
+ overflow: t.style.overflow,
32
+ paddingTop: t.style.paddingTop,
33
+ paddingBottom: t.style.paddingBottom,
34
+ borderTopWidth: t.style.borderTopWidth,
35
+ borderBottomWidth: t.style.borderBottomWidth,
36
+ marginTop: t.style.marginTop,
37
+ marginBottom: t.style.marginBottom
38
+ };
33
39
  }
34
40
  function V(t, o, i) {
35
- const e = unref(t), { width: n } = getComputedStyle(o);
36
- o.style.width = n, o.style.position = "absolute", o.style.visibility = "hidden", o.style.height = "";
37
- const { height: s } = getComputedStyle(o);
38
- return o.style.width = i.width, o.style.position = i.position, o.style.visibility = i.visibility, o.style.height = e, o.style.overflow = "hidden", i.height && i.height != e ? i.height : s;
41
+ const e = unref(t), { width: n } = getComputedStyle(o);
42
+ o.style.width = n, o.style.position = "absolute", o.style.visibility = "hidden", o.style.height = "";
43
+ const { height: s } = getComputedStyle(o);
44
+ return o.style.width = i.width, o.style.position = i.position, o.style.visibility = i.visibility, o.style.height = e, o.style.overflow = "hidden", i.height && i.height != e ? i.height : s;
39
45
  }
40
46
  function f(t, o, i, e, n) {
41
- const s = t.animate(e, n);
42
- t.style.height = o.height, s.onfinish = () => {
43
- t.style.overflow = o.overflow, i();
44
- };
47
+ const s = t.animate(e, n);
48
+ t.style.height = o.height, s.onfinish = () => {
49
+ t.style.overflow = o.overflow, i();
50
+ };
45
51
  }
46
52
  function m(t, o, i, e) {
47
- const n = unref(o);
48
- return [
49
- {
50
- height: n,
51
- opacity: t.opacityClosed,
52
- paddingTop: n,
53
- paddingBottom: n,
54
- borderTopWidth: n,
55
- borderBottomWidth: n,
56
- marginTop: n,
57
- marginBottom: n
58
- },
59
- {
60
- height: i,
61
- opacity: t.opacityOpen,
62
- paddingTop: e.paddingTop || 0,
63
- paddingBottom: e.paddingBottom || 0,
64
- borderTopWidth: e.borderTopWidth || 0,
65
- borderBottomWidth: e.borderBottomWidth || 0,
66
- marginTop: e.marginTop || 0,
67
- marginBottom: e.marginBottom || 0
68
- }
69
- ];
53
+ const n = unref(o);
54
+ return [{
55
+ height: n,
56
+ opacity: t.opacityClosed,
57
+ paddingTop: n,
58
+ paddingBottom: n,
59
+ borderTopWidth: n,
60
+ borderBottomWidth: n,
61
+ marginTop: n,
62
+ marginBottom: n
63
+ }, {
64
+ height: i,
65
+ opacity: t.opacityOpen,
66
+ paddingTop: e.paddingTop || 0,
67
+ paddingBottom: e.paddingBottom || 0,
68
+ borderTopWidth: e.borderTopWidth || 0,
69
+ borderBottomWidth: e.borderBottomWidth || 0,
70
+ marginTop: e.marginTop || 0,
71
+ marginBottom: e.marginBottom || 0
72
+ }];
70
73
  }
71
- const x = /* @__PURE__ */ defineComponent({
72
- props: {
73
- modelValue: {
74
- type: Boolean,
75
- default: false
76
- },
77
- /**
78
- * Time in milliseconds for the slide duration
79
- */
80
- duration: {
81
- type: Number,
82
- default: 500
83
- },
84
- /**
85
- * Timing function for the animation
86
- */
87
- timingFunction: {
88
- type: String,
89
- default: "ease-in-out"
90
- },
91
- /**
92
- * Independent timing function for the animation when entering
93
- */
94
- timingFunctionEnter: {
95
- type: String,
96
- default: null
97
- },
98
- /**
99
- * Independent timing function for the animation when leaving
100
- */
101
- timingFunctionLeave: {
102
- type: String,
103
- default: null
104
- },
105
- /**
106
- * Opacity value from 0 - 1 of the element when open
107
- */
108
- opacityOpen: {
109
- type: Number,
110
- default: 1
111
- },
112
- /**
113
- * Opacity value from 0 - 1 of the element when closed
114
- */
115
- opacityClosed: {
116
- type: Number,
117
- default: 0
118
- },
119
- /**
120
- * HTML tag to use for the outer container
121
- */
122
- tag: {
123
- type: String,
124
- default: "div"
125
- },
126
- /**
127
- * Always render the element inside the slide container
128
- */
129
- eager: {
130
- type: Boolean,
131
- default: false
132
- }
133
- },
134
- emits: ["update:modelValue", "open-start", "open-end", "close-start", "close-end"],
135
- setup(t, { slots: o, attrs: i, emit: e }) {
136
- const n = ref("0px"), s = computed(() => t.timingFunctionEnter || t.timingFunction), v = computed(() => t.timingFunctionLeave || t.timingFunction);
137
- function T(g, l) {
138
- const d = g, a = y(d), r = V(n, d, a), u = m(t, n, r, a), c = { duration: t.duration, easing: s.value };
139
- f(d, a, () => {
140
- l(), e("open-end");
141
- }, u, c);
142
- }
143
- function B(g, l) {
144
- const d = g, a = y(d), { height: r } = getComputedStyle(d);
145
- d.style.height = r, d.style.overflow = "hidden";
146
- const u = m(t, n, r, a).reverse(), c = { duration: t.duration, easing: v.value };
147
- f(d, a, () => {
148
- l(), e("close-end");
149
- }, u, c);
150
- }
151
- return () => h(
152
- Transition,
153
- {
154
- css: false,
155
- persisted: t.eager,
156
- onBeforeEnter: () => e("open-start"),
157
- onEnter: T,
158
- onBeforeLeave: () => e("close-start"),
159
- onLeave: B
160
- },
161
- {
162
- default: () => t.modelValue || t.eager ? withDirectives(
163
- h(
164
- t.tag,
165
- mergeProps(i, {
166
- class: "slide-up-down__container"
167
- }),
168
- o
169
- ),
170
- [t.eager ? [vShow, t.modelValue === true] : [null]]
171
- ) : null
172
- }
173
- );
174
- }
74
+ var x = /* @__PURE__ */ defineComponent({
75
+ props: {
76
+ modelValue: {
77
+ type: Boolean,
78
+ default: !1
79
+ },
80
+ duration: {
81
+ type: Number,
82
+ default: 500
83
+ },
84
+ timingFunction: {
85
+ type: String,
86
+ default: "ease-in-out"
87
+ },
88
+ timingFunctionEnter: {
89
+ type: String,
90
+ default: null
91
+ },
92
+ timingFunctionLeave: {
93
+ type: String,
94
+ default: null
95
+ },
96
+ opacityOpen: {
97
+ type: Number,
98
+ default: 1
99
+ },
100
+ opacityClosed: {
101
+ type: Number,
102
+ default: 0
103
+ },
104
+ tag: {
105
+ type: String,
106
+ default: "div"
107
+ },
108
+ eager: {
109
+ type: Boolean,
110
+ default: !1
111
+ }
112
+ },
113
+ emits: [
114
+ "update:modelValue",
115
+ "open-start",
116
+ "open-end",
117
+ "close-start",
118
+ "close-end"
119
+ ],
120
+ setup(t, { slots: o, attrs: i, emit: e }) {
121
+ const n = ref("0px"), s = computed(() => t.timingFunctionEnter || t.timingFunction), v = computed(() => t.timingFunctionLeave || t.timingFunction);
122
+ function T(g, l) {
123
+ const d = g, a = y(d);
124
+ f(d, a, () => {
125
+ l(), e("open-end");
126
+ }, m(t, n, V(n, d, a), a), {
127
+ duration: t.duration,
128
+ easing: s.value
129
+ });
130
+ }
131
+ function B(g, l) {
132
+ const d = g, a = y(d), { height: r } = getComputedStyle(d);
133
+ d.style.height = r, d.style.overflow = "hidden";
134
+ f(d, a, () => {
135
+ l(), e("close-end");
136
+ }, m(t, n, r, a).reverse(), {
137
+ duration: t.duration,
138
+ easing: v.value
139
+ });
140
+ }
141
+ return () => h(Transition, {
142
+ css: !1,
143
+ persisted: t.eager,
144
+ onBeforeEnter: () => e("open-start"),
145
+ onEnter: T,
146
+ onBeforeLeave: () => e("close-start"),
147
+ onLeave: B
148
+ }, { default: () => t.modelValue || t.eager ? withDirectives(h(t.tag, mergeProps(i, { class: "slide-up-down__container" }), o), [t.eager ? [vShow, t.modelValue === !0] : [null]]) : null });
149
+ }
175
150
  });
176
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
177
- __name: "TreeItem",
178
- props: {
179
- node: {},
180
- level: { default: 1 },
181
- branchSelectable: { type: Boolean, default: false }
182
- },
183
- emits: ["change", "input"],
184
- setup(__props, { expose: __expose, emit: __emit }) {
185
- const props = __props;
186
- const emit = __emit;
187
- const node = ref(props.node);
188
- const selectedValues = inject("selectedValues");
189
- const id = inject("id");
190
- const multiple = inject("multiple");
191
- const valueGetter = inject("valueGetter");
192
- const titleGetter = inject("titleGetter");
193
- const selected = ref(false);
194
- const indeterminate = computed(() => !!props.node.indeterminate);
195
- const stopWatch = ref(false);
196
- const open = ref(false);
197
- const childrenComponents = ref([]);
198
- watch(() => props.node, () => {
199
- selected.value = !!props.node.selected;
200
- }, { deep: true });
201
- function setChildrenComponent(child) {
202
- childrenComponents.value.push(child);
203
- }
204
- onBeforeUpdate(() => {
205
- childrenComponents.value = [];
206
- });
207
- const indentPx = computed(() => {
208
- return (props.level - 1) * 15;
209
- });
210
- const isBranch = computed(() => {
211
- return props.node.children.length > 0;
212
- });
213
- const isLeaf = computed(() => {
214
- return !isBranch.value;
215
- });
216
- function updateSelected() {
217
- if (isBranch.value) {
218
- return;
219
- }
220
- node.value.selected = selectedValues.value.includes(valueGetter(props.node.value));
221
- }
222
- function select(select2) {
223
- if (selected.value === select2) {
224
- return;
225
- }
226
- node.value.selected = select2;
227
- checkboxChanged(select2);
228
- }
229
- function checkboxChanged(v) {
230
- if (isBranch.value) {
231
- node.value.selected = v;
232
- if (multiple) {
233
- stopWatchThen(() => {
234
- const flatChildren = flattenChildren(node.value.children);
235
- for (const child of flatChildren) {
236
- child.selected = v;
237
- child.indeterminate = false;
238
- }
239
- });
240
- }
241
- } else {
242
- nextTick(() => {
243
- node.value.selected = v;
244
- });
245
- }
246
- emit("change", v);
247
- emit("input", v);
248
- }
249
- function childChanged(v) {
250
- if (isLeaf.value || stopWatch.value) {
251
- return;
252
- }
253
- if (!childrenComponents.value) {
254
- return;
255
- }
256
- if (childrenComponents.value.length === 0) {
257
- return;
258
- }
259
- syncChildrenStatus();
260
- }
261
- function syncChildrenStatus() {
262
- if (isLeaf.value) {
263
- return;
264
- }
265
- let selectedCount = 0;
266
- let unselectCount = 0;
267
- let indeterminateInner = 0;
268
- const oldIndeterminate = indeterminate.value;
269
- const oldSelected = selected.value;
270
- for (const child of flattenChildren(props.node.children)) {
271
- if (child.selected) {
272
- selectedCount++;
273
- } else {
274
- unselectCount++;
275
- }
276
- if (child.indeterminate) {
277
- indeterminateInner++;
278
- }
279
- }
280
- if (selectedCount !== 0 && unselectCount !== 0 || indeterminateInner > 0) {
281
- node.value.indeterminate = true;
282
- } else {
283
- node.value.selected = unselectCount === 0;
284
- node.value.indeterminate = false;
285
- }
286
- if (selected.value !== oldSelected || indeterminate.value !== oldIndeterminate) {
287
- emit("change", selected.value);
288
- emit("input", selected.value);
289
- }
290
- }
291
- function stopWatchThen(callback) {
292
- stopWatch.value = true;
293
- callback();
294
- stopWatch.value = false;
295
- }
296
- watch(() => selectedValues, async () => {
297
- if (!isBranch.value) {
298
- updateSelected();
299
- }
300
- await nextTick();
301
- syncChildrenStatus();
302
- }, { deep: true });
303
- watch(selected, (v) => {
304
- });
305
- updateSelected();
306
- onMounted(() => {
307
- syncChildrenStatus();
308
- });
309
- __expose({
310
- select,
311
- selected,
312
- indeterminate
313
- });
314
- const __returned__ = { props, emit, node, selectedValues, id, multiple, valueGetter, titleGetter, selected, indeterminate, stopWatch, open, childrenComponents, setChildrenComponent, indentPx, isBranch, isLeaf, updateSelected, select, checkboxChanged, childChanged, syncChildrenStatus, stopWatchThen, get Vue3SlideUpDown() {
315
- return x;
316
- }, TreeItem };
317
- Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
318
- return __returned__;
319
- }
151
+ //#endregion
152
+ //#region src/vue/components/ModalTree/TreeItem.vue?vue&type=script&setup=true&lang.ts
153
+ var TreeItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
154
+ __name: "TreeItem",
155
+ props: {
156
+ node: {},
157
+ level: { default: 1 },
158
+ branchSelectable: {
159
+ type: Boolean,
160
+ default: false
161
+ }
162
+ },
163
+ emits: ["change", "input"],
164
+ setup(__props, { expose: __expose, emit: __emit }) {
165
+ const props = __props;
166
+ const emit = __emit;
167
+ const node = ref(props.node);
168
+ const selectedValues = inject("selectedValues");
169
+ const id = inject("id");
170
+ const multiple = inject("multiple");
171
+ const valueGetter = inject("valueGetter");
172
+ const titleGetter = inject("titleGetter");
173
+ const selected = ref(false);
174
+ const indeterminate = computed(() => !!props.node.indeterminate);
175
+ const stopWatch = ref(false);
176
+ const open = ref(false);
177
+ const childrenComponents = ref([]);
178
+ watch(() => props.node, () => {
179
+ selected.value = !!props.node.selected;
180
+ }, { deep: true });
181
+ function setChildrenComponent(child) {
182
+ childrenComponents.value.push(child);
183
+ }
184
+ onBeforeUpdate(() => {
185
+ childrenComponents.value = [];
186
+ });
187
+ const indentPx = computed(() => {
188
+ return (props.level - 1) * 15;
189
+ });
190
+ const isBranch = computed(() => {
191
+ return props.node.children.length > 0;
192
+ });
193
+ const isLeaf = computed(() => {
194
+ return !isBranch.value;
195
+ });
196
+ function updateSelected() {
197
+ if (isBranch.value) return;
198
+ node.value.selected = selectedValues.value.includes(valueGetter(props.node.value));
199
+ }
200
+ function select(select) {
201
+ if (selected.value === select) return;
202
+ node.value.selected = select;
203
+ checkboxChanged(select);
204
+ }
205
+ function checkboxChanged(v) {
206
+ if (isBranch.value) {
207
+ node.value.selected = v;
208
+ if (multiple) stopWatchThen(() => {
209
+ const flatChildren = flattenChildren(node.value.children);
210
+ for (const child of flatChildren) {
211
+ child.selected = v;
212
+ child.indeterminate = false;
213
+ }
214
+ });
215
+ } else nextTick(() => {
216
+ node.value.selected = v;
217
+ });
218
+ emit("change", v);
219
+ emit("input", v);
220
+ }
221
+ function childChanged(v) {
222
+ if (isLeaf.value || stopWatch.value) return;
223
+ if (!childrenComponents.value) return;
224
+ if (childrenComponents.value.length === 0) return;
225
+ syncChildrenStatus();
226
+ }
227
+ function syncChildrenStatus() {
228
+ if (isLeaf.value) return;
229
+ let selectedCount = 0;
230
+ let unselectCount = 0;
231
+ let indeterminateInner = 0;
232
+ const oldIndeterminate = indeterminate.value;
233
+ const oldSelected = selected.value;
234
+ for (const child of flattenChildren(props.node.children)) {
235
+ if (child.selected) selectedCount++;
236
+ else unselectCount++;
237
+ if (child.indeterminate) indeterminateInner++;
238
+ }
239
+ if (selectedCount !== 0 && unselectCount !== 0 || indeterminateInner > 0) node.value.indeterminate = true;
240
+ else {
241
+ node.value.selected = unselectCount === 0;
242
+ node.value.indeterminate = false;
243
+ }
244
+ if (selected.value !== oldSelected || indeterminate.value !== oldIndeterminate) {
245
+ emit("change", selected.value);
246
+ emit("input", selected.value);
247
+ }
248
+ }
249
+ function stopWatchThen(callback) {
250
+ stopWatch.value = true;
251
+ callback();
252
+ stopWatch.value = false;
253
+ }
254
+ watch(() => selectedValues, async () => {
255
+ if (!isBranch.value) updateSelected();
256
+ await nextTick();
257
+ syncChildrenStatus();
258
+ }, { deep: true });
259
+ watch(selected, (v) => {});
260
+ updateSelected();
261
+ onMounted(() => {
262
+ syncChildrenStatus();
263
+ });
264
+ __expose({
265
+ select,
266
+ selected,
267
+ indeterminate
268
+ });
269
+ const __returned__ = {
270
+ props,
271
+ emit,
272
+ node,
273
+ selectedValues,
274
+ id,
275
+ multiple,
276
+ valueGetter,
277
+ titleGetter,
278
+ selected,
279
+ indeterminate,
280
+ stopWatch,
281
+ open,
282
+ childrenComponents,
283
+ setChildrenComponent,
284
+ indentPx,
285
+ isBranch,
286
+ isLeaf,
287
+ updateSelected,
288
+ select,
289
+ checkboxChanged,
290
+ childChanged,
291
+ syncChildrenStatus,
292
+ stopWatchThen,
293
+ get Vue3SlideUpDown() {
294
+ return x;
295
+ },
296
+ TreeItem: TreeItem_default
297
+ };
298
+ Object.defineProperty(__returned__, "__isScriptSetup", {
299
+ enumerable: false,
300
+ value: true
301
+ });
302
+ return __returned__;
303
+ }
320
304
  });
321
- const _export_sfc = (sfc, props) => {
322
- const target = sfc.__vccOpts || sfc;
323
- for (const [key, val] of props) {
324
- target[key] = val;
325
- }
326
- return target;
305
+ //#endregion
306
+ //#region \0plugin-vue:export-helper
307
+ var _plugin_vue_export_helper_default = (sfc, props) => {
308
+ const target = sfc.__vccOpts || sfc;
309
+ for (const [key, val] of props) target[key] = val;
310
+ return target;
327
311
  };
328
- const _hoisted_1$2 = { class: "p-2 ms-2" };
329
- const _hoisted_2$2 = ["type", "id", "indeterminate"];
330
- const _hoisted_3$2 = ["type", "checked", "indeterminate"];
331
- const _hoisted_4$2 = ["data-level"];
332
- const _hoisted_5$2 = {
333
- key: 0,
334
- class: "ms-auto me-3"
312
+ //#endregion
313
+ //#region src/vue/components/ModalTree/TreeItem.vue
314
+ var _hoisted_1$2 = { class: "p-2 ms-2" };
315
+ var _hoisted_2$2 = [
316
+ "type",
317
+ "id",
318
+ "indeterminate"
319
+ ];
320
+ var _hoisted_3$2 = [
321
+ "type",
322
+ "checked",
323
+ "indeterminate"
324
+ ];
325
+ var _hoisted_4$2 = ["data-level"];
326
+ var _hoisted_5$2 = {
327
+ key: 0,
328
+ class: "ms-auto me-3"
335
329
  };
336
330
  function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
337
- return openBlock(), createElementBlock("div", {
338
- class: normalizeClass(["c-tree-item", [$setup.isBranch ? "c-tree-item--branch" : "c-tree-item--leaf"]])
339
- }, [
340
- createElementVNode("div", {
341
- class: normalizeClass(["d-flex c-tree-item__title", [$setup.isBranch ? "bg-light " : ""]]),
342
- style: normalizeStyle({ "padding-left": $setup.indentPx + "px" })
343
- }, [
344
- createElementVNode("div", _hoisted_1$2, [
345
- $setup.isLeaf || $props.branchSelectable && $setup.multiple ? withDirectives((openBlock(), createElementBlock("input", {
346
- key: 0,
347
- type: $setup.multiple ? "checkbox" : "radio",
348
- class: "form-check-input",
349
- id: $setup.id + "__item-" + $setup.valueGetter($setup.node.value),
350
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.selected = $event),
351
- value: true,
352
- "unchecked-value": false,
353
- indeterminate: $setup.indeterminate,
354
- onChange: _cache[1] || (_cache[1] = ($event) => $setup.checkboxChanged($event.target.checked))
355
- }, null, 40, _hoisted_2$2)), [
356
- [vModelDynamic, $setup.selected]
357
- ]) : (openBlock(), createElementBlock("input", {
358
- key: 1,
359
- type: $setup.multiple ? "checkbox" : "radio",
360
- class: "form-check-input",
361
- disabled: "",
362
- checked: $setup.indeterminate,
363
- indeterminate: $setup.indeterminate
364
- }, null, 8, _hoisted_3$2))
365
- ]),
366
- createElementVNode("a", {
367
- class: "c-tree-item__text d-flex align-items-center flex-grow-1 py-2 text-decoration-none",
368
- style: { "cursor": "pointer" },
369
- "data-level": $props.level,
370
- "data-bs-toggle": "collapse",
371
- onClick: _cache[2] || (_cache[2] = withModifiers(($event) => $setup.isLeaf ? $setup.select(!$setup.selected) : $setup.open = !$setup.open, ["prevent"]))
372
- }, [
373
- createElementVNode("span", {
374
- class: normalizeClass(["me-2 fa", [$setup.isLeaf ? "fa-tag" : "fa-folder"]])
375
- }, null, 2),
376
- createTextVNode(" " + toDisplayString($setup.node.value.title) + " ", 1),
377
- $setup.isBranch ? (openBlock(), createElementBlock("span", _hoisted_5$2, [
378
- createElementVNode("span", {
379
- class: normalizeClass([$setup.open ? "fa fa-chevron-up" : "fa fa-chevron-down"])
380
- }, null, 2)
381
- ])) : createCommentVNode("", true)
382
- ], 8, _hoisted_4$2)
383
- ], 6),
384
- $setup.node.children.length > 0 ? (openBlock(), createBlock($setup["Vue3SlideUpDown"], {
385
- key: 0,
386
- modelValue: $setup.open,
387
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => $setup.open = $event),
388
- duration: 300,
389
- class: "c-tree-item__children"
390
- }, {
391
- default: withCtx(() => [
392
- (openBlock(true), createElementBlock(Fragment, null, renderList($setup.node.children, (child, i) => {
393
- return openBlock(), createBlock($setup["TreeItem"], {
394
- node: child,
395
- key: $setup.valueGetter(child.value),
396
- level: $props.level + 1,
397
- "branch-selectable": $props.branchSelectable,
398
- ref_for: true,
399
- ref: $setup.setChildrenComponent,
400
- onChange: $setup.childChanged
401
- }, null, 8, ["node", "level", "branch-selectable"]);
402
- }), 128))
403
- ]),
404
- _: 1
405
- }, 8, ["modelValue"])) : createCommentVNode("", true)
406
- ], 2);
331
+ return openBlock(), createElementBlock("div", { class: normalizeClass(["c-tree-item", [$setup.isBranch ? "c-tree-item--branch" : "c-tree-item--leaf"]]) }, [createElementVNode("div", {
332
+ class: normalizeClass(["d-flex c-tree-item__title", [$setup.isBranch ? "bg-light " : ""]]),
333
+ style: normalizeStyle({ "padding-left": $setup.indentPx + "px" })
334
+ }, [createElementVNode("div", _hoisted_1$2, [$setup.isLeaf || $props.branchSelectable && $setup.multiple ? withDirectives((openBlock(), createElementBlock("input", {
335
+ key: 0,
336
+ type: $setup.multiple ? "checkbox" : "radio",
337
+ class: "form-check-input",
338
+ id: $setup.id + "__item-" + $setup.valueGetter($setup.node.value),
339
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.selected = $event),
340
+ value: true,
341
+ "unchecked-value": false,
342
+ indeterminate: $setup.indeterminate,
343
+ onChange: _cache[1] || (_cache[1] = ($event) => $setup.checkboxChanged($event.target.checked))
344
+ }, null, 40, _hoisted_2$2)), [[vModelDynamic, $setup.selected]]) : (openBlock(), createElementBlock("input", {
345
+ key: 1,
346
+ type: $setup.multiple ? "checkbox" : "radio",
347
+ class: "form-check-input",
348
+ disabled: "",
349
+ checked: $setup.indeterminate,
350
+ indeterminate: $setup.indeterminate
351
+ }, null, 8, _hoisted_3$2))]), createElementVNode("a", {
352
+ class: "c-tree-item__text d-flex align-items-center flex-grow-1 py-2 text-decoration-none",
353
+ style: { "cursor": "pointer" },
354
+ "data-level": $props.level,
355
+ "data-bs-toggle": "collapse",
356
+ onClick: _cache[2] || (_cache[2] = withModifiers(($event) => $setup.isLeaf ? $setup.select(!$setup.selected) : $setup.open = !$setup.open, ["prevent"]))
357
+ }, [
358
+ createElementVNode("span", { class: normalizeClass(["me-2 fa", [$setup.isLeaf ? "fa-tag" : "fa-folder"]]) }, null, 2),
359
+ createTextVNode(" " + toDisplayString($setup.node.value.title) + " ", 1),
360
+ $setup.isBranch ? (openBlock(), createElementBlock("span", _hoisted_5$2, [createElementVNode("span", { class: normalizeClass([$setup.open ? "fa fa-chevron-up" : "fa fa-chevron-down"]) }, null, 2)])) : createCommentVNode("", true)
361
+ ], 8, _hoisted_4$2)], 6), $setup.node.children.length > 0 ? (openBlock(), createBlock($setup["Vue3SlideUpDown"], {
362
+ key: 0,
363
+ modelValue: $setup.open,
364
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => $setup.open = $event),
365
+ duration: 300,
366
+ class: "c-tree-item__children"
367
+ }, {
368
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($setup.node.children, (child, i) => {
369
+ return openBlock(), createBlock($setup["TreeItem"], {
370
+ node: child,
371
+ key: $setup.valueGetter(child.value),
372
+ level: $props.level + 1,
373
+ "branch-selectable": $props.branchSelectable,
374
+ ref_for: true,
375
+ ref: $setup.setChildrenComponent,
376
+ onChange: $setup.childChanged
377
+ }, null, 8, [
378
+ "node",
379
+ "level",
380
+ "branch-selectable"
381
+ ]);
382
+ }), 128))]),
383
+ _: 1
384
+ }, 8, ["modelValue"])) : createCommentVNode("", true)], 2);
407
385
  }
408
- const TreeItem = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-897596f4"], ["__file", "TreeItem.vue"]]);
409
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
410
- __name: "TreeModal",
411
- props: {
412
- open: { type: Boolean },
413
- id: {},
414
- name: {},
415
- types: {},
416
- title: {},
417
- disabled: { type: Boolean },
418
- readonly: { type: Boolean },
419
- value: {},
420
- branchSelectable: { type: Boolean, default: false },
421
- source: {},
422
- searchText: {}
423
- },
424
- emits: ["change", "input", "selected", "hide"],
425
- setup(__props, { expose: __expose, emit: __emit }) {
426
- __expose();
427
- const props = __props;
428
- const emits = __emit;
429
- const valueGetter = inject("valueGetter");
430
- const titleGetter = inject("titleGetter");
431
- const searchMatcher = inject("searchMatcher");
432
- const loading = ref(false);
433
- const multiple = inject("multiple", false);
434
- const modalElement = useTemplateRef("modal");
435
- let $modal;
436
- onMounted(() => {
437
- $modal = Modal.getOrCreateInstance(modalElement.value);
438
- modalElement.value.addEventListener("show.bs.modal", onShow);
439
- modalElement.value.addEventListener("hide.bs.modal", onHide);
440
- });
441
- onUnmounted(() => {
442
- modalElement.value.removeEventListener("show.bs.modal", onShow);
443
- modalElement.value.removeEventListener("hide.bs.modal", onHide);
444
- });
445
- const nodes = ref([]);
446
- const selectedNodes = ref([]);
447
- const displayNodes = computed(() => {
448
- if (searchEnabled.value) {
449
- return searchedItems.value;
450
- }
451
- return nodes.value;
452
- });
453
- const flatNodes = computed(() => flattenChildren(nodes.value));
454
- const selectedValues = computed(() => {
455
- return flatNodes.value.filter((node) => node.selected).map((node) => valueGetter(node.value));
456
- });
457
- provide("selectedValues", selectedValues);
458
- watch(() => selectedValues, () => {
459
- emits("change", selectedValues.value);
460
- emits("input", selectedValues.value);
461
- emits("selected", selectedNodes.value);
462
- });
463
- const canModify = computed(() => {
464
- return !props.readonly && !props.disabled;
465
- });
466
- const q = ref("");
467
- const searchEnabled = computed(() => q.value !== "");
468
- const searchedItems = computed(() => {
469
- if (q.value === "") {
470
- return [];
471
- }
472
- return flatNodes.value.filter((item) => {
473
- return searchMatcher(item.value, q.value);
474
- });
475
- });
476
- async function loadItems() {
477
- loading.value = true;
478
- const http = await useHttpClient();
479
- try {
480
- let src = props.source;
481
- if (typeof src === "string") {
482
- const res = await http.get(src);
483
- nodes.value = res.data.data;
484
- } else if (typeof src === "function") {
485
- nodes.value = await src();
486
- } else {
487
- if (!Array.isArray(src)) {
488
- src = src.children;
489
- }
490
- nodes.value = src;
491
- }
492
- } finally {
493
- loading.value = false;
494
- }
495
- }
496
- watch(() => props.open, (v) => {
497
- if (v) {
498
- $modal.show();
499
- } else {
500
- $modal.hide();
501
- }
502
- });
503
- async function onShow() {
504
- await loadItems();
505
- updateSelectedItemsByValue();
506
- }
507
- function onHide() {
508
- nodes.value = [];
509
- q.value = "";
510
- emits("hide");
511
- }
512
- function updateSelectedItemsByValue() {
513
- const values = forceArray(props.value);
514
- selectedNodes.value = flatNodes.value.filter((item) => {
515
- return values.includes(valueGetter(item.value));
516
- });
517
- }
518
- watch(
519
- () => props.value,
520
- () => updateSelectedItemsByValue(),
521
- { immediate: true, deep: true }
522
- );
523
- const __returned__ = { props, emits, valueGetter, titleGetter, searchMatcher, loading, multiple, modalElement, get $modal() {
524
- return $modal;
525
- }, set $modal(v) {
526
- $modal = v;
527
- }, nodes, selectedNodes, displayNodes, flatNodes, selectedValues, canModify, q, searchEnabled, searchedItems, loadItems, onShow, onHide, updateSelectedItemsByValue, TreeItem };
528
- Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
529
- return __returned__;
530
- }
386
+ var TreeItem_default = /* @__PURE__ */ _plugin_vue_export_helper_default(TreeItem_vue_vue_type_script_setup_true_lang_default, [
387
+ ["render", _sfc_render$2],
388
+ ["__scopeId", "data-v-897596f4"],
389
+ ["__file", "TreeItem.vue"]
390
+ ]);
391
+ //#endregion
392
+ //#region src/vue/components/ModalTree/TreeModal.vue?vue&type=script&setup=true&lang.ts
393
+ var TreeModal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
394
+ __name: "TreeModal",
395
+ props: {
396
+ open: { type: Boolean },
397
+ id: {},
398
+ name: {},
399
+ types: {},
400
+ title: {},
401
+ disabled: { type: Boolean },
402
+ readonly: { type: Boolean },
403
+ value: {},
404
+ branchSelectable: {
405
+ type: Boolean,
406
+ default: false
407
+ },
408
+ source: {},
409
+ searchText: {}
410
+ },
411
+ emits: [
412
+ "change",
413
+ "input",
414
+ "selected",
415
+ "hide"
416
+ ],
417
+ setup(__props, { expose: __expose, emit: __emit }) {
418
+ __expose();
419
+ const props = __props;
420
+ const emits = __emit;
421
+ const valueGetter = inject("valueGetter");
422
+ const titleGetter = inject("titleGetter");
423
+ const searchMatcher = inject("searchMatcher");
424
+ const loading = ref(false);
425
+ const multiple = inject("multiple", false);
426
+ const modalElement = useTemplateRef("modal");
427
+ let $modal;
428
+ onMounted(() => {
429
+ $modal = Modal.getOrCreateInstance(modalElement.value);
430
+ modalElement.value.addEventListener("show.bs.modal", onShow);
431
+ modalElement.value.addEventListener("hide.bs.modal", onHide);
432
+ });
433
+ onUnmounted(() => {
434
+ modalElement.value.removeEventListener("show.bs.modal", onShow);
435
+ modalElement.value.removeEventListener("hide.bs.modal", onHide);
436
+ });
437
+ const nodes = ref([]);
438
+ const selectedNodes = ref([]);
439
+ const displayNodes = computed(() => {
440
+ if (searchEnabled.value) return searchedItems.value;
441
+ return nodes.value;
442
+ });
443
+ const flatNodes = computed(() => flattenChildren(nodes.value));
444
+ const selectedValues = computed(() => {
445
+ return flatNodes.value.filter((node) => node.selected).map((node) => valueGetter(node.value));
446
+ });
447
+ provide("selectedValues", selectedValues);
448
+ watch(() => selectedValues, () => {
449
+ emits("change", selectedValues.value);
450
+ emits("input", selectedValues.value);
451
+ emits("selected", selectedNodes.value);
452
+ });
453
+ const canModify = computed(() => {
454
+ return !props.readonly && !props.disabled;
455
+ });
456
+ const q = ref("");
457
+ const searchEnabled = computed(() => q.value !== "");
458
+ const searchedItems = computed(() => {
459
+ if (q.value === "") return [];
460
+ return flatNodes.value.filter((item) => {
461
+ return searchMatcher(item.value, q.value);
462
+ });
463
+ });
464
+ async function loadItems() {
465
+ loading.value = true;
466
+ const http = await useHttpClient();
467
+ try {
468
+ let src = props.source;
469
+ if (typeof src === "string") nodes.value = (await http.get(src)).data.data;
470
+ else if (typeof src === "function") nodes.value = await src();
471
+ else {
472
+ if (!Array.isArray(src)) src = src.children;
473
+ nodes.value = src;
474
+ }
475
+ } finally {
476
+ loading.value = false;
477
+ }
478
+ }
479
+ watch(() => props.open, (v) => {
480
+ if (v) $modal.show();
481
+ else $modal.hide();
482
+ });
483
+ async function onShow() {
484
+ await loadItems();
485
+ updateSelectedItemsByValue();
486
+ }
487
+ function onHide() {
488
+ nodes.value = [];
489
+ q.value = "";
490
+ emits("hide");
491
+ }
492
+ function updateSelectedItemsByValue() {
493
+ const values = forceArray(props.value);
494
+ selectedNodes.value = flatNodes.value.filter((item) => {
495
+ return values.includes(valueGetter(item.value));
496
+ });
497
+ }
498
+ watch(() => props.value, () => updateSelectedItemsByValue(), {
499
+ immediate: true,
500
+ deep: true
501
+ });
502
+ const __returned__ = {
503
+ props,
504
+ emits,
505
+ valueGetter,
506
+ titleGetter,
507
+ searchMatcher,
508
+ loading,
509
+ multiple,
510
+ modalElement,
511
+ get $modal() {
512
+ return $modal;
513
+ },
514
+ set $modal(v) {
515
+ $modal = v;
516
+ },
517
+ nodes,
518
+ selectedNodes,
519
+ displayNodes,
520
+ flatNodes,
521
+ selectedValues,
522
+ canModify,
523
+ q,
524
+ searchEnabled,
525
+ searchedItems,
526
+ loadItems,
527
+ onShow,
528
+ onHide,
529
+ updateSelectedItemsByValue,
530
+ TreeItem: TreeItem_default
531
+ };
532
+ Object.defineProperty(__returned__, "__isScriptSetup", {
533
+ enumerable: false,
534
+ value: true
535
+ });
536
+ return __returned__;
537
+ }
531
538
  });
532
- const _hoisted_1$1 = ["id"];
533
- const _hoisted_2$1 = {
534
- class: "modal-dialog",
535
- role: "document"
539
+ //#endregion
540
+ //#region src/vue/components/ModalTree/TreeModal.vue
541
+ var _hoisted_1$1 = ["id"];
542
+ var _hoisted_2$1 = {
543
+ class: "modal-dialog",
544
+ role: "document"
536
545
  };
537
- const _hoisted_3$1 = { class: "modal-content" };
538
- const _hoisted_4$1 = { class: "modal-header" };
539
- const _hoisted_5$1 = ["id"];
540
- const _hoisted_6$1 = { class: "modal-body p-0" };
541
- const _hoisted_7$1 = { class: "std-form box-list m-3" };
542
- const _hoisted_8 = { class: "form-group" };
543
- const _hoisted_9 = ["placeholder"];
544
- const _hoisted_10 = {
545
- key: 0,
546
- class: "box-list__items"
546
+ var _hoisted_3$1 = { class: "modal-content" };
547
+ var _hoisted_4$1 = { class: "modal-header" };
548
+ var _hoisted_5$1 = ["id"];
549
+ var _hoisted_6$1 = { class: "modal-body p-0" };
550
+ var _hoisted_7$1 = { class: "std-form box-list m-3" };
551
+ var _hoisted_8 = { class: "form-group" };
552
+ var _hoisted_9 = ["placeholder"];
553
+ var _hoisted_10 = {
554
+ key: 0,
555
+ class: "box-list__items"
547
556
  };
548
- const _hoisted_11 = { key: 1 };
557
+ var _hoisted_11 = { key: 1 };
549
558
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
550
- return openBlock(), createElementBlock("div", {
551
- ref: "modal",
552
- class: "modal fade",
553
- id: `${$props.id}__modal`,
554
- tabindex: "-1",
555
- role: "dialog",
556
- "aria-labelledby": "-modal-label",
557
- "aria-hidden": "true"
558
- }, [
559
- createElementVNode("div", _hoisted_2$1, [
560
- createElementVNode("div", _hoisted_3$1, [
561
- createElementVNode("div", _hoisted_4$1, [
562
- createElementVNode("h4", {
563
- class: "modal-title",
564
- id: `${$props.id}__modal-label`
565
- }, toDisplayString($props.title), 9, _hoisted_5$1),
566
- _cache[1] || (_cache[1] = createElementVNode("button", {
567
- type: "button",
568
- class: "close btn-close",
569
- "data-bs-dismiss": "modal",
570
- "data-dismiss": "modal",
571
- "aria-label": "Close"
572
- }, [
573
- createElementVNode("span", {
574
- "aria-hidden": "true",
575
- class: "visually-hidden"
576
- }, "×")
577
- ], -1))
578
- ]),
579
- createElementVNode("div", _hoisted_6$1, [
580
- createElementVNode("div", _hoisted_7$1, [
581
- createElementVNode("div", _hoisted_8, [
582
- withDirectives(createElementVNode("input", {
583
- type: "search",
584
- class: "form-control",
585
- placeholder: $props.searchText,
586
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.q = $event)
587
- }, null, 8, _hoisted_9), [
588
- [vModelText, $setup.q]
589
- ])
590
- ])
591
- ]),
592
- !$setup.loading ? (openBlock(), createElementBlock("div", _hoisted_10, [
593
- (openBlock(true), createElementBlock(Fragment, null, renderList($setup.displayNodes, (node) => {
594
- return openBlock(), createBlock($setup["TreeItem"], {
595
- node,
596
- key: $setup.valueGetter(node.value),
597
- level: 1,
598
- branchSelectable: $props.branchSelectable
599
- }, null, 8, ["node", "branchSelectable"]);
600
- }), 128))
601
- ])) : (openBlock(), createElementBlock("div", _hoisted_11, [..._cache[2] || (_cache[2] = [
602
- createElementVNode("div", { class: "d-flex justify-content-center" }, [
603
- createElementVNode("div", { class: "spinner-border spinner-border-sm my-3" })
604
- ], -1)
605
- ])]))
606
- ])
607
- ])
608
- ])
609
- ], 8, _hoisted_1$1);
559
+ return openBlock(), createElementBlock("div", {
560
+ ref: "modal",
561
+ class: "modal fade",
562
+ id: `${$props.id}__modal`,
563
+ tabindex: "-1",
564
+ role: "dialog",
565
+ "aria-labelledby": "-modal-label",
566
+ "aria-hidden": "true"
567
+ }, [createElementVNode("div", _hoisted_2$1, [createElementVNode("div", _hoisted_3$1, [createElementVNode("div", _hoisted_4$1, [createElementVNode("h4", {
568
+ class: "modal-title",
569
+ id: `${$props.id}__modal-label`
570
+ }, toDisplayString($props.title), 9, _hoisted_5$1), _cache[1] || (_cache[1] = createElementVNode("button", {
571
+ type: "button",
572
+ class: "close btn-close",
573
+ "data-bs-dismiss": "modal",
574
+ "data-dismiss": "modal",
575
+ "aria-label": "Close"
576
+ }, [createElementVNode("span", {
577
+ "aria-hidden": "true",
578
+ class: "visually-hidden"
579
+ }, "×")], -1))]), createElementVNode("div", _hoisted_6$1, [createElementVNode("div", _hoisted_7$1, [createElementVNode("div", _hoisted_8, [withDirectives(createElementVNode("input", {
580
+ type: "search",
581
+ class: "form-control",
582
+ placeholder: $props.searchText,
583
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.q = $event)
584
+ }, null, 8, _hoisted_9), [[vModelText, $setup.q]])])]), !$setup.loading ? (openBlock(), createElementBlock("div", _hoisted_10, [(openBlock(true), createElementBlock(Fragment, null, renderList($setup.displayNodes, (node) => {
585
+ return openBlock(), createBlock($setup["TreeItem"], {
586
+ node,
587
+ key: $setup.valueGetter(node.value),
588
+ level: 1,
589
+ branchSelectable: $props.branchSelectable
590
+ }, null, 8, ["node", "branchSelectable"]);
591
+ }), 128))])) : (openBlock(), createElementBlock("div", _hoisted_11, [..._cache[2] || (_cache[2] = [createElementVNode("div", { class: "d-flex justify-content-center" }, [createElementVNode("div", { class: "spinner-border spinner-border-sm my-3" })], -1)])]))])])])], 8, _hoisted_1$1);
610
592
  }
611
- const TreeModal = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__file", "TreeModal.vue"]]);
612
- const _sfc_main = /* @__PURE__ */ defineComponent({
613
- __name: "ModalTreeApp",
614
- props: {
615
- id: {},
616
- name: {},
617
- title: {},
618
- disabled: { type: Boolean },
619
- readonly: { type: Boolean },
620
- value: {},
621
- source: {},
622
- items: {},
623
- valueGetter: { type: Function, default: (item) => item.id },
624
- titleGetter: { type: Function, default: (item) => item.title },
625
- searchMatcher: {},
626
- modalTitle: {},
627
- vertical: { type: Boolean },
628
- branchSelectable: { type: Boolean, default: false },
629
- selectAllChildren: { type: Boolean, default: false },
630
- placeholder: { default: "- No selected -" },
631
- multiple: { type: Boolean, default: false },
632
- buttonText: { default: "Select" },
633
- itemClass: { default: "badge bg-primary badge-pill" },
634
- searchText: { default: "Search" }
635
- },
636
- setup(__props, { expose: __expose }) {
637
- __expose();
638
- const props = __props;
639
- provide("id", props.id);
640
- provide("name", props.name);
641
- provide("multiple", props.multiple);
642
- provide("valueGetter", props.valueGetter);
643
- provide("titleGetter", props.titleGetter);
644
- provide("searchMatcher", props.searchMatcher ?? defaultSearchMatcher);
645
- function defaultSearchMatcher(item, q) {
646
- return props.titleGetter(item).toLowerCase().includes(q.toLowerCase());
647
- }
648
- const selected = ref([]);
649
- const value = ref(forceArray(props.value));
650
- const treeModalOpen = ref(false);
651
- function openSelector() {
652
- treeModalOpen.value = true;
653
- }
654
- function deleteItem(i, node) {
655
- selected.value = selected.value.filter((it) => props.valueGetter(it.value) !== props.valueGetter(node.value));
656
- }
657
- function handleSelected(items) {
658
- selected.value = cloneDeep(items);
659
- }
660
- watch(() => props.items, async (v) => {
661
- if (typeof v === "function") {
662
- v = await v();
663
- }
664
- selected.value = forceArray(v).filter((node) => {
665
- return value.value.includes(props.valueGetter(node.value));
666
- });
667
- }, { immediate: true });
668
- const selectedValues = computed(() => {
669
- return selected.value.map((node) => props.valueGetter(node.value));
670
- });
671
- const canModify = computed(() => {
672
- return !props.readonly && !props.disabled;
673
- });
674
- const __returned__ = { props, defaultSearchMatcher, selected, value, treeModalOpen, openSelector, deleteItem, handleSelected, selectedValues, canModify, TreeModal };
675
- Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
676
- return __returned__;
677
- }
593
+ var TreeModal_default = /* @__PURE__ */ _plugin_vue_export_helper_default(TreeModal_vue_vue_type_script_setup_true_lang_default, [["render", _sfc_render$1], ["__file", "TreeModal.vue"]]);
594
+ //#endregion
595
+ //#region src/vue/components/ModalTree/ModalTreeApp.vue?vue&type=script&setup=true&lang.ts
596
+ var ModalTreeApp_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
597
+ __name: "ModalTreeApp",
598
+ props: {
599
+ id: {},
600
+ name: {},
601
+ title: {},
602
+ disabled: { type: Boolean },
603
+ readonly: { type: Boolean },
604
+ value: {},
605
+ source: {},
606
+ items: {},
607
+ valueGetter: {
608
+ type: Function,
609
+ default: (item) => item.id
610
+ },
611
+ titleGetter: {
612
+ type: Function,
613
+ default: (item) => item.title
614
+ },
615
+ searchMatcher: {},
616
+ modalTitle: {},
617
+ vertical: { type: Boolean },
618
+ branchSelectable: {
619
+ type: Boolean,
620
+ default: false
621
+ },
622
+ selectAllChildren: {
623
+ type: Boolean,
624
+ default: false
625
+ },
626
+ placeholder: { default: "- No selected -" },
627
+ multiple: {
628
+ type: Boolean,
629
+ default: false
630
+ },
631
+ buttonText: { default: "Select" },
632
+ itemClass: { default: "badge bg-primary badge-pill" },
633
+ searchText: { default: "Search" }
634
+ },
635
+ setup(__props, { expose: __expose }) {
636
+ __expose();
637
+ const props = __props;
638
+ provide("id", props.id);
639
+ provide("name", props.name);
640
+ provide("multiple", props.multiple);
641
+ provide("valueGetter", props.valueGetter);
642
+ provide("titleGetter", props.titleGetter);
643
+ provide("searchMatcher", props.searchMatcher ?? defaultSearchMatcher);
644
+ function defaultSearchMatcher(item, q) {
645
+ return props.titleGetter(item).toLowerCase().includes(q.toLowerCase());
646
+ }
647
+ const selected = ref([]);
648
+ const value = ref(forceArray(props.value));
649
+ const treeModalOpen = ref(false);
650
+ function openSelector() {
651
+ treeModalOpen.value = true;
652
+ }
653
+ function deleteItem(i, node) {
654
+ selected.value = selected.value.filter((it) => props.valueGetter(it.value) !== props.valueGetter(node.value));
655
+ }
656
+ function handleSelected(items) {
657
+ selected.value = cloneDeep(items);
658
+ }
659
+ watch(() => props.items, async (v) => {
660
+ if (typeof v === "function") v = await v();
661
+ selected.value = forceArray(v).filter((node) => {
662
+ return value.value.includes(props.valueGetter(node.value));
663
+ });
664
+ }, { immediate: true });
665
+ const __returned__ = {
666
+ props,
667
+ defaultSearchMatcher,
668
+ selected,
669
+ value,
670
+ treeModalOpen,
671
+ openSelector,
672
+ deleteItem,
673
+ handleSelected,
674
+ selectedValues: computed(() => {
675
+ return selected.value.map((node) => props.valueGetter(node.value));
676
+ }),
677
+ canModify: computed(() => {
678
+ return !props.readonly && !props.disabled;
679
+ }),
680
+ TreeModal: TreeModal_default
681
+ };
682
+ Object.defineProperty(__returned__, "__isScriptSetup", {
683
+ enumerable: false,
684
+ value: true
685
+ });
686
+ return __returned__;
687
+ }
678
688
  });
679
- const _hoisted_1 = { class: "c-modal-tree" };
680
- const _hoisted_2 = { class: "btn-group" };
681
- const _hoisted_3 = { key: 1 };
682
- const _hoisted_4 = ["onClick"];
683
- const _hoisted_5 = {
684
- key: 2,
685
- class: "text-muted"
689
+ //#endregion
690
+ //#region src/vue/components/ModalTree/ModalTreeApp.vue
691
+ var _hoisted_1 = { class: "c-modal-tree" };
692
+ var _hoisted_2 = { class: "btn-group" };
693
+ var _hoisted_3 = { key: 1 };
694
+ var _hoisted_4 = ["onClick"];
695
+ var _hoisted_5 = {
696
+ key: 2,
697
+ class: "text-muted"
686
698
  };
687
- const _hoisted_6 = ["id", "name", "disabled", "readonly"];
688
- const _hoisted_7 = ["value"];
699
+ var _hoisted_6 = [
700
+ "id",
701
+ "name",
702
+ "disabled",
703
+ "readonly"
704
+ ];
705
+ var _hoisted_7 = ["value"];
689
706
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
690
- return openBlock(), createElementBlock("div", _hoisted_1, [
691
- createElementVNode("div", {
692
- class: normalizeClass(["c-modal-tree__container p-2 d-flex flex-column", [$props.vertical ? "" : "flex-md-row"]])
693
- }, [
694
- $setup.canModify ? (openBlock(), createElementBlock("div", {
695
- key: 0,
696
- class: normalizeClass(["me-2 mb-2", { "mb-md-0": !$props.vertical }])
697
- }, [
698
- createElementVNode("div", _hoisted_2, [
699
- createElementVNode("button", {
700
- class: "btn btn-secondary btn-sm btn-rounded text-nowrap",
701
- type: "button",
702
- onClick: $setup.openSelector
703
- }, toDisplayString($props.buttonText), 1),
704
- createElementVNode("button", {
705
- class: "btn btn-secondary btn-sm btn-rounded",
706
- type: "button",
707
- onClick: _cache[0] || (_cache[0] = ($event) => $setup.selected = [])
708
- }, [..._cache[2] || (_cache[2] = [
709
- createElementVNode("span", { class: "fa fa-times" }, null, -1)
710
- ])])
711
- ])
712
- ], 2)) : createCommentVNode("", true),
713
- $setup.selected.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_3, [
714
- createVNode(TransitionGroup, { name: "fade" }, {
715
- default: withCtx(() => [
716
- (openBlock(true), createElementBlock(Fragment, null, renderList($setup.selected, (node, i) => {
717
- return openBlock(), createElementBlock("span", {
718
- class: normalizeClass(["me-2 mb-2 c-item", $props.itemClass]),
719
- key: $props.valueGetter(node.value),
720
- style: { "animation-duration": ".3s" }
721
- }, [
722
- createElementVNode("span", null, toDisplayString($props.titleGetter(node.value)), 1),
723
- $setup.canModify ? (openBlock(), createElementBlock("span", {
724
- key: 0,
725
- type: "button",
726
- onClick: withModifiers(($event) => $setup.deleteItem(i, node), ["prevent"]),
727
- class: "ms-2",
728
- style: { "cursor": "pointer" }
729
- }, [..._cache[3] || (_cache[3] = [
730
- createElementVNode("span", { class: "fa fa-times" }, null, -1)
731
- ])], 8, _hoisted_4)) : createCommentVNode("", true)
732
- ], 2);
733
- }), 128))
734
- ]),
735
- _: 1
736
- })
737
- ])) : (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString($props.placeholder), 1))
738
- ], 2),
739
- createElementVNode("select", mergeProps({
740
- multiple: "",
741
- style: { "display": "none" },
742
- ref: "input",
743
- id: $props.id,
744
- name: $props.name,
745
- disabled: $props.disabled,
746
- readonly: $props.readonly
747
- }, _ctx.$attrs), [
748
- (openBlock(true), createElementBlock(Fragment, null, renderList($setup.selectedValues, (id) => {
749
- return openBlock(), createElementBlock("option", {
750
- value: id,
751
- selected: true
752
- }, toDisplayString(id), 9, _hoisted_7);
753
- }), 256))
754
- ], 16, _hoisted_6),
755
- createVNode($setup["TreeModal"], mergeProps({
756
- open: $setup.treeModalOpen,
757
- onHide: _cache[1] || (_cache[1] = ($event) => $setup.treeModalOpen = false),
758
- id: $props.id,
759
- title: $props.modalTitle,
760
- source: $props.source,
761
- value: $setup.selectedValues,
762
- branchSelectable: $props.branchSelectable
763
- }, _ctx.$attrs, {
764
- disabled: $props.disabled,
765
- readonly: $props.readonly,
766
- "search-text": $props.searchText,
767
- onSelected: $setup.handleSelected
768
- }), null, 16, ["open", "id", "title", "source", "value", "branchSelectable", "disabled", "readonly", "search-text"])
769
- ]);
707
+ return openBlock(), createElementBlock("div", _hoisted_1, [
708
+ createElementVNode("div", { class: normalizeClass(["c-modal-tree__container p-2 d-flex flex-column", [$props.vertical ? "" : "flex-md-row"]]) }, [$setup.canModify ? (openBlock(), createElementBlock("div", {
709
+ key: 0,
710
+ class: normalizeClass(["me-2 mb-2", { "mb-md-0": !$props.vertical }])
711
+ }, [createElementVNode("div", _hoisted_2, [createElementVNode("button", {
712
+ class: "btn btn-secondary btn-sm btn-rounded text-nowrap",
713
+ type: "button",
714
+ onClick: $setup.openSelector
715
+ }, toDisplayString($props.buttonText), 1), createElementVNode("button", {
716
+ class: "btn btn-secondary btn-sm btn-rounded",
717
+ type: "button",
718
+ onClick: _cache[0] || (_cache[0] = ($event) => $setup.selected = [])
719
+ }, [..._cache[2] || (_cache[2] = [createElementVNode("span", { class: "fa fa-times" }, null, -1)])])])], 2)) : createCommentVNode("", true), $setup.selected.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(TransitionGroup, { name: "fade" }, {
720
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList($setup.selected, (node, i) => {
721
+ return openBlock(), createElementBlock("span", {
722
+ class: normalizeClass(["me-2 mb-2 c-item", $props.itemClass]),
723
+ key: $props.valueGetter(node.value),
724
+ style: { "animation-duration": ".3s" }
725
+ }, [createElementVNode("span", null, toDisplayString($props.titleGetter(node.value)), 1), $setup.canModify ? (openBlock(), createElementBlock("span", {
726
+ key: 0,
727
+ type: "button",
728
+ onClick: withModifiers(($event) => $setup.deleteItem(i, node), ["prevent"]),
729
+ class: "ms-2",
730
+ style: { "cursor": "pointer" }
731
+ }, [..._cache[3] || (_cache[3] = [createElementVNode("span", { class: "fa fa-times" }, null, -1)])], 8, _hoisted_4)) : createCommentVNode("", true)], 2);
732
+ }), 128))]),
733
+ _: 1
734
+ })])) : (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString($props.placeholder), 1))], 2),
735
+ createElementVNode("select", mergeProps({
736
+ multiple: "",
737
+ style: { "display": "none" },
738
+ ref: "input",
739
+ id: $props.id,
740
+ name: $props.name,
741
+ disabled: $props.disabled,
742
+ readonly: $props.readonly
743
+ }, _ctx.$attrs), [(openBlock(true), createElementBlock(Fragment, null, renderList($setup.selectedValues, (id) => {
744
+ return openBlock(), createElementBlock("option", {
745
+ value: id,
746
+ selected: true
747
+ }, toDisplayString(id), 9, _hoisted_7);
748
+ }), 256))], 16, _hoisted_6),
749
+ createVNode($setup["TreeModal"], mergeProps({
750
+ open: $setup.treeModalOpen,
751
+ onHide: _cache[1] || (_cache[1] = ($event) => $setup.treeModalOpen = false),
752
+ id: $props.id,
753
+ title: $props.modalTitle,
754
+ source: $props.source,
755
+ value: $setup.selectedValues,
756
+ branchSelectable: $props.branchSelectable
757
+ }, _ctx.$attrs, {
758
+ disabled: $props.disabled,
759
+ readonly: $props.readonly,
760
+ "search-text": $props.searchText,
761
+ onSelected: $setup.handleSelected
762
+ }), null, 16, [
763
+ "open",
764
+ "id",
765
+ "title",
766
+ "source",
767
+ "value",
768
+ "branchSelectable",
769
+ "disabled",
770
+ "readonly",
771
+ "search-text"
772
+ ])
773
+ ]);
770
774
  }
771
- const ModalTreeApp = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-f21c791b"], ["__file", "ModalTreeApp.vue"]]);
772
- const app = /* @__PURE__ */ createApp({
773
- name: "modal-tree",
774
- components: {
775
- ModalTreeApp
776
- }
775
+ //#endregion
776
+ //#region src/module/field-modal-tree.ts
777
+ var app = /* @__PURE__ */ createApp({
778
+ name: "modal-tree",
779
+ components: { ModalTreeApp: /* @__PURE__ */ _plugin_vue_export_helper_default(ModalTreeApp_vue_vue_type_script_setup_true_lang_default, [
780
+ ["render", _sfc_render],
781
+ ["__scopeId", "data-v-f21c791b"],
782
+ ["__file", "ModalTreeApp.vue"]
783
+ ]) }
777
784
  });
778
785
  app.config.globalProperties.$getData = data;
779
- class ModalTreeElement extends HTMLElement {
780
- static is = "modal-tree";
781
- vm;
782
- connectedCallback() {
783
- if (!this.vm) {
784
- this.vm = app.mount(this);
785
- }
786
- }
787
- }
786
+ var ModalTreeElement = class extends HTMLElement {
787
+ static is = "modal-tree";
788
+ vm;
789
+ connectedCallback() {
790
+ if (!this.vm) this.vm = app.mount(this);
791
+ }
792
+ };
788
793
  async function init() {
789
- customElements.define(ModalTreeElement.is, ModalTreeElement);
790
- await useCssImport("@vue-animate");
794
+ customElements.define(ModalTreeElement.is, ModalTreeElement);
795
+ await useCssImport("@vue-animate");
791
796
  }
792
- const ready = /* @__PURE__ */ init();
793
- export {
794
- ready
795
- };
796
- //# sourceMappingURL=field-modal-tree.js.map
797
+ var ready = /* @__PURE__ */ init();
798
+ //#endregion
799
+ export { ready };
800
+
801
+ //# sourceMappingURL=field-modal-tree.js.map