vue-devui 1.0.0-rc.5 → 1.0.0-rc.6
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/README.md +17 -8
- package/auto-complete/index.es.js +11 -1
- package/auto-complete/index.umd.js +3 -3
- package/button/index.es.js +1 -1
- package/button/index.umd.js +1 -1
- package/date-picker/index.es.js +13 -19
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dropdown/index.es.js +3 -1
- package/dropdown/index.umd.js +1 -1
- package/form/index.es.js +800 -807
- package/form/index.umd.js +16 -16
- package/form/style.css +1 -1
- package/input/index.es.js +13 -19
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +27 -5
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/treeProps.js +3 -0
- package/package.json +1 -1
- package/popover/style.css +1 -1
- package/search/index.es.js +13 -19
- package/search/index.umd.js +12 -12
- package/search/style.css +1 -1
- package/slider/index.es.js +18 -6
- package/slider/index.umd.js +1 -1
- package/style.css +1 -1
- package/table/index.es.js +794 -509
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tooltip/index.es.js +1 -1
- package/tooltip/index.umd.js +1 -1
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +1021 -0
- package/tree/index.umd.js +1 -0
- package/tree/package.json +7 -0
- package/tree/style.css +1 -0
- package/vue-devui.es.js +1575 -669
- package/vue-devui.umd.js +16 -16
package/vue-devui.es.js
CHANGED
|
@@ -33,7 +33,7 @@ var __publicField = (obj, key, value) => {
|
|
|
33
33
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
34
|
return value;
|
|
35
35
|
};
|
|
36
|
-
import { createVNode, defineComponent, ref, onMounted, Transition, withDirectives, vShow, nextTick, h, render, inject, createTextVNode, resolveDirective, unref, watch, onUnmounted, mergeProps, toRefs, provide, Teleport, isVNode, computed, toRef, resolveComponent, reactive, createApp, renderSlot, Fragment, withModifiers, onBeforeUnmount, useSlots, onUpdated, getCurrentInstance,
|
|
36
|
+
import { createVNode, defineComponent, ref, onMounted, Transition, withDirectives, vShow, nextTick, h, render, inject, createTextVNode, resolveDirective, unref, watch, onUnmounted, mergeProps, toRefs, provide, Teleport, isVNode, computed, toRef, resolveComponent, reactive, createApp, renderSlot, Fragment, withModifiers, onBeforeUnmount, useSlots, onUpdated, getCurrentInstance, onBeforeMount } from "vue";
|
|
37
37
|
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
38
38
|
import { onClickOutside } from "@vueuse/core";
|
|
39
39
|
const AlertCloseIcon = () => createVNode("svg", {
|
|
@@ -392,6 +392,7 @@ function useInputHandle(ctx2, searchList, showNoResultItemTemplate, modelValue,
|
|
|
392
392
|
const visible = ref(false);
|
|
393
393
|
const inputRef = ref();
|
|
394
394
|
const searchStatus = ref(false);
|
|
395
|
+
const isFocus = ref(false);
|
|
395
396
|
const debounce = (cb, time) => {
|
|
396
397
|
let timer;
|
|
397
398
|
return (arg) => {
|
|
@@ -418,10 +419,14 @@ function useInputHandle(ctx2, searchList, showNoResultItemTemplate, modelValue,
|
|
|
418
419
|
onInputDebounce(inp.value);
|
|
419
420
|
};
|
|
420
421
|
const onFocus = () => {
|
|
422
|
+
isFocus.value = true;
|
|
421
423
|
handleSearch(modelValue.value);
|
|
422
424
|
recentlyFocus(latestSource == null ? void 0 : latestSource.value);
|
|
423
425
|
transInputFocusEmit.value && transInputFocusEmit.value();
|
|
424
426
|
};
|
|
427
|
+
const onBlur = () => {
|
|
428
|
+
isFocus.value = false;
|
|
429
|
+
};
|
|
425
430
|
const handleClose = () => {
|
|
426
431
|
visible.value = false;
|
|
427
432
|
searchStatus.value = false;
|
|
@@ -444,6 +449,8 @@ function useInputHandle(ctx2, searchList, showNoResultItemTemplate, modelValue,
|
|
|
444
449
|
toggleMenu,
|
|
445
450
|
onInput,
|
|
446
451
|
onFocus,
|
|
452
|
+
onBlur,
|
|
453
|
+
isFocus,
|
|
447
454
|
inputRef,
|
|
448
455
|
visible,
|
|
449
456
|
searchStatus
|
|
@@ -1068,7 +1075,7 @@ const FlexibleOverlay = defineComponent({
|
|
|
1068
1075
|
}
|
|
1069
1076
|
});
|
|
1070
1077
|
var autoComplete = "";
|
|
1071
|
-
function _isSlot$
|
|
1078
|
+
function _isSlot$5(s) {
|
|
1072
1079
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
1073
1080
|
}
|
|
1074
1081
|
var AutoComplete = defineComponent({
|
|
@@ -1105,7 +1112,9 @@ var AutoComplete = defineComponent({
|
|
|
1105
1112
|
const {
|
|
1106
1113
|
onInput,
|
|
1107
1114
|
onFocus,
|
|
1115
|
+
onBlur,
|
|
1108
1116
|
inputRef,
|
|
1117
|
+
isFocus,
|
|
1109
1118
|
visible,
|
|
1110
1119
|
searchStatus,
|
|
1111
1120
|
handleClose,
|
|
@@ -1168,7 +1177,7 @@ var AutoComplete = defineComponent({
|
|
|
1168
1177
|
${width.value + "px"}
|
|
1169
1178
|
`
|
|
1170
1179
|
}
|
|
1171
|
-
}, [createVNode(DAutoCompleteDropdown, null, _isSlot$
|
|
1180
|
+
}, [createVNode(DAutoCompleteDropdown, null, _isSlot$5(_slot = customRenderSolts()) ? _slot : {
|
|
1172
1181
|
default: () => [_slot]
|
|
1173
1182
|
})])]
|
|
1174
1183
|
})]
|
|
@@ -1193,7 +1202,7 @@ var AutoComplete = defineComponent({
|
|
|
1193
1202
|
${width.value + "px"}
|
|
1194
1203
|
`
|
|
1195
1204
|
}
|
|
1196
|
-
}, [createVNode(DAutoCompleteDropdown, null, _isSlot$
|
|
1205
|
+
}, [createVNode(DAutoCompleteDropdown, null, _isSlot$5(_slot2 = customRenderSolts()) ? _slot2 : {
|
|
1197
1206
|
default: () => [_slot2]
|
|
1198
1207
|
})])]
|
|
1199
1208
|
})]
|
|
@@ -1211,10 +1220,11 @@ var AutoComplete = defineComponent({
|
|
|
1211
1220
|
"disabled": disabled.value,
|
|
1212
1221
|
"type": "text",
|
|
1213
1222
|
"onClick": toggleMenu,
|
|
1214
|
-
"class": ["devui-form-control", "devui-dropdown-origin", "devui-dropdown-origin-open", disabled.value && "disabled"],
|
|
1223
|
+
"class": ["devui-form-control", "devui-dropdown-origin", isFocus.value && "devui-dropdown-origin-open", disabled.value && "disabled"],
|
|
1215
1224
|
"placeholder": "Search",
|
|
1216
1225
|
"onInput": onInput,
|
|
1217
1226
|
"onFocus": onFocus,
|
|
1227
|
+
"onBlur": onBlur,
|
|
1218
1228
|
"value": modelValue.value,
|
|
1219
1229
|
"ref": inputRef,
|
|
1220
1230
|
"onKeydown": handlekeyDown
|
|
@@ -1753,7 +1763,7 @@ var Button = defineComponent({
|
|
|
1753
1763
|
"onClick": onClick
|
|
1754
1764
|
}, [icon.value && createVNode(DIcon, {
|
|
1755
1765
|
"name": icon.value,
|
|
1756
|
-
"size": "12px",
|
|
1766
|
+
"size": "var(--devui-font-size, 12px)",
|
|
1757
1767
|
"color": "",
|
|
1758
1768
|
"class": iconClass.value
|
|
1759
1769
|
}, null), createVNode("span", {
|
|
@@ -2689,86 +2699,25 @@ const inputProps = {
|
|
|
2689
2699
|
default: void 0
|
|
2690
2700
|
}
|
|
2691
2701
|
};
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
formData: {
|
|
2695
|
-
type: Object,
|
|
2696
|
-
default: {}
|
|
2697
|
-
},
|
|
2698
|
-
layout: {
|
|
2699
|
-
type: String,
|
|
2700
|
-
default: "horizontal"
|
|
2701
|
-
},
|
|
2702
|
-
labelSize: {
|
|
2703
|
-
type: String,
|
|
2704
|
-
default: ""
|
|
2705
|
-
},
|
|
2706
|
-
labelAlign: {
|
|
2707
|
-
type: String,
|
|
2708
|
-
default: "start"
|
|
2709
|
-
},
|
|
2710
|
-
rules: {
|
|
2711
|
-
type: Object,
|
|
2712
|
-
default: {}
|
|
2713
|
-
},
|
|
2714
|
-
columnsClass: {
|
|
2715
|
-
type: String,
|
|
2716
|
-
default: ""
|
|
2717
|
-
},
|
|
2718
|
-
name: {
|
|
2702
|
+
const formItemProps = {
|
|
2703
|
+
field: {
|
|
2719
2704
|
type: String,
|
|
2720
2705
|
default: ""
|
|
2721
2706
|
},
|
|
2722
|
-
messageShowType: {
|
|
2723
|
-
type: String,
|
|
2724
|
-
default: "popover"
|
|
2725
|
-
}
|
|
2726
|
-
};
|
|
2727
|
-
const formItemProps = {
|
|
2728
2707
|
dHasFeedback: {
|
|
2729
2708
|
type: Boolean,
|
|
2730
2709
|
default: false
|
|
2731
2710
|
},
|
|
2732
|
-
prop: {
|
|
2733
|
-
type: String,
|
|
2734
|
-
default: ""
|
|
2735
|
-
}
|
|
2736
|
-
};
|
|
2737
|
-
const formLabelProps = {
|
|
2738
2711
|
required: {
|
|
2739
2712
|
type: Boolean,
|
|
2740
2713
|
default: false
|
|
2741
2714
|
},
|
|
2742
|
-
|
|
2743
|
-
type:
|
|
2744
|
-
default: false
|
|
2745
|
-
},
|
|
2746
|
-
helpTips: {
|
|
2747
|
-
type: String,
|
|
2748
|
-
default: ""
|
|
2749
|
-
}
|
|
2750
|
-
};
|
|
2751
|
-
const formControlProps = {
|
|
2752
|
-
feedbackStatus: {
|
|
2753
|
-
type: String,
|
|
2754
|
-
default: ""
|
|
2755
|
-
},
|
|
2756
|
-
extraInfo: {
|
|
2757
|
-
type: String,
|
|
2758
|
-
default: ""
|
|
2715
|
+
rules: {
|
|
2716
|
+
type: [Object, Array]
|
|
2759
2717
|
}
|
|
2760
2718
|
};
|
|
2761
|
-
const
|
|
2762
|
-
|
|
2763
|
-
removeField: "d.form.removeField"
|
|
2764
|
-
};
|
|
2765
|
-
const formInjectionKey = Symbol("dForm");
|
|
2766
|
-
const formItemInjectionKey = Symbol("dFormItem");
|
|
2767
|
-
const dFormItemEvents = {
|
|
2768
|
-
blur: "d.form.blur",
|
|
2769
|
-
change: "d.form.change",
|
|
2770
|
-
input: "d.form.input"
|
|
2771
|
-
};
|
|
2719
|
+
const FORM_ITEM_TOKEN = Symbol("dFormItem");
|
|
2720
|
+
var input = "";
|
|
2772
2721
|
var DInput = defineComponent({
|
|
2773
2722
|
name: "DInput",
|
|
2774
2723
|
directives: {
|
|
@@ -2783,19 +2732,17 @@ var DInput = defineComponent({
|
|
|
2783
2732
|
props: inputProps,
|
|
2784
2733
|
emits: ["update:modelValue", "focus", "blur", "change", "keydown"],
|
|
2785
2734
|
setup(props, ctx2) {
|
|
2786
|
-
const
|
|
2787
|
-
const hasFormItem = Object.keys(formItem2).length > 0;
|
|
2735
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
2788
2736
|
const sizeCls = computed(() => `devui-input-${props.size}`);
|
|
2789
2737
|
const showPwdIcon = ref(false);
|
|
2790
2738
|
const inputType = ref("text");
|
|
2791
|
-
const
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
});
|
|
2739
|
+
const isValidateError = computed(() => (formItemContext == null ? void 0 : formItemContext.validateState) === "error");
|
|
2740
|
+
const inputCls = computed(() => ({
|
|
2741
|
+
"devui-error": props.error || isValidateError.value,
|
|
2742
|
+
[props.cssClass]: true,
|
|
2743
|
+
"devui-input-restore": showPwdIcon.value,
|
|
2744
|
+
[sizeCls.value]: props.size !== ""
|
|
2745
|
+
}));
|
|
2799
2746
|
const showPreviewIcon = computed(() => inputType.value === "password");
|
|
2800
2747
|
watch(() => props.showPassword, (flg) => {
|
|
2801
2748
|
inputType.value = flg ? "password" : "text";
|
|
@@ -2803,17 +2750,18 @@ var DInput = defineComponent({
|
|
|
2803
2750
|
}, {
|
|
2804
2751
|
immediate: true
|
|
2805
2752
|
});
|
|
2753
|
+
watch(() => props.modelValue, () => {
|
|
2754
|
+
formItemContext == null ? void 0 : formItemContext.validate("change").catch((err) => console.warn(err));
|
|
2755
|
+
});
|
|
2806
2756
|
const onInput = ($event) => {
|
|
2807
2757
|
ctx2.emit("update:modelValue", $event.target.value);
|
|
2808
|
-
hasFormItem && formItem2.formItemMitt.emit(dFormItemEvents.input);
|
|
2809
2758
|
}, onFocus = () => {
|
|
2810
2759
|
ctx2.emit("focus");
|
|
2811
2760
|
}, onBlur = () => {
|
|
2812
2761
|
ctx2.emit("blur");
|
|
2813
|
-
|
|
2762
|
+
formItemContext == null ? void 0 : formItemContext.validate("blur").catch((err) => console.warn(err));
|
|
2814
2763
|
}, onChange = ($event) => {
|
|
2815
2764
|
ctx2.emit("change", $event.target.value);
|
|
2816
|
-
hasFormItem && formItem2.formItemMitt.emit(dFormItemEvents.change);
|
|
2817
2765
|
}, onKeydown = ($event) => {
|
|
2818
2766
|
ctx2.emit("keydown", $event);
|
|
2819
2767
|
}, onChangeInputType = () => {
|
|
@@ -3772,7 +3720,7 @@ var Drawer = defineComponent({
|
|
|
3772
3720
|
});
|
|
3773
3721
|
}
|
|
3774
3722
|
});
|
|
3775
|
-
function _isSlot$
|
|
3723
|
+
function _isSlot$4(s) {
|
|
3776
3724
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
3777
3725
|
}
|
|
3778
3726
|
const defaultOptions$1 = {
|
|
@@ -3799,7 +3747,7 @@ function initInstance$1(state) {
|
|
|
3799
3747
|
});
|
|
3800
3748
|
return () => createVNode(Drawer, mergeProps(state, {
|
|
3801
3749
|
"onUpdate:modelValue": handleVisibleChange
|
|
3802
|
-
}), _isSlot$
|
|
3750
|
+
}), _isSlot$4(content2) ? content2 : {
|
|
3803
3751
|
default: () => [content2]
|
|
3804
3752
|
});
|
|
3805
3753
|
}
|
|
@@ -3920,7 +3868,7 @@ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
|
|
|
3920
3868
|
setTimeout(() => {
|
|
3921
3869
|
subscriptions.push(subscribeEvent(document, "click", (e) => {
|
|
3922
3870
|
const dropdownValues = [...dropdownMap.values()];
|
|
3923
|
-
if (!isOpen.value || closeScope.value === "none" || dropdownEl.contains(e.target) && closeScope.value === "blank" || dropdownValues.some((item) => {
|
|
3871
|
+
if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
|
|
3924
3872
|
var _a;
|
|
3925
3873
|
return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
|
|
3926
3874
|
}) && dropdownValues.some((item) => {
|
|
@@ -4036,7 +3984,7 @@ function useOverlayProps(props, currentPosition, isOpen) {
|
|
|
4036
3984
|
return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
|
|
4037
3985
|
}
|
|
4038
3986
|
var baseOverlay = "";
|
|
4039
|
-
function _isSlot$
|
|
3987
|
+
function _isSlot$3(s) {
|
|
4040
3988
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
4041
3989
|
}
|
|
4042
3990
|
const CommonOverlay = defineComponent({
|
|
@@ -4048,7 +3996,7 @@ const CommonOverlay = defineComponent({
|
|
|
4048
3996
|
}, {
|
|
4049
3997
|
default: () => [createVNode(Transition, {
|
|
4050
3998
|
"name": "devui-overlay-fade"
|
|
4051
|
-
}, _isSlot$
|
|
3999
|
+
}, _isSlot$3(_slot = renderSlot(ctx2.slots, "default")) ? _slot : {
|
|
4052
4000
|
default: () => [_slot]
|
|
4053
4001
|
})]
|
|
4054
4002
|
});
|
|
@@ -4201,6 +4149,7 @@ var Dropdown = defineComponent({
|
|
|
4201
4149
|
align,
|
|
4202
4150
|
offset: offset2,
|
|
4203
4151
|
destroyOnHide,
|
|
4152
|
+
shiftOffset,
|
|
4204
4153
|
showAnimation
|
|
4205
4154
|
} = toRefs(props);
|
|
4206
4155
|
const origin = ref();
|
|
@@ -4254,6 +4203,7 @@ var Dropdown = defineComponent({
|
|
|
4254
4203
|
"position": position.value,
|
|
4255
4204
|
"align": align.value,
|
|
4256
4205
|
"offset": offset2.value,
|
|
4206
|
+
"shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
|
|
4257
4207
|
"onPositionChange": handlePositionChange,
|
|
4258
4208
|
"class": classes.value,
|
|
4259
4209
|
"style": styles.value
|
|
@@ -4715,6 +4665,36 @@ function mitt(n) {
|
|
|
4715
4665
|
});
|
|
4716
4666
|
} };
|
|
4717
4667
|
}
|
|
4668
|
+
const formProps = {
|
|
4669
|
+
data: {
|
|
4670
|
+
type: Object,
|
|
4671
|
+
default: () => ({})
|
|
4672
|
+
},
|
|
4673
|
+
layout: {
|
|
4674
|
+
type: String,
|
|
4675
|
+
default: "horizontal"
|
|
4676
|
+
},
|
|
4677
|
+
labelSize: {
|
|
4678
|
+
type: String,
|
|
4679
|
+
default: "md"
|
|
4680
|
+
},
|
|
4681
|
+
labelAlign: {
|
|
4682
|
+
type: String,
|
|
4683
|
+
default: "start"
|
|
4684
|
+
},
|
|
4685
|
+
rules: {
|
|
4686
|
+
type: Object
|
|
4687
|
+
},
|
|
4688
|
+
messageShowType: {
|
|
4689
|
+
type: String,
|
|
4690
|
+
default: "popover"
|
|
4691
|
+
}
|
|
4692
|
+
};
|
|
4693
|
+
const dFormEvents = {
|
|
4694
|
+
addField: "d.form.addField",
|
|
4695
|
+
removeField: "d.form.removeField"
|
|
4696
|
+
};
|
|
4697
|
+
const FORM_TOKEN = Symbol("dForm");
|
|
4718
4698
|
var eventBus = mitt();
|
|
4719
4699
|
const EventBus = eventBus;
|
|
4720
4700
|
function isObject(obj) {
|
|
@@ -4726,123 +4706,39 @@ function hasKey(obj, key) {
|
|
|
4726
4706
|
}
|
|
4727
4707
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
4728
4708
|
}
|
|
4729
|
-
function
|
|
4730
|
-
let
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
totalLeft += curEl.offsetLeft;
|
|
4734
|
-
totalTop += curEl.offsetTop;
|
|
4735
|
-
while (par) {
|
|
4736
|
-
if (navigator.userAgent.indexOf("MSIE 8.0") === -1) {
|
|
4737
|
-
totalTop += par.clientTop;
|
|
4738
|
-
totalLeft += par.clientLeft;
|
|
4739
|
-
}
|
|
4740
|
-
totalTop += par.offsetTop;
|
|
4741
|
-
totalLeft += par.offsetLeft;
|
|
4742
|
-
par = par.offsetParent;
|
|
4743
|
-
}
|
|
4744
|
-
return { left: totalLeft, top: totalTop };
|
|
4745
|
-
}
|
|
4746
|
-
var form = "";
|
|
4747
|
-
var Form = defineComponent({
|
|
4748
|
-
name: "DForm",
|
|
4749
|
-
props: formProps,
|
|
4750
|
-
emits: ["submit"],
|
|
4751
|
-
setup(props, ctx2) {
|
|
4752
|
-
const formMitt = mitt();
|
|
4753
|
-
const fields = [];
|
|
4754
|
-
const resetFormFields = () => {
|
|
4755
|
-
fields.forEach((field) => {
|
|
4756
|
-
field.resetField();
|
|
4757
|
-
});
|
|
4758
|
-
};
|
|
4759
|
-
formMitt.on(dFormEvents.addField, (field) => {
|
|
4760
|
-
if (field) {
|
|
4761
|
-
fields.push(field);
|
|
4762
|
-
}
|
|
4763
|
-
});
|
|
4764
|
-
formMitt.on(dFormEvents.removeField, (field) => {
|
|
4765
|
-
if (field.prop) {
|
|
4766
|
-
fields.splice(fields.indexOf(field), 1);
|
|
4767
|
-
}
|
|
4768
|
-
});
|
|
4769
|
-
provide(formInjectionKey, {
|
|
4770
|
-
formData: props.formData,
|
|
4771
|
-
formMitt,
|
|
4772
|
-
labelData: {
|
|
4773
|
-
layout: props.layout,
|
|
4774
|
-
labelSize: props.labelSize,
|
|
4775
|
-
labelAlign: props.labelAlign
|
|
4776
|
-
},
|
|
4777
|
-
rules: props.rules,
|
|
4778
|
-
columnsClass: props.columnsClass,
|
|
4779
|
-
messageShowType: "popover"
|
|
4780
|
-
});
|
|
4781
|
-
const onSubmit = (e) => {
|
|
4782
|
-
e.preventDefault();
|
|
4783
|
-
ctx2.emit("submit", e);
|
|
4784
|
-
EventBus.emit(`formSubmit:${props.name}`);
|
|
4785
|
-
};
|
|
4786
|
-
return {
|
|
4787
|
-
fields,
|
|
4788
|
-
formMitt,
|
|
4789
|
-
onSubmit,
|
|
4790
|
-
resetFormFields
|
|
4791
|
-
};
|
|
4792
|
-
},
|
|
4793
|
-
render() {
|
|
4794
|
-
var _a, _b;
|
|
4795
|
-
const {
|
|
4796
|
-
onSubmit
|
|
4797
|
-
} = this;
|
|
4798
|
-
return createVNode("form", {
|
|
4799
|
-
"onSubmit": onSubmit,
|
|
4800
|
-
"class": "devui-form"
|
|
4801
|
-
}, [(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)]);
|
|
4709
|
+
function createBem(namespace, element, modifier) {
|
|
4710
|
+
let cls = namespace;
|
|
4711
|
+
if (element) {
|
|
4712
|
+
cls += `__${element}`;
|
|
4802
4713
|
}
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
isOpen: {
|
|
4806
|
-
type: Boolean,
|
|
4807
|
-
default: false
|
|
4808
|
-
},
|
|
4809
|
-
position: {
|
|
4810
|
-
type: Array,
|
|
4811
|
-
default: ["bottom"]
|
|
4812
|
-
},
|
|
4813
|
-
align: {
|
|
4814
|
-
type: String,
|
|
4815
|
-
default: null
|
|
4816
|
-
},
|
|
4817
|
-
offset: {
|
|
4818
|
-
type: [Number, Object],
|
|
4819
|
-
default: 8
|
|
4820
|
-
},
|
|
4821
|
-
content: {
|
|
4822
|
-
type: String,
|
|
4823
|
-
default: ""
|
|
4824
|
-
},
|
|
4825
|
-
trigger: {
|
|
4826
|
-
type: String,
|
|
4827
|
-
default: "click"
|
|
4828
|
-
},
|
|
4829
|
-
popType: {
|
|
4830
|
-
type: String,
|
|
4831
|
-
default: "default"
|
|
4832
|
-
},
|
|
4833
|
-
showAnimation: {
|
|
4834
|
-
type: Boolean,
|
|
4835
|
-
default: true
|
|
4836
|
-
},
|
|
4837
|
-
mouseEnterDelay: {
|
|
4838
|
-
type: Number,
|
|
4839
|
-
default: 150
|
|
4840
|
-
},
|
|
4841
|
-
mouseLeaveDelay: {
|
|
4842
|
-
type: Number,
|
|
4843
|
-
default: 100
|
|
4714
|
+
if (modifier) {
|
|
4715
|
+
cls += `--${modifier}`;
|
|
4844
4716
|
}
|
|
4845
|
-
|
|
4717
|
+
return cls;
|
|
4718
|
+
}
|
|
4719
|
+
function useNamespace(block) {
|
|
4720
|
+
const namespace = `devui-${block}`;
|
|
4721
|
+
const b = () => createBem(namespace);
|
|
4722
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
4723
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
4724
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
4725
|
+
return {
|
|
4726
|
+
b,
|
|
4727
|
+
e,
|
|
4728
|
+
m,
|
|
4729
|
+
em
|
|
4730
|
+
};
|
|
4731
|
+
}
|
|
4732
|
+
function useFieldCollection() {
|
|
4733
|
+
const itemContexts = [];
|
|
4734
|
+
const addItemContext = (field) => {
|
|
4735
|
+
itemContexts.push(field);
|
|
4736
|
+
};
|
|
4737
|
+
const removeItemContext = (field) => {
|
|
4738
|
+
itemContexts.splice(itemContexts.indexOf(field), 1);
|
|
4739
|
+
};
|
|
4740
|
+
return { itemContexts, addItemContext, removeItemContext };
|
|
4741
|
+
}
|
|
4846
4742
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
4847
4743
|
var lodash = { exports: {} };
|
|
4848
4744
|
/**
|
|
@@ -9157,7 +9053,7 @@ var lodash = { exports: {} };
|
|
|
9157
9053
|
var mergeWith = createAssigner(function(object4, source, srcIndex, customizer) {
|
|
9158
9054
|
baseMerge(object4, source, srcIndex, customizer);
|
|
9159
9055
|
});
|
|
9160
|
-
var
|
|
9056
|
+
var omit2 = flatRest(function(object4, paths) {
|
|
9161
9057
|
var result3 = {};
|
|
9162
9058
|
if (object4 == null) {
|
|
9163
9059
|
return result3;
|
|
@@ -9845,7 +9741,7 @@ var lodash = { exports: {} };
|
|
|
9845
9741
|
lodash2.mixin = mixin;
|
|
9846
9742
|
lodash2.negate = negate;
|
|
9847
9743
|
lodash2.nthArg = nthArg;
|
|
9848
|
-
lodash2.omit =
|
|
9744
|
+
lodash2.omit = omit2;
|
|
9849
9745
|
lodash2.omitBy = omitBy;
|
|
9850
9746
|
lodash2.once = once;
|
|
9851
9747
|
lodash2.orderBy = orderBy;
|
|
@@ -10255,64 +10151,217 @@ var lodash = { exports: {} };
|
|
|
10255
10151
|
}
|
|
10256
10152
|
}).call(commonjsGlobal);
|
|
10257
10153
|
})(lodash, lodash.exports);
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
zIndex: 1060,
|
|
10268
|
-
transformOrigin: TransformOriginMap$1[placement.value]
|
|
10269
|
-
}));
|
|
10270
|
-
const onDocumentClick = (e) => {
|
|
10271
|
-
var _a, _b;
|
|
10272
|
-
if (!((_a = origin.value) == null ? void 0 : _a.contains(e.target)) && !((_b = popoverRef.value.$el) == null ? void 0 : _b.contains(e.target))) {
|
|
10273
|
-
visible.value = false;
|
|
10154
|
+
function useFormValidation(itemContexts) {
|
|
10155
|
+
const getValidateFields = (fields) => {
|
|
10156
|
+
if (!itemContexts.length) {
|
|
10157
|
+
return [];
|
|
10158
|
+
}
|
|
10159
|
+
const normalizedFields = lodash.exports.castArray(fields);
|
|
10160
|
+
const filteredFields = normalizedFields.length ? itemContexts.filter((context) => context.field && normalizedFields.includes(context.field)) : itemContexts;
|
|
10161
|
+
if (!filteredFields.length) {
|
|
10162
|
+
return [];
|
|
10274
10163
|
}
|
|
10164
|
+
return filteredFields;
|
|
10275
10165
|
};
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
if (visible.value && trigger.value !== "manually") {
|
|
10281
|
-
document.addEventListener("click", onDocumentClick);
|
|
10282
|
-
} else {
|
|
10283
|
-
document.removeEventListener("click", onDocumentClick);
|
|
10166
|
+
const execValidateFields = async (fields = []) => {
|
|
10167
|
+
const validateFields2 = getValidateFields(fields);
|
|
10168
|
+
if (!validateFields2.length) {
|
|
10169
|
+
return true;
|
|
10284
10170
|
}
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
}
|
|
10291
|
-
|
|
10292
|
-
const { trigger, position, mouseEnterDelay, mouseLeaveDelay } = toRefs(props);
|
|
10293
|
-
const isClick = computed(() => trigger.value === "click");
|
|
10294
|
-
const placement = ref(position.value[0].split("-")[0]);
|
|
10295
|
-
const isEnter = ref(false);
|
|
10296
|
-
const onClick = () => isClick.value && (visible.value = !visible.value);
|
|
10297
|
-
const enter = lodash.exports.debounce(() => {
|
|
10298
|
-
isEnter.value && (visible.value = true);
|
|
10299
|
-
}, mouseEnterDelay.value);
|
|
10300
|
-
const leave = lodash.exports.debounce(() => {
|
|
10301
|
-
!isEnter.value && (visible.value = false);
|
|
10302
|
-
}, mouseLeaveDelay.value);
|
|
10303
|
-
const onMouseenter = () => {
|
|
10304
|
-
if (!isClick.value) {
|
|
10305
|
-
isEnter.value = true;
|
|
10306
|
-
enter();
|
|
10171
|
+
let errors = {};
|
|
10172
|
+
for (const field of validateFields2) {
|
|
10173
|
+
try {
|
|
10174
|
+
await field.validate("");
|
|
10175
|
+
} catch (err) {
|
|
10176
|
+
errors = __spreadValues(__spreadValues({}, errors), err);
|
|
10177
|
+
}
|
|
10307
10178
|
}
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
if (!isClick.value) {
|
|
10311
|
-
isEnter.value = false;
|
|
10312
|
-
leave();
|
|
10179
|
+
if (!Object.keys(errors).length) {
|
|
10180
|
+
return true;
|
|
10313
10181
|
}
|
|
10182
|
+
return Promise.reject(errors);
|
|
10314
10183
|
};
|
|
10315
|
-
const
|
|
10184
|
+
const validateFields = async (fields = [], callback) => {
|
|
10185
|
+
try {
|
|
10186
|
+
const result2 = await execValidateFields(fields);
|
|
10187
|
+
if (result2) {
|
|
10188
|
+
callback == null ? void 0 : callback(result2);
|
|
10189
|
+
}
|
|
10190
|
+
return result2;
|
|
10191
|
+
} catch (err) {
|
|
10192
|
+
const invalidFields = err;
|
|
10193
|
+
callback == null ? void 0 : callback(false, invalidFields);
|
|
10194
|
+
return !callback && Promise.reject(invalidFields);
|
|
10195
|
+
}
|
|
10196
|
+
};
|
|
10197
|
+
const validate = async (callback) => validateFields(void 0, callback);
|
|
10198
|
+
return { validate, validateFields };
|
|
10199
|
+
}
|
|
10200
|
+
var Form = defineComponent({
|
|
10201
|
+
name: "DForm",
|
|
10202
|
+
props: formProps,
|
|
10203
|
+
emits: ["submit"],
|
|
10204
|
+
setup(props, ctx2) {
|
|
10205
|
+
const formMitt = mitt();
|
|
10206
|
+
const ns = useNamespace("form");
|
|
10207
|
+
const {
|
|
10208
|
+
data,
|
|
10209
|
+
layout: layout2,
|
|
10210
|
+
labelSize,
|
|
10211
|
+
labelAlign
|
|
10212
|
+
} = toRefs(props);
|
|
10213
|
+
const {
|
|
10214
|
+
itemContexts,
|
|
10215
|
+
addItemContext,
|
|
10216
|
+
removeItemContext
|
|
10217
|
+
} = useFieldCollection();
|
|
10218
|
+
const {
|
|
10219
|
+
validate,
|
|
10220
|
+
validateFields
|
|
10221
|
+
} = useFormValidation(itemContexts);
|
|
10222
|
+
formMitt.on(dFormEvents.addField, (field) => {
|
|
10223
|
+
});
|
|
10224
|
+
formMitt.on(dFormEvents.removeField, (field) => {
|
|
10225
|
+
if (field.prop)
|
|
10226
|
+
;
|
|
10227
|
+
});
|
|
10228
|
+
provide(FORM_TOKEN, reactive({
|
|
10229
|
+
formData: data,
|
|
10230
|
+
formMitt,
|
|
10231
|
+
labelData: {
|
|
10232
|
+
layout: layout2,
|
|
10233
|
+
labelSize,
|
|
10234
|
+
labelAlign
|
|
10235
|
+
},
|
|
10236
|
+
rules: props.rules,
|
|
10237
|
+
messageShowType: "popover",
|
|
10238
|
+
addItemContext,
|
|
10239
|
+
removeItemContext
|
|
10240
|
+
}));
|
|
10241
|
+
ctx2.expose({
|
|
10242
|
+
validate,
|
|
10243
|
+
validateFields
|
|
10244
|
+
});
|
|
10245
|
+
const onSubmit = (e) => {
|
|
10246
|
+
e.preventDefault();
|
|
10247
|
+
ctx2.emit("submit", e);
|
|
10248
|
+
EventBus.emit(`formSubmit:${props.name}`);
|
|
10249
|
+
};
|
|
10250
|
+
return () => {
|
|
10251
|
+
var _a, _b;
|
|
10252
|
+
return createVNode("form", {
|
|
10253
|
+
"onSubmit": onSubmit,
|
|
10254
|
+
"class": ns.b()
|
|
10255
|
+
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
10256
|
+
};
|
|
10257
|
+
}
|
|
10258
|
+
});
|
|
10259
|
+
const formLabelProps = {
|
|
10260
|
+
helpTips: {
|
|
10261
|
+
type: String,
|
|
10262
|
+
default: ""
|
|
10263
|
+
}
|
|
10264
|
+
};
|
|
10265
|
+
const popoverProps = {
|
|
10266
|
+
isOpen: {
|
|
10267
|
+
type: Boolean,
|
|
10268
|
+
default: false
|
|
10269
|
+
},
|
|
10270
|
+
position: {
|
|
10271
|
+
type: Array,
|
|
10272
|
+
default: ["bottom"]
|
|
10273
|
+
},
|
|
10274
|
+
align: {
|
|
10275
|
+
type: String,
|
|
10276
|
+
default: null
|
|
10277
|
+
},
|
|
10278
|
+
offset: {
|
|
10279
|
+
type: [Number, Object],
|
|
10280
|
+
default: 8
|
|
10281
|
+
},
|
|
10282
|
+
content: {
|
|
10283
|
+
type: String,
|
|
10284
|
+
default: ""
|
|
10285
|
+
},
|
|
10286
|
+
trigger: {
|
|
10287
|
+
type: String,
|
|
10288
|
+
default: "click"
|
|
10289
|
+
},
|
|
10290
|
+
popType: {
|
|
10291
|
+
type: String,
|
|
10292
|
+
default: "default"
|
|
10293
|
+
},
|
|
10294
|
+
showAnimation: {
|
|
10295
|
+
type: Boolean,
|
|
10296
|
+
default: true
|
|
10297
|
+
},
|
|
10298
|
+
mouseEnterDelay: {
|
|
10299
|
+
type: Number,
|
|
10300
|
+
default: 150
|
|
10301
|
+
},
|
|
10302
|
+
mouseLeaveDelay: {
|
|
10303
|
+
type: Number,
|
|
10304
|
+
default: 100
|
|
10305
|
+
}
|
|
10306
|
+
};
|
|
10307
|
+
const TransformOriginMap$1 = {
|
|
10308
|
+
top: "50% calc(100% + 8px)",
|
|
10309
|
+
bottom: "50% -8px",
|
|
10310
|
+
left: "calc(100% + 8px)",
|
|
10311
|
+
right: "-8px 50%"
|
|
10312
|
+
};
|
|
10313
|
+
function usePopover(props, visible, placement, origin, popoverRef) {
|
|
10314
|
+
const { trigger, isOpen } = toRefs(props);
|
|
10315
|
+
const overlayStyles = computed(() => ({
|
|
10316
|
+
zIndex: 1060,
|
|
10317
|
+
transformOrigin: TransformOriginMap$1[placement.value]
|
|
10318
|
+
}));
|
|
10319
|
+
const onDocumentClick = (e) => {
|
|
10320
|
+
var _a, _b;
|
|
10321
|
+
if (!((_a = origin.value) == null ? void 0 : _a.contains(e.target)) && !((_b = popoverRef.value.$el) == null ? void 0 : _b.contains(e.target))) {
|
|
10322
|
+
visible.value = false;
|
|
10323
|
+
}
|
|
10324
|
+
};
|
|
10325
|
+
watch(isOpen, (isOpenVal) => {
|
|
10326
|
+
visible.value = isOpenVal;
|
|
10327
|
+
});
|
|
10328
|
+
watch(visible, () => {
|
|
10329
|
+
if (visible.value && trigger.value !== "manually") {
|
|
10330
|
+
document.addEventListener("click", onDocumentClick);
|
|
10331
|
+
} else {
|
|
10332
|
+
document.removeEventListener("click", onDocumentClick);
|
|
10333
|
+
}
|
|
10334
|
+
});
|
|
10335
|
+
onUnmounted(() => {
|
|
10336
|
+
document.removeEventListener("click", onDocumentClick);
|
|
10337
|
+
});
|
|
10338
|
+
return { overlayStyles };
|
|
10339
|
+
}
|
|
10340
|
+
function usePopoverEvent(props, visible, origin) {
|
|
10341
|
+
const { trigger, position, mouseEnterDelay, mouseLeaveDelay } = toRefs(props);
|
|
10342
|
+
const isClick = computed(() => trigger.value === "click");
|
|
10343
|
+
const placement = ref(position.value[0].split("-")[0]);
|
|
10344
|
+
const isEnter = ref(false);
|
|
10345
|
+
const onClick = () => isClick.value && (visible.value = !visible.value);
|
|
10346
|
+
const enter = lodash.exports.debounce(() => {
|
|
10347
|
+
isEnter.value && (visible.value = true);
|
|
10348
|
+
}, mouseEnterDelay.value);
|
|
10349
|
+
const leave = lodash.exports.debounce(() => {
|
|
10350
|
+
!isEnter.value && (visible.value = false);
|
|
10351
|
+
}, mouseLeaveDelay.value);
|
|
10352
|
+
const onMouseenter = () => {
|
|
10353
|
+
if (!isClick.value) {
|
|
10354
|
+
isEnter.value = true;
|
|
10355
|
+
enter();
|
|
10356
|
+
}
|
|
10357
|
+
};
|
|
10358
|
+
const onMouseleave = () => {
|
|
10359
|
+
if (!isClick.value) {
|
|
10360
|
+
isEnter.value = false;
|
|
10361
|
+
leave();
|
|
10362
|
+
}
|
|
10363
|
+
};
|
|
10364
|
+
const handlePositionChange = (pos) => {
|
|
10316
10365
|
placement.value = pos.split("-")[0];
|
|
10317
10366
|
};
|
|
10318
10367
|
onMounted(() => {
|
|
@@ -10488,43 +10537,63 @@ var Popover = defineComponent({
|
|
|
10488
10537
|
};
|
|
10489
10538
|
}
|
|
10490
10539
|
});
|
|
10540
|
+
function HelpTipsIcon() {
|
|
10541
|
+
return createVNode("svg", {
|
|
10542
|
+
"width": "16px",
|
|
10543
|
+
"height": "16px",
|
|
10544
|
+
"viewBox": "0 0 16 16"
|
|
10545
|
+
}, [createVNode("g", {
|
|
10546
|
+
"stroke": "none",
|
|
10547
|
+
"stroke-width": "1",
|
|
10548
|
+
"fill": "none",
|
|
10549
|
+
"fill-rule": "evenodd"
|
|
10550
|
+
}, [createVNode("g", null, [createVNode("path", {
|
|
10551
|
+
"d": "M8.5,8.95852078 L8.5,11 L7.5,11 L7.5,8.5 C7.5,8.22385763 7.72385763,8 8,8 C9.1045695,8 10,7.1045695 10,6 C10,4.8954305 9.1045695,4 8,4 C6.8954305,4 6,4.8954305 6,6 L5,6 C5,4.34314575 6.34314575,3 8,3 C9.65685425,3 11,4.34314575 11,6 C11,7.48649814 9.91885667,8.72048173 8.5,8.95852078 L8.5,8.95852078 Z M8,16 C3.581722,16 0,12.418278 0,8 C0,3.581722 3.581722,0 8,0 C12.418278,0 16,3.581722 16,8 C16,12.418278 12.418278,16 8,16 Z M8,15 C11.8659932,15 15,11.8659932 15,8 C15,4.13400675 11.8659932,1 8,1 C4.13400675,1 1,4.13400675 1,8 C1,11.8659932 4.13400675,15 8,15 Z M7.5,12 L8.5,12 L8.5,13 L7.5,13 L7.5,12 Z",
|
|
10552
|
+
"fill": "#293040",
|
|
10553
|
+
"fill-rule": "nonzero"
|
|
10554
|
+
}, null)])])]);
|
|
10555
|
+
}
|
|
10556
|
+
function useFormLabel() {
|
|
10557
|
+
const { labelData } = inject(FORM_TOKEN);
|
|
10558
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
10559
|
+
const ns = useNamespace("form");
|
|
10560
|
+
const labelClasses = computed(() => ({
|
|
10561
|
+
[`${ns.e("label")}`]: true,
|
|
10562
|
+
[`${ns.em("label", "vertical")}`]: labelData.layout === "vertical",
|
|
10563
|
+
[`${ns.em("label", labelData.labelSize)}`]: labelData.layout === "horizontal",
|
|
10564
|
+
[`${ns.em("label", labelData.labelAlign)}`]: labelData.layout === "horizontal"
|
|
10565
|
+
}));
|
|
10566
|
+
const labelInnerClasses = computed(() => ({
|
|
10567
|
+
[`${ns.em("label", "required")}`]: formItemContext.required
|
|
10568
|
+
}));
|
|
10569
|
+
return { labelClasses, labelInnerClasses };
|
|
10570
|
+
}
|
|
10491
10571
|
var formLabel = "";
|
|
10492
10572
|
var FormLabel = defineComponent({
|
|
10493
10573
|
name: "DFormLabel",
|
|
10494
10574
|
props: formLabelProps,
|
|
10495
10575
|
setup(props, ctx2) {
|
|
10496
|
-
const
|
|
10497
|
-
const
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10501
|
-
const isCenter = computed(() => labelData.labelAlign === "center").value;
|
|
10502
|
-
const isEnd = computed(() => labelData.labelAlign === "end").value;
|
|
10503
|
-
const wrapperCls = `devui-form-label${isHorizontal ? isSm ? " devui-form-label_sm" : isLg ? " devui-form-label_lg" : " devui-form-label_sd" : ""}${isCenter ? " devui-form-label_center" : isEnd ? " devui-form-label_end" : ""}`;
|
|
10504
|
-
const className2 = `${props.required ? " devui-required" : ""}`;
|
|
10505
|
-
const style2 = {
|
|
10506
|
-
display: isHorizontal ? "inline" : "inline-block"
|
|
10507
|
-
};
|
|
10576
|
+
const ns = useNamespace("form");
|
|
10577
|
+
const {
|
|
10578
|
+
labelClasses,
|
|
10579
|
+
labelInnerClasses
|
|
10580
|
+
} = useFormLabel();
|
|
10508
10581
|
return () => {
|
|
10509
10582
|
var _a, _b;
|
|
10510
10583
|
return createVNode("span", {
|
|
10511
|
-
"class":
|
|
10512
|
-
"style": style2
|
|
10584
|
+
"class": labelClasses.value
|
|
10513
10585
|
}, [createVNode("span", {
|
|
10514
|
-
"class":
|
|
10515
|
-
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a), props.
|
|
10586
|
+
"class": labelInnerClasses.value
|
|
10587
|
+
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)]), props.helpTips && createVNode(Popover, {
|
|
10516
10588
|
"content": props.helpTips,
|
|
10517
|
-
"
|
|
10518
|
-
"
|
|
10519
|
-
"
|
|
10589
|
+
"position": ["top"],
|
|
10590
|
+
"trigger": "hover",
|
|
10591
|
+
"pop-type": "info"
|
|
10520
10592
|
}, {
|
|
10521
|
-
reference: () => createVNode(
|
|
10522
|
-
"class": "
|
|
10523
|
-
},
|
|
10524
|
-
|
|
10525
|
-
"color": "#252b3a"
|
|
10526
|
-
}, null)])
|
|
10527
|
-
})])]);
|
|
10593
|
+
reference: () => createVNode(HelpTipsIcon, {
|
|
10594
|
+
"class": ns.e("label-help")
|
|
10595
|
+
}, null)
|
|
10596
|
+
})]);
|
|
10528
10597
|
};
|
|
10529
10598
|
}
|
|
10530
10599
|
});
|
|
@@ -11530,228 +11599,228 @@ Schema.register = function register(type4, validator) {
|
|
|
11530
11599
|
Schema.warning = warning;
|
|
11531
11600
|
Schema.messages = messages;
|
|
11532
11601
|
Schema.validators = validators;
|
|
11602
|
+
function useFormItem() {
|
|
11603
|
+
const formContext = reactive(inject(FORM_TOKEN));
|
|
11604
|
+
const labelData = reactive(formContext.labelData);
|
|
11605
|
+
const ns = useNamespace("form");
|
|
11606
|
+
const itemClasses = computed(() => ({
|
|
11607
|
+
[`${ns.em("item", "horizontal")}`]: labelData.layout === "horizontal",
|
|
11608
|
+
[`${ns.em("item", "vertical")}`]: labelData.layout === "vertical"
|
|
11609
|
+
}));
|
|
11610
|
+
return { itemClasses };
|
|
11611
|
+
}
|
|
11612
|
+
function useFormItemRule(props) {
|
|
11613
|
+
const formContext = inject(FORM_TOKEN);
|
|
11614
|
+
const _rules = computed(() => {
|
|
11615
|
+
const rules2 = props.rules ? lodash.exports.castArray(props.rules) : [];
|
|
11616
|
+
const formRules = formContext.rules;
|
|
11617
|
+
if (formRules && props.field) {
|
|
11618
|
+
const _itemRules = lodash.exports.get(formRules, props.field, void 0);
|
|
11619
|
+
if (_itemRules) {
|
|
11620
|
+
rules2.push(...lodash.exports.castArray(_itemRules));
|
|
11621
|
+
}
|
|
11622
|
+
}
|
|
11623
|
+
if (props.required) {
|
|
11624
|
+
rules2.push({ required: Boolean(props.required) });
|
|
11625
|
+
}
|
|
11626
|
+
return rules2;
|
|
11627
|
+
});
|
|
11628
|
+
return { _rules };
|
|
11629
|
+
}
|
|
11630
|
+
function useFormItemValidate(props, _rules) {
|
|
11631
|
+
const formContext = inject(FORM_TOKEN);
|
|
11632
|
+
const validateState = ref("");
|
|
11633
|
+
const validateMessage = ref("");
|
|
11634
|
+
const computedField = computed(() => {
|
|
11635
|
+
return typeof props.field === "string" ? props.field : "";
|
|
11636
|
+
});
|
|
11637
|
+
const fieldValue = computed(() => {
|
|
11638
|
+
const formData = formContext.formData;
|
|
11639
|
+
if (!formData || !props.field) {
|
|
11640
|
+
return;
|
|
11641
|
+
}
|
|
11642
|
+
return formData[props.field];
|
|
11643
|
+
});
|
|
11644
|
+
const getRuleByTrigger = (triggerVal) => {
|
|
11645
|
+
return _rules.value.filter((rule) => {
|
|
11646
|
+
if (!rule.trigger || !triggerVal) {
|
|
11647
|
+
return true;
|
|
11648
|
+
}
|
|
11649
|
+
if (Array.isArray(rule.trigger)) {
|
|
11650
|
+
return rule.trigger.includes(triggerVal);
|
|
11651
|
+
} else {
|
|
11652
|
+
return rule.trigger === triggerVal;
|
|
11653
|
+
}
|
|
11654
|
+
}).map((_a) => {
|
|
11655
|
+
var _b = _a, { trigger } = _b, rule = __objRest(_b, ["trigger"]);
|
|
11656
|
+
return rule;
|
|
11657
|
+
});
|
|
11658
|
+
};
|
|
11659
|
+
const onValidateSuccess = () => {
|
|
11660
|
+
validateState.value = "success";
|
|
11661
|
+
validateMessage.value = "";
|
|
11662
|
+
};
|
|
11663
|
+
const onValidateError = ({ errors }) => {
|
|
11664
|
+
var _a;
|
|
11665
|
+
validateState.value = "error";
|
|
11666
|
+
validateMessage.value = ((_a = errors == null ? void 0 : errors[0]) == null ? void 0 : _a.message) || "";
|
|
11667
|
+
};
|
|
11668
|
+
const execValidate = async (rules2) => {
|
|
11669
|
+
const ruleName = computedField.value;
|
|
11670
|
+
const validator = new Schema({
|
|
11671
|
+
[ruleName]: rules2
|
|
11672
|
+
});
|
|
11673
|
+
return validator.validate({ [ruleName]: fieldValue.value }, { firstFields: true }).then(() => {
|
|
11674
|
+
onValidateSuccess();
|
|
11675
|
+
return true;
|
|
11676
|
+
}).catch((error) => {
|
|
11677
|
+
onValidateError(error);
|
|
11678
|
+
return Promise.reject(error);
|
|
11679
|
+
});
|
|
11680
|
+
};
|
|
11681
|
+
const validate = async (trigger, callback) => {
|
|
11682
|
+
const rules2 = getRuleByTrigger(trigger);
|
|
11683
|
+
if (!rules2.length) {
|
|
11684
|
+
callback == null ? void 0 : callback(true);
|
|
11685
|
+
return true;
|
|
11686
|
+
}
|
|
11687
|
+
validateState.value = "pending";
|
|
11688
|
+
return execValidate(rules2).then(() => {
|
|
11689
|
+
callback == null ? void 0 : callback(true);
|
|
11690
|
+
return true;
|
|
11691
|
+
}).catch((error) => {
|
|
11692
|
+
const { fields } = error;
|
|
11693
|
+
callback == null ? void 0 : callback(false, fields);
|
|
11694
|
+
return lodash.exports.isFunction(callback) ? false : Promise.reject(fields);
|
|
11695
|
+
});
|
|
11696
|
+
};
|
|
11697
|
+
return { validateState, validateMessage, validate };
|
|
11698
|
+
}
|
|
11533
11699
|
var formItem = "";
|
|
11534
11700
|
var FormItem = defineComponent({
|
|
11535
11701
|
name: "DFormItem",
|
|
11536
11702
|
props: formItemProps,
|
|
11537
11703
|
setup(props, ctx2) {
|
|
11538
|
-
const
|
|
11539
|
-
const
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
const
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
const
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
resetField
|
|
11557
|
-
});
|
|
11558
|
-
provide(formItemInjectionKey, formItem2);
|
|
11559
|
-
const isHorizontal = labelData.layout === "horizontal";
|
|
11560
|
-
const isVertical = labelData.layout === "vertical";
|
|
11561
|
-
const isColumns = labelData.layout === "columns";
|
|
11562
|
-
const showMessage = ref(false);
|
|
11563
|
-
const tipMessage = ref("");
|
|
11564
|
-
const validate = (trigger) => {
|
|
11565
|
-
const ruleKey = props.prop;
|
|
11566
|
-
const ruleItem = rules2[ruleKey];
|
|
11567
|
-
const descriptor = {};
|
|
11568
|
-
descriptor[ruleKey] = ruleItem;
|
|
11569
|
-
const validator = new Schema(descriptor);
|
|
11570
|
-
validator.validate({
|
|
11571
|
-
[ruleKey]: formData[ruleKey]
|
|
11572
|
-
}).then(() => {
|
|
11573
|
-
showMessage.value = false;
|
|
11574
|
-
tipMessage.value = "";
|
|
11575
|
-
}).catch(({
|
|
11576
|
-
errors
|
|
11577
|
-
}) => {
|
|
11578
|
-
showMessage.value = true;
|
|
11579
|
-
tipMessage.value = errors[0].message;
|
|
11580
|
-
});
|
|
11581
|
-
};
|
|
11582
|
-
const validateEvents = [];
|
|
11583
|
-
const addValidateEvents = () => {
|
|
11584
|
-
if (rules2 && rules2[props.prop]) {
|
|
11585
|
-
const ruleItem = rules2[props.prop];
|
|
11586
|
-
let eventName = ruleItem["trigger"];
|
|
11587
|
-
if (Array.isArray(ruleItem)) {
|
|
11588
|
-
ruleItem.forEach((item) => {
|
|
11589
|
-
eventName = item["trigger"];
|
|
11590
|
-
const cb = () => validate();
|
|
11591
|
-
validateEvents.push({
|
|
11592
|
-
eventName: cb
|
|
11593
|
-
});
|
|
11594
|
-
formItem2.formItemMitt.on(dFormItemEvents[eventName], cb);
|
|
11595
|
-
});
|
|
11596
|
-
} else {
|
|
11597
|
-
const cb = () => validate();
|
|
11598
|
-
validateEvents.push({
|
|
11599
|
-
eventName: cb
|
|
11600
|
-
});
|
|
11601
|
-
ruleItem && formItem2.formItemMitt.on(dFormItemEvents[eventName], cb);
|
|
11602
|
-
}
|
|
11603
|
-
}
|
|
11604
|
-
};
|
|
11605
|
-
const removeValidateEvents = () => {
|
|
11606
|
-
if (rules2 && rules2[props.prop] && validateEvents.length > 0) {
|
|
11607
|
-
validateEvents.forEach((item) => {
|
|
11608
|
-
formItem2.formItemMitt.off(item.eventName, item.cb);
|
|
11609
|
-
});
|
|
11610
|
-
}
|
|
11611
|
-
};
|
|
11704
|
+
const formContext = inject(FORM_TOKEN);
|
|
11705
|
+
const {
|
|
11706
|
+
itemClasses
|
|
11707
|
+
} = useFormItem();
|
|
11708
|
+
const {
|
|
11709
|
+
_rules
|
|
11710
|
+
} = useFormItemRule(props);
|
|
11711
|
+
const {
|
|
11712
|
+
validateState,
|
|
11713
|
+
validateMessage,
|
|
11714
|
+
validate
|
|
11715
|
+
} = useFormItemValidate(props, _rules);
|
|
11716
|
+
const context = reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
|
|
11717
|
+
validateState,
|
|
11718
|
+
validateMessage,
|
|
11719
|
+
validate
|
|
11720
|
+
}));
|
|
11721
|
+
provide(FORM_ITEM_TOKEN, context);
|
|
11612
11722
|
onMounted(() => {
|
|
11613
|
-
|
|
11614
|
-
|
|
11723
|
+
if (props.field) {
|
|
11724
|
+
formContext == null ? void 0 : formContext.addItemContext(context);
|
|
11725
|
+
}
|
|
11615
11726
|
});
|
|
11616
11727
|
onBeforeUnmount(() => {
|
|
11617
|
-
|
|
11618
|
-
removeValidateEvents();
|
|
11728
|
+
formContext == null ? void 0 : formContext.removeItemContext(context);
|
|
11619
11729
|
});
|
|
11620
11730
|
return () => {
|
|
11621
11731
|
var _a, _b;
|
|
11622
11732
|
return createVNode("div", {
|
|
11623
|
-
"class":
|
|
11624
|
-
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)
|
|
11625
|
-
"class": `devui-validate-tip${isHorizontal ? " devui-validate-tip-horizontal" : ""}`
|
|
11626
|
-
}, [showMessage.value && tipMessage.value])]);
|
|
11733
|
+
"class": itemClasses.value
|
|
11734
|
+
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
11627
11735
|
};
|
|
11628
11736
|
}
|
|
11629
11737
|
});
|
|
11738
|
+
const formControlProps = {
|
|
11739
|
+
feedbackStatus: {
|
|
11740
|
+
type: String
|
|
11741
|
+
},
|
|
11742
|
+
extraInfo: {
|
|
11743
|
+
type: String,
|
|
11744
|
+
default: ""
|
|
11745
|
+
}
|
|
11746
|
+
};
|
|
11747
|
+
function useFormControl(props) {
|
|
11748
|
+
const formContext = inject(FORM_TOKEN);
|
|
11749
|
+
const labelData = reactive(formContext.labelData);
|
|
11750
|
+
const ns = useNamespace("form");
|
|
11751
|
+
const { feedbackStatus } = toRefs(props);
|
|
11752
|
+
const controlClasses = computed(() => ({
|
|
11753
|
+
[`${ns.e("control")}`]: true,
|
|
11754
|
+
[`${ns.em("control", "horizontal")}`]: labelData.layout === "horizontal"
|
|
11755
|
+
}));
|
|
11756
|
+
const controlContainerClasses = computed(() => ({
|
|
11757
|
+
[`${ns.e("control-container")}`]: true,
|
|
11758
|
+
[`${ns.em("control-container", "horizontal")}`]: labelData.layout === "horizontal",
|
|
11759
|
+
[`${ns.em("control-container", "has-feedback")}`]: Boolean(feedbackStatus.value),
|
|
11760
|
+
[`${ns.em("control-container", "feedback-error")}`]: Boolean(feedbackStatus.value === "error")
|
|
11761
|
+
}));
|
|
11762
|
+
return { controlClasses, controlContainerClasses };
|
|
11763
|
+
}
|
|
11764
|
+
function useFormControlValidate() {
|
|
11765
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
11766
|
+
const errorMessage = computed(() => formItemContext.validateMessage);
|
|
11767
|
+
return { errorMessage };
|
|
11768
|
+
}
|
|
11630
11769
|
var formControl = "";
|
|
11631
11770
|
var FormControl = defineComponent({
|
|
11632
11771
|
name: "DFormControl",
|
|
11633
|
-
directives: {
|
|
11634
|
-
clickoutside: clickoutsideDirective
|
|
11635
|
-
},
|
|
11636
11772
|
props: formControlProps,
|
|
11637
11773
|
setup(props, ctx2) {
|
|
11638
11774
|
const formControl2 = ref();
|
|
11639
|
-
const dForm = reactive(inject(formInjectionKey, {}));
|
|
11640
|
-
const labelData = reactive(dForm.labelData);
|
|
11641
|
-
const isHorizontal = labelData.layout === "horizontal";
|
|
11642
11775
|
const uid = lodash.exports.uniqueId("dfc-");
|
|
11643
|
-
const
|
|
11644
|
-
const
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
};
|
|
11651
|
-
let elOffset = {
|
|
11652
|
-
left: 0,
|
|
11653
|
-
top: 0
|
|
11654
|
-
};
|
|
11655
|
-
let popoverLeftPosition = 0;
|
|
11656
|
-
let popoverTopPosition = 0;
|
|
11657
|
-
onMounted(() => {
|
|
11658
|
-
const el = document.getElementById(uid);
|
|
11659
|
-
elOffset = getElOffset(el);
|
|
11660
|
-
EventBus.on("showPopoverErrorMessage", (data) => {
|
|
11661
|
-
var _a;
|
|
11662
|
-
if (uid === data.uid) {
|
|
11663
|
-
rectInfo = el.getBoundingClientRect();
|
|
11664
|
-
showPopover.value = data.showPopover;
|
|
11665
|
-
tipMessage.value = data.message;
|
|
11666
|
-
popPosition.value = data.popPosition;
|
|
11667
|
-
popoverLeftPosition = popPosition.value === "top" || popPosition.value === "bottom" ? rectInfo.right - rectInfo.width / 2 : rectInfo.right;
|
|
11668
|
-
popoverTopPosition = popPosition.value === "top" ? elOffset.top + rectInfo.height / 2 - rectInfo.height : elOffset.top + rectInfo.height / 2;
|
|
11669
|
-
updateOn.value = (_a = data.updateOn) != null ? _a : "change";
|
|
11670
|
-
}
|
|
11671
|
-
});
|
|
11672
|
-
});
|
|
11673
|
-
const iconData = computed(() => {
|
|
11674
|
-
switch (props.feedbackStatus) {
|
|
11675
|
-
case "pending":
|
|
11676
|
-
return {
|
|
11677
|
-
name: "priority",
|
|
11678
|
-
color: "#e9edfa"
|
|
11679
|
-
};
|
|
11680
|
-
case "success":
|
|
11681
|
-
return {
|
|
11682
|
-
name: "right-o",
|
|
11683
|
-
color: "rgb(61, 204, 166)"
|
|
11684
|
-
};
|
|
11685
|
-
case "error":
|
|
11686
|
-
return {
|
|
11687
|
-
name: "error-o",
|
|
11688
|
-
color: "rgb(249, 95, 91)"
|
|
11689
|
-
};
|
|
11690
|
-
default:
|
|
11691
|
-
return {
|
|
11692
|
-
name: "",
|
|
11693
|
-
color: ""
|
|
11694
|
-
};
|
|
11695
|
-
}
|
|
11696
|
-
});
|
|
11697
|
-
const handleClickOutside = () => {
|
|
11698
|
-
if (updateOn.value !== "change") {
|
|
11699
|
-
showPopover.value = false;
|
|
11700
|
-
}
|
|
11701
|
-
};
|
|
11776
|
+
const ns = useNamespace("form");
|
|
11777
|
+
const {
|
|
11778
|
+
controlClasses,
|
|
11779
|
+
controlContainerClasses
|
|
11780
|
+
} = useFormControl(props);
|
|
11781
|
+
const {
|
|
11782
|
+
errorMessage
|
|
11783
|
+
} = useFormControlValidate();
|
|
11702
11784
|
return () => {
|
|
11703
|
-
var _a, _b
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
extraInfo
|
|
11707
|
-
} = props;
|
|
11708
|
-
return withDirectives(createVNode("div", {
|
|
11709
|
-
"class": "devui-form-control",
|
|
11785
|
+
var _a, _b;
|
|
11786
|
+
return createVNode("div", {
|
|
11787
|
+
"class": controlClasses.value,
|
|
11710
11788
|
"ref": formControl2,
|
|
11711
11789
|
"data-uid": uid
|
|
11712
|
-
}, [showPopover.value && createVNode(Teleport, {
|
|
11713
|
-
"to": "body"
|
|
11714
|
-
}, {
|
|
11715
|
-
default: () => [createVNode("div", {
|
|
11716
|
-
"style": {
|
|
11717
|
-
position: "absolute",
|
|
11718
|
-
left: popoverLeftPosition + "px",
|
|
11719
|
-
top: popoverTopPosition + "px",
|
|
11720
|
-
width: rectInfo.width + "px",
|
|
11721
|
-
height: rectInfo.height + "px"
|
|
11722
|
-
}
|
|
11723
|
-
}, [createVNode(Popover, {
|
|
11724
|
-
"controlled": updateOn.value !== "change",
|
|
11725
|
-
"visible": showPopover.value,
|
|
11726
|
-
"content": tipMessage.value,
|
|
11727
|
-
"popType": "error",
|
|
11728
|
-
"position": popPosition.value
|
|
11729
|
-
}, null)])]
|
|
11730
|
-
}), createVNode("div", {
|
|
11731
|
-
"class": `devui-form-control-container${isHorizontal ? " devui-form-control-container-horizontal" : ""}${feedbackStatus ? " devui-has-feedback" : ""}${feedbackStatus === "error" ? " devui-feedback-error" : ""}`
|
|
11732
11790
|
}, [createVNode("div", {
|
|
11733
|
-
"class":
|
|
11791
|
+
"class": controlContainerClasses.value
|
|
11792
|
+
}, [createVNode("div", {
|
|
11793
|
+
"class": ns.e("control-content"),
|
|
11734
11794
|
"id": uid
|
|
11735
|
-
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)]),
|
|
11736
|
-
"class": "
|
|
11737
|
-
}, [
|
|
11738
|
-
"
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
}, [extraInfo])]), [[resolveDirective("clickoutside"), handleClickOutside]]);
|
|
11795
|
+
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)])]), createVNode("div", {
|
|
11796
|
+
"class": ns.e("control-info")
|
|
11797
|
+
}, [errorMessage.value && createVNode("div", {
|
|
11798
|
+
"class": "error-message"
|
|
11799
|
+
}, [errorMessage.value]), props.extraInfo && createVNode("div", {
|
|
11800
|
+
"class": ns.e("control-extra")
|
|
11801
|
+
}, [props.extraInfo])])]);
|
|
11743
11802
|
};
|
|
11744
11803
|
}
|
|
11745
11804
|
});
|
|
11746
11805
|
var formOperation = "";
|
|
11747
11806
|
var FormOperation = defineComponent({
|
|
11748
11807
|
name: "DFormOperation",
|
|
11749
|
-
props: {},
|
|
11750
11808
|
setup(props, ctx2) {
|
|
11809
|
+
const formContext = reactive(inject(FORM_TOKEN));
|
|
11810
|
+
const labelData = reactive(formContext.labelData);
|
|
11811
|
+
const LabelSizeMap = {
|
|
11812
|
+
sm: 80,
|
|
11813
|
+
md: 100,
|
|
11814
|
+
lg: 150
|
|
11815
|
+
};
|
|
11816
|
+
const styles = computed(() => ({
|
|
11817
|
+
marginLeft: labelData.layout === "horizontal" ? `${LabelSizeMap[labelData.labelSize] + 16}px` : void 0
|
|
11818
|
+
}));
|
|
11751
11819
|
return () => {
|
|
11752
11820
|
var _a, _b;
|
|
11753
11821
|
return createVNode("div", {
|
|
11754
|
-
"class": "devui-form-operation"
|
|
11822
|
+
"class": "devui-form-operation",
|
|
11823
|
+
"style": styles.value
|
|
11755
11824
|
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
11756
11825
|
};
|
|
11757
11826
|
}
|
|
@@ -11898,7 +11967,16 @@ function getFormControlUID(el) {
|
|
|
11898
11967
|
getFormControlUID(el.parentElement);
|
|
11899
11968
|
}
|
|
11900
11969
|
}
|
|
11901
|
-
function handleValidateError({
|
|
11970
|
+
function handleValidateError({
|
|
11971
|
+
el,
|
|
11972
|
+
tipEl,
|
|
11973
|
+
message = "",
|
|
11974
|
+
isFormTag,
|
|
11975
|
+
messageShowType,
|
|
11976
|
+
dfcUID,
|
|
11977
|
+
popPosition = "right-bottom",
|
|
11978
|
+
updateOn
|
|
11979
|
+
}) {
|
|
11902
11980
|
if (isFormTag && messageShowType === "toast") {
|
|
11903
11981
|
alert(message);
|
|
11904
11982
|
return;
|
|
@@ -11907,7 +11985,13 @@ function handleValidateError({ el, tipEl, message = "", isFormTag, messageShowTy
|
|
|
11907
11985
|
dfcUID = getFormControlUID(el);
|
|
11908
11986
|
}
|
|
11909
11987
|
if (messageShowType === "popover") {
|
|
11910
|
-
EventBus.emit("showPopoverErrorMessage", {
|
|
11988
|
+
EventBus.emit("showPopoverErrorMessage", {
|
|
11989
|
+
showPopover: true,
|
|
11990
|
+
message,
|
|
11991
|
+
uid: dfcUID,
|
|
11992
|
+
popPosition,
|
|
11993
|
+
updateOn
|
|
11994
|
+
});
|
|
11911
11995
|
return;
|
|
11912
11996
|
}
|
|
11913
11997
|
tipEl.innerText = "" + message;
|
|
@@ -11929,7 +12013,17 @@ function getFormName(binding) {
|
|
|
11929
12013
|
const key = Object.keys(_refs)[0];
|
|
11930
12014
|
return _refs[key]["name"];
|
|
11931
12015
|
}
|
|
11932
|
-
function validateFn({
|
|
12016
|
+
function validateFn({
|
|
12017
|
+
validator,
|
|
12018
|
+
modelValue,
|
|
12019
|
+
el,
|
|
12020
|
+
tipEl,
|
|
12021
|
+
isFormTag,
|
|
12022
|
+
messageShowType,
|
|
12023
|
+
dfcUID,
|
|
12024
|
+
popPosition,
|
|
12025
|
+
updateOn
|
|
12026
|
+
}) {
|
|
11933
12027
|
validator.validate({ modelName: modelValue }).then(() => {
|
|
11934
12028
|
handleValidatePass(el, tipEl);
|
|
11935
12029
|
}).catch((err) => {
|
|
@@ -11947,7 +12041,20 @@ function validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowTy
|
|
|
11947
12041
|
});
|
|
11948
12042
|
}
|
|
11949
12043
|
function checkValidPopsition(positionStr) {
|
|
11950
|
-
const validPosition = [
|
|
12044
|
+
const validPosition = [
|
|
12045
|
+
"left",
|
|
12046
|
+
"right",
|
|
12047
|
+
"top",
|
|
12048
|
+
"bottom",
|
|
12049
|
+
"left-top",
|
|
12050
|
+
"left-bottom",
|
|
12051
|
+
"top-left",
|
|
12052
|
+
"top-right",
|
|
12053
|
+
"right-top",
|
|
12054
|
+
"right-bottom",
|
|
12055
|
+
"bottom-left",
|
|
12056
|
+
"bottom-right"
|
|
12057
|
+
];
|
|
11951
12058
|
const isValid = validPosition.includes(positionStr);
|
|
11952
12059
|
!isValid && console.warn(`invalid popPosition value '${positionStr}'.`);
|
|
11953
12060
|
return isValid;
|
|
@@ -11959,11 +12066,7 @@ var dValidateRules = {
|
|
|
11959
12066
|
const dfcUID = el.parentNode.parentNode.parentElement.dataset.uid;
|
|
11960
12067
|
const refName = getRefName(binding);
|
|
11961
12068
|
const hasOptions = isObject(binding.value) && hasKey(binding.value, "options");
|
|
11962
|
-
let {
|
|
11963
|
-
rules: bindingRules,
|
|
11964
|
-
options = {},
|
|
11965
|
-
messageShowType = "popover"
|
|
11966
|
-
} = binding.value;
|
|
12069
|
+
let { rules: bindingRules, options = {}, messageShowType = "popover" } = binding.value;
|
|
11967
12070
|
let { errorStrategy } = binding.value;
|
|
11968
12071
|
if (refName) {
|
|
11969
12072
|
messageShowType = (_a = binding.instance[refName]["messageShowType"]) != null ? _a : "popover";
|
|
@@ -12042,7 +12145,13 @@ var dValidateRules = {
|
|
|
12042
12145
|
const htmlEventValidateHandler = (e) => {
|
|
12043
12146
|
const modelValue = e.target.value;
|
|
12044
12147
|
if (messageShowType === "popover") {
|
|
12045
|
-
EventBus.emit("showPopoverErrorMessage", {
|
|
12148
|
+
EventBus.emit("showPopoverErrorMessage", {
|
|
12149
|
+
showPopover: false,
|
|
12150
|
+
message: "",
|
|
12151
|
+
uid: dfcUID,
|
|
12152
|
+
popPosition,
|
|
12153
|
+
updateOn
|
|
12154
|
+
});
|
|
12046
12155
|
}
|
|
12047
12156
|
validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition, updateOn });
|
|
12048
12157
|
};
|
|
@@ -12063,32 +12172,17 @@ var dValidateRules = {
|
|
|
12063
12172
|
});
|
|
12064
12173
|
}
|
|
12065
12174
|
};
|
|
12066
|
-
Form.install = function(app) {
|
|
12067
|
-
app.component(Form.name, Form);
|
|
12068
|
-
app.directive("d-validate-rules", dValidateRules);
|
|
12069
|
-
};
|
|
12070
|
-
FormLabel.install = function(app) {
|
|
12071
|
-
app.component(FormLabel.name, FormLabel);
|
|
12072
|
-
};
|
|
12073
|
-
FormItem.install = function(app) {
|
|
12074
|
-
app.component(FormItem.name, FormItem);
|
|
12075
|
-
};
|
|
12076
|
-
FormControl.install = function(app) {
|
|
12077
|
-
app.component(FormControl.name, FormControl);
|
|
12078
|
-
};
|
|
12079
|
-
FormOperation.install = function(app) {
|
|
12080
|
-
app.component(FormOperation.name, FormOperation);
|
|
12081
|
-
};
|
|
12082
12175
|
var FormInstall = {
|
|
12083
12176
|
title: "Form \u8868\u5355",
|
|
12084
12177
|
category: "\u6570\u636E\u5F55\u5165",
|
|
12085
12178
|
status: "75%",
|
|
12086
12179
|
install(app) {
|
|
12087
|
-
app.
|
|
12088
|
-
app.
|
|
12089
|
-
app.
|
|
12090
|
-
app.
|
|
12091
|
-
app.
|
|
12180
|
+
app.component(Form.name, Form);
|
|
12181
|
+
app.directive("d-validate-rules", dValidateRules);
|
|
12182
|
+
app.component(FormLabel.name, FormLabel);
|
|
12183
|
+
app.component(FormItem.name, FormItem);
|
|
12184
|
+
app.component(FormControl.name, FormControl);
|
|
12185
|
+
app.component(FormOperation.name, FormOperation);
|
|
12092
12186
|
}
|
|
12093
12187
|
};
|
|
12094
12188
|
const fullscreenProps = {
|
|
@@ -13023,7 +13117,7 @@ var InputNumber = defineComponent({
|
|
|
13023
13117
|
props: inputNumberProps,
|
|
13024
13118
|
emits: ["update:modelValue", "change", "input", "focus", "blur", "keydown"],
|
|
13025
13119
|
setup(props, ctx2) {
|
|
13026
|
-
const inputVal = ref(props.modelValue);
|
|
13120
|
+
const inputVal = ref(props.modelValue < props.min ? props.min : props.modelValue);
|
|
13027
13121
|
const focusVal = ref("");
|
|
13028
13122
|
const isSize = computed(() => {
|
|
13029
13123
|
return `devui-input-number-${props.size}`;
|
|
@@ -13038,7 +13132,18 @@ var InputNumber = defineComponent({
|
|
|
13038
13132
|
if (inputVal.value >= props.max) {
|
|
13039
13133
|
return;
|
|
13040
13134
|
}
|
|
13041
|
-
|
|
13135
|
+
if (props.step !== 0) {
|
|
13136
|
+
const maxSpaceVal = props.max - inputVal.value;
|
|
13137
|
+
if (inputVal.value < props.max && maxSpaceVal < props.step) {
|
|
13138
|
+
inputVal.value += maxSpaceVal;
|
|
13139
|
+
} else if (inputVal.value < props.max && maxSpaceVal > props.step) {
|
|
13140
|
+
inputVal.value += props.step;
|
|
13141
|
+
} else {
|
|
13142
|
+
inputVal.value += props.step;
|
|
13143
|
+
}
|
|
13144
|
+
} else {
|
|
13145
|
+
inputVal.value += 1;
|
|
13146
|
+
}
|
|
13042
13147
|
focusVal.value = "active";
|
|
13043
13148
|
ctx2.emit("change", inputVal.value);
|
|
13044
13149
|
ctx2.emit("update:modelValue", inputVal.value);
|
|
@@ -13050,15 +13155,26 @@ var InputNumber = defineComponent({
|
|
|
13050
13155
|
if (inputVal.value <= props.min) {
|
|
13051
13156
|
return;
|
|
13052
13157
|
}
|
|
13053
|
-
|
|
13158
|
+
if (props.step !== 0) {
|
|
13159
|
+
const minSpaceVal = inputVal.value - props.min;
|
|
13160
|
+
if (inputVal.value > props.min && minSpaceVal > props.step) {
|
|
13161
|
+
inputVal.value -= props.step;
|
|
13162
|
+
} else if (inputVal.value > props.min && minSpaceVal < props.step) {
|
|
13163
|
+
inputVal.value -= minSpaceVal;
|
|
13164
|
+
} else {
|
|
13165
|
+
inputVal.value -= props.step;
|
|
13166
|
+
}
|
|
13167
|
+
} else {
|
|
13168
|
+
inputVal.value -= 1;
|
|
13169
|
+
}
|
|
13054
13170
|
focusVal.value = "active";
|
|
13055
13171
|
ctx2.emit("change", inputVal.value);
|
|
13056
13172
|
ctx2.emit("update:modelValue", inputVal.value);
|
|
13057
13173
|
};
|
|
13058
13174
|
const onInput = (val) => {
|
|
13059
13175
|
inputVal.value = parseInt(val.data);
|
|
13060
|
-
ctx2.emit("input",
|
|
13061
|
-
ctx2.emit("update:modelValue",
|
|
13176
|
+
ctx2.emit("input", inputVal.value);
|
|
13177
|
+
ctx2.emit("update:modelValue", inputVal.value);
|
|
13062
13178
|
};
|
|
13063
13179
|
const onFocus = ($event) => {
|
|
13064
13180
|
focusVal.value = "active";
|
|
@@ -13731,7 +13847,7 @@ var Notification = defineComponent({
|
|
|
13731
13847
|
});
|
|
13732
13848
|
}
|
|
13733
13849
|
});
|
|
13734
|
-
function _isSlot$
|
|
13850
|
+
function _isSlot$2(s) {
|
|
13735
13851
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
13736
13852
|
}
|
|
13737
13853
|
const defaultOptions = {
|
|
@@ -13748,7 +13864,7 @@ function initInstance(props, content2) {
|
|
|
13748
13864
|
});
|
|
13749
13865
|
return () => createVNode(Notification, mergeProps(props, {
|
|
13750
13866
|
"onDestroy": app.unmount
|
|
13751
|
-
}), _isSlot$
|
|
13867
|
+
}), _isSlot$2(content2) ? content2 : {
|
|
13752
13868
|
default: () => [content2]
|
|
13753
13869
|
});
|
|
13754
13870
|
}
|
|
@@ -14152,9 +14268,9 @@ var PageNumBtn = defineComponent({
|
|
|
14152
14268
|
"class": "devui-pagination-link"
|
|
14153
14269
|
}, [createTextVNode("...")])]),
|
|
14154
14270
|
(() => {
|
|
14155
|
-
const
|
|
14271
|
+
const list2 = [];
|
|
14156
14272
|
for (let i = showPageNum[0]; i <= showPageNum[1]; i++) {
|
|
14157
|
-
|
|
14273
|
+
list2.push(createVNode("li", {
|
|
14158
14274
|
"onClick": changeCursor.bind(null, i),
|
|
14159
14275
|
"key": i,
|
|
14160
14276
|
"class": {
|
|
@@ -14165,7 +14281,7 @@ var PageNumBtn = defineComponent({
|
|
|
14165
14281
|
"class": "devui-pagination-link"
|
|
14166
14282
|
}, [i])]));
|
|
14167
14283
|
}
|
|
14168
|
-
return
|
|
14284
|
+
return list2;
|
|
14169
14285
|
})(),
|
|
14170
14286
|
showPageNum[1] < totalPages - 1 && createVNode("li", {
|
|
14171
14287
|
"onClick": nextChange.bind(null, showPageNum[1] + 1),
|
|
@@ -14878,7 +14994,7 @@ var Radio = defineComponent({
|
|
|
14878
14994
|
}
|
|
14879
14995
|
});
|
|
14880
14996
|
var radioGroup = "";
|
|
14881
|
-
function _isSlot(s) {
|
|
14997
|
+
function _isSlot$1(s) {
|
|
14882
14998
|
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
14883
14999
|
}
|
|
14884
15000
|
var RadioGroup = defineComponent({
|
|
@@ -14914,7 +15030,7 @@ var RadioGroup = defineComponent({
|
|
|
14914
15030
|
return createVNode(Radio, {
|
|
14915
15031
|
"key": item,
|
|
14916
15032
|
"value": item
|
|
14917
|
-
}, _isSlot(item) ? item : {
|
|
15033
|
+
}, _isSlot$1(item) ? item : {
|
|
14918
15034
|
default: () => [item]
|
|
14919
15035
|
});
|
|
14920
15036
|
});
|
|
@@ -16399,6 +16515,10 @@ const sliderProps = {
|
|
|
16399
16515
|
tipsRenderer: {
|
|
16400
16516
|
type: String,
|
|
16401
16517
|
default: ""
|
|
16518
|
+
},
|
|
16519
|
+
color: {
|
|
16520
|
+
type: String,
|
|
16521
|
+
default: ""
|
|
16402
16522
|
}
|
|
16403
16523
|
};
|
|
16404
16524
|
var slider = "";
|
|
@@ -16433,7 +16553,8 @@ var Slider = defineComponent({
|
|
|
16433
16553
|
}
|
|
16434
16554
|
}
|
|
16435
16555
|
function setPostion(newPosition) {
|
|
16436
|
-
const
|
|
16556
|
+
const clientWidth = !!sliderRunway.value ? sliderRunway.value.clientWidth : 0;
|
|
16557
|
+
const sliderWidth = Math.round(clientWidth);
|
|
16437
16558
|
if (newPosition < 0) {
|
|
16438
16559
|
newPosition = 0;
|
|
16439
16560
|
}
|
|
@@ -16478,7 +16599,8 @@ var Slider = defineComponent({
|
|
|
16478
16599
|
"class": "devui-input__out-wrap"
|
|
16479
16600
|
}, [createVNode("input", {
|
|
16480
16601
|
"onInput": handleOnInput,
|
|
16481
|
-
"value": inputValue.value + ""
|
|
16602
|
+
"value": inputValue.value + "",
|
|
16603
|
+
"disabled": props.disabled
|
|
16482
16604
|
}, null)]) : "";
|
|
16483
16605
|
};
|
|
16484
16606
|
if (props.modelValue > props.max) {
|
|
@@ -16489,7 +16611,7 @@ var Slider = defineComponent({
|
|
|
16489
16611
|
percentDispaly.value = (props.modelValue - props.min) * 100 / (props.max - props.min) + "%";
|
|
16490
16612
|
}
|
|
16491
16613
|
onMounted(() => {
|
|
16492
|
-
const sliderWidth = sliderRunway.value.clientWidth;
|
|
16614
|
+
const sliderWidth = !!sliderRunway.value ? sliderRunway.value.clientWidth : 0;
|
|
16493
16615
|
currentPosition.value = sliderWidth * (inputValue.value - props.min) / (props.max - props.min);
|
|
16494
16616
|
});
|
|
16495
16617
|
function handleButtonMousedown(event) {
|
|
@@ -16504,7 +16626,8 @@ var Slider = defineComponent({
|
|
|
16504
16626
|
}
|
|
16505
16627
|
function handleRunwayMousedown(event) {
|
|
16506
16628
|
if (!props.disabled && isClick) {
|
|
16507
|
-
|
|
16629
|
+
const _e = event.target;
|
|
16630
|
+
startX = _e.getBoundingClientRect().left;
|
|
16508
16631
|
const currentX = event.clientX;
|
|
16509
16632
|
setPostion(currentX - startX);
|
|
16510
16633
|
handleButtonMousedown(event);
|
|
@@ -16528,6 +16651,9 @@ var Slider = defineComponent({
|
|
|
16528
16651
|
"class": "devui-slider_popover-content"
|
|
16529
16652
|
}, [inputValue.value + " " + props.tipsRenderer])]);
|
|
16530
16653
|
};
|
|
16654
|
+
const color = computed(() => {
|
|
16655
|
+
return props.disabled ? "" : props.color;
|
|
16656
|
+
});
|
|
16531
16657
|
return () => createVNode("div", {
|
|
16532
16658
|
"class": "devui-slider"
|
|
16533
16659
|
}, [createVNode("div", {
|
|
@@ -16538,12 +16664,14 @@ var Slider = defineComponent({
|
|
|
16538
16664
|
}, [createVNode("div", {
|
|
16539
16665
|
"class": "devui-slider__bar" + disableClass.value,
|
|
16540
16666
|
"style": {
|
|
16541
|
-
width: percentDispaly.value
|
|
16667
|
+
width: percentDispaly.value,
|
|
16668
|
+
backgroundColor: color.value
|
|
16542
16669
|
}
|
|
16543
16670
|
}, null), createVNode("div", {
|
|
16544
16671
|
"class": "devui-slider__button" + disableClass.value,
|
|
16545
16672
|
"style": {
|
|
16546
|
-
left: percentDispaly.value
|
|
16673
|
+
left: percentDispaly.value,
|
|
16674
|
+
borderColor: color.value
|
|
16547
16675
|
},
|
|
16548
16676
|
"onMousedown": handleButtonMousedown,
|
|
16549
16677
|
"onMouseenter": () => popoverShow.value = true,
|
|
@@ -17815,29 +17943,6 @@ const TableProps = {
|
|
|
17815
17943
|
}
|
|
17816
17944
|
};
|
|
17817
17945
|
const TABLE_TOKEN = Symbol();
|
|
17818
|
-
function createBem(namespace, element, modifier) {
|
|
17819
|
-
let cls = namespace;
|
|
17820
|
-
if (element) {
|
|
17821
|
-
cls += `__${element}`;
|
|
17822
|
-
}
|
|
17823
|
-
if (modifier) {
|
|
17824
|
-
cls += `--${modifier}`;
|
|
17825
|
-
}
|
|
17826
|
-
return cls;
|
|
17827
|
-
}
|
|
17828
|
-
function useNamespace(block) {
|
|
17829
|
-
const namespace = `devui-${block}`;
|
|
17830
|
-
const b = () => createBem(namespace);
|
|
17831
|
-
const e = (element) => element ? createBem(namespace, element) : "";
|
|
17832
|
-
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
17833
|
-
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
17834
|
-
return {
|
|
17835
|
-
b,
|
|
17836
|
-
e,
|
|
17837
|
-
m,
|
|
17838
|
-
em
|
|
17839
|
-
};
|
|
17840
|
-
}
|
|
17841
17946
|
function useTable(props) {
|
|
17842
17947
|
const ns = useNamespace("table");
|
|
17843
17948
|
const classes = computed(() => ({
|
|
@@ -17940,15 +18045,15 @@ const createSelection = (dataSource, _data) => {
|
|
|
17940
18045
|
watch(dataSource, (value) => {
|
|
17941
18046
|
_checkList.value = new Array(value.length).fill(false);
|
|
17942
18047
|
}, { deep: true, immediate: true });
|
|
17943
|
-
watch(_checkList, (
|
|
17944
|
-
if (
|
|
18048
|
+
watch(_checkList, (list2) => {
|
|
18049
|
+
if (list2.length === 0) {
|
|
17945
18050
|
return;
|
|
17946
18051
|
}
|
|
17947
18052
|
let allTrue = true;
|
|
17948
18053
|
let allFalse = true;
|
|
17949
|
-
for (let i = 0; i <
|
|
17950
|
-
allTrue && (allTrue =
|
|
17951
|
-
allFalse && (allFalse = !
|
|
18054
|
+
for (let i = 0; i < list2.length; i++) {
|
|
18055
|
+
allTrue && (allTrue = list2[i]);
|
|
18056
|
+
allFalse && (allFalse = !list2[i]);
|
|
17952
18057
|
}
|
|
17953
18058
|
_checkAllRecord.value = allTrue;
|
|
17954
18059
|
_halfChecked.value = !(allFalse || allTrue);
|
|
@@ -17976,23 +18081,6 @@ const createSorter = (dataSource, _data) => {
|
|
|
17976
18081
|
const thList = [];
|
|
17977
18082
|
return { sortData, thList };
|
|
17978
18083
|
};
|
|
17979
|
-
const createFilter = (dataSource, _data) => {
|
|
17980
|
-
const fieldSet = /* @__PURE__ */ new Set();
|
|
17981
|
-
const filterData = (field, results2) => {
|
|
17982
|
-
fieldSet.add(field);
|
|
17983
|
-
const fields = [...fieldSet];
|
|
17984
|
-
_data.value = dataSource.value.filter((item) => {
|
|
17985
|
-
return fields.reduce((prev, fieldKey) => {
|
|
17986
|
-
return prev && results2.indexOf(item[fieldKey]) !== -1;
|
|
17987
|
-
}, true);
|
|
17988
|
-
});
|
|
17989
|
-
};
|
|
17990
|
-
const resetFilterData = () => {
|
|
17991
|
-
fieldSet.clear();
|
|
17992
|
-
_data.value = [...dataSource.value];
|
|
17993
|
-
};
|
|
17994
|
-
return { filterData, resetFilterData };
|
|
17995
|
-
};
|
|
17996
18084
|
const createFixedLogic = (columns) => {
|
|
17997
18085
|
const isFixedLeft = computed(() => {
|
|
17998
18086
|
return columns.value.reduce((prev, current) => prev || !!current.fixedLeft, false);
|
|
@@ -18007,7 +18095,6 @@ function createStore(dataSource) {
|
|
|
18007
18095
|
const { _columns, flatColumns, insertColumn, removeColumn, sortColumn, updateColumns } = createColumnGenerator();
|
|
18008
18096
|
const { _checkAll, _checkList, _halfChecked, getCheckedRows } = createSelection(dataSource, _data);
|
|
18009
18097
|
const { sortData, thList } = createSorter(dataSource, _data);
|
|
18010
|
-
const { filterData, resetFilterData } = createFilter(dataSource, _data);
|
|
18011
18098
|
const { isFixedLeft } = createFixedLogic(_columns);
|
|
18012
18099
|
return {
|
|
18013
18100
|
states: {
|
|
@@ -18025,9 +18112,7 @@ function createStore(dataSource) {
|
|
|
18025
18112
|
removeColumn,
|
|
18026
18113
|
updateColumns,
|
|
18027
18114
|
getCheckedRows,
|
|
18028
|
-
sortData
|
|
18029
|
-
filterData,
|
|
18030
|
-
resetFilterData
|
|
18115
|
+
sortData
|
|
18031
18116
|
};
|
|
18032
18117
|
}
|
|
18033
18118
|
var ColGroup = defineComponent({
|
|
@@ -18117,99 +18202,252 @@ var Sort = defineComponent({
|
|
|
18117
18202
|
}, null)])])])]);
|
|
18118
18203
|
}
|
|
18119
18204
|
});
|
|
18120
|
-
|
|
18121
|
-
|
|
18205
|
+
const filterProps = {
|
|
18206
|
+
filterList: {
|
|
18207
|
+
type: Array,
|
|
18208
|
+
default: () => []
|
|
18209
|
+
},
|
|
18210
|
+
multiple: {
|
|
18211
|
+
type: Boolean,
|
|
18212
|
+
default: true
|
|
18213
|
+
}
|
|
18214
|
+
};
|
|
18215
|
+
function useFilterRender(ctx2) {
|
|
18216
|
+
const showMenu = ref(false);
|
|
18217
|
+
const filterMenuRef = ref(null);
|
|
18218
|
+
const filterIconRef = ref(null);
|
|
18219
|
+
const singleVal = ref(null);
|
|
18220
|
+
const multipleVal = ref(null);
|
|
18221
|
+
const handleIconClick = () => {
|
|
18222
|
+
showMenu.value = !showMenu.value;
|
|
18223
|
+
};
|
|
18224
|
+
const handleConfirm = (val) => {
|
|
18225
|
+
showMenu.value = false;
|
|
18226
|
+
multipleVal.value = val;
|
|
18227
|
+
ctx2.emit("filter", val);
|
|
18228
|
+
};
|
|
18229
|
+
const handleSelect = (val) => {
|
|
18230
|
+
showMenu.value = false;
|
|
18231
|
+
singleVal.value = val;
|
|
18232
|
+
ctx2.emit("filter", val);
|
|
18233
|
+
};
|
|
18234
|
+
const iconClasses = computed(() => {
|
|
18235
|
+
var _a;
|
|
18236
|
+
return {
|
|
18237
|
+
"filter-icon": true,
|
|
18238
|
+
"filter-icon-active": Boolean(singleVal.value || ((_a = multipleVal.value) == null ? void 0 : _a.length))
|
|
18239
|
+
};
|
|
18240
|
+
});
|
|
18241
|
+
onClickOutside(filterMenuRef, () => {
|
|
18242
|
+
showMenu.value = false;
|
|
18243
|
+
}, {
|
|
18244
|
+
ignore: [filterIconRef]
|
|
18245
|
+
});
|
|
18246
|
+
return { showMenu, filterMenuRef, filterIconRef, iconClasses, handleIconClick, handleConfirm, handleSelect };
|
|
18247
|
+
}
|
|
18248
|
+
function useFilterMultiple(filterList, ctx2) {
|
|
18249
|
+
const _checkList = ref([]);
|
|
18250
|
+
const _checkAllRecord = ref(false);
|
|
18251
|
+
const _checkAll = computed({
|
|
18252
|
+
get: () => _checkAllRecord.value,
|
|
18253
|
+
set: (val) => {
|
|
18254
|
+
_checkAllRecord.value = val;
|
|
18255
|
+
for (let i = 0; i < _checkList.value.length; i++) {
|
|
18256
|
+
_checkList.value[i].checked = val;
|
|
18257
|
+
}
|
|
18258
|
+
}
|
|
18259
|
+
});
|
|
18260
|
+
const _halfChecked = ref(false);
|
|
18261
|
+
filterList == null ? void 0 : filterList.forEach((item) => {
|
|
18262
|
+
_checkList.value.push(__spreadValues({ checked: false }, item));
|
|
18263
|
+
});
|
|
18264
|
+
watch(_checkList, (list2) => {
|
|
18265
|
+
if (!list2.length) {
|
|
18266
|
+
return;
|
|
18267
|
+
}
|
|
18268
|
+
let allTrue = true;
|
|
18269
|
+
let allFalse = true;
|
|
18270
|
+
for (let i = 0; i < list2.length; i++) {
|
|
18271
|
+
allTrue && (allTrue = Boolean(list2[i].checked));
|
|
18272
|
+
allFalse && (allFalse = Boolean(!list2[i].checked));
|
|
18273
|
+
}
|
|
18274
|
+
_checkAllRecord.value = allTrue;
|
|
18275
|
+
_halfChecked.value = !(allFalse || allTrue);
|
|
18276
|
+
}, { immediate: true, deep: true });
|
|
18277
|
+
const getCheckedItems = () => {
|
|
18278
|
+
return _checkList.value.filter((item) => item.checked);
|
|
18279
|
+
};
|
|
18280
|
+
const handleConfirm = () => {
|
|
18281
|
+
ctx2.emit("confirm", getCheckedItems());
|
|
18282
|
+
};
|
|
18283
|
+
return { _checkList, _checkAll, _halfChecked, handleConfirm };
|
|
18284
|
+
}
|
|
18285
|
+
function useFilterSingle(ctx2) {
|
|
18286
|
+
const selectedItem = ref(null);
|
|
18287
|
+
const handleSelect = (val) => {
|
|
18288
|
+
selectedItem.value = val;
|
|
18289
|
+
ctx2.emit("select", val);
|
|
18290
|
+
};
|
|
18291
|
+
return { selectedItem, handleSelect };
|
|
18292
|
+
}
|
|
18293
|
+
var MultipleFilter = defineComponent({
|
|
18122
18294
|
props: {
|
|
18123
|
-
modelValue: {
|
|
18124
|
-
type: Array,
|
|
18125
|
-
default: []
|
|
18126
|
-
},
|
|
18127
|
-
"onUpdate:modelValue": {
|
|
18128
|
-
type: Function
|
|
18129
|
-
},
|
|
18130
|
-
customTemplate: {
|
|
18131
|
-
type: Function
|
|
18132
|
-
},
|
|
18133
18295
|
filterList: {
|
|
18134
18296
|
type: Array,
|
|
18135
|
-
|
|
18136
|
-
},
|
|
18137
|
-
filterMultiple: {
|
|
18138
|
-
type: Boolean,
|
|
18139
|
-
default: true
|
|
18297
|
+
default: () => []
|
|
18140
18298
|
}
|
|
18141
18299
|
},
|
|
18142
|
-
emits: ["
|
|
18143
|
-
setup(props) {
|
|
18144
|
-
const
|
|
18145
|
-
|
|
18146
|
-
|
|
18147
|
-
|
|
18148
|
-
|
|
18149
|
-
|
|
18150
|
-
|
|
18151
|
-
|
|
18152
|
-
|
|
18153
|
-
|
|
18154
|
-
}
|
|
18155
|
-
|
|
18300
|
+
emits: ["confirm"],
|
|
18301
|
+
setup(props, ctx2) {
|
|
18302
|
+
const {
|
|
18303
|
+
_checkList,
|
|
18304
|
+
_checkAll,
|
|
18305
|
+
_halfChecked,
|
|
18306
|
+
handleConfirm
|
|
18307
|
+
} = useFilterMultiple(props.filterList, ctx2);
|
|
18308
|
+
return () => createVNode(Fragment, null, [createVNode("div", {
|
|
18309
|
+
"class": "filter-all-check"
|
|
18310
|
+
}, [createVNode("div", {
|
|
18311
|
+
"class": "filter-item"
|
|
18312
|
+
}, [createVNode(Checkbox, {
|
|
18313
|
+
"modelValue": _checkAll.value,
|
|
18314
|
+
"onUpdate:modelValue": ($event) => _checkAll.value = $event,
|
|
18315
|
+
"halfchecked": _halfChecked.value,
|
|
18316
|
+
"label": "\u5168\u9009"
|
|
18317
|
+
}, null)])]), createVNode("div", {
|
|
18318
|
+
"class": "filter-multiple-menu"
|
|
18319
|
+
}, [_checkList.value.map((item) => createVNode("div", {
|
|
18320
|
+
"class": "filter-item"
|
|
18321
|
+
}, [createVNode(Checkbox, {
|
|
18322
|
+
"modelValue": item.checked,
|
|
18323
|
+
"onUpdate:modelValue": ($event) => item.checked = $event,
|
|
18324
|
+
"label": item.name
|
|
18325
|
+
}, null)]))]), createVNode("div", {
|
|
18326
|
+
"class": "filter-operation"
|
|
18327
|
+
}, [createVNode(Button, {
|
|
18328
|
+
"variant": "text",
|
|
18329
|
+
"onClick": handleConfirm
|
|
18330
|
+
}, {
|
|
18331
|
+
default: () => [createTextVNode("\u786E\u5B9A")]
|
|
18332
|
+
})])]);
|
|
18333
|
+
}
|
|
18334
|
+
});
|
|
18335
|
+
var list = "";
|
|
18336
|
+
var List = defineComponent({
|
|
18337
|
+
name: "DList",
|
|
18338
|
+
setup(props, {
|
|
18339
|
+
slots
|
|
18340
|
+
}) {
|
|
18341
|
+
return () => {
|
|
18156
18342
|
var _a;
|
|
18157
|
-
(
|
|
18158
|
-
|
|
18159
|
-
|
|
18160
|
-
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18164
|
-
|
|
18165
|
-
|
|
18166
|
-
|
|
18167
|
-
|
|
18168
|
-
|
|
18169
|
-
|
|
18170
|
-
|
|
18171
|
-
|
|
18172
|
-
|
|
18173
|
-
|
|
18174
|
-
|
|
18175
|
-
|
|
18343
|
+
return createVNode("div", {
|
|
18344
|
+
"class": "devui-list"
|
|
18345
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
18346
|
+
};
|
|
18347
|
+
}
|
|
18348
|
+
});
|
|
18349
|
+
var listItem = "";
|
|
18350
|
+
var ListItem = defineComponent({
|
|
18351
|
+
name: "DListItem",
|
|
18352
|
+
setup(props, {
|
|
18353
|
+
slots
|
|
18354
|
+
}) {
|
|
18355
|
+
return () => {
|
|
18356
|
+
var _a;
|
|
18357
|
+
return createVNode("div", {
|
|
18358
|
+
"class": "devui-list-item"
|
|
18359
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
18360
|
+
};
|
|
18361
|
+
}
|
|
18362
|
+
});
|
|
18363
|
+
function _isSlot(s) {
|
|
18364
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
18365
|
+
}
|
|
18366
|
+
var SingleFilter = defineComponent({
|
|
18367
|
+
props: {
|
|
18368
|
+
filterList: {
|
|
18369
|
+
type: Array,
|
|
18370
|
+
default: () => []
|
|
18371
|
+
}
|
|
18372
|
+
},
|
|
18373
|
+
emits: ["select"],
|
|
18374
|
+
setup(props, ctx2) {
|
|
18375
|
+
const {
|
|
18376
|
+
selectedItem,
|
|
18377
|
+
handleSelect
|
|
18378
|
+
} = useFilterSingle(ctx2);
|
|
18379
|
+
return () => {
|
|
18380
|
+
let _slot;
|
|
18381
|
+
return createVNode(Fragment, null, [createVNode(List, {
|
|
18382
|
+
"class": "filter-single-menu"
|
|
18383
|
+
}, _isSlot(_slot = props.filterList.map((item) => createVNode(ListItem, {
|
|
18384
|
+
"class": ["filter-item", {
|
|
18385
|
+
"filter-item-active": selectedItem.value === item
|
|
18386
|
+
}],
|
|
18387
|
+
"onClick": () => {
|
|
18388
|
+
handleSelect(item);
|
|
18389
|
+
}
|
|
18390
|
+
}, {
|
|
18391
|
+
default: () => [item.name]
|
|
18392
|
+
}))) ? _slot : {
|
|
18393
|
+
default: () => [_slot]
|
|
18176
18394
|
})]);
|
|
18177
|
-
}
|
|
18178
|
-
|
|
18179
|
-
|
|
18180
|
-
|
|
18181
|
-
|
|
18182
|
-
|
|
18183
|
-
|
|
18184
|
-
|
|
18185
|
-
|
|
18186
|
-
|
|
18187
|
-
|
|
18188
|
-
|
|
18189
|
-
|
|
18190
|
-
|
|
18191
|
-
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
"
|
|
18196
|
-
|
|
18197
|
-
"
|
|
18198
|
-
|
|
18199
|
-
"
|
|
18200
|
-
"closeScope": "blank"
|
|
18395
|
+
};
|
|
18396
|
+
}
|
|
18397
|
+
});
|
|
18398
|
+
var filter = "";
|
|
18399
|
+
var Filter = defineComponent({
|
|
18400
|
+
props: filterProps,
|
|
18401
|
+
emits: ["filter"],
|
|
18402
|
+
setup(props, ctx2) {
|
|
18403
|
+
const {
|
|
18404
|
+
showMenu,
|
|
18405
|
+
filterMenuRef,
|
|
18406
|
+
filterIconRef,
|
|
18407
|
+
iconClasses,
|
|
18408
|
+
handleIconClick,
|
|
18409
|
+
handleConfirm,
|
|
18410
|
+
handleSelect
|
|
18411
|
+
} = useFilterRender(ctx2);
|
|
18412
|
+
return () => createVNode(Dropdown, {
|
|
18413
|
+
"visible": showMenu.value,
|
|
18414
|
+
"trigger": "manually",
|
|
18415
|
+
"close-scope": "none",
|
|
18416
|
+
"destroy-on-hide": false,
|
|
18417
|
+
"style": "padding-bottom: 4px;"
|
|
18201
18418
|
}, {
|
|
18202
|
-
default: () => {
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18419
|
+
default: () => createVNode("i", {
|
|
18420
|
+
"ref": filterIconRef,
|
|
18421
|
+
"class": iconClasses.value,
|
|
18422
|
+
"onClick": handleIconClick
|
|
18423
|
+
}, [createVNode("svg", {
|
|
18424
|
+
"width": "16px",
|
|
18425
|
+
"height": "16px",
|
|
18426
|
+
"viewBox": "0 0 16 16",
|
|
18427
|
+
"version": "1.1",
|
|
18428
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
18429
|
+
}, [createVNode("g", {
|
|
18430
|
+
"stroke": "none",
|
|
18431
|
+
"stroke-width": "1",
|
|
18432
|
+
"fill": "none",
|
|
18433
|
+
"fill-rule": "evenodd"
|
|
18434
|
+
}, [createVNode("g", null, [createVNode("polygon", {
|
|
18435
|
+
"points": "10.0085775 7 10.0085775 15 6 13 6 7 2 3 2 1 14 1 14 3"
|
|
18436
|
+
}, null)])])])]),
|
|
18437
|
+
menu: () => createVNode("div", {
|
|
18438
|
+
"ref": filterMenuRef,
|
|
18439
|
+
"class": "filter-wrapper"
|
|
18440
|
+
}, [props.multiple ? createVNode(MultipleFilter, {
|
|
18441
|
+
"filterList": props.filterList,
|
|
18442
|
+
"onConfirm": handleConfirm
|
|
18443
|
+
}, null) : createVNode(SingleFilter, {
|
|
18444
|
+
"filterList": props.filterList,
|
|
18445
|
+
"onSelect": handleSelect
|
|
18446
|
+
}, null)])
|
|
18447
|
+
});
|
|
18210
18448
|
}
|
|
18211
18449
|
});
|
|
18212
|
-
|
|
18450
|
+
function useSort(column) {
|
|
18213
18451
|
const table2 = inject(TABLE_TOKEN);
|
|
18214
18452
|
const store = table2.store;
|
|
18215
18453
|
const direction = ref(column.value.sortDirection);
|
|
@@ -18241,14 +18479,18 @@ const useSort = (column) => {
|
|
|
18241
18479
|
direction.value = "";
|
|
18242
18480
|
};
|
|
18243
18481
|
return { direction, sortClass, handleSort, clearSortOrder };
|
|
18244
|
-
}
|
|
18245
|
-
|
|
18246
|
-
const
|
|
18247
|
-
|
|
18248
|
-
|
|
18249
|
-
});
|
|
18250
|
-
|
|
18251
|
-
|
|
18482
|
+
}
|
|
18483
|
+
function useFilter(column) {
|
|
18484
|
+
const filter2 = ref(null);
|
|
18485
|
+
const filterClass = computed(() => ({
|
|
18486
|
+
"filter-active": Boolean(filter2.value || Array.isArray(filter2.value) && filter2.value.length)
|
|
18487
|
+
}));
|
|
18488
|
+
const handleFilter = (val) => {
|
|
18489
|
+
filter2.value = val;
|
|
18490
|
+
column.value.ctx.emit("filter-change", val);
|
|
18491
|
+
};
|
|
18492
|
+
return { filterClass, handleFilter };
|
|
18493
|
+
}
|
|
18252
18494
|
var TH = defineComponent({
|
|
18253
18495
|
name: "DTableHeaderTh",
|
|
18254
18496
|
props: {
|
|
@@ -18271,7 +18513,10 @@ var TH = defineComponent({
|
|
|
18271
18513
|
handleSort,
|
|
18272
18514
|
clearSortOrder
|
|
18273
18515
|
} = useSort(column);
|
|
18274
|
-
const
|
|
18516
|
+
const {
|
|
18517
|
+
filterClass,
|
|
18518
|
+
handleFilter
|
|
18519
|
+
} = useFilter(column);
|
|
18275
18520
|
const {
|
|
18276
18521
|
stickyClass,
|
|
18277
18522
|
stickyStyle
|
|
@@ -18282,15 +18527,14 @@ var TH = defineComponent({
|
|
|
18282
18527
|
return () => {
|
|
18283
18528
|
var _a, _b;
|
|
18284
18529
|
return createVNode("th", {
|
|
18285
|
-
"class": [stickyClass.value, sortClass.value],
|
|
18530
|
+
"class": [stickyClass.value, sortClass.value, filterClass.value],
|
|
18286
18531
|
"style": stickyStyle.value
|
|
18287
18532
|
}, [createVNode("div", {
|
|
18288
18533
|
"class": "header-container"
|
|
18289
18534
|
}, [(_b = (_a = column.value).renderHeader) == null ? void 0 : _b.call(_a, column.value, store), column.value.filterable && createVNode(Filter, {
|
|
18290
|
-
"
|
|
18291
|
-
"
|
|
18292
|
-
"
|
|
18293
|
-
"customTemplate": props.column.customFilterTemplate
|
|
18535
|
+
"filterList": column.value.filterList,
|
|
18536
|
+
"multiple": column.value.filterMultiple,
|
|
18537
|
+
"onFilter": handleFilter
|
|
18294
18538
|
}, null), column.value.sortable && createVNode(Sort, {
|
|
18295
18539
|
"sort-direction": direction.value,
|
|
18296
18540
|
"onSort": handleSort
|
|
@@ -18650,7 +18894,7 @@ const tableColumnProps = {
|
|
|
18650
18894
|
},
|
|
18651
18895
|
filterMultiple: {
|
|
18652
18896
|
type: Boolean,
|
|
18653
|
-
default:
|
|
18897
|
+
default: true
|
|
18654
18898
|
},
|
|
18655
18899
|
filterList: {
|
|
18656
18900
|
type: Array,
|
|
@@ -18803,6 +19047,7 @@ let columnIdInit = 1;
|
|
|
18803
19047
|
var Column = defineComponent({
|
|
18804
19048
|
name: "DColumn",
|
|
18805
19049
|
props: tableColumnProps,
|
|
19050
|
+
emits: ["filter-change"],
|
|
18806
19051
|
setup(props, ctx2) {
|
|
18807
19052
|
const instance = getCurrentInstance();
|
|
18808
19053
|
const column = createColumn(toRefs(props), ctx2.slots);
|
|
@@ -18815,6 +19060,7 @@ var Column = defineComponent({
|
|
|
18815
19060
|
} = useRender();
|
|
18816
19061
|
const parent = columnOrTableParent.value;
|
|
18817
19062
|
columnId = `${parent.tableId || parent.columnId}_column_${columnIdInit++}`;
|
|
19063
|
+
column.ctx = ctx2;
|
|
18818
19064
|
onBeforeMount(() => {
|
|
18819
19065
|
isSubColumn.value = owner !== parent;
|
|
18820
19066
|
column.id = columnId;
|
|
@@ -19543,13 +19789,672 @@ var TimelineInstall = {
|
|
|
19543
19789
|
}
|
|
19544
19790
|
};
|
|
19545
19791
|
var TooltipInstall = {
|
|
19546
|
-
title: "Tooltip\u63D0\u793A",
|
|
19792
|
+
title: "Tooltip \u63D0\u793A",
|
|
19547
19793
|
category: "\u53CD\u9988",
|
|
19548
19794
|
status: "70%",
|
|
19549
19795
|
install(app) {
|
|
19550
19796
|
app.component(Tooltip.name, Tooltip);
|
|
19551
19797
|
}
|
|
19552
19798
|
};
|
|
19799
|
+
const USE_TREE_TOKEN = "use-tree-token";
|
|
19800
|
+
const NODE_HEIGHT = 30;
|
|
19801
|
+
const NODE_INDENT = 24;
|
|
19802
|
+
const IconClose = () => createVNode("svg", {
|
|
19803
|
+
"width": "16px",
|
|
19804
|
+
"height": "16px",
|
|
19805
|
+
"viewBox": "0 0 16 16",
|
|
19806
|
+
"version": "1.1",
|
|
19807
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
19808
|
+
"class": "svg-icon"
|
|
19809
|
+
}, [createVNode("g", {
|
|
19810
|
+
"stroke": "none",
|
|
19811
|
+
"stroke-width": "1",
|
|
19812
|
+
"fill": "none",
|
|
19813
|
+
"fill-rule": "evenodd"
|
|
19814
|
+
}, [createVNode("rect", {
|
|
19815
|
+
"x": "0.5",
|
|
19816
|
+
"y": "0.5",
|
|
19817
|
+
"width": "15",
|
|
19818
|
+
"height": "15",
|
|
19819
|
+
"rx": "2",
|
|
19820
|
+
"stroke": "#252b3a"
|
|
19821
|
+
}, null), createVNode("path", {
|
|
19822
|
+
"fill": "#252b3a",
|
|
19823
|
+
"d": "M8.75,4 L8.75,7.25 L12,7.25 L12,8.75 L8.749,8.75 L8.75,12 L7.25,12 L7.249,8.75 L4,8.75 L4,7.25 L7.25,7.25 L7.25,4 L8.75,4 Z"
|
|
19824
|
+
}, null)])]);
|
|
19825
|
+
const IconOpen = () => createVNode("svg", {
|
|
19826
|
+
"width": "16px",
|
|
19827
|
+
"height": "16px",
|
|
19828
|
+
"viewBox": "0 0 16 16",
|
|
19829
|
+
"version": "1.1",
|
|
19830
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
|
19831
|
+
"class": "svg-icon svg-icon-close"
|
|
19832
|
+
}, [createVNode("g", {
|
|
19833
|
+
"stroke-width": "1",
|
|
19834
|
+
"fill": "none",
|
|
19835
|
+
"fill-rule": "evenodd"
|
|
19836
|
+
}, [createVNode("rect", {
|
|
19837
|
+
"x": "0.5",
|
|
19838
|
+
"y": "0.5",
|
|
19839
|
+
"width": "15",
|
|
19840
|
+
"height": "15",
|
|
19841
|
+
"rx": "2",
|
|
19842
|
+
"stroke": "#5e7ce0"
|
|
19843
|
+
}, null), createVNode("rect", {
|
|
19844
|
+
"x": "4",
|
|
19845
|
+
"y": "7",
|
|
19846
|
+
"width": "8",
|
|
19847
|
+
"height": "2",
|
|
19848
|
+
"fill": "#5e7ce0"
|
|
19849
|
+
}, null)])]);
|
|
19850
|
+
var DTreeNodeToggle = defineComponent({
|
|
19851
|
+
name: "DTreeNodeToggle",
|
|
19852
|
+
props: {
|
|
19853
|
+
data: {
|
|
19854
|
+
type: Object,
|
|
19855
|
+
default: () => ({})
|
|
19856
|
+
}
|
|
19857
|
+
},
|
|
19858
|
+
setup(props) {
|
|
19859
|
+
const {
|
|
19860
|
+
data
|
|
19861
|
+
} = toRefs(props);
|
|
19862
|
+
const {
|
|
19863
|
+
toggleNode
|
|
19864
|
+
} = inject(USE_TREE_TOKEN);
|
|
19865
|
+
return () => {
|
|
19866
|
+
var _a;
|
|
19867
|
+
return createVNode("span", {
|
|
19868
|
+
"class": ["devui-tree-node__folder", ((_a = data.value) == null ? void 0 : _a.disableToggle) && "toggle-disabled"],
|
|
19869
|
+
"onClick": (event) => {
|
|
19870
|
+
event.stopPropagation();
|
|
19871
|
+
if (toggleNode) {
|
|
19872
|
+
toggleNode(data.value);
|
|
19873
|
+
}
|
|
19874
|
+
}
|
|
19875
|
+
}, [data.value.isLeaf ? createVNode("span", {
|
|
19876
|
+
"class": "devui-tree-node__indent"
|
|
19877
|
+
}, null) : data.value.expanded ? createVNode(IconOpen, {
|
|
19878
|
+
"class": "mr-xs"
|
|
19879
|
+
}, null) : createVNode(IconClose, {
|
|
19880
|
+
"class": "mr-xs"
|
|
19881
|
+
}, null)]);
|
|
19882
|
+
};
|
|
19883
|
+
}
|
|
19884
|
+
});
|
|
19885
|
+
function useTreeNode(data) {
|
|
19886
|
+
const { getChildren } = inject(USE_TREE_TOKEN);
|
|
19887
|
+
const nodeClass = computed(() => {
|
|
19888
|
+
var _a;
|
|
19889
|
+
return [
|
|
19890
|
+
"devui-tree-node",
|
|
19891
|
+
((_a = data.value) == null ? void 0 : _a.expanded) && "devui-tree-node__open"
|
|
19892
|
+
];
|
|
19893
|
+
});
|
|
19894
|
+
const nodeStyle = computed(() => {
|
|
19895
|
+
var _a;
|
|
19896
|
+
return { paddingLeft: `${NODE_INDENT * (((_a = data.value) == null ? void 0 : _a.level) - 1)}px` };
|
|
19897
|
+
});
|
|
19898
|
+
const nodeVLineClass = computed(() => {
|
|
19899
|
+
var _a, _b;
|
|
19900
|
+
return [
|
|
19901
|
+
!((_a = data.value) == null ? void 0 : _a.isLeaf) && ((_b = data.value) == null ? void 0 : _b.expanded) && "devui-tree-node__vline"
|
|
19902
|
+
];
|
|
19903
|
+
});
|
|
19904
|
+
const nodeVLineStyle = computed(() => {
|
|
19905
|
+
var _a;
|
|
19906
|
+
return {
|
|
19907
|
+
height: `${NODE_HEIGHT * (getChildren(data.value, { expanded: true }).length - 1) + NODE_HEIGHT / 2 + 1}px`,
|
|
19908
|
+
left: `${NODE_INDENT * (((_a = data.value) == null ? void 0 : _a.level) - 1) + 9}px`,
|
|
19909
|
+
top: `${NODE_HEIGHT}px`
|
|
19910
|
+
};
|
|
19911
|
+
});
|
|
19912
|
+
const nodeHLineClass = computed(() => {
|
|
19913
|
+
var _a;
|
|
19914
|
+
return [
|
|
19915
|
+
((_a = data.value) == null ? void 0 : _a.level) !== 1 && "devui-tree-node__hline"
|
|
19916
|
+
];
|
|
19917
|
+
});
|
|
19918
|
+
const nodeContentClass = computed(() => {
|
|
19919
|
+
var _a;
|
|
19920
|
+
return [
|
|
19921
|
+
"devui-tree-node__content",
|
|
19922
|
+
((_a = data.value) == null ? void 0 : _a.selected) && "active"
|
|
19923
|
+
];
|
|
19924
|
+
});
|
|
19925
|
+
const nodeTitleClass = computed(() => {
|
|
19926
|
+
var _a;
|
|
19927
|
+
return [
|
|
19928
|
+
"devui-tree-node__title",
|
|
19929
|
+
((_a = data.value) == null ? void 0 : _a.disableSelect) && "select-disabled"
|
|
19930
|
+
];
|
|
19931
|
+
});
|
|
19932
|
+
return {
|
|
19933
|
+
nodeClass,
|
|
19934
|
+
nodeStyle,
|
|
19935
|
+
nodeContentClass,
|
|
19936
|
+
nodeTitleClass,
|
|
19937
|
+
nodeVLineClass,
|
|
19938
|
+
nodeVLineStyle,
|
|
19939
|
+
nodeHLineClass
|
|
19940
|
+
};
|
|
19941
|
+
}
|
|
19942
|
+
var DTreeNodeContent = defineComponent({
|
|
19943
|
+
name: "DTreeNodeContent",
|
|
19944
|
+
props: {
|
|
19945
|
+
data: {
|
|
19946
|
+
type: Object,
|
|
19947
|
+
default: () => ({})
|
|
19948
|
+
}
|
|
19949
|
+
},
|
|
19950
|
+
setup(props) {
|
|
19951
|
+
const {
|
|
19952
|
+
data
|
|
19953
|
+
} = toRefs(props);
|
|
19954
|
+
const {
|
|
19955
|
+
nodeTitleClass
|
|
19956
|
+
} = useTreeNode(data);
|
|
19957
|
+
return () => {
|
|
19958
|
+
var _a;
|
|
19959
|
+
return createVNode("span", {
|
|
19960
|
+
"class": nodeTitleClass.value
|
|
19961
|
+
}, [(_a = data.value) == null ? void 0 : _a.label]);
|
|
19962
|
+
};
|
|
19963
|
+
}
|
|
19964
|
+
});
|
|
19965
|
+
var DTreeNode = defineComponent({
|
|
19966
|
+
name: "DTreeNode",
|
|
19967
|
+
props: {
|
|
19968
|
+
data: {
|
|
19969
|
+
type: Object,
|
|
19970
|
+
default: () => ({})
|
|
19971
|
+
},
|
|
19972
|
+
check: {
|
|
19973
|
+
type: Boolean,
|
|
19974
|
+
default: false
|
|
19975
|
+
}
|
|
19976
|
+
},
|
|
19977
|
+
setup(props, {
|
|
19978
|
+
slots
|
|
19979
|
+
}) {
|
|
19980
|
+
const {
|
|
19981
|
+
data,
|
|
19982
|
+
check
|
|
19983
|
+
} = toRefs(props);
|
|
19984
|
+
const {
|
|
19985
|
+
toggleSelectNode,
|
|
19986
|
+
toggleCheckNode,
|
|
19987
|
+
toggleNode,
|
|
19988
|
+
getChildren
|
|
19989
|
+
} = inject(USE_TREE_TOKEN);
|
|
19990
|
+
const {
|
|
19991
|
+
nodeClass,
|
|
19992
|
+
nodeStyle,
|
|
19993
|
+
nodeContentClass,
|
|
19994
|
+
nodeVLineClass,
|
|
19995
|
+
nodeVLineStyle,
|
|
19996
|
+
nodeHLineClass
|
|
19997
|
+
} = useTreeNode(data);
|
|
19998
|
+
const halfChecked = computed(() => {
|
|
19999
|
+
const children = getChildren == null ? void 0 : getChildren(data.value);
|
|
20000
|
+
const checkedChildren = children == null ? void 0 : children.filter((item) => item.checked);
|
|
20001
|
+
if (["upward", "both"].includes(check.value)) {
|
|
20002
|
+
return checkedChildren.length > 0 && checkedChildren.length < children.length;
|
|
20003
|
+
} else {
|
|
20004
|
+
return false;
|
|
20005
|
+
}
|
|
20006
|
+
});
|
|
20007
|
+
return () => {
|
|
20008
|
+
var _a, _b, _c;
|
|
20009
|
+
const checkboxProps2 = {
|
|
20010
|
+
key: (_a = data.value) == null ? void 0 : _a.id,
|
|
20011
|
+
disabled: (_b = data.value) == null ? void 0 : _b.disableCheck,
|
|
20012
|
+
halfchecked: halfChecked.value,
|
|
20013
|
+
modelValue: (_c = data.value) == null ? void 0 : _c.checked,
|
|
20014
|
+
"onUpdate:modelValue": () => {
|
|
20015
|
+
toggleCheckNode(data.value);
|
|
20016
|
+
},
|
|
20017
|
+
onClick: (event) => {
|
|
20018
|
+
event.stopPropagation();
|
|
20019
|
+
}
|
|
20020
|
+
};
|
|
20021
|
+
return createVNode("div", {
|
|
20022
|
+
"class": nodeClass.value,
|
|
20023
|
+
"style": nodeStyle.value
|
|
20024
|
+
}, [createVNode("span", {
|
|
20025
|
+
"class": nodeVLineClass.value,
|
|
20026
|
+
"style": nodeVLineStyle.value
|
|
20027
|
+
}, null), createVNode("div", {
|
|
20028
|
+
"class": nodeContentClass.value,
|
|
20029
|
+
"onClick": () => {
|
|
20030
|
+
toggleSelectNode(data.value);
|
|
20031
|
+
}
|
|
20032
|
+
}, [createVNode("span", {
|
|
20033
|
+
"class": nodeHLineClass.value
|
|
20034
|
+
}, null), slots.icon ? renderSlot(useSlots(), "icon", {
|
|
20035
|
+
nodeData: data,
|
|
20036
|
+
toggleNode
|
|
20037
|
+
}) : createVNode(DTreeNodeToggle, {
|
|
20038
|
+
"data": data.value
|
|
20039
|
+
}, null), createVNode("div", {
|
|
20040
|
+
"class": "devui-tree-node__content--value-wrapper",
|
|
20041
|
+
"style": {
|
|
20042
|
+
height: `${NODE_HEIGHT}px`
|
|
20043
|
+
}
|
|
20044
|
+
}, [check.value && createVNode(Checkbox, checkboxProps2, null), slots.default ? renderSlot(useSlots(), "default", {
|
|
20045
|
+
nodeData: data
|
|
20046
|
+
}) : createVNode(DTreeNodeContent, {
|
|
20047
|
+
"data": data
|
|
20048
|
+
}, null)])])]);
|
|
20049
|
+
};
|
|
20050
|
+
}
|
|
20051
|
+
});
|
|
20052
|
+
function useToggle() {
|
|
20053
|
+
return function useToggle2(data, core) {
|
|
20054
|
+
const { getNode, setNodeValue } = core;
|
|
20055
|
+
const expandNode = (node) => {
|
|
20056
|
+
if (node.disableToggle) {
|
|
20057
|
+
return;
|
|
20058
|
+
}
|
|
20059
|
+
setNodeValue(node, "expanded", true);
|
|
20060
|
+
};
|
|
20061
|
+
const collapseNode = (node) => {
|
|
20062
|
+
if (node.disableToggle) {
|
|
20063
|
+
return;
|
|
20064
|
+
}
|
|
20065
|
+
setNodeValue(node, "expanded", false);
|
|
20066
|
+
};
|
|
20067
|
+
const toggleNode = (node) => {
|
|
20068
|
+
if (node.disableToggle) {
|
|
20069
|
+
return;
|
|
20070
|
+
}
|
|
20071
|
+
if (getNode(node).expanded) {
|
|
20072
|
+
setNodeValue(node, "expanded", false);
|
|
20073
|
+
} else {
|
|
20074
|
+
setNodeValue(node, "expanded", true);
|
|
20075
|
+
}
|
|
20076
|
+
};
|
|
20077
|
+
return {
|
|
20078
|
+
expandNode,
|
|
20079
|
+
collapseNode,
|
|
20080
|
+
toggleNode
|
|
20081
|
+
};
|
|
20082
|
+
};
|
|
20083
|
+
}
|
|
20084
|
+
function randomId(n = 8) {
|
|
20085
|
+
const str = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
20086
|
+
let result2 = "";
|
|
20087
|
+
for (let i = 0; i < n; i++) {
|
|
20088
|
+
result2 += str[parseInt((Math.random() * str.length).toString())];
|
|
20089
|
+
}
|
|
20090
|
+
return result2;
|
|
20091
|
+
}
|
|
20092
|
+
function omit(obj, ...keys) {
|
|
20093
|
+
return Object.entries(obj).filter((item) => !keys.includes(item[0])).reduce((acc, item) => Object.assign({}, acc, { [item[0]]: item[1] }), {});
|
|
20094
|
+
}
|
|
20095
|
+
function generateInnerTree(tree2, key = "children", level = 0, path = []) {
|
|
20096
|
+
level++;
|
|
20097
|
+
return tree2.reduce((acc, item) => {
|
|
20098
|
+
var _a, _b;
|
|
20099
|
+
const newItem = Object.assign({}, item);
|
|
20100
|
+
if (newItem.id === void 0) {
|
|
20101
|
+
newItem.id = randomId();
|
|
20102
|
+
newItem.idType = "random";
|
|
20103
|
+
}
|
|
20104
|
+
newItem.level = level;
|
|
20105
|
+
if (path.length > 0 && ((_a = path[path.length - 1]) == null ? void 0 : _a.level) >= level) {
|
|
20106
|
+
while (((_b = path[path.length - 1]) == null ? void 0 : _b.level) >= level) {
|
|
20107
|
+
path.pop();
|
|
20108
|
+
}
|
|
20109
|
+
}
|
|
20110
|
+
path.push(newItem);
|
|
20111
|
+
const parentNode = path[path.length - 2];
|
|
20112
|
+
if (parentNode) {
|
|
20113
|
+
newItem.parentId = parentNode.id;
|
|
20114
|
+
}
|
|
20115
|
+
if (!newItem[key]) {
|
|
20116
|
+
return acc.concat(__spreadProps(__spreadValues({}, newItem), { isLeaf: true }));
|
|
20117
|
+
} else {
|
|
20118
|
+
return acc.concat(omit(newItem, "children"), generateInnerTree(newItem[key], key, level, path));
|
|
20119
|
+
}
|
|
20120
|
+
}, []);
|
|
20121
|
+
}
|
|
20122
|
+
const DEFAULT_CONFIG = {
|
|
20123
|
+
expanded: false,
|
|
20124
|
+
recursive: true
|
|
20125
|
+
};
|
|
20126
|
+
function useCore() {
|
|
20127
|
+
return function useCore2(data) {
|
|
20128
|
+
const getLevel = (node) => {
|
|
20129
|
+
return data.value.find((item) => item.id === node.id).level;
|
|
20130
|
+
};
|
|
20131
|
+
const getChildren = (node, userConfig = DEFAULT_CONFIG) => {
|
|
20132
|
+
const getInnerExpendedTree = () => {
|
|
20133
|
+
return computed(() => {
|
|
20134
|
+
let excludeNodes = [];
|
|
20135
|
+
const result22 = [];
|
|
20136
|
+
for (let i = 0, len = data == null ? void 0 : data.value.length; i < len; i++) {
|
|
20137
|
+
const item = data == null ? void 0 : data.value[i];
|
|
20138
|
+
if (excludeNodes.map((innerNode) => innerNode.id).includes(item.id)) {
|
|
20139
|
+
continue;
|
|
20140
|
+
}
|
|
20141
|
+
if (item.expanded !== true) {
|
|
20142
|
+
excludeNodes = getChildren(item);
|
|
20143
|
+
}
|
|
20144
|
+
result22.push(item);
|
|
20145
|
+
}
|
|
20146
|
+
return result22;
|
|
20147
|
+
});
|
|
20148
|
+
};
|
|
20149
|
+
const result2 = [];
|
|
20150
|
+
const config = __spreadValues(__spreadValues({}, DEFAULT_CONFIG), userConfig);
|
|
20151
|
+
const treeData = config.expanded ? getInnerExpendedTree() : data;
|
|
20152
|
+
const startIndex = treeData.value.findIndex((item) => item.id === node.id);
|
|
20153
|
+
for (let i = startIndex + 1; i < treeData.value.length && getLevel(node) < treeData.value[i].level; i++) {
|
|
20154
|
+
if (config.recursive) {
|
|
20155
|
+
result2.push(treeData.value[i]);
|
|
20156
|
+
} else if (getLevel(node) === treeData.value[i].level - 1) {
|
|
20157
|
+
result2.push(treeData.value[i]);
|
|
20158
|
+
}
|
|
20159
|
+
}
|
|
20160
|
+
return result2;
|
|
20161
|
+
};
|
|
20162
|
+
const getParent = (node) => {
|
|
20163
|
+
return data.value.find((item) => item.id === node.parentId);
|
|
20164
|
+
};
|
|
20165
|
+
const getExpendedTree = () => {
|
|
20166
|
+
return computed(() => {
|
|
20167
|
+
let excludeNodes = [];
|
|
20168
|
+
const result2 = [];
|
|
20169
|
+
for (let i = 0, len = data == null ? void 0 : data.value.length; i < len; i++) {
|
|
20170
|
+
const item = data == null ? void 0 : data.value[i];
|
|
20171
|
+
if (excludeNodes.map((node) => node.id).includes(item.id)) {
|
|
20172
|
+
continue;
|
|
20173
|
+
}
|
|
20174
|
+
if (item.expanded !== true) {
|
|
20175
|
+
excludeNodes = getChildren(item);
|
|
20176
|
+
}
|
|
20177
|
+
result2.push(item);
|
|
20178
|
+
}
|
|
20179
|
+
return result2;
|
|
20180
|
+
});
|
|
20181
|
+
};
|
|
20182
|
+
const getIndex = (node) => {
|
|
20183
|
+
return data.value.findIndex((item) => item.id === node.id);
|
|
20184
|
+
};
|
|
20185
|
+
const getNode = (node) => {
|
|
20186
|
+
return data.value.find((item) => item.id === node.id);
|
|
20187
|
+
};
|
|
20188
|
+
const setNodeValue = (node, key, value) => {
|
|
20189
|
+
data.value[getIndex(node)][key] = value;
|
|
20190
|
+
};
|
|
20191
|
+
const setTree = (newTree) => {
|
|
20192
|
+
data.value = generateInnerTree(newTree);
|
|
20193
|
+
};
|
|
20194
|
+
return {
|
|
20195
|
+
getLevel,
|
|
20196
|
+
getChildren,
|
|
20197
|
+
getParent,
|
|
20198
|
+
getExpendedTree,
|
|
20199
|
+
getIndex,
|
|
20200
|
+
getNode,
|
|
20201
|
+
setNodeValue,
|
|
20202
|
+
setTree
|
|
20203
|
+
};
|
|
20204
|
+
};
|
|
20205
|
+
}
|
|
20206
|
+
const DEFAULT_TREE_PLUGINS = [useCore(), useToggle()];
|
|
20207
|
+
function useTree(tree2, plugins = []) {
|
|
20208
|
+
const treeData = ref(generateInnerTree(tree2));
|
|
20209
|
+
const core = useCore()(treeData);
|
|
20210
|
+
const pluginMethods = DEFAULT_TREE_PLUGINS.concat(plugins).reduce((acc, plugin) => {
|
|
20211
|
+
return __spreadValues(__spreadValues({}, acc), plugin(treeData, core));
|
|
20212
|
+
}, {});
|
|
20213
|
+
return __spreadValues({
|
|
20214
|
+
treeData
|
|
20215
|
+
}, pluginMethods);
|
|
20216
|
+
}
|
|
20217
|
+
function useCheck(options = ref({ checkStrategy: "both" })) {
|
|
20218
|
+
return function useCheck2(data, core) {
|
|
20219
|
+
const { setNodeValue, getNode, getChildren, getParent } = core;
|
|
20220
|
+
const checkNode = (node) => {
|
|
20221
|
+
setNodeValue(node, "checked", true);
|
|
20222
|
+
};
|
|
20223
|
+
const uncheckNode = (node) => {
|
|
20224
|
+
setNodeValue(node, "checked", false);
|
|
20225
|
+
};
|
|
20226
|
+
const controlParentNodeChecked = (node) => {
|
|
20227
|
+
const parentNode = getParent(node);
|
|
20228
|
+
if (!parentNode) {
|
|
20229
|
+
return;
|
|
20230
|
+
}
|
|
20231
|
+
const siblingNodes = getChildren(parentNode, { recursive: false });
|
|
20232
|
+
const checkedSiblingNodes = siblingNodes.filter((item) => item.checked);
|
|
20233
|
+
const toggleParentChecked = () => {
|
|
20234
|
+
if (checkedSiblingNodes.length === 0) {
|
|
20235
|
+
setNodeValue(parentNode, "checked", false);
|
|
20236
|
+
} else if (checkedSiblingNodes.length === siblingNodes.length) {
|
|
20237
|
+
setNodeValue(parentNode, "checked", true);
|
|
20238
|
+
}
|
|
20239
|
+
};
|
|
20240
|
+
if (parentNode.parentId) {
|
|
20241
|
+
toggleParentChecked();
|
|
20242
|
+
controlParentNodeChecked(parentNode);
|
|
20243
|
+
} else {
|
|
20244
|
+
toggleParentChecked();
|
|
20245
|
+
}
|
|
20246
|
+
};
|
|
20247
|
+
const toggleCheckNode = (node) => {
|
|
20248
|
+
if (getNode(node).checked) {
|
|
20249
|
+
setNodeValue(node, "checked", false);
|
|
20250
|
+
if (["downward", "both"].includes(options.value.checkStrategy)) {
|
|
20251
|
+
getChildren(node).forEach((item) => setNodeValue(item, "checked", false));
|
|
20252
|
+
}
|
|
20253
|
+
} else {
|
|
20254
|
+
setNodeValue(node, "checked", true);
|
|
20255
|
+
if (["downward", "both"].includes(options.value.checkStrategy)) {
|
|
20256
|
+
getChildren(node).forEach((item) => setNodeValue(item, "checked", true));
|
|
20257
|
+
}
|
|
20258
|
+
}
|
|
20259
|
+
if (["upward", "both"].includes(options.value.checkStrategy)) {
|
|
20260
|
+
controlParentNodeChecked(node);
|
|
20261
|
+
}
|
|
20262
|
+
};
|
|
20263
|
+
return {
|
|
20264
|
+
checkNode,
|
|
20265
|
+
uncheckNode,
|
|
20266
|
+
toggleCheckNode
|
|
20267
|
+
};
|
|
20268
|
+
};
|
|
20269
|
+
}
|
|
20270
|
+
function useSelect() {
|
|
20271
|
+
return function useSelect2(data, core) {
|
|
20272
|
+
const { setNodeValue } = core;
|
|
20273
|
+
let prevActiveNode;
|
|
20274
|
+
const selectNode = (node) => {
|
|
20275
|
+
if (node.disableSelect) {
|
|
20276
|
+
return;
|
|
20277
|
+
}
|
|
20278
|
+
if (prevActiveNode) {
|
|
20279
|
+
const prevActiveNodeIndex = data.value.findIndex((item) => item.id === prevActiveNode.id);
|
|
20280
|
+
setNodeValue(data.value[prevActiveNodeIndex], "selected", false);
|
|
20281
|
+
}
|
|
20282
|
+
setNodeValue(node, "selected", true);
|
|
20283
|
+
prevActiveNode = node;
|
|
20284
|
+
};
|
|
20285
|
+
const deselectNode = (node) => {
|
|
20286
|
+
setNodeValue(node, "selected", false);
|
|
20287
|
+
};
|
|
20288
|
+
const toggleSelectNode = (node) => {
|
|
20289
|
+
if (node.selected) {
|
|
20290
|
+
deselectNode(node);
|
|
20291
|
+
} else {
|
|
20292
|
+
selectNode(node);
|
|
20293
|
+
}
|
|
20294
|
+
};
|
|
20295
|
+
return {
|
|
20296
|
+
selectNode,
|
|
20297
|
+
deselectNode,
|
|
20298
|
+
toggleSelectNode
|
|
20299
|
+
};
|
|
20300
|
+
};
|
|
20301
|
+
}
|
|
20302
|
+
function useOperate() {
|
|
20303
|
+
return function useOperate2(data, core) {
|
|
20304
|
+
const { setNodeValue, getChildren, getIndex, getLevel } = core;
|
|
20305
|
+
const insertBefore = (parentNode, node, referenceNode) => {
|
|
20306
|
+
const children = getChildren(parentNode);
|
|
20307
|
+
const lastChild = children[children.length - 1];
|
|
20308
|
+
let insertedIndex = getIndex(parentNode) + 1;
|
|
20309
|
+
if (referenceNode) {
|
|
20310
|
+
insertedIndex = getIndex(referenceNode);
|
|
20311
|
+
} else if (lastChild) {
|
|
20312
|
+
insertedIndex = getIndex(lastChild) + 1;
|
|
20313
|
+
}
|
|
20314
|
+
setNodeValue(parentNode, "expanded", true);
|
|
20315
|
+
setNodeValue(parentNode, "isLeaf", false);
|
|
20316
|
+
const currentNode = __spreadProps(__spreadValues({}, node), {
|
|
20317
|
+
level: getLevel(parentNode) + 1,
|
|
20318
|
+
parentId: parentNode.id,
|
|
20319
|
+
isLeaf: true
|
|
20320
|
+
});
|
|
20321
|
+
data.value = data.value.slice(0, insertedIndex).concat(currentNode, data.value.slice(insertedIndex, data.value.length));
|
|
20322
|
+
};
|
|
20323
|
+
const removeNode = (node, config = { recursive: true }) => {
|
|
20324
|
+
if (!config.recursive) {
|
|
20325
|
+
getChildren(node).forEach((child) => {
|
|
20326
|
+
setNodeValue(child, "level", getLevel(child) - 1);
|
|
20327
|
+
});
|
|
20328
|
+
}
|
|
20329
|
+
data.value = data.value.filter((item) => {
|
|
20330
|
+
if (config.recursive) {
|
|
20331
|
+
return item.id !== node.id && !getChildren(node).map((nodeItem) => nodeItem.id).includes(item.id);
|
|
20332
|
+
} else {
|
|
20333
|
+
return item.id !== node.id;
|
|
20334
|
+
}
|
|
20335
|
+
});
|
|
20336
|
+
};
|
|
20337
|
+
const editNode = (node, label) => {
|
|
20338
|
+
setNodeValue(node, "label", label);
|
|
20339
|
+
};
|
|
20340
|
+
return {
|
|
20341
|
+
insertBefore,
|
|
20342
|
+
removeNode,
|
|
20343
|
+
editNode
|
|
20344
|
+
};
|
|
20345
|
+
};
|
|
20346
|
+
}
|
|
20347
|
+
function useMergeNodes() {
|
|
20348
|
+
return function useMergeNodes2(data, core) {
|
|
20349
|
+
const { setNodeValue, getChildren } = core;
|
|
20350
|
+
const { removeNode } = useOperate()(data, core);
|
|
20351
|
+
const mergeTreeNodes = () => {
|
|
20352
|
+
const mergeToNode = (node) => {
|
|
20353
|
+
var _a;
|
|
20354
|
+
if (node.isLeaf) {
|
|
20355
|
+
return;
|
|
20356
|
+
}
|
|
20357
|
+
const children = getChildren(node, { recursive: false });
|
|
20358
|
+
if ((children == null ? void 0 : children.length) === 1) {
|
|
20359
|
+
const subChildren = getChildren(children[0], { recursive: false });
|
|
20360
|
+
if (subChildren.length !== 0) {
|
|
20361
|
+
setNodeValue(node, "label", node.label + " / " + ((_a = children[0]) == null ? void 0 : _a.label));
|
|
20362
|
+
removeNode(children[0], { recursive: false });
|
|
20363
|
+
mergeToNode(node);
|
|
20364
|
+
} else {
|
|
20365
|
+
setNodeValue(children[0], "parentId", node.id);
|
|
20366
|
+
}
|
|
20367
|
+
} else {
|
|
20368
|
+
children.forEach((item) => {
|
|
20369
|
+
mergeToNode(item);
|
|
20370
|
+
});
|
|
20371
|
+
}
|
|
20372
|
+
};
|
|
20373
|
+
data.value.filter((item) => item.level === 1).forEach((item) => {
|
|
20374
|
+
mergeToNode(item);
|
|
20375
|
+
});
|
|
20376
|
+
};
|
|
20377
|
+
return {
|
|
20378
|
+
mergeTreeNodes
|
|
20379
|
+
};
|
|
20380
|
+
};
|
|
20381
|
+
}
|
|
20382
|
+
const treeProps = {
|
|
20383
|
+
data: {
|
|
20384
|
+
type: Object,
|
|
20385
|
+
default: []
|
|
20386
|
+
},
|
|
20387
|
+
check: {
|
|
20388
|
+
type: [Boolean, String],
|
|
20389
|
+
default: false
|
|
20390
|
+
}
|
|
20391
|
+
};
|
|
20392
|
+
var tree = "";
|
|
20393
|
+
var Tree = defineComponent({
|
|
20394
|
+
name: "DTree",
|
|
20395
|
+
props: treeProps,
|
|
20396
|
+
setup(props, {
|
|
20397
|
+
slots,
|
|
20398
|
+
expose
|
|
20399
|
+
}) {
|
|
20400
|
+
const {
|
|
20401
|
+
data,
|
|
20402
|
+
check
|
|
20403
|
+
} = toRefs(props);
|
|
20404
|
+
const userPlugins = [useSelect(), useOperate(), useMergeNodes()];
|
|
20405
|
+
const checkOptions = ref({
|
|
20406
|
+
checkStrategy: check.value || "both"
|
|
20407
|
+
});
|
|
20408
|
+
watch(check, (newVal) => {
|
|
20409
|
+
checkOptions.value.checkStrategy = newVal;
|
|
20410
|
+
});
|
|
20411
|
+
if (check.value) {
|
|
20412
|
+
userPlugins.push(useCheck(checkOptions));
|
|
20413
|
+
}
|
|
20414
|
+
const treeFactory = useTree(data.value, userPlugins);
|
|
20415
|
+
const {
|
|
20416
|
+
setTree,
|
|
20417
|
+
getExpendedTree,
|
|
20418
|
+
toggleNode
|
|
20419
|
+
} = treeFactory;
|
|
20420
|
+
watch(data, setTree);
|
|
20421
|
+
provide(USE_TREE_TOKEN, treeFactory);
|
|
20422
|
+
expose({
|
|
20423
|
+
treeFactory
|
|
20424
|
+
});
|
|
20425
|
+
return () => {
|
|
20426
|
+
return createVNode("div", {
|
|
20427
|
+
"class": "devui-tree"
|
|
20428
|
+
}, [getExpendedTree == null ? void 0 : getExpendedTree().value.map((treeNode) => slots.default ? renderSlot(useSlots(), "default", {
|
|
20429
|
+
treeFactory,
|
|
20430
|
+
nodeData: treeNode
|
|
20431
|
+
}) : createVNode(DTreeNode, {
|
|
20432
|
+
"data": treeNode,
|
|
20433
|
+
"check": check.value
|
|
20434
|
+
}, {
|
|
20435
|
+
default: () => slots.content ? renderSlot(useSlots(), "content", {
|
|
20436
|
+
nodeData: treeNode
|
|
20437
|
+
}) : createVNode(DTreeNodeContent, {
|
|
20438
|
+
"data": treeNode
|
|
20439
|
+
}, null),
|
|
20440
|
+
icon: () => slots.icon ? renderSlot(useSlots(), "icon", {
|
|
20441
|
+
nodeData: treeNode,
|
|
20442
|
+
toggleNode
|
|
20443
|
+
}) : createVNode(DTreeNodeToggle, {
|
|
20444
|
+
"data": treeNode
|
|
20445
|
+
}, null)
|
|
20446
|
+
}))]);
|
|
20447
|
+
};
|
|
20448
|
+
}
|
|
20449
|
+
});
|
|
20450
|
+
var TreeInstall = {
|
|
20451
|
+
title: "Tree \u6811",
|
|
20452
|
+
category: "\u6570\u636E\u5C55\u793A",
|
|
20453
|
+
status: "20%",
|
|
20454
|
+
install(app) {
|
|
20455
|
+
app.component(Tree.name, Tree);
|
|
20456
|
+
}
|
|
20457
|
+
};
|
|
19553
20458
|
var UploadStatus = /* @__PURE__ */ ((UploadStatus2) => {
|
|
19554
20459
|
UploadStatus2[UploadStatus2["preLoad"] = 0] = "preLoad";
|
|
19555
20460
|
UploadStatus2[UploadStatus2["uploading"] = 1] = "uploading";
|
|
@@ -20260,6 +21165,7 @@ const installs = [
|
|
|
20260
21165
|
TextareaInstall,
|
|
20261
21166
|
TimelineInstall,
|
|
20262
21167
|
TooltipInstall,
|
|
21168
|
+
TreeInstall,
|
|
20263
21169
|
UploadInstall
|
|
20264
21170
|
];
|
|
20265
21171
|
var vueDevui = {
|
|
@@ -20268,4 +21174,4 @@ var vueDevui = {
|
|
|
20268
21174
|
installs.forEach((p) => app.use(p));
|
|
20269
21175
|
}
|
|
20270
21176
|
};
|
|
20271
|
-
export { Alert, Aside, AutoComplete, Avatar, Badge, Button, Card, Checkbox, Col, Column, Comment, Content, Countdown, DatePicker, Drawer, DrawerService, Dropdown, DropdownMenu, EditableSelect, FixedOverlay, FlexibleOverlay, Footer$1 as Footer, Form, FormControl, FormItem, FormLabel, FormOperation, Fullscreen, Header$1 as Header, DIcon as Icon, ImagePreviewDirective, ImagePreviewService, DInput as Input, InputNumber, Layout, loadingDirective as Loading, loading as LoadingService, Modal, Notification, NotificationService, Pagination, Panel, PanelBody, PanelFooter, PanelHeader, Popover, Progress, Radio, RadioGroup, Rate, ReadTip, Result, RippleDirective, Row, Search, Select, Skeleton, SkeletonItem, Slider, Splitter, Statistic, Status, StickSlider, Switch, Tab, Table, Tabs, Tag, Textarea, Timeline, TimelineItem, Tooltip, Upload, vueDevui as default };
|
|
21177
|
+
export { Alert, Aside, AutoComplete, Avatar, Badge, Button, Card, Checkbox, Col, Column, Comment, Content, Countdown, DatePicker, Drawer, DrawerService, Dropdown, DropdownMenu, EditableSelect, FixedOverlay, FlexibleOverlay, Footer$1 as Footer, Form, FormControl, FormItem, FormLabel, FormOperation, Fullscreen, Header$1 as Header, DIcon as Icon, ImagePreviewDirective, ImagePreviewService, DInput as Input, InputNumber, Layout, loadingDirective as Loading, loading as LoadingService, Modal, Notification, NotificationService, Pagination, Panel, PanelBody, PanelFooter, PanelHeader, Popover, Progress, Radio, RadioGroup, Rate, ReadTip, Result, RippleDirective, Row, Search, Select, Skeleton, SkeletonItem, Slider, Splitter, Statistic, Status, StickSlider, Switch, Tab, Table, Tabs, Tag, Textarea, Timeline, TimelineItem, Tooltip, Tree, Upload, vueDevui as default };
|