vue-devui 1.0.0-alpha.4 → 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 +237 -1
- 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 +175 -1
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/anchor/index.d.ts +7 -0
- package/anchor/index.es.js +263 -1
- package/anchor/index.umd.js +1 -1
- package/avatar/index.d.ts +7 -0
- package/avatar/index.es.js +301 -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 +95 -1
- package/badge/index.umd.js +1 -1
- package/breadcrumb/index.d.ts +7 -0
- package/breadcrumb/index.es.js +127 -1
- package/breadcrumb/index.umd.js +1 -1
- package/breadcrumb/style.css +1 -1
- package/button/index.d.ts +7 -0
- package/button/index.es.js +190 -1
- package/button/index.umd.js +1 -1
- package/card/index.d.ts +7 -0
- package/card/index.es.js +61 -1
- package/card/index.umd.js +1 -1
- package/carousel/index.d.ts +7 -0
- package/carousel/index.es.js +329 -1
- package/carousel/index.umd.js +1 -1
- package/cascader/index.d.ts +7 -0
- package/cascader/index.es.js +1343 -1
- 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 +377 -1
- 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 +1172 -1
- 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 +288 -0
- package/drawer/index.umd.js +1 -0
- package/drawer/package.json +7 -0
- package/drawer/style.css +1 -0
- 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 +5793 -1
- 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 +163 -1
- 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 +75 -1
- package/icon/index.umd.js +1 -1
- package/image-preview/index.d.ts +7 -0
- package/image-preview/index.es.js +480 -1
- 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 +190 -1
- 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 +240 -1
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.d.ts +7 -0
- package/layout/index.es.js +100 -0
- package/layout/index.umd.js +1 -0
- package/layout/package.json +7 -0
- package/layout/style.css +1 -0
- package/loading/index.d.ts +7 -0
- package/loading/index.es.js +256 -1
- package/loading/index.umd.js +1 -1
- package/modal/index.d.ts +7 -0
- package/modal/index.es.js +1027 -1
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.d.ts +7 -0
- package/nav-sprite/index.es.js +742 -0
- package/nav-sprite/index.umd.js +1 -0
- package/nav-sprite/package.json +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 +368 -1
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -33
- package/pagination/index.d.ts +7 -0
- package/pagination/index.es.js +642 -1
- package/pagination/index.umd.js +1 -1
- package/panel/index.d.ts +7 -0
- package/panel/index.es.js +205 -1
- 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 +236 -1
- package/popover/index.umd.js +1 -1
- package/popover/style.css +1 -1
- package/progress/index.d.ts +7 -0
- package/progress/index.es.js +153 -1
- package/progress/index.umd.js +3 -1
- package/quadrant-diagram/index.d.ts +7 -0
- package/quadrant-diagram/index.es.js +489 -1
- package/quadrant-diagram/index.umd.js +1 -1
- package/radio/index.d.ts +7 -0
- package/radio/index.es.js +225 -1
- package/radio/index.umd.js +1 -1
- package/rate/index.d.ts +7 -0
- package/rate/index.es.js +220 -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 +181 -1
- package/ripple/index.umd.js +1 -1
- package/search/index.d.ts +7 -0
- package/search/index.es.js +543 -1
- package/search/index.umd.js +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +706 -1
- package/select/index.umd.js +1 -1
- package/skeleton/index.d.ts +7 -0
- package/skeleton/index.es.js +297 -1
- 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 +199 -1
- 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 +636 -1
- 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 +42 -1
- package/status/index.umd.js +1 -1
- package/steps-guide/index.d.ts +7 -0
- package/steps-guide/index.es.js +239 -1
- package/steps-guide/index.umd.js +1 -1
- package/steps-guide/style.css +1 -1
- package/sticky/index.d.ts +7 -0
- package/sticky/index.es.js +197 -1
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/switch/index.d.ts +7 -0
- package/switch/index.es.js +100 -1
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +1626 -1
- 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 +195 -1
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +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 +329 -1
- 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 +299 -0
- package/time-axis/index.umd.js +1 -0
- package/time-axis/package.json +7 -0
- package/time-axis/style.css +1 -0
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +1053 -1
- 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 +2060 -1
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.es.js +171 -1
- package/tooltip/index.umd.js +1 -1
- package/transfer/index.d.ts +7 -0
- package/transfer/index.es.js +1725 -1
- 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 +907 -1
- package/tree/index.umd.js +1 -1
- package/tree/style.css +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 +3179 -1
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +27755 -1
- package/vue-devui.umd.js +29 -1
package/tree/index.es.js
CHANGED
|
@@ -1 +1,907 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
import { h, render, defineComponent, ref, createVNode, inject, computed, mergeProps, watch, unref, Fragment, onUpdated, toRefs, reactive, provide } from "vue";
|
|
25
|
+
const treeProps = {
|
|
26
|
+
data: {
|
|
27
|
+
type: Array,
|
|
28
|
+
required: true,
|
|
29
|
+
default: () => []
|
|
30
|
+
},
|
|
31
|
+
checkable: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
checkableRelation: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "none"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const CHECK_CONFIG = {
|
|
41
|
+
none: {},
|
|
42
|
+
half: {
|
|
43
|
+
halfchecked: true
|
|
44
|
+
},
|
|
45
|
+
select: {
|
|
46
|
+
checked: true
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const flatten = (tree2, key = "children") => {
|
|
50
|
+
return tree2.reduce((acc, item) => !item[key] ? acc.concat(item) : acc.concat(item, flatten(item[key], key)), []);
|
|
51
|
+
};
|
|
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 });
|
|
57
|
+
};
|
|
58
|
+
const getId = (id) => {
|
|
59
|
+
const ids = id.split("_");
|
|
60
|
+
return [...ids.slice(0, ids.length), getRandomId()].join("_");
|
|
61
|
+
};
|
|
62
|
+
const preCheckTree = (ds, postfixId) => {
|
|
63
|
+
return ds.map((d) => {
|
|
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
|
+
}
|
|
79
|
+
}
|
|
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);
|
|
88
|
+
};
|
|
89
|
+
const COMPONENT_CONTAINER_SYMBOL = Symbol("dev_component_container");
|
|
90
|
+
function createComponent(Component, props, children = null) {
|
|
91
|
+
const vnode = h(Component, __spreadValues({}, props), children);
|
|
92
|
+
const container = document.createElement("div");
|
|
93
|
+
vnode[COMPONENT_CONTAINER_SYMBOL] = container;
|
|
94
|
+
render(vnode, container);
|
|
95
|
+
return vnode.component;
|
|
96
|
+
}
|
|
97
|
+
class View {
|
|
98
|
+
constructor() {
|
|
99
|
+
__publicField(this, "top", "50%");
|
|
100
|
+
__publicField(this, "left", "50%");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const componentProps = {
|
|
104
|
+
message: String,
|
|
105
|
+
backdrop: Boolean,
|
|
106
|
+
view: {
|
|
107
|
+
type: Object,
|
|
108
|
+
default: () => new View()
|
|
109
|
+
},
|
|
110
|
+
zIndex: Number,
|
|
111
|
+
isFull: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: false
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
class LoadingProps {
|
|
117
|
+
constructor() {
|
|
118
|
+
__publicField(this, "target");
|
|
119
|
+
__publicField(this, "message");
|
|
120
|
+
__publicField(this, "loadingTemplateRef");
|
|
121
|
+
__publicField(this, "backdrop", true);
|
|
122
|
+
__publicField(this, "positionType", "relative");
|
|
123
|
+
__publicField(this, "view", new View());
|
|
124
|
+
__publicField(this, "zIndex");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
var loading$1 = "";
|
|
128
|
+
var Loading = defineComponent({
|
|
129
|
+
name: "DLoading",
|
|
130
|
+
inheritAttrs: false,
|
|
131
|
+
props: componentProps,
|
|
132
|
+
setup(props) {
|
|
133
|
+
const style = {
|
|
134
|
+
top: props.view.top,
|
|
135
|
+
left: props.view.left,
|
|
136
|
+
zIndex: props.zIndex
|
|
137
|
+
};
|
|
138
|
+
if (!props.message) {
|
|
139
|
+
style.background = "none";
|
|
140
|
+
}
|
|
141
|
+
const isShow = ref(false);
|
|
142
|
+
const open = () => {
|
|
143
|
+
isShow.value = true;
|
|
144
|
+
};
|
|
145
|
+
const close = () => {
|
|
146
|
+
isShow.value = false;
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
style,
|
|
150
|
+
isShow,
|
|
151
|
+
open,
|
|
152
|
+
close
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
render() {
|
|
156
|
+
var _a;
|
|
157
|
+
const {
|
|
158
|
+
isShow,
|
|
159
|
+
isFull,
|
|
160
|
+
backdrop,
|
|
161
|
+
style,
|
|
162
|
+
message,
|
|
163
|
+
$slots
|
|
164
|
+
} = this;
|
|
165
|
+
return isShow && createVNode("div", {
|
|
166
|
+
"class": ["devui-loading-contanier", isFull ? "devui-loading--full" : ""]
|
|
167
|
+
}, [((_a = $slots.default) == null ? void 0 : _a.call($slots)) || createVNode("div", {
|
|
168
|
+
"class": "devui-loading-wrapper"
|
|
169
|
+
}, [backdrop ? createVNode("div", {
|
|
170
|
+
"class": "devui-loading-mask"
|
|
171
|
+
}, null) : null, createVNode("div", {
|
|
172
|
+
"style": style,
|
|
173
|
+
"class": "devui-loading-area"
|
|
174
|
+
}, [createVNode("div", {
|
|
175
|
+
"class": "devui-busy-default-spinner"
|
|
176
|
+
}, [createVNode("div", {
|
|
177
|
+
"class": "devui-loading-bar1"
|
|
178
|
+
}, null), createVNode("div", {
|
|
179
|
+
"class": "devui-loading-bar2"
|
|
180
|
+
}, null), createVNode("div", {
|
|
181
|
+
"class": "devui-loading-bar3"
|
|
182
|
+
}, null), createVNode("div", {
|
|
183
|
+
"class": "devui-loading-bar4"
|
|
184
|
+
}, null)]), message ? createVNode("span", {
|
|
185
|
+
"class": "devui-loading-text"
|
|
186
|
+
}, [message]) : null])])]);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
const loadingConstructor = defineComponent(Loading);
|
|
190
|
+
const cacheTarget = new WeakMap();
|
|
191
|
+
const loading = {
|
|
192
|
+
open(options = {}) {
|
|
193
|
+
const parent = options.target || document.body;
|
|
194
|
+
if (cacheTarget.has(parent)) {
|
|
195
|
+
return cacheTarget.get(parent);
|
|
196
|
+
}
|
|
197
|
+
parent.style.position = options.positionType;
|
|
198
|
+
const isFull = document.body === parent;
|
|
199
|
+
options = __spreadValues(__spreadValues({}, new LoadingProps()), options);
|
|
200
|
+
const instance = createComponent(loadingConstructor, __spreadProps(__spreadValues({}, options), {
|
|
201
|
+
isFull
|
|
202
|
+
}), options.loadingTemplateRef ? () => options.loadingTemplateRef : null);
|
|
203
|
+
cacheTarget.set(parent, instance);
|
|
204
|
+
instance.proxy.open();
|
|
205
|
+
parent.appendChild(instance.proxy.$el);
|
|
206
|
+
const close = instance.proxy.close;
|
|
207
|
+
instance.loadingInstance = instance.proxy;
|
|
208
|
+
instance.loadingInstance.close = (...args) => {
|
|
209
|
+
cacheTarget.delete(parent);
|
|
210
|
+
close(...args);
|
|
211
|
+
};
|
|
212
|
+
return instance;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
var checkbox = "";
|
|
216
|
+
const commonProps = {
|
|
217
|
+
name: {
|
|
218
|
+
type: String,
|
|
219
|
+
default: void 0
|
|
220
|
+
},
|
|
221
|
+
halfchecked: {
|
|
222
|
+
type: Boolean,
|
|
223
|
+
default: false
|
|
224
|
+
},
|
|
225
|
+
isShowTitle: {
|
|
226
|
+
type: Boolean,
|
|
227
|
+
default: true
|
|
228
|
+
},
|
|
229
|
+
title: {
|
|
230
|
+
type: String
|
|
231
|
+
},
|
|
232
|
+
color: {
|
|
233
|
+
type: String,
|
|
234
|
+
default: void 0
|
|
235
|
+
},
|
|
236
|
+
showAnimation: {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
default: true
|
|
239
|
+
},
|
|
240
|
+
disabled: {
|
|
241
|
+
type: Boolean,
|
|
242
|
+
default: false
|
|
243
|
+
},
|
|
244
|
+
beforeChange: {
|
|
245
|
+
type: Function,
|
|
246
|
+
default: void 0
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const checkboxProps = __spreadProps(__spreadValues({}, commonProps), {
|
|
250
|
+
halfchecked: {
|
|
251
|
+
type: Boolean,
|
|
252
|
+
default: false
|
|
253
|
+
},
|
|
254
|
+
checked: {
|
|
255
|
+
type: Boolean,
|
|
256
|
+
default: false
|
|
257
|
+
},
|
|
258
|
+
value: {
|
|
259
|
+
type: String
|
|
260
|
+
},
|
|
261
|
+
label: {
|
|
262
|
+
type: String,
|
|
263
|
+
default: void 0
|
|
264
|
+
},
|
|
265
|
+
title: {
|
|
266
|
+
type: String,
|
|
267
|
+
default: void 0
|
|
268
|
+
},
|
|
269
|
+
"onUpdate:checked": {
|
|
270
|
+
type: Function,
|
|
271
|
+
default: void 0
|
|
272
|
+
},
|
|
273
|
+
onChange: {
|
|
274
|
+
type: Function,
|
|
275
|
+
default: void 0
|
|
276
|
+
},
|
|
277
|
+
modelValue: {
|
|
278
|
+
type: Boolean
|
|
279
|
+
},
|
|
280
|
+
"onUpdate:modelValue": {
|
|
281
|
+
type: Function
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
const checkboxGroupInjectionKey = Symbol("d-checkbox-group");
|
|
285
|
+
var Checkbox = defineComponent({
|
|
286
|
+
name: "DCheckbox",
|
|
287
|
+
props: checkboxProps,
|
|
288
|
+
emits: ["change", "update:checked", "update:modelValue"],
|
|
289
|
+
setup(props, ctx) {
|
|
290
|
+
const checkboxGroupConf = inject(checkboxGroupInjectionKey, null);
|
|
291
|
+
const isChecked = computed(() => props.checked || props.modelValue);
|
|
292
|
+
const mergedDisabled = computed(() => {
|
|
293
|
+
return (checkboxGroupConf == null ? void 0 : checkboxGroupConf.disabled.value) || props.disabled;
|
|
294
|
+
});
|
|
295
|
+
const mergedChecked = computed(() => {
|
|
296
|
+
var _a, _b;
|
|
297
|
+
return (_b = (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isItemChecked) == null ? void 0 : _a.call(checkboxGroupConf, props.value)) != null ? _b : isChecked.value;
|
|
298
|
+
});
|
|
299
|
+
const mergedIsShowTitle = computed(() => {
|
|
300
|
+
var _a;
|
|
301
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.isShowTitle.value) != null ? _a : props.isShowTitle;
|
|
302
|
+
});
|
|
303
|
+
const mergedShowAnimation = computed(() => {
|
|
304
|
+
var _a;
|
|
305
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.showAnimation.value) != null ? _a : props.showAnimation;
|
|
306
|
+
});
|
|
307
|
+
const mergedColor = computed(() => {
|
|
308
|
+
var _a;
|
|
309
|
+
return (_a = checkboxGroupConf == null ? void 0 : checkboxGroupConf.color.value) != null ? _a : props.color;
|
|
310
|
+
});
|
|
311
|
+
const itemWidth = checkboxGroupConf == null ? void 0 : checkboxGroupConf.itemWidth.value;
|
|
312
|
+
const direction = checkboxGroupConf == null ? void 0 : checkboxGroupConf.direction.value;
|
|
313
|
+
const canChange = (isChecked2, val) => {
|
|
314
|
+
var _a;
|
|
315
|
+
if (mergedDisabled.value) {
|
|
316
|
+
return Promise.resolve(false);
|
|
317
|
+
}
|
|
318
|
+
const beforeChange = (_a = props.beforeChange) != null ? _a : checkboxGroupConf == null ? void 0 : checkboxGroupConf.beforeChange;
|
|
319
|
+
if (beforeChange) {
|
|
320
|
+
const res = beforeChange(isChecked2, val);
|
|
321
|
+
if (typeof res === "boolean") {
|
|
322
|
+
return Promise.resolve(res);
|
|
323
|
+
}
|
|
324
|
+
return res;
|
|
325
|
+
}
|
|
326
|
+
return Promise.resolve(true);
|
|
327
|
+
};
|
|
328
|
+
const toggle = () => {
|
|
329
|
+
const current = !isChecked.value;
|
|
330
|
+
checkboxGroupConf == null ? void 0 : checkboxGroupConf.toggleGroupVal(props.value);
|
|
331
|
+
ctx.emit("update:checked", current);
|
|
332
|
+
ctx.emit("update:modelValue", current);
|
|
333
|
+
ctx.emit("change", current);
|
|
334
|
+
};
|
|
335
|
+
const handleClick = () => {
|
|
336
|
+
canChange(!isChecked.value, props.label).then((res) => res && toggle());
|
|
337
|
+
};
|
|
338
|
+
return {
|
|
339
|
+
itemWidth,
|
|
340
|
+
direction,
|
|
341
|
+
mergedColor,
|
|
342
|
+
mergedDisabled,
|
|
343
|
+
mergedIsShowTitle,
|
|
344
|
+
mergedChecked,
|
|
345
|
+
mergedShowAnimation,
|
|
346
|
+
handleClick
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
render() {
|
|
350
|
+
var _a;
|
|
351
|
+
const {
|
|
352
|
+
itemWidth,
|
|
353
|
+
direction,
|
|
354
|
+
mergedChecked,
|
|
355
|
+
mergedDisabled,
|
|
356
|
+
mergedIsShowTitle,
|
|
357
|
+
mergedShowAnimation,
|
|
358
|
+
halfchecked,
|
|
359
|
+
title,
|
|
360
|
+
label,
|
|
361
|
+
handleClick,
|
|
362
|
+
name,
|
|
363
|
+
value,
|
|
364
|
+
mergedColor,
|
|
365
|
+
$slots
|
|
366
|
+
} = this;
|
|
367
|
+
const wrapperCls = {
|
|
368
|
+
"devui-checkbox-column-margin": direction === "column",
|
|
369
|
+
"devui-checkbox-wrap": typeof itemWidth !== "undefined"
|
|
370
|
+
};
|
|
371
|
+
const wrapperStyle = itemWidth ? [`width: ${itemWidth}px`] : [];
|
|
372
|
+
const checkboxCls = {
|
|
373
|
+
"devui-checkbox": true,
|
|
374
|
+
active: mergedChecked,
|
|
375
|
+
halfchecked,
|
|
376
|
+
disabled: mergedDisabled,
|
|
377
|
+
unchecked: !mergedChecked
|
|
378
|
+
};
|
|
379
|
+
const labelTitle = mergedIsShowTitle ? title || label : "";
|
|
380
|
+
const bgImgStyle = mergedColor && halfchecked || mergedColor ? `linear-gradient(${mergedColor}, ${mergedColor})` : "";
|
|
381
|
+
const spanStyle = [`border-color:${(mergedChecked || halfchecked) && mergedColor ? mergedColor : ""}`, `background-image:${bgImgStyle}`, `background-color:${mergedColor && halfchecked ? mergedColor : ""}`];
|
|
382
|
+
const spanCls = {
|
|
383
|
+
"devui-checkbox-material": true,
|
|
384
|
+
"custom-color": mergedColor,
|
|
385
|
+
"devui-checkbox-no-label": !label && !$slots.default,
|
|
386
|
+
"devui-no-animation": !mergedShowAnimation,
|
|
387
|
+
"devui-checkbox-default-background": !halfchecked
|
|
388
|
+
};
|
|
389
|
+
const polygonCls = {
|
|
390
|
+
"devui-tick": true,
|
|
391
|
+
"devui-no-animation": !mergedShowAnimation
|
|
392
|
+
};
|
|
393
|
+
const stopPropagation = ($event) => $event.stopPropagation();
|
|
394
|
+
const inputProps = {
|
|
395
|
+
indeterminate: halfchecked
|
|
396
|
+
};
|
|
397
|
+
return createVNode("div", {
|
|
398
|
+
"class": wrapperCls,
|
|
399
|
+
"style": wrapperStyle
|
|
400
|
+
}, [createVNode("div", {
|
|
401
|
+
"class": checkboxCls
|
|
402
|
+
}, [createVNode("label", {
|
|
403
|
+
"title": labelTitle,
|
|
404
|
+
"onClick": handleClick
|
|
405
|
+
}, [createVNode("input", mergeProps({
|
|
406
|
+
"name": name || value,
|
|
407
|
+
"class": "devui-checkbox-input",
|
|
408
|
+
"type": "checkbox"
|
|
409
|
+
}, inputProps, {
|
|
410
|
+
"checked": mergedChecked,
|
|
411
|
+
"disabled": mergedDisabled,
|
|
412
|
+
"onClick": stopPropagation,
|
|
413
|
+
"onChange": stopPropagation
|
|
414
|
+
}), null), createVNode("span", {
|
|
415
|
+
"style": spanStyle,
|
|
416
|
+
"class": spanCls
|
|
417
|
+
}, [createVNode("span", {
|
|
418
|
+
"class": "devui-checkbox-halfchecked-bg"
|
|
419
|
+
}, null), createVNode("svg", {
|
|
420
|
+
"viewBox": "0 0 16 16",
|
|
421
|
+
"version": "1.1",
|
|
422
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
423
|
+
"class": "devui-checkbox-tick"
|
|
424
|
+
}, [createVNode("g", {
|
|
425
|
+
"stroke": "none",
|
|
426
|
+
"stroke-width": "1",
|
|
427
|
+
"fill": "none",
|
|
428
|
+
"fill-rule": "evenodd"
|
|
429
|
+
}, [createVNode("polygon", {
|
|
430
|
+
"fill-rule": "nonzero",
|
|
431
|
+
"points": "5.17391304 6.56521739 7.7173913 9.10869565 11.826087 5 13 6.17391304 7.7173913 11.4565217 4 7.73913043",
|
|
432
|
+
"class": polygonCls
|
|
433
|
+
}, null)])])]), label || ((_a = $slots.default) == null ? void 0 : _a.call($slots))])])]);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
function useToggle(data) {
|
|
437
|
+
const openedTree = (tree2) => {
|
|
438
|
+
return tree2.reduce((acc, item) => item.open ? acc.concat(item, openedTree(item.children)) : acc.concat(item), []);
|
|
439
|
+
};
|
|
440
|
+
const openedData = ref(openedTree(data.value));
|
|
441
|
+
watch(() => data.value, (d) => openedData.value = openedTree(d), { deep: true });
|
|
442
|
+
const toggle = (target, item) => {
|
|
443
|
+
target.stopPropagation();
|
|
444
|
+
if (!item.children)
|
|
445
|
+
return;
|
|
446
|
+
item.open = !item.open;
|
|
447
|
+
openedData.value = openedTree(data.value);
|
|
448
|
+
};
|
|
449
|
+
return {
|
|
450
|
+
openedData,
|
|
451
|
+
toggle
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function useMergeNode(data) {
|
|
455
|
+
const mergeObject = (treeItem, childName = "children", labelName = "label") => {
|
|
456
|
+
const { [childName]: children, [labelName]: label } = treeItem;
|
|
457
|
+
if (Array.isArray(children) && children.length === 1 && children[0][childName] && children[0][childName].length === 1) {
|
|
458
|
+
return mergeObject(Object.assign({}, children[0], {
|
|
459
|
+
[labelName]: `${label} \\ ${children[0][labelName]}`
|
|
460
|
+
}));
|
|
461
|
+
}
|
|
462
|
+
return treeItem;
|
|
463
|
+
};
|
|
464
|
+
const mergeNode = (tree2, level = 0, childName = "children", labelName = "label") => {
|
|
465
|
+
return tree2.map((item) => {
|
|
466
|
+
const { [childName]: children } = item;
|
|
467
|
+
if (!Array.isArray(children) || !children.length) {
|
|
468
|
+
return Object.assign({}, item, { level: level + 1 });
|
|
469
|
+
}
|
|
470
|
+
let currentObject = item;
|
|
471
|
+
if (children.length === 1) {
|
|
472
|
+
currentObject = mergeObject(item);
|
|
473
|
+
}
|
|
474
|
+
return Object.assign({}, currentObject, {
|
|
475
|
+
[childName]: mergeNode(currentObject[childName], level + 1, childName, labelName),
|
|
476
|
+
level: level + 1
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
const mergeData = ref(mergeNode(data));
|
|
481
|
+
return {
|
|
482
|
+
mergeData
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
const HIGHLIGHT_CLASS = "active";
|
|
486
|
+
const IS_DISABLED_FLAG = "devui-tree_isDisabledNode";
|
|
487
|
+
const useHighlightNode = () => {
|
|
488
|
+
const nodeClassNameReflectRef = ref({});
|
|
489
|
+
const prevActiveNodeKey = ref("");
|
|
490
|
+
const handleInit = (isDisabled = false, ...keys) => {
|
|
491
|
+
const key = keys.join("-");
|
|
492
|
+
nodeClassNameReflectRef.value[key] = isDisabled ? IS_DISABLED_FLAG : nodeClassNameReflectRef.value[key] || "";
|
|
493
|
+
return key;
|
|
494
|
+
};
|
|
495
|
+
const handleClick = (key) => {
|
|
496
|
+
if (nodeClassNameReflectRef.value[key] === IS_DISABLED_FLAG)
|
|
497
|
+
return;
|
|
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;
|
|
504
|
+
};
|
|
505
|
+
return {
|
|
506
|
+
nodeClassNameReflect: nodeClassNameReflectRef,
|
|
507
|
+
handleClickOnNode: handleClick,
|
|
508
|
+
handleInitNodeClassNameReflect: handleInit
|
|
509
|
+
};
|
|
510
|
+
};
|
|
511
|
+
function useChecked(cbr, ctx, data) {
|
|
512
|
+
const selected = ref({});
|
|
513
|
+
const flatData = flatten(data);
|
|
514
|
+
const findPedigreeById = (id) => {
|
|
515
|
+
const treeData = data;
|
|
516
|
+
let parentLevel = {};
|
|
517
|
+
let childLevel = [];
|
|
518
|
+
let target = void 0;
|
|
519
|
+
const ergodic = (curr, parentNode) => {
|
|
520
|
+
curr.every(({ children, id: itemId }) => {
|
|
521
|
+
if (target) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
if (itemId === id) {
|
|
525
|
+
parentLevel = parentNode;
|
|
526
|
+
childLevel = Array.isArray(children) ? flatten(children).map(({ id: key }) => key) : [];
|
|
527
|
+
target = itemId;
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
if (Array.isArray(children)) {
|
|
531
|
+
ergodic(children, {
|
|
532
|
+
id: itemId,
|
|
533
|
+
children: children.map(({ id: key }) => key),
|
|
534
|
+
parent: parentNode
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
return true;
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
ergodic(treeData, {});
|
|
541
|
+
return {
|
|
542
|
+
parentLevel,
|
|
543
|
+
childLevel
|
|
544
|
+
};
|
|
545
|
+
};
|
|
546
|
+
const generateParentObject = (parentLevel, isSelected, checkId) => {
|
|
547
|
+
const state = {};
|
|
548
|
+
const currentSelected = unref(selected);
|
|
549
|
+
const ergodic = (currObj, isOverflow = false) => {
|
|
550
|
+
const { id, children, parent } = currObj;
|
|
551
|
+
if (!parent) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (isSelected) {
|
|
555
|
+
const optional = children.filter((item) => !currentSelected[item] || currentSelected[item] === "none");
|
|
556
|
+
if (optional.length <= 1) {
|
|
557
|
+
if (optional[0] === checkId) {
|
|
558
|
+
state[id] = "select";
|
|
559
|
+
} else if (isOverflow) {
|
|
560
|
+
state[id] = "half";
|
|
561
|
+
}
|
|
562
|
+
} else {
|
|
563
|
+
state[id] = "half";
|
|
564
|
+
}
|
|
565
|
+
ergodic(parent, state[id] === "select");
|
|
566
|
+
} else {
|
|
567
|
+
const optional = children.filter((item) => currentSelected[item] && currentSelected[item] !== "none");
|
|
568
|
+
if (optional.length <= 1) {
|
|
569
|
+
if (optional[0] === checkId || isOverflow) {
|
|
570
|
+
state[id] = "none";
|
|
571
|
+
}
|
|
572
|
+
} else {
|
|
573
|
+
state[id] = "half";
|
|
574
|
+
}
|
|
575
|
+
ergodic(parent, state[id] === "none");
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
ergodic(parentLevel);
|
|
579
|
+
return state;
|
|
580
|
+
};
|
|
581
|
+
const onNodeClick = (item) => {
|
|
582
|
+
const { id } = item;
|
|
583
|
+
let currentSelected = Object.assign({}, unref(selected));
|
|
584
|
+
const isSelected = currentSelected[id] === "none" || !currentSelected[id];
|
|
585
|
+
if (cbr.value === "none") {
|
|
586
|
+
currentSelected = Object.assign(currentSelected, {
|
|
587
|
+
[id]: isSelected ? "select" : "none"
|
|
588
|
+
});
|
|
589
|
+
} else if (cbr.value === "both") {
|
|
590
|
+
const { parentLevel, childLevel } = findPedigreeById(id);
|
|
591
|
+
currentSelected = Object.assign(currentSelected, Object.fromEntries(childLevel.map((key) => [key, isSelected ? "select" : "none"])), generateParentObject(parentLevel, isSelected, id), { [id]: isSelected ? "select" : "none" });
|
|
592
|
+
} else if (cbr.value === "upward") {
|
|
593
|
+
const { parentLevel } = findPedigreeById(id);
|
|
594
|
+
currentSelected = Object.assign(currentSelected, generateParentObject(parentLevel, isSelected, id), { [id]: isSelected ? "select" : "none" });
|
|
595
|
+
} else if (cbr.value === "downward") {
|
|
596
|
+
const { childLevel } = findPedigreeById(id);
|
|
597
|
+
currentSelected = Object.assign(currentSelected, Object.fromEntries(childLevel.map((key) => [key, isSelected ? "select" : "none"])), { [id]: isSelected ? "select" : "none" });
|
|
598
|
+
}
|
|
599
|
+
selected.value = currentSelected;
|
|
600
|
+
const currentSelectedItem = flatData.filter(({ id: id2 }) => currentSelected[id2] && currentSelected[id2] !== "none");
|
|
601
|
+
ctx.emit("nodeSelected", currentSelectedItem);
|
|
602
|
+
};
|
|
603
|
+
return {
|
|
604
|
+
selected,
|
|
605
|
+
onNodeClick
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
const useLazy = () => {
|
|
609
|
+
const reflect = ref({});
|
|
610
|
+
const handleInit = (item, value) => {
|
|
611
|
+
var _a;
|
|
612
|
+
if (!item.isParent) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
const key = (_a = reflect.value[value.id]) == null ? void 0 : _a.id.toString();
|
|
616
|
+
if (!key) {
|
|
617
|
+
reflect.value[value.id] = __spreadProps(__spreadValues({}, value), {
|
|
618
|
+
loadingTargetId: `devui-tree_loadingTemplate-${value.id}`,
|
|
619
|
+
dataSource: null
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
const getLazyData = async (key) => {
|
|
624
|
+
const ds = reflect.value[key];
|
|
625
|
+
if (ds.dataSource) {
|
|
626
|
+
return ds.dataSource;
|
|
627
|
+
}
|
|
628
|
+
const handleLoading = reflect.value[key].renderLoading(reflect.value[key].loadingTargetId);
|
|
629
|
+
try {
|
|
630
|
+
reflect.value[key].dataSource = await ds.onGetNodeData();
|
|
631
|
+
} catch (e) {
|
|
632
|
+
console.error(e);
|
|
633
|
+
} finally {
|
|
634
|
+
handleLoading.loadingInstance.close();
|
|
635
|
+
}
|
|
636
|
+
return reflect.value[key].dataSource;
|
|
637
|
+
};
|
|
638
|
+
return {
|
|
639
|
+
lazyNodesReflect: reflect,
|
|
640
|
+
handleInitLazyNodeReflect: handleInit,
|
|
641
|
+
getLazyData
|
|
642
|
+
};
|
|
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
|
+
};
|
|
680
|
+
var IconOpen = "data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIxNnB4IgogIGhlaWdodD0iMTZweCIKICB2aWV3Qm94PSIwIDAgMTYgMTYiCiAgdmVyc2lvbj0iMS4xIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIKICBjbGFzcz0ic3ZnLWljb24gc3ZnLWljb24tY2xvc2UiCj4KICA8ZyBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICA8cmVjdCB4PSIwLjUiIHk9IjAuNSIgd2lkdGg9IjE1IiBoZWlnaHQ9IjE1IiByeD0iMiIgc3Ryb2tlPSIjNWU3Y2UwIj48L3JlY3Q+CiAgICA8cmVjdCB4PSI0IiB5PSI3IiB3aWR0aD0iOCIgaGVpZ2h0PSIyIiBmaWxsPSIjNWU3Y2UwIj48L3JlY3Q+CiAgPC9nPgo8L3N2Zz4=";
|
|
681
|
+
var IconClose = "data:image/svg+xml;base64,PHN2ZwogIHdpZHRoPSIxNnB4IgogIGhlaWdodD0iMTZweCIKICB2aWV3Qm94PSIwIDAgMTYgMTYiCiAgdmVyc2lvbj0iMS4xIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIKICBjbGFzcz0ic3ZnLWljb24iCj4KICA8ZyBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgIDxyZWN0IHg9IjAuNSIgeT0iMC41IiB3aWR0aD0iMTUiIGhlaWdodD0iMTUiIHJ4PSIyIiBzdHJva2U9IiMyNTJiM2EiPjwvcmVjdD4KICAgIDxwYXRoCiAgICAgIGZpbGw9IiMyNTJiM2EiCiAgICAgIGQ9Ik04Ljc1LDQgTDguNzUsNy4yNSBMMTIsNy4yNSBMMTIsOC43NSBMOC43NDksOC43NSBMOC43NSwxMiBMNy4yNSwxMiBMNy4yNDksOC43NSBMNCw4Ljc1IEw0LDcuMjUgTDcuMjUsNy4yNSBMNy4yNSw0IEw4Ljc1LDQgWiIKICAgID48L3BhdGg+CiAgPC9nPgo8L3N2Zz4K";
|
|
682
|
+
var NodeContent = defineComponent({
|
|
683
|
+
name: "DTreeNodeContent",
|
|
684
|
+
props: {
|
|
685
|
+
node: {
|
|
686
|
+
type: Object,
|
|
687
|
+
required: true
|
|
688
|
+
},
|
|
689
|
+
editStatusReflect: {
|
|
690
|
+
type: Object,
|
|
691
|
+
required: true
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
setup(props) {
|
|
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
|
+
});
|
|
701
|
+
return () => {
|
|
702
|
+
const {
|
|
703
|
+
node,
|
|
704
|
+
editStatusReflect
|
|
705
|
+
} = toRefs(props);
|
|
706
|
+
const {
|
|
707
|
+
disabled,
|
|
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
|
+
};
|
|
719
|
+
return tree2.ctx.slots.default ? tree2.ctx.slots.default({
|
|
720
|
+
node
|
|
721
|
+
}) : createVNode("span", {
|
|
722
|
+
"class": ["devui-tree-node__title", disabled && "select-disabled"]
|
|
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]);
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
var tree = "";
|
|
734
|
+
var Tree = defineComponent({
|
|
735
|
+
name: "DTree",
|
|
736
|
+
props: treeProps,
|
|
737
|
+
emits: ["nodeSelected"],
|
|
738
|
+
setup(props, ctx) {
|
|
739
|
+
const {
|
|
740
|
+
data,
|
|
741
|
+
checkable,
|
|
742
|
+
checkableRelation: cbr
|
|
743
|
+
} = toRefs(reactive(__spreadProps(__spreadValues({}, props), {
|
|
744
|
+
data: preCheckTree(props.data)
|
|
745
|
+
})));
|
|
746
|
+
const {
|
|
747
|
+
mergeData
|
|
748
|
+
} = useMergeNode(data.value);
|
|
749
|
+
const {
|
|
750
|
+
openedData,
|
|
751
|
+
toggle
|
|
752
|
+
} = useToggle(mergeData);
|
|
753
|
+
const {
|
|
754
|
+
nodeClassNameReflect,
|
|
755
|
+
handleInitNodeClassNameReflect,
|
|
756
|
+
handleClickOnNode
|
|
757
|
+
} = useHighlightNode();
|
|
758
|
+
const {
|
|
759
|
+
lazyNodesReflect,
|
|
760
|
+
handleInitLazyNodeReflect,
|
|
761
|
+
getLazyData
|
|
762
|
+
} = useLazy();
|
|
763
|
+
const {
|
|
764
|
+
selected,
|
|
765
|
+
onNodeClick
|
|
766
|
+
} = useChecked(cbr, ctx, data.value);
|
|
767
|
+
const {
|
|
768
|
+
editStatusReflect,
|
|
769
|
+
operateIconReflect,
|
|
770
|
+
handleReflectIdToIcon
|
|
771
|
+
} = useOperate();
|
|
772
|
+
provide("treeRoot", {
|
|
773
|
+
ctx,
|
|
774
|
+
props
|
|
775
|
+
});
|
|
776
|
+
const Indent = () => {
|
|
777
|
+
return createVNode("span", {
|
|
778
|
+
"style": "display: inline-block; width: 16px; height: 16px; margin-left: 8px;"
|
|
779
|
+
}, null);
|
|
780
|
+
};
|
|
781
|
+
const renderNode = (item) => {
|
|
782
|
+
var _a;
|
|
783
|
+
const {
|
|
784
|
+
id = "",
|
|
785
|
+
label,
|
|
786
|
+
disabled,
|
|
787
|
+
open,
|
|
788
|
+
isParent,
|
|
789
|
+
level,
|
|
790
|
+
children,
|
|
791
|
+
addable,
|
|
792
|
+
editable,
|
|
793
|
+
deletable
|
|
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
|
+
});
|
|
822
|
+
handleInitNodeClassNameReflect(disabled, id);
|
|
823
|
+
handleInitLazyNodeReflect(item, {
|
|
824
|
+
id,
|
|
825
|
+
onGetNodeData: async () => {
|
|
826
|
+
return new Promise((resolve) => {
|
|
827
|
+
setTimeout(() => {
|
|
828
|
+
resolve([{
|
|
829
|
+
id: `It is a test Node-1 ID = ${id}`,
|
|
830
|
+
label: `It is a test Node-1 ID = ${id}`,
|
|
831
|
+
level: item.level + 1
|
|
832
|
+
}, {
|
|
833
|
+
id: `It is a test Node-2 ID = ${id}`,
|
|
834
|
+
label: `It is a test Node-2 ID = ${id}`,
|
|
835
|
+
level: item.level + 1
|
|
836
|
+
}]);
|
|
837
|
+
}, 4e3);
|
|
838
|
+
});
|
|
839
|
+
},
|
|
840
|
+
renderLoading: (id2) => {
|
|
841
|
+
return loading.open({
|
|
842
|
+
target: document.getElementById(id2),
|
|
843
|
+
message: "\u52A0\u8F7D\u4E2D...",
|
|
844
|
+
positionType: "relative",
|
|
845
|
+
zIndex: 1
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
const renderFoldIcon = (item2) => {
|
|
850
|
+
const handleClick = async (target) => {
|
|
851
|
+
if (item2.isParent) {
|
|
852
|
+
item2.children = await getLazyData(id);
|
|
853
|
+
}
|
|
854
|
+
return toggle(target, item2);
|
|
855
|
+
};
|
|
856
|
+
return isParent || children && children.length ? open ? createVNode(IconOpen, {
|
|
857
|
+
"class": "mr-xs",
|
|
858
|
+
"onClick": handleClick
|
|
859
|
+
}, null) : createVNode(IconClose, {
|
|
860
|
+
"class": "mr-xs",
|
|
861
|
+
"onClick": handleClick
|
|
862
|
+
}, null) : createVNode(Indent, null, null);
|
|
863
|
+
};
|
|
864
|
+
const checkState = CHECK_CONFIG[(_a = selected.value[id]) != null ? _a : "none"];
|
|
865
|
+
return createVNode("div", {
|
|
866
|
+
"class": ["devui-tree-node", open && "devui-tree-node__open"],
|
|
867
|
+
"style": {
|
|
868
|
+
paddingLeft: `${24 * (level - 1)}px`
|
|
869
|
+
}
|
|
870
|
+
}, [createVNode("div", {
|
|
871
|
+
"class": `devui-tree-node__content ${nodeClassNameReflect.value[id]}`,
|
|
872
|
+
"onClick": () => handleClickOnNode(id)
|
|
873
|
+
}, [createVNode("div", {
|
|
874
|
+
"class": "devui-tree-node__content--value-wrapper"
|
|
875
|
+
}, [renderFoldIcon(item), checkable.value && createVNode(Checkbox, mergeProps({
|
|
876
|
+
"key": id,
|
|
877
|
+
"onClick": () => onNodeClick(item),
|
|
878
|
+
"disabled": disabled
|
|
879
|
+
}, checkState), null), createVNode(NodeContent, {
|
|
880
|
+
"node": item,
|
|
881
|
+
"editStatusReflect": editStatusReflect.value
|
|
882
|
+
}, null), operateIconReflect.value.find(({
|
|
883
|
+
id: d
|
|
884
|
+
}) => id === d).renderIcon(item), item.isParent ? createVNode("div", {
|
|
885
|
+
"class": "devui-tree-node_loading",
|
|
886
|
+
"id": lazyNodesReflect.value[id].loadingTargetId
|
|
887
|
+
}, null) : null])])]);
|
|
888
|
+
};
|
|
889
|
+
return () => {
|
|
890
|
+
return createVNode("div", {
|
|
891
|
+
"class": "devui-tree"
|
|
892
|
+
}, [openedData.value.map((item) => renderNode(item))]);
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
Tree.install = function(app) {
|
|
897
|
+
app.component(Tree.name, Tree);
|
|
898
|
+
};
|
|
899
|
+
var index = {
|
|
900
|
+
title: "Tree \u6811",
|
|
901
|
+
category: "\u6570\u636E\u5C55\u793A",
|
|
902
|
+
status: "20%",
|
|
903
|
+
install(app) {
|
|
904
|
+
app.use(Tree);
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
export { Tree, index as default };
|