vue-devui 1.0.0-beta.1 → 1.0.0-beta.10
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/accordion/index.d.ts +7 -0
- package/accordion/index.es.js +186 -139
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.d.ts +7 -0
- package/alert/index.es.js +2 -3
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/anchor/index.d.ts +7 -0
- package/avatar/index.d.ts +7 -0
- package/avatar/index.es.js +1 -1
- package/avatar/index.umd.js +1 -1
- package/back-top/index.d.ts +7 -0
- package/back-top/index.es.js +128 -0
- package/back-top/index.umd.js +1 -0
- package/back-top/package.json +7 -0
- package/back-top/style.css +1 -0
- package/badge/index.d.ts +7 -0
- package/badge/index.es.js +1 -1
- package/badge/index.umd.js +1 -1
- package/breadcrumb/index.d.ts +7 -0
- package/button/index.d.ts +7 -0
- package/button/index.es.js +9 -8
- package/button/index.umd.js +1 -1
- package/card/index.d.ts +7 -0
- package/card/index.es.js +1 -1
- package/card/index.umd.js +1 -1
- package/carousel/index.d.ts +7 -0
- package/carousel/index.es.js +5 -4
- package/carousel/index.umd.js +1 -1
- package/cascader/index.d.ts +7 -0
- package/cascader/index.es.js +1239 -83
- package/cascader/index.umd.js +1 -1
- package/cascader/style.css +1 -1
- package/checkbox/index.d.ts +7 -0
- package/checkbox/index.es.js +43 -8
- package/checkbox/index.umd.js +1 -1
- package/comment/index.d.ts +7 -0
- package/comment/index.es.js +85 -0
- package/comment/index.umd.js +1 -0
- package/comment/package.json +7 -0
- package/comment/style.css +1 -0
- package/countdown/index.d.ts +7 -0
- package/countdown/index.es.js +176 -0
- package/countdown/index.umd.js +1 -0
- package/countdown/package.json +7 -0
- package/countdown/style.css +1 -0
- package/date-picker/index.d.ts +7 -0
- package/date-picker/index.es.js +32 -21
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.d.ts +7 -0
- package/dragdrop/index.es.js +32 -0
- package/dragdrop/index.umd.js +1 -0
- package/dragdrop/package.json +7 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +161 -41
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +527 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/editable-select/index.d.ts +7 -0
- package/editable-select/index.es.js +5718 -469
- package/editable-select/index.umd.js +27 -1
- package/editable-select/style.css +1 -1
- package/form/index.d.ts +7 -0
- package/form/index.es.js +2244 -0
- package/form/index.umd.js +1 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/fullscreen/index.d.ts +7 -0
- package/fullscreen/index.es.js +14 -4
- package/fullscreen/index.umd.js +1 -1
- package/gantt/index.d.ts +7 -0
- package/gantt/index.es.js +535 -0
- package/gantt/index.umd.js +1 -0
- package/gantt/package.json +7 -0
- package/gantt/style.css +1 -0
- package/grid/index.d.ts +7 -0
- package/grid/index.es.js +269 -0
- package/grid/index.umd.js +1 -0
- package/grid/package.json +7 -0
- package/grid/style.css +1 -0
- package/icon/index.d.ts +7 -0
- package/icon/index.es.js +6 -5
- package/icon/index.umd.js +1 -1
- package/image-preview/index.d.ts +7 -0
- package/image-preview/index.es.js +72 -11
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/index.d.ts +7 -0
- package/input/index.d.ts +7 -0
- package/input/index.es.js +24 -13
- package/input/index.umd.js +1 -1
- package/input-icon/index.d.ts +7 -0
- package/input-icon/index.es.js +332 -0
- package/input-icon/index.umd.js +1 -0
- package/input-icon/package.json +7 -0
- package/input-icon/style.css +1 -0
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +5 -4
- package/input-number/index.umd.js +1 -1
- package/layout/index.d.ts +7 -0
- package/layout/index.es.js +1 -1
- package/layout/index.umd.js +1 -1
- package/loading/index.d.ts +7 -0
- package/loading/index.es.js +1 -1
- package/loading/index.umd.js +1 -1
- package/modal/index.d.ts +7 -0
- package/modal/index.es.js +117 -99
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.d.ts +7 -0
- package/nuxt/components/Accordion.js +3 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Anchor.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/BackTop.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Breadcrumb.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Carousel.js +3 -0
- package/nuxt/components/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Comment.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Gantt.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/Icon.js +2 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputIcon.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/MultiUpload.js +3 -0
- package/nuxt/components/NavSprite.js +2 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/QuadrantDiagram.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/ReadTip.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/StepsGuide.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Sticky.js +2 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/TagInput.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimeAxis.js +3 -0
- package/nuxt/components/TimeAxisItem.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/Toast.js +3 -0
- package/nuxt/components/ToastService.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Transfer.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/TreeSelect.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/buttonProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.d.ts +7 -0
- package/overlay/index.es.js +110 -93
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +6 -33
- package/pagination/index.d.ts +7 -0
- package/pagination/index.es.js +3 -3
- package/pagination/index.umd.js +1 -1
- package/panel/index.d.ts +7 -0
- package/panel/index.es.js +25 -22
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.d.ts +7 -0
- package/popover/index.es.js +5 -2
- package/popover/index.umd.js +1 -1
- package/progress/index.d.ts +7 -0
- package/progress/index.es.js +1 -1
- package/progress/index.umd.js +2 -2
- package/quadrant-diagram/index.d.ts +7 -0
- package/radio/index.d.ts +7 -0
- package/radio/index.es.js +1 -1
- package/radio/index.umd.js +1 -1
- package/rate/index.d.ts +7 -0
- package/rate/index.es.js +1 -1
- package/rate/index.umd.js +1 -1
- package/read-tip/index.d.ts +7 -0
- package/read-tip/index.es.js +258 -0
- package/read-tip/index.umd.js +1 -0
- package/read-tip/package.json +7 -0
- package/read-tip/style.css +1 -0
- package/result/index.d.ts +7 -0
- package/result/index.es.js +119 -0
- package/result/index.umd.js +1 -0
- package/result/package.json +7 -0
- package/result/style.css +1 -0
- package/ripple/index.d.ts +7 -0
- package/ripple/index.es.js +5 -2
- package/ripple/index.umd.js +1 -1
- package/search/index.d.ts +7 -0
- package/search/index.es.js +35 -21
- package/search/index.umd.js +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +47 -11
- package/select/index.umd.js +1 -1
- package/skeleton/index.d.ts +7 -0
- package/skeleton/index.es.js +148 -26
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.d.ts +7 -0
- package/slider/index.es.js +30 -177
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.d.ts +7 -0
- package/splitter/index.es.js +107 -89
- package/splitter/index.umd.js +1 -1
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +280 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.d.ts +7 -0
- package/status/index.es.js +2 -2
- package/status/index.umd.js +1 -1
- package/steps-guide/index.d.ts +7 -0
- package/steps-guide/index.es.js +101 -73
- package/steps-guide/index.umd.js +1 -1
- package/steps-guide/style.css +1 -1
- package/sticky/index.d.ts +7 -0
- package/style.css +1 -1
- package/switch/index.d.ts +7 -0
- package/switch/index.es.js +1 -1
- package/switch/index.umd.js +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +1498 -156
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +6 -3
- package/tabs/index.umd.js +1 -1
- package/tag/index.d.ts +7 -0
- package/tag/index.es.js +131 -0
- package/tag/index.umd.js +1 -0
- package/tag/package.json +7 -0
- package/tag/style.css +1 -0
- package/tag-input/index.d.ts +7 -0
- package/tag-input/index.es.js +1 -13
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.d.ts +7 -0
- package/textarea/index.es.js +132 -0
- package/textarea/index.umd.js +1 -0
- package/textarea/package.json +7 -0
- package/textarea/style.css +1 -0
- package/time-axis/index.d.ts +7 -0
- package/time-axis/index.es.js +241 -21
- package/time-axis/index.umd.js +1 -1
- package/time-axis/style.css +1 -1
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +50 -26
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.d.ts +7 -0
- package/toast/index.es.js +8 -7
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/tooltip/index.d.ts +7 -0
- package/transfer/index.d.ts +7 -0
- package/transfer/index.es.js +368 -79
- package/transfer/index.umd.js +1 -1
- package/transfer/style.css +1 -1
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +171 -35
- package/tree/index.umd.js +1 -1
- package/tree-select/index.d.ts +7 -0
- package/tree-select/index.es.js +528 -0
- package/tree-select/index.umd.js +1 -0
- package/tree-select/package.json +7 -0
- package/tree-select/style.css +1 -0
- package/upload/index.d.ts +7 -0
- package/upload/index.es.js +8 -7
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +19214 -7637
- package/vue-devui.umd.js +29 -3
package/tree/index.es.js
CHANGED
|
@@ -21,7 +21,7 @@ var __publicField = (obj, key, value) => {
|
|
|
21
21
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
|
-
import { h, render, defineComponent, ref, createVNode, inject, computed, mergeProps, unref, toRefs, provide } from "vue";
|
|
24
|
+
import { h, render, defineComponent, ref, createVNode, inject, computed, mergeProps, watch, unref, Fragment, onUpdated, toRefs, reactive, provide } from "vue";
|
|
25
25
|
const treeProps = {
|
|
26
26
|
data: {
|
|
27
27
|
type: Array,
|
|
@@ -49,20 +49,42 @@ const CHECK_CONFIG = {
|
|
|
49
49
|
const flatten = (tree2, key = "children") => {
|
|
50
50
|
return tree2.reduce((acc, item) => !item[key] ? acc.concat(item) : acc.concat(item, flatten(item[key], key)), []);
|
|
51
51
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const getRandomId = () => (Math.random() * 10 ** 9).toString().slice(0, 8);
|
|
53
|
+
const preCheckNodeId = (d, postfixId) => {
|
|
54
|
+
const randomStr = getRandomId();
|
|
55
|
+
console.info("randomStr: ", randomStr);
|
|
56
|
+
return __spreadProps(__spreadValues({}, d), { id: postfixId ? `${postfixId}_${randomStr}` : randomStr });
|
|
55
57
|
};
|
|
56
|
-
const
|
|
58
|
+
const getId = (id) => {
|
|
59
|
+
const ids = id.split("_");
|
|
60
|
+
return [...ids.slice(0, ids.length), getRandomId()].join("_");
|
|
61
|
+
};
|
|
62
|
+
const preCheckTree = (ds, postfixId) => {
|
|
57
63
|
return ds.map((d) => {
|
|
58
|
-
const dd =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
const dd = preCheckNodeId(d, postfixId);
|
|
65
|
+
return d.children ? __spreadProps(__spreadValues({}, dd), {
|
|
66
|
+
children: preCheckTree(d.children, dd.id)
|
|
67
|
+
}) : dd;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const _deleteNode = (ids, data, index2 = 0) => {
|
|
71
|
+
const curTargetId = ids.slice(0, index2 + 2).join("_");
|
|
72
|
+
data.forEach((item) => {
|
|
73
|
+
if (item.id === ids.slice(0, index2 + 1).join("_")) {
|
|
74
|
+
if (ids.length === index2 + 2) {
|
|
75
|
+
item.children = item.children.filter(({ id: d }) => d !== curTargetId);
|
|
76
|
+
} else {
|
|
77
|
+
item.children = _deleteNode(ids, item.children, index2 + 1);
|
|
78
|
+
}
|
|
63
79
|
}
|
|
64
|
-
return dd;
|
|
65
80
|
});
|
|
81
|
+
return data;
|
|
82
|
+
};
|
|
83
|
+
const deleteNode = (id, data) => {
|
|
84
|
+
if (id.includes("_")) {
|
|
85
|
+
return _deleteNode(id.split("_"), data);
|
|
86
|
+
}
|
|
87
|
+
return data.filter(({ id: d }) => d !== id);
|
|
66
88
|
};
|
|
67
89
|
const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
|
|
68
90
|
function createComponent(Component, props, children = null) {
|
|
@@ -196,10 +218,17 @@ const commonProps = {
|
|
|
196
218
|
type: String,
|
|
197
219
|
default: void 0
|
|
198
220
|
},
|
|
221
|
+
halfchecked: {
|
|
222
|
+
type: Boolean,
|
|
223
|
+
default: false
|
|
224
|
+
},
|
|
199
225
|
isShowTitle: {
|
|
200
226
|
type: Boolean,
|
|
201
227
|
default: true
|
|
202
228
|
},
|
|
229
|
+
title: {
|
|
230
|
+
type: String
|
|
231
|
+
},
|
|
203
232
|
color: {
|
|
204
233
|
type: String,
|
|
205
234
|
default: void 0
|
|
@@ -269,15 +298,15 @@ var Checkbox = defineComponent({
|
|
|
269
298
|
});
|
|
270
299
|
const mergedIsShowTitle = computed(() => {
|
|
271
300
|
var _a;
|
|
272
|
-
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle) != null ? _a : props.isShowTitle;
|
|
301
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
|
|
273
302
|
});
|
|
274
303
|
const mergedShowAnimation = computed(() => {
|
|
275
304
|
var _a;
|
|
276
|
-
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation) != null ? _a : props.showAnimation;
|
|
305
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
|
|
277
306
|
});
|
|
278
307
|
const mergedColor = computed(() => {
|
|
279
308
|
var _a;
|
|
280
|
-
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color) != null ? _a : props.color;
|
|
309
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
|
|
281
310
|
});
|
|
282
311
|
const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
|
|
283
312
|
const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
|
|
@@ -304,7 +333,7 @@ var Checkbox = defineComponent({
|
|
|
304
333
|
ctx.emit("change", current);
|
|
305
334
|
};
|
|
306
335
|
const handleClick = () => {
|
|
307
|
-
canChange(!isChecked.value, props.
|
|
336
|
+
canChange(!isChecked.value, props.label).then((res) => res && toggle());
|
|
308
337
|
};
|
|
309
338
|
return {
|
|
310
339
|
itemWidth,
|
|
@@ -408,13 +437,14 @@ function useToggle(data) {
|
|
|
408
437
|
const openedTree = (tree2) => {
|
|
409
438
|
return tree2.reduce((acc, item) => item.open ? acc.concat(item, openedTree(item.children)) : acc.concat(item), []);
|
|
410
439
|
};
|
|
411
|
-
const openedData = ref(openedTree(data));
|
|
440
|
+
const openedData = ref(openedTree(data.value));
|
|
441
|
+
watch(() => data.value, (d) => openedData.value = openedTree(d), { deep: true });
|
|
412
442
|
const toggle = (target, item) => {
|
|
413
443
|
target.stopPropagation();
|
|
414
444
|
if (!item.children)
|
|
415
445
|
return;
|
|
416
446
|
item.open = !item.open;
|
|
417
|
-
openedData.value = openedTree(data);
|
|
447
|
+
openedData.value = openedTree(data.value);
|
|
418
448
|
};
|
|
419
449
|
return {
|
|
420
450
|
openedData,
|
|
@@ -456,16 +486,21 @@ const HIGHLIGHT_CLASS = "active";
|
|
|
456
486
|
const IS_DISABLED_FLAG = "devui-tree_isDisabledNode";
|
|
457
487
|
const useHighlightNode = () => {
|
|
458
488
|
const nodeClassNameReflectRef = ref({});
|
|
489
|
+
const prevActiveNodeKey = ref("");
|
|
459
490
|
const handleInit = (isDisabled = false, ...keys) => {
|
|
460
491
|
const key = keys.join("-");
|
|
461
492
|
nodeClassNameReflectRef.value[key] = isDisabled ? IS_DISABLED_FLAG : nodeClassNameReflectRef.value[key] || "";
|
|
462
493
|
return key;
|
|
463
494
|
};
|
|
464
495
|
const handleClick = (key) => {
|
|
465
|
-
if (nodeClassNameReflectRef.value[key] === IS_DISABLED_FLAG)
|
|
496
|
+
if (nodeClassNameReflectRef.value[key] === IS_DISABLED_FLAG)
|
|
466
497
|
return;
|
|
467
|
-
|
|
468
|
-
|
|
498
|
+
if (prevActiveNodeKey.value === key)
|
|
499
|
+
return;
|
|
500
|
+
if (prevActiveNodeKey.value)
|
|
501
|
+
nodeClassNameReflectRef.value[prevActiveNodeKey.value] = "";
|
|
502
|
+
nodeClassNameReflectRef.value[key] = HIGHLIGHT_CLASS;
|
|
503
|
+
prevActiveNodeKey.value = key;
|
|
469
504
|
};
|
|
470
505
|
return {
|
|
471
506
|
nodeClassNameReflect: nodeClassNameReflectRef,
|
|
@@ -606,6 +641,42 @@ const useLazy = () => {
|
|
|
606
641
|
getLazyData
|
|
607
642
|
};
|
|
608
643
|
};
|
|
644
|
+
const reflectIconWithHandle = (data, operator) => {
|
|
645
|
+
const handleAdd = (payload) => operator.handleAdd();
|
|
646
|
+
const handleEdit = (payload) => operator.handleEdit();
|
|
647
|
+
const handleDelete = (payload) => operator.handleDelete();
|
|
648
|
+
return createVNode(Fragment, null, [operator.addable && createVNode("span", {
|
|
649
|
+
"class": "op-icons icon icon-add",
|
|
650
|
+
"onClick": handleAdd
|
|
651
|
+
}, null), operator.editable && createVNode("span", {
|
|
652
|
+
"class": "op-icons icon icon-edit",
|
|
653
|
+
"onClick": handleEdit
|
|
654
|
+
}, null), operator.deletable && createVNode("span", {
|
|
655
|
+
"class": "op-icons icon icon-close",
|
|
656
|
+
"onClick": handleDelete
|
|
657
|
+
}, null)]);
|
|
658
|
+
};
|
|
659
|
+
const useOperate = (treeData) => {
|
|
660
|
+
const operateIconReflect = ref([]);
|
|
661
|
+
const editStatusReflect = ref({});
|
|
662
|
+
const handleReflectIdToIcon = (id, operator) => {
|
|
663
|
+
const isNotExistedReflectItem = operateIconReflect.value.every(({
|
|
664
|
+
id: d
|
|
665
|
+
}) => d != id);
|
|
666
|
+
if (isNotExistedReflectItem) {
|
|
667
|
+
editStatusReflect.value[id] = false;
|
|
668
|
+
operateIconReflect.value.push({
|
|
669
|
+
id,
|
|
670
|
+
renderIcon: (data) => reflectIconWithHandle(data, operator)
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
return {
|
|
675
|
+
operateIconReflect,
|
|
676
|
+
editStatusReflect,
|
|
677
|
+
handleReflectIdToIcon
|
|
678
|
+
};
|
|
679
|
+
};
|
|
609
680
|
var IconOpen = "data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIxNnB4IgogIGhlaWdodD0iMTZweCIKICB2aWV3Qm94PSIwIDAgMTYgMTYiCiAgdmVyc2lvbj0iMS4xIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIKICBjbGFzcz0ic3ZnLWljb24gc3ZnLWljb24tY2xvc2UiCj4KICA8ZyBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICA8cmVjdCB4PSIwLjUiIHk9IjAuNSIgd2lkdGg9IjE1IiBoZWlnaHQ9IjE1IiByeD0iMiIgc3Ryb2tlPSIjNWU3Y2UwIj48L3JlY3Q+CiAgICA8cmVjdCB4PSI0IiB5PSI3IiB3aWR0aD0iOCIgaGVpZ2h0PSIyIiBmaWxsPSIjNWU3Y2UwIj48L3JlY3Q+CiAgPC9nPgo8L3N2Zz4=";
|
|
610
681
|
var IconClose = "data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIxNnB4IgogIGhlaWdodD0iMTZweCIKICB2aWV3Qm94PSIwIDAgMTYgMTYiCiAgdmVyc2lvbj0iMS4xIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIKICBjbGFzcz0ic3ZnLWljb24iCj4KICA8ZyBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgIDxyZWN0IHg9IjAuNSIgeT0iMC41IiB3aWR0aD0iMTUiIGhlaWdodD0iMTUiIHJ4PSIyIiBzdHJva2U9IiMyNTJiM2EiPjwvcmVjdD4KICAgIDxwYXRoCiAgICAgIGZpbGw9IiMyNTJiM2EiCiAgICAgIGQ9Ik04Ljc1LDQgTDguNzUsNy4yNSBMMTIsNy4yNSBMMTIsOC43NSBMOC43NDksOC43NSBMOC43NSwxMiBMNy4yNSwxMiBMNy4yNDksOC43NSBMNCw4Ljc1IEw0LDcuMjUgTDcuMjUsNy4yNSBMNy4yNSw0IEw4Ljc1LDQgWiIKICAgID48L3BhdGg+CiAgPC9nPgo8L3N2Zz4K";
|
|
611
682
|
var NodeContent = defineComponent({
|
|
@@ -614,21 +685,48 @@ var NodeContent = defineComponent({
|
|
|
614
685
|
node: {
|
|
615
686
|
type: Object,
|
|
616
687
|
required: true
|
|
688
|
+
},
|
|
689
|
+
editStatusReflect: {
|
|
690
|
+
type: Object,
|
|
691
|
+
required: true
|
|
617
692
|
}
|
|
618
693
|
},
|
|
619
694
|
setup(props) {
|
|
620
695
|
const tree2 = inject("treeRoot");
|
|
696
|
+
const getCurID = (id) => `devui-tree-node__input-${id}`;
|
|
697
|
+
onUpdated(() => {
|
|
698
|
+
const target = document.querySelector(`#${getCurID(props.node.id)}`);
|
|
699
|
+
target == null ? void 0 : target.focus();
|
|
700
|
+
});
|
|
621
701
|
return () => {
|
|
622
|
-
const
|
|
702
|
+
const {
|
|
703
|
+
node,
|
|
704
|
+
editStatusReflect
|
|
705
|
+
} = toRefs(props);
|
|
623
706
|
const {
|
|
624
707
|
disabled,
|
|
625
|
-
label
|
|
626
|
-
|
|
708
|
+
label,
|
|
709
|
+
id
|
|
710
|
+
} = node.value;
|
|
711
|
+
const handleChange = ({
|
|
712
|
+
target
|
|
713
|
+
}) => {
|
|
714
|
+
node.value.label = target.value;
|
|
715
|
+
};
|
|
716
|
+
const handleBlur = () => {
|
|
717
|
+
editStatusReflect.value[id] = false;
|
|
718
|
+
};
|
|
627
719
|
return tree2.ctx.slots.default ? tree2.ctx.slots.default({
|
|
628
720
|
node
|
|
629
721
|
}) : createVNode("span", {
|
|
630
722
|
"class": ["devui-tree-node__title", disabled && "select-disabled"]
|
|
631
|
-
}, [
|
|
723
|
+
}, [editStatusReflect.value[id] ? createVNode("input", {
|
|
724
|
+
"id": getCurID(id),
|
|
725
|
+
"ref": ref,
|
|
726
|
+
"value": label,
|
|
727
|
+
"onChange": handleChange,
|
|
728
|
+
"onBlur": handleBlur
|
|
729
|
+
}, null) : label]);
|
|
632
730
|
};
|
|
633
731
|
}
|
|
634
732
|
});
|
|
@@ -642,16 +740,16 @@ var Tree = defineComponent({
|
|
|
642
740
|
data,
|
|
643
741
|
checkable,
|
|
644
742
|
checkableRelation: cbr
|
|
645
|
-
} = toRefs(__spreadProps(__spreadValues({}, props), {
|
|
646
|
-
data:
|
|
647
|
-
}));
|
|
743
|
+
} = toRefs(reactive(__spreadProps(__spreadValues({}, props), {
|
|
744
|
+
data: preCheckTree(props.data)
|
|
745
|
+
})));
|
|
648
746
|
const {
|
|
649
747
|
mergeData
|
|
650
748
|
} = useMergeNode(data.value);
|
|
651
749
|
const {
|
|
652
750
|
openedData,
|
|
653
751
|
toggle
|
|
654
|
-
} = useToggle(mergeData
|
|
752
|
+
} = useToggle(mergeData);
|
|
655
753
|
const {
|
|
656
754
|
nodeClassNameReflect,
|
|
657
755
|
handleInitNodeClassNameReflect,
|
|
@@ -666,6 +764,11 @@ var Tree = defineComponent({
|
|
|
666
764
|
selected,
|
|
667
765
|
onNodeClick
|
|
668
766
|
} = useChecked(cbr, ctx, data.value);
|
|
767
|
+
const {
|
|
768
|
+
editStatusReflect,
|
|
769
|
+
operateIconReflect,
|
|
770
|
+
handleReflectIdToIcon
|
|
771
|
+
} = useOperate();
|
|
669
772
|
provide("treeRoot", {
|
|
670
773
|
ctx,
|
|
671
774
|
props
|
|
@@ -684,8 +787,38 @@ var Tree = defineComponent({
|
|
|
684
787
|
open,
|
|
685
788
|
isParent,
|
|
686
789
|
level,
|
|
687
|
-
children
|
|
790
|
+
children,
|
|
791
|
+
addable,
|
|
792
|
+
editable,
|
|
793
|
+
deletable
|
|
688
794
|
} = item;
|
|
795
|
+
handleReflectIdToIcon(id, {
|
|
796
|
+
addable,
|
|
797
|
+
editable,
|
|
798
|
+
deletable,
|
|
799
|
+
handleAdd: () => {
|
|
800
|
+
const newItem = {
|
|
801
|
+
id: getId(item.id),
|
|
802
|
+
label: "new item",
|
|
803
|
+
level: item.level + 1,
|
|
804
|
+
addable,
|
|
805
|
+
editable,
|
|
806
|
+
deletable
|
|
807
|
+
};
|
|
808
|
+
item.open = true;
|
|
809
|
+
if (item.children && Array.isArray(item.children)) {
|
|
810
|
+
item.children.push(newItem);
|
|
811
|
+
} else {
|
|
812
|
+
item.children = [newItem];
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
handleEdit: () => {
|
|
816
|
+
editStatusReflect.value[id] = !editStatusReflect.value[id];
|
|
817
|
+
},
|
|
818
|
+
handleDelete: () => {
|
|
819
|
+
mergeData.value = deleteNode(id, mergeData.value);
|
|
820
|
+
}
|
|
821
|
+
});
|
|
689
822
|
handleInitNodeClassNameReflect(disabled, id);
|
|
690
823
|
handleInitLazyNodeReflect(item, {
|
|
691
824
|
id,
|
|
@@ -713,14 +846,14 @@ var Tree = defineComponent({
|
|
|
713
846
|
});
|
|
714
847
|
}
|
|
715
848
|
});
|
|
716
|
-
const
|
|
849
|
+
const renderFoldIcon = (item2) => {
|
|
717
850
|
const handleClick = async (target) => {
|
|
718
851
|
if (item2.isParent) {
|
|
719
852
|
item2.children = await getLazyData(id);
|
|
720
853
|
}
|
|
721
854
|
return toggle(target, item2);
|
|
722
855
|
};
|
|
723
|
-
return isParent || children ? open ? createVNode(IconOpen, {
|
|
856
|
+
return isParent || children && children.length ? open ? createVNode(IconOpen, {
|
|
724
857
|
"class": "mr-xs",
|
|
725
858
|
"onClick": handleClick
|
|
726
859
|
}, null) : createVNode(IconClose, {
|
|
@@ -739,16 +872,19 @@ var Tree = defineComponent({
|
|
|
739
872
|
"onClick": () => handleClickOnNode(id)
|
|
740
873
|
}, [createVNode("div", {
|
|
741
874
|
"class": "devui-tree-node__content--value-wrapper"
|
|
742
|
-
}, [
|
|
875
|
+
}, [renderFoldIcon(item), checkable.value && createVNode(Checkbox, mergeProps({
|
|
743
876
|
"key": id,
|
|
744
877
|
"onClick": () => onNodeClick(item),
|
|
745
878
|
"disabled": disabled
|
|
746
879
|
}, checkState), null), createVNode(NodeContent, {
|
|
747
|
-
"node": item
|
|
748
|
-
|
|
880
|
+
"node": item,
|
|
881
|
+
"editStatusReflect": editStatusReflect.value
|
|
882
|
+
}, null), operateIconReflect.value.find(({
|
|
883
|
+
id: d
|
|
884
|
+
}) => id === d).renderIcon(item), item.isParent ? createVNode("div", {
|
|
749
885
|
"class": "devui-tree-node_loading",
|
|
750
886
|
"id": lazyNodesReflect.value[id].loadingTargetId
|
|
751
|
-
}, null)])])]);
|
|
887
|
+
}, null) : null])])]);
|
|
752
888
|
};
|
|
753
889
|
return () => {
|
|
754
890
|
return createVNode("div", {
|
package/tree/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var pe=Object.defineProperty,fe=Object.defineProperties;var me=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var x=(f,e,b)=>e in f?pe(f,e,{enumerable:!0,configurable:!0,writable:!0,value:b}):f[e]=b,S=(f,e)=>{for(var b in e||(e={}))ye.call(e,b)&&x(f,b,e[b]);if(_)for(var b of _(e))he.call(e,b)&&x(f,b,e[b]);return f},D=(f,e)=>fe(f,me(e));var w=(f,e,b)=>(x(f,typeof e!="symbol"?e+"":e,b),b);(function(f,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(f=typeof globalThis!="undefined"?globalThis:f||self,e(f.index={},f.Vue))})(this,function(f,e){"use strict";const b={data:{type:Array,required:!0,default:()=>[]},checkable:{type:Boolean,default:!1},checkableRelation:{type:String,default:"none"}},$={none:{},half:{halfchecked:!0},select:{checked:!0}},M=(t,l="children")=>t.reduce((n,a)=>a[l]?n.concat(a,M(a[l],l)):n.concat(a),[]),E=t=>{const l=parseInt((Math.random()*10**8).toString().padEnd(8,"0"));return D(S({},t),{id:t.id?`${t.id}_${l}`:`${t.label.replaceAll(" ","-")}_${l}`})},z=t=>t.map(l=>{const n=E(l);return l.children?D(S({},n),{children:z(l.children)}):n}),U=Symbol("dev_component_container");function K(t,l,n=null){const a=e.h(t,S({},l),n),o=document.createElement("div");return a[U]=o,e.render(a,o),a.component}class R{constructor(){w(this,"top","50%");w(this,"left","50%")}}const F={message:String,backdrop:Boolean,view:{type:Object,default:()=>new R},zIndex:Number,isFull:{type:Boolean,default:!1}};class G{constructor(){w(this,"target");w(this,"message");w(this,"loadingTemplateRef");w(this,"backdrop",!0);w(this,"positionType","relative");w(this,"view",new R);w(this,"zIndex")}}var ve="",J=e.defineComponent({name:"DLoading",inheritAttrs:!1,props:F,setup(t){const l={top:t.view.top,left:t.view.left,zIndex:t.zIndex};t.message||(l.background="none");const n=e.ref(!1);return{style:l,isShow:n,open:()=>{n.value=!0},close:()=>{n.value=!1}}},render(){var i;const{isShow:t,isFull:l,backdrop:n,style:a,message:o,$slots:d}=this;return t&&e.createVNode("div",{class:["devui-loading-contanier",l?"devui-loading--full":""]},[((i=d.default)==null?void 0:i.call(d))||e.createVNode("div",{class:"devui-loading-wrapper"},[n?e.createVNode("div",{class:"devui-loading-mask"},null):null,e.createVNode("div",{style:a,class:"devui-loading-area"},[e.createVNode("div",{class:"devui-busy-default-spinner"},[e.createVNode("div",{class:"devui-loading-bar1"},null),e.createVNode("div",{class:"devui-loading-bar2"},null),e.createVNode("div",{class:"devui-loading-bar3"},null),e.createVNode("div",{class:"devui-loading-bar4"},null)]),o?e.createVNode("span",{class:"devui-loading-text"},[o]):null])])])}});const Y=e.defineComponent(J),L=new WeakMap,Q={open(t={}){const l=t.target||document.body;if(L.has(l))return L.get(l);l.style.position=t.positionType;const n=document.body===l;t=S(S({},new G),t);const a=K(Y,D(S({},t),{isFull:n}),t.loadingTemplateRef?()=>t.loadingTemplateRef:null);L.set(l,a),a.proxy.open(),l.appendChild(a.proxy.$el);const o=a.proxy.close;return a.loadingInstance=a.proxy,a.loadingInstance.close=(...d)=>{L.delete(l),o(...d)},a}};var be="";const q=D(S({},{name:{type:String,default:void 0},isShowTitle:{type:Boolean,default:!0},color:{type:String,default:void 0},showAnimation:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},beforeChange:{type:Function,default:void 0}}),{halfchecked:{type:Boolean,default:!1},checked:{type:Boolean,default:!1},value:{type:String},label:{type:String,default:void 0},title:{type:String,default:void 0},"onUpdate:checked":{type:Function,default:void 0},onChange:{type:Function,default:void 0},modelValue:{type:Boolean},"onUpdate:modelValue":{type:Function}}),X=Symbol("d-checkbox-group");var ee=e.defineComponent({name:"DCheckbox",props:q,emits:["change","update:checked","update:modelValue"],setup(t,l){const n=e.inject(X,null),a=e.computed(()=>t.checked||t.modelValue),o=e.computed(()=>(n==null?void 0:n.disabled.value)||t.disabled),d=e.computed(()=>{var c,v;return(v=(c=n==null?void 0:n.isItemChecked)==null?void 0:c.call(n,t.value))!=null?v:a.value}),i=e.computed(()=>{var c;return(c=n==null?void 0:n.isShowTitle)!=null?c:t.isShowTitle}),N=e.computed(()=>{var c;return(c=n==null?void 0:n.showAnimation)!=null?c:t.showAnimation}),m=e.computed(()=>{var c;return(c=n==null?void 0:n.color)!=null?c:t.color}),u=n==null?void 0:n.itemWidth.value,r=n==null?void 0:n.direction.value,s=(c,v)=>{var C;if(o.value)return Promise.resolve(!1);const y=(C=t.beforeChange)!=null?C:n==null?void 0:n.beforeChange;if(y){const g=y(c,v);return typeof g=="boolean"?Promise.resolve(g):g}return Promise.resolve(!0)},I=()=>{const c=!a.value;n==null||n.toggleGroupVal(t.value),l.emit("update:checked",c),l.emit("update:modelValue",c),l.emit("change",c)};return{itemWidth:u,direction:r,mergedColor:m,mergedDisabled:o,mergedIsShowTitle:i,mergedChecked:d,mergedShowAnimation:N,handleClick:()=>{s(!a.value,t.value).then(c=>c&&I())}}},render(){var A;const{itemWidth:t,direction:l,mergedChecked:n,mergedDisabled:a,mergedIsShowTitle:o,mergedShowAnimation:d,halfchecked:i,title:N,label:m,handleClick:u,name:r,value:s,mergedColor:I,$slots:p}=this,c={"devui-checkbox-column-margin":l==="column","devui-checkbox-wrap":typeof t!="undefined"},v=t?[`width: ${t}px`]:[],y={"devui-checkbox":!0,active:n,halfchecked:i,disabled:a,unchecked:!n},C=o?N||m:"",g=I&&i||I?`linear-gradient(${I}, ${I})`:"",h=[`border-color:${(n||i)&&I?I:""}`,`background-image:${g}`,`background-color:${I&&i?I:""}`],k={"devui-checkbox-material":!0,"custom-color":I,"devui-checkbox-no-label":!m&&!p.default,"devui-no-animation":!d,"devui-checkbox-default-background":!i},P={"devui-tick":!0,"devui-no-animation":!d},V=O=>O.stopPropagation(),B={indeterminate:i};return e.createVNode("div",{class:c,style:v},[e.createVNode("div",{class:y},[e.createVNode("label",{title:C,onClick:u},[e.createVNode("input",e.mergeProps({name:r||s,class:"devui-checkbox-input",type:"checkbox"},B,{checked:n,disabled:a,onClick:V,onChange:V}),null),e.createVNode("span",{style:h,class:k},[e.createVNode("span",{class:"devui-checkbox-halfchecked-bg"},null),e.createVNode("svg",{viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg",class:"devui-checkbox-tick"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("polygon",{"fill-rule":"nonzero",points:"5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",class:P},null)])])]),m||((A=p.default)==null?void 0:A.call(p))])])])}});function te(t){const l=o=>o.reduce((d,i)=>i.open?d.concat(i,l(i.children)):d.concat(i),[]),n=e.ref(l(t));return{openedData:n,toggle:(o,d)=>{o.stopPropagation(),!!d.children&&(d.open=!d.open,n.value=l(t))}}}function ne(t){const l=(o,d="children",i="label")=>{const{[d]:N,[i]:m}=o;return Array.isArray(N)&&N.length===1&&N[0][d]&&N[0][d].length===1?l(Object.assign({},N[0],{[i]:`${m} \\ ${N[0][i]}`})):o},n=(o,d=0,i="children",N="label")=>o.map(m=>{const{[i]:u}=m;if(!Array.isArray(u)||!u.length)return Object.assign({},m,{level:d+1});let r=m;return u.length===1&&(r=l(m)),Object.assign({},r,{[i]:n(r[i],d+1,i,N),level:d+1})});return{mergeData:e.ref(n(t))}}const ae="active",Z="devui-tree_isDisabledNode",le=()=>{const t=e.ref({});return{nodeClassNameReflect:t,handleClickOnNode:a=>{t.value[a]!==Z&&(t.value=Object.fromEntries(Object.entries(t.value).map(([o])=>[o,o===a?ae:""])))},handleInitNodeClassNameReflect:(a=!1,...o)=>{const d=o.join("-");return t.value[d]=a?Z:t.value[d]||"",d}}};function oe(t,l,n){const a=e.ref({}),o=M(n),d=m=>{const u=n;let r={},s=[],I;const p=(c,v)=>{c.every(({children:y,id:C})=>I?!1:C===m?(r=v,s=Array.isArray(y)?M(y).map(({id:g})=>g):[],I=C,!1):(Array.isArray(y)&&p(y,{id:C,children:y.map(({id:g})=>g),parent:v}),!0))};return p(u,{}),{parentLevel:r,childLevel:s}},i=(m,u,r)=>{const s={},I=e.unref(a),p=(c,v=!1)=>{const{id:y,children:C,parent:g}=c;if(!!g)if(u){const h=C.filter(k=>!I[k]||I[k]==="none");h.length<=1?h[0]===r?s[y]="select":v&&(s[y]="half"):s[y]="half",p(g,s[y]==="select")}else{const h=C.filter(k=>I[k]&&I[k]!=="none");h.length<=1?(h[0]===r||v)&&(s[y]="none"):s[y]="half",p(g,s[y]==="none")}};return p(m),s};return{selected:a,onNodeClick:m=>{const{id:u}=m;let r=Object.assign({},e.unref(a));const s=r[u]==="none"||!r[u];if(t.value==="none")r=Object.assign(r,{[u]:s?"select":"none"});else if(t.value==="both"){const{parentLevel:p,childLevel:c}=d(u);r=Object.assign(r,Object.fromEntries(c.map(v=>[v,s?"select":"none"])),i(p,s,u),{[u]:s?"select":"none"})}else if(t.value==="upward"){const{parentLevel:p}=d(u);r=Object.assign(r,i(p,s,u),{[u]:s?"select":"none"})}else if(t.value==="downward"){const{childLevel:p}=d(u);r=Object.assign(r,Object.fromEntries(p.map(c=>[c,s?"select":"none"])),{[u]:s?"select":"none"})}a.value=r;const I=o.filter(({id:p})=>r[p]&&r[p]!=="none");l.emit("nodeSelected",I)}}}const de=()=>{const t=e.ref({});return{lazyNodesReflect:t,handleInitLazyNodeReflect:(a,o)=>{var i;if(!a.isParent)return;((i=t.value[o.id])==null?void 0:i.id.toString())||(t.value[o.id]=D(S({},o),{loadingTargetId:`devui-tree_loadingTemplate-${o.id}`,dataSource:null}))},getLazyData:async a=>{const o=t.value[a];if(o.dataSource)return o.dataSource;const d=t.value[a].renderLoading(t.value[a].loadingTargetId);try{t.value[a].dataSource=await o.onGetNodeData()}catch(i){console.error(i)}finally{d.loadingInstance.close()}return t.value[a].dataSource}}};var ie="data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIxNnB4IgogIGhlaWdodD0iMTZweCIKICB2aWV3Qm94PSIwIDAgMTYgMTYiCiAgdmVyc2lvbj0iMS4xIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIKICBjbGFzcz0ic3ZnLWljb24gc3ZnLWljb24tY2xvc2UiCj4KICA8ZyBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICA8cmVjdCB4PSIwLjUiIHk9IjAuNSIgd2lkdGg9IjE1IiBoZWlnaHQ9IjE1IiByeD0iMiIgc3Ryb2tlPSIjNWU3Y2UwIj48L3JlY3Q+CiAgICA8cmVjdCB4PSI0IiB5PSI3IiB3aWR0aD0iOCIgaGVpZ2h0PSIyIiBmaWxsPSIjNWU3Y2UwIj48L3JlY3Q+CiAgPC9nPgo8L3N2Zz4=",ce="data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIxNnB4IgogIGhlaWdodD0iMTZweCIKICB2aWV3Qm94PSIwIDAgMTYgMTYiCiAgdmVyc2lvbj0iMS4xIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIKICBjbGFzcz0ic3ZnLWljb24iCj4KICA8ZyBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgIDxyZWN0IHg9IjAuNSIgeT0iMC41IiB3aWR0aD0iMTUiIGhlaWdodD0iMTUiIHJ4PSIyIiBzdHJva2U9IiMyNTJiM2EiPjwvcmVjdD4KICAgIDxwYXRoCiAgICAgIGZpbGw9IiMyNTJiM2EiCiAgICAgIGQ9Ik04Ljc1LDQgTDguNzUsNy4yNSBMMTIsNy4yNSBMMTIsOC43NSBMOC43NDksOC43NSBMOC43NSwxMiBMNy4yNSwxMiBMNy4yNDksOC43NSBMNCw4Ljc1IEw0LDcuMjUgTDcuMjUsNy4yNSBMNy4yNSw0IEw4Ljc1LDQgWiIKICAgID48L3BhdGg+CiAgPC9nPgo8L3N2Zz4K",re=e.defineComponent({name:"DTreeNodeContent",props:{node:{type:Object,required:!0}},setup(t){const l=e.inject("treeRoot");return()=>{const n=t.node,{disabled:a,label:o}=n;return l.ctx.slots.default?l.ctx.slots.default({node:n}):e.createVNode("span",{class:["devui-tree-node__title",a&&"select-disabled"]},[o])}}}),Ce="",T=e.defineComponent({name:"DTree",props:b,emits:["nodeSelected"],setup(t,l){const{data:n,checkable:a,checkableRelation:o}=e.toRefs(D(S({},t),{data:z(t.data)})),{mergeData:d}=ne(n.value),{openedData:i,toggle:N}=te(d.value),{nodeClassNameReflect:m,handleInitNodeClassNameReflect:u,handleClickOnNode:r}=le(),{lazyNodesReflect:s,handleInitLazyNodeReflect:I,getLazyData:p}=de(),{selected:c,onNodeClick:v}=oe(o,l,n.value);e.provide("treeRoot",{ctx:l,props:t});const y=()=>e.createVNode("span",{style:"display: inline-block; width: 16px; height: 16px; margin-left: 8px;"},null),C=g=>{var H;const{id:h="",label:k,disabled:P,open:V,isParent:B,level:A,children:O}=g;u(P,h),I(g,{id:h,onGetNodeData:async()=>new Promise(j=>{setTimeout(()=>{j([{id:`It is a test Node-1 ID = ${h}`,label:`It is a test Node-1 ID = ${h}`,level:g.level+1},{id:`It is a test Node-2 ID = ${h}`,label:`It is a test Node-2 ID = ${h}`,level:g.level+1}])},4e3)}),renderLoading:j=>Q.open({target:document.getElementById(j),message:"\u52A0\u8F7D\u4E2D...",positionType:"relative",zIndex:1})});const ue=j=>{const W=async Ie=>(j.isParent&&(j.children=await p(h)),N(Ie,j));return B||O?V?e.createVNode(ie,{class:"mr-xs",onClick:W},null):e.createVNode(ce,{class:"mr-xs",onClick:W},null):e.createVNode(y,null,null)},ge=$[(H=c.value[h])!=null?H:"none"];return e.createVNode("div",{class:["devui-tree-node",V&&"devui-tree-node__open"],style:{paddingLeft:`${24*(A-1)}px`}},[e.createVNode("div",{class:`devui-tree-node__content ${m.value[h]}`,onClick:()=>r(h)},[e.createVNode("div",{class:"devui-tree-node__content--value-wrapper"},[ue(g),a.value&&e.createVNode(ee,e.mergeProps({key:h,onClick:()=>v(g),disabled:P},ge),null),e.createVNode(re,{node:g},null),g.isParent&&e.createVNode("div",{class:"devui-tree-node_loading",id:s.value[h].loadingTargetId},null)])])])};return()=>e.createVNode("div",{class:"devui-tree"},[i.value.map(g=>C(g))])}});T.install=function(t){t.component(T.name,T)};var se={title:"Tree \u6811",category:"\u6570\u636E\u5C55\u793A",status:"20%",install(t){t.use(T)}};f.Tree=T,f.default=se,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
|
|
1
|
+
var De=Object.defineProperty,je=Object.defineProperties;var Te=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable;var M=(y,e,N)=>e in y?De(y,e,{enumerable:!0,configurable:!0,writable:!0,value:N}):y[e]=N,k=(y,e)=>{for(var N in e||(e={}))Ve.call(e,N)&&M(y,N,e[N]);if(G)for(var N of G(e))Ae.call(e,N)&&M(y,N,e[N]);return y},V=(y,e)=>je(y,Te(e));var D=(y,e,N)=>(M(y,typeof e!="symbol"?e+"":e,N),N);(function(y,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(y=typeof globalThis!="undefined"?globalThis:y||self,e(y.index={},y.Vue))})(this,function(y,e){"use strict";const N={data:{type:Array,required:!0,default:()=>[]},checkable:{type:Boolean,default:!1},checkableRelation:{type:String,default:"none"}},J={none:{},half:{halfchecked:!0},select:{checked:!0}},R=(t,l="children")=>t.reduce((n,a)=>a[l]?n.concat(a,R(a[l],l)):n.concat(a),[]),O=()=>(Math.random()*10**9).toString().slice(0,8),Y=(t,l)=>{const n=O();return console.info("randomStr: ",n),V(k({},t),{id:l?`${l}_${n}`:n})},Q=t=>{const l=t.split("_");return[...l.slice(0,l.length),O()].join("_")},z=(t,l)=>t.map(n=>{const a=Y(n,l);return n.children?V(k({},a),{children:z(n.children,a.id)}):a}),x=(t,l,n=0)=>{const a=t.slice(0,n+2).join("_");return l.forEach(o=>{o.id===t.slice(0,n+1).join("_")&&(t.length===n+2?o.children=o.children.filter(({id:d})=>d!==a):o.children=x(t,o.children,n+1))}),l},q=(t,l)=>t.includes("_")?x(t.split("_"),l):l.filter(({id:n})=>n!==t),X=Symbol("dev_component_container");function ee(t,l,n=null){const a=e.h(t,k({},l),n),o=document.createElement("div");return a[X]=o,e.render(a,o),a.component}class Z{constructor(){D(this,"top","50%");D(this,"left","50%")}}const te={message:String,backdrop:Boolean,view:{type:Object,default:()=>new Z},zIndex:Number,isFull:{type:Boolean,default:!1}};class ne{constructor(){D(this,"target");D(this,"message");D(this,"loadingTemplateRef");D(this,"backdrop",!0);D(this,"positionType","relative");D(this,"view",new Z);D(this,"zIndex")}}var Le="",le=e.defineComponent({name:"DLoading",inheritAttrs:!1,props:te,setup(t){const l={top:t.view.top,left:t.view.left,zIndex:t.zIndex};t.message||(l.background="none");const n=e.ref(!1);return{style:l,isShow:n,open:()=>{n.value=!0},close:()=>{n.value=!1}}},render(){var c;const{isShow:t,isFull:l,backdrop:n,style:a,message:o,$slots:d}=this;return t&&e.createVNode("div",{class:["devui-loading-contanier",l?"devui-loading--full":""]},[((c=d.default)==null?void 0:c.call(d))||e.createVNode("div",{class:"devui-loading-wrapper"},[n?e.createVNode("div",{class:"devui-loading-mask"},null):null,e.createVNode("div",{style:a,class:"devui-loading-area"},[e.createVNode("div",{class:"devui-busy-default-spinner"},[e.createVNode("div",{class:"devui-loading-bar1"},null),e.createVNode("div",{class:"devui-loading-bar2"},null),e.createVNode("div",{class:"devui-loading-bar3"},null),e.createVNode("div",{class:"devui-loading-bar4"},null)]),o?e.createVNode("span",{class:"devui-loading-text"},[o]):null])])])}});const ae=e.defineComponent(le),B=new WeakMap,oe={open(t={}){const l=t.target||document.body;if(B.has(l))return B.get(l);l.style.position=t.positionType;const n=document.body===l;t=k(k({},new ne),t);const a=ee(ae,V(k({},t),{isFull:n}),t.loadingTemplateRef?()=>t.loadingTemplateRef:null);B.set(l,a),a.proxy.open(),l.appendChild(a.proxy.$el);const o=a.proxy.close;return a.loadingInstance=a.proxy,a.loadingInstance.close=(...d)=>{B.delete(l),o(...d)},a}};var Be="";const de=V(k({},{name:{type:String,default:void 0},halfchecked:{type:Boolean,default:!1},isShowTitle:{type:Boolean,default:!0},title:{type:String},color:{type:String,default:void 0},showAnimation:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},beforeChange:{type:Function,default:void 0}}),{halfchecked:{type:Boolean,default:!1},checked:{type:Boolean,default:!1},value:{type:String},label:{type:String,default:void 0},title:{type:String,default:void 0},"onUpdate:checked":{type:Function,default:void 0},onChange:{type:Function,default:void 0},modelValue:{type:Boolean},"onUpdate:modelValue":{type:Function}}),ce=Symbol("d-checkbox-group");var ie=e.defineComponent({name:"DCheckbox",props:de,emits:["change","update:checked","update:modelValue"],setup(t,l){const n=e.inject(ce,null),a=e.computed(()=>t.checked||t.modelValue),o=e.computed(()=>(n==null?void 0:n.disabled.value)||t.disabled),d=e.computed(()=>{var r,b;return(b=(r=n==null?void 0:n.isItemChecked)==null?void 0:r.call(n,t.value))!=null?b:a.value}),c=e.computed(()=>{var r;return(r=n==null?void 0:n.isShowTitle.value)!=null?r:t.isShowTitle}),g=e.computed(()=>{var r;return(r=n==null?void 0:n.showAnimation.value)!=null?r:t.showAnimation}),I=e.computed(()=>{var r;return(r=n==null?void 0:n.color.value)!=null?r:t.color}),s=n==null?void 0:n.itemWidth.value,i=n==null?void 0:n.direction.value,u=(r,b)=>{var S;if(o.value)return Promise.resolve(!1);const p=(S=t.beforeChange)!=null?S:n==null?void 0:n.beforeChange;if(p){const C=p(r,b);return typeof C=="boolean"?Promise.resolve(C):C}return Promise.resolve(!0)},f=()=>{const r=!a.value;n==null||n.toggleGroupVal(t.value),l.emit("update:checked",r),l.emit("update:modelValue",r),l.emit("change",r)};return{itemWidth:s,direction:i,mergedColor:I,mergedDisabled:o,mergedIsShowTitle:c,mergedChecked:d,mergedShowAnimation:g,handleClick:()=>{u(!a.value,t.label).then(r=>r&&f())}}},render(){var L;const{itemWidth:t,direction:l,mergedChecked:n,mergedDisabled:a,mergedIsShowTitle:o,mergedShowAnimation:d,halfchecked:c,title:g,label:I,handleClick:s,name:i,value:u,mergedColor:f,$slots:h}=this,r={"devui-checkbox-column-margin":l==="column","devui-checkbox-wrap":typeof t!="undefined"},b=t?[`width: ${t}px`]:[],p={"devui-checkbox":!0,active:n,halfchecked:c,disabled:a,unchecked:!n},S=o?g||I:"",C=f&&c||f?`linear-gradient(${f}, ${f})`:"",j=[`border-color:${(n||c)&&f?f:""}`,`background-image:${C}`,`background-color:${f&&c?f:""}`],T={"devui-checkbox-material":!0,"custom-color":f,"devui-checkbox-no-label":!I&&!h.default,"devui-no-animation":!d,"devui-checkbox-default-background":!c},v={"devui-tick":!0,"devui-no-animation":!d},m=P=>P.stopPropagation(),H={indeterminate:c};return e.createVNode("div",{class:r,style:b},[e.createVNode("div",{class:p},[e.createVNode("label",{title:S,onClick:s},[e.createVNode("input",e.mergeProps({name:i||u,class:"devui-checkbox-input",type:"checkbox"},H,{checked:n,disabled:a,onClick:m,onChange:m}),null),e.createVNode("span",{style:j,class:T},[e.createVNode("span",{class:"devui-checkbox-halfchecked-bg"},null),e.createVNode("svg",{viewBox:"0 0 16 16",version:"1.1",xmlns:"http://www.w3.org/2000/svg",class:"devui-checkbox-tick"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("polygon",{"fill-rule":"nonzero",points:"5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",class:v},null)])])]),I||((L=h.default)==null?void 0:L.call(h))])])])}});function re(t){const l=o=>o.reduce((d,c)=>c.open?d.concat(c,l(c.children)):d.concat(c),[]),n=e.ref(l(t.value));return e.watch(()=>t.value,o=>n.value=l(o),{deep:!0}),{openedData:n,toggle:(o,d)=>{o.stopPropagation(),!!d.children&&(d.open=!d.open,n.value=l(t.value))}}}function se(t){const l=(o,d="children",c="label")=>{const{[d]:g,[c]:I}=o;return Array.isArray(g)&&g.length===1&&g[0][d]&&g[0][d].length===1?l(Object.assign({},g[0],{[c]:`${I} \\ ${g[0][c]}`})):o},n=(o,d=0,c="children",g="label")=>o.map(I=>{const{[c]:s}=I;if(!Array.isArray(s)||!s.length)return Object.assign({},I,{level:d+1});let i=I;return s.length===1&&(i=l(I)),Object.assign({},i,{[c]:n(i[c],d+1,c,g),level:d+1})});return{mergeData:e.ref(n(t))}}const ue="active",_="devui-tree_isDisabledNode",ge=()=>{const t=e.ref({}),l=e.ref("");return{nodeClassNameReflect:t,handleClickOnNode:o=>{t.value[o]!==_&&l.value!==o&&(l.value&&(t.value[l.value]=""),t.value[o]=ue,l.value=o)},handleInitNodeClassNameReflect:(o=!1,...d)=>{const c=d.join("-");return t.value[c]=o?_:t.value[c]||"",c}}};function fe(t,l,n){const a=e.ref({}),o=R(n),d=I=>{const s=n;let i={},u=[],f;const h=(r,b)=>{r.every(({children:p,id:S})=>f?!1:S===I?(i=b,u=Array.isArray(p)?R(p).map(({id:C})=>C):[],f=S,!1):(Array.isArray(p)&&h(p,{id:S,children:p.map(({id:C})=>C),parent:b}),!0))};return h(s,{}),{parentLevel:i,childLevel:u}},c=(I,s,i)=>{const u={},f=e.unref(a),h=(r,b=!1)=>{const{id:p,children:S,parent:C}=r;if(!!C)if(s){const j=S.filter(T=>!f[T]||f[T]==="none");j.length<=1?j[0]===i?u[p]="select":b&&(u[p]="half"):u[p]="half",h(C,u[p]==="select")}else{const j=S.filter(T=>f[T]&&f[T]!=="none");j.length<=1?(j[0]===i||b)&&(u[p]="none"):u[p]="half",h(C,u[p]==="none")}};return h(I),u};return{selected:a,onNodeClick:I=>{const{id:s}=I;let i=Object.assign({},e.unref(a));const u=i[s]==="none"||!i[s];if(t.value==="none")i=Object.assign(i,{[s]:u?"select":"none"});else if(t.value==="both"){const{parentLevel:h,childLevel:r}=d(s);i=Object.assign(i,Object.fromEntries(r.map(b=>[b,u?"select":"none"])),c(h,u,s),{[s]:u?"select":"none"})}else if(t.value==="upward"){const{parentLevel:h}=d(s);i=Object.assign(i,c(h,u,s),{[s]:u?"select":"none"})}else if(t.value==="downward"){const{childLevel:h}=d(s);i=Object.assign(i,Object.fromEntries(h.map(r=>[r,u?"select":"none"])),{[s]:u?"select":"none"})}a.value=i;const f=o.filter(({id:h})=>i[h]&&i[h]!=="none");l.emit("nodeSelected",f)}}}const he=()=>{const t=e.ref({});return{lazyNodesReflect:t,handleInitLazyNodeReflect:(a,o)=>{var c;if(!a.isParent)return;((c=t.value[o.id])==null?void 0:c.id.toString())||(t.value[o.id]=V(k({},o),{loadingTargetId:`devui-tree_loadingTemplate-${o.id}`,dataSource:null}))},getLazyData:async a=>{const o=t.value[a];if(o.dataSource)return o.dataSource;const d=t.value[a].renderLoading(t.value[a].loadingTargetId);try{t.value[a].dataSource=await o.onGetNodeData()}catch(c){console.error(c)}finally{d.loadingInstance.close()}return t.value[a].dataSource}}},Ie=(t,l)=>{const n=d=>l.handleAdd(),a=d=>l.handleEdit(),o=d=>l.handleDelete();return e.createVNode(e.Fragment,null,[l.addable&&e.createVNode("span",{class:"op-icons icon icon-add",onClick:n},null),l.editable&&e.createVNode("span",{class:"op-icons icon icon-edit",onClick:a},null),l.deletable&&e.createVNode("span",{class:"op-icons icon icon-close",onClick:o},null)])},pe=t=>{const l=e.ref([]),n=e.ref({});return{operateIconReflect:l,editStatusReflect:n,handleReflectIdToIcon:(o,d)=>{l.value.every(({id:g})=>g!=o)&&(n.value[o]=!1,l.value.push({id:o,renderIcon:g=>Ie(g,d)}))}}};var ye="data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIxNnB4IgogIGhlaWdodD0iMTZweCIKICB2aWV3Qm94PSIwIDAgMTYgMTYiCiAgdmVyc2lvbj0iMS4xIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIKICBjbGFzcz0ic3ZnLWljb24gc3ZnLWljb24tY2xvc2UiCj4KICA8ZyBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICA8cmVjdCB4PSIwLjUiIHk9IjAuNSIgd2lkdGg9IjE1IiBoZWlnaHQ9IjE1IiByeD0iMiIgc3Ryb2tlPSIjNWU3Y2UwIj48L3JlY3Q+CiAgICA8cmVjdCB4PSI0IiB5PSI3IiB3aWR0aD0iOCIgaGVpZ2h0PSIyIiBmaWxsPSIjNWU3Y2UwIj48L3JlY3Q+CiAgPC9nPgo8L3N2Zz4=",ve="data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIxNnB4IgogIGhlaWdodD0iMTZweCIKICB2aWV3Qm94PSIwIDAgMTYgMTYiCiAgdmVyc2lvbj0iMS4xIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIKICBjbGFzcz0ic3ZnLWljb24iCj4KICA8ZyBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgIDxyZWN0IHg9IjAuNSIgeT0iMC41IiB3aWR0aD0iMTUiIGhlaWdodD0iMTUiIHJ4PSIyIiBzdHJva2U9IiMyNTJiM2EiPjwvcmVjdD4KICAgIDxwYXRoCiAgICAgIGZpbGw9IiMyNTJiM2EiCiAgICAgIGQ9Ik04Ljc1LDQgTDguNzUsNy4yNSBMMTIsNy4yNSBMMTIsOC43NSBMOC43NDksOC43NSBMOC43NSwxMiBMNy4yNSwxMiBMNy4yNDksOC43NSBMNCw4Ljc1IEw0LDcuMjUgTDcuMjUsNy4yNSBMNy4yNSw0IEw4Ljc1LDQgWiIKICAgID48L3BhdGg+CiAgPC9nPgo8L3N2Zz4K",me=e.defineComponent({name:"DTreeNodeContent",props:{node:{type:Object,required:!0},editStatusReflect:{type:Object,required:!0}},setup(t){const l=e.inject("treeRoot"),n=a=>`devui-tree-node__input-${a}`;return e.onUpdated(()=>{const a=document.querySelector(`#${n(t.node.id)}`);a==null||a.focus()}),()=>{const{node:a,editStatusReflect:o}=e.toRefs(t),{disabled:d,label:c,id:g}=a.value,I=({target:i})=>{a.value.label=i.value},s=()=>{o.value[g]=!1};return l.ctx.slots.default?l.ctx.slots.default({node:a}):e.createVNode("span",{class:["devui-tree-node__title",d&&"select-disabled"]},[o.value[g]?e.createVNode("input",{id:n(g),ref:e.ref,value:c,onChange:I,onBlur:s},null):c])}}}),Re="",A=e.defineComponent({name:"DTree",props:N,emits:["nodeSelected"],setup(t,l){const{data:n,checkable:a,checkableRelation:o}=e.toRefs(e.reactive(V(k({},t),{data:z(t.data)}))),{mergeData:d}=se(n.value),{openedData:c,toggle:g}=re(d),{nodeClassNameReflect:I,handleInitNodeClassNameReflect:s,handleClickOnNode:i}=ge(),{lazyNodesReflect:u,handleInitLazyNodeReflect:f,getLazyData:h}=he(),{selected:r,onNodeClick:b}=fe(o,l,n.value),{editStatusReflect:p,operateIconReflect:S,handleReflectIdToIcon:C}=pe();e.provide("treeRoot",{ctx:l,props:t});const j=()=>e.createVNode("span",{style:"display: inline-block; width: 16px; height: 16px; margin-left: 8px;"},null),T=v=>{var K;const{id:m="",label:H,disabled:L,open:P,isParent:Ne,level:Ce,children:W,addable:E,editable:U,deletable:$}=v;C(m,{addable:E,editable:U,deletable:$,handleAdd:()=>{const w={id:Q(v.id),label:"new item",level:v.level+1,addable:E,editable:U,deletable:$};v.open=!0,v.children&&Array.isArray(v.children)?v.children.push(w):v.children=[w]},handleEdit:()=>{p.value[m]=!p.value[m]},handleDelete:()=>{d.value=q(m,d.value)}}),s(L,m),f(v,{id:m,onGetNodeData:async()=>new Promise(w=>{setTimeout(()=>{w([{id:`It is a test Node-1 ID = ${m}`,label:`It is a test Node-1 ID = ${m}`,level:v.level+1},{id:`It is a test Node-2 ID = ${m}`,label:`It is a test Node-2 ID = ${m}`,level:v.level+1}])},4e3)}),renderLoading:w=>oe.open({target:document.getElementById(w),message:"\u52A0\u8F7D\u4E2D...",positionType:"relative",zIndex:1})});const Se=w=>{const F=async ke=>(w.isParent&&(w.children=await h(m)),g(ke,w));return Ne||W&&W.length?P?e.createVNode(ye,{class:"mr-xs",onClick:F},null):e.createVNode(ve,{class:"mr-xs",onClick:F},null):e.createVNode(j,null,null)},we=J[(K=r.value[m])!=null?K:"none"];return e.createVNode("div",{class:["devui-tree-node",P&&"devui-tree-node__open"],style:{paddingLeft:`${24*(Ce-1)}px`}},[e.createVNode("div",{class:`devui-tree-node__content ${I.value[m]}`,onClick:()=>i(m)},[e.createVNode("div",{class:"devui-tree-node__content--value-wrapper"},[Se(v),a.value&&e.createVNode(ie,e.mergeProps({key:m,onClick:()=>b(v),disabled:L},we),null),e.createVNode(me,{node:v,editStatusReflect:p.value},null),S.value.find(({id:w})=>m===w).renderIcon(v),v.isParent?e.createVNode("div",{class:"devui-tree-node_loading",id:u.value[m].loadingTargetId},null):null])])])};return()=>e.createVNode("div",{class:"devui-tree"},[c.value.map(v=>T(v))])}});A.install=function(t){t.component(A.name,A)};var be={title:"Tree \u6811",category:"\u6570\u636E\u5C55\u793A",status:"20%",install(t){t.use(A)}};y.Tree=A,y.default=be,Object.defineProperty(y,"__esModule",{value:!0}),y[Symbol.toStringTag]="Module"});
|