vue-devui 1.0.0-rc.6 → 1.0.0-rc.9
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 +5 -0
- package/alert/index.es.js +37 -11
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +311 -77
- package/auto-complete/index.umd.js +3 -5
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +81 -70
- package/avatar/index.umd.js +1 -1
- package/avatar/style.css +1 -1
- package/badge/index.es.js +29 -4
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +5632 -87
- package/button/index.umd.js +27 -1
- package/button/style.css +1 -1
- package/card/index.es.js +56 -29
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +364 -234
- package/checkbox/index.umd.js +1 -1
- package/checkbox/style.css +1 -1
- package/date-picker/index.es.js +310 -157
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/drawer/index.es.js +28 -3
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +125 -45
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +437 -22
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +490 -605
- package/form/index.umd.js +15 -15
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +29 -5
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/grid/index.es.js +71 -50
- package/grid/index.umd.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +109 -13
- package/icon/index.umd.js +1 -1
- package/icon/style.css +1 -0
- package/image-preview/index.es.js +34 -11
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +330 -130
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +272 -199
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +34 -6
- package/layout/index.umd.js +1 -1
- package/layout/style.css +1 -1
- package/loading/index.es.js +34 -10
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/modal/index.es.js +126 -27
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +125 -25
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/ButtonGroup.js +3 -0
- package/nuxt/components/CheckboxButton.js +3 -0
- package/nuxt/components/CheckboxGroup.js +3 -0
- package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
- package/nuxt/components/FORM_TOKEN.js +3 -0
- package/nuxt/components/Icon.js +1 -0
- package/nuxt/components/LABEL_DATA.js +3 -0
- package/nuxt/components/Option.js +3 -0
- package/nuxt/components/buttonGroupInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupProps.js +3 -0
- package/nuxt/components/formControlProps.js +3 -0
- package/nuxt/components/formItemProps.js +3 -0
- package/nuxt/components/formProps.js +3 -0
- package/nuxt/components/iconProps.js +1 -0
- package/nuxt/components/svgIconProps.js +3 -0
- package/overlay/index.es.js +31 -9
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +2 -1
- package/pagination/index.es.js +135 -124
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/popover/index.es.js +198 -83
- package/popover/index.umd.js +16 -16
- package/popover/style.css +1 -1
- package/progress/index.es.js +76 -20
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +161 -140
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +48 -16
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/result/index.es.js +108 -12
- package/result/index.umd.js +1 -1
- package/result/style.css +1 -1
- package/search/index.es.js +379 -167
- package/search/index.umd.js +17 -17
- package/search/style.css +1 -1
- package/select/index.es.js +7339 -556
- package/select/index.umd.js +27 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +37 -12
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +34 -10
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +201 -84
- package/splitter/index.umd.js +14 -14
- package/splitter/style.css +1 -1
- package/status/index.es.js +26 -2
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +30 -6
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +6808 -585
- package/table/index.umd.js +27 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +136 -70
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +31 -7
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +5631 -80
- package/textarea/index.umd.js +35 -1
- package/textarea/style.css +1 -1
- package/timeline/index.es.js +108 -12
- package/timeline/index.umd.js +1 -1
- package/timeline/style.css +1 -1
- package/tooltip/index.es.js +190 -74
- package/tooltip/index.umd.js +17 -17
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +376 -256
- package/tree/index.umd.js +1 -1
- package/tree/style.css +1 -1
- package/upload/index.es.js +138 -34
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +6770 -5769
- package/vue-devui.umd.js +27 -21
- package/comment/index.d.ts +0 -7
- package/comment/index.es.js +0 -84
- package/comment/index.umd.js +0 -1
- package/comment/package.json +0 -7
- package/comment/style.css +0 -1
- package/nuxt/components/Comment.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/ReadTip.js +0 -3
- package/nuxt/components/commentProps.js +0 -3
- package/nuxt/components/readTipProps.js +0 -3
- package/read-tip/index.d.ts +0 -7
- package/read-tip/index.es.js +0 -261
- package/read-tip/index.umd.js +0 -1
- package/read-tip/package.json +0 -7
- package/read-tip/style.css +0 -1
package/form/index.es.js
CHANGED
|
@@ -29,24 +29,8 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
import { defineComponent,
|
|
32
|
+
import { defineComponent, watch, provide, reactive, toRefs, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, onUnmounted, ref, unref, nextTick, mergeProps, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, createTextVNode, onBeforeUnmount } from "vue";
|
|
33
33
|
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
34
|
-
function mitt(n) {
|
|
35
|
-
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
36
|
-
var i = n.get(t);
|
|
37
|
-
i ? i.push(e) : n.set(t, [e]);
|
|
38
|
-
}, off: function(t, e) {
|
|
39
|
-
var i = n.get(t);
|
|
40
|
-
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
41
|
-
}, emit: function(t, e) {
|
|
42
|
-
var i = n.get(t);
|
|
43
|
-
i && i.slice().map(function(n2) {
|
|
44
|
-
n2(e);
|
|
45
|
-
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
46
|
-
n2(t, e);
|
|
47
|
-
});
|
|
48
|
-
} };
|
|
49
|
-
}
|
|
50
34
|
const formProps = {
|
|
51
35
|
data: {
|
|
52
36
|
type: Object,
|
|
@@ -67,27 +51,24 @@ const formProps = {
|
|
|
67
51
|
rules: {
|
|
68
52
|
type: Object
|
|
69
53
|
},
|
|
70
|
-
|
|
54
|
+
messageType: {
|
|
71
55
|
type: String,
|
|
72
56
|
default: "popover"
|
|
57
|
+
},
|
|
58
|
+
popPosition: {
|
|
59
|
+
type: Array,
|
|
60
|
+
default: ["right", "bottom"]
|
|
61
|
+
},
|
|
62
|
+
validateOnRuleChange: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false
|
|
65
|
+
},
|
|
66
|
+
showFeedback: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: false
|
|
73
69
|
}
|
|
74
70
|
};
|
|
75
|
-
const dFormEvents = {
|
|
76
|
-
addField: "d.form.addField",
|
|
77
|
-
removeField: "d.form.removeField"
|
|
78
|
-
};
|
|
79
71
|
const FORM_TOKEN = Symbol("dForm");
|
|
80
|
-
var eventBus = mitt();
|
|
81
|
-
const EventBus = eventBus;
|
|
82
|
-
function isObject(obj) {
|
|
83
|
-
return Object.prototype.toString.call(obj).slice(8, -1) === "Object";
|
|
84
|
-
}
|
|
85
|
-
function hasKey(obj, key) {
|
|
86
|
-
if (!isObject(obj)) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
90
|
-
}
|
|
91
72
|
function createBem(namespace, element, modifier) {
|
|
92
73
|
let cls = namespace;
|
|
93
74
|
if (element) {
|
|
@@ -98,8 +79,8 @@ function createBem(namespace, element, modifier) {
|
|
|
98
79
|
}
|
|
99
80
|
return cls;
|
|
100
81
|
}
|
|
101
|
-
function useNamespace(block) {
|
|
102
|
-
const namespace = `devui-${block}`;
|
|
82
|
+
function useNamespace(block, needDot = false) {
|
|
83
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
103
84
|
const b = () => createBem(namespace);
|
|
104
85
|
const e = (element) => element ? createBem(namespace, element) : "";
|
|
105
86
|
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
@@ -5577,21 +5558,20 @@ function useFormValidation(itemContexts) {
|
|
|
5577
5558
|
}
|
|
5578
5559
|
};
|
|
5579
5560
|
const validate = async (callback) => validateFields(void 0, callback);
|
|
5580
|
-
|
|
5561
|
+
const clearValidate = (fields = []) => {
|
|
5562
|
+
getValidateFields(fields).forEach((field) => field.clearValidate());
|
|
5563
|
+
};
|
|
5564
|
+
const resetFields = (fields = []) => {
|
|
5565
|
+
getValidateFields(fields).forEach((field) => field.resetField());
|
|
5566
|
+
};
|
|
5567
|
+
return { validate, validateFields, resetFields, clearValidate };
|
|
5581
5568
|
}
|
|
5582
5569
|
var Form = defineComponent({
|
|
5583
5570
|
name: "DForm",
|
|
5584
5571
|
props: formProps,
|
|
5585
|
-
emits: ["
|
|
5572
|
+
emits: ["validate"],
|
|
5586
5573
|
setup(props, ctx) {
|
|
5587
|
-
const
|
|
5588
|
-
const ns = useNamespace("form");
|
|
5589
|
-
const {
|
|
5590
|
-
data,
|
|
5591
|
-
layout,
|
|
5592
|
-
labelSize,
|
|
5593
|
-
labelAlign
|
|
5594
|
-
} = toRefs(props);
|
|
5574
|
+
const ns2 = useNamespace("form");
|
|
5595
5575
|
const {
|
|
5596
5576
|
itemContexts,
|
|
5597
5577
|
addItemContext,
|
|
@@ -5599,45 +5579,79 @@ var Form = defineComponent({
|
|
|
5599
5579
|
} = useFieldCollection();
|
|
5600
5580
|
const {
|
|
5601
5581
|
validate,
|
|
5602
|
-
validateFields
|
|
5582
|
+
validateFields,
|
|
5583
|
+
resetFields,
|
|
5584
|
+
clearValidate
|
|
5603
5585
|
} = useFormValidation(itemContexts);
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5586
|
+
const onSubmit = (e) => {
|
|
5587
|
+
e.preventDefault();
|
|
5588
|
+
};
|
|
5589
|
+
watch(() => props.rules, () => {
|
|
5590
|
+
if (props.validateOnRuleChange) {
|
|
5591
|
+
validate();
|
|
5592
|
+
}
|
|
5593
|
+
}, {
|
|
5594
|
+
deep: true
|
|
5609
5595
|
});
|
|
5610
|
-
provide(FORM_TOKEN, reactive({
|
|
5611
|
-
|
|
5612
|
-
formMitt,
|
|
5613
|
-
labelData: {
|
|
5614
|
-
layout,
|
|
5615
|
-
labelSize,
|
|
5616
|
-
labelAlign
|
|
5617
|
-
},
|
|
5618
|
-
rules: props.rules,
|
|
5619
|
-
messageShowType: "popover",
|
|
5596
|
+
provide(FORM_TOKEN, reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
|
|
5597
|
+
emit: ctx.emit,
|
|
5620
5598
|
addItemContext,
|
|
5621
5599
|
removeItemContext
|
|
5622
|
-
}));
|
|
5600
|
+
})));
|
|
5623
5601
|
ctx.expose({
|
|
5624
5602
|
validate,
|
|
5625
|
-
validateFields
|
|
5603
|
+
validateFields,
|
|
5604
|
+
resetFields,
|
|
5605
|
+
clearValidate
|
|
5626
5606
|
});
|
|
5627
|
-
const onSubmit = (e) => {
|
|
5628
|
-
e.preventDefault();
|
|
5629
|
-
ctx.emit("submit", e);
|
|
5630
|
-
EventBus.emit(`formSubmit:${props.name}`);
|
|
5631
|
-
};
|
|
5632
5607
|
return () => {
|
|
5633
5608
|
var _a, _b;
|
|
5634
5609
|
return createVNode("form", {
|
|
5635
5610
|
"onSubmit": onSubmit,
|
|
5636
|
-
"class":
|
|
5611
|
+
"class": ns2.b()
|
|
5637
5612
|
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
5638
5613
|
};
|
|
5639
5614
|
}
|
|
5640
5615
|
});
|
|
5616
|
+
const formItemProps = {
|
|
5617
|
+
label: {
|
|
5618
|
+
type: String
|
|
5619
|
+
},
|
|
5620
|
+
field: {
|
|
5621
|
+
type: String,
|
|
5622
|
+
default: ""
|
|
5623
|
+
},
|
|
5624
|
+
required: {
|
|
5625
|
+
type: Boolean,
|
|
5626
|
+
default: false
|
|
5627
|
+
},
|
|
5628
|
+
messageType: {
|
|
5629
|
+
type: String
|
|
5630
|
+
},
|
|
5631
|
+
popPosition: {
|
|
5632
|
+
type: Array
|
|
5633
|
+
},
|
|
5634
|
+
rules: {
|
|
5635
|
+
type: [Object, Array]
|
|
5636
|
+
},
|
|
5637
|
+
showFeedback: {
|
|
5638
|
+
type: Boolean,
|
|
5639
|
+
default: void 0
|
|
5640
|
+
},
|
|
5641
|
+
helpTips: {
|
|
5642
|
+
type: String,
|
|
5643
|
+
default: ""
|
|
5644
|
+
},
|
|
5645
|
+
feedbackStatus: {
|
|
5646
|
+
type: String
|
|
5647
|
+
},
|
|
5648
|
+
extraInfo: {
|
|
5649
|
+
type: String,
|
|
5650
|
+
default: ""
|
|
5651
|
+
}
|
|
5652
|
+
};
|
|
5653
|
+
const FORM_ITEM_TOKEN = Symbol("dFormItem");
|
|
5654
|
+
const LABEL_DATA = Symbol("labelData");
|
|
5641
5655
|
const formLabelProps = {
|
|
5642
5656
|
helpTips: {
|
|
5643
5657
|
type: String,
|
|
@@ -5650,13 +5664,14 @@ function _isSlot(s) {
|
|
|
5650
5664
|
}
|
|
5651
5665
|
const CommonOverlay = defineComponent({
|
|
5652
5666
|
setup(props, ctx) {
|
|
5667
|
+
const ns2 = useNamespace("overlay");
|
|
5653
5668
|
return () => {
|
|
5654
5669
|
let _slot;
|
|
5655
5670
|
return createVNode(Teleport, {
|
|
5656
5671
|
"to": "#d-overlay-anchor"
|
|
5657
5672
|
}, {
|
|
5658
5673
|
default: () => [createVNode(Transition, {
|
|
5659
|
-
"name": "
|
|
5674
|
+
"name": ns2.e("fade")
|
|
5660
5675
|
}, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
5661
5676
|
default: () => [_slot]
|
|
5662
5677
|
})]
|
|
@@ -5699,15 +5714,12 @@ const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
|
5699
5714
|
});
|
|
5700
5715
|
const overlayEmits = ["update:visible", "backdropClick"];
|
|
5701
5716
|
function useOverlayLogic(props, ctx) {
|
|
5717
|
+
const ns2 = useNamespace("overlay");
|
|
5702
5718
|
const backgroundClass = computed(() => {
|
|
5703
|
-
return [
|
|
5704
|
-
"devui-overlay-background",
|
|
5705
|
-
props.backgroundClass,
|
|
5706
|
-
!props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
|
|
5707
|
-
];
|
|
5719
|
+
return [ns2.e("background"), props.backgroundClass, !props.hasBackdrop ? ns2.em("background", "disabled") : ns2.em("background", "color")];
|
|
5708
5720
|
});
|
|
5709
5721
|
const overlayClass = computed(() => {
|
|
5710
|
-
return
|
|
5722
|
+
return ns2.b();
|
|
5711
5723
|
});
|
|
5712
5724
|
const handleBackdropClick = (event) => {
|
|
5713
5725
|
var _a;
|
|
@@ -5809,8 +5821,8 @@ const flexibleOverlayProps = {
|
|
|
5809
5821
|
function getScrollParent(element) {
|
|
5810
5822
|
const overflowRegex = /(auto|scroll|hidden)/;
|
|
5811
5823
|
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
5812
|
-
const
|
|
5813
|
-
if (overflowRegex.test(
|
|
5824
|
+
const style = window.getComputedStyle(parent);
|
|
5825
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
5814
5826
|
return parent;
|
|
5815
5827
|
}
|
|
5816
5828
|
}
|
|
@@ -5917,6 +5929,7 @@ const FlexibleOverlay = defineComponent({
|
|
|
5917
5929
|
emit,
|
|
5918
5930
|
expose
|
|
5919
5931
|
}) {
|
|
5932
|
+
const ns2 = useNamespace("flexible-overlay");
|
|
5920
5933
|
const {
|
|
5921
5934
|
arrowRef,
|
|
5922
5935
|
overlayRef,
|
|
@@ -5929,14 +5942,70 @@ const FlexibleOverlay = defineComponent({
|
|
|
5929
5942
|
var _a;
|
|
5930
5943
|
return props.modelValue && createVNode("div", mergeProps({
|
|
5931
5944
|
"ref": overlayRef,
|
|
5932
|
-
"class":
|
|
5945
|
+
"class": ns2.b()
|
|
5933
5946
|
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
5934
5947
|
"ref": arrowRef,
|
|
5935
|
-
"class": "
|
|
5948
|
+
"class": ns2.e("arrow")
|
|
5936
5949
|
}, null)]);
|
|
5937
5950
|
};
|
|
5938
5951
|
}
|
|
5939
5952
|
});
|
|
5953
|
+
const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
|
|
5954
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
5955
|
+
const ns$1 = useNamespace("popper-trigger");
|
|
5956
|
+
function wrapContent(content) {
|
|
5957
|
+
return h("span", { class: ns$1.b() }, content);
|
|
5958
|
+
}
|
|
5959
|
+
function getFirstValidChild(nodes) {
|
|
5960
|
+
for (const child of nodes) {
|
|
5961
|
+
if (isObject(child)) {
|
|
5962
|
+
if (child.type === Comment) {
|
|
5963
|
+
continue;
|
|
5964
|
+
}
|
|
5965
|
+
if (child.type === "svg" || child.type === Text) {
|
|
5966
|
+
return wrapContent(child);
|
|
5967
|
+
}
|
|
5968
|
+
if (child.type === Fragment) {
|
|
5969
|
+
return getFirstValidChild(child.children);
|
|
5970
|
+
}
|
|
5971
|
+
return child;
|
|
5972
|
+
}
|
|
5973
|
+
return wrapContent(child);
|
|
5974
|
+
}
|
|
5975
|
+
return null;
|
|
5976
|
+
}
|
|
5977
|
+
var PopperTrigger = defineComponent({
|
|
5978
|
+
name: "DPopperTrigger",
|
|
5979
|
+
setup(_, ctx) {
|
|
5980
|
+
const {
|
|
5981
|
+
slots,
|
|
5982
|
+
attrs
|
|
5983
|
+
} = ctx;
|
|
5984
|
+
return () => {
|
|
5985
|
+
var _a;
|
|
5986
|
+
const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
|
|
5987
|
+
const triggerRef = inject(POPPER_TRIGGER_TOKEN);
|
|
5988
|
+
if (!defaultSlot) {
|
|
5989
|
+
return null;
|
|
5990
|
+
}
|
|
5991
|
+
const firstValidChild = getFirstValidChild(defaultSlot);
|
|
5992
|
+
if (!firstValidChild) {
|
|
5993
|
+
return null;
|
|
5994
|
+
}
|
|
5995
|
+
return withDirectives(cloneVNode(firstValidChild, attrs), [[{
|
|
5996
|
+
mounted(el) {
|
|
5997
|
+
triggerRef.value = el;
|
|
5998
|
+
},
|
|
5999
|
+
updated(el) {
|
|
6000
|
+
triggerRef.value = el;
|
|
6001
|
+
},
|
|
6002
|
+
unmounted() {
|
|
6003
|
+
triggerRef.value = null;
|
|
6004
|
+
}
|
|
6005
|
+
}]]);
|
|
6006
|
+
};
|
|
6007
|
+
}
|
|
6008
|
+
});
|
|
5940
6009
|
const popoverProps = {
|
|
5941
6010
|
isOpen: {
|
|
5942
6011
|
type: Boolean,
|
|
@@ -5977,6 +6046,10 @@ const popoverProps = {
|
|
|
5977
6046
|
mouseLeaveDelay: {
|
|
5978
6047
|
type: Number,
|
|
5979
6048
|
default: 100
|
|
6049
|
+
},
|
|
6050
|
+
disabled: {
|
|
6051
|
+
type: Boolean,
|
|
6052
|
+
default: false
|
|
5980
6053
|
}
|
|
5981
6054
|
};
|
|
5982
6055
|
const TransformOriginMap = {
|
|
@@ -6013,11 +6086,16 @@ function usePopover(props, visible, placement, origin, popoverRef) {
|
|
|
6013
6086
|
return { overlayStyles };
|
|
6014
6087
|
}
|
|
6015
6088
|
function usePopoverEvent(props, visible, origin) {
|
|
6016
|
-
const { trigger, position, mouseEnterDelay, mouseLeaveDelay } = toRefs(props);
|
|
6089
|
+
const { trigger, position, mouseEnterDelay, mouseLeaveDelay, disabled } = toRefs(props);
|
|
6017
6090
|
const isClick = computed(() => trigger.value === "click");
|
|
6018
6091
|
const placement = ref(position.value[0].split("-")[0]);
|
|
6019
6092
|
const isEnter = ref(false);
|
|
6020
|
-
const onClick = () =>
|
|
6093
|
+
const onClick = () => {
|
|
6094
|
+
if (disabled.value) {
|
|
6095
|
+
return;
|
|
6096
|
+
}
|
|
6097
|
+
isClick.value && (visible.value = !visible.value);
|
|
6098
|
+
};
|
|
6021
6099
|
const enter = lodash.exports.debounce(() => {
|
|
6022
6100
|
isEnter.value && (visible.value = true);
|
|
6023
6101
|
}, mouseEnterDelay.value);
|
|
@@ -6025,6 +6103,9 @@ function usePopoverEvent(props, visible, origin) {
|
|
|
6025
6103
|
!isEnter.value && (visible.value = false);
|
|
6026
6104
|
}, mouseLeaveDelay.value);
|
|
6027
6105
|
const onMouseenter = () => {
|
|
6106
|
+
if (disabled.value) {
|
|
6107
|
+
return;
|
|
6108
|
+
}
|
|
6028
6109
|
if (!isClick.value) {
|
|
6029
6110
|
isEnter.value = true;
|
|
6030
6111
|
enter();
|
|
@@ -6036,6 +6117,15 @@ function usePopoverEvent(props, visible, origin) {
|
|
|
6036
6117
|
leave();
|
|
6037
6118
|
}
|
|
6038
6119
|
};
|
|
6120
|
+
const quickLeave = () => {
|
|
6121
|
+
isEnter.value = false;
|
|
6122
|
+
visible.value = false;
|
|
6123
|
+
};
|
|
6124
|
+
watch(disabled, (newVal) => {
|
|
6125
|
+
if (newVal && visible.value) {
|
|
6126
|
+
quickLeave();
|
|
6127
|
+
}
|
|
6128
|
+
});
|
|
6039
6129
|
const handlePositionChange = (pos) => {
|
|
6040
6130
|
placement.value = pos.split("-")[0];
|
|
6041
6131
|
};
|
|
@@ -6047,11 +6137,12 @@ function usePopoverEvent(props, visible, origin) {
|
|
|
6047
6137
|
origin.value.addEventListener("mouseleave", onMouseleave);
|
|
6048
6138
|
}
|
|
6049
6139
|
});
|
|
6050
|
-
return { placement, handlePositionChange };
|
|
6140
|
+
return { placement, handlePositionChange, onMouseenter, onMouseleave };
|
|
6051
6141
|
}
|
|
6052
|
-
|
|
6142
|
+
const ns = useNamespace("popover");
|
|
6143
|
+
function SuccessIcon$1() {
|
|
6053
6144
|
return createVNode("svg", {
|
|
6054
|
-
"class": "
|
|
6145
|
+
"class": [ns.e("icon"), ns.em("icon", "success")],
|
|
6055
6146
|
"viewBox": "0 0 16 16",
|
|
6056
6147
|
"version": "1.1",
|
|
6057
6148
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6075,7 +6166,7 @@ function SuccessIcon() {
|
|
|
6075
6166
|
}
|
|
6076
6167
|
function WarningIcon() {
|
|
6077
6168
|
return createVNode("svg", {
|
|
6078
|
-
"class": "
|
|
6169
|
+
"class": [ns.e("icon"), ns.em("icon", "warning")],
|
|
6079
6170
|
"viewBox": "0 0 16 16",
|
|
6080
6171
|
"version": "1.1",
|
|
6081
6172
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6085,14 +6176,14 @@ function WarningIcon() {
|
|
|
6085
6176
|
"fill": "none",
|
|
6086
6177
|
"fill-rule": "evenodd"
|
|
6087
6178
|
}, [createVNode("polygon", {
|
|
6088
|
-
"points": "7.5 1.74501946 1.39184847 13.5954649 7.08947368
|
|
6179
|
+
"points": "7.5 1.74501946 1.39184847 13.5954649 7.08947368 14.2207621 13.9973698 13.5954649 10.9383683 5.61273879 8.40084114 1.27624313"
|
|
6089
6180
|
}, null), createVNode("path", {
|
|
6090
|
-
"d": "M8.51325441,0.127397589 C8.70423071,0.228333932
|
|
6181
|
+
"d": "M8.51325441,0.127397589 C8.70423071,0.228333932 8.8605922,0.383286648 8.96244623,0.57254229 L15.8714442,13.4101975 C16.1549662,13.9370117 15.9538562,14.5918482 15.4222523,14.8728158 C15.2642579,14.9563203 15.0879506,15 14.9088903,15 L1.09089441,15 C0.488410063,15 0,14.5159904 0,13.9189343 C0,13.7414873 0.0440768395,13.5667684 0.128340519,13.4101975 L7.03733844,0.57254229 C7.32086049,0.0457280838 7.98165058,-0.153569987 8.51325441,0.127397589 Z M8.87894737,11.2105263 L7.08947368,11.2105263 L7.08947368,13 L8.87894737,13 L8.87894737,11.2105263 Z M8.96842105,4.5 L7,4.5 L7.08947368,9.86842105 L8.87894737,9.86842105 L8.96842105,4.5 Z"
|
|
6091
6182
|
}, null)])]);
|
|
6092
6183
|
}
|
|
6093
6184
|
function InfoIcon() {
|
|
6094
6185
|
return createVNode("svg", {
|
|
6095
|
-
"class": "
|
|
6186
|
+
"class": [ns.e("icon"), ns.em("icon", "info")],
|
|
6096
6187
|
"viewBox": "0 0 16 16",
|
|
6097
6188
|
"version": "1.1",
|
|
6098
6189
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6108,12 +6199,12 @@ function InfoIcon() {
|
|
|
6108
6199
|
}, null), createVNode("g", {
|
|
6109
6200
|
"stroke-width": "1"
|
|
6110
6201
|
}, [createVNode("path", {
|
|
6111
|
-
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16
|
|
6202
|
+
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8 C16,3.6 12.4,0 8,0 Z M9,5 L7,5 L7,3 L9,3 L9,5 Z M9,12.6 L7,12.6 L7,6.6 L9,6.6 L9,12.6 Z"
|
|
6112
6203
|
}, null)])])]);
|
|
6113
6204
|
}
|
|
6114
|
-
function ErrorIcon() {
|
|
6205
|
+
function ErrorIcon$1() {
|
|
6115
6206
|
return createVNode("svg", {
|
|
6116
|
-
"class": "
|
|
6207
|
+
"class": [ns.e("icon"), ns.em("icon", "error")],
|
|
6117
6208
|
"width": "16px",
|
|
6118
6209
|
"height": "16px",
|
|
6119
6210
|
"viewBox": "0 0 16 16",
|
|
@@ -6129,7 +6220,7 @@ function ErrorIcon() {
|
|
|
6129
6220
|
"cy": "8",
|
|
6130
6221
|
"r": "7"
|
|
6131
6222
|
}, null), createVNode("path", {
|
|
6132
|
-
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8
|
|
6223
|
+
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16 C12.4,16 16,12.4 16,8 C16,3.6 12.4,0 8,0 Z M9,12.6 L7,12.6 L7,10.6 L9,10.6 L9,12.6 Z M9,9.1 L7,9.1 L6.9,3.1 L9.1,3.1 L9,9.1 Z",
|
|
6133
6224
|
"fill-rule": "nonzero"
|
|
6134
6225
|
}, null)])]);
|
|
6135
6226
|
}
|
|
@@ -6142,9 +6233,10 @@ var PopoverIcon = defineComponent({
|
|
|
6142
6233
|
}
|
|
6143
6234
|
},
|
|
6144
6235
|
setup(props) {
|
|
6236
|
+
const ns2 = useNamespace("popover");
|
|
6145
6237
|
return () => props.type && props.type !== "default" && createVNode("span", {
|
|
6146
|
-
"class": "
|
|
6147
|
-
}, [props.type === "success" && createVNode(SuccessIcon, null, null), props.type === "warning" && createVNode(WarningIcon, null, null), props.type === "info" && createVNode(InfoIcon, null, null), props.type === "error" && createVNode(ErrorIcon, null, null)]);
|
|
6238
|
+
"class": ns2.e("icon-wrap")
|
|
6239
|
+
}, [props.type === "success" && createVNode(SuccessIcon$1, null, null), props.type === "warning" && createVNode(WarningIcon, null, null), props.type === "info" && createVNode(InfoIcon, null, null), props.type === "error" && createVNode(ErrorIcon$1, null, null)]);
|
|
6148
6240
|
}
|
|
6149
6241
|
});
|
|
6150
6242
|
var popover = "";
|
|
@@ -6152,9 +6244,11 @@ var Popover = defineComponent({
|
|
|
6152
6244
|
name: "DPopover",
|
|
6153
6245
|
inheritAttrs: false,
|
|
6154
6246
|
props: popoverProps,
|
|
6247
|
+
emits: ["show", "hide"],
|
|
6155
6248
|
setup(props, {
|
|
6156
6249
|
slots,
|
|
6157
|
-
attrs
|
|
6250
|
+
attrs,
|
|
6251
|
+
emit
|
|
6158
6252
|
}) {
|
|
6159
6253
|
const {
|
|
6160
6254
|
content,
|
|
@@ -6169,47 +6263,59 @@ var Popover = defineComponent({
|
|
|
6169
6263
|
const visible = ref(false);
|
|
6170
6264
|
const {
|
|
6171
6265
|
placement,
|
|
6172
|
-
handlePositionChange
|
|
6266
|
+
handlePositionChange,
|
|
6267
|
+
onMouseenter,
|
|
6268
|
+
onMouseleave
|
|
6173
6269
|
} = usePopoverEvent(props, visible, origin);
|
|
6174
6270
|
const {
|
|
6175
6271
|
overlayStyles
|
|
6176
6272
|
} = usePopover(props, visible, placement, origin, popoverRef);
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
"
|
|
6182
|
-
}
|
|
6183
|
-
"
|
|
6273
|
+
const ns2 = useNamespace("popover");
|
|
6274
|
+
provide(POPPER_TRIGGER_TOKEN, origin);
|
|
6275
|
+
watch(visible, (newVal) => {
|
|
6276
|
+
if (newVal) {
|
|
6277
|
+
emit("show");
|
|
6278
|
+
} else {
|
|
6279
|
+
emit("hide");
|
|
6280
|
+
}
|
|
6281
|
+
});
|
|
6282
|
+
return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
|
|
6283
|
+
default: () => {
|
|
6284
|
+
var _a;
|
|
6285
|
+
return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
|
6286
|
+
}
|
|
6287
|
+
}), createVNode(Teleport, {
|
|
6288
|
+
"to": "body"
|
|
6289
|
+
}, {
|
|
6290
|
+
default: () => [createVNode(Transition, {
|
|
6291
|
+
"name": showAnimation.value ? ns2.m(`fade-${placement.value}`) : ""
|
|
6184
6292
|
}, {
|
|
6185
|
-
default: () => [createVNode(
|
|
6186
|
-
"
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
}
|
|
6209
|
-
})]
|
|
6293
|
+
default: () => [createVNode(FlexibleOverlay, mergeProps({
|
|
6294
|
+
"modelValue": visible.value,
|
|
6295
|
+
"onUpdate:modelValue": ($event) => visible.value = $event,
|
|
6296
|
+
"ref": popoverRef,
|
|
6297
|
+
"origin": origin.value,
|
|
6298
|
+
"position": position.value,
|
|
6299
|
+
"align": align.value,
|
|
6300
|
+
"offset": offset2.value,
|
|
6301
|
+
"class": [ns2.e("content"), popType.value !== "default" ? "is-icon" : ""],
|
|
6302
|
+
"show-arrow": true,
|
|
6303
|
+
"is-arrow-center": false,
|
|
6304
|
+
"style": overlayStyles.value
|
|
6305
|
+
}, attrs, {
|
|
6306
|
+
"onPositionChange": handlePositionChange,
|
|
6307
|
+
"onMouseenter": onMouseenter,
|
|
6308
|
+
"onMouseleave": onMouseleave
|
|
6309
|
+
}), {
|
|
6310
|
+
default: () => {
|
|
6311
|
+
var _a;
|
|
6312
|
+
return [createVNode(PopoverIcon, {
|
|
6313
|
+
"type": popType.value
|
|
6314
|
+
}, null), ((_a = slots.content) == null ? void 0 : _a.call(slots)) || createVNode("span", null, [content.value])];
|
|
6315
|
+
}
|
|
6210
6316
|
})]
|
|
6211
|
-
})]
|
|
6212
|
-
};
|
|
6317
|
+
})]
|
|
6318
|
+
})]);
|
|
6213
6319
|
}
|
|
6214
6320
|
});
|
|
6215
6321
|
function HelpTipsIcon() {
|
|
@@ -6228,36 +6334,74 @@ function HelpTipsIcon() {
|
|
|
6228
6334
|
"fill-rule": "nonzero"
|
|
6229
6335
|
}, null)])])]);
|
|
6230
6336
|
}
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
};
|
|
6248
|
-
|
|
6337
|
+
function ErrorIcon() {
|
|
6338
|
+
return createVNode("svg", {
|
|
6339
|
+
"width": "14px",
|
|
6340
|
+
"height": "14px",
|
|
6341
|
+
"viewBox": "0 0 16 16"
|
|
6342
|
+
}, [createVNode("g", {
|
|
6343
|
+
"stroke": "none",
|
|
6344
|
+
"stroke-width": "1",
|
|
6345
|
+
"fill": "none",
|
|
6346
|
+
"fill-rule": "evenodd"
|
|
6347
|
+
}, [createVNode("circle", {
|
|
6348
|
+
"cx": "8",
|
|
6349
|
+
"cy": "8",
|
|
6350
|
+
"r": "8"
|
|
6351
|
+
}, null), createVNode("polygon", {
|
|
6352
|
+
"points": "8.07106781 6.65685425 10.8994949 3.82842712 12.3137085 5.24264069 9.48528137 8.07106781 12.3137085 10.8994949 10.8994949 12.3137085 8.07106781 9.48528137 5.24264069 12.3137085 3.82842712 10.8994949 6.65685425 8.07106781 3.82842712 5.24264069 5.24264069 3.82842712"
|
|
6353
|
+
}, null)])]);
|
|
6354
|
+
}
|
|
6355
|
+
function SuccessIcon() {
|
|
6356
|
+
return createVNode("svg", {
|
|
6357
|
+
"width": "14px",
|
|
6358
|
+
"height": "14px",
|
|
6359
|
+
"viewBox": "0 0 16 16"
|
|
6360
|
+
}, [createVNode("g", {
|
|
6361
|
+
"stroke": "none",
|
|
6362
|
+
"stroke-width": "1",
|
|
6363
|
+
"fill": "none",
|
|
6364
|
+
"fill-rule": "evenodd"
|
|
6365
|
+
}, [createVNode("circle", {
|
|
6366
|
+
"cx": "8",
|
|
6367
|
+
"cy": "8",
|
|
6368
|
+
"r": "8"
|
|
6369
|
+
}, null), createVNode("polygon", {
|
|
6370
|
+
"points": "6.53553391 9.77817459 12.1923882 4.12132034 13.6066017 5.53553391 6.53553391 12.6066017 3 9.07106781 4.41421356 7.65685425 6.53553391 9.77817459"
|
|
6371
|
+
}, null)])]);
|
|
6372
|
+
}
|
|
6373
|
+
function PendingIcon() {
|
|
6374
|
+
return createVNode("svg", {
|
|
6375
|
+
"width": "14px",
|
|
6376
|
+
"height": "14px",
|
|
6377
|
+
"viewBox": "0 0 16 16"
|
|
6378
|
+
}, [createVNode("g", {
|
|
6379
|
+
"id": "loading",
|
|
6380
|
+
"stroke": "none",
|
|
6381
|
+
"stroke-width": "1",
|
|
6382
|
+
"fill": "none",
|
|
6383
|
+
"fill-rule": "evenodd"
|
|
6384
|
+
}, [createVNode("path", {
|
|
6385
|
+
"d": "M8,0 C12.4,0 16,3.6 16,8 C16,12.4 12.4,16 8,16 C3.6,16 0,12.4 0,8 C0,3.6 3.6,0 8,0 Z M8,1 C4.15,1 1,4.15 1,8 C1,11.85 4.15,15 8,15 C11.85,15 15,11.85 15,8 C15,4.15 11.85,1 8,1 Z",
|
|
6386
|
+
"fill-rule": "nonzero"
|
|
6387
|
+
}, null), createVNode("path", {
|
|
6388
|
+
"d": "M8,0 C12.4,0 16,3.6 16,8 L15,8 C15,4.15 11.85,1 8,1 L8,0 Z",
|
|
6389
|
+
"fill-rule": "nonzero"
|
|
6390
|
+
}, null)])]);
|
|
6391
|
+
}
|
|
6249
6392
|
function useFormLabel() {
|
|
6250
|
-
const { labelData } = inject(FORM_TOKEN);
|
|
6251
6393
|
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6252
|
-
const
|
|
6394
|
+
const labelData = inject(LABEL_DATA);
|
|
6395
|
+
const ns2 = useNamespace("form");
|
|
6253
6396
|
const labelClasses = computed(() => ({
|
|
6254
|
-
[`${
|
|
6255
|
-
[`${
|
|
6256
|
-
[`${
|
|
6257
|
-
[`${
|
|
6397
|
+
[`${ns2.e("label")}`]: true,
|
|
6398
|
+
[`${ns2.em("label", "vertical")}`]: labelData.value.layout === "vertical",
|
|
6399
|
+
[`${ns2.em("label", labelData.value.labelSize)}`]: labelData.value.layout === "horizontal",
|
|
6400
|
+
[`${ns2.em("label", labelData.value.labelAlign)}`]: labelData.value.layout === "horizontal"
|
|
6258
6401
|
}));
|
|
6259
6402
|
const labelInnerClasses = computed(() => ({
|
|
6260
|
-
[`${
|
|
6403
|
+
[`${ns2.e("label-span")}`]: true,
|
|
6404
|
+
[`${ns2.em("label", "required")}`]: formItemContext.isRequired
|
|
6261
6405
|
}));
|
|
6262
6406
|
return { labelClasses, labelInnerClasses };
|
|
6263
6407
|
}
|
|
@@ -6266,7 +6410,7 @@ var FormLabel = defineComponent({
|
|
|
6266
6410
|
name: "DFormLabel",
|
|
6267
6411
|
props: formLabelProps,
|
|
6268
6412
|
setup(props, ctx) {
|
|
6269
|
-
const
|
|
6413
|
+
const ns2 = useNamespace("form");
|
|
6270
6414
|
const {
|
|
6271
6415
|
labelClasses,
|
|
6272
6416
|
labelInnerClasses
|
|
@@ -6283,13 +6427,96 @@ var FormLabel = defineComponent({
|
|
|
6283
6427
|
"trigger": "hover",
|
|
6284
6428
|
"pop-type": "info"
|
|
6285
6429
|
}, {
|
|
6286
|
-
|
|
6287
|
-
"class":
|
|
6288
|
-
}, null)
|
|
6430
|
+
default: () => [createVNode(HelpTipsIcon, {
|
|
6431
|
+
"class": ns2.e("label-help")
|
|
6432
|
+
}, null), createTextVNode(",")]
|
|
6289
6433
|
})]);
|
|
6290
6434
|
};
|
|
6291
6435
|
}
|
|
6292
6436
|
});
|
|
6437
|
+
const formControlProps = {
|
|
6438
|
+
feedbackStatus: {
|
|
6439
|
+
type: String
|
|
6440
|
+
},
|
|
6441
|
+
extraInfo: {
|
|
6442
|
+
type: String,
|
|
6443
|
+
default: ""
|
|
6444
|
+
}
|
|
6445
|
+
};
|
|
6446
|
+
function useFormControl(props) {
|
|
6447
|
+
const labelData = inject(LABEL_DATA);
|
|
6448
|
+
const ns2 = useNamespace("form");
|
|
6449
|
+
const { feedbackStatus } = toRefs(props);
|
|
6450
|
+
const controlClasses = computed(() => ({
|
|
6451
|
+
[ns2.e("control")]: true,
|
|
6452
|
+
[ns2.em("control", "horizontal")]: labelData.value.layout === "horizontal"
|
|
6453
|
+
}));
|
|
6454
|
+
const controlContainerClasses = computed(() => ({
|
|
6455
|
+
[ns2.e("control-container")]: true,
|
|
6456
|
+
[ns2.em("control-container", "horizontal")]: labelData.value.layout === "horizontal",
|
|
6457
|
+
[ns2.em("control-container", "has-feedback")]: Boolean(feedbackStatus == null ? void 0 : feedbackStatus.value),
|
|
6458
|
+
[ns2.em("control-container", "feedback-error")]: Boolean((feedbackStatus == null ? void 0 : feedbackStatus.value) === "error")
|
|
6459
|
+
}));
|
|
6460
|
+
return { controlClasses, controlContainerClasses };
|
|
6461
|
+
}
|
|
6462
|
+
function useFormControlValidate() {
|
|
6463
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6464
|
+
const feedbackStatus = computed(() => formItemContext.validateState);
|
|
6465
|
+
const showFeedback = computed(() => formItemContext.showFeedback && Boolean(formItemContext.validateState));
|
|
6466
|
+
const showPopover = computed(() => formItemContext.messageType === "popover" && formItemContext.validateState === "error");
|
|
6467
|
+
const showMessage = computed(() => formItemContext.messageType === "text" && formItemContext.validateState === "error");
|
|
6468
|
+
const errorMessage = computed(() => formItemContext.validateMessage);
|
|
6469
|
+
const popPosition = computed(() => formItemContext.popPosition);
|
|
6470
|
+
return { feedbackStatus, showFeedback, showPopover, showMessage, errorMessage, popPosition };
|
|
6471
|
+
}
|
|
6472
|
+
var formControl = "";
|
|
6473
|
+
var FormControl = defineComponent({
|
|
6474
|
+
name: "DFormControl",
|
|
6475
|
+
props: formControlProps,
|
|
6476
|
+
setup(props, ctx) {
|
|
6477
|
+
const formControl2 = ref();
|
|
6478
|
+
const ns2 = useNamespace("form");
|
|
6479
|
+
const {
|
|
6480
|
+
controlClasses,
|
|
6481
|
+
controlContainerClasses
|
|
6482
|
+
} = useFormControl(props);
|
|
6483
|
+
const {
|
|
6484
|
+
feedbackStatus,
|
|
6485
|
+
showFeedback,
|
|
6486
|
+
showPopover,
|
|
6487
|
+
showMessage,
|
|
6488
|
+
errorMessage,
|
|
6489
|
+
popPosition
|
|
6490
|
+
} = useFormControlValidate();
|
|
6491
|
+
return () => createVNode("div", {
|
|
6492
|
+
"class": controlClasses.value,
|
|
6493
|
+
"ref": formControl2
|
|
6494
|
+
}, [createVNode("div", {
|
|
6495
|
+
"class": controlContainerClasses.value
|
|
6496
|
+
}, [createVNode(Popover, {
|
|
6497
|
+
"is-open": showPopover.value,
|
|
6498
|
+
"trigger": "manually",
|
|
6499
|
+
"content": errorMessage.value,
|
|
6500
|
+
"pop-type": "error",
|
|
6501
|
+
"position": popPosition.value
|
|
6502
|
+
}, {
|
|
6503
|
+
default: () => {
|
|
6504
|
+
var _a, _b;
|
|
6505
|
+
return [createVNode("div", {
|
|
6506
|
+
"class": ns2.e("control-content")
|
|
6507
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createTextVNode(",")];
|
|
6508
|
+
}
|
|
6509
|
+
}), showFeedback.value && createVNode("span", {
|
|
6510
|
+
"class": [ns2.e("feedback-icon"), ns2.em("feedback-icon", feedbackStatus.value)]
|
|
6511
|
+
}, [feedbackStatus.value === "error" && createVNode(ErrorIcon, null, null), feedbackStatus.value === "success" && createVNode(SuccessIcon, null, null), feedbackStatus.value === "pending" && createVNode(PendingIcon, null, null)])]), createVNode("div", {
|
|
6512
|
+
"class": ns2.e("control-info")
|
|
6513
|
+
}, [showMessage.value && createVNode("div", {
|
|
6514
|
+
"class": "error-message"
|
|
6515
|
+
}, [errorMessage.value]), props.extraInfo && createVNode("div", {
|
|
6516
|
+
"class": ns2.e("control-extra")
|
|
6517
|
+
}, [props.extraInfo])])]);
|
|
6518
|
+
}
|
|
6519
|
+
});
|
|
6293
6520
|
function _extends() {
|
|
6294
6521
|
_extends = Object.assign || function(target) {
|
|
6295
6522
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -7292,15 +7519,16 @@ Schema.register = function register(type4, validator) {
|
|
|
7292
7519
|
Schema.warning = warning;
|
|
7293
7520
|
Schema.messages = messages;
|
|
7294
7521
|
Schema.validators = validators;
|
|
7295
|
-
function useFormItem() {
|
|
7296
|
-
const formContext =
|
|
7297
|
-
const
|
|
7298
|
-
const ns = useNamespace("form");
|
|
7522
|
+
function useFormItem(messageType, _rules, validateState) {
|
|
7523
|
+
const formContext = inject(FORM_TOKEN);
|
|
7524
|
+
const ns2 = useNamespace("form");
|
|
7299
7525
|
const itemClasses = computed(() => ({
|
|
7300
|
-
[`${
|
|
7301
|
-
[`${
|
|
7526
|
+
[`${ns2.em("item", "horizontal")}`]: formContext.layout === "horizontal",
|
|
7527
|
+
[`${ns2.em("item", "vertical")}`]: formContext.layout === "vertical",
|
|
7528
|
+
[`${ns2.em("item", "error")}`]: messageType.value === "text" && validateState.value === "error"
|
|
7302
7529
|
}));
|
|
7303
|
-
|
|
7530
|
+
const isRequired = computed(() => _rules.value.some((rule) => Boolean(rule.required)));
|
|
7531
|
+
return { itemClasses, isRequired };
|
|
7304
7532
|
}
|
|
7305
7533
|
function useFormItemRule(props) {
|
|
7306
7534
|
const formContext = inject(FORM_TOKEN);
|
|
@@ -7324,15 +7552,22 @@ function useFormItemValidate(props, _rules) {
|
|
|
7324
7552
|
const formContext = inject(FORM_TOKEN);
|
|
7325
7553
|
const validateState = ref("");
|
|
7326
7554
|
const validateMessage = ref("");
|
|
7555
|
+
let initFieldValue = void 0;
|
|
7556
|
+
let isResetting = false;
|
|
7327
7557
|
const computedField = computed(() => {
|
|
7328
7558
|
return typeof props.field === "string" ? props.field : "";
|
|
7329
7559
|
});
|
|
7330
|
-
const fieldValue = computed(
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7560
|
+
const fieldValue = computed({
|
|
7561
|
+
get: () => {
|
|
7562
|
+
const formData = formContext.data;
|
|
7563
|
+
if (!formData || !props.field) {
|
|
7564
|
+
return;
|
|
7565
|
+
}
|
|
7566
|
+
return formData[props.field];
|
|
7567
|
+
},
|
|
7568
|
+
set: (val) => {
|
|
7569
|
+
formContext.data[props.field] = val;
|
|
7334
7570
|
}
|
|
7335
|
-
return formData[props.field];
|
|
7336
7571
|
});
|
|
7337
7572
|
const getRuleByTrigger = (triggerVal) => {
|
|
7338
7573
|
return _rules.value.filter((rule) => {
|
|
@@ -7352,11 +7587,13 @@ function useFormItemValidate(props, _rules) {
|
|
|
7352
7587
|
const onValidateSuccess = () => {
|
|
7353
7588
|
validateState.value = "success";
|
|
7354
7589
|
validateMessage.value = "";
|
|
7590
|
+
formContext.emit("validate", props.field, true, "");
|
|
7355
7591
|
};
|
|
7356
7592
|
const onValidateError = ({ errors }) => {
|
|
7357
7593
|
var _a;
|
|
7358
7594
|
validateState.value = "error";
|
|
7359
7595
|
validateMessage.value = ((_a = errors == null ? void 0 : errors[0]) == null ? void 0 : _a.message) || "";
|
|
7596
|
+
formContext.emit("validate", props.field, false, validateMessage.value);
|
|
7360
7597
|
};
|
|
7361
7598
|
const execValidate = async (rules2) => {
|
|
7362
7599
|
const ruleName = computedField.value;
|
|
@@ -7372,6 +7609,10 @@ function useFormItemValidate(props, _rules) {
|
|
|
7372
7609
|
});
|
|
7373
7610
|
};
|
|
7374
7611
|
const validate = async (trigger, callback) => {
|
|
7612
|
+
if (isResetting) {
|
|
7613
|
+
isResetting = false;
|
|
7614
|
+
return false;
|
|
7615
|
+
}
|
|
7375
7616
|
const rules2 = getRuleByTrigger(trigger);
|
|
7376
7617
|
if (!rules2.length) {
|
|
7377
7618
|
callback == null ? void 0 : callback(true);
|
|
@@ -7387,7 +7628,23 @@ function useFormItemValidate(props, _rules) {
|
|
|
7387
7628
|
return lodash.exports.isFunction(callback) ? false : Promise.reject(fields);
|
|
7388
7629
|
});
|
|
7389
7630
|
};
|
|
7390
|
-
|
|
7631
|
+
const clearValidate = () => {
|
|
7632
|
+
validateState.value = "";
|
|
7633
|
+
validateMessage.value = "";
|
|
7634
|
+
};
|
|
7635
|
+
const resetField = async () => {
|
|
7636
|
+
if (!formContext.data || !props.field) {
|
|
7637
|
+
return;
|
|
7638
|
+
}
|
|
7639
|
+
isResetting = true;
|
|
7640
|
+
fieldValue.value = initFieldValue;
|
|
7641
|
+
await nextTick();
|
|
7642
|
+
clearValidate();
|
|
7643
|
+
};
|
|
7644
|
+
onMounted(() => {
|
|
7645
|
+
initFieldValue = lodash.exports.cloneDeep(formContext.data[props.field]);
|
|
7646
|
+
});
|
|
7647
|
+
return { validateState, validateMessage, validate, resetField, clearValidate };
|
|
7391
7648
|
}
|
|
7392
7649
|
var formItem = "";
|
|
7393
7650
|
var FormItem = defineComponent({
|
|
@@ -7395,23 +7652,60 @@ var FormItem = defineComponent({
|
|
|
7395
7652
|
props: formItemProps,
|
|
7396
7653
|
setup(props, ctx) {
|
|
7397
7654
|
const formContext = inject(FORM_TOKEN);
|
|
7655
|
+
const _a = toRefs(props), {
|
|
7656
|
+
messageType: itemMessageType,
|
|
7657
|
+
popPosition: itemPopPosition,
|
|
7658
|
+
showFeedback: itemShowFeedback
|
|
7659
|
+
} = _a, otherProps = __objRest(_a, [
|
|
7660
|
+
"messageType",
|
|
7661
|
+
"popPosition",
|
|
7662
|
+
"showFeedback"
|
|
7663
|
+
]);
|
|
7398
7664
|
const {
|
|
7399
|
-
|
|
7400
|
-
|
|
7665
|
+
label,
|
|
7666
|
+
helpTips,
|
|
7667
|
+
feedbackStatus,
|
|
7668
|
+
extraInfo
|
|
7669
|
+
} = toRefs(props);
|
|
7670
|
+
const showFeedback = computed(() => (itemShowFeedback == null ? void 0 : itemShowFeedback.value) !== void 0 ? itemShowFeedback.value : formContext.showFeedback);
|
|
7671
|
+
const messageType = computed(() => (itemMessageType == null ? void 0 : itemMessageType.value) || formContext.messageType);
|
|
7672
|
+
const popPosition = computed(() => (itemPopPosition == null ? void 0 : itemPopPosition.value) || formContext.popPosition);
|
|
7401
7673
|
const {
|
|
7402
7674
|
_rules
|
|
7403
7675
|
} = useFormItemRule(props);
|
|
7404
7676
|
const {
|
|
7405
7677
|
validateState,
|
|
7406
7678
|
validateMessage,
|
|
7407
|
-
validate
|
|
7679
|
+
validate,
|
|
7680
|
+
resetField,
|
|
7681
|
+
clearValidate
|
|
7408
7682
|
} = useFormItemValidate(props, _rules);
|
|
7409
|
-
const
|
|
7683
|
+
const {
|
|
7684
|
+
itemClasses,
|
|
7685
|
+
isRequired
|
|
7686
|
+
} = useFormItem(messageType, _rules, validateState);
|
|
7687
|
+
const labelData = computed(() => ({
|
|
7688
|
+
layout: formContext.layout,
|
|
7689
|
+
labelSize: formContext.labelSize,
|
|
7690
|
+
labelAlign: formContext.labelAlign
|
|
7691
|
+
}));
|
|
7692
|
+
provide(LABEL_DATA, labelData);
|
|
7693
|
+
const context = reactive(__spreadProps(__spreadValues({}, otherProps), {
|
|
7694
|
+
showFeedback,
|
|
7695
|
+
messageType,
|
|
7696
|
+
popPosition,
|
|
7697
|
+
isRequired,
|
|
7410
7698
|
validateState,
|
|
7411
7699
|
validateMessage,
|
|
7412
|
-
validate
|
|
7700
|
+
validate,
|
|
7701
|
+
resetField,
|
|
7702
|
+
clearValidate
|
|
7413
7703
|
}));
|
|
7414
7704
|
provide(FORM_ITEM_TOKEN, context);
|
|
7705
|
+
ctx.expose({
|
|
7706
|
+
resetField,
|
|
7707
|
+
clearValidate
|
|
7708
|
+
});
|
|
7415
7709
|
onMounted(() => {
|
|
7416
7710
|
if (props.field) {
|
|
7417
7711
|
formContext == null ? void 0 : formContext.addItemContext(context);
|
|
@@ -7420,94 +7714,35 @@ var FormItem = defineComponent({
|
|
|
7420
7714
|
onBeforeUnmount(() => {
|
|
7421
7715
|
formContext == null ? void 0 : formContext.removeItemContext(context);
|
|
7422
7716
|
});
|
|
7423
|
-
return () => {
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
}
|
|
7439
|
-
};
|
|
7440
|
-
function useFormControl(props) {
|
|
7441
|
-
const formContext = inject(FORM_TOKEN);
|
|
7442
|
-
const labelData = reactive(formContext.labelData);
|
|
7443
|
-
const ns = useNamespace("form");
|
|
7444
|
-
const { feedbackStatus } = toRefs(props);
|
|
7445
|
-
const controlClasses = computed(() => ({
|
|
7446
|
-
[`${ns.e("control")}`]: true,
|
|
7447
|
-
[`${ns.em("control", "horizontal")}`]: labelData.layout === "horizontal"
|
|
7448
|
-
}));
|
|
7449
|
-
const controlContainerClasses = computed(() => ({
|
|
7450
|
-
[`${ns.e("control-container")}`]: true,
|
|
7451
|
-
[`${ns.em("control-container", "horizontal")}`]: labelData.layout === "horizontal",
|
|
7452
|
-
[`${ns.em("control-container", "has-feedback")}`]: Boolean(feedbackStatus.value),
|
|
7453
|
-
[`${ns.em("control-container", "feedback-error")}`]: Boolean(feedbackStatus.value === "error")
|
|
7454
|
-
}));
|
|
7455
|
-
return { controlClasses, controlContainerClasses };
|
|
7456
|
-
}
|
|
7457
|
-
function useFormControlValidate() {
|
|
7458
|
-
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
7459
|
-
const errorMessage = computed(() => formItemContext.validateMessage);
|
|
7460
|
-
return { errorMessage };
|
|
7461
|
-
}
|
|
7462
|
-
var formControl = "";
|
|
7463
|
-
var FormControl = defineComponent({
|
|
7464
|
-
name: "DFormControl",
|
|
7465
|
-
props: formControlProps,
|
|
7466
|
-
setup(props, ctx) {
|
|
7467
|
-
const formControl2 = ref();
|
|
7468
|
-
const uid = lodash.exports.uniqueId("dfc-");
|
|
7469
|
-
const ns = useNamespace("form");
|
|
7470
|
-
const {
|
|
7471
|
-
controlClasses,
|
|
7472
|
-
controlContainerClasses
|
|
7473
|
-
} = useFormControl(props);
|
|
7474
|
-
const {
|
|
7475
|
-
errorMessage
|
|
7476
|
-
} = useFormControlValidate();
|
|
7477
|
-
return () => {
|
|
7478
|
-
var _a, _b;
|
|
7479
|
-
return createVNode("div", {
|
|
7480
|
-
"class": controlClasses.value,
|
|
7481
|
-
"ref": formControl2,
|
|
7482
|
-
"data-uid": uid
|
|
7483
|
-
}, [createVNode("div", {
|
|
7484
|
-
"class": controlContainerClasses.value
|
|
7485
|
-
}, [createVNode("div", {
|
|
7486
|
-
"class": ns.e("control-content"),
|
|
7487
|
-
"id": uid
|
|
7488
|
-
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])]), createVNode("div", {
|
|
7489
|
-
"class": ns.e("control-info")
|
|
7490
|
-
}, [errorMessage.value && createVNode("div", {
|
|
7491
|
-
"class": "error-message"
|
|
7492
|
-
}, [errorMessage.value]), props.extraInfo && createVNode("div", {
|
|
7493
|
-
"class": ns.e("control-extra")
|
|
7494
|
-
}, [props.extraInfo])])]);
|
|
7495
|
-
};
|
|
7717
|
+
return () => createVNode("div", {
|
|
7718
|
+
"class": itemClasses.value
|
|
7719
|
+
}, [createVNode(FormLabel, {
|
|
7720
|
+
"help-tips": helpTips.value
|
|
7721
|
+
}, {
|
|
7722
|
+
default: () => [label == null ? void 0 : label.value]
|
|
7723
|
+
}), createVNode(FormControl, {
|
|
7724
|
+
"feedback-status": feedbackStatus == null ? void 0 : feedbackStatus.value,
|
|
7725
|
+
"extra-info": extraInfo.value
|
|
7726
|
+
}, {
|
|
7727
|
+
default: () => {
|
|
7728
|
+
var _a2, _b;
|
|
7729
|
+
return [(_b = (_a2 = ctx.slots).default) == null ? void 0 : _b.call(_a2)];
|
|
7730
|
+
}
|
|
7731
|
+
})]);
|
|
7496
7732
|
}
|
|
7497
7733
|
});
|
|
7498
7734
|
var formOperation = "";
|
|
7499
7735
|
var FormOperation = defineComponent({
|
|
7500
7736
|
name: "DFormOperation",
|
|
7501
7737
|
setup(props, ctx) {
|
|
7502
|
-
const formContext =
|
|
7503
|
-
const labelData = reactive(formContext.labelData);
|
|
7738
|
+
const formContext = inject(FORM_TOKEN);
|
|
7504
7739
|
const LabelSizeMap = {
|
|
7505
7740
|
sm: 80,
|
|
7506
7741
|
md: 100,
|
|
7507
7742
|
lg: 150
|
|
7508
7743
|
};
|
|
7509
7744
|
const styles = computed(() => ({
|
|
7510
|
-
marginLeft:
|
|
7745
|
+
marginLeft: formContext.layout === "horizontal" ? `${LabelSizeMap[formContext.labelSize] + 16}px` : void 0
|
|
7511
7746
|
}));
|
|
7512
7747
|
return () => {
|
|
7513
7748
|
var _a, _b;
|
|
@@ -7518,364 +7753,14 @@ var FormOperation = defineComponent({
|
|
|
7518
7753
|
};
|
|
7519
7754
|
}
|
|
7520
7755
|
});
|
|
7521
|
-
var style = "";
|
|
7522
|
-
function getAvaliableRuleObj(ruleName, value) {
|
|
7523
|
-
if (!ruleName) {
|
|
7524
|
-
console.error("[v-d-validate] validator's key is invalid");
|
|
7525
|
-
return null;
|
|
7526
|
-
}
|
|
7527
|
-
switch (ruleName) {
|
|
7528
|
-
case "maxlength":
|
|
7529
|
-
return {
|
|
7530
|
-
type: "string",
|
|
7531
|
-
max: value,
|
|
7532
|
-
asyncValidator: (rule, val) => {
|
|
7533
|
-
return new Promise((resolve, reject) => {
|
|
7534
|
-
if (val.length > value) {
|
|
7535
|
-
reject("\u6700\u5927\u957F\u5EA6\u4E3A" + value);
|
|
7536
|
-
} else {
|
|
7537
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7538
|
-
}
|
|
7539
|
-
});
|
|
7540
|
-
}
|
|
7541
|
-
};
|
|
7542
|
-
case "minlength":
|
|
7543
|
-
return {
|
|
7544
|
-
type: "string",
|
|
7545
|
-
min: value,
|
|
7546
|
-
asyncValidator: (rule, val) => {
|
|
7547
|
-
return new Promise((resolve, reject) => {
|
|
7548
|
-
if (val.length < value) {
|
|
7549
|
-
reject("\u6700\u5C0F\u957F\u5EA6\u4E3A" + value);
|
|
7550
|
-
} else {
|
|
7551
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7552
|
-
}
|
|
7553
|
-
});
|
|
7554
|
-
}
|
|
7555
|
-
};
|
|
7556
|
-
case "min":
|
|
7557
|
-
return {
|
|
7558
|
-
type: "number",
|
|
7559
|
-
asyncValidator: (rule, val) => {
|
|
7560
|
-
return new Promise((resolve, reject) => {
|
|
7561
|
-
if (val < value) {
|
|
7562
|
-
reject("\u6700\u5C0F\u503C\u4E3A" + value);
|
|
7563
|
-
} else {
|
|
7564
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7565
|
-
}
|
|
7566
|
-
});
|
|
7567
|
-
}
|
|
7568
|
-
};
|
|
7569
|
-
case "max":
|
|
7570
|
-
return {
|
|
7571
|
-
type: "number",
|
|
7572
|
-
asyncValidator: (rule, val) => {
|
|
7573
|
-
return new Promise((resolve, reject) => {
|
|
7574
|
-
if (val > value) {
|
|
7575
|
-
reject("\u6700\u5927\u503C\u4E3A" + value);
|
|
7576
|
-
} else {
|
|
7577
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7578
|
-
}
|
|
7579
|
-
});
|
|
7580
|
-
}
|
|
7581
|
-
};
|
|
7582
|
-
case "required":
|
|
7583
|
-
return {
|
|
7584
|
-
reqiured: true,
|
|
7585
|
-
asyncValidator: (rule, val) => {
|
|
7586
|
-
return new Promise((resolve, reject) => {
|
|
7587
|
-
if (!val) {
|
|
7588
|
-
reject("\u5FC5\u586B\u9879");
|
|
7589
|
-
} else {
|
|
7590
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7591
|
-
}
|
|
7592
|
-
});
|
|
7593
|
-
}
|
|
7594
|
-
};
|
|
7595
|
-
case "requiredTrue":
|
|
7596
|
-
return {
|
|
7597
|
-
asyncValidator: (rule, val) => {
|
|
7598
|
-
return new Promise((resolve, reject) => {
|
|
7599
|
-
if (!val) {
|
|
7600
|
-
reject("\u5FC5\u987B\u4E3Atrue\u503C");
|
|
7601
|
-
} else {
|
|
7602
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7603
|
-
}
|
|
7604
|
-
});
|
|
7605
|
-
}
|
|
7606
|
-
};
|
|
7607
|
-
case "email":
|
|
7608
|
-
return {
|
|
7609
|
-
type: "email",
|
|
7610
|
-
message: "\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E"
|
|
7611
|
-
};
|
|
7612
|
-
case "pattern":
|
|
7613
|
-
return {
|
|
7614
|
-
type: "regexp",
|
|
7615
|
-
pattern: value,
|
|
7616
|
-
message: "\u53EA\u80FD\u5305\u542B\u6570\u5B57\u4E0E\u5927\u5C0F\u5199\u5B57\u7B26",
|
|
7617
|
-
validator: (rule, val) => value.test(val)
|
|
7618
|
-
};
|
|
7619
|
-
case "whitespace":
|
|
7620
|
-
return {
|
|
7621
|
-
message: "\u8F93\u5165\u4E0D\u80FD\u5168\u90E8\u4E3A\u7A7A\u683C\u6216\u7A7A\u5B57\u7B26",
|
|
7622
|
-
validator: (rule, val) => !!val.trim()
|
|
7623
|
-
};
|
|
7624
|
-
default:
|
|
7625
|
-
return {
|
|
7626
|
-
[ruleName]: value
|
|
7627
|
-
};
|
|
7628
|
-
}
|
|
7629
|
-
}
|
|
7630
|
-
function getKeyValueOfObjectList(obj) {
|
|
7631
|
-
const kvArr = [];
|
|
7632
|
-
for (const key in obj) {
|
|
7633
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
7634
|
-
kvArr.push({
|
|
7635
|
-
key,
|
|
7636
|
-
value: obj[key]
|
|
7637
|
-
});
|
|
7638
|
-
}
|
|
7639
|
-
}
|
|
7640
|
-
return kvArr;
|
|
7641
|
-
}
|
|
7642
|
-
function handleErrorStrategy(el) {
|
|
7643
|
-
const classList = [...el.classList];
|
|
7644
|
-
classList.push("devui-validate-rules-error-pristine");
|
|
7645
|
-
el.setAttribute("class", classList.join(" "));
|
|
7646
|
-
}
|
|
7647
|
-
function handleErrorStrategyPass(el) {
|
|
7648
|
-
const classList = [...el.classList];
|
|
7649
|
-
const index2 = classList.indexOf("devui-validate-rules-error-pristine");
|
|
7650
|
-
index2 !== -1 && classList.splice(index2, 1);
|
|
7651
|
-
el.setAttribute("class", classList.join(" "));
|
|
7652
|
-
}
|
|
7653
|
-
function getFormControlUID(el) {
|
|
7654
|
-
if (el.tagName.toLocaleLowerCase() === "body") {
|
|
7655
|
-
return "";
|
|
7656
|
-
}
|
|
7657
|
-
if (el.parentElement.id.startsWith("dfc-")) {
|
|
7658
|
-
return el.parentElement.id;
|
|
7659
|
-
} else {
|
|
7660
|
-
getFormControlUID(el.parentElement);
|
|
7661
|
-
}
|
|
7662
|
-
}
|
|
7663
|
-
function handleValidateError({
|
|
7664
|
-
el,
|
|
7665
|
-
tipEl,
|
|
7666
|
-
message = "",
|
|
7667
|
-
isFormTag,
|
|
7668
|
-
messageShowType,
|
|
7669
|
-
dfcUID,
|
|
7670
|
-
popPosition = "right-bottom",
|
|
7671
|
-
updateOn
|
|
7672
|
-
}) {
|
|
7673
|
-
if (isFormTag && messageShowType === "toast") {
|
|
7674
|
-
alert(message);
|
|
7675
|
-
return;
|
|
7676
|
-
}
|
|
7677
|
-
if (!dfcUID) {
|
|
7678
|
-
dfcUID = getFormControlUID(el);
|
|
7679
|
-
}
|
|
7680
|
-
if (messageShowType === "popover") {
|
|
7681
|
-
EventBus.emit("showPopoverErrorMessage", {
|
|
7682
|
-
showPopover: true,
|
|
7683
|
-
message,
|
|
7684
|
-
uid: dfcUID,
|
|
7685
|
-
popPosition,
|
|
7686
|
-
updateOn
|
|
7687
|
-
});
|
|
7688
|
-
return;
|
|
7689
|
-
}
|
|
7690
|
-
tipEl.innerText = "" + message;
|
|
7691
|
-
tipEl.style.display = "inline-flex";
|
|
7692
|
-
tipEl.setAttribute("class", "devui-validate-tip");
|
|
7693
|
-
handleErrorStrategy(el);
|
|
7694
|
-
}
|
|
7695
|
-
function handleValidatePass(el, tipEl) {
|
|
7696
|
-
tipEl.style.display = "none";
|
|
7697
|
-
handleErrorStrategyPass(el);
|
|
7698
|
-
}
|
|
7699
|
-
function getRefName(binding) {
|
|
7700
|
-
const _refs = binding.instance.$refs;
|
|
7701
|
-
const refName = Object.keys(_refs)[0];
|
|
7702
|
-
return refName;
|
|
7703
|
-
}
|
|
7704
|
-
function getFormName(binding) {
|
|
7705
|
-
const _refs = binding.instance.$refs;
|
|
7706
|
-
const key = Object.keys(_refs)[0];
|
|
7707
|
-
return _refs[key]["name"];
|
|
7708
|
-
}
|
|
7709
|
-
function validateFn({
|
|
7710
|
-
validator,
|
|
7711
|
-
modelValue,
|
|
7712
|
-
el,
|
|
7713
|
-
tipEl,
|
|
7714
|
-
isFormTag,
|
|
7715
|
-
messageShowType,
|
|
7716
|
-
dfcUID,
|
|
7717
|
-
popPosition,
|
|
7718
|
-
updateOn
|
|
7719
|
-
}) {
|
|
7720
|
-
validator.validate({ modelName: modelValue }).then(() => {
|
|
7721
|
-
handleValidatePass(el, tipEl);
|
|
7722
|
-
}).catch((err) => {
|
|
7723
|
-
const { errors } = err;
|
|
7724
|
-
if (!errors || errors.length === 0) {
|
|
7725
|
-
return;
|
|
7726
|
-
}
|
|
7727
|
-
let msg = "";
|
|
7728
|
-
if (typeof errors[0].message === "object") {
|
|
7729
|
-
msg = errors[0].message.default;
|
|
7730
|
-
} else {
|
|
7731
|
-
msg = errors[0].message;
|
|
7732
|
-
}
|
|
7733
|
-
handleValidateError({ el, tipEl, message: msg, isFormTag, messageShowType, dfcUID, popPosition, updateOn });
|
|
7734
|
-
});
|
|
7735
|
-
}
|
|
7736
|
-
function checkValidPopsition(positionStr) {
|
|
7737
|
-
const validPosition = [
|
|
7738
|
-
"left",
|
|
7739
|
-
"right",
|
|
7740
|
-
"top",
|
|
7741
|
-
"bottom",
|
|
7742
|
-
"left-top",
|
|
7743
|
-
"left-bottom",
|
|
7744
|
-
"top-left",
|
|
7745
|
-
"top-right",
|
|
7746
|
-
"right-top",
|
|
7747
|
-
"right-bottom",
|
|
7748
|
-
"bottom-left",
|
|
7749
|
-
"bottom-right"
|
|
7750
|
-
];
|
|
7751
|
-
const isValid = validPosition.includes(positionStr);
|
|
7752
|
-
!isValid && console.warn(`invalid popPosition value '${positionStr}'.`);
|
|
7753
|
-
return isValid;
|
|
7754
|
-
}
|
|
7755
|
-
var dValidateRules = {
|
|
7756
|
-
mounted(el, binding, vnode) {
|
|
7757
|
-
var _a;
|
|
7758
|
-
const isFormTag = el.tagName === "FORM";
|
|
7759
|
-
const dfcUID = el.parentNode.parentNode.parentElement.dataset.uid;
|
|
7760
|
-
const refName = getRefName(binding);
|
|
7761
|
-
const hasOptions = isObject(binding.value) && hasKey(binding.value, "options");
|
|
7762
|
-
let { rules: bindingRules, options = {}, messageShowType = "popover" } = binding.value;
|
|
7763
|
-
let { errorStrategy } = binding.value;
|
|
7764
|
-
if (refName) {
|
|
7765
|
-
messageShowType = (_a = binding.instance[refName]["messageShowType"]) != null ? _a : "popover";
|
|
7766
|
-
}
|
|
7767
|
-
let {
|
|
7768
|
-
updateOn = "change",
|
|
7769
|
-
errorStrategy: ErrorStrategy = "dirty",
|
|
7770
|
-
asyncDebounceTime = 300,
|
|
7771
|
-
popPosition = ["right", "bottom"]
|
|
7772
|
-
} = options;
|
|
7773
|
-
if (messageShowType === "popover") {
|
|
7774
|
-
if (Array.isArray(popPosition)) {
|
|
7775
|
-
popPosition = popPosition.length > 1 ? popPosition.join("-") : popPosition[0];
|
|
7776
|
-
if (!checkValidPopsition(popPosition)) {
|
|
7777
|
-
popPosition = "right-bottom";
|
|
7778
|
-
}
|
|
7779
|
-
} else if (!checkValidPopsition(popPosition)) {
|
|
7780
|
-
popPosition = "right-bottom";
|
|
7781
|
-
}
|
|
7782
|
-
}
|
|
7783
|
-
if (!errorStrategy) {
|
|
7784
|
-
errorStrategy = ErrorStrategy;
|
|
7785
|
-
}
|
|
7786
|
-
let customRule = {};
|
|
7787
|
-
if (hasOptions) {
|
|
7788
|
-
customRule = bindingRules != null ? bindingRules : binding.value;
|
|
7789
|
-
} else {
|
|
7790
|
-
customRule = binding.value;
|
|
7791
|
-
}
|
|
7792
|
-
const isCustomValidator = customRule && isObject(customRule) && (hasKey(customRule, "validators") || hasKey(customRule, "asyncValidators"));
|
|
7793
|
-
const rules2 = Array.isArray(customRule) ? customRule : [customRule];
|
|
7794
|
-
const tipEl = document.createElement("span");
|
|
7795
|
-
if (messageShowType !== "none") {
|
|
7796
|
-
el.parentNode.append(tipEl);
|
|
7797
|
-
}
|
|
7798
|
-
const descriptor = {
|
|
7799
|
-
modelName: []
|
|
7800
|
-
};
|
|
7801
|
-
rules2.forEach((rule) => {
|
|
7802
|
-
const kvObjList = !Array.isArray(rule) && getKeyValueOfObjectList(rule);
|
|
7803
|
-
let ruleObj = {};
|
|
7804
|
-
let avaliableRuleObj = {};
|
|
7805
|
-
kvObjList.forEach((item) => {
|
|
7806
|
-
avaliableRuleObj = getAvaliableRuleObj(item.key, item.value);
|
|
7807
|
-
ruleObj = __spreadValues(__spreadValues({}, ruleObj), avaliableRuleObj);
|
|
7808
|
-
});
|
|
7809
|
-
descriptor.modelName.push(ruleObj);
|
|
7810
|
-
});
|
|
7811
|
-
if (isCustomValidator) {
|
|
7812
|
-
const { validators: validators2, asyncValidators } = customRule;
|
|
7813
|
-
validators2 && validators2.forEach((item) => {
|
|
7814
|
-
const ruleObj = {
|
|
7815
|
-
message: (item == null ? void 0 : item.message) || "",
|
|
7816
|
-
validator: (rule, value) => item.validator(rule, value)
|
|
7817
|
-
};
|
|
7818
|
-
descriptor.modelName.push(ruleObj);
|
|
7819
|
-
});
|
|
7820
|
-
asyncValidators && asyncValidators.forEach((item) => {
|
|
7821
|
-
const ruleObj = {
|
|
7822
|
-
message: (item == null ? void 0 : item.message) || "",
|
|
7823
|
-
asyncValidator: (rule, value) => {
|
|
7824
|
-
return new Promise(lodash.exports.debounce((resolve, reject) => {
|
|
7825
|
-
const res = item.asyncValidator(rule, value);
|
|
7826
|
-
if (res) {
|
|
7827
|
-
resolve("");
|
|
7828
|
-
} else {
|
|
7829
|
-
reject(rule.message);
|
|
7830
|
-
}
|
|
7831
|
-
}, asyncDebounceTime));
|
|
7832
|
-
}
|
|
7833
|
-
};
|
|
7834
|
-
descriptor.modelName.push(ruleObj);
|
|
7835
|
-
});
|
|
7836
|
-
}
|
|
7837
|
-
const validator = new Schema(descriptor);
|
|
7838
|
-
const htmlEventValidateHandler = (e) => {
|
|
7839
|
-
const modelValue = e.target.value;
|
|
7840
|
-
if (messageShowType === "popover") {
|
|
7841
|
-
EventBus.emit("showPopoverErrorMessage", {
|
|
7842
|
-
showPopover: false,
|
|
7843
|
-
message: "",
|
|
7844
|
-
uid: dfcUID,
|
|
7845
|
-
popPosition,
|
|
7846
|
-
updateOn
|
|
7847
|
-
});
|
|
7848
|
-
}
|
|
7849
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition, updateOn });
|
|
7850
|
-
};
|
|
7851
|
-
vnode.children[0].el.addEventListener(updateOn, htmlEventValidateHandler);
|
|
7852
|
-
if (messageShowType === "popover" && updateOn === "change") {
|
|
7853
|
-
vnode.children[0].el.addEventListener("focus", () => {
|
|
7854
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: false, uid: dfcUID, updateOn });
|
|
7855
|
-
});
|
|
7856
|
-
}
|
|
7857
|
-
if (errorStrategy === "pristine") {
|
|
7858
|
-
handleErrorStrategy(el);
|
|
7859
|
-
vnode.children[0].props.value = "" + vnode.children[0].props.value;
|
|
7860
|
-
}
|
|
7861
|
-
const formName = getFormName(binding);
|
|
7862
|
-
formName && EventBus.on(`formSubmit:${formName}`, () => {
|
|
7863
|
-
const modelValue = isFormTag ? "" : vnode.children[0].el.value;
|
|
7864
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, updateOn: "submit" });
|
|
7865
|
-
});
|
|
7866
|
-
}
|
|
7867
|
-
};
|
|
7868
7756
|
var index = {
|
|
7869
7757
|
title: "Form \u8868\u5355",
|
|
7870
7758
|
category: "\u6570\u636E\u5F55\u5165",
|
|
7871
7759
|
status: "75%",
|
|
7872
7760
|
install(app) {
|
|
7873
7761
|
app.component(Form.name, Form);
|
|
7874
|
-
app.directive("d-validate-rules", dValidateRules);
|
|
7875
|
-
app.component(FormLabel.name, FormLabel);
|
|
7876
7762
|
app.component(FormItem.name, FormItem);
|
|
7877
|
-
app.component(FormControl.name, FormControl);
|
|
7878
7763
|
app.component(FormOperation.name, FormOperation);
|
|
7879
7764
|
}
|
|
7880
7765
|
};
|
|
7881
|
-
export {
|
|
7766
|
+
export { FORM_ITEM_TOKEN, FORM_TOKEN, Form, FormItem, FormOperation, LABEL_DATA, index as default, formControlProps, formItemProps, formProps };
|