vue-devui 1.0.0-pre.0 → 1.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -187
- package/alert/index.es.js +74 -45
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +8182 -296
- package/auto-complete/index.umd.js +29 -1
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +153 -146
- package/avatar/index.umd.js +1 -1
- package/avatar/style.css +1 -1
- package/badge/index.es.js +30 -5
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +5741 -127
- package/button/index.umd.js +27 -1
- package/button/style.css +1 -1
- package/card/index.es.js +59 -35
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +8060 -255
- package/checkbox/index.umd.js +27 -1
- package/checkbox/style.css +1 -1
- package/{accordion → collapse}/index.d.ts +0 -0
- package/collapse/index.es.js +379 -0
- package/collapse/index.umd.js +1 -0
- package/{anchor → collapse}/package.json +1 -1
- package/collapse/style.css +1 -0
- package/countdown/index.es.js +5 -7
- package/countdown/index.umd.js +1 -1
- package/date-picker/index.es.js +8159 -288
- package/date-picker/index.umd.js +27 -1
- package/date-picker/style.css +1 -1
- package/drawer/index.es.js +31 -4
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +297 -181
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +525 -154
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +1039 -1175
- package/form/index.umd.js +15 -15
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +42 -21
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/grid/index.es.js +101 -86
- package/grid/index.umd.js +1 -1
- package/grid/style.css +1 -1
- package/icon/index.es.js +197 -56
- package/icon/index.umd.js +1 -1
- package/icon/style.css +1 -0
- package/image-preview/index.es.js +55 -31
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +8066 -144
- package/input/index.umd.js +27 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +269 -183
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +40 -25
- package/layout/index.umd.js +1 -1
- package/layout/style.css +1 -1
- package/loading/index.es.js +74 -35
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/modal/index.es.js +412 -204
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +307 -57
- 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/Collapse.js +3 -0
- package/nuxt/components/CollapseItem.js +3 -0
- package/nuxt/components/DropdownPropsKey.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/IconGroup.js +3 -0
- package/nuxt/components/LABEL_DATA.js +3 -0
- package/nuxt/components/LoadingOptions.js +3 -0
- package/nuxt/components/Option.js +3 -0
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/RadioButton.js +3 -0
- package/nuxt/components/Tab.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/autoCompleteProps.js +3 -0
- package/nuxt/components/avatarProps.js +3 -0
- package/nuxt/components/buttonGroupInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupProps.js +3 -0
- package/nuxt/components/cardProps.js +3 -0
- package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
- package/nuxt/components/checkboxGroupProps.js +3 -0
- package/nuxt/components/checkboxProps.js +3 -0
- package/nuxt/components/colProps.js +3 -0
- package/nuxt/components/colPropsBaseClass.js +3 -0
- package/nuxt/components/colPropsBaseStyle.js +3 -0
- package/nuxt/components/collapseItemProps.js +3 -0
- package/nuxt/components/collapseProps.js +3 -0
- package/nuxt/components/countdownProps.js +3 -0
- package/nuxt/components/editableSelectProps.js +3 -0
- package/nuxt/components/formItemProps.js +3 -0
- package/nuxt/components/formProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +3 -0
- package/nuxt/components/imagePreviewProps.js +3 -0
- package/nuxt/components/inputProps.js +3 -0
- package/nuxt/components/loadingProps.js +3 -0
- package/nuxt/components/modalProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/progressProps.js +3 -0
- package/nuxt/components/rateProps.js +3 -0
- package/nuxt/components/resultProps.js +3 -0
- package/nuxt/components/rowProps.js +3 -0
- package/nuxt/components/screenSizes.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/skeletonProps.js +3 -0
- package/nuxt/components/sliderProps.js +3 -0
- package/nuxt/components/splitterProps.js +3 -0
- package/nuxt/components/statisticProps.js +3 -0
- package/nuxt/components/svgIconProps.js +3 -0
- package/nuxt/components/switchProps.js +3 -0
- package/nuxt/components/tabsProps.js +3 -0
- package/nuxt/components/tagProps.js +3 -0
- package/nuxt/components/textareaProps.js +3 -0
- package/nuxt/components/timeAxisProps.js +3 -0
- package/nuxt/components/treeProps.js +3 -0
- package/overlay/index.es.js +127 -149
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +10 -44
- package/pagination/index.es.js +158 -148
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/panel/index.es.js +45 -32
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.es.js +317 -246
- package/popover/index.umd.js +15 -15
- package/popover/style.css +1 -1
- package/progress/index.es.js +110 -56
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +7964 -157
- package/radio/index.umd.js +27 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +77 -55
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/result/index.es.js +184 -57
- package/result/index.umd.js +1 -1
- package/result/style.css +1 -1
- package/ripple/index.es.js +47 -42
- package/ripple/index.umd.js +1 -1
- package/search/index.es.js +3644 -1122
- package/search/index.umd.js +18 -18
- package/search/style.css +1 -1
- package/select/index.es.js +9144 -597
- package/select/index.umd.js +27 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +63 -41
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +109 -75
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +469 -349
- package/splitter/index.umd.js +15 -15
- package/splitter/style.css +1 -1
- package/statistic/index.es.js +7 -18
- package/statistic/index.umd.js +1 -1
- package/status/index.es.js +27 -6
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +7794 -64
- package/switch/index.umd.js +27 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +10119 -1206
- package/table/index.umd.js +27 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +342 -141
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +49 -24
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +7913 -83
- package/textarea/index.umd.js +35 -1
- package/textarea/style.css +1 -1
- package/{anchor → timeline}/index.d.ts +0 -0
- package/timeline/index.es.js +425 -0
- package/timeline/index.umd.js +1 -0
- package/{back-top → timeline}/package.json +1 -1
- package/timeline/style.css +1 -0
- package/tooltip/index.es.js +308 -236
- package/tooltip/index.umd.js +15 -15
- package/tooltip/style.css +1 -1
- package/tree/index.es.js +4189 -1851
- package/tree/index.umd.js +18 -18
- package/tree/style.css +1 -1
- package/upload/index.es.js +380 -123
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +18121 -23161
- package/vue-devui.umd.js +25 -15
- package/accordion/index.es.js +0 -720
- package/accordion/index.umd.js +0 -1
- package/accordion/package.json +0 -7
- package/accordion/style.css +0 -1
- package/anchor/index.es.js +0 -263
- package/anchor/index.umd.js +0 -1
- package/anchor/style.css +0 -1
- package/back-top/index.d.ts +0 -7
- package/back-top/index.es.js +0 -128
- package/back-top/index.umd.js +0 -1
- package/back-top/style.css +0 -1
- package/breadcrumb/index.d.ts +0 -7
- package/breadcrumb/index.es.js +0 -127
- package/breadcrumb/index.umd.js +0 -1
- package/breadcrumb/package.json +0 -7
- package/breadcrumb/style.css +0 -1
- package/carousel/index.d.ts +0 -7
- package/carousel/index.es.js +0 -329
- package/carousel/index.umd.js +0 -1
- package/carousel/package.json +0 -7
- package/carousel/style.css +0 -1
- package/cascader/index.d.ts +0 -7
- package/cascader/index.es.js +0 -5963
- package/cascader/index.umd.js +0 -27
- package/cascader/package.json +0 -7
- package/cascader/style.css +0 -1
- package/color-picker/index.d.ts +0 -7
- package/color-picker/index.es.js +0 -8187
- package/color-picker/index.umd.js +0 -27
- package/color-picker/package.json +0 -7
- package/color-picker/style.css +0 -1
- package/comment/index.d.ts +0 -7
- package/comment/index.es.js +0 -86
- package/comment/index.umd.js +0 -1
- package/comment/package.json +0 -7
- package/comment/style.css +0 -1
- package/dragdrop/index.d.ts +0 -7
- package/dragdrop/index.es.js +0 -157
- package/dragdrop/index.umd.js +0 -1
- package/dragdrop/package.json +0 -7
- package/gantt/index.d.ts +0 -7
- package/gantt/index.es.js +0 -523
- package/gantt/index.umd.js +0 -1
- package/gantt/package.json +0 -7
- package/gantt/style.css +0 -1
- package/input-icon/index.d.ts +0 -7
- package/input-icon/index.es.js +0 -331
- package/input-icon/index.umd.js +0 -1
- package/input-icon/package.json +0 -7
- package/input-icon/style.css +0 -1
- package/list/index.d.ts +0 -7
- package/list/index.es.js +0 -39
- package/list/index.umd.js +0 -1
- package/list/package.json +0 -7
- package/list/style.css +0 -1
- package/nav-sprite/index.d.ts +0 -7
- package/nav-sprite/index.es.js +0 -68
- package/nav-sprite/index.umd.js +0 -1
- package/nav-sprite/package.json +0 -7
- package/nuxt/components/Accordion.js +0 -3
- package/nuxt/components/Anchor.js +0 -3
- package/nuxt/components/BackTop.js +0 -3
- package/nuxt/components/Breadcrumb.js +0 -3
- package/nuxt/components/Carousel.js +0 -3
- package/nuxt/components/CarouselItem.js +0 -3
- package/nuxt/components/Cascader.js +0 -3
- package/nuxt/components/ColorPicker.js +0 -3
- package/nuxt/components/Comment.js +0 -3
- package/nuxt/components/FormControl.js +0 -3
- package/nuxt/components/FormLabel.js +0 -3
- package/nuxt/components/Gantt.js +0 -3
- package/nuxt/components/InputIcon.js +0 -3
- package/nuxt/components/List.js +0 -3
- package/nuxt/components/ListItem.js +0 -3
- package/nuxt/components/NavSprite.js +0 -2
- package/nuxt/components/QuadrantDiagram.js +0 -3
- package/nuxt/components/ReadTip.js +0 -3
- package/nuxt/components/StepsGuide.js +0 -3
- package/nuxt/components/Sticky.js +0 -2
- package/nuxt/components/TagInput.js +0 -3
- package/nuxt/components/TimeAxis.js +0 -3
- package/nuxt/components/TimeAxisItem.js +0 -3
- package/nuxt/components/TimePicker.js +0 -3
- package/nuxt/components/Transfer.js +0 -3
- package/nuxt/components/TreeSelect.js +0 -3
- package/nuxt/components/overlayEmits.js +0 -3
- package/nuxt/components/overlayProps.js +0 -3
- package/quadrant-diagram/index.d.ts +0 -7
- package/quadrant-diagram/index.es.js +0 -5728
- package/quadrant-diagram/index.umd.js +0 -27
- package/quadrant-diagram/package.json +0 -7
- package/quadrant-diagram/style.css +0 -1
- package/read-tip/index.d.ts +0 -7
- package/read-tip/index.es.js +0 -258
- package/read-tip/index.umd.js +0 -1
- package/read-tip/package.json +0 -7
- package/read-tip/style.css +0 -1
- package/steps-guide/index.d.ts +0 -7
- package/steps-guide/index.es.js +0 -239
- package/steps-guide/index.umd.js +0 -1
- package/steps-guide/package.json +0 -7
- package/steps-guide/style.css +0 -1
- package/sticky/index.d.ts +0 -7
- package/sticky/index.es.js +0 -197
- package/sticky/index.umd.js +0 -1
- package/sticky/package.json +0 -7
- package/tag-input/index.d.ts +0 -7
- package/tag-input/index.es.js +0 -329
- package/tag-input/index.umd.js +0 -1
- package/tag-input/package.json +0 -7
- package/tag-input/style.css +0 -1
- package/time-axis/index.d.ts +0 -7
- package/time-axis/index.es.js +0 -299
- package/time-axis/index.umd.js +0 -1
- package/time-axis/package.json +0 -7
- package/time-axis/style.css +0 -1
- package/time-picker/index.d.ts +0 -7
- package/time-picker/index.es.js +0 -1237
- package/time-picker/index.umd.js +0 -1
- package/time-picker/package.json +0 -7
- package/time-picker/style.css +0 -1
- package/transfer/index.d.ts +0 -7
- package/transfer/index.es.js +0 -7608
- package/transfer/index.umd.js +0 -27
- package/transfer/package.json +0 -7
- package/transfer/style.css +0 -1
- package/tree-select/index.d.ts +0 -7
- package/tree-select/index.es.js +0 -623
- package/tree-select/index.umd.js +0 -1
- package/tree-select/package.json +0 -7
- package/tree-select/style.css +0 -1
package/form/index.es.js
CHANGED
|
@@ -17,28 +17,24 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
n2(t, e);
|
|
35
|
-
});
|
|
36
|
-
} };
|
|
37
|
-
}
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { defineComponent, watch, provide, reactive, toRefs, createVNode, onUnmounted, Transition, mergeProps, ref, unref, nextTick, Comment, Text, h, Fragment, inject, withDirectives, cloneVNode, computed, onMounted, Teleport, createTextVNode, onBeforeUnmount } from "vue";
|
|
33
|
+
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
38
34
|
const formProps = {
|
|
39
|
-
|
|
35
|
+
data: {
|
|
40
36
|
type: Object,
|
|
41
|
-
default: {}
|
|
37
|
+
default: () => ({})
|
|
42
38
|
},
|
|
43
39
|
layout: {
|
|
44
40
|
type: String,
|
|
@@ -46,522 +42,73 @@ const formProps = {
|
|
|
46
42
|
},
|
|
47
43
|
labelSize: {
|
|
48
44
|
type: String,
|
|
49
|
-
default: ""
|
|
45
|
+
default: "md"
|
|
50
46
|
},
|
|
51
47
|
labelAlign: {
|
|
52
48
|
type: String,
|
|
53
49
|
default: "start"
|
|
54
50
|
},
|
|
55
51
|
rules: {
|
|
56
|
-
type: Object
|
|
57
|
-
default: {}
|
|
52
|
+
type: Object
|
|
58
53
|
},
|
|
59
|
-
|
|
54
|
+
messageType: {
|
|
60
55
|
type: String,
|
|
61
|
-
default: ""
|
|
56
|
+
default: "popover"
|
|
62
57
|
},
|
|
63
|
-
|
|
64
|
-
type:
|
|
65
|
-
default: ""
|
|
58
|
+
popPosition: {
|
|
59
|
+
type: Array,
|
|
60
|
+
default: ["right", "bottom"]
|
|
66
61
|
},
|
|
67
|
-
|
|
68
|
-
type: String,
|
|
69
|
-
default: "popover"
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const formItemProps = {
|
|
73
|
-
dHasFeedback: {
|
|
62
|
+
validateOnRuleChange: {
|
|
74
63
|
type: Boolean,
|
|
75
64
|
default: false
|
|
76
65
|
},
|
|
77
|
-
|
|
78
|
-
type: String,
|
|
79
|
-
default: ""
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const formLabelProps = {
|
|
83
|
-
required: {
|
|
66
|
+
showFeedback: {
|
|
84
67
|
type: Boolean,
|
|
85
68
|
default: false
|
|
86
69
|
},
|
|
87
|
-
|
|
70
|
+
disabled: {
|
|
88
71
|
type: Boolean,
|
|
89
72
|
default: false
|
|
90
73
|
},
|
|
91
|
-
|
|
92
|
-
type: String
|
|
93
|
-
default: ""
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const formControlProps = {
|
|
97
|
-
feedbackStatus: {
|
|
98
|
-
type: String,
|
|
99
|
-
default: ""
|
|
100
|
-
},
|
|
101
|
-
extraInfo: {
|
|
102
|
-
type: String,
|
|
103
|
-
default: ""
|
|
74
|
+
size: {
|
|
75
|
+
type: String
|
|
104
76
|
}
|
|
105
77
|
};
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const formItemInjectionKey = Symbol("dFormItem");
|
|
112
|
-
const dFormItemEvents = {
|
|
113
|
-
blur: "d.form.blur",
|
|
114
|
-
change: "d.form.change",
|
|
115
|
-
input: "d.form.input"
|
|
116
|
-
};
|
|
117
|
-
var eventBus = mitt();
|
|
118
|
-
const EventBus = eventBus;
|
|
119
|
-
function isObject(obj) {
|
|
120
|
-
return Object.prototype.toString.call(obj).slice(8, -1) === "Object";
|
|
121
|
-
}
|
|
122
|
-
function hasKey(obj, key) {
|
|
123
|
-
if (!isObject(obj))
|
|
124
|
-
return false;
|
|
125
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
126
|
-
}
|
|
127
|
-
function getElOffset(curEl) {
|
|
128
|
-
let totalLeft = 0;
|
|
129
|
-
let totalTop = 0;
|
|
130
|
-
let par = curEl.offsetParent;
|
|
131
|
-
totalLeft += curEl.offsetLeft;
|
|
132
|
-
totalTop += curEl.offsetTop;
|
|
133
|
-
while (par) {
|
|
134
|
-
if (navigator.userAgent.indexOf("MSIE 8.0") === -1) {
|
|
135
|
-
totalTop += par.clientTop;
|
|
136
|
-
totalLeft += par.clientLeft;
|
|
137
|
-
}
|
|
138
|
-
totalTop += par.offsetTop;
|
|
139
|
-
totalLeft += par.offsetLeft;
|
|
140
|
-
par = par.offsetParent;
|
|
141
|
-
}
|
|
142
|
-
return { left: totalLeft, top: totalTop };
|
|
143
|
-
}
|
|
144
|
-
var form = "";
|
|
145
|
-
var Form = defineComponent({
|
|
146
|
-
name: "DForm",
|
|
147
|
-
props: formProps,
|
|
148
|
-
emits: ["submit"],
|
|
149
|
-
setup(props, ctx2) {
|
|
150
|
-
const formMitt = mitt();
|
|
151
|
-
const fields = [];
|
|
152
|
-
const resetFormFields = () => {
|
|
153
|
-
fields.forEach((field) => {
|
|
154
|
-
field.resetField();
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
formMitt.on(dFormEvents.addField, (field) => {
|
|
158
|
-
if (field) {
|
|
159
|
-
fields.push(field);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
formMitt.on(dFormEvents.removeField, (field) => {
|
|
163
|
-
if (field.prop) {
|
|
164
|
-
fields.splice(fields.indexOf(field), 1);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
provide(formInjectionKey, {
|
|
168
|
-
formData: props.formData,
|
|
169
|
-
formMitt,
|
|
170
|
-
labelData: {
|
|
171
|
-
layout: props.layout,
|
|
172
|
-
labelSize: props.labelSize,
|
|
173
|
-
labelAlign: props.labelAlign
|
|
174
|
-
},
|
|
175
|
-
rules: props.rules,
|
|
176
|
-
columnsClass: props.columnsClass,
|
|
177
|
-
messageShowType: "popover"
|
|
178
|
-
});
|
|
179
|
-
const onSubmit = (e) => {
|
|
180
|
-
e.preventDefault();
|
|
181
|
-
ctx2.emit("submit", e);
|
|
182
|
-
EventBus.emit(`formSubmit:${props.name}`);
|
|
183
|
-
};
|
|
184
|
-
return {
|
|
185
|
-
fields,
|
|
186
|
-
formMitt,
|
|
187
|
-
onSubmit,
|
|
188
|
-
resetFormFields
|
|
189
|
-
};
|
|
190
|
-
},
|
|
191
|
-
render() {
|
|
192
|
-
var _a, _b;
|
|
193
|
-
const {
|
|
194
|
-
onSubmit
|
|
195
|
-
} = this;
|
|
196
|
-
return createVNode("form", {
|
|
197
|
-
"onSubmit": onSubmit,
|
|
198
|
-
"class": "devui-form"
|
|
199
|
-
}, [(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)]);
|
|
78
|
+
const FORM_TOKEN = Symbol("dForm");
|
|
79
|
+
function createBem(namespace, element, modifier) {
|
|
80
|
+
let cls = namespace;
|
|
81
|
+
if (element) {
|
|
82
|
+
cls += `__${element}`;
|
|
200
83
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
name: "DIcon",
|
|
204
|
-
props: {
|
|
205
|
-
name: {
|
|
206
|
-
type: String,
|
|
207
|
-
required: true
|
|
208
|
-
},
|
|
209
|
-
size: {
|
|
210
|
-
type: String,
|
|
211
|
-
default: "inherit"
|
|
212
|
-
},
|
|
213
|
-
color: {
|
|
214
|
-
type: String,
|
|
215
|
-
default: "inherit"
|
|
216
|
-
},
|
|
217
|
-
classPrefix: {
|
|
218
|
-
type: String,
|
|
219
|
-
default: "icon"
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
setup(props) {
|
|
223
|
-
return __spreadValues({}, props);
|
|
224
|
-
},
|
|
225
|
-
render() {
|
|
226
|
-
const {
|
|
227
|
-
name,
|
|
228
|
-
size,
|
|
229
|
-
color,
|
|
230
|
-
classPrefix
|
|
231
|
-
} = this;
|
|
232
|
-
return /^((https?):)?\/\//.test(name) ? createVNode("img", {
|
|
233
|
-
"src": name,
|
|
234
|
-
"alt": name.split("/")[name.split("/").length - 1],
|
|
235
|
-
"style": {
|
|
236
|
-
width: size,
|
|
237
|
-
verticalAlign: "text-bottom"
|
|
238
|
-
}
|
|
239
|
-
}, null) : createVNode("i", {
|
|
240
|
-
"class": `${classPrefix} ${classPrefix}-${name}`,
|
|
241
|
-
"style": {
|
|
242
|
-
fontSize: size,
|
|
243
|
-
color
|
|
244
|
-
}
|
|
245
|
-
}, null);
|
|
84
|
+
if (modifier) {
|
|
85
|
+
cls += `--${modifier}`;
|
|
246
86
|
}
|
|
247
|
-
|
|
248
|
-
var overlay = "";
|
|
249
|
-
function _isSlot(s) {
|
|
250
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
87
|
+
return cls;
|
|
251
88
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}, {
|
|
259
|
-
default: () => [createVNode(Transition, {
|
|
260
|
-
"name": "devui-overlay-fade"
|
|
261
|
-
}, _isSlot(_slot = renderSlot(ctx2.slots, "default")) ? _slot : {
|
|
262
|
-
default: () => [_slot]
|
|
263
|
-
})]
|
|
264
|
-
});
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
const overlayProps = {
|
|
269
|
-
visible: {
|
|
270
|
-
type: Boolean
|
|
271
|
-
},
|
|
272
|
-
backgroundBlock: {
|
|
273
|
-
type: Boolean,
|
|
274
|
-
default: false
|
|
275
|
-
},
|
|
276
|
-
backgroundClass: {
|
|
277
|
-
type: String,
|
|
278
|
-
default: ""
|
|
279
|
-
},
|
|
280
|
-
backgroundStyle: {
|
|
281
|
-
type: [String, Object]
|
|
282
|
-
},
|
|
283
|
-
onBackdropClick: {
|
|
284
|
-
type: Function
|
|
285
|
-
},
|
|
286
|
-
backdropClose: {
|
|
287
|
-
type: Boolean,
|
|
288
|
-
default: true
|
|
289
|
-
},
|
|
290
|
-
hasBackdrop: {
|
|
291
|
-
type: Boolean,
|
|
292
|
-
default: true
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
const overlayEmits = ["update:visible", "backdropClick"];
|
|
296
|
-
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
297
|
-
overlayStyle: {
|
|
298
|
-
type: [String, Object],
|
|
299
|
-
default: void 0
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
const flexibleOverlayProps = {
|
|
303
|
-
modelValue: {
|
|
304
|
-
type: Boolean,
|
|
305
|
-
default: false
|
|
306
|
-
},
|
|
307
|
-
origin: {
|
|
308
|
-
type: Object,
|
|
309
|
-
require: true
|
|
310
|
-
},
|
|
311
|
-
position: {
|
|
312
|
-
type: Array,
|
|
313
|
-
default: ["bottom"]
|
|
314
|
-
},
|
|
315
|
-
offset: {
|
|
316
|
-
type: [Number, Object],
|
|
317
|
-
default: 8
|
|
318
|
-
},
|
|
319
|
-
align: {
|
|
320
|
-
type: String,
|
|
321
|
-
default: null
|
|
322
|
-
},
|
|
323
|
-
showArrow: {
|
|
324
|
-
type: Boolean,
|
|
325
|
-
default: false
|
|
326
|
-
},
|
|
327
|
-
isArrowCenter: {
|
|
328
|
-
type: Boolean,
|
|
329
|
-
default: true
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
function useOverlayLogic(props, ctx2) {
|
|
333
|
-
const backgroundClass = computed(() => {
|
|
334
|
-
return [
|
|
335
|
-
"devui-overlay-background",
|
|
336
|
-
props.backgroundClass,
|
|
337
|
-
!props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
|
|
338
|
-
];
|
|
339
|
-
});
|
|
340
|
-
const overlayClass = computed(() => {
|
|
341
|
-
return "devui-overlay";
|
|
342
|
-
});
|
|
343
|
-
const handleBackdropClick = (event) => {
|
|
344
|
-
var _a;
|
|
345
|
-
event.preventDefault();
|
|
346
|
-
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
347
|
-
if (props.backdropClose) {
|
|
348
|
-
ctx2.emit("update:visible", false);
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
352
|
-
onMounted(() => {
|
|
353
|
-
const body = document.body;
|
|
354
|
-
const originOverflow = body.style.overflow;
|
|
355
|
-
const originPosition = body.style.position;
|
|
356
|
-
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
357
|
-
if (backgroundBlock) {
|
|
358
|
-
const top = body.getBoundingClientRect().y;
|
|
359
|
-
if (visible) {
|
|
360
|
-
body.style.overflowY = "scroll";
|
|
361
|
-
body.style.position = visible ? "fixed" : "";
|
|
362
|
-
body.style.top = `${top}px`;
|
|
363
|
-
} else {
|
|
364
|
-
body.style.overflowY = originOverflow;
|
|
365
|
-
body.style.position = originPosition;
|
|
366
|
-
body.style.top = "";
|
|
367
|
-
window.scrollTo(0, -top);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
onUnmounted(() => {
|
|
372
|
-
document.body.style.overflow = originOverflow;
|
|
373
|
-
});
|
|
374
|
-
});
|
|
89
|
+
function useNamespace(block, needDot = false) {
|
|
90
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
91
|
+
const b = () => createBem(namespace);
|
|
92
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
93
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
94
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
375
95
|
return {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
96
|
+
b,
|
|
97
|
+
e,
|
|
98
|
+
m,
|
|
99
|
+
em
|
|
380
100
|
};
|
|
381
101
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
setup(props, ctx2) {
|
|
387
|
-
const {
|
|
388
|
-
backgroundClass,
|
|
389
|
-
overlayClass,
|
|
390
|
-
handleBackdropClick,
|
|
391
|
-
handleOverlayBubbleCancel
|
|
392
|
-
} = useOverlayLogic(props, ctx2);
|
|
393
|
-
return () => createVNode(CommonOverlay, null, {
|
|
394
|
-
default: () => [props.visible && createVNode("div", {
|
|
395
|
-
"class": backgroundClass.value,
|
|
396
|
-
"style": props.backgroundStyle,
|
|
397
|
-
"onClick": handleBackdropClick
|
|
398
|
-
}, [createVNode("div", {
|
|
399
|
-
"class": overlayClass.value,
|
|
400
|
-
"style": props.overlayStyle,
|
|
401
|
-
"onClick": handleOverlayBubbleCancel
|
|
402
|
-
}, [renderSlot(ctx2.slots, "default")])])]
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
function getScrollParent(element) {
|
|
407
|
-
const overflowRegex = /(auto|scroll|hidden)/;
|
|
408
|
-
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
409
|
-
const style2 = window.getComputedStyle(parent);
|
|
410
|
-
if (overflowRegex.test(style2.overflow + style2.overflowX + style2.overflowY)) {
|
|
411
|
-
return parent;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return window;
|
|
415
|
-
}
|
|
416
|
-
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
417
|
-
let { x, y } = point;
|
|
418
|
-
if (!isArrowCenter) {
|
|
419
|
-
const { width, height } = originRect;
|
|
420
|
-
if (x && placement.includes("start")) {
|
|
421
|
-
x = 12;
|
|
422
|
-
}
|
|
423
|
-
if (x && placement.includes("end")) {
|
|
424
|
-
x = Math.round(width - 24);
|
|
425
|
-
}
|
|
426
|
-
if (y && placement.includes("start")) {
|
|
427
|
-
y = 10;
|
|
428
|
-
}
|
|
429
|
-
if (y && placement.includes("end")) {
|
|
430
|
-
y = height - 14;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
return { x, y };
|
|
434
|
-
}
|
|
435
|
-
function useOverlay(props, emit) {
|
|
436
|
-
const overlayRef = ref();
|
|
437
|
-
const arrowRef = ref();
|
|
438
|
-
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
439
|
-
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
440
|
-
const staticSide = {
|
|
441
|
-
top: "bottom",
|
|
442
|
-
right: "left",
|
|
443
|
-
bottom: "top",
|
|
444
|
-
left: "right"
|
|
445
|
-
}[placement.split("-")[0]];
|
|
446
|
-
Object.assign(arrowEl.style, {
|
|
447
|
-
left: x ? `${x}px` : "",
|
|
448
|
-
top: y ? `${y}px` : "",
|
|
449
|
-
right: "",
|
|
450
|
-
bottom: "",
|
|
451
|
-
[staticSide]: "-4px"
|
|
452
|
-
});
|
|
102
|
+
function useFieldCollection() {
|
|
103
|
+
const itemContexts = [];
|
|
104
|
+
const addItemContext = (field) => {
|
|
105
|
+
itemContexts.push(field);
|
|
453
106
|
};
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
const overlayEl = unref(overlayRef.value);
|
|
457
|
-
const arrowEl = unref(arrowRef.value);
|
|
458
|
-
const middleware = [
|
|
459
|
-
offset(props.offset),
|
|
460
|
-
autoPlacement({
|
|
461
|
-
alignment: props.align,
|
|
462
|
-
allowedPlacements: props.position
|
|
463
|
-
})
|
|
464
|
-
];
|
|
465
|
-
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
466
|
-
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
467
|
-
strategy: "fixed",
|
|
468
|
-
middleware
|
|
469
|
-
});
|
|
470
|
-
emit("positionChange", placement);
|
|
471
|
-
Object.assign(overlayEl.style, { top: `${y}px`, left: `${x}px` });
|
|
472
|
-
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
107
|
+
const removeItemContext = (field) => {
|
|
108
|
+
itemContexts.splice(itemContexts.indexOf(field), 1);
|
|
473
109
|
};
|
|
474
|
-
|
|
475
|
-
const originParent = getScrollParent(props.origin);
|
|
476
|
-
if (props.modelValue && props.origin) {
|
|
477
|
-
nextTick(updatePosition);
|
|
478
|
-
originParent.addEventListener("scroll", updatePosition);
|
|
479
|
-
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
480
|
-
window.addEventListener("resize", updatePosition);
|
|
481
|
-
} else {
|
|
482
|
-
originParent.removeEventListener("scroll", updatePosition);
|
|
483
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
484
|
-
window.removeEventListener("resize", updatePosition);
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
onUnmounted(() => {
|
|
488
|
-
const originParent = getScrollParent(props.origin);
|
|
489
|
-
originParent.removeEventListener("scroll", updatePosition);
|
|
490
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
491
|
-
window.removeEventListener("resize", updatePosition);
|
|
492
|
-
});
|
|
493
|
-
return { arrowRef, overlayRef };
|
|
110
|
+
return { itemContexts, addItemContext, removeItemContext };
|
|
494
111
|
}
|
|
495
|
-
var flexibleOverlay = "";
|
|
496
|
-
const FlexibleOverlay = defineComponent({
|
|
497
|
-
name: "DFlexibleOverlay",
|
|
498
|
-
inheritAttrs: false,
|
|
499
|
-
props: flexibleOverlayProps,
|
|
500
|
-
emits: ["update:modelValue", "positionChange"],
|
|
501
|
-
setup(props, {
|
|
502
|
-
slots,
|
|
503
|
-
attrs,
|
|
504
|
-
emit
|
|
505
|
-
}) {
|
|
506
|
-
const {
|
|
507
|
-
arrowRef,
|
|
508
|
-
overlayRef
|
|
509
|
-
} = useOverlay(props, emit);
|
|
510
|
-
return () => {
|
|
511
|
-
var _a;
|
|
512
|
-
return props.modelValue && createVNode("div", mergeProps({
|
|
513
|
-
"ref": overlayRef,
|
|
514
|
-
"class": "devui-flexible-overlay"
|
|
515
|
-
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
516
|
-
"ref": arrowRef,
|
|
517
|
-
"class": "devui-flexible-overlay-arrow"
|
|
518
|
-
}, null)]);
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
const inBrowser = typeof window !== "undefined";
|
|
523
|
-
const popoverProps = {
|
|
524
|
-
isOpen: {
|
|
525
|
-
type: Boolean,
|
|
526
|
-
default: false
|
|
527
|
-
},
|
|
528
|
-
position: {
|
|
529
|
-
type: Array,
|
|
530
|
-
default: ["bottom"]
|
|
531
|
-
},
|
|
532
|
-
align: {
|
|
533
|
-
type: String,
|
|
534
|
-
default: null
|
|
535
|
-
},
|
|
536
|
-
offset: {
|
|
537
|
-
type: [Number, Object],
|
|
538
|
-
default: 8
|
|
539
|
-
},
|
|
540
|
-
content: {
|
|
541
|
-
type: String,
|
|
542
|
-
default: ""
|
|
543
|
-
},
|
|
544
|
-
trigger: {
|
|
545
|
-
type: String,
|
|
546
|
-
default: "click"
|
|
547
|
-
},
|
|
548
|
-
popType: {
|
|
549
|
-
type: String,
|
|
550
|
-
default: "default"
|
|
551
|
-
},
|
|
552
|
-
showAnimation: {
|
|
553
|
-
type: Boolean,
|
|
554
|
-
default: true
|
|
555
|
-
},
|
|
556
|
-
mouseEnterDelay: {
|
|
557
|
-
type: Number,
|
|
558
|
-
default: 150
|
|
559
|
-
},
|
|
560
|
-
mouseLeaveDelay: {
|
|
561
|
-
type: Number,
|
|
562
|
-
default: 100
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
112
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
566
113
|
var lodash = { exports: {} };
|
|
567
114
|
/**
|
|
@@ -5963,17 +5510,511 @@ var lodash = { exports: {} };
|
|
|
5963
5510
|
if (symIterator) {
|
|
5964
5511
|
lodash2.prototype[symIterator] = wrapperToIterator;
|
|
5965
5512
|
}
|
|
5966
|
-
return lodash2;
|
|
5513
|
+
return lodash2;
|
|
5514
|
+
};
|
|
5515
|
+
var _ = runInContext();
|
|
5516
|
+
if (freeModule) {
|
|
5517
|
+
(freeModule.exports = _)._ = _;
|
|
5518
|
+
freeExports._ = _;
|
|
5519
|
+
} else {
|
|
5520
|
+
root._ = _;
|
|
5521
|
+
}
|
|
5522
|
+
}).call(commonjsGlobal);
|
|
5523
|
+
})(lodash, lodash.exports);
|
|
5524
|
+
function useFormValidation(itemContexts) {
|
|
5525
|
+
const getValidateFields = (fields) => {
|
|
5526
|
+
if (!itemContexts.length) {
|
|
5527
|
+
return [];
|
|
5528
|
+
}
|
|
5529
|
+
const normalizedFields = lodash.exports.castArray(fields);
|
|
5530
|
+
const filteredFields = normalizedFields.length ? itemContexts.filter((context) => context.field && normalizedFields.includes(context.field)) : itemContexts;
|
|
5531
|
+
if (!filteredFields.length) {
|
|
5532
|
+
return [];
|
|
5533
|
+
}
|
|
5534
|
+
return filteredFields;
|
|
5535
|
+
};
|
|
5536
|
+
const execValidateFields = async (fields = []) => {
|
|
5537
|
+
const validateFields2 = getValidateFields(fields);
|
|
5538
|
+
if (!validateFields2.length) {
|
|
5539
|
+
return true;
|
|
5540
|
+
}
|
|
5541
|
+
let errors = {};
|
|
5542
|
+
for (const field of validateFields2) {
|
|
5543
|
+
try {
|
|
5544
|
+
await field.validate("");
|
|
5545
|
+
} catch (err) {
|
|
5546
|
+
errors = __spreadValues(__spreadValues({}, errors), err);
|
|
5547
|
+
}
|
|
5548
|
+
}
|
|
5549
|
+
if (!Object.keys(errors).length) {
|
|
5550
|
+
return true;
|
|
5551
|
+
}
|
|
5552
|
+
return Promise.reject(errors);
|
|
5553
|
+
};
|
|
5554
|
+
const validateFields = async (fields = [], callback) => {
|
|
5555
|
+
try {
|
|
5556
|
+
const result = await execValidateFields(fields);
|
|
5557
|
+
if (result) {
|
|
5558
|
+
callback == null ? void 0 : callback(result);
|
|
5559
|
+
}
|
|
5560
|
+
return result;
|
|
5561
|
+
} catch (err) {
|
|
5562
|
+
const invalidFields = err;
|
|
5563
|
+
callback == null ? void 0 : callback(false, invalidFields);
|
|
5564
|
+
return !callback && Promise.reject(invalidFields);
|
|
5565
|
+
}
|
|
5566
|
+
};
|
|
5567
|
+
const validate = async (callback) => validateFields(void 0, callback);
|
|
5568
|
+
const clearValidate = (fields = []) => {
|
|
5569
|
+
getValidateFields(fields).forEach((field) => field.clearValidate());
|
|
5570
|
+
};
|
|
5571
|
+
const resetFields = (fields = []) => {
|
|
5572
|
+
getValidateFields(fields).forEach((field) => field.resetField());
|
|
5573
|
+
};
|
|
5574
|
+
return { validate, validateFields, resetFields, clearValidate };
|
|
5575
|
+
}
|
|
5576
|
+
var Form = defineComponent({
|
|
5577
|
+
name: "DForm",
|
|
5578
|
+
props: formProps,
|
|
5579
|
+
emits: ["validate"],
|
|
5580
|
+
setup(props, ctx) {
|
|
5581
|
+
const ns2 = useNamespace("form");
|
|
5582
|
+
const {
|
|
5583
|
+
itemContexts,
|
|
5584
|
+
addItemContext,
|
|
5585
|
+
removeItemContext
|
|
5586
|
+
} = useFieldCollection();
|
|
5587
|
+
const {
|
|
5588
|
+
validate,
|
|
5589
|
+
validateFields,
|
|
5590
|
+
resetFields,
|
|
5591
|
+
clearValidate
|
|
5592
|
+
} = useFormValidation(itemContexts);
|
|
5593
|
+
const onSubmit = (e) => {
|
|
5594
|
+
e.preventDefault();
|
|
5595
|
+
};
|
|
5596
|
+
watch(() => props.rules, () => {
|
|
5597
|
+
if (props.validateOnRuleChange) {
|
|
5598
|
+
validate();
|
|
5599
|
+
}
|
|
5600
|
+
}, {
|
|
5601
|
+
deep: true
|
|
5602
|
+
});
|
|
5603
|
+
provide(FORM_TOKEN, reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
|
|
5604
|
+
emit: ctx.emit,
|
|
5605
|
+
addItemContext,
|
|
5606
|
+
removeItemContext
|
|
5607
|
+
})));
|
|
5608
|
+
ctx.expose({
|
|
5609
|
+
validate,
|
|
5610
|
+
validateFields,
|
|
5611
|
+
resetFields,
|
|
5612
|
+
clearValidate
|
|
5613
|
+
});
|
|
5614
|
+
return () => {
|
|
5615
|
+
var _a, _b;
|
|
5616
|
+
return createVNode("form", {
|
|
5617
|
+
"onSubmit": onSubmit,
|
|
5618
|
+
"class": ns2.b()
|
|
5619
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
5620
|
+
};
|
|
5621
|
+
}
|
|
5622
|
+
});
|
|
5623
|
+
const formItemProps = {
|
|
5624
|
+
label: {
|
|
5625
|
+
type: String
|
|
5626
|
+
},
|
|
5627
|
+
field: {
|
|
5628
|
+
type: String,
|
|
5629
|
+
default: ""
|
|
5630
|
+
},
|
|
5631
|
+
required: {
|
|
5632
|
+
type: Boolean,
|
|
5633
|
+
default: false
|
|
5634
|
+
},
|
|
5635
|
+
messageType: {
|
|
5636
|
+
type: String
|
|
5637
|
+
},
|
|
5638
|
+
popPosition: {
|
|
5639
|
+
type: Array
|
|
5640
|
+
},
|
|
5641
|
+
rules: {
|
|
5642
|
+
type: [Object, Array]
|
|
5643
|
+
},
|
|
5644
|
+
showFeedback: {
|
|
5645
|
+
type: Boolean,
|
|
5646
|
+
default: void 0
|
|
5647
|
+
},
|
|
5648
|
+
helpTips: {
|
|
5649
|
+
type: String,
|
|
5650
|
+
default: ""
|
|
5651
|
+
},
|
|
5652
|
+
feedbackStatus: {
|
|
5653
|
+
type: String
|
|
5654
|
+
},
|
|
5655
|
+
extraInfo: {
|
|
5656
|
+
type: String,
|
|
5657
|
+
default: ""
|
|
5658
|
+
}
|
|
5659
|
+
};
|
|
5660
|
+
const FORM_ITEM_TOKEN = Symbol("dFormItem");
|
|
5661
|
+
const LABEL_DATA = Symbol("labelData");
|
|
5662
|
+
const formLabelProps = {
|
|
5663
|
+
helpTips: {
|
|
5664
|
+
type: String,
|
|
5665
|
+
default: ""
|
|
5666
|
+
}
|
|
5667
|
+
};
|
|
5668
|
+
const fixedOverlayProps = {
|
|
5669
|
+
modelValue: {
|
|
5670
|
+
type: Boolean,
|
|
5671
|
+
default: false
|
|
5672
|
+
},
|
|
5673
|
+
lockScroll: {
|
|
5674
|
+
type: Boolean,
|
|
5675
|
+
default: true
|
|
5676
|
+
},
|
|
5677
|
+
closeOnClickOverlay: {
|
|
5678
|
+
type: Boolean,
|
|
5679
|
+
default: true
|
|
5680
|
+
}
|
|
5681
|
+
};
|
|
5682
|
+
function lockScroll() {
|
|
5683
|
+
if (document.documentElement.scrollHeight > document.documentElement.clientHeight) {
|
|
5684
|
+
const scrollTop = document.documentElement.scrollTop;
|
|
5685
|
+
const style = document.documentElement.getAttribute("style");
|
|
5686
|
+
document.documentElement.style.position = "fixed";
|
|
5687
|
+
document.documentElement.style.top = `-${scrollTop}px`;
|
|
5688
|
+
document.documentElement.style.width = document.documentElement.style.width || "100%";
|
|
5689
|
+
document.documentElement.style.overflowY = "scroll";
|
|
5690
|
+
return () => {
|
|
5691
|
+
if (style) {
|
|
5692
|
+
document.documentElement.setAttribute("style", style);
|
|
5693
|
+
} else {
|
|
5694
|
+
document.documentElement.removeAttribute("style");
|
|
5695
|
+
}
|
|
5696
|
+
document.documentElement.scrollTop = scrollTop;
|
|
5967
5697
|
};
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5698
|
+
}
|
|
5699
|
+
return;
|
|
5700
|
+
}
|
|
5701
|
+
function useFixedOverlay(props, ctx) {
|
|
5702
|
+
let lockScrollCb;
|
|
5703
|
+
const onClick = (event) => {
|
|
5704
|
+
event.preventDefault();
|
|
5705
|
+
ctx.emit("click", event);
|
|
5706
|
+
if (props.closeOnClickOverlay) {
|
|
5707
|
+
ctx.emit("update:modelValue", false);
|
|
5708
|
+
}
|
|
5709
|
+
};
|
|
5710
|
+
const removeBodyAdditions = () => {
|
|
5711
|
+
lockScrollCb == null ? void 0 : lockScrollCb();
|
|
5712
|
+
};
|
|
5713
|
+
watch(() => props.modelValue, (val) => {
|
|
5714
|
+
if (val) {
|
|
5715
|
+
props.lockScroll && (lockScrollCb = lockScroll());
|
|
5972
5716
|
} else {
|
|
5973
|
-
|
|
5717
|
+
removeBodyAdditions();
|
|
5974
5718
|
}
|
|
5975
|
-
})
|
|
5976
|
-
|
|
5719
|
+
});
|
|
5720
|
+
onUnmounted(removeBodyAdditions);
|
|
5721
|
+
return { onClick };
|
|
5722
|
+
}
|
|
5723
|
+
var fixedOverlay = "";
|
|
5724
|
+
defineComponent({
|
|
5725
|
+
name: "DFixedOverlay",
|
|
5726
|
+
inheritAttrs: false,
|
|
5727
|
+
props: fixedOverlayProps,
|
|
5728
|
+
emits: ["update:modelValue", "click"],
|
|
5729
|
+
setup(props, ctx) {
|
|
5730
|
+
const {
|
|
5731
|
+
modelValue
|
|
5732
|
+
} = toRefs(props);
|
|
5733
|
+
const ns2 = useNamespace("fixed-overlay");
|
|
5734
|
+
const {
|
|
5735
|
+
onClick
|
|
5736
|
+
} = useFixedOverlay(props, ctx);
|
|
5737
|
+
return () => createVNode(Transition, {
|
|
5738
|
+
"name": ns2.m("fade")
|
|
5739
|
+
}, {
|
|
5740
|
+
default: () => {
|
|
5741
|
+
var _a, _b;
|
|
5742
|
+
return [modelValue.value && createVNode("div", mergeProps({
|
|
5743
|
+
"class": ns2.b()
|
|
5744
|
+
}, ctx.attrs, {
|
|
5745
|
+
"onClick": onClick
|
|
5746
|
+
}), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
|
|
5747
|
+
}
|
|
5748
|
+
});
|
|
5749
|
+
}
|
|
5750
|
+
});
|
|
5751
|
+
const flexibleOverlayProps = {
|
|
5752
|
+
modelValue: {
|
|
5753
|
+
type: Boolean,
|
|
5754
|
+
default: false
|
|
5755
|
+
},
|
|
5756
|
+
origin: {
|
|
5757
|
+
type: Object,
|
|
5758
|
+
require: true
|
|
5759
|
+
},
|
|
5760
|
+
position: {
|
|
5761
|
+
type: Array,
|
|
5762
|
+
default: ["bottom"]
|
|
5763
|
+
},
|
|
5764
|
+
offset: {
|
|
5765
|
+
type: [Number, Object],
|
|
5766
|
+
default: 8
|
|
5767
|
+
},
|
|
5768
|
+
shiftOffset: {
|
|
5769
|
+
type: Number
|
|
5770
|
+
},
|
|
5771
|
+
align: {
|
|
5772
|
+
type: String,
|
|
5773
|
+
default: null
|
|
5774
|
+
},
|
|
5775
|
+
showArrow: {
|
|
5776
|
+
type: Boolean,
|
|
5777
|
+
default: false
|
|
5778
|
+
},
|
|
5779
|
+
isArrowCenter: {
|
|
5780
|
+
type: Boolean,
|
|
5781
|
+
default: true
|
|
5782
|
+
}
|
|
5783
|
+
};
|
|
5784
|
+
function getScrollParent(element) {
|
|
5785
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
5786
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
5787
|
+
const style = window.getComputedStyle(parent);
|
|
5788
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
5789
|
+
return parent;
|
|
5790
|
+
}
|
|
5791
|
+
}
|
|
5792
|
+
return window;
|
|
5793
|
+
}
|
|
5794
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
5795
|
+
let { x, y } = point;
|
|
5796
|
+
if (!isArrowCenter) {
|
|
5797
|
+
const { width, height } = originRect;
|
|
5798
|
+
if (x && placement.includes("start")) {
|
|
5799
|
+
x = 12;
|
|
5800
|
+
}
|
|
5801
|
+
if (x && placement.includes("end")) {
|
|
5802
|
+
x = Math.round(width - 24);
|
|
5803
|
+
}
|
|
5804
|
+
if (y && placement.includes("start")) {
|
|
5805
|
+
y = 10;
|
|
5806
|
+
}
|
|
5807
|
+
if (y && placement.includes("end")) {
|
|
5808
|
+
y = height - 14;
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5811
|
+
return { x, y };
|
|
5812
|
+
}
|
|
5813
|
+
function useOverlay(props, emit) {
|
|
5814
|
+
const overlayRef = ref();
|
|
5815
|
+
const arrowRef = ref();
|
|
5816
|
+
let originParent = null;
|
|
5817
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
5818
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
5819
|
+
const staticSide = {
|
|
5820
|
+
top: "bottom",
|
|
5821
|
+
right: "left",
|
|
5822
|
+
bottom: "top",
|
|
5823
|
+
left: "right"
|
|
5824
|
+
}[placement.split("-")[0]];
|
|
5825
|
+
Object.assign(arrowEl.style, {
|
|
5826
|
+
left: x ? `${x}px` : "",
|
|
5827
|
+
top: y ? `${y}px` : "",
|
|
5828
|
+
right: "",
|
|
5829
|
+
bottom: "",
|
|
5830
|
+
[staticSide]: "-4px"
|
|
5831
|
+
});
|
|
5832
|
+
};
|
|
5833
|
+
const updatePosition = async () => {
|
|
5834
|
+
const hostEl = props.origin;
|
|
5835
|
+
const overlayEl = unref(overlayRef.value);
|
|
5836
|
+
const arrowEl = unref(arrowRef.value);
|
|
5837
|
+
const middleware = [
|
|
5838
|
+
offset(props.offset),
|
|
5839
|
+
autoPlacement({
|
|
5840
|
+
alignment: props.align,
|
|
5841
|
+
allowedPlacements: props.position
|
|
5842
|
+
})
|
|
5843
|
+
];
|
|
5844
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
5845
|
+
props.shiftOffset !== void 0 && middleware.push(shift());
|
|
5846
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
5847
|
+
strategy: "fixed",
|
|
5848
|
+
middleware
|
|
5849
|
+
});
|
|
5850
|
+
let applyX = x;
|
|
5851
|
+
let applyY = y;
|
|
5852
|
+
if (props.shiftOffset !== void 0) {
|
|
5853
|
+
const { x: shiftX, y: shiftY } = middlewareData.shift;
|
|
5854
|
+
shiftX < 0 && (applyX -= props.shiftOffset);
|
|
5855
|
+
shiftX > 0 && (applyX += props.shiftOffset);
|
|
5856
|
+
shiftY < 0 && (applyY -= props.shiftOffset);
|
|
5857
|
+
shiftY > 0 && (applyY += props.shiftOffset);
|
|
5858
|
+
}
|
|
5859
|
+
emit("positionChange", placement);
|
|
5860
|
+
Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
|
|
5861
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
5862
|
+
};
|
|
5863
|
+
watch(() => props.modelValue, () => {
|
|
5864
|
+
if (props.modelValue && props.origin) {
|
|
5865
|
+
originParent = getScrollParent(props.origin);
|
|
5866
|
+
nextTick(updatePosition);
|
|
5867
|
+
originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
|
|
5868
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
5869
|
+
window.addEventListener("resize", updatePosition);
|
|
5870
|
+
} else {
|
|
5871
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
5872
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
5873
|
+
window.removeEventListener("resize", updatePosition);
|
|
5874
|
+
}
|
|
5875
|
+
});
|
|
5876
|
+
onUnmounted(() => {
|
|
5877
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
5878
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
5879
|
+
window.removeEventListener("resize", updatePosition);
|
|
5880
|
+
});
|
|
5881
|
+
return { arrowRef, overlayRef, updatePosition };
|
|
5882
|
+
}
|
|
5883
|
+
var flexibleOverlay = "";
|
|
5884
|
+
const FlexibleOverlay = defineComponent({
|
|
5885
|
+
name: "DFlexibleOverlay",
|
|
5886
|
+
inheritAttrs: false,
|
|
5887
|
+
props: flexibleOverlayProps,
|
|
5888
|
+
emits: ["update:modelValue", "positionChange"],
|
|
5889
|
+
setup(props, {
|
|
5890
|
+
slots,
|
|
5891
|
+
attrs,
|
|
5892
|
+
emit,
|
|
5893
|
+
expose
|
|
5894
|
+
}) {
|
|
5895
|
+
const ns2 = useNamespace("flexible-overlay");
|
|
5896
|
+
const {
|
|
5897
|
+
arrowRef,
|
|
5898
|
+
overlayRef,
|
|
5899
|
+
updatePosition
|
|
5900
|
+
} = useOverlay(props, emit);
|
|
5901
|
+
expose({
|
|
5902
|
+
updatePosition
|
|
5903
|
+
});
|
|
5904
|
+
return () => {
|
|
5905
|
+
var _a;
|
|
5906
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
5907
|
+
"ref": overlayRef,
|
|
5908
|
+
"class": ns2.b()
|
|
5909
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
5910
|
+
"ref": arrowRef,
|
|
5911
|
+
"class": ns2.e("arrow")
|
|
5912
|
+
}, null)]);
|
|
5913
|
+
};
|
|
5914
|
+
}
|
|
5915
|
+
});
|
|
5916
|
+
const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
|
|
5917
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
5918
|
+
const ns$1 = useNamespace("popper-trigger");
|
|
5919
|
+
function wrapContent(content) {
|
|
5920
|
+
return h("span", { class: ns$1.b() }, content);
|
|
5921
|
+
}
|
|
5922
|
+
function getFirstValidChild(nodes) {
|
|
5923
|
+
for (const child of nodes) {
|
|
5924
|
+
if (isObject(child)) {
|
|
5925
|
+
if (child.type === Comment) {
|
|
5926
|
+
continue;
|
|
5927
|
+
}
|
|
5928
|
+
if (child.type === "svg" || child.type === Text) {
|
|
5929
|
+
return wrapContent(child);
|
|
5930
|
+
}
|
|
5931
|
+
if (child.type === Fragment) {
|
|
5932
|
+
return getFirstValidChild(child.children);
|
|
5933
|
+
}
|
|
5934
|
+
return child;
|
|
5935
|
+
}
|
|
5936
|
+
return wrapContent(child);
|
|
5937
|
+
}
|
|
5938
|
+
return null;
|
|
5939
|
+
}
|
|
5940
|
+
var PopperTrigger = defineComponent({
|
|
5941
|
+
name: "DPopperTrigger",
|
|
5942
|
+
setup(_, ctx) {
|
|
5943
|
+
const {
|
|
5944
|
+
slots,
|
|
5945
|
+
attrs
|
|
5946
|
+
} = ctx;
|
|
5947
|
+
return () => {
|
|
5948
|
+
var _a;
|
|
5949
|
+
const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
|
|
5950
|
+
const triggerRef = inject(POPPER_TRIGGER_TOKEN);
|
|
5951
|
+
if (!defaultSlot) {
|
|
5952
|
+
return null;
|
|
5953
|
+
}
|
|
5954
|
+
const firstValidChild = getFirstValidChild(defaultSlot);
|
|
5955
|
+
if (!firstValidChild) {
|
|
5956
|
+
return null;
|
|
5957
|
+
}
|
|
5958
|
+
return withDirectives(cloneVNode(firstValidChild, attrs), [[{
|
|
5959
|
+
mounted(el) {
|
|
5960
|
+
triggerRef.value = el;
|
|
5961
|
+
},
|
|
5962
|
+
updated(el) {
|
|
5963
|
+
triggerRef.value = el;
|
|
5964
|
+
},
|
|
5965
|
+
unmounted() {
|
|
5966
|
+
triggerRef.value = null;
|
|
5967
|
+
}
|
|
5968
|
+
}]]);
|
|
5969
|
+
};
|
|
5970
|
+
}
|
|
5971
|
+
});
|
|
5972
|
+
const popoverProps = {
|
|
5973
|
+
isOpen: {
|
|
5974
|
+
type: Boolean,
|
|
5975
|
+
default: false
|
|
5976
|
+
},
|
|
5977
|
+
position: {
|
|
5978
|
+
type: Array,
|
|
5979
|
+
default: ["bottom"]
|
|
5980
|
+
},
|
|
5981
|
+
align: {
|
|
5982
|
+
type: String,
|
|
5983
|
+
default: null
|
|
5984
|
+
},
|
|
5985
|
+
offset: {
|
|
5986
|
+
type: [Number, Object],
|
|
5987
|
+
default: 8
|
|
5988
|
+
},
|
|
5989
|
+
content: {
|
|
5990
|
+
type: String,
|
|
5991
|
+
default: ""
|
|
5992
|
+
},
|
|
5993
|
+
trigger: {
|
|
5994
|
+
type: String,
|
|
5995
|
+
default: "click"
|
|
5996
|
+
},
|
|
5997
|
+
popType: {
|
|
5998
|
+
type: String,
|
|
5999
|
+
default: "default"
|
|
6000
|
+
},
|
|
6001
|
+
showAnimation: {
|
|
6002
|
+
type: Boolean,
|
|
6003
|
+
default: true
|
|
6004
|
+
},
|
|
6005
|
+
mouseEnterDelay: {
|
|
6006
|
+
type: Number,
|
|
6007
|
+
default: 150
|
|
6008
|
+
},
|
|
6009
|
+
mouseLeaveDelay: {
|
|
6010
|
+
type: Number,
|
|
6011
|
+
default: 100
|
|
6012
|
+
},
|
|
6013
|
+
disabled: {
|
|
6014
|
+
type: Boolean,
|
|
6015
|
+
default: false
|
|
6016
|
+
}
|
|
6017
|
+
};
|
|
5977
6018
|
const TransformOriginMap = {
|
|
5978
6019
|
top: "50% calc(100% + 8px)",
|
|
5979
6020
|
bottom: "50% -8px",
|
|
@@ -5987,8 +6028,8 @@ function usePopover(props, visible, placement, origin, popoverRef) {
|
|
|
5987
6028
|
transformOrigin: TransformOriginMap[placement.value]
|
|
5988
6029
|
}));
|
|
5989
6030
|
const onDocumentClick = (e) => {
|
|
5990
|
-
var _a;
|
|
5991
|
-
if (!origin.value.contains(e.target) && !((
|
|
6031
|
+
var _a, _b;
|
|
6032
|
+
if (!((_a = origin.value) == null ? void 0 : _a.contains(e.target)) && !((_b = popoverRef.value.$el) == null ? void 0 : _b.contains(e.target))) {
|
|
5992
6033
|
visible.value = false;
|
|
5993
6034
|
}
|
|
5994
6035
|
};
|
|
@@ -6008,11 +6049,16 @@ function usePopover(props, visible, placement, origin, popoverRef) {
|
|
|
6008
6049
|
return { overlayStyles };
|
|
6009
6050
|
}
|
|
6010
6051
|
function usePopoverEvent(props, visible, origin) {
|
|
6011
|
-
const { trigger, position, mouseEnterDelay, mouseLeaveDelay } = toRefs(props);
|
|
6052
|
+
const { trigger, position, mouseEnterDelay, mouseLeaveDelay, disabled } = toRefs(props);
|
|
6012
6053
|
const isClick = computed(() => trigger.value === "click");
|
|
6013
6054
|
const placement = ref(position.value[0].split("-")[0]);
|
|
6014
6055
|
const isEnter = ref(false);
|
|
6015
|
-
const onClick = () =>
|
|
6056
|
+
const onClick = () => {
|
|
6057
|
+
if (disabled.value) {
|
|
6058
|
+
return;
|
|
6059
|
+
}
|
|
6060
|
+
isClick.value && (visible.value = !visible.value);
|
|
6061
|
+
};
|
|
6016
6062
|
const enter = lodash.exports.debounce(() => {
|
|
6017
6063
|
isEnter.value && (visible.value = true);
|
|
6018
6064
|
}, mouseEnterDelay.value);
|
|
@@ -6020,6 +6066,9 @@ function usePopoverEvent(props, visible, origin) {
|
|
|
6020
6066
|
!isEnter.value && (visible.value = false);
|
|
6021
6067
|
}, mouseLeaveDelay.value);
|
|
6022
6068
|
const onMouseenter = () => {
|
|
6069
|
+
if (disabled.value) {
|
|
6070
|
+
return;
|
|
6071
|
+
}
|
|
6023
6072
|
if (!isClick.value) {
|
|
6024
6073
|
isEnter.value = true;
|
|
6025
6074
|
enter();
|
|
@@ -6031,6 +6080,15 @@ function usePopoverEvent(props, visible, origin) {
|
|
|
6031
6080
|
leave();
|
|
6032
6081
|
}
|
|
6033
6082
|
};
|
|
6083
|
+
const quickLeave = () => {
|
|
6084
|
+
isEnter.value = false;
|
|
6085
|
+
visible.value = false;
|
|
6086
|
+
};
|
|
6087
|
+
watch(disabled, (newVal) => {
|
|
6088
|
+
if (newVal && visible.value) {
|
|
6089
|
+
quickLeave();
|
|
6090
|
+
}
|
|
6091
|
+
});
|
|
6034
6092
|
const handlePositionChange = (pos) => {
|
|
6035
6093
|
placement.value = pos.split("-")[0];
|
|
6036
6094
|
};
|
|
@@ -6042,11 +6100,12 @@ function usePopoverEvent(props, visible, origin) {
|
|
|
6042
6100
|
origin.value.addEventListener("mouseleave", onMouseleave);
|
|
6043
6101
|
}
|
|
6044
6102
|
});
|
|
6045
|
-
return { placement, handlePositionChange };
|
|
6103
|
+
return { placement, handlePositionChange, onMouseenter, onMouseleave };
|
|
6046
6104
|
}
|
|
6047
|
-
|
|
6105
|
+
const ns = useNamespace("popover");
|
|
6106
|
+
function SuccessIcon$1() {
|
|
6048
6107
|
return createVNode("svg", {
|
|
6049
|
-
"class": "
|
|
6108
|
+
"class": [ns.e("icon"), ns.em("icon", "success")],
|
|
6050
6109
|
"viewBox": "0 0 16 16",
|
|
6051
6110
|
"version": "1.1",
|
|
6052
6111
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6070,7 +6129,7 @@ function SuccessIcon() {
|
|
|
6070
6129
|
}
|
|
6071
6130
|
function WarningIcon() {
|
|
6072
6131
|
return createVNode("svg", {
|
|
6073
|
-
"class": "
|
|
6132
|
+
"class": [ns.e("icon"), ns.em("icon", "warning")],
|
|
6074
6133
|
"viewBox": "0 0 16 16",
|
|
6075
6134
|
"version": "1.1",
|
|
6076
6135
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6080,14 +6139,14 @@ function WarningIcon() {
|
|
|
6080
6139
|
"fill": "none",
|
|
6081
6140
|
"fill-rule": "evenodd"
|
|
6082
6141
|
}, [createVNode("polygon", {
|
|
6083
|
-
"points": "7.5 1.74501946 1.39184847 13.5954649 7.08947368
|
|
6142
|
+
"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"
|
|
6084
6143
|
}, null), createVNode("path", {
|
|
6085
|
-
"d": "M8.51325441,0.127397589 C8.70423071,0.228333932
|
|
6144
|
+
"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"
|
|
6086
6145
|
}, null)])]);
|
|
6087
6146
|
}
|
|
6088
6147
|
function InfoIcon() {
|
|
6089
6148
|
return createVNode("svg", {
|
|
6090
|
-
"class": "
|
|
6149
|
+
"class": [ns.e("icon"), ns.em("icon", "info")],
|
|
6091
6150
|
"viewBox": "0 0 16 16",
|
|
6092
6151
|
"version": "1.1",
|
|
6093
6152
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6103,12 +6162,12 @@ function InfoIcon() {
|
|
|
6103
6162
|
}, null), createVNode("g", {
|
|
6104
6163
|
"stroke-width": "1"
|
|
6105
6164
|
}, [createVNode("path", {
|
|
6106
|
-
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16
|
|
6165
|
+
"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"
|
|
6107
6166
|
}, null)])])]);
|
|
6108
6167
|
}
|
|
6109
|
-
function ErrorIcon() {
|
|
6168
|
+
function ErrorIcon$1() {
|
|
6110
6169
|
return createVNode("svg", {
|
|
6111
|
-
"class": "
|
|
6170
|
+
"class": [ns.e("icon"), ns.em("icon", "error")],
|
|
6112
6171
|
"width": "16px",
|
|
6113
6172
|
"height": "16px",
|
|
6114
6173
|
"viewBox": "0 0 16 16",
|
|
@@ -6124,7 +6183,7 @@ function ErrorIcon() {
|
|
|
6124
6183
|
"cy": "8",
|
|
6125
6184
|
"r": "7"
|
|
6126
6185
|
}, null), createVNode("path", {
|
|
6127
|
-
"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
|
|
6186
|
+
"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",
|
|
6128
6187
|
"fill-rule": "nonzero"
|
|
6129
6188
|
}, null)])]);
|
|
6130
6189
|
}
|
|
@@ -6137,9 +6196,10 @@ var PopoverIcon = defineComponent({
|
|
|
6137
6196
|
}
|
|
6138
6197
|
},
|
|
6139
6198
|
setup(props) {
|
|
6199
|
+
const ns2 = useNamespace("popover");
|
|
6140
6200
|
return () => props.type && props.type !== "default" && createVNode("span", {
|
|
6141
|
-
"class": "
|
|
6142
|
-
}, [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)]);
|
|
6201
|
+
"class": ns2.e("icon-wrap")
|
|
6202
|
+
}, [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)]);
|
|
6143
6203
|
}
|
|
6144
6204
|
});
|
|
6145
6205
|
var popover = "";
|
|
@@ -6147,9 +6207,11 @@ var Popover = defineComponent({
|
|
|
6147
6207
|
name: "DPopover",
|
|
6148
6208
|
inheritAttrs: false,
|
|
6149
6209
|
props: popoverProps,
|
|
6210
|
+
emits: ["show", "hide"],
|
|
6150
6211
|
setup(props, {
|
|
6151
6212
|
slots,
|
|
6152
|
-
attrs
|
|
6213
|
+
attrs,
|
|
6214
|
+
emit
|
|
6153
6215
|
}) {
|
|
6154
6216
|
const {
|
|
6155
6217
|
content,
|
|
@@ -6164,89 +6226,260 @@ var Popover = defineComponent({
|
|
|
6164
6226
|
const visible = ref(false);
|
|
6165
6227
|
const {
|
|
6166
6228
|
placement,
|
|
6167
|
-
handlePositionChange
|
|
6229
|
+
handlePositionChange,
|
|
6230
|
+
onMouseenter,
|
|
6231
|
+
onMouseleave
|
|
6168
6232
|
} = usePopoverEvent(props, visible, origin);
|
|
6169
6233
|
const {
|
|
6170
6234
|
overlayStyles
|
|
6171
6235
|
} = usePopover(props, visible, placement, origin, popoverRef);
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
"
|
|
6177
|
-
}
|
|
6178
|
-
"
|
|
6236
|
+
const ns2 = useNamespace("popover");
|
|
6237
|
+
provide(POPPER_TRIGGER_TOKEN, origin);
|
|
6238
|
+
watch(visible, (newVal) => {
|
|
6239
|
+
if (newVal) {
|
|
6240
|
+
emit("show");
|
|
6241
|
+
} else {
|
|
6242
|
+
emit("hide");
|
|
6243
|
+
}
|
|
6244
|
+
});
|
|
6245
|
+
return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
|
|
6246
|
+
default: () => {
|
|
6247
|
+
var _a;
|
|
6248
|
+
return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
|
6249
|
+
}
|
|
6250
|
+
}), createVNode(Teleport, {
|
|
6251
|
+
"to": "body"
|
|
6252
|
+
}, {
|
|
6253
|
+
default: () => [createVNode(Transition, {
|
|
6254
|
+
"name": showAnimation.value ? ns2.m(`fade-${placement.value}`) : ""
|
|
6179
6255
|
}, {
|
|
6180
|
-
default: () => [createVNode(
|
|
6181
|
-
"
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
}
|
|
6204
|
-
})]
|
|
6256
|
+
default: () => [createVNode(FlexibleOverlay, mergeProps({
|
|
6257
|
+
"modelValue": visible.value,
|
|
6258
|
+
"onUpdate:modelValue": ($event) => visible.value = $event,
|
|
6259
|
+
"ref": popoverRef,
|
|
6260
|
+
"origin": origin.value,
|
|
6261
|
+
"position": position.value,
|
|
6262
|
+
"align": align.value,
|
|
6263
|
+
"offset": offset2.value,
|
|
6264
|
+
"class": [ns2.e("content"), popType.value !== "default" ? "is-icon" : ""],
|
|
6265
|
+
"show-arrow": true,
|
|
6266
|
+
"is-arrow-center": false,
|
|
6267
|
+
"style": overlayStyles.value
|
|
6268
|
+
}, attrs, {
|
|
6269
|
+
"onPositionChange": handlePositionChange,
|
|
6270
|
+
"onMouseenter": onMouseenter,
|
|
6271
|
+
"onMouseleave": onMouseleave
|
|
6272
|
+
}), {
|
|
6273
|
+
default: () => {
|
|
6274
|
+
var _a;
|
|
6275
|
+
return [createVNode(PopoverIcon, {
|
|
6276
|
+
"type": popType.value
|
|
6277
|
+
}, null), ((_a = slots.content) == null ? void 0 : _a.call(slots)) || createVNode("span", null, [content.value])];
|
|
6278
|
+
}
|
|
6205
6279
|
})]
|
|
6206
|
-
})]
|
|
6207
|
-
};
|
|
6280
|
+
})]
|
|
6281
|
+
})]);
|
|
6208
6282
|
}
|
|
6209
6283
|
});
|
|
6284
|
+
function HelpTipsIcon() {
|
|
6285
|
+
return createVNode("svg", {
|
|
6286
|
+
"width": "16px",
|
|
6287
|
+
"height": "16px",
|
|
6288
|
+
"viewBox": "0 0 16 16"
|
|
6289
|
+
}, [createVNode("g", {
|
|
6290
|
+
"stroke": "none",
|
|
6291
|
+
"stroke-width": "1",
|
|
6292
|
+
"fill": "none",
|
|
6293
|
+
"fill-rule": "evenodd"
|
|
6294
|
+
}, [createVNode("g", null, [createVNode("path", {
|
|
6295
|
+
"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",
|
|
6296
|
+
"fill": "#293040",
|
|
6297
|
+
"fill-rule": "nonzero"
|
|
6298
|
+
}, null)])])]);
|
|
6299
|
+
}
|
|
6300
|
+
function ErrorIcon() {
|
|
6301
|
+
return createVNode("svg", {
|
|
6302
|
+
"width": "14px",
|
|
6303
|
+
"height": "14px",
|
|
6304
|
+
"viewBox": "0 0 16 16"
|
|
6305
|
+
}, [createVNode("g", {
|
|
6306
|
+
"stroke": "none",
|
|
6307
|
+
"stroke-width": "1",
|
|
6308
|
+
"fill": "none",
|
|
6309
|
+
"fill-rule": "evenodd"
|
|
6310
|
+
}, [createVNode("circle", {
|
|
6311
|
+
"cx": "8",
|
|
6312
|
+
"cy": "8",
|
|
6313
|
+
"r": "8"
|
|
6314
|
+
}, null), createVNode("polygon", {
|
|
6315
|
+
"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"
|
|
6316
|
+
}, null)])]);
|
|
6317
|
+
}
|
|
6318
|
+
function SuccessIcon() {
|
|
6319
|
+
return createVNode("svg", {
|
|
6320
|
+
"width": "14px",
|
|
6321
|
+
"height": "14px",
|
|
6322
|
+
"viewBox": "0 0 16 16"
|
|
6323
|
+
}, [createVNode("g", {
|
|
6324
|
+
"stroke": "none",
|
|
6325
|
+
"stroke-width": "1",
|
|
6326
|
+
"fill": "none",
|
|
6327
|
+
"fill-rule": "evenodd"
|
|
6328
|
+
}, [createVNode("circle", {
|
|
6329
|
+
"cx": "8",
|
|
6330
|
+
"cy": "8",
|
|
6331
|
+
"r": "8"
|
|
6332
|
+
}, null), createVNode("polygon", {
|
|
6333
|
+
"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"
|
|
6334
|
+
}, null)])]);
|
|
6335
|
+
}
|
|
6336
|
+
function PendingIcon() {
|
|
6337
|
+
return createVNode("svg", {
|
|
6338
|
+
"width": "14px",
|
|
6339
|
+
"height": "14px",
|
|
6340
|
+
"viewBox": "0 0 16 16"
|
|
6341
|
+
}, [createVNode("g", {
|
|
6342
|
+
"id": "loading",
|
|
6343
|
+
"stroke": "none",
|
|
6344
|
+
"stroke-width": "1",
|
|
6345
|
+
"fill": "none",
|
|
6346
|
+
"fill-rule": "evenodd"
|
|
6347
|
+
}, [createVNode("path", {
|
|
6348
|
+
"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",
|
|
6349
|
+
"fill-rule": "nonzero"
|
|
6350
|
+
}, null), createVNode("path", {
|
|
6351
|
+
"d": "M8,0 C12.4,0 16,3.6 16,8 L15,8 C15,4.15 11.85,1 8,1 L8,0 Z",
|
|
6352
|
+
"fill-rule": "nonzero"
|
|
6353
|
+
}, null)])]);
|
|
6354
|
+
}
|
|
6355
|
+
function useFormLabel() {
|
|
6356
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6357
|
+
const labelData = inject(LABEL_DATA);
|
|
6358
|
+
const ns2 = useNamespace("form");
|
|
6359
|
+
const labelClasses = computed(() => ({
|
|
6360
|
+
[`${ns2.e("label")}`]: true,
|
|
6361
|
+
[`${ns2.em("label", "vertical")}`]: labelData.value.layout === "vertical",
|
|
6362
|
+
[`${ns2.em("label", labelData.value.labelSize)}`]: labelData.value.layout === "horizontal",
|
|
6363
|
+
[`${ns2.em("label", labelData.value.labelAlign)}`]: labelData.value.layout === "horizontal"
|
|
6364
|
+
}));
|
|
6365
|
+
const labelInnerClasses = computed(() => ({
|
|
6366
|
+
[`${ns2.e("label-span")}`]: true,
|
|
6367
|
+
[`${ns2.em("label", "required")}`]: formItemContext.isRequired
|
|
6368
|
+
}));
|
|
6369
|
+
return { labelClasses, labelInnerClasses };
|
|
6370
|
+
}
|
|
6210
6371
|
var formLabel = "";
|
|
6211
6372
|
var FormLabel = defineComponent({
|
|
6212
6373
|
name: "DFormLabel",
|
|
6213
6374
|
props: formLabelProps,
|
|
6214
|
-
setup(props,
|
|
6215
|
-
const
|
|
6216
|
-
const
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
const isCenter = computed(() => labelData.labelAlign === "center").value;
|
|
6221
|
-
const isEnd = computed(() => labelData.labelAlign === "end").value;
|
|
6222
|
-
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" : ""}`;
|
|
6223
|
-
const className = `${props.required ? " devui-required" : ""}`;
|
|
6224
|
-
const style2 = {
|
|
6225
|
-
display: isHorizontal ? "inline" : "inline-block"
|
|
6226
|
-
};
|
|
6375
|
+
setup(props, ctx) {
|
|
6376
|
+
const ns2 = useNamespace("form");
|
|
6377
|
+
const {
|
|
6378
|
+
labelClasses,
|
|
6379
|
+
labelInnerClasses
|
|
6380
|
+
} = useFormLabel();
|
|
6227
6381
|
return () => {
|
|
6228
6382
|
var _a, _b;
|
|
6229
6383
|
return createVNode("span", {
|
|
6230
|
-
"class":
|
|
6231
|
-
"style": style2
|
|
6384
|
+
"class": labelClasses.value
|
|
6232
6385
|
}, [createVNode("span", {
|
|
6233
|
-
"class":
|
|
6234
|
-
}, [(_b = (_a =
|
|
6386
|
+
"class": labelInnerClasses.value
|
|
6387
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), props.helpTips && createVNode(Popover, {
|
|
6235
6388
|
"content": props.helpTips,
|
|
6236
|
-
"
|
|
6237
|
-
"
|
|
6238
|
-
"
|
|
6389
|
+
"position": ["top"],
|
|
6390
|
+
"trigger": "hover",
|
|
6391
|
+
"pop-type": "info"
|
|
6239
6392
|
}, {
|
|
6240
|
-
|
|
6241
|
-
"class": "
|
|
6242
|
-
},
|
|
6243
|
-
|
|
6244
|
-
"color": "#252b3a"
|
|
6245
|
-
}, null)])
|
|
6246
|
-
})])]);
|
|
6393
|
+
default: () => [createVNode(HelpTipsIcon, {
|
|
6394
|
+
"class": ns2.e("label-help")
|
|
6395
|
+
}, null), createTextVNode(",")]
|
|
6396
|
+
})]);
|
|
6247
6397
|
};
|
|
6248
6398
|
}
|
|
6249
6399
|
});
|
|
6400
|
+
const formControlProps = {
|
|
6401
|
+
feedbackStatus: {
|
|
6402
|
+
type: String
|
|
6403
|
+
},
|
|
6404
|
+
extraInfo: {
|
|
6405
|
+
type: String,
|
|
6406
|
+
default: ""
|
|
6407
|
+
}
|
|
6408
|
+
};
|
|
6409
|
+
function useFormControl(props) {
|
|
6410
|
+
const labelData = inject(LABEL_DATA);
|
|
6411
|
+
const ns2 = useNamespace("form");
|
|
6412
|
+
const { feedbackStatus } = toRefs(props);
|
|
6413
|
+
const controlClasses = computed(() => ({
|
|
6414
|
+
[ns2.e("control")]: true,
|
|
6415
|
+
[ns2.em("control", "horizontal")]: labelData.value.layout === "horizontal"
|
|
6416
|
+
}));
|
|
6417
|
+
const controlContainerClasses = computed(() => ({
|
|
6418
|
+
[ns2.e("control-container")]: true,
|
|
6419
|
+
[ns2.em("control-container", "horizontal")]: labelData.value.layout === "horizontal",
|
|
6420
|
+
[ns2.em("control-container", "has-feedback")]: Boolean(feedbackStatus == null ? void 0 : feedbackStatus.value),
|
|
6421
|
+
[ns2.em("control-container", "feedback-error")]: Boolean((feedbackStatus == null ? void 0 : feedbackStatus.value) === "error")
|
|
6422
|
+
}));
|
|
6423
|
+
return { controlClasses, controlContainerClasses };
|
|
6424
|
+
}
|
|
6425
|
+
function useFormControlValidate() {
|
|
6426
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6427
|
+
const feedbackStatus = computed(() => formItemContext.validateState);
|
|
6428
|
+
const showFeedback = computed(() => formItemContext.showFeedback && Boolean(formItemContext.validateState));
|
|
6429
|
+
const showPopover = computed(() => formItemContext.messageType === "popover" && formItemContext.validateState === "error");
|
|
6430
|
+
const showMessage = computed(() => formItemContext.messageType === "text" && formItemContext.validateState === "error");
|
|
6431
|
+
const errorMessage = computed(() => formItemContext.validateMessage);
|
|
6432
|
+
const popPosition = computed(() => formItemContext.popPosition);
|
|
6433
|
+
return { feedbackStatus, showFeedback, showPopover, showMessage, errorMessage, popPosition };
|
|
6434
|
+
}
|
|
6435
|
+
var formControl = "";
|
|
6436
|
+
var FormControl = defineComponent({
|
|
6437
|
+
name: "DFormControl",
|
|
6438
|
+
props: formControlProps,
|
|
6439
|
+
setup(props, ctx) {
|
|
6440
|
+
const formControl2 = ref();
|
|
6441
|
+
const ns2 = useNamespace("form");
|
|
6442
|
+
const {
|
|
6443
|
+
controlClasses,
|
|
6444
|
+
controlContainerClasses
|
|
6445
|
+
} = useFormControl(props);
|
|
6446
|
+
const {
|
|
6447
|
+
feedbackStatus,
|
|
6448
|
+
showFeedback,
|
|
6449
|
+
showPopover,
|
|
6450
|
+
showMessage,
|
|
6451
|
+
errorMessage,
|
|
6452
|
+
popPosition
|
|
6453
|
+
} = useFormControlValidate();
|
|
6454
|
+
return () => createVNode("div", {
|
|
6455
|
+
"class": controlClasses.value,
|
|
6456
|
+
"ref": formControl2
|
|
6457
|
+
}, [createVNode("div", {
|
|
6458
|
+
"class": controlContainerClasses.value
|
|
6459
|
+
}, [createVNode(Popover, {
|
|
6460
|
+
"is-open": showPopover.value,
|
|
6461
|
+
"trigger": "manually",
|
|
6462
|
+
"content": errorMessage.value,
|
|
6463
|
+
"pop-type": "error",
|
|
6464
|
+
"position": popPosition.value
|
|
6465
|
+
}, {
|
|
6466
|
+
default: () => {
|
|
6467
|
+
var _a, _b;
|
|
6468
|
+
return [createVNode("div", {
|
|
6469
|
+
"class": ns2.e("control-content")
|
|
6470
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), createTextVNode(",")];
|
|
6471
|
+
}
|
|
6472
|
+
}), showFeedback.value && createVNode("span", {
|
|
6473
|
+
"class": [ns2.e("feedback-icon"), ns2.em("feedback-icon", feedbackStatus.value)]
|
|
6474
|
+
}, [feedbackStatus.value === "error" && createVNode(ErrorIcon, null, null), feedbackStatus.value === "success" && createVNode(SuccessIcon, null, null), feedbackStatus.value === "pending" && createVNode(PendingIcon, null, null)])]), createVNode("div", {
|
|
6475
|
+
"class": ns2.e("control-info")
|
|
6476
|
+
}, [showMessage.value && createVNode("div", {
|
|
6477
|
+
"class": "error-message"
|
|
6478
|
+
}, [errorMessage.value]), props.extraInfo && createVNode("div", {
|
|
6479
|
+
"class": ns2.e("control-extra")
|
|
6480
|
+
}, [props.extraInfo])])]);
|
|
6481
|
+
}
|
|
6482
|
+
});
|
|
6250
6483
|
function _extends() {
|
|
6251
6484
|
_extends = Object.assign || function(target) {
|
|
6252
6485
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -7249,617 +7482,248 @@ Schema.register = function register(type4, validator) {
|
|
|
7249
7482
|
Schema.warning = warning;
|
|
7250
7483
|
Schema.messages = messages;
|
|
7251
7484
|
Schema.validators = validators;
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7485
|
+
function useFormItem(messageType, _rules, validateState) {
|
|
7486
|
+
const formContext = inject(FORM_TOKEN);
|
|
7487
|
+
const ns2 = useNamespace("form");
|
|
7488
|
+
const itemClasses = computed(() => ({
|
|
7489
|
+
[`${ns2.em("item", "horizontal")}`]: formContext.layout === "horizontal",
|
|
7490
|
+
[`${ns2.em("item", "vertical")}`]: formContext.layout === "vertical",
|
|
7491
|
+
[`${ns2.em("item", "error")}`]: messageType.value === "text" && validateState.value === "error"
|
|
7492
|
+
}));
|
|
7493
|
+
const isRequired = computed(() => _rules.value.some((rule) => Boolean(rule.required)));
|
|
7494
|
+
return { itemClasses, isRequired };
|
|
7495
|
+
}
|
|
7496
|
+
function useFormItemRule(props) {
|
|
7497
|
+
const formContext = inject(FORM_TOKEN);
|
|
7498
|
+
const _rules = computed(() => {
|
|
7499
|
+
const rules2 = props.rules ? lodash.exports.castArray(props.rules) : [];
|
|
7500
|
+
const formRules = formContext.rules;
|
|
7501
|
+
if (formRules && props.field) {
|
|
7502
|
+
const _itemRules = lodash.exports.get(formRules, props.field, void 0);
|
|
7503
|
+
if (_itemRules) {
|
|
7504
|
+
rules2.push(...lodash.exports.castArray(_itemRules));
|
|
7269
7505
|
}
|
|
7270
|
-
}
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
showMessage.value = false;
|
|
7293
|
-
tipMessage.value = "";
|
|
7294
|
-
}).catch(({
|
|
7295
|
-
errors
|
|
7296
|
-
}) => {
|
|
7297
|
-
showMessage.value = true;
|
|
7298
|
-
tipMessage.value = errors[0].message;
|
|
7299
|
-
});
|
|
7300
|
-
};
|
|
7301
|
-
const validateEvents = [];
|
|
7302
|
-
const addValidateEvents = () => {
|
|
7303
|
-
if (rules2 && rules2[props.prop]) {
|
|
7304
|
-
const ruleItem = rules2[props.prop];
|
|
7305
|
-
let eventName = ruleItem["trigger"];
|
|
7306
|
-
if (Array.isArray(ruleItem)) {
|
|
7307
|
-
ruleItem.forEach((item) => {
|
|
7308
|
-
eventName = item["trigger"];
|
|
7309
|
-
const cb = () => validate();
|
|
7310
|
-
validateEvents.push({
|
|
7311
|
-
eventName: cb
|
|
7312
|
-
});
|
|
7313
|
-
formItem2.formItemMitt.on(dFormItemEvents[eventName], cb);
|
|
7314
|
-
});
|
|
7315
|
-
} else {
|
|
7316
|
-
const cb = () => validate();
|
|
7317
|
-
validateEvents.push({
|
|
7318
|
-
eventName: cb
|
|
7319
|
-
});
|
|
7320
|
-
ruleItem && formItem2.formItemMitt.on(dFormItemEvents[eventName], cb);
|
|
7321
|
-
}
|
|
7506
|
+
}
|
|
7507
|
+
if (props.required) {
|
|
7508
|
+
rules2.push({ required: Boolean(props.required) });
|
|
7509
|
+
}
|
|
7510
|
+
return rules2;
|
|
7511
|
+
});
|
|
7512
|
+
return { _rules };
|
|
7513
|
+
}
|
|
7514
|
+
function useFormItemValidate(props, _rules) {
|
|
7515
|
+
const formContext = inject(FORM_TOKEN);
|
|
7516
|
+
const validateState = ref("");
|
|
7517
|
+
const validateMessage = ref("");
|
|
7518
|
+
let initFieldValue = void 0;
|
|
7519
|
+
let isResetting = false;
|
|
7520
|
+
const computedField = computed(() => {
|
|
7521
|
+
return typeof props.field === "string" ? props.field : "";
|
|
7522
|
+
});
|
|
7523
|
+
const fieldValue = computed({
|
|
7524
|
+
get: () => {
|
|
7525
|
+
const formData = formContext.data;
|
|
7526
|
+
if (!formData || !props.field) {
|
|
7527
|
+
return;
|
|
7322
7528
|
}
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7529
|
+
return formData[props.field];
|
|
7530
|
+
},
|
|
7531
|
+
set: (val) => {
|
|
7532
|
+
formContext.data[props.field] = val;
|
|
7533
|
+
}
|
|
7534
|
+
});
|
|
7535
|
+
const getRuleByTrigger = (triggerVal) => {
|
|
7536
|
+
return _rules.value.filter((rule) => {
|
|
7537
|
+
if (!rule.trigger || !triggerVal) {
|
|
7538
|
+
return true;
|
|
7329
7539
|
}
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7540
|
+
if (Array.isArray(rule.trigger)) {
|
|
7541
|
+
return rule.trigger.includes(triggerVal);
|
|
7542
|
+
} else {
|
|
7543
|
+
return rule.trigger === triggerVal;
|
|
7544
|
+
}
|
|
7545
|
+
}).map((_a) => {
|
|
7546
|
+
var _b = _a, { trigger } = _b, rule = __objRest(_b, ["trigger"]);
|
|
7547
|
+
return rule;
|
|
7334
7548
|
});
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7549
|
+
};
|
|
7550
|
+
const onValidateSuccess = () => {
|
|
7551
|
+
validateState.value = "success";
|
|
7552
|
+
validateMessage.value = "";
|
|
7553
|
+
formContext.emit("validate", props.field, true, "");
|
|
7554
|
+
};
|
|
7555
|
+
const onValidateError = ({ errors }) => {
|
|
7556
|
+
var _a;
|
|
7557
|
+
validateState.value = "error";
|
|
7558
|
+
validateMessage.value = ((_a = errors == null ? void 0 : errors[0]) == null ? void 0 : _a.message) || "";
|
|
7559
|
+
formContext.emit("validate", props.field, false, validateMessage.value);
|
|
7560
|
+
};
|
|
7561
|
+
const execValidate = async (rules2) => {
|
|
7562
|
+
const ruleName = computedField.value;
|
|
7563
|
+
const validator = new Schema({
|
|
7564
|
+
[ruleName]: rules2
|
|
7338
7565
|
});
|
|
7339
|
-
return () => {
|
|
7340
|
-
|
|
7341
|
-
return
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
if (element && eventName && handler) {
|
|
7352
|
-
element.addEventListener(eventName, handler, false);
|
|
7566
|
+
return validator.validate({ [ruleName]: fieldValue.value }, { firstFields: true }).then(() => {
|
|
7567
|
+
onValidateSuccess();
|
|
7568
|
+
return true;
|
|
7569
|
+
}).catch((error) => {
|
|
7570
|
+
onValidateError(error);
|
|
7571
|
+
return Promise.reject(error);
|
|
7572
|
+
});
|
|
7573
|
+
};
|
|
7574
|
+
const validate = async (trigger, callback) => {
|
|
7575
|
+
if (isResetting) {
|
|
7576
|
+
isResetting = false;
|
|
7577
|
+
return false;
|
|
7353
7578
|
}
|
|
7354
|
-
|
|
7355
|
-
if (
|
|
7356
|
-
|
|
7579
|
+
const rules2 = getRuleByTrigger(trigger);
|
|
7580
|
+
if (!rules2.length) {
|
|
7581
|
+
callback == null ? void 0 : callback(true);
|
|
7582
|
+
return true;
|
|
7357
7583
|
}
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
if (inBrowser && isFirst) {
|
|
7367
|
-
isFirst = false;
|
|
7368
|
-
on(document, "mousedown", (e) => {
|
|
7369
|
-
startClick = e;
|
|
7370
|
-
});
|
|
7371
|
-
on(document, "mouseup", (e) => {
|
|
7372
|
-
for (const [id, node] of nodeList) {
|
|
7373
|
-
node[ctx].documentHandler(e, startClick);
|
|
7374
|
-
}
|
|
7584
|
+
validateState.value = "pending";
|
|
7585
|
+
return execValidate(rules2).then(() => {
|
|
7586
|
+
callback == null ? void 0 : callback(true);
|
|
7587
|
+
return true;
|
|
7588
|
+
}).catch((error) => {
|
|
7589
|
+
const { fields } = error;
|
|
7590
|
+
callback == null ? void 0 : callback(false, fields);
|
|
7591
|
+
return lodash.exports.isFunction(callback) ? false : Promise.reject(fields);
|
|
7375
7592
|
});
|
|
7376
|
-
}
|
|
7377
|
-
|
|
7378
|
-
|
|
7593
|
+
};
|
|
7594
|
+
const clearValidate = () => {
|
|
7595
|
+
validateState.value = "";
|
|
7596
|
+
validateMessage.value = "";
|
|
7597
|
+
};
|
|
7598
|
+
const resetField = async () => {
|
|
7599
|
+
if (!formContext.data || !props.field) {
|
|
7379
7600
|
return;
|
|
7380
7601
|
}
|
|
7381
|
-
|
|
7602
|
+
isResetting = true;
|
|
7603
|
+
fieldValue.value = initFieldValue;
|
|
7604
|
+
await nextTick();
|
|
7605
|
+
clearValidate();
|
|
7382
7606
|
};
|
|
7607
|
+
onMounted(() => {
|
|
7608
|
+
initFieldValue = lodash.exports.cloneDeep(formContext.data[props.field]);
|
|
7609
|
+
});
|
|
7610
|
+
return { validateState, validateMessage, validate, resetField, clearValidate };
|
|
7383
7611
|
}
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
const
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
const
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
}
|
|
7444
|
-
});
|
|
7612
|
+
var formItem = "";
|
|
7613
|
+
var FormItem = defineComponent({
|
|
7614
|
+
name: "DFormItem",
|
|
7615
|
+
props: formItemProps,
|
|
7616
|
+
setup(props, ctx) {
|
|
7617
|
+
const formContext = inject(FORM_TOKEN);
|
|
7618
|
+
const _a = toRefs(props), {
|
|
7619
|
+
messageType: itemMessageType,
|
|
7620
|
+
popPosition: itemPopPosition,
|
|
7621
|
+
showFeedback: itemShowFeedback
|
|
7622
|
+
} = _a, otherProps = __objRest(_a, [
|
|
7623
|
+
"messageType",
|
|
7624
|
+
"popPosition",
|
|
7625
|
+
"showFeedback"
|
|
7626
|
+
]);
|
|
7627
|
+
const {
|
|
7628
|
+
label,
|
|
7629
|
+
helpTips,
|
|
7630
|
+
feedbackStatus,
|
|
7631
|
+
extraInfo
|
|
7632
|
+
} = toRefs(props);
|
|
7633
|
+
const showFeedback = computed(() => (itemShowFeedback == null ? void 0 : itemShowFeedback.value) !== void 0 ? itemShowFeedback.value : formContext.showFeedback);
|
|
7634
|
+
const messageType = computed(() => (itemMessageType == null ? void 0 : itemMessageType.value) || formContext.messageType);
|
|
7635
|
+
const popPosition = computed(() => (itemPopPosition == null ? void 0 : itemPopPosition.value) || formContext.popPosition);
|
|
7636
|
+
const {
|
|
7637
|
+
_rules
|
|
7638
|
+
} = useFormItemRule(props);
|
|
7639
|
+
const {
|
|
7640
|
+
validateState,
|
|
7641
|
+
validateMessage,
|
|
7642
|
+
validate,
|
|
7643
|
+
resetField,
|
|
7644
|
+
clearValidate
|
|
7645
|
+
} = useFormItemValidate(props, _rules);
|
|
7646
|
+
const {
|
|
7647
|
+
itemClasses,
|
|
7648
|
+
isRequired
|
|
7649
|
+
} = useFormItem(messageType, _rules, validateState);
|
|
7650
|
+
const labelData = computed(() => ({
|
|
7651
|
+
layout: formContext.layout,
|
|
7652
|
+
labelSize: formContext.labelSize,
|
|
7653
|
+
labelAlign: formContext.labelAlign
|
|
7654
|
+
}));
|
|
7655
|
+
provide(LABEL_DATA, labelData);
|
|
7656
|
+
const context = reactive(__spreadProps(__spreadValues({}, otherProps), {
|
|
7657
|
+
showFeedback,
|
|
7658
|
+
messageType,
|
|
7659
|
+
popPosition,
|
|
7660
|
+
isRequired,
|
|
7661
|
+
validateState,
|
|
7662
|
+
validateMessage,
|
|
7663
|
+
validate,
|
|
7664
|
+
resetField,
|
|
7665
|
+
clearValidate
|
|
7666
|
+
}));
|
|
7667
|
+
provide(FORM_ITEM_TOKEN, context);
|
|
7668
|
+
ctx.expose({
|
|
7669
|
+
resetField,
|
|
7670
|
+
clearValidate
|
|
7445
7671
|
});
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
return {
|
|
7450
|
-
name: "priority",
|
|
7451
|
-
color: "#e9edfa"
|
|
7452
|
-
};
|
|
7453
|
-
case "success":
|
|
7454
|
-
return {
|
|
7455
|
-
name: "right-o",
|
|
7456
|
-
color: "rgb(61, 204, 166)"
|
|
7457
|
-
};
|
|
7458
|
-
case "error":
|
|
7459
|
-
return {
|
|
7460
|
-
name: "error-o",
|
|
7461
|
-
color: "rgb(249, 95, 91)"
|
|
7462
|
-
};
|
|
7463
|
-
default:
|
|
7464
|
-
return {
|
|
7465
|
-
name: "",
|
|
7466
|
-
color: ""
|
|
7467
|
-
};
|
|
7672
|
+
onMounted(() => {
|
|
7673
|
+
if (props.field) {
|
|
7674
|
+
formContext == null ? void 0 : formContext.addItemContext(context);
|
|
7468
7675
|
}
|
|
7469
7676
|
});
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
default: () => [createVNode("div", {
|
|
7489
|
-
"style": {
|
|
7490
|
-
position: "absolute",
|
|
7491
|
-
left: popoverLeftPosition + "px",
|
|
7492
|
-
top: popoverTopPosition + "px",
|
|
7493
|
-
width: rectInfo.width + "px",
|
|
7494
|
-
height: rectInfo.height + "px"
|
|
7495
|
-
}
|
|
7496
|
-
}, [createVNode(Popover, {
|
|
7497
|
-
"controlled": updateOn.value !== "change",
|
|
7498
|
-
"visible": showPopover.value,
|
|
7499
|
-
"content": tipMessage.value,
|
|
7500
|
-
"popType": "error",
|
|
7501
|
-
"position": popPosition.value
|
|
7502
|
-
}, null)])]
|
|
7503
|
-
}), createVNode("div", {
|
|
7504
|
-
"class": `devui-form-control-container${isHorizontal ? " devui-form-control-container-horizontal" : ""}${feedbackStatus ? " devui-has-feedback" : ""}${feedbackStatus === "error" ? " devui-feedback-error" : ""}`
|
|
7505
|
-
}, [createVNode("div", {
|
|
7506
|
-
"class": "devui-control-content-wrapper",
|
|
7507
|
-
"id": uid
|
|
7508
|
-
}, [(_b = (_a = ctx2.slots).default) == null ? void 0 : _b.call(_a)]), (feedbackStatus || ((_d = (_c = ctx2.slots).suffixTemplate) == null ? void 0 : _d.call(_c))) && createVNode("span", {
|
|
7509
|
-
"class": "devui-feedback-status"
|
|
7510
|
-
}, [((_f = (_e = ctx2.slots).suffixTemplate) == null ? void 0 : _f.call(_e)) ? (_h = (_g = ctx2.slots).suffixTemplate) == null ? void 0 : _h.call(_g) : createVNode(Icon, {
|
|
7511
|
-
"name": iconData.value.name,
|
|
7512
|
-
"color": iconData.value.color
|
|
7513
|
-
}, null)])]), extraInfo && createVNode("div", {
|
|
7514
|
-
"class": "devui-form-control-extra-info"
|
|
7515
|
-
}, [extraInfo])]), [[resolveDirective("clickoutside"), handleClickOutside]]);
|
|
7516
|
-
};
|
|
7677
|
+
onBeforeUnmount(() => {
|
|
7678
|
+
formContext == null ? void 0 : formContext.removeItemContext(context);
|
|
7679
|
+
});
|
|
7680
|
+
return () => createVNode("div", {
|
|
7681
|
+
"class": itemClasses.value
|
|
7682
|
+
}, [createVNode(FormLabel, {
|
|
7683
|
+
"help-tips": helpTips.value
|
|
7684
|
+
}, {
|
|
7685
|
+
default: () => [label == null ? void 0 : label.value]
|
|
7686
|
+
}), createVNode(FormControl, {
|
|
7687
|
+
"feedback-status": feedbackStatus == null ? void 0 : feedbackStatus.value,
|
|
7688
|
+
"extra-info": extraInfo.value
|
|
7689
|
+
}, {
|
|
7690
|
+
default: () => {
|
|
7691
|
+
var _a2, _b;
|
|
7692
|
+
return [(_b = (_a2 = ctx.slots).default) == null ? void 0 : _b.call(_a2)];
|
|
7693
|
+
}
|
|
7694
|
+
})]);
|
|
7517
7695
|
}
|
|
7518
7696
|
});
|
|
7519
7697
|
var formOperation = "";
|
|
7520
7698
|
var FormOperation = defineComponent({
|
|
7521
7699
|
name: "DFormOperation",
|
|
7522
|
-
props
|
|
7523
|
-
|
|
7700
|
+
setup(props, ctx) {
|
|
7701
|
+
const formContext = inject(FORM_TOKEN);
|
|
7702
|
+
const LabelSizeMap = {
|
|
7703
|
+
sm: 80,
|
|
7704
|
+
md: 100,
|
|
7705
|
+
lg: 150
|
|
7706
|
+
};
|
|
7707
|
+
const styles = computed(() => ({
|
|
7708
|
+
marginLeft: formContext.layout === "horizontal" ? `${LabelSizeMap[formContext.labelSize] + 16}px` : void 0
|
|
7709
|
+
}));
|
|
7524
7710
|
return () => {
|
|
7525
7711
|
var _a, _b;
|
|
7526
7712
|
return createVNode("div", {
|
|
7527
|
-
"class": "devui-form-operation"
|
|
7528
|
-
|
|
7713
|
+
"class": "devui-form-operation",
|
|
7714
|
+
"style": styles.value
|
|
7715
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
7529
7716
|
};
|
|
7530
7717
|
}
|
|
7531
7718
|
});
|
|
7532
|
-
var style = "";
|
|
7533
|
-
function getAvaliableRuleObj(ruleName, value) {
|
|
7534
|
-
if (!ruleName) {
|
|
7535
|
-
console.error("[v-d-validate] validator's key is invalid");
|
|
7536
|
-
return null;
|
|
7537
|
-
}
|
|
7538
|
-
switch (ruleName) {
|
|
7539
|
-
case "maxlength":
|
|
7540
|
-
return {
|
|
7541
|
-
type: "string",
|
|
7542
|
-
max: value,
|
|
7543
|
-
asyncValidator: (rule, val) => {
|
|
7544
|
-
return new Promise((resolve, reject) => {
|
|
7545
|
-
if (val.length > value) {
|
|
7546
|
-
reject("\u6700\u5927\u957F\u5EA6\u4E3A" + value);
|
|
7547
|
-
} else {
|
|
7548
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7549
|
-
}
|
|
7550
|
-
});
|
|
7551
|
-
}
|
|
7552
|
-
};
|
|
7553
|
-
case "minlength":
|
|
7554
|
-
return {
|
|
7555
|
-
type: "string",
|
|
7556
|
-
min: value,
|
|
7557
|
-
asyncValidator: (rule, val) => {
|
|
7558
|
-
return new Promise((resolve, reject) => {
|
|
7559
|
-
if (val.length < value) {
|
|
7560
|
-
reject("\u6700\u5C0F\u957F\u5EA6\u4E3A" + value);
|
|
7561
|
-
} else {
|
|
7562
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7563
|
-
}
|
|
7564
|
-
});
|
|
7565
|
-
}
|
|
7566
|
-
};
|
|
7567
|
-
case "min":
|
|
7568
|
-
return {
|
|
7569
|
-
type: "number",
|
|
7570
|
-
asyncValidator: (rule, val) => {
|
|
7571
|
-
return new Promise((resolve, reject) => {
|
|
7572
|
-
if (val < value) {
|
|
7573
|
-
reject("\u6700\u5C0F\u503C\u4E3A" + value);
|
|
7574
|
-
} else {
|
|
7575
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7576
|
-
}
|
|
7577
|
-
});
|
|
7578
|
-
}
|
|
7579
|
-
};
|
|
7580
|
-
case "max":
|
|
7581
|
-
return {
|
|
7582
|
-
type: "number",
|
|
7583
|
-
asyncValidator: (rule, val) => {
|
|
7584
|
-
return new Promise((resolve, reject) => {
|
|
7585
|
-
if (val > value) {
|
|
7586
|
-
reject("\u6700\u5927\u503C\u4E3A" + value);
|
|
7587
|
-
} else {
|
|
7588
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7589
|
-
}
|
|
7590
|
-
});
|
|
7591
|
-
}
|
|
7592
|
-
};
|
|
7593
|
-
case "required":
|
|
7594
|
-
return {
|
|
7595
|
-
reqiured: true,
|
|
7596
|
-
asyncValidator: (rule, val) => {
|
|
7597
|
-
return new Promise((resolve, reject) => {
|
|
7598
|
-
if (!val) {
|
|
7599
|
-
reject("\u5FC5\u586B\u9879");
|
|
7600
|
-
} else {
|
|
7601
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7602
|
-
}
|
|
7603
|
-
});
|
|
7604
|
-
}
|
|
7605
|
-
};
|
|
7606
|
-
case "requiredTrue":
|
|
7607
|
-
return {
|
|
7608
|
-
asyncValidator: (rule, val) => {
|
|
7609
|
-
return new Promise((resolve, reject) => {
|
|
7610
|
-
if (!val) {
|
|
7611
|
-
reject("\u5FC5\u987B\u4E3Atrue\u503C");
|
|
7612
|
-
} else {
|
|
7613
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7614
|
-
}
|
|
7615
|
-
});
|
|
7616
|
-
}
|
|
7617
|
-
};
|
|
7618
|
-
case "email":
|
|
7619
|
-
return {
|
|
7620
|
-
type: "email",
|
|
7621
|
-
message: "\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E"
|
|
7622
|
-
};
|
|
7623
|
-
case "pattern":
|
|
7624
|
-
return {
|
|
7625
|
-
type: "regexp",
|
|
7626
|
-
pattern: value,
|
|
7627
|
-
message: "\u53EA\u80FD\u5305\u542B\u6570\u5B57\u4E0E\u5927\u5C0F\u5199\u5B57\u7B26",
|
|
7628
|
-
validator: (rule, val) => value.test(val)
|
|
7629
|
-
};
|
|
7630
|
-
case "whitespace":
|
|
7631
|
-
return {
|
|
7632
|
-
message: "\u8F93\u5165\u4E0D\u80FD\u5168\u90E8\u4E3A\u7A7A\u683C\u6216\u7A7A\u5B57\u7B26",
|
|
7633
|
-
validator: (rule, val) => !!val.trim()
|
|
7634
|
-
};
|
|
7635
|
-
default:
|
|
7636
|
-
return {
|
|
7637
|
-
[ruleName]: value
|
|
7638
|
-
};
|
|
7639
|
-
}
|
|
7640
|
-
}
|
|
7641
|
-
function getKeyValueOfObjectList(obj) {
|
|
7642
|
-
const kvArr = [];
|
|
7643
|
-
for (const key in obj) {
|
|
7644
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
7645
|
-
kvArr.push({
|
|
7646
|
-
key,
|
|
7647
|
-
value: obj[key]
|
|
7648
|
-
});
|
|
7649
|
-
}
|
|
7650
|
-
}
|
|
7651
|
-
return kvArr;
|
|
7652
|
-
}
|
|
7653
|
-
function handleErrorStrategy(el) {
|
|
7654
|
-
const classList = [...el.classList];
|
|
7655
|
-
classList.push("devui-validate-rules-error-pristine");
|
|
7656
|
-
el.setAttribute("class", classList.join(" "));
|
|
7657
|
-
}
|
|
7658
|
-
function handleErrorStrategyPass(el) {
|
|
7659
|
-
const classList = [...el.classList];
|
|
7660
|
-
const index2 = classList.indexOf("devui-validate-rules-error-pristine");
|
|
7661
|
-
index2 !== -1 && classList.splice(index2, 1);
|
|
7662
|
-
el.setAttribute("class", classList.join(" "));
|
|
7663
|
-
}
|
|
7664
|
-
function getFormControlUID(el) {
|
|
7665
|
-
if (el.tagName.toLocaleLowerCase() === "body")
|
|
7666
|
-
return "";
|
|
7667
|
-
if (el.parentElement.id.startsWith("dfc-")) {
|
|
7668
|
-
return el.parentElement.id;
|
|
7669
|
-
} else {
|
|
7670
|
-
getFormControlUID(el.parentElement);
|
|
7671
|
-
}
|
|
7672
|
-
}
|
|
7673
|
-
function handleValidateError({ el, tipEl, message = "", isFormTag, messageShowType, dfcUID, popPosition = "right-bottom", updateOn }) {
|
|
7674
|
-
if (isFormTag && messageShowType === "toast") {
|
|
7675
|
-
alert(message);
|
|
7676
|
-
return;
|
|
7677
|
-
}
|
|
7678
|
-
if (!dfcUID) {
|
|
7679
|
-
dfcUID = getFormControlUID(el);
|
|
7680
|
-
}
|
|
7681
|
-
if (messageShowType === "popover") {
|
|
7682
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: true, message, uid: dfcUID, popPosition, updateOn });
|
|
7683
|
-
return;
|
|
7684
|
-
}
|
|
7685
|
-
tipEl.innerText = "" + message;
|
|
7686
|
-
tipEl.style.display = "inline-flex";
|
|
7687
|
-
tipEl.setAttribute("class", "devui-validate-tip");
|
|
7688
|
-
handleErrorStrategy(el);
|
|
7689
|
-
}
|
|
7690
|
-
function handleValidatePass(el, tipEl) {
|
|
7691
|
-
tipEl.style.display = "none";
|
|
7692
|
-
handleErrorStrategyPass(el);
|
|
7693
|
-
}
|
|
7694
|
-
function getRefName(binding) {
|
|
7695
|
-
const _refs = binding.instance.$refs;
|
|
7696
|
-
const refName = Object.keys(_refs)[0];
|
|
7697
|
-
return refName;
|
|
7698
|
-
}
|
|
7699
|
-
function getFormName(binding) {
|
|
7700
|
-
const _refs = binding.instance.$refs;
|
|
7701
|
-
const key = Object.keys(_refs)[0];
|
|
7702
|
-
return _refs[key]["name"];
|
|
7703
|
-
}
|
|
7704
|
-
function validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, dfcUID, popPosition, updateOn }) {
|
|
7705
|
-
validator.validate({ modelName: modelValue }).then(() => {
|
|
7706
|
-
handleValidatePass(el, tipEl);
|
|
7707
|
-
}).catch((err) => {
|
|
7708
|
-
const { errors } = err;
|
|
7709
|
-
if (!errors || errors.length === 0)
|
|
7710
|
-
return;
|
|
7711
|
-
let msg = "";
|
|
7712
|
-
if (typeof errors[0].message === "object") {
|
|
7713
|
-
msg = errors[0].message.default;
|
|
7714
|
-
} else {
|
|
7715
|
-
msg = errors[0].message;
|
|
7716
|
-
}
|
|
7717
|
-
handleValidateError({ el, tipEl, message: msg, isFormTag, messageShowType, dfcUID, popPosition, updateOn });
|
|
7718
|
-
});
|
|
7719
|
-
}
|
|
7720
|
-
function checkValidPopsition(positionStr) {
|
|
7721
|
-
const validPosition = ["left", "right", "top", "bottom", "left-top", "left-bottom", "top-left", "top-right", "right-top", "right-bottom", "bottom-left", "bottom-right"];
|
|
7722
|
-
const isValid = validPosition.includes(positionStr);
|
|
7723
|
-
!isValid && console.warn(`invalid popPosition value '${positionStr}'.`);
|
|
7724
|
-
return isValid;
|
|
7725
|
-
}
|
|
7726
|
-
var dValidateRules = {
|
|
7727
|
-
mounted(el, binding, vnode) {
|
|
7728
|
-
var _a;
|
|
7729
|
-
const isFormTag = el.tagName === "FORM";
|
|
7730
|
-
const dfcUID = el.parentNode.parentNode.parentElement.dataset.uid;
|
|
7731
|
-
const refName = getRefName(binding);
|
|
7732
|
-
const hasOptions = isObject(binding.value) && hasKey(binding.value, "options");
|
|
7733
|
-
let {
|
|
7734
|
-
rules: bindingRules,
|
|
7735
|
-
options = {},
|
|
7736
|
-
messageShowType = "popover"
|
|
7737
|
-
} = binding.value;
|
|
7738
|
-
let { errorStrategy } = binding.value;
|
|
7739
|
-
if (refName) {
|
|
7740
|
-
messageShowType = (_a = binding.instance[refName]["messageShowType"]) != null ? _a : "popover";
|
|
7741
|
-
}
|
|
7742
|
-
let {
|
|
7743
|
-
updateOn = "change",
|
|
7744
|
-
errorStrategy: ErrorStrategy = "dirty",
|
|
7745
|
-
asyncDebounceTime = 300,
|
|
7746
|
-
popPosition = ["right", "bottom"]
|
|
7747
|
-
} = options;
|
|
7748
|
-
if (messageShowType === "popover") {
|
|
7749
|
-
if (Array.isArray(popPosition)) {
|
|
7750
|
-
popPosition = popPosition.length > 1 ? popPosition.join("-") : popPosition[0];
|
|
7751
|
-
if (!checkValidPopsition(popPosition)) {
|
|
7752
|
-
popPosition = "right-bottom";
|
|
7753
|
-
}
|
|
7754
|
-
} else if (!checkValidPopsition(popPosition)) {
|
|
7755
|
-
popPosition = "right-bottom";
|
|
7756
|
-
}
|
|
7757
|
-
}
|
|
7758
|
-
if (!errorStrategy) {
|
|
7759
|
-
errorStrategy = ErrorStrategy;
|
|
7760
|
-
}
|
|
7761
|
-
let customRule = {};
|
|
7762
|
-
if (hasOptions) {
|
|
7763
|
-
customRule = bindingRules != null ? bindingRules : binding.value;
|
|
7764
|
-
} else {
|
|
7765
|
-
customRule = binding.value;
|
|
7766
|
-
}
|
|
7767
|
-
const isCustomValidator = customRule && isObject(customRule) && (hasKey(customRule, "validators") || hasKey(customRule, "asyncValidators"));
|
|
7768
|
-
const rules2 = Array.isArray(customRule) ? customRule : [customRule];
|
|
7769
|
-
const tipEl = document.createElement("span");
|
|
7770
|
-
if (messageShowType !== "none") {
|
|
7771
|
-
el.parentNode.append(tipEl);
|
|
7772
|
-
}
|
|
7773
|
-
const descriptor = {
|
|
7774
|
-
modelName: []
|
|
7775
|
-
};
|
|
7776
|
-
rules2.forEach((rule) => {
|
|
7777
|
-
const kvObjList = !Array.isArray(rule) && getKeyValueOfObjectList(rule);
|
|
7778
|
-
let ruleObj = {};
|
|
7779
|
-
let avaliableRuleObj = {};
|
|
7780
|
-
kvObjList.forEach((item) => {
|
|
7781
|
-
avaliableRuleObj = getAvaliableRuleObj(item.key, item.value);
|
|
7782
|
-
ruleObj = __spreadValues(__spreadValues({}, ruleObj), avaliableRuleObj);
|
|
7783
|
-
});
|
|
7784
|
-
descriptor.modelName.push(ruleObj);
|
|
7785
|
-
});
|
|
7786
|
-
if (isCustomValidator) {
|
|
7787
|
-
const { validators: validators2, asyncValidators } = customRule;
|
|
7788
|
-
validators2 && validators2.forEach((item) => {
|
|
7789
|
-
const ruleObj = {
|
|
7790
|
-
message: (item == null ? void 0 : item.message) || "",
|
|
7791
|
-
validator: (rule, value) => item.validator(rule, value)
|
|
7792
|
-
};
|
|
7793
|
-
descriptor.modelName.push(ruleObj);
|
|
7794
|
-
});
|
|
7795
|
-
asyncValidators && asyncValidators.forEach((item) => {
|
|
7796
|
-
const ruleObj = {
|
|
7797
|
-
message: (item == null ? void 0 : item.message) || "",
|
|
7798
|
-
asyncValidator: (rule, value) => {
|
|
7799
|
-
return new Promise(lodash.exports.debounce((resolve, reject) => {
|
|
7800
|
-
const res = item.asyncValidator(rule, value);
|
|
7801
|
-
if (res) {
|
|
7802
|
-
resolve("");
|
|
7803
|
-
} else {
|
|
7804
|
-
reject(rule.message);
|
|
7805
|
-
}
|
|
7806
|
-
}, asyncDebounceTime));
|
|
7807
|
-
}
|
|
7808
|
-
};
|
|
7809
|
-
descriptor.modelName.push(ruleObj);
|
|
7810
|
-
});
|
|
7811
|
-
}
|
|
7812
|
-
const validator = new Schema(descriptor);
|
|
7813
|
-
const htmlEventValidateHandler = (e) => {
|
|
7814
|
-
const modelValue = e.target.value;
|
|
7815
|
-
if (messageShowType === "popover") {
|
|
7816
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: false, message: "", uid: dfcUID, popPosition, updateOn });
|
|
7817
|
-
}
|
|
7818
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition, updateOn });
|
|
7819
|
-
};
|
|
7820
|
-
vnode.children[0].el.addEventListener(updateOn, htmlEventValidateHandler);
|
|
7821
|
-
if (messageShowType === "popover" && updateOn === "change") {
|
|
7822
|
-
vnode.children[0].el.addEventListener("focus", () => {
|
|
7823
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: false, uid: dfcUID, updateOn });
|
|
7824
|
-
});
|
|
7825
|
-
}
|
|
7826
|
-
if (errorStrategy === "pristine") {
|
|
7827
|
-
handleErrorStrategy(el);
|
|
7828
|
-
vnode.children[0].props.value = "" + vnode.children[0].props.value;
|
|
7829
|
-
}
|
|
7830
|
-
const formName = getFormName(binding);
|
|
7831
|
-
formName && EventBus.on(`formSubmit:${formName}`, () => {
|
|
7832
|
-
const modelValue = isFormTag ? "" : vnode.children[0].el.value;
|
|
7833
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, updateOn: "submit" });
|
|
7834
|
-
});
|
|
7835
|
-
}
|
|
7836
|
-
};
|
|
7837
|
-
Form.install = function(app) {
|
|
7838
|
-
app.component(Form.name, Form);
|
|
7839
|
-
app.directive("d-validate-rules", dValidateRules);
|
|
7840
|
-
};
|
|
7841
|
-
FormLabel.install = function(app) {
|
|
7842
|
-
app.component(FormLabel.name, FormLabel);
|
|
7843
|
-
};
|
|
7844
|
-
FormItem.install = function(app) {
|
|
7845
|
-
app.component(FormItem.name, FormItem);
|
|
7846
|
-
};
|
|
7847
|
-
FormControl.install = function(app) {
|
|
7848
|
-
app.component(FormControl.name, FormControl);
|
|
7849
|
-
};
|
|
7850
|
-
FormOperation.install = function(app) {
|
|
7851
|
-
app.component(FormOperation.name, FormOperation);
|
|
7852
|
-
};
|
|
7853
7719
|
var index = {
|
|
7854
7720
|
title: "Form \u8868\u5355",
|
|
7855
7721
|
category: "\u6570\u636E\u5F55\u5165",
|
|
7856
7722
|
status: "75%",
|
|
7857
7723
|
install(app) {
|
|
7858
|
-
app.
|
|
7859
|
-
app.
|
|
7860
|
-
app.
|
|
7861
|
-
app.use(FormControl);
|
|
7862
|
-
app.use(FormOperation);
|
|
7724
|
+
app.component(Form.name, Form);
|
|
7725
|
+
app.component(FormItem.name, FormItem);
|
|
7726
|
+
app.component(FormOperation.name, FormOperation);
|
|
7863
7727
|
}
|
|
7864
7728
|
};
|
|
7865
|
-
export {
|
|
7729
|
+
export { FORM_ITEM_TOKEN, FORM_TOKEN, Form, FormItem, FormOperation, LABEL_DATA, index as default, formItemProps, formProps };
|