vue-devui 1.0.0-rc.5 → 1.0.0-rc.8
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 +22 -8
- package/alert/index.es.js +37 -11
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/auto-complete/index.es.js +72 -26
- package/auto-complete/index.umd.js +5 -5
- package/auto-complete/style.css +1 -1
- package/avatar/index.es.js +32 -6
- package/avatar/index.umd.js +1 -1
- package/avatar/style.css +1 -1
- package/badge/index.es.js +29 -4
- package/badge/index.umd.js +1 -1
- package/badge/style.css +1 -1
- package/button/index.es.js +5548 -76
- package/button/index.umd.js +27 -1
- package/button/style.css +1 -1
- package/card/index.es.js +56 -29
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +48 -30
- package/checkbox/index.umd.js +1 -1
- package/checkbox/style.css +1 -1
- package/date-picker/index.es.js +91 -145
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/drawer/index.es.js +28 -3
- package/drawer/index.umd.js +1 -1
- package/drawer/style.css +1 -1
- package/dropdown/index.es.js +39 -13
- package/dropdown/index.umd.js +1 -1
- package/dropdown/style.css +1 -1
- package/editable-select/index.es.js +14 -14
- package/editable-select/index.umd.js +1 -1
- package/editable-select/style.css +1 -1
- package/form/index.es.js +958 -1200
- package/form/index.umd.js +18 -18
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +29 -5
- package/fullscreen/index.umd.js +1 -1
- package/fullscreen/style.css +1 -1
- package/grid/index.es.js +68 -49
- package/grid/index.umd.js +1 -1
- package/grid/style.css +1 -1
- package/image-preview/index.es.js +34 -11
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/index.es.js +91 -145
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +27 -5
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/layout/index.es.js +34 -6
- package/layout/index.umd.js +1 -1
- package/layout/style.css +1 -1
- package/loading/index.es.js +34 -10
- package/loading/index.umd.js +1 -1
- package/loading/style.css +1 -1
- package/modal/index.es.js +41 -15
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/notification/index.es.js +40 -13
- package/notification/index.umd.js +1 -1
- package/notification/style.css +1 -1
- package/nuxt/components/ButtonGroup.js +3 -0
- package/nuxt/components/CheckboxGroup.js +3 -0
- package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
- package/nuxt/components/FORM_TOKEN.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/buttonGroupInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupProps.js +3 -0
- package/nuxt/components/formControlProps.js +3 -0
- package/nuxt/components/formItemProps.js +3 -0
- package/nuxt/components/formProps.js +3 -0
- package/nuxt/components/treeProps.js +3 -0
- package/overlay/index.es.js +31 -9
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +1 -1
- package/pagination/index.es.js +135 -124
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/popover/index.es.js +53 -24
- package/popover/index.umd.js +13 -13
- package/popover/style.css +1 -1
- package/progress/index.es.js +76 -20
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/radio/index.es.js +32 -7
- package/radio/index.umd.js +1 -1
- package/radio/style.css +1 -1
- package/rate/index.es.js +34 -10
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/search/index.es.js +103 -153
- package/search/index.umd.js +14 -14
- package/search/style.css +1 -1
- package/select/index.es.js +74 -51
- package/select/index.umd.js +1 -1
- package/select/style.css +1 -1
- package/skeleton/index.es.js +37 -12
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.es.js +52 -16
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.es.js +52 -24
- package/splitter/index.umd.js +15 -15
- package/splitter/style.css +1 -1
- package/status/index.es.js +26 -2
- package/status/index.umd.js +1 -1
- package/status/style.css +1 -1
- package/style.css +1 -1
- package/switch/index.es.js +30 -6
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.es.js +6267 -536
- package/table/index.umd.js +27 -1
- package/table/style.css +1 -1
- package/tabs/index.es.js +32 -8
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.es.js +27 -2
- package/tag/index.umd.js +1 -1
- package/tag/style.css +1 -1
- package/textarea/index.es.js +93 -76
- package/textarea/index.umd.js +1 -1
- package/textarea/style.css +1 -1
- package/tooltip/index.es.js +42 -15
- package/tooltip/index.umd.js +12 -12
- package/tooltip/style.css +1 -1
- package/{comment → tree}/index.d.ts +0 -0
- package/tree/index.es.js +1030 -0
- package/tree/index.umd.js +1 -0
- package/{comment → tree}/package.json +1 -1
- package/tree/style.css +1 -0
- package/upload/index.es.js +53 -22
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +5296 -4916
- package/vue-devui.umd.js +22 -22
- package/comment/index.es.js +0 -84
- package/comment/index.umd.js +0 -1
- package/comment/style.css +0 -1
- package/nuxt/components/Comment.js +0 -3
- package/nuxt/components/ReadTip.js +0 -3
- package/nuxt/components/commentProps.js +0 -3
- package/nuxt/components/readTipProps.js +0 -3
- package/read-tip/index.d.ts +0 -7
- package/read-tip/index.es.js +0 -261
- package/read-tip/index.umd.js +0 -1
- package/read-tip/package.json +0 -7
- package/read-tip/style.css +0 -1
package/form/index.es.js
CHANGED
|
@@ -17,572 +17,91 @@ 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
|
-
}, emit: function(t, e) {
|
|
30
|
-
var i = n.get(t);
|
|
31
|
-
i && i.slice().map(function(n2) {
|
|
32
|
-
n2(e);
|
|
33
|
-
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
34
|
-
n2(t, e);
|
|
35
|
-
});
|
|
36
|
-
} };
|
|
37
|
-
}
|
|
38
|
-
const formProps = {
|
|
39
|
-
formData: {
|
|
40
|
-
type: Object,
|
|
41
|
-
default: {}
|
|
42
|
-
},
|
|
43
|
-
layout: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: "horizontal"
|
|
46
|
-
},
|
|
47
|
-
labelSize: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: ""
|
|
50
|
-
},
|
|
51
|
-
labelAlign: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: "start"
|
|
54
|
-
},
|
|
55
|
-
rules: {
|
|
56
|
-
type: Object,
|
|
57
|
-
default: {}
|
|
58
|
-
},
|
|
59
|
-
columnsClass: {
|
|
60
|
-
type: String,
|
|
61
|
-
default: ""
|
|
62
|
-
},
|
|
63
|
-
name: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: ""
|
|
66
|
-
},
|
|
67
|
-
messageShowType: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: "popover"
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const formItemProps = {
|
|
73
|
-
dHasFeedback: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: false
|
|
76
|
-
},
|
|
77
|
-
prop: {
|
|
78
|
-
type: String,
|
|
79
|
-
default: ""
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const formLabelProps = {
|
|
83
|
-
required: {
|
|
84
|
-
type: Boolean,
|
|
85
|
-
default: false
|
|
86
|
-
},
|
|
87
|
-
hasHelp: {
|
|
88
|
-
type: Boolean,
|
|
89
|
-
default: false
|
|
90
|
-
},
|
|
91
|
-
helpTips: {
|
|
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: ""
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const dFormEvents = {
|
|
107
|
-
addField: "d.form.addField",
|
|
108
|
-
removeField: "d.form.removeField"
|
|
109
|
-
};
|
|
110
|
-
const formInjectionKey = Symbol("dForm");
|
|
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
|
-
}
|
|
126
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
127
|
-
}
|
|
128
|
-
function getElOffset(curEl) {
|
|
129
|
-
let totalLeft = 0;
|
|
130
|
-
let totalTop = 0;
|
|
131
|
-
let par = curEl.offsetParent;
|
|
132
|
-
totalLeft += curEl.offsetLeft;
|
|
133
|
-
totalTop += curEl.offsetTop;
|
|
134
|
-
while (par) {
|
|
135
|
-
if (navigator.userAgent.indexOf("MSIE 8.0") === -1) {
|
|
136
|
-
totalTop += par.clientTop;
|
|
137
|
-
totalLeft += par.clientLeft;
|
|
138
|
-
}
|
|
139
|
-
totalTop += par.offsetTop;
|
|
140
|
-
totalLeft += par.offsetLeft;
|
|
141
|
-
par = par.offsetParent;
|
|
142
|
-
}
|
|
143
|
-
return { left: totalLeft, top: totalTop };
|
|
144
|
-
}
|
|
145
|
-
var form = "";
|
|
146
|
-
var Form = defineComponent({
|
|
147
|
-
name: "DForm",
|
|
148
|
-
props: formProps,
|
|
149
|
-
emits: ["submit"],
|
|
150
|
-
setup(props, ctx2) {
|
|
151
|
-
const formMitt = mitt();
|
|
152
|
-
const fields = [];
|
|
153
|
-
const resetFormFields = () => {
|
|
154
|
-
fields.forEach((field) => {
|
|
155
|
-
field.resetField();
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
formMitt.on(dFormEvents.addField, (field) => {
|
|
159
|
-
if (field) {
|
|
160
|
-
fields.push(field);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
formMitt.on(dFormEvents.removeField, (field) => {
|
|
164
|
-
if (field.prop) {
|
|
165
|
-
fields.splice(fields.indexOf(field), 1);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
provide(formInjectionKey, {
|
|
169
|
-
formData: props.formData,
|
|
170
|
-
formMitt,
|
|
171
|
-
labelData: {
|
|
172
|
-
layout: props.layout,
|
|
173
|
-
labelSize: props.labelSize,
|
|
174
|
-
labelAlign: props.labelAlign
|
|
175
|
-
},
|
|
176
|
-
rules: props.rules,
|
|
177
|
-
columnsClass: props.columnsClass,
|
|
178
|
-
messageShowType: "popover"
|
|
179
|
-
});
|
|
180
|
-
const onSubmit = (e) => {
|
|
181
|
-
e.preventDefault();
|
|
182
|
-
ctx2.emit("submit", e);
|
|
183
|
-
EventBus.emit(`formSubmit:${props.name}`);
|
|
184
|
-
};
|
|
185
|
-
return {
|
|
186
|
-
fields,
|
|
187
|
-
formMitt,
|
|
188
|
-
onSubmit,
|
|
189
|
-
resetFormFields
|
|
190
|
-
};
|
|
191
|
-
},
|
|
192
|
-
render() {
|
|
193
|
-
var _a, _b;
|
|
194
|
-
const {
|
|
195
|
-
onSubmit
|
|
196
|
-
} = this;
|
|
197
|
-
return createVNode("form", {
|
|
198
|
-
"onSubmit": onSubmit,
|
|
199
|
-
"class": "devui-form"
|
|
200
|
-
}, [(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)]);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
const iconProps = {
|
|
204
|
-
name: {
|
|
205
|
-
type: String,
|
|
206
|
-
default: "",
|
|
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
|
-
var Icon = defineComponent({
|
|
223
|
-
name: "DIcon",
|
|
224
|
-
props: iconProps,
|
|
225
|
-
setup(props) {
|
|
226
|
-
const {
|
|
227
|
-
name,
|
|
228
|
-
size,
|
|
229
|
-
color,
|
|
230
|
-
classPrefix
|
|
231
|
-
} = toRefs(props);
|
|
232
|
-
return () => {
|
|
233
|
-
return /^((https?):)?\/\//.test(name.value) ? createVNode("img", {
|
|
234
|
-
"src": name.value,
|
|
235
|
-
"alt": name.value.split("/")[name.value.split("/").length - 1],
|
|
236
|
-
"style": {
|
|
237
|
-
width: size.value,
|
|
238
|
-
verticalAlign: "text-bottom"
|
|
239
|
-
}
|
|
240
|
-
}, null) : createVNode("i", {
|
|
241
|
-
"class": `${classPrefix.value} ${classPrefix.value}-${name.value}`,
|
|
242
|
-
"style": {
|
|
243
|
-
fontSize: size.value,
|
|
244
|
-
color: color.value
|
|
245
|
-
}
|
|
246
|
-
}, null);
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
var baseOverlay = "";
|
|
251
|
-
function _isSlot(s) {
|
|
252
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
253
|
-
}
|
|
254
|
-
const CommonOverlay = defineComponent({
|
|
255
|
-
setup(props, ctx2) {
|
|
256
|
-
return () => {
|
|
257
|
-
let _slot;
|
|
258
|
-
return createVNode(Teleport, {
|
|
259
|
-
"to": "#d-overlay-anchor"
|
|
260
|
-
}, {
|
|
261
|
-
default: () => [createVNode(Transition, {
|
|
262
|
-
"name": "devui-overlay-fade"
|
|
263
|
-
}, _isSlot(_slot = renderSlot(ctx2.slots, "default")) ? _slot : {
|
|
264
|
-
default: () => [_slot]
|
|
265
|
-
})]
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
const overlayProps = {
|
|
271
|
-
visible: {
|
|
272
|
-
type: Boolean
|
|
273
|
-
},
|
|
274
|
-
backgroundBlock: {
|
|
275
|
-
type: Boolean,
|
|
276
|
-
default: false
|
|
277
|
-
},
|
|
278
|
-
backgroundClass: {
|
|
279
|
-
type: String,
|
|
280
|
-
default: ""
|
|
281
|
-
},
|
|
282
|
-
backgroundStyle: {
|
|
283
|
-
type: [String, Object]
|
|
284
|
-
},
|
|
285
|
-
onBackdropClick: {
|
|
286
|
-
type: Function
|
|
287
|
-
},
|
|
288
|
-
backdropClose: {
|
|
289
|
-
type: Boolean,
|
|
290
|
-
default: true
|
|
291
|
-
},
|
|
292
|
-
hasBackdrop: {
|
|
293
|
-
type: Boolean,
|
|
294
|
-
default: true
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
298
|
-
overlayStyle: {
|
|
299
|
-
type: [String, Object],
|
|
300
|
-
default: void 0
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
const overlayEmits = ["update:visible", "backdropClick"];
|
|
304
|
-
function useOverlayLogic(props, ctx2) {
|
|
305
|
-
const backgroundClass = computed(() => {
|
|
306
|
-
return [
|
|
307
|
-
"devui-overlay-background",
|
|
308
|
-
props.backgroundClass,
|
|
309
|
-
!props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
|
|
310
|
-
];
|
|
311
|
-
});
|
|
312
|
-
const overlayClass = computed(() => {
|
|
313
|
-
return "devui-overlay";
|
|
314
|
-
});
|
|
315
|
-
const handleBackdropClick = (event) => {
|
|
316
|
-
var _a;
|
|
317
|
-
event.preventDefault();
|
|
318
|
-
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
319
|
-
if (props.backdropClose) {
|
|
320
|
-
ctx2.emit("update:visible", false);
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
324
|
-
onMounted(() => {
|
|
325
|
-
const body = document.body;
|
|
326
|
-
const originOverflow = body.style.overflow;
|
|
327
|
-
const originPosition = body.style.position;
|
|
328
|
-
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
329
|
-
if (backgroundBlock) {
|
|
330
|
-
const top = body.getBoundingClientRect().y;
|
|
331
|
-
if (visible) {
|
|
332
|
-
body.style.overflowY = "scroll";
|
|
333
|
-
body.style.position = visible ? "fixed" : "";
|
|
334
|
-
body.style.top = `${top}px`;
|
|
335
|
-
} else {
|
|
336
|
-
body.style.overflowY = originOverflow;
|
|
337
|
-
body.style.position = originPosition;
|
|
338
|
-
body.style.top = "";
|
|
339
|
-
window.scrollTo(0, -top);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
onUnmounted(() => {
|
|
344
|
-
document.body.style.overflow = originOverflow;
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
return {
|
|
348
|
-
backgroundClass,
|
|
349
|
-
overlayClass,
|
|
350
|
-
handleBackdropClick,
|
|
351
|
-
handleOverlayBubbleCancel
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
var fixedOverlay = "";
|
|
355
|
-
defineComponent({
|
|
356
|
-
name: "DFixedOverlay",
|
|
357
|
-
props: fixedOverlayProps,
|
|
358
|
-
emits: overlayEmits,
|
|
359
|
-
setup(props, ctx2) {
|
|
360
|
-
const {
|
|
361
|
-
backgroundClass,
|
|
362
|
-
overlayClass,
|
|
363
|
-
handleBackdropClick,
|
|
364
|
-
handleOverlayBubbleCancel
|
|
365
|
-
} = useOverlayLogic(props, ctx2);
|
|
366
|
-
return () => createVNode(CommonOverlay, null, {
|
|
367
|
-
default: () => [props.visible && createVNode("div", {
|
|
368
|
-
"class": backgroundClass.value,
|
|
369
|
-
"style": props.backgroundStyle,
|
|
370
|
-
"onClick": handleBackdropClick
|
|
371
|
-
}, [createVNode("div", {
|
|
372
|
-
"class": overlayClass.value,
|
|
373
|
-
"style": props.overlayStyle,
|
|
374
|
-
"onClick": handleOverlayBubbleCancel
|
|
375
|
-
}, [renderSlot(ctx2.slots, "default")])])]
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
const flexibleOverlayProps = {
|
|
380
|
-
modelValue: {
|
|
381
|
-
type: Boolean,
|
|
382
|
-
default: false
|
|
383
|
-
},
|
|
384
|
-
origin: {
|
|
385
|
-
type: Object,
|
|
386
|
-
require: true
|
|
387
|
-
},
|
|
388
|
-
position: {
|
|
389
|
-
type: Array,
|
|
390
|
-
default: ["bottom"]
|
|
391
|
-
},
|
|
392
|
-
offset: {
|
|
393
|
-
type: [Number, Object],
|
|
394
|
-
default: 8
|
|
395
|
-
},
|
|
396
|
-
shiftOffset: {
|
|
397
|
-
type: Number
|
|
398
|
-
},
|
|
399
|
-
align: {
|
|
400
|
-
type: String,
|
|
401
|
-
default: null
|
|
402
|
-
},
|
|
403
|
-
showArrow: {
|
|
404
|
-
type: Boolean,
|
|
405
|
-
default: false
|
|
406
|
-
},
|
|
407
|
-
isArrowCenter: {
|
|
408
|
-
type: Boolean,
|
|
409
|
-
default: true
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
function getScrollParent(element) {
|
|
413
|
-
const overflowRegex = /(auto|scroll|hidden)/;
|
|
414
|
-
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
415
|
-
const style2 = window.getComputedStyle(parent);
|
|
416
|
-
if (overflowRegex.test(style2.overflow + style2.overflowX + style2.overflowY)) {
|
|
417
|
-
return parent;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return window;
|
|
421
|
-
}
|
|
422
|
-
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
423
|
-
let { x, y } = point;
|
|
424
|
-
if (!isArrowCenter) {
|
|
425
|
-
const { width, height } = originRect;
|
|
426
|
-
if (x && placement.includes("start")) {
|
|
427
|
-
x = 12;
|
|
428
|
-
}
|
|
429
|
-
if (x && placement.includes("end")) {
|
|
430
|
-
x = Math.round(width - 24);
|
|
431
|
-
}
|
|
432
|
-
if (y && placement.includes("start")) {
|
|
433
|
-
y = 10;
|
|
434
|
-
}
|
|
435
|
-
if (y && placement.includes("end")) {
|
|
436
|
-
y = height - 14;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
return { x, y };
|
|
440
|
-
}
|
|
441
|
-
function useOverlay(props, emit) {
|
|
442
|
-
const overlayRef = ref();
|
|
443
|
-
const arrowRef = ref();
|
|
444
|
-
let originParent = null;
|
|
445
|
-
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
446
|
-
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
447
|
-
const staticSide = {
|
|
448
|
-
top: "bottom",
|
|
449
|
-
right: "left",
|
|
450
|
-
bottom: "top",
|
|
451
|
-
left: "right"
|
|
452
|
-
}[placement.split("-")[0]];
|
|
453
|
-
Object.assign(arrowEl.style, {
|
|
454
|
-
left: x ? `${x}px` : "",
|
|
455
|
-
top: y ? `${y}px` : "",
|
|
456
|
-
right: "",
|
|
457
|
-
bottom: "",
|
|
458
|
-
[staticSide]: "-4px"
|
|
459
|
-
});
|
|
460
|
-
};
|
|
461
|
-
const updatePosition = async () => {
|
|
462
|
-
const hostEl = props.origin;
|
|
463
|
-
const overlayEl = unref(overlayRef.value);
|
|
464
|
-
const arrowEl = unref(arrowRef.value);
|
|
465
|
-
const middleware = [
|
|
466
|
-
offset(props.offset),
|
|
467
|
-
autoPlacement({
|
|
468
|
-
alignment: props.align,
|
|
469
|
-
allowedPlacements: props.position
|
|
470
|
-
})
|
|
471
|
-
];
|
|
472
|
-
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
473
|
-
props.shiftOffset !== void 0 && middleware.push(shift());
|
|
474
|
-
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
475
|
-
strategy: "fixed",
|
|
476
|
-
middleware
|
|
477
|
-
});
|
|
478
|
-
let applyX = x;
|
|
479
|
-
let applyY = y;
|
|
480
|
-
if (props.shiftOffset !== void 0) {
|
|
481
|
-
const { x: shiftX, y: shiftY } = middlewareData.shift;
|
|
482
|
-
shiftX < 0 && (applyX -= props.shiftOffset);
|
|
483
|
-
shiftX > 0 && (applyX += props.shiftOffset);
|
|
484
|
-
shiftY < 0 && (applyY -= props.shiftOffset);
|
|
485
|
-
shiftY > 0 && (applyY += props.shiftOffset);
|
|
486
|
-
}
|
|
487
|
-
emit("positionChange", placement);
|
|
488
|
-
Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
|
|
489
|
-
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
490
|
-
};
|
|
491
|
-
watch(() => props.modelValue, () => {
|
|
492
|
-
if (props.modelValue && props.origin) {
|
|
493
|
-
originParent = getScrollParent(props.origin);
|
|
494
|
-
nextTick(updatePosition);
|
|
495
|
-
originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
|
|
496
|
-
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
497
|
-
window.addEventListener("resize", updatePosition);
|
|
498
|
-
} else {
|
|
499
|
-
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
500
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
501
|
-
window.removeEventListener("resize", updatePosition);
|
|
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];
|
|
502
29
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
var flexibleOverlay = "";
|
|
512
|
-
const FlexibleOverlay = defineComponent({
|
|
513
|
-
name: "DFlexibleOverlay",
|
|
514
|
-
inheritAttrs: false,
|
|
515
|
-
props: flexibleOverlayProps,
|
|
516
|
-
emits: ["update:modelValue", "positionChange"],
|
|
517
|
-
setup(props, {
|
|
518
|
-
slots,
|
|
519
|
-
attrs,
|
|
520
|
-
emit,
|
|
521
|
-
expose
|
|
522
|
-
}) {
|
|
523
|
-
const {
|
|
524
|
-
arrowRef,
|
|
525
|
-
overlayRef,
|
|
526
|
-
updatePosition
|
|
527
|
-
} = useOverlay(props, emit);
|
|
528
|
-
expose({
|
|
529
|
-
updatePosition
|
|
530
|
-
});
|
|
531
|
-
return () => {
|
|
532
|
-
var _a;
|
|
533
|
-
return props.modelValue && createVNode("div", mergeProps({
|
|
534
|
-
"ref": overlayRef,
|
|
535
|
-
"class": "devui-flexible-overlay"
|
|
536
|
-
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
537
|
-
"ref": arrowRef,
|
|
538
|
-
"class": "devui-flexible-overlay-arrow"
|
|
539
|
-
}, null)]);
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
const inBrowser = typeof window !== "undefined";
|
|
544
|
-
const popoverProps = {
|
|
545
|
-
isOpen: {
|
|
546
|
-
type: Boolean,
|
|
547
|
-
default: false
|
|
548
|
-
},
|
|
549
|
-
position: {
|
|
550
|
-
type: Array,
|
|
551
|
-
default: ["bottom"]
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { defineComponent, watch, provide, reactive, toRefs, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, onUnmounted, ref, unref, nextTick, mergeProps, Fragment, inject, onBeforeUnmount } from "vue";
|
|
33
|
+
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
34
|
+
const formProps = {
|
|
35
|
+
data: {
|
|
36
|
+
type: Object,
|
|
37
|
+
default: () => ({})
|
|
552
38
|
},
|
|
553
|
-
|
|
39
|
+
layout: {
|
|
554
40
|
type: String,
|
|
555
|
-
default:
|
|
556
|
-
},
|
|
557
|
-
offset: {
|
|
558
|
-
type: [Number, Object],
|
|
559
|
-
default: 8
|
|
41
|
+
default: "horizontal"
|
|
560
42
|
},
|
|
561
|
-
|
|
43
|
+
labelSize: {
|
|
562
44
|
type: String,
|
|
563
|
-
default: ""
|
|
45
|
+
default: "md"
|
|
564
46
|
},
|
|
565
|
-
|
|
47
|
+
labelAlign: {
|
|
566
48
|
type: String,
|
|
567
|
-
default: "
|
|
49
|
+
default: "start"
|
|
568
50
|
},
|
|
569
|
-
|
|
51
|
+
rules: {
|
|
52
|
+
type: Object
|
|
53
|
+
},
|
|
54
|
+
messageType: {
|
|
570
55
|
type: String,
|
|
571
|
-
default: "
|
|
56
|
+
default: "popover"
|
|
572
57
|
},
|
|
573
|
-
|
|
574
|
-
type:
|
|
575
|
-
default:
|
|
58
|
+
popPosition: {
|
|
59
|
+
type: Array,
|
|
60
|
+
default: ["right", "bottom"]
|
|
576
61
|
},
|
|
577
|
-
|
|
578
|
-
type:
|
|
579
|
-
default:
|
|
62
|
+
validateOnRuleChange: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false
|
|
580
65
|
},
|
|
581
|
-
|
|
582
|
-
type:
|
|
583
|
-
default:
|
|
66
|
+
showFeedback: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: false
|
|
584
69
|
}
|
|
585
70
|
};
|
|
71
|
+
const FORM_TOKEN = Symbol("dForm");
|
|
72
|
+
function createBem(namespace, element, modifier) {
|
|
73
|
+
let cls = namespace;
|
|
74
|
+
if (element) {
|
|
75
|
+
cls += `__${element}`;
|
|
76
|
+
}
|
|
77
|
+
if (modifier) {
|
|
78
|
+
cls += `--${modifier}`;
|
|
79
|
+
}
|
|
80
|
+
return cls;
|
|
81
|
+
}
|
|
82
|
+
function useNamespace(block) {
|
|
83
|
+
const namespace = `devui-${block}`;
|
|
84
|
+
const b = () => createBem(namespace);
|
|
85
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
86
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
87
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
88
|
+
return {
|
|
89
|
+
b,
|
|
90
|
+
e,
|
|
91
|
+
m,
|
|
92
|
+
em
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function useFieldCollection() {
|
|
96
|
+
const itemContexts = [];
|
|
97
|
+
const addItemContext = (field) => {
|
|
98
|
+
itemContexts.push(field);
|
|
99
|
+
};
|
|
100
|
+
const removeItemContext = (field) => {
|
|
101
|
+
itemContexts.splice(itemContexts.indexOf(field), 1);
|
|
102
|
+
};
|
|
103
|
+
return { itemContexts, addItemContext, removeItemContext };
|
|
104
|
+
}
|
|
586
105
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
587
106
|
var lodash = { exports: {} };
|
|
588
107
|
/**
|
|
@@ -1325,7 +844,7 @@ var lodash = { exports: {} };
|
|
|
1325
844
|
function object4() {
|
|
1326
845
|
}
|
|
1327
846
|
return function(proto) {
|
|
1328
|
-
if (!
|
|
847
|
+
if (!isObject(proto)) {
|
|
1329
848
|
return {};
|
|
1330
849
|
}
|
|
1331
850
|
if (objectCreate) {
|
|
@@ -1687,7 +1206,7 @@ var lodash = { exports: {} };
|
|
|
1687
1206
|
if (result2 !== undefined$1) {
|
|
1688
1207
|
return result2;
|
|
1689
1208
|
}
|
|
1690
|
-
if (!
|
|
1209
|
+
if (!isObject(value)) {
|
|
1691
1210
|
return value;
|
|
1692
1211
|
}
|
|
1693
1212
|
var isArr = isArray(value);
|
|
@@ -2034,7 +1553,7 @@ var lodash = { exports: {} };
|
|
|
2034
1553
|
return true;
|
|
2035
1554
|
}
|
|
2036
1555
|
function baseIsNative(value) {
|
|
2037
|
-
if (!
|
|
1556
|
+
if (!isObject(value) || isMasked(value)) {
|
|
2038
1557
|
return false;
|
|
2039
1558
|
}
|
|
2040
1559
|
var pattern4 = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
@@ -2074,7 +1593,7 @@ var lodash = { exports: {} };
|
|
|
2074
1593
|
return result2;
|
|
2075
1594
|
}
|
|
2076
1595
|
function baseKeysIn(object4) {
|
|
2077
|
-
if (!
|
|
1596
|
+
if (!isObject(object4)) {
|
|
2078
1597
|
return nativeKeysIn(object4);
|
|
2079
1598
|
}
|
|
2080
1599
|
var isProto = isPrototype(object4), result2 = [];
|
|
@@ -2119,7 +1638,7 @@ var lodash = { exports: {} };
|
|
|
2119
1638
|
}
|
|
2120
1639
|
baseFor(source, function(srcValue, key) {
|
|
2121
1640
|
stack || (stack = new Stack());
|
|
2122
|
-
if (
|
|
1641
|
+
if (isObject(srcValue)) {
|
|
2123
1642
|
baseMergeDeep(object4, source, key, srcIndex, baseMerge, customizer, stack);
|
|
2124
1643
|
} else {
|
|
2125
1644
|
var newValue = customizer ? customizer(safeGet(object4, key), srcValue, key + "", object4, source, stack) : undefined$1;
|
|
@@ -2159,7 +1678,7 @@ var lodash = { exports: {} };
|
|
|
2159
1678
|
newValue = objValue;
|
|
2160
1679
|
if (isArguments(objValue)) {
|
|
2161
1680
|
newValue = toPlainObject(objValue);
|
|
2162
|
-
} else if (!
|
|
1681
|
+
} else if (!isObject(objValue) || isFunction(objValue)) {
|
|
2163
1682
|
newValue = initCloneObject(srcValue);
|
|
2164
1683
|
}
|
|
2165
1684
|
} else {
|
|
@@ -2298,7 +1817,7 @@ var lodash = { exports: {} };
|
|
|
2298
1817
|
return shuffleSelf(array4, baseClamp(n, 0, array4.length));
|
|
2299
1818
|
}
|
|
2300
1819
|
function baseSet(object4, path, value, customizer) {
|
|
2301
|
-
if (!
|
|
1820
|
+
if (!isObject(object4)) {
|
|
2302
1821
|
return object4;
|
|
2303
1822
|
}
|
|
2304
1823
|
path = castPath(path, object4);
|
|
@@ -2312,7 +1831,7 @@ var lodash = { exports: {} };
|
|
|
2312
1831
|
var objValue = nested[key];
|
|
2313
1832
|
newValue = customizer ? customizer(objValue, key, nested) : undefined$1;
|
|
2314
1833
|
if (newValue === undefined$1) {
|
|
2315
|
-
newValue =
|
|
1834
|
+
newValue = isObject(objValue) ? objValue : isIndex(path[index2 + 1]) ? [] : {};
|
|
2316
1835
|
}
|
|
2317
1836
|
}
|
|
2318
1837
|
assignValue(nested, key, newValue);
|
|
@@ -2762,7 +2281,7 @@ var lodash = { exports: {} };
|
|
|
2762
2281
|
return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
2763
2282
|
}
|
|
2764
2283
|
var thisBinding = baseCreate(Ctor.prototype), result2 = Ctor.apply(thisBinding, args);
|
|
2765
|
-
return
|
|
2284
|
+
return isObject(result2) ? result2 : thisBinding;
|
|
2766
2285
|
};
|
|
2767
2286
|
}
|
|
2768
2287
|
function createCurry(func, bitmask, arity) {
|
|
@@ -3076,7 +2595,7 @@ var lodash = { exports: {} };
|
|
|
3076
2595
|
return objValue;
|
|
3077
2596
|
}
|
|
3078
2597
|
function customDefaultsMerge(objValue, srcValue, key, object4, source, stack) {
|
|
3079
|
-
if (
|
|
2598
|
+
if (isObject(objValue) && isObject(srcValue)) {
|
|
3080
2599
|
stack.set(srcValue, objValue);
|
|
3081
2600
|
baseMerge(objValue, srcValue, undefined$1, customDefaultsMerge, stack);
|
|
3082
2601
|
stack["delete"](srcValue);
|
|
@@ -3424,7 +2943,7 @@ var lodash = { exports: {} };
|
|
|
3424
2943
|
return !!length && (type4 == "number" || type4 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
3425
2944
|
}
|
|
3426
2945
|
function isIterateeCall(value, index2, object4) {
|
|
3427
|
-
if (!
|
|
2946
|
+
if (!isObject(object4)) {
|
|
3428
2947
|
return false;
|
|
3429
2948
|
}
|
|
3430
2949
|
var type4 = typeof index2;
|
|
@@ -3467,7 +2986,7 @@ var lodash = { exports: {} };
|
|
|
3467
2986
|
return value === proto;
|
|
3468
2987
|
}
|
|
3469
2988
|
function isStrictComparable(value) {
|
|
3470
|
-
return value === value && !
|
|
2989
|
+
return value === value && !isObject(value);
|
|
3471
2990
|
}
|
|
3472
2991
|
function matchesStrictComparable(key, srcValue) {
|
|
3473
2992
|
return function(object4) {
|
|
@@ -4349,7 +3868,7 @@ var lodash = { exports: {} };
|
|
|
4349
3868
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
4350
3869
|
}
|
|
4351
3870
|
wait = toNumber(wait) || 0;
|
|
4352
|
-
if (
|
|
3871
|
+
if (isObject(options)) {
|
|
4353
3872
|
leading = !!options.leading;
|
|
4354
3873
|
maxing = "maxWait" in options;
|
|
4355
3874
|
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
@@ -4519,7 +4038,7 @@ var lodash = { exports: {} };
|
|
|
4519
4038
|
if (typeof func != "function") {
|
|
4520
4039
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
4521
4040
|
}
|
|
4522
|
-
if (
|
|
4041
|
+
if (isObject(options)) {
|
|
4523
4042
|
leading = "leading" in options ? !!options.leading : leading;
|
|
4524
4043
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
4525
4044
|
}
|
|
@@ -4627,7 +4146,7 @@ var lodash = { exports: {} };
|
|
|
4627
4146
|
return typeof value == "number" && nativeIsFinite(value);
|
|
4628
4147
|
}
|
|
4629
4148
|
function isFunction(value) {
|
|
4630
|
-
if (!
|
|
4149
|
+
if (!isObject(value)) {
|
|
4631
4150
|
return false;
|
|
4632
4151
|
}
|
|
4633
4152
|
var tag = baseGetTag(value);
|
|
@@ -4639,7 +4158,7 @@ var lodash = { exports: {} };
|
|
|
4639
4158
|
function isLength(value) {
|
|
4640
4159
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
4641
4160
|
}
|
|
4642
|
-
function
|
|
4161
|
+
function isObject(value) {
|
|
4643
4162
|
var type4 = typeof value;
|
|
4644
4163
|
return value != null && (type4 == "object" || type4 == "function");
|
|
4645
4164
|
}
|
|
@@ -4746,9 +4265,9 @@ var lodash = { exports: {} };
|
|
|
4746
4265
|
if (isSymbol(value)) {
|
|
4747
4266
|
return NAN;
|
|
4748
4267
|
}
|
|
4749
|
-
if (
|
|
4268
|
+
if (isObject(value)) {
|
|
4750
4269
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
4751
|
-
value =
|
|
4270
|
+
value = isObject(other) ? other + "" : other;
|
|
4752
4271
|
}
|
|
4753
4272
|
if (typeof value != "string") {
|
|
4754
4273
|
return value === 0 ? value : +value;
|
|
@@ -4969,7 +4488,7 @@ var lodash = { exports: {} };
|
|
|
4969
4488
|
var Ctor = object4 && object4.constructor;
|
|
4970
4489
|
if (isArrLike) {
|
|
4971
4490
|
accumulator = isArr ? new Ctor() : [];
|
|
4972
|
-
} else if (
|
|
4491
|
+
} else if (isObject(object4)) {
|
|
4973
4492
|
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object4)) : {};
|
|
4974
4493
|
} else {
|
|
4975
4494
|
accumulator = {};
|
|
@@ -5251,7 +4770,7 @@ var lodash = { exports: {} };
|
|
|
5251
4770
|
}
|
|
5252
4771
|
function truncate(string3, options) {
|
|
5253
4772
|
var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
|
|
5254
|
-
if (
|
|
4773
|
+
if (isObject(options)) {
|
|
5255
4774
|
var separator = "separator" in options ? options.separator : separator;
|
|
5256
4775
|
length = "length" in options ? toInteger(options.length) : length;
|
|
5257
4776
|
omission = "omission" in options ? baseToString(options.omission) : omission;
|
|
@@ -5381,13 +4900,13 @@ var lodash = { exports: {} };
|
|
|
5381
4900
|
});
|
|
5382
4901
|
function mixin(object4, source, options) {
|
|
5383
4902
|
var props = keys(source), methodNames = baseFunctions(source, props);
|
|
5384
|
-
if (options == null && !(
|
|
4903
|
+
if (options == null && !(isObject(source) && (methodNames.length || !props.length))) {
|
|
5385
4904
|
options = source;
|
|
5386
4905
|
source = object4;
|
|
5387
4906
|
object4 = this;
|
|
5388
4907
|
methodNames = baseFunctions(source, keys(source));
|
|
5389
4908
|
}
|
|
5390
|
-
var chain2 = !(
|
|
4909
|
+
var chain2 = !(isObject(options) && "chain" in options) || !!options.chain, isFunc = isFunction(object4);
|
|
5391
4910
|
arrayEach(methodNames, function(methodName) {
|
|
5392
4911
|
var func = source[methodName];
|
|
5393
4912
|
object4[methodName] = func;
|
|
@@ -5733,7 +5252,7 @@ var lodash = { exports: {} };
|
|
|
5733
5252
|
lodash2.isNil = isNil;
|
|
5734
5253
|
lodash2.isNull = isNull;
|
|
5735
5254
|
lodash2.isNumber = isNumber;
|
|
5736
|
-
lodash2.isObject =
|
|
5255
|
+
lodash2.isObject = isObject;
|
|
5737
5256
|
lodash2.isObjectLike = isObjectLike;
|
|
5738
5257
|
lodash2.isPlainObject = isPlainObject;
|
|
5739
5258
|
lodash2.isRegExp = isRegExp;
|
|
@@ -5991,10 +5510,449 @@ var lodash = { exports: {} };
|
|
|
5991
5510
|
(freeModule.exports = _)._ = _;
|
|
5992
5511
|
freeExports._ = _;
|
|
5993
5512
|
} else {
|
|
5994
|
-
root._ = _;
|
|
5513
|
+
root._ = _;
|
|
5514
|
+
}
|
|
5515
|
+
}).call(commonjsGlobal);
|
|
5516
|
+
})(lodash, lodash.exports);
|
|
5517
|
+
function useFormValidation(itemContexts) {
|
|
5518
|
+
const getValidateFields = (fields) => {
|
|
5519
|
+
if (!itemContexts.length) {
|
|
5520
|
+
return [];
|
|
5521
|
+
}
|
|
5522
|
+
const normalizedFields = lodash.exports.castArray(fields);
|
|
5523
|
+
const filteredFields = normalizedFields.length ? itemContexts.filter((context) => context.field && normalizedFields.includes(context.field)) : itemContexts;
|
|
5524
|
+
if (!filteredFields.length) {
|
|
5525
|
+
return [];
|
|
5526
|
+
}
|
|
5527
|
+
return filteredFields;
|
|
5528
|
+
};
|
|
5529
|
+
const execValidateFields = async (fields = []) => {
|
|
5530
|
+
const validateFields2 = getValidateFields(fields);
|
|
5531
|
+
if (!validateFields2.length) {
|
|
5532
|
+
return true;
|
|
5533
|
+
}
|
|
5534
|
+
let errors = {};
|
|
5535
|
+
for (const field of validateFields2) {
|
|
5536
|
+
try {
|
|
5537
|
+
await field.validate("");
|
|
5538
|
+
} catch (err) {
|
|
5539
|
+
errors = __spreadValues(__spreadValues({}, errors), err);
|
|
5540
|
+
}
|
|
5541
|
+
}
|
|
5542
|
+
if (!Object.keys(errors).length) {
|
|
5543
|
+
return true;
|
|
5544
|
+
}
|
|
5545
|
+
return Promise.reject(errors);
|
|
5546
|
+
};
|
|
5547
|
+
const validateFields = async (fields = [], callback) => {
|
|
5548
|
+
try {
|
|
5549
|
+
const result = await execValidateFields(fields);
|
|
5550
|
+
if (result) {
|
|
5551
|
+
callback == null ? void 0 : callback(result);
|
|
5552
|
+
}
|
|
5553
|
+
return result;
|
|
5554
|
+
} catch (err) {
|
|
5555
|
+
const invalidFields = err;
|
|
5556
|
+
callback == null ? void 0 : callback(false, invalidFields);
|
|
5557
|
+
return !callback && Promise.reject(invalidFields);
|
|
5558
|
+
}
|
|
5559
|
+
};
|
|
5560
|
+
const validate = async (callback) => validateFields(void 0, callback);
|
|
5561
|
+
const clearValidate = (fields = []) => {
|
|
5562
|
+
getValidateFields(fields).forEach((field) => field.clearValidate());
|
|
5563
|
+
};
|
|
5564
|
+
const resetFields = (fields = []) => {
|
|
5565
|
+
getValidateFields(fields).forEach((field) => field.resetField());
|
|
5566
|
+
};
|
|
5567
|
+
return { validate, validateFields, resetFields, clearValidate };
|
|
5568
|
+
}
|
|
5569
|
+
var Form = defineComponent({
|
|
5570
|
+
name: "DForm",
|
|
5571
|
+
props: formProps,
|
|
5572
|
+
emits: ["validate"],
|
|
5573
|
+
setup(props, ctx) {
|
|
5574
|
+
const ns2 = useNamespace("form");
|
|
5575
|
+
const {
|
|
5576
|
+
itemContexts,
|
|
5577
|
+
addItemContext,
|
|
5578
|
+
removeItemContext
|
|
5579
|
+
} = useFieldCollection();
|
|
5580
|
+
const {
|
|
5581
|
+
validate,
|
|
5582
|
+
validateFields,
|
|
5583
|
+
resetFields,
|
|
5584
|
+
clearValidate
|
|
5585
|
+
} = useFormValidation(itemContexts);
|
|
5586
|
+
const onSubmit = (e) => {
|
|
5587
|
+
e.preventDefault();
|
|
5588
|
+
};
|
|
5589
|
+
watch(() => props.rules, () => {
|
|
5590
|
+
if (props.validateOnRuleChange) {
|
|
5591
|
+
validate();
|
|
5592
|
+
}
|
|
5593
|
+
}, {
|
|
5594
|
+
deep: true
|
|
5595
|
+
});
|
|
5596
|
+
provide(FORM_TOKEN, reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
|
|
5597
|
+
emit: ctx.emit,
|
|
5598
|
+
addItemContext,
|
|
5599
|
+
removeItemContext
|
|
5600
|
+
})));
|
|
5601
|
+
ctx.expose({
|
|
5602
|
+
validate,
|
|
5603
|
+
validateFields,
|
|
5604
|
+
resetFields,
|
|
5605
|
+
clearValidate
|
|
5606
|
+
});
|
|
5607
|
+
return () => {
|
|
5608
|
+
var _a, _b;
|
|
5609
|
+
return createVNode("form", {
|
|
5610
|
+
"onSubmit": onSubmit,
|
|
5611
|
+
"class": ns2.b()
|
|
5612
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
5613
|
+
};
|
|
5614
|
+
}
|
|
5615
|
+
});
|
|
5616
|
+
const formLabelProps = {
|
|
5617
|
+
helpTips: {
|
|
5618
|
+
type: String,
|
|
5619
|
+
default: ""
|
|
5620
|
+
}
|
|
5621
|
+
};
|
|
5622
|
+
var baseOverlay = "";
|
|
5623
|
+
function _isSlot(s) {
|
|
5624
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
5625
|
+
}
|
|
5626
|
+
const CommonOverlay = defineComponent({
|
|
5627
|
+
setup(props, ctx) {
|
|
5628
|
+
const ns2 = useNamespace("overlay");
|
|
5629
|
+
return () => {
|
|
5630
|
+
let _slot;
|
|
5631
|
+
return createVNode(Teleport, {
|
|
5632
|
+
"to": "#d-overlay-anchor"
|
|
5633
|
+
}, {
|
|
5634
|
+
default: () => [createVNode(Transition, {
|
|
5635
|
+
"name": ns2.e("fade")
|
|
5636
|
+
}, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
5637
|
+
default: () => [_slot]
|
|
5638
|
+
})]
|
|
5639
|
+
});
|
|
5640
|
+
};
|
|
5641
|
+
}
|
|
5642
|
+
});
|
|
5643
|
+
const overlayProps = {
|
|
5644
|
+
visible: {
|
|
5645
|
+
type: Boolean
|
|
5646
|
+
},
|
|
5647
|
+
backgroundBlock: {
|
|
5648
|
+
type: Boolean,
|
|
5649
|
+
default: false
|
|
5650
|
+
},
|
|
5651
|
+
backgroundClass: {
|
|
5652
|
+
type: String,
|
|
5653
|
+
default: ""
|
|
5654
|
+
},
|
|
5655
|
+
backgroundStyle: {
|
|
5656
|
+
type: [String, Object]
|
|
5657
|
+
},
|
|
5658
|
+
onBackdropClick: {
|
|
5659
|
+
type: Function
|
|
5660
|
+
},
|
|
5661
|
+
backdropClose: {
|
|
5662
|
+
type: Boolean,
|
|
5663
|
+
default: true
|
|
5664
|
+
},
|
|
5665
|
+
hasBackdrop: {
|
|
5666
|
+
type: Boolean,
|
|
5667
|
+
default: true
|
|
5668
|
+
}
|
|
5669
|
+
};
|
|
5670
|
+
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
5671
|
+
overlayStyle: {
|
|
5672
|
+
type: [String, Object],
|
|
5673
|
+
default: void 0
|
|
5674
|
+
}
|
|
5675
|
+
});
|
|
5676
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
5677
|
+
function useOverlayLogic(props, ctx) {
|
|
5678
|
+
const ns2 = useNamespace("overlay");
|
|
5679
|
+
const backgroundClass = computed(() => {
|
|
5680
|
+
return [ns2.e("background"), props.backgroundClass, !props.hasBackdrop ? ns2.em("background", "disabled") : ns2.em("background", "color")];
|
|
5681
|
+
});
|
|
5682
|
+
const overlayClass = computed(() => {
|
|
5683
|
+
return ns2.b();
|
|
5684
|
+
});
|
|
5685
|
+
const handleBackdropClick = (event) => {
|
|
5686
|
+
var _a;
|
|
5687
|
+
event.preventDefault();
|
|
5688
|
+
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
5689
|
+
if (props.backdropClose) {
|
|
5690
|
+
ctx.emit("update:visible", false);
|
|
5691
|
+
}
|
|
5692
|
+
};
|
|
5693
|
+
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
5694
|
+
onMounted(() => {
|
|
5695
|
+
const body = document.body;
|
|
5696
|
+
const originOverflow = body.style.overflow;
|
|
5697
|
+
const originPosition = body.style.position;
|
|
5698
|
+
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
5699
|
+
if (backgroundBlock) {
|
|
5700
|
+
const top = body.getBoundingClientRect().y;
|
|
5701
|
+
if (visible) {
|
|
5702
|
+
body.style.overflowY = "scroll";
|
|
5703
|
+
body.style.position = visible ? "fixed" : "";
|
|
5704
|
+
body.style.top = `${top}px`;
|
|
5705
|
+
} else {
|
|
5706
|
+
body.style.overflowY = originOverflow;
|
|
5707
|
+
body.style.position = originPosition;
|
|
5708
|
+
body.style.top = "";
|
|
5709
|
+
window.scrollTo(0, -top);
|
|
5710
|
+
}
|
|
5711
|
+
}
|
|
5712
|
+
});
|
|
5713
|
+
onUnmounted(() => {
|
|
5714
|
+
document.body.style.overflow = originOverflow;
|
|
5715
|
+
});
|
|
5716
|
+
});
|
|
5717
|
+
return {
|
|
5718
|
+
backgroundClass,
|
|
5719
|
+
overlayClass,
|
|
5720
|
+
handleBackdropClick,
|
|
5721
|
+
handleOverlayBubbleCancel
|
|
5722
|
+
};
|
|
5723
|
+
}
|
|
5724
|
+
var fixedOverlay = "";
|
|
5725
|
+
defineComponent({
|
|
5726
|
+
name: "DFixedOverlay",
|
|
5727
|
+
props: fixedOverlayProps,
|
|
5728
|
+
emits: overlayEmits,
|
|
5729
|
+
setup(props, ctx) {
|
|
5730
|
+
const {
|
|
5731
|
+
backgroundClass,
|
|
5732
|
+
overlayClass,
|
|
5733
|
+
handleBackdropClick,
|
|
5734
|
+
handleOverlayBubbleCancel
|
|
5735
|
+
} = useOverlayLogic(props, ctx);
|
|
5736
|
+
return () => createVNode(CommonOverlay, null, {
|
|
5737
|
+
default: () => [props.visible && createVNode("div", {
|
|
5738
|
+
"class": backgroundClass.value,
|
|
5739
|
+
"style": props.backgroundStyle,
|
|
5740
|
+
"onClick": handleBackdropClick
|
|
5741
|
+
}, [createVNode("div", {
|
|
5742
|
+
"class": overlayClass.value,
|
|
5743
|
+
"style": props.overlayStyle,
|
|
5744
|
+
"onClick": handleOverlayBubbleCancel
|
|
5745
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
5746
|
+
});
|
|
5747
|
+
}
|
|
5748
|
+
});
|
|
5749
|
+
const flexibleOverlayProps = {
|
|
5750
|
+
modelValue: {
|
|
5751
|
+
type: Boolean,
|
|
5752
|
+
default: false
|
|
5753
|
+
},
|
|
5754
|
+
origin: {
|
|
5755
|
+
type: Object,
|
|
5756
|
+
require: true
|
|
5757
|
+
},
|
|
5758
|
+
position: {
|
|
5759
|
+
type: Array,
|
|
5760
|
+
default: ["bottom"]
|
|
5761
|
+
},
|
|
5762
|
+
offset: {
|
|
5763
|
+
type: [Number, Object],
|
|
5764
|
+
default: 8
|
|
5765
|
+
},
|
|
5766
|
+
shiftOffset: {
|
|
5767
|
+
type: Number
|
|
5768
|
+
},
|
|
5769
|
+
align: {
|
|
5770
|
+
type: String,
|
|
5771
|
+
default: null
|
|
5772
|
+
},
|
|
5773
|
+
showArrow: {
|
|
5774
|
+
type: Boolean,
|
|
5775
|
+
default: false
|
|
5776
|
+
},
|
|
5777
|
+
isArrowCenter: {
|
|
5778
|
+
type: Boolean,
|
|
5779
|
+
default: true
|
|
5780
|
+
}
|
|
5781
|
+
};
|
|
5782
|
+
function getScrollParent(element) {
|
|
5783
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
5784
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
5785
|
+
const style = window.getComputedStyle(parent);
|
|
5786
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
5787
|
+
return parent;
|
|
5788
|
+
}
|
|
5789
|
+
}
|
|
5790
|
+
return window;
|
|
5791
|
+
}
|
|
5792
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
5793
|
+
let { x, y } = point;
|
|
5794
|
+
if (!isArrowCenter) {
|
|
5795
|
+
const { width, height } = originRect;
|
|
5796
|
+
if (x && placement.includes("start")) {
|
|
5797
|
+
x = 12;
|
|
5798
|
+
}
|
|
5799
|
+
if (x && placement.includes("end")) {
|
|
5800
|
+
x = Math.round(width - 24);
|
|
5801
|
+
}
|
|
5802
|
+
if (y && placement.includes("start")) {
|
|
5803
|
+
y = 10;
|
|
5804
|
+
}
|
|
5805
|
+
if (y && placement.includes("end")) {
|
|
5806
|
+
y = height - 14;
|
|
5807
|
+
}
|
|
5808
|
+
}
|
|
5809
|
+
return { x, y };
|
|
5810
|
+
}
|
|
5811
|
+
function useOverlay(props, emit) {
|
|
5812
|
+
const overlayRef = ref();
|
|
5813
|
+
const arrowRef = ref();
|
|
5814
|
+
let originParent = null;
|
|
5815
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
5816
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
5817
|
+
const staticSide = {
|
|
5818
|
+
top: "bottom",
|
|
5819
|
+
right: "left",
|
|
5820
|
+
bottom: "top",
|
|
5821
|
+
left: "right"
|
|
5822
|
+
}[placement.split("-")[0]];
|
|
5823
|
+
Object.assign(arrowEl.style, {
|
|
5824
|
+
left: x ? `${x}px` : "",
|
|
5825
|
+
top: y ? `${y}px` : "",
|
|
5826
|
+
right: "",
|
|
5827
|
+
bottom: "",
|
|
5828
|
+
[staticSide]: "-4px"
|
|
5829
|
+
});
|
|
5830
|
+
};
|
|
5831
|
+
const updatePosition = async () => {
|
|
5832
|
+
const hostEl = props.origin;
|
|
5833
|
+
const overlayEl = unref(overlayRef.value);
|
|
5834
|
+
const arrowEl = unref(arrowRef.value);
|
|
5835
|
+
const middleware = [
|
|
5836
|
+
offset(props.offset),
|
|
5837
|
+
autoPlacement({
|
|
5838
|
+
alignment: props.align,
|
|
5839
|
+
allowedPlacements: props.position
|
|
5840
|
+
})
|
|
5841
|
+
];
|
|
5842
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
5843
|
+
props.shiftOffset !== void 0 && middleware.push(shift());
|
|
5844
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
5845
|
+
strategy: "fixed",
|
|
5846
|
+
middleware
|
|
5847
|
+
});
|
|
5848
|
+
let applyX = x;
|
|
5849
|
+
let applyY = y;
|
|
5850
|
+
if (props.shiftOffset !== void 0) {
|
|
5851
|
+
const { x: shiftX, y: shiftY } = middlewareData.shift;
|
|
5852
|
+
shiftX < 0 && (applyX -= props.shiftOffset);
|
|
5853
|
+
shiftX > 0 && (applyX += props.shiftOffset);
|
|
5854
|
+
shiftY < 0 && (applyY -= props.shiftOffset);
|
|
5855
|
+
shiftY > 0 && (applyY += props.shiftOffset);
|
|
5856
|
+
}
|
|
5857
|
+
emit("positionChange", placement);
|
|
5858
|
+
Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
|
|
5859
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
5860
|
+
};
|
|
5861
|
+
watch(() => props.modelValue, () => {
|
|
5862
|
+
if (props.modelValue && props.origin) {
|
|
5863
|
+
originParent = getScrollParent(props.origin);
|
|
5864
|
+
nextTick(updatePosition);
|
|
5865
|
+
originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
|
|
5866
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
5867
|
+
window.addEventListener("resize", updatePosition);
|
|
5868
|
+
} else {
|
|
5869
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
5870
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
5871
|
+
window.removeEventListener("resize", updatePosition);
|
|
5995
5872
|
}
|
|
5996
|
-
})
|
|
5997
|
-
|
|
5873
|
+
});
|
|
5874
|
+
onUnmounted(() => {
|
|
5875
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
5876
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
5877
|
+
window.removeEventListener("resize", updatePosition);
|
|
5878
|
+
});
|
|
5879
|
+
return { arrowRef, overlayRef, updatePosition };
|
|
5880
|
+
}
|
|
5881
|
+
var flexibleOverlay = "";
|
|
5882
|
+
const FlexibleOverlay = defineComponent({
|
|
5883
|
+
name: "DFlexibleOverlay",
|
|
5884
|
+
inheritAttrs: false,
|
|
5885
|
+
props: flexibleOverlayProps,
|
|
5886
|
+
emits: ["update:modelValue", "positionChange"],
|
|
5887
|
+
setup(props, {
|
|
5888
|
+
slots,
|
|
5889
|
+
attrs,
|
|
5890
|
+
emit,
|
|
5891
|
+
expose
|
|
5892
|
+
}) {
|
|
5893
|
+
const ns2 = useNamespace("flexible-overlay");
|
|
5894
|
+
const {
|
|
5895
|
+
arrowRef,
|
|
5896
|
+
overlayRef,
|
|
5897
|
+
updatePosition
|
|
5898
|
+
} = useOverlay(props, emit);
|
|
5899
|
+
expose({
|
|
5900
|
+
updatePosition
|
|
5901
|
+
});
|
|
5902
|
+
return () => {
|
|
5903
|
+
var _a;
|
|
5904
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
5905
|
+
"ref": overlayRef,
|
|
5906
|
+
"class": ns2.b()
|
|
5907
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
5908
|
+
"ref": arrowRef,
|
|
5909
|
+
"class": ns2.e("arrow")
|
|
5910
|
+
}, null)]);
|
|
5911
|
+
};
|
|
5912
|
+
}
|
|
5913
|
+
});
|
|
5914
|
+
const popoverProps = {
|
|
5915
|
+
isOpen: {
|
|
5916
|
+
type: Boolean,
|
|
5917
|
+
default: false
|
|
5918
|
+
},
|
|
5919
|
+
position: {
|
|
5920
|
+
type: Array,
|
|
5921
|
+
default: ["bottom"]
|
|
5922
|
+
},
|
|
5923
|
+
align: {
|
|
5924
|
+
type: String,
|
|
5925
|
+
default: null
|
|
5926
|
+
},
|
|
5927
|
+
offset: {
|
|
5928
|
+
type: [Number, Object],
|
|
5929
|
+
default: 8
|
|
5930
|
+
},
|
|
5931
|
+
content: {
|
|
5932
|
+
type: String,
|
|
5933
|
+
default: ""
|
|
5934
|
+
},
|
|
5935
|
+
trigger: {
|
|
5936
|
+
type: String,
|
|
5937
|
+
default: "click"
|
|
5938
|
+
},
|
|
5939
|
+
popType: {
|
|
5940
|
+
type: String,
|
|
5941
|
+
default: "default"
|
|
5942
|
+
},
|
|
5943
|
+
showAnimation: {
|
|
5944
|
+
type: Boolean,
|
|
5945
|
+
default: true
|
|
5946
|
+
},
|
|
5947
|
+
mouseEnterDelay: {
|
|
5948
|
+
type: Number,
|
|
5949
|
+
default: 150
|
|
5950
|
+
},
|
|
5951
|
+
mouseLeaveDelay: {
|
|
5952
|
+
type: Number,
|
|
5953
|
+
default: 100
|
|
5954
|
+
}
|
|
5955
|
+
};
|
|
5998
5956
|
const TransformOriginMap = {
|
|
5999
5957
|
top: "50% calc(100% + 8px)",
|
|
6000
5958
|
bottom: "50% -8px",
|
|
@@ -6063,11 +6021,12 @@ function usePopoverEvent(props, visible, origin) {
|
|
|
6063
6021
|
origin.value.addEventListener("mouseleave", onMouseleave);
|
|
6064
6022
|
}
|
|
6065
6023
|
});
|
|
6066
|
-
return { placement, handlePositionChange };
|
|
6024
|
+
return { placement, handlePositionChange, onMouseenter, onMouseleave };
|
|
6067
6025
|
}
|
|
6068
|
-
|
|
6026
|
+
const ns = useNamespace("popover");
|
|
6027
|
+
function SuccessIcon$1() {
|
|
6069
6028
|
return createVNode("svg", {
|
|
6070
|
-
"class": "
|
|
6029
|
+
"class": [ns.e("icon"), ns.em("icon", "success")],
|
|
6071
6030
|
"viewBox": "0 0 16 16",
|
|
6072
6031
|
"version": "1.1",
|
|
6073
6032
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6091,7 +6050,7 @@ function SuccessIcon() {
|
|
|
6091
6050
|
}
|
|
6092
6051
|
function WarningIcon() {
|
|
6093
6052
|
return createVNode("svg", {
|
|
6094
|
-
"class": "
|
|
6053
|
+
"class": [ns.e("icon"), ns.em("icon", "warning")],
|
|
6095
6054
|
"viewBox": "0 0 16 16",
|
|
6096
6055
|
"version": "1.1",
|
|
6097
6056
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6101,14 +6060,14 @@ function WarningIcon() {
|
|
|
6101
6060
|
"fill": "none",
|
|
6102
6061
|
"fill-rule": "evenodd"
|
|
6103
6062
|
}, [createVNode("polygon", {
|
|
6104
|
-
"points": "7.5 1.74501946 1.39184847 13.5954649 7.08947368
|
|
6063
|
+
"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"
|
|
6105
6064
|
}, null), createVNode("path", {
|
|
6106
|
-
"d": "M8.51325441,0.127397589 C8.70423071,0.228333932
|
|
6065
|
+
"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"
|
|
6107
6066
|
}, null)])]);
|
|
6108
6067
|
}
|
|
6109
6068
|
function InfoIcon() {
|
|
6110
6069
|
return createVNode("svg", {
|
|
6111
|
-
"class": "
|
|
6070
|
+
"class": [ns.e("icon"), ns.em("icon", "info")],
|
|
6112
6071
|
"viewBox": "0 0 16 16",
|
|
6113
6072
|
"version": "1.1",
|
|
6114
6073
|
"xmlns": "http://www.w3.org/2000/svg"
|
|
@@ -6124,12 +6083,12 @@ function InfoIcon() {
|
|
|
6124
6083
|
}, null), createVNode("g", {
|
|
6125
6084
|
"stroke-width": "1"
|
|
6126
6085
|
}, [createVNode("path", {
|
|
6127
|
-
"d": "M8,0 C3.6,0 0,3.6 0,8 C0,12.4 3.6,16 8,16
|
|
6086
|
+
"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"
|
|
6128
6087
|
}, null)])])]);
|
|
6129
6088
|
}
|
|
6130
|
-
function ErrorIcon() {
|
|
6089
|
+
function ErrorIcon$1() {
|
|
6131
6090
|
return createVNode("svg", {
|
|
6132
|
-
"class": "
|
|
6091
|
+
"class": [ns.e("icon"), ns.em("icon", "error")],
|
|
6133
6092
|
"width": "16px",
|
|
6134
6093
|
"height": "16px",
|
|
6135
6094
|
"viewBox": "0 0 16 16",
|
|
@@ -6145,7 +6104,7 @@ function ErrorIcon() {
|
|
|
6145
6104
|
"cy": "8",
|
|
6146
6105
|
"r": "7"
|
|
6147
6106
|
}, null), createVNode("path", {
|
|
6148
|
-
"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
|
|
6107
|
+
"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",
|
|
6149
6108
|
"fill-rule": "nonzero"
|
|
6150
6109
|
}, null)])]);
|
|
6151
6110
|
}
|
|
@@ -6158,9 +6117,10 @@ var PopoverIcon = defineComponent({
|
|
|
6158
6117
|
}
|
|
6159
6118
|
},
|
|
6160
6119
|
setup(props) {
|
|
6120
|
+
const ns2 = useNamespace("popover");
|
|
6161
6121
|
return () => props.type && props.type !== "default" && createVNode("span", {
|
|
6162
|
-
"class": "
|
|
6163
|
-
}, [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)]);
|
|
6122
|
+
"class": ns2.e("icon-wrap")
|
|
6123
|
+
}, [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)]);
|
|
6164
6124
|
}
|
|
6165
6125
|
});
|
|
6166
6126
|
var popover = "";
|
|
@@ -6185,21 +6145,24 @@ var Popover = defineComponent({
|
|
|
6185
6145
|
const visible = ref(false);
|
|
6186
6146
|
const {
|
|
6187
6147
|
placement,
|
|
6188
|
-
handlePositionChange
|
|
6148
|
+
handlePositionChange,
|
|
6149
|
+
onMouseenter,
|
|
6150
|
+
onMouseleave
|
|
6189
6151
|
} = usePopoverEvent(props, visible, origin);
|
|
6190
6152
|
const {
|
|
6191
6153
|
overlayStyles
|
|
6192
6154
|
} = usePopover(props, visible, placement, origin, popoverRef);
|
|
6155
|
+
const ns2 = useNamespace("popover");
|
|
6193
6156
|
return () => {
|
|
6194
6157
|
var _a;
|
|
6195
6158
|
return createVNode(Fragment, null, [createVNode("div", {
|
|
6196
6159
|
"ref": origin,
|
|
6197
|
-
"class": "
|
|
6160
|
+
"class": ns2.e("reference")
|
|
6198
6161
|
}, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), createVNode(Teleport, {
|
|
6199
6162
|
"to": "body"
|
|
6200
6163
|
}, {
|
|
6201
6164
|
default: () => [createVNode(Transition, {
|
|
6202
|
-
"name": showAnimation.value ? `
|
|
6165
|
+
"name": showAnimation.value ? ns2.m(`fade-${placement.value}`) : ""
|
|
6203
6166
|
}, {
|
|
6204
6167
|
default: () => [createVNode(FlexibleOverlay, mergeProps({
|
|
6205
6168
|
"modelValue": visible.value,
|
|
@@ -6209,12 +6172,14 @@ var Popover = defineComponent({
|
|
|
6209
6172
|
"position": position.value,
|
|
6210
6173
|
"align": align.value,
|
|
6211
6174
|
"offset": offset2.value,
|
|
6212
|
-
"class": ["
|
|
6175
|
+
"class": [ns2.e("content"), popType.value !== "default" ? "is-icon" : ""],
|
|
6213
6176
|
"show-arrow": true,
|
|
6214
6177
|
"is-arrow-center": false,
|
|
6215
6178
|
"style": overlayStyles.value
|
|
6216
6179
|
}, attrs, {
|
|
6217
|
-
"onPositionChange": handlePositionChange
|
|
6180
|
+
"onPositionChange": handlePositionChange,
|
|
6181
|
+
"onMouseenter": onMouseenter,
|
|
6182
|
+
"onMouseleave": onMouseleave
|
|
6218
6183
|
}), {
|
|
6219
6184
|
default: () => {
|
|
6220
6185
|
var _a2;
|
|
@@ -6227,44 +6192,144 @@ var Popover = defineComponent({
|
|
|
6227
6192
|
})]);
|
|
6228
6193
|
};
|
|
6229
6194
|
}
|
|
6230
|
-
});
|
|
6195
|
+
});
|
|
6196
|
+
function HelpTipsIcon() {
|
|
6197
|
+
return createVNode("svg", {
|
|
6198
|
+
"width": "16px",
|
|
6199
|
+
"height": "16px",
|
|
6200
|
+
"viewBox": "0 0 16 16"
|
|
6201
|
+
}, [createVNode("g", {
|
|
6202
|
+
"stroke": "none",
|
|
6203
|
+
"stroke-width": "1",
|
|
6204
|
+
"fill": "none",
|
|
6205
|
+
"fill-rule": "evenodd"
|
|
6206
|
+
}, [createVNode("g", null, [createVNode("path", {
|
|
6207
|
+
"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",
|
|
6208
|
+
"fill": "#293040",
|
|
6209
|
+
"fill-rule": "nonzero"
|
|
6210
|
+
}, null)])])]);
|
|
6211
|
+
}
|
|
6212
|
+
function ErrorIcon() {
|
|
6213
|
+
return createVNode("svg", {
|
|
6214
|
+
"width": "14px",
|
|
6215
|
+
"height": "14px",
|
|
6216
|
+
"viewBox": "0 0 16 16"
|
|
6217
|
+
}, [createVNode("g", {
|
|
6218
|
+
"stroke": "none",
|
|
6219
|
+
"stroke-width": "1",
|
|
6220
|
+
"fill": "none",
|
|
6221
|
+
"fill-rule": "evenodd"
|
|
6222
|
+
}, [createVNode("circle", {
|
|
6223
|
+
"cx": "8",
|
|
6224
|
+
"cy": "8",
|
|
6225
|
+
"r": "8"
|
|
6226
|
+
}, null), createVNode("polygon", {
|
|
6227
|
+
"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"
|
|
6228
|
+
}, null)])]);
|
|
6229
|
+
}
|
|
6230
|
+
function SuccessIcon() {
|
|
6231
|
+
return createVNode("svg", {
|
|
6232
|
+
"width": "14px",
|
|
6233
|
+
"height": "14px",
|
|
6234
|
+
"viewBox": "0 0 16 16"
|
|
6235
|
+
}, [createVNode("g", {
|
|
6236
|
+
"stroke": "none",
|
|
6237
|
+
"stroke-width": "1",
|
|
6238
|
+
"fill": "none",
|
|
6239
|
+
"fill-rule": "evenodd"
|
|
6240
|
+
}, [createVNode("circle", {
|
|
6241
|
+
"cx": "8",
|
|
6242
|
+
"cy": "8",
|
|
6243
|
+
"r": "8"
|
|
6244
|
+
}, null), createVNode("polygon", {
|
|
6245
|
+
"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"
|
|
6246
|
+
}, null)])]);
|
|
6247
|
+
}
|
|
6248
|
+
function PendingIcon() {
|
|
6249
|
+
return createVNode("svg", {
|
|
6250
|
+
"width": "14px",
|
|
6251
|
+
"height": "14px",
|
|
6252
|
+
"viewBox": "0 0 16 16"
|
|
6253
|
+
}, [createVNode("g", {
|
|
6254
|
+
"id": "loading",
|
|
6255
|
+
"stroke": "none",
|
|
6256
|
+
"stroke-width": "1",
|
|
6257
|
+
"fill": "none",
|
|
6258
|
+
"fill-rule": "evenodd"
|
|
6259
|
+
}, [createVNode("path", {
|
|
6260
|
+
"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",
|
|
6261
|
+
"fill-rule": "nonzero"
|
|
6262
|
+
}, null), createVNode("path", {
|
|
6263
|
+
"d": "M8,0 C12.4,0 16,3.6 16,8 L15,8 C15,4.15 11.85,1 8,1 L8,0 Z",
|
|
6264
|
+
"fill-rule": "nonzero"
|
|
6265
|
+
}, null)])]);
|
|
6266
|
+
}
|
|
6267
|
+
const formItemProps = {
|
|
6268
|
+
field: {
|
|
6269
|
+
type: String,
|
|
6270
|
+
default: ""
|
|
6271
|
+
},
|
|
6272
|
+
required: {
|
|
6273
|
+
type: Boolean,
|
|
6274
|
+
default: false
|
|
6275
|
+
},
|
|
6276
|
+
messageType: {
|
|
6277
|
+
type: String
|
|
6278
|
+
},
|
|
6279
|
+
popPosition: {
|
|
6280
|
+
type: Array
|
|
6281
|
+
},
|
|
6282
|
+
rules: {
|
|
6283
|
+
type: [Object, Array]
|
|
6284
|
+
},
|
|
6285
|
+
showFeedback: {
|
|
6286
|
+
type: Boolean,
|
|
6287
|
+
default: void 0
|
|
6288
|
+
}
|
|
6289
|
+
};
|
|
6290
|
+
const FORM_ITEM_TOKEN = Symbol("dFormItem");
|
|
6291
|
+
function useFormLabel() {
|
|
6292
|
+
const formContext = inject(FORM_TOKEN);
|
|
6293
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6294
|
+
const ns2 = useNamespace("form");
|
|
6295
|
+
const labelClasses = computed(() => ({
|
|
6296
|
+
[`${ns2.e("label")}`]: true,
|
|
6297
|
+
[`${ns2.em("label", "vertical")}`]: formContext.layout === "vertical",
|
|
6298
|
+
[`${ns2.em("label", formContext.labelSize)}`]: formContext.layout === "horizontal",
|
|
6299
|
+
[`${ns2.em("label", formContext.labelAlign)}`]: formContext.layout === "horizontal"
|
|
6300
|
+
}));
|
|
6301
|
+
const labelInnerClasses = computed(() => ({
|
|
6302
|
+
[`${ns2.e("label-span")}`]: true,
|
|
6303
|
+
[`${ns2.em("label", "required")}`]: formItemContext.isRequired
|
|
6304
|
+
}));
|
|
6305
|
+
return { labelClasses, labelInnerClasses };
|
|
6306
|
+
}
|
|
6231
6307
|
var formLabel = "";
|
|
6232
6308
|
var FormLabel = defineComponent({
|
|
6233
6309
|
name: "DFormLabel",
|
|
6234
6310
|
props: formLabelProps,
|
|
6235
|
-
setup(props,
|
|
6236
|
-
const
|
|
6237
|
-
const
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
const isCenter = computed(() => labelData.labelAlign === "center").value;
|
|
6242
|
-
const isEnd = computed(() => labelData.labelAlign === "end").value;
|
|
6243
|
-
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" : ""}`;
|
|
6244
|
-
const className = `${props.required ? " devui-required" : ""}`;
|
|
6245
|
-
const style2 = {
|
|
6246
|
-
display: isHorizontal ? "inline" : "inline-block"
|
|
6247
|
-
};
|
|
6311
|
+
setup(props, ctx) {
|
|
6312
|
+
const ns2 = useNamespace("form");
|
|
6313
|
+
const {
|
|
6314
|
+
labelClasses,
|
|
6315
|
+
labelInnerClasses
|
|
6316
|
+
} = useFormLabel();
|
|
6248
6317
|
return () => {
|
|
6249
6318
|
var _a, _b;
|
|
6250
6319
|
return createVNode("span", {
|
|
6251
|
-
"class":
|
|
6252
|
-
"style": style2
|
|
6320
|
+
"class": labelClasses.value
|
|
6253
6321
|
}, [createVNode("span", {
|
|
6254
|
-
"class":
|
|
6255
|
-
}, [(_b = (_a =
|
|
6322
|
+
"class": labelInnerClasses.value
|
|
6323
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), props.helpTips && createVNode(Popover, {
|
|
6256
6324
|
"content": props.helpTips,
|
|
6257
|
-
"
|
|
6258
|
-
"
|
|
6259
|
-
"
|
|
6325
|
+
"position": ["top"],
|
|
6326
|
+
"trigger": "hover",
|
|
6327
|
+
"pop-type": "info"
|
|
6260
6328
|
}, {
|
|
6261
|
-
reference: () => createVNode(
|
|
6262
|
-
"class": "
|
|
6263
|
-
},
|
|
6264
|
-
|
|
6265
|
-
"color": "#252b3a"
|
|
6266
|
-
}, null)])
|
|
6267
|
-
})])]);
|
|
6329
|
+
reference: () => createVNode(HelpTipsIcon, {
|
|
6330
|
+
"class": ns2.e("label-help")
|
|
6331
|
+
}, null)
|
|
6332
|
+
})]);
|
|
6268
6333
|
};
|
|
6269
6334
|
}
|
|
6270
6335
|
});
|
|
@@ -7270,619 +7335,312 @@ Schema.register = function register(type4, validator) {
|
|
|
7270
7335
|
Schema.warning = warning;
|
|
7271
7336
|
Schema.messages = messages;
|
|
7272
7337
|
Schema.validators = validators;
|
|
7338
|
+
function useFormItem(messageType, _rules, validateState) {
|
|
7339
|
+
const formContext = inject(FORM_TOKEN);
|
|
7340
|
+
const ns2 = useNamespace("form");
|
|
7341
|
+
const itemClasses = computed(() => ({
|
|
7342
|
+
[`${ns2.em("item", "horizontal")}`]: formContext.layout === "horizontal",
|
|
7343
|
+
[`${ns2.em("item", "vertical")}`]: formContext.layout === "vertical",
|
|
7344
|
+
[`${ns2.em("item", "error")}`]: messageType.value === "text" && validateState.value === "error"
|
|
7345
|
+
}));
|
|
7346
|
+
const isRequired = computed(() => _rules.value.some((rule) => Boolean(rule.required)));
|
|
7347
|
+
return { itemClasses, isRequired };
|
|
7348
|
+
}
|
|
7349
|
+
function useFormItemRule(props) {
|
|
7350
|
+
const formContext = inject(FORM_TOKEN);
|
|
7351
|
+
const _rules = computed(() => {
|
|
7352
|
+
const rules2 = props.rules ? lodash.exports.castArray(props.rules) : [];
|
|
7353
|
+
const formRules = formContext.rules;
|
|
7354
|
+
if (formRules && props.field) {
|
|
7355
|
+
const _itemRules = lodash.exports.get(formRules, props.field, void 0);
|
|
7356
|
+
if (_itemRules) {
|
|
7357
|
+
rules2.push(...lodash.exports.castArray(_itemRules));
|
|
7358
|
+
}
|
|
7359
|
+
}
|
|
7360
|
+
if (props.required) {
|
|
7361
|
+
rules2.push({ required: Boolean(props.required) });
|
|
7362
|
+
}
|
|
7363
|
+
return rules2;
|
|
7364
|
+
});
|
|
7365
|
+
return { _rules };
|
|
7366
|
+
}
|
|
7367
|
+
function useFormItemValidate(props, _rules) {
|
|
7368
|
+
const formContext = inject(FORM_TOKEN);
|
|
7369
|
+
const validateState = ref("");
|
|
7370
|
+
const validateMessage = ref("");
|
|
7371
|
+
let initFieldValue = void 0;
|
|
7372
|
+
let isResetting = false;
|
|
7373
|
+
const computedField = computed(() => {
|
|
7374
|
+
return typeof props.field === "string" ? props.field : "";
|
|
7375
|
+
});
|
|
7376
|
+
const fieldValue = computed({
|
|
7377
|
+
get: () => {
|
|
7378
|
+
const formData = formContext.data;
|
|
7379
|
+
if (!formData || !props.field) {
|
|
7380
|
+
return;
|
|
7381
|
+
}
|
|
7382
|
+
return formData[props.field];
|
|
7383
|
+
},
|
|
7384
|
+
set: (val) => {
|
|
7385
|
+
formContext.data[props.field] = val;
|
|
7386
|
+
}
|
|
7387
|
+
});
|
|
7388
|
+
const getRuleByTrigger = (triggerVal) => {
|
|
7389
|
+
return _rules.value.filter((rule) => {
|
|
7390
|
+
if (!rule.trigger || !triggerVal) {
|
|
7391
|
+
return true;
|
|
7392
|
+
}
|
|
7393
|
+
if (Array.isArray(rule.trigger)) {
|
|
7394
|
+
return rule.trigger.includes(triggerVal);
|
|
7395
|
+
} else {
|
|
7396
|
+
return rule.trigger === triggerVal;
|
|
7397
|
+
}
|
|
7398
|
+
}).map((_a) => {
|
|
7399
|
+
var _b = _a, { trigger } = _b, rule = __objRest(_b, ["trigger"]);
|
|
7400
|
+
return rule;
|
|
7401
|
+
});
|
|
7402
|
+
};
|
|
7403
|
+
const onValidateSuccess = () => {
|
|
7404
|
+
validateState.value = "success";
|
|
7405
|
+
validateMessage.value = "";
|
|
7406
|
+
formContext.emit("validate", props.field, true, "");
|
|
7407
|
+
};
|
|
7408
|
+
const onValidateError = ({ errors }) => {
|
|
7409
|
+
var _a;
|
|
7410
|
+
validateState.value = "error";
|
|
7411
|
+
validateMessage.value = ((_a = errors == null ? void 0 : errors[0]) == null ? void 0 : _a.message) || "";
|
|
7412
|
+
formContext.emit("validate", props.field, false, validateMessage.value);
|
|
7413
|
+
};
|
|
7414
|
+
const execValidate = async (rules2) => {
|
|
7415
|
+
const ruleName = computedField.value;
|
|
7416
|
+
const validator = new Schema({
|
|
7417
|
+
[ruleName]: rules2
|
|
7418
|
+
});
|
|
7419
|
+
return validator.validate({ [ruleName]: fieldValue.value }, { firstFields: true }).then(() => {
|
|
7420
|
+
onValidateSuccess();
|
|
7421
|
+
return true;
|
|
7422
|
+
}).catch((error) => {
|
|
7423
|
+
onValidateError(error);
|
|
7424
|
+
return Promise.reject(error);
|
|
7425
|
+
});
|
|
7426
|
+
};
|
|
7427
|
+
const validate = async (trigger, callback) => {
|
|
7428
|
+
if (isResetting) {
|
|
7429
|
+
isResetting = false;
|
|
7430
|
+
return false;
|
|
7431
|
+
}
|
|
7432
|
+
const rules2 = getRuleByTrigger(trigger);
|
|
7433
|
+
if (!rules2.length) {
|
|
7434
|
+
callback == null ? void 0 : callback(true);
|
|
7435
|
+
return true;
|
|
7436
|
+
}
|
|
7437
|
+
validateState.value = "pending";
|
|
7438
|
+
return execValidate(rules2).then(() => {
|
|
7439
|
+
callback == null ? void 0 : callback(true);
|
|
7440
|
+
return true;
|
|
7441
|
+
}).catch((error) => {
|
|
7442
|
+
const { fields } = error;
|
|
7443
|
+
callback == null ? void 0 : callback(false, fields);
|
|
7444
|
+
return lodash.exports.isFunction(callback) ? false : Promise.reject(fields);
|
|
7445
|
+
});
|
|
7446
|
+
};
|
|
7447
|
+
const clearValidate = () => {
|
|
7448
|
+
validateState.value = "";
|
|
7449
|
+
validateMessage.value = "";
|
|
7450
|
+
};
|
|
7451
|
+
const resetField = async () => {
|
|
7452
|
+
if (!formContext.data || !props.field) {
|
|
7453
|
+
return;
|
|
7454
|
+
}
|
|
7455
|
+
isResetting = true;
|
|
7456
|
+
fieldValue.value = initFieldValue;
|
|
7457
|
+
await nextTick();
|
|
7458
|
+
clearValidate();
|
|
7459
|
+
};
|
|
7460
|
+
onMounted(() => {
|
|
7461
|
+
initFieldValue = lodash.exports.cloneDeep(formContext.data[props.field]);
|
|
7462
|
+
});
|
|
7463
|
+
return { validateState, validateMessage, validate, resetField, clearValidate };
|
|
7464
|
+
}
|
|
7273
7465
|
var formItem = "";
|
|
7274
7466
|
var FormItem = defineComponent({
|
|
7275
7467
|
name: "DFormItem",
|
|
7276
7468
|
props: formItemProps,
|
|
7277
|
-
setup(props,
|
|
7278
|
-
const
|
|
7279
|
-
const
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7469
|
+
setup(props, ctx) {
|
|
7470
|
+
const formContext = inject(FORM_TOKEN);
|
|
7471
|
+
const _a = toRefs(props), {
|
|
7472
|
+
messageType: itemMessageType,
|
|
7473
|
+
popPosition: itemPopPosition,
|
|
7474
|
+
showFeedback: itemShowFeedback
|
|
7475
|
+
} = _a, otherProps = __objRest(_a, [
|
|
7476
|
+
"messageType",
|
|
7477
|
+
"popPosition",
|
|
7478
|
+
"showFeedback"
|
|
7479
|
+
]);
|
|
7480
|
+
const showFeedback = computed(() => (itemShowFeedback == null ? void 0 : itemShowFeedback.value) !== void 0 ? itemShowFeedback.value : formContext.showFeedback);
|
|
7481
|
+
const messageType = computed(() => (itemMessageType == null ? void 0 : itemMessageType.value) || formContext.messageType);
|
|
7482
|
+
const popPosition = computed(() => (itemPopPosition == null ? void 0 : itemPopPosition.value) || formContext.popPosition);
|
|
7483
|
+
const {
|
|
7484
|
+
_rules
|
|
7485
|
+
} = useFormItemRule(props);
|
|
7486
|
+
const {
|
|
7487
|
+
validateState,
|
|
7488
|
+
validateMessage,
|
|
7489
|
+
validate,
|
|
7490
|
+
resetField,
|
|
7491
|
+
clearValidate
|
|
7492
|
+
} = useFormItemValidate(props, _rules);
|
|
7493
|
+
const {
|
|
7494
|
+
itemClasses,
|
|
7495
|
+
isRequired
|
|
7496
|
+
} = useFormItem(messageType, _rules, validateState);
|
|
7497
|
+
const context = reactive(__spreadProps(__spreadValues({}, otherProps), {
|
|
7498
|
+
showFeedback,
|
|
7499
|
+
messageType,
|
|
7500
|
+
popPosition,
|
|
7501
|
+
isRequired,
|
|
7502
|
+
validateState,
|
|
7503
|
+
validateMessage,
|
|
7504
|
+
validate,
|
|
7505
|
+
resetField,
|
|
7506
|
+
clearValidate
|
|
7507
|
+
}));
|
|
7508
|
+
provide(FORM_ITEM_TOKEN, context);
|
|
7509
|
+
ctx.expose({
|
|
7510
|
+
resetField,
|
|
7511
|
+
clearValidate
|
|
7297
7512
|
});
|
|
7298
|
-
provide(formItemInjectionKey, formItem2);
|
|
7299
|
-
const isHorizontal = labelData.layout === "horizontal";
|
|
7300
|
-
const isVertical = labelData.layout === "vertical";
|
|
7301
|
-
const isColumns = labelData.layout === "columns";
|
|
7302
|
-
const showMessage = ref(false);
|
|
7303
|
-
const tipMessage = ref("");
|
|
7304
|
-
const validate = (trigger) => {
|
|
7305
|
-
const ruleKey = props.prop;
|
|
7306
|
-
const ruleItem = rules2[ruleKey];
|
|
7307
|
-
const descriptor = {};
|
|
7308
|
-
descriptor[ruleKey] = ruleItem;
|
|
7309
|
-
const validator = new Schema(descriptor);
|
|
7310
|
-
validator.validate({
|
|
7311
|
-
[ruleKey]: formData[ruleKey]
|
|
7312
|
-
}).then(() => {
|
|
7313
|
-
showMessage.value = false;
|
|
7314
|
-
tipMessage.value = "";
|
|
7315
|
-
}).catch(({
|
|
7316
|
-
errors
|
|
7317
|
-
}) => {
|
|
7318
|
-
showMessage.value = true;
|
|
7319
|
-
tipMessage.value = errors[0].message;
|
|
7320
|
-
});
|
|
7321
|
-
};
|
|
7322
|
-
const validateEvents = [];
|
|
7323
|
-
const addValidateEvents = () => {
|
|
7324
|
-
if (rules2 && rules2[props.prop]) {
|
|
7325
|
-
const ruleItem = rules2[props.prop];
|
|
7326
|
-
let eventName = ruleItem["trigger"];
|
|
7327
|
-
if (Array.isArray(ruleItem)) {
|
|
7328
|
-
ruleItem.forEach((item) => {
|
|
7329
|
-
eventName = item["trigger"];
|
|
7330
|
-
const cb = () => validate();
|
|
7331
|
-
validateEvents.push({
|
|
7332
|
-
eventName: cb
|
|
7333
|
-
});
|
|
7334
|
-
formItem2.formItemMitt.on(dFormItemEvents[eventName], cb);
|
|
7335
|
-
});
|
|
7336
|
-
} else {
|
|
7337
|
-
const cb = () => validate();
|
|
7338
|
-
validateEvents.push({
|
|
7339
|
-
eventName: cb
|
|
7340
|
-
});
|
|
7341
|
-
ruleItem && formItem2.formItemMitt.on(dFormItemEvents[eventName], cb);
|
|
7342
|
-
}
|
|
7343
|
-
}
|
|
7344
|
-
};
|
|
7345
|
-
const removeValidateEvents = () => {
|
|
7346
|
-
if (rules2 && rules2[props.prop] && validateEvents.length > 0) {
|
|
7347
|
-
validateEvents.forEach((item) => {
|
|
7348
|
-
formItem2.formItemMitt.off(item.eventName, item.cb);
|
|
7349
|
-
});
|
|
7350
|
-
}
|
|
7351
|
-
};
|
|
7352
7513
|
onMounted(() => {
|
|
7353
|
-
|
|
7354
|
-
|
|
7514
|
+
if (props.field) {
|
|
7515
|
+
formContext == null ? void 0 : formContext.addItemContext(context);
|
|
7516
|
+
}
|
|
7355
7517
|
});
|
|
7356
7518
|
onBeforeUnmount(() => {
|
|
7357
|
-
|
|
7358
|
-
removeValidateEvents();
|
|
7519
|
+
formContext == null ? void 0 : formContext.removeItemContext(context);
|
|
7359
7520
|
});
|
|
7360
7521
|
return () => {
|
|
7361
|
-
var
|
|
7522
|
+
var _a2, _b;
|
|
7362
7523
|
return createVNode("div", {
|
|
7363
|
-
"class":
|
|
7364
|
-
}, [(_b = (
|
|
7365
|
-
"class": `devui-validate-tip${isHorizontal ? " devui-validate-tip-horizontal" : ""}`
|
|
7366
|
-
}, [showMessage.value && tipMessage.value])]);
|
|
7524
|
+
"class": itemClasses.value
|
|
7525
|
+
}, [(_b = (_a2 = ctx.slots).default) == null ? void 0 : _b.call(_a2)]);
|
|
7367
7526
|
};
|
|
7368
7527
|
}
|
|
7369
7528
|
});
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
element.addEventListener(eventName, handler, false);
|
|
7374
|
-
}
|
|
7375
|
-
} else {
|
|
7376
|
-
if (element && eventName && handler) {
|
|
7377
|
-
element.attachEvent("on" + eventName, handler);
|
|
7378
|
-
}
|
|
7379
|
-
}
|
|
7380
|
-
}
|
|
7381
|
-
const ctx = Symbol("@@clickoutside");
|
|
7382
|
-
const nodeList = /* @__PURE__ */ new Map();
|
|
7383
|
-
let startClick;
|
|
7384
|
-
let nid = 0;
|
|
7385
|
-
let isFirst = true;
|
|
7386
|
-
function createDocumentHandler(el, binding, vnode) {
|
|
7387
|
-
if (inBrowser && isFirst) {
|
|
7388
|
-
isFirst = false;
|
|
7389
|
-
on(document, "mousedown", (e) => {
|
|
7390
|
-
startClick = e;
|
|
7391
|
-
});
|
|
7392
|
-
on(document, "mouseup", (e) => {
|
|
7393
|
-
for (const [id, node] of nodeList) {
|
|
7394
|
-
node[ctx].documentHandler(e, startClick);
|
|
7395
|
-
}
|
|
7396
|
-
});
|
|
7397
|
-
}
|
|
7398
|
-
return function(mouseup, mousedown) {
|
|
7399
|
-
if (!vnode || !binding.instance || !mouseup.target || !mousedown.target || el.contains(mouseup.target) || el.contains(mousedown.target) || el === mouseup.target) {
|
|
7400
|
-
return;
|
|
7401
|
-
}
|
|
7402
|
-
el[ctx].bindingFn && el[ctx].bindingFn();
|
|
7403
|
-
};
|
|
7404
|
-
}
|
|
7405
|
-
const clickoutsideDirective = {
|
|
7406
|
-
beforeMount: function(el, binding, vnode) {
|
|
7407
|
-
nid++;
|
|
7408
|
-
nodeList.set(nid, el);
|
|
7409
|
-
el[ctx] = {
|
|
7410
|
-
nid,
|
|
7411
|
-
documentHandler: createDocumentHandler(el, binding, vnode),
|
|
7412
|
-
bindingFn: binding.value
|
|
7413
|
-
};
|
|
7414
|
-
},
|
|
7415
|
-
updated: function(el, binding, vnode) {
|
|
7416
|
-
el[ctx].documentHandler = createDocumentHandler(el, binding, vnode);
|
|
7417
|
-
el[ctx].bindingFn = binding.value;
|
|
7529
|
+
const formControlProps = {
|
|
7530
|
+
feedbackStatus: {
|
|
7531
|
+
type: String
|
|
7418
7532
|
},
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7533
|
+
extraInfo: {
|
|
7534
|
+
type: String,
|
|
7535
|
+
default: ""
|
|
7422
7536
|
}
|
|
7423
7537
|
};
|
|
7538
|
+
function useFormControl(props) {
|
|
7539
|
+
const formContext = inject(FORM_TOKEN);
|
|
7540
|
+
const ns2 = useNamespace("form");
|
|
7541
|
+
const { feedbackStatus } = toRefs(props);
|
|
7542
|
+
const controlClasses = computed(() => ({
|
|
7543
|
+
[ns2.e("control")]: true,
|
|
7544
|
+
[ns2.em("control", "horizontal")]: formContext.layout === "horizontal"
|
|
7545
|
+
}));
|
|
7546
|
+
const controlContainerClasses = computed(() => ({
|
|
7547
|
+
[ns2.e("control-container")]: true,
|
|
7548
|
+
[ns2.em("control-container", "horizontal")]: formContext.layout === "horizontal",
|
|
7549
|
+
[ns2.em("control-container", "has-feedback")]: Boolean(feedbackStatus == null ? void 0 : feedbackStatus.value),
|
|
7550
|
+
[ns2.em("control-container", "feedback-error")]: Boolean((feedbackStatus == null ? void 0 : feedbackStatus.value) === "error")
|
|
7551
|
+
}));
|
|
7552
|
+
return { controlClasses, controlContainerClasses };
|
|
7553
|
+
}
|
|
7554
|
+
function useFormControlValidate() {
|
|
7555
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
7556
|
+
const feedbackStatus = computed(() => formItemContext.validateState);
|
|
7557
|
+
const showFeedback = computed(() => formItemContext.showFeedback && Boolean(formItemContext.validateState));
|
|
7558
|
+
const showPopover = computed(() => formItemContext.messageType === "popover" && formItemContext.validateState === "error");
|
|
7559
|
+
const showMessage = computed(() => formItemContext.messageType === "text" && formItemContext.validateState === "error");
|
|
7560
|
+
const errorMessage = computed(() => formItemContext.validateMessage);
|
|
7561
|
+
const popPosition = computed(() => formItemContext.popPosition);
|
|
7562
|
+
return { feedbackStatus, showFeedback, showPopover, showMessage, errorMessage, popPosition };
|
|
7563
|
+
}
|
|
7424
7564
|
var formControl = "";
|
|
7425
7565
|
var FormControl = defineComponent({
|
|
7426
7566
|
name: "DFormControl",
|
|
7427
|
-
directives: {
|
|
7428
|
-
clickoutside: clickoutsideDirective
|
|
7429
|
-
},
|
|
7430
7567
|
props: formControlProps,
|
|
7431
|
-
setup(props,
|
|
7568
|
+
setup(props, ctx) {
|
|
7432
7569
|
const formControl2 = ref();
|
|
7433
|
-
const
|
|
7434
|
-
const
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
const
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
})
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
};
|
|
7474
|
-
case "success":
|
|
7475
|
-
return {
|
|
7476
|
-
name: "right-o",
|
|
7477
|
-
color: "rgb(61, 204, 166)"
|
|
7478
|
-
};
|
|
7479
|
-
case "error":
|
|
7480
|
-
return {
|
|
7481
|
-
name: "error-o",
|
|
7482
|
-
color: "rgb(249, 95, 91)"
|
|
7483
|
-
};
|
|
7484
|
-
default:
|
|
7485
|
-
return {
|
|
7486
|
-
name: "",
|
|
7487
|
-
color: ""
|
|
7488
|
-
};
|
|
7489
|
-
}
|
|
7490
|
-
});
|
|
7491
|
-
const handleClickOutside = () => {
|
|
7492
|
-
if (updateOn.value !== "change") {
|
|
7493
|
-
showPopover.value = false;
|
|
7494
|
-
}
|
|
7495
|
-
};
|
|
7496
|
-
return () => {
|
|
7497
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7498
|
-
const {
|
|
7499
|
-
feedbackStatus,
|
|
7500
|
-
extraInfo
|
|
7501
|
-
} = props;
|
|
7502
|
-
return withDirectives(createVNode("div", {
|
|
7503
|
-
"class": "devui-form-control",
|
|
7504
|
-
"ref": formControl2,
|
|
7505
|
-
"data-uid": uid
|
|
7506
|
-
}, [showPopover.value && createVNode(Teleport, {
|
|
7507
|
-
"to": "body"
|
|
7508
|
-
}, {
|
|
7509
|
-
default: () => [createVNode("div", {
|
|
7510
|
-
"style": {
|
|
7511
|
-
position: "absolute",
|
|
7512
|
-
left: popoverLeftPosition + "px",
|
|
7513
|
-
top: popoverTopPosition + "px",
|
|
7514
|
-
width: rectInfo.width + "px",
|
|
7515
|
-
height: rectInfo.height + "px"
|
|
7516
|
-
}
|
|
7517
|
-
}, [createVNode(Popover, {
|
|
7518
|
-
"controlled": updateOn.value !== "change",
|
|
7519
|
-
"visible": showPopover.value,
|
|
7520
|
-
"content": tipMessage.value,
|
|
7521
|
-
"popType": "error",
|
|
7522
|
-
"position": popPosition.value
|
|
7523
|
-
}, null)])]
|
|
7524
|
-
}), createVNode("div", {
|
|
7525
|
-
"class": `devui-form-control-container${isHorizontal ? " devui-form-control-container-horizontal" : ""}${feedbackStatus ? " devui-has-feedback" : ""}${feedbackStatus === "error" ? " devui-feedback-error" : ""}`
|
|
7526
|
-
}, [createVNode("div", {
|
|
7527
|
-
"class": "devui-control-content-wrapper",
|
|
7528
|
-
"id": uid
|
|
7529
|
-
}, [(_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", {
|
|
7530
|
-
"class": "devui-feedback-status"
|
|
7531
|
-
}, [((_f = (_e = ctx2.slots).suffixTemplate) == null ? void 0 : _f.call(_e)) ? (_h = (_g = ctx2.slots).suffixTemplate) == null ? void 0 : _h.call(_g) : createVNode(Icon, {
|
|
7532
|
-
"name": iconData.value.name,
|
|
7533
|
-
"color": iconData.value.color
|
|
7534
|
-
}, null)])]), extraInfo && createVNode("div", {
|
|
7535
|
-
"class": "devui-form-control-extra-info"
|
|
7536
|
-
}, [extraInfo])]), [[resolveDirective("clickoutside"), handleClickOutside]]);
|
|
7537
|
-
};
|
|
7570
|
+
const ns2 = useNamespace("form");
|
|
7571
|
+
const {
|
|
7572
|
+
controlClasses,
|
|
7573
|
+
controlContainerClasses
|
|
7574
|
+
} = useFormControl(props);
|
|
7575
|
+
const {
|
|
7576
|
+
feedbackStatus,
|
|
7577
|
+
showFeedback,
|
|
7578
|
+
showPopover,
|
|
7579
|
+
showMessage,
|
|
7580
|
+
errorMessage,
|
|
7581
|
+
popPosition
|
|
7582
|
+
} = useFormControlValidate();
|
|
7583
|
+
return () => createVNode("div", {
|
|
7584
|
+
"class": controlClasses.value,
|
|
7585
|
+
"ref": formControl2
|
|
7586
|
+
}, [createVNode("div", {
|
|
7587
|
+
"class": controlContainerClasses.value
|
|
7588
|
+
}, [createVNode(Popover, {
|
|
7589
|
+
"is-open": showPopover.value,
|
|
7590
|
+
"trigger": "manually",
|
|
7591
|
+
"content": errorMessage.value,
|
|
7592
|
+
"pop-type": "error",
|
|
7593
|
+
"position": popPosition.value
|
|
7594
|
+
}, {
|
|
7595
|
+
reference: () => {
|
|
7596
|
+
var _a, _b;
|
|
7597
|
+
return createVNode("div", {
|
|
7598
|
+
"class": ns2.e("control-content")
|
|
7599
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
7600
|
+
}
|
|
7601
|
+
}), showFeedback.value && createVNode("span", {
|
|
7602
|
+
"class": [ns2.e("feedback-icon"), ns2.em("feedback-icon", feedbackStatus.value)]
|
|
7603
|
+
}, [feedbackStatus.value === "error" && createVNode(ErrorIcon, null, null), feedbackStatus.value === "success" && createVNode(SuccessIcon, null, null), feedbackStatus.value === "pending" && createVNode(PendingIcon, null, null)])]), createVNode("div", {
|
|
7604
|
+
"class": ns2.e("control-info")
|
|
7605
|
+
}, [showMessage.value && createVNode("div", {
|
|
7606
|
+
"class": "error-message"
|
|
7607
|
+
}, [errorMessage.value]), props.extraInfo && createVNode("div", {
|
|
7608
|
+
"class": ns2.e("control-extra")
|
|
7609
|
+
}, [props.extraInfo])])]);
|
|
7538
7610
|
}
|
|
7539
7611
|
});
|
|
7540
7612
|
var formOperation = "";
|
|
7541
7613
|
var FormOperation = defineComponent({
|
|
7542
7614
|
name: "DFormOperation",
|
|
7543
|
-
props
|
|
7544
|
-
|
|
7615
|
+
setup(props, ctx) {
|
|
7616
|
+
const formContext = inject(FORM_TOKEN);
|
|
7617
|
+
const LabelSizeMap = {
|
|
7618
|
+
sm: 80,
|
|
7619
|
+
md: 100,
|
|
7620
|
+
lg: 150
|
|
7621
|
+
};
|
|
7622
|
+
const styles = computed(() => ({
|
|
7623
|
+
marginLeft: formContext.layout === "horizontal" ? `${LabelSizeMap[formContext.labelSize] + 16}px` : void 0
|
|
7624
|
+
}));
|
|
7545
7625
|
return () => {
|
|
7546
7626
|
var _a, _b;
|
|
7547
7627
|
return createVNode("div", {
|
|
7548
|
-
"class": "devui-form-operation"
|
|
7549
|
-
|
|
7628
|
+
"class": "devui-form-operation",
|
|
7629
|
+
"style": styles.value
|
|
7630
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
7550
7631
|
};
|
|
7551
7632
|
}
|
|
7552
7633
|
});
|
|
7553
|
-
var style = "";
|
|
7554
|
-
function getAvaliableRuleObj(ruleName, value) {
|
|
7555
|
-
if (!ruleName) {
|
|
7556
|
-
console.error("[v-d-validate] validator's key is invalid");
|
|
7557
|
-
return null;
|
|
7558
|
-
}
|
|
7559
|
-
switch (ruleName) {
|
|
7560
|
-
case "maxlength":
|
|
7561
|
-
return {
|
|
7562
|
-
type: "string",
|
|
7563
|
-
max: value,
|
|
7564
|
-
asyncValidator: (rule, val) => {
|
|
7565
|
-
return new Promise((resolve, reject) => {
|
|
7566
|
-
if (val.length > value) {
|
|
7567
|
-
reject("\u6700\u5927\u957F\u5EA6\u4E3A" + value);
|
|
7568
|
-
} else {
|
|
7569
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7570
|
-
}
|
|
7571
|
-
});
|
|
7572
|
-
}
|
|
7573
|
-
};
|
|
7574
|
-
case "minlength":
|
|
7575
|
-
return {
|
|
7576
|
-
type: "string",
|
|
7577
|
-
min: value,
|
|
7578
|
-
asyncValidator: (rule, val) => {
|
|
7579
|
-
return new Promise((resolve, reject) => {
|
|
7580
|
-
if (val.length < value) {
|
|
7581
|
-
reject("\u6700\u5C0F\u957F\u5EA6\u4E3A" + value);
|
|
7582
|
-
} else {
|
|
7583
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7584
|
-
}
|
|
7585
|
-
});
|
|
7586
|
-
}
|
|
7587
|
-
};
|
|
7588
|
-
case "min":
|
|
7589
|
-
return {
|
|
7590
|
-
type: "number",
|
|
7591
|
-
asyncValidator: (rule, val) => {
|
|
7592
|
-
return new Promise((resolve, reject) => {
|
|
7593
|
-
if (val < value) {
|
|
7594
|
-
reject("\u6700\u5C0F\u503C\u4E3A" + value);
|
|
7595
|
-
} else {
|
|
7596
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7597
|
-
}
|
|
7598
|
-
});
|
|
7599
|
-
}
|
|
7600
|
-
};
|
|
7601
|
-
case "max":
|
|
7602
|
-
return {
|
|
7603
|
-
type: "number",
|
|
7604
|
-
asyncValidator: (rule, val) => {
|
|
7605
|
-
return new Promise((resolve, reject) => {
|
|
7606
|
-
if (val > value) {
|
|
7607
|
-
reject("\u6700\u5927\u503C\u4E3A" + value);
|
|
7608
|
-
} else {
|
|
7609
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7610
|
-
}
|
|
7611
|
-
});
|
|
7612
|
-
}
|
|
7613
|
-
};
|
|
7614
|
-
case "required":
|
|
7615
|
-
return {
|
|
7616
|
-
reqiured: true,
|
|
7617
|
-
asyncValidator: (rule, val) => {
|
|
7618
|
-
return new Promise((resolve, reject) => {
|
|
7619
|
-
if (!val) {
|
|
7620
|
-
reject("\u5FC5\u586B\u9879");
|
|
7621
|
-
} else {
|
|
7622
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7623
|
-
}
|
|
7624
|
-
});
|
|
7625
|
-
}
|
|
7626
|
-
};
|
|
7627
|
-
case "requiredTrue":
|
|
7628
|
-
return {
|
|
7629
|
-
asyncValidator: (rule, val) => {
|
|
7630
|
-
return new Promise((resolve, reject) => {
|
|
7631
|
-
if (!val) {
|
|
7632
|
-
reject("\u5FC5\u987B\u4E3Atrue\u503C");
|
|
7633
|
-
} else {
|
|
7634
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7635
|
-
}
|
|
7636
|
-
});
|
|
7637
|
-
}
|
|
7638
|
-
};
|
|
7639
|
-
case "email":
|
|
7640
|
-
return {
|
|
7641
|
-
type: "email",
|
|
7642
|
-
message: "\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E"
|
|
7643
|
-
};
|
|
7644
|
-
case "pattern":
|
|
7645
|
-
return {
|
|
7646
|
-
type: "regexp",
|
|
7647
|
-
pattern: value,
|
|
7648
|
-
message: "\u53EA\u80FD\u5305\u542B\u6570\u5B57\u4E0E\u5927\u5C0F\u5199\u5B57\u7B26",
|
|
7649
|
-
validator: (rule, val) => value.test(val)
|
|
7650
|
-
};
|
|
7651
|
-
case "whitespace":
|
|
7652
|
-
return {
|
|
7653
|
-
message: "\u8F93\u5165\u4E0D\u80FD\u5168\u90E8\u4E3A\u7A7A\u683C\u6216\u7A7A\u5B57\u7B26",
|
|
7654
|
-
validator: (rule, val) => !!val.trim()
|
|
7655
|
-
};
|
|
7656
|
-
default:
|
|
7657
|
-
return {
|
|
7658
|
-
[ruleName]: value
|
|
7659
|
-
};
|
|
7660
|
-
}
|
|
7661
|
-
}
|
|
7662
|
-
function getKeyValueOfObjectList(obj) {
|
|
7663
|
-
const kvArr = [];
|
|
7664
|
-
for (const key in obj) {
|
|
7665
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
7666
|
-
kvArr.push({
|
|
7667
|
-
key,
|
|
7668
|
-
value: obj[key]
|
|
7669
|
-
});
|
|
7670
|
-
}
|
|
7671
|
-
}
|
|
7672
|
-
return kvArr;
|
|
7673
|
-
}
|
|
7674
|
-
function handleErrorStrategy(el) {
|
|
7675
|
-
const classList = [...el.classList];
|
|
7676
|
-
classList.push("devui-validate-rules-error-pristine");
|
|
7677
|
-
el.setAttribute("class", classList.join(" "));
|
|
7678
|
-
}
|
|
7679
|
-
function handleErrorStrategyPass(el) {
|
|
7680
|
-
const classList = [...el.classList];
|
|
7681
|
-
const index2 = classList.indexOf("devui-validate-rules-error-pristine");
|
|
7682
|
-
index2 !== -1 && classList.splice(index2, 1);
|
|
7683
|
-
el.setAttribute("class", classList.join(" "));
|
|
7684
|
-
}
|
|
7685
|
-
function getFormControlUID(el) {
|
|
7686
|
-
if (el.tagName.toLocaleLowerCase() === "body") {
|
|
7687
|
-
return "";
|
|
7688
|
-
}
|
|
7689
|
-
if (el.parentElement.id.startsWith("dfc-")) {
|
|
7690
|
-
return el.parentElement.id;
|
|
7691
|
-
} else {
|
|
7692
|
-
getFormControlUID(el.parentElement);
|
|
7693
|
-
}
|
|
7694
|
-
}
|
|
7695
|
-
function handleValidateError({ el, tipEl, message = "", isFormTag, messageShowType, dfcUID, popPosition = "right-bottom", updateOn }) {
|
|
7696
|
-
if (isFormTag && messageShowType === "toast") {
|
|
7697
|
-
alert(message);
|
|
7698
|
-
return;
|
|
7699
|
-
}
|
|
7700
|
-
if (!dfcUID) {
|
|
7701
|
-
dfcUID = getFormControlUID(el);
|
|
7702
|
-
}
|
|
7703
|
-
if (messageShowType === "popover") {
|
|
7704
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: true, message, uid: dfcUID, popPosition, updateOn });
|
|
7705
|
-
return;
|
|
7706
|
-
}
|
|
7707
|
-
tipEl.innerText = "" + message;
|
|
7708
|
-
tipEl.style.display = "inline-flex";
|
|
7709
|
-
tipEl.setAttribute("class", "devui-validate-tip");
|
|
7710
|
-
handleErrorStrategy(el);
|
|
7711
|
-
}
|
|
7712
|
-
function handleValidatePass(el, tipEl) {
|
|
7713
|
-
tipEl.style.display = "none";
|
|
7714
|
-
handleErrorStrategyPass(el);
|
|
7715
|
-
}
|
|
7716
|
-
function getRefName(binding) {
|
|
7717
|
-
const _refs = binding.instance.$refs;
|
|
7718
|
-
const refName = Object.keys(_refs)[0];
|
|
7719
|
-
return refName;
|
|
7720
|
-
}
|
|
7721
|
-
function getFormName(binding) {
|
|
7722
|
-
const _refs = binding.instance.$refs;
|
|
7723
|
-
const key = Object.keys(_refs)[0];
|
|
7724
|
-
return _refs[key]["name"];
|
|
7725
|
-
}
|
|
7726
|
-
function validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, dfcUID, popPosition, updateOn }) {
|
|
7727
|
-
validator.validate({ modelName: modelValue }).then(() => {
|
|
7728
|
-
handleValidatePass(el, tipEl);
|
|
7729
|
-
}).catch((err) => {
|
|
7730
|
-
const { errors } = err;
|
|
7731
|
-
if (!errors || errors.length === 0) {
|
|
7732
|
-
return;
|
|
7733
|
-
}
|
|
7734
|
-
let msg = "";
|
|
7735
|
-
if (typeof errors[0].message === "object") {
|
|
7736
|
-
msg = errors[0].message.default;
|
|
7737
|
-
} else {
|
|
7738
|
-
msg = errors[0].message;
|
|
7739
|
-
}
|
|
7740
|
-
handleValidateError({ el, tipEl, message: msg, isFormTag, messageShowType, dfcUID, popPosition, updateOn });
|
|
7741
|
-
});
|
|
7742
|
-
}
|
|
7743
|
-
function checkValidPopsition(positionStr) {
|
|
7744
|
-
const validPosition = ["left", "right", "top", "bottom", "left-top", "left-bottom", "top-left", "top-right", "right-top", "right-bottom", "bottom-left", "bottom-right"];
|
|
7745
|
-
const isValid = validPosition.includes(positionStr);
|
|
7746
|
-
!isValid && console.warn(`invalid popPosition value '${positionStr}'.`);
|
|
7747
|
-
return isValid;
|
|
7748
|
-
}
|
|
7749
|
-
var dValidateRules = {
|
|
7750
|
-
mounted(el, binding, vnode) {
|
|
7751
|
-
var _a;
|
|
7752
|
-
const isFormTag = el.tagName === "FORM";
|
|
7753
|
-
const dfcUID = el.parentNode.parentNode.parentElement.dataset.uid;
|
|
7754
|
-
const refName = getRefName(binding);
|
|
7755
|
-
const hasOptions = isObject(binding.value) && hasKey(binding.value, "options");
|
|
7756
|
-
let {
|
|
7757
|
-
rules: bindingRules,
|
|
7758
|
-
options = {},
|
|
7759
|
-
messageShowType = "popover"
|
|
7760
|
-
} = binding.value;
|
|
7761
|
-
let { errorStrategy } = binding.value;
|
|
7762
|
-
if (refName) {
|
|
7763
|
-
messageShowType = (_a = binding.instance[refName]["messageShowType"]) != null ? _a : "popover";
|
|
7764
|
-
}
|
|
7765
|
-
let {
|
|
7766
|
-
updateOn = "change",
|
|
7767
|
-
errorStrategy: ErrorStrategy = "dirty",
|
|
7768
|
-
asyncDebounceTime = 300,
|
|
7769
|
-
popPosition = ["right", "bottom"]
|
|
7770
|
-
} = options;
|
|
7771
|
-
if (messageShowType === "popover") {
|
|
7772
|
-
if (Array.isArray(popPosition)) {
|
|
7773
|
-
popPosition = popPosition.length > 1 ? popPosition.join("-") : popPosition[0];
|
|
7774
|
-
if (!checkValidPopsition(popPosition)) {
|
|
7775
|
-
popPosition = "right-bottom";
|
|
7776
|
-
}
|
|
7777
|
-
} else if (!checkValidPopsition(popPosition)) {
|
|
7778
|
-
popPosition = "right-bottom";
|
|
7779
|
-
}
|
|
7780
|
-
}
|
|
7781
|
-
if (!errorStrategy) {
|
|
7782
|
-
errorStrategy = ErrorStrategy;
|
|
7783
|
-
}
|
|
7784
|
-
let customRule = {};
|
|
7785
|
-
if (hasOptions) {
|
|
7786
|
-
customRule = bindingRules != null ? bindingRules : binding.value;
|
|
7787
|
-
} else {
|
|
7788
|
-
customRule = binding.value;
|
|
7789
|
-
}
|
|
7790
|
-
const isCustomValidator = customRule && isObject(customRule) && (hasKey(customRule, "validators") || hasKey(customRule, "asyncValidators"));
|
|
7791
|
-
const rules2 = Array.isArray(customRule) ? customRule : [customRule];
|
|
7792
|
-
const tipEl = document.createElement("span");
|
|
7793
|
-
if (messageShowType !== "none") {
|
|
7794
|
-
el.parentNode.append(tipEl);
|
|
7795
|
-
}
|
|
7796
|
-
const descriptor = {
|
|
7797
|
-
modelName: []
|
|
7798
|
-
};
|
|
7799
|
-
rules2.forEach((rule) => {
|
|
7800
|
-
const kvObjList = !Array.isArray(rule) && getKeyValueOfObjectList(rule);
|
|
7801
|
-
let ruleObj = {};
|
|
7802
|
-
let avaliableRuleObj = {};
|
|
7803
|
-
kvObjList.forEach((item) => {
|
|
7804
|
-
avaliableRuleObj = getAvaliableRuleObj(item.key, item.value);
|
|
7805
|
-
ruleObj = __spreadValues(__spreadValues({}, ruleObj), avaliableRuleObj);
|
|
7806
|
-
});
|
|
7807
|
-
descriptor.modelName.push(ruleObj);
|
|
7808
|
-
});
|
|
7809
|
-
if (isCustomValidator) {
|
|
7810
|
-
const { validators: validators2, asyncValidators } = customRule;
|
|
7811
|
-
validators2 && validators2.forEach((item) => {
|
|
7812
|
-
const ruleObj = {
|
|
7813
|
-
message: (item == null ? void 0 : item.message) || "",
|
|
7814
|
-
validator: (rule, value) => item.validator(rule, value)
|
|
7815
|
-
};
|
|
7816
|
-
descriptor.modelName.push(ruleObj);
|
|
7817
|
-
});
|
|
7818
|
-
asyncValidators && asyncValidators.forEach((item) => {
|
|
7819
|
-
const ruleObj = {
|
|
7820
|
-
message: (item == null ? void 0 : item.message) || "",
|
|
7821
|
-
asyncValidator: (rule, value) => {
|
|
7822
|
-
return new Promise(lodash.exports.debounce((resolve, reject) => {
|
|
7823
|
-
const res = item.asyncValidator(rule, value);
|
|
7824
|
-
if (res) {
|
|
7825
|
-
resolve("");
|
|
7826
|
-
} else {
|
|
7827
|
-
reject(rule.message);
|
|
7828
|
-
}
|
|
7829
|
-
}, asyncDebounceTime));
|
|
7830
|
-
}
|
|
7831
|
-
};
|
|
7832
|
-
descriptor.modelName.push(ruleObj);
|
|
7833
|
-
});
|
|
7834
|
-
}
|
|
7835
|
-
const validator = new Schema(descriptor);
|
|
7836
|
-
const htmlEventValidateHandler = (e) => {
|
|
7837
|
-
const modelValue = e.target.value;
|
|
7838
|
-
if (messageShowType === "popover") {
|
|
7839
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: false, message: "", uid: dfcUID, popPosition, updateOn });
|
|
7840
|
-
}
|
|
7841
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition, updateOn });
|
|
7842
|
-
};
|
|
7843
|
-
vnode.children[0].el.addEventListener(updateOn, htmlEventValidateHandler);
|
|
7844
|
-
if (messageShowType === "popover" && updateOn === "change") {
|
|
7845
|
-
vnode.children[0].el.addEventListener("focus", () => {
|
|
7846
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: false, uid: dfcUID, updateOn });
|
|
7847
|
-
});
|
|
7848
|
-
}
|
|
7849
|
-
if (errorStrategy === "pristine") {
|
|
7850
|
-
handleErrorStrategy(el);
|
|
7851
|
-
vnode.children[0].props.value = "" + vnode.children[0].props.value;
|
|
7852
|
-
}
|
|
7853
|
-
const formName = getFormName(binding);
|
|
7854
|
-
formName && EventBus.on(`formSubmit:${formName}`, () => {
|
|
7855
|
-
const modelValue = isFormTag ? "" : vnode.children[0].el.value;
|
|
7856
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, updateOn: "submit" });
|
|
7857
|
-
});
|
|
7858
|
-
}
|
|
7859
|
-
};
|
|
7860
|
-
Form.install = function(app) {
|
|
7861
|
-
app.component(Form.name, Form);
|
|
7862
|
-
app.directive("d-validate-rules", dValidateRules);
|
|
7863
|
-
};
|
|
7864
|
-
FormLabel.install = function(app) {
|
|
7865
|
-
app.component(FormLabel.name, FormLabel);
|
|
7866
|
-
};
|
|
7867
|
-
FormItem.install = function(app) {
|
|
7868
|
-
app.component(FormItem.name, FormItem);
|
|
7869
|
-
};
|
|
7870
|
-
FormControl.install = function(app) {
|
|
7871
|
-
app.component(FormControl.name, FormControl);
|
|
7872
|
-
};
|
|
7873
|
-
FormOperation.install = function(app) {
|
|
7874
|
-
app.component(FormOperation.name, FormOperation);
|
|
7875
|
-
};
|
|
7876
7634
|
var index = {
|
|
7877
7635
|
title: "Form \u8868\u5355",
|
|
7878
7636
|
category: "\u6570\u636E\u5F55\u5165",
|
|
7879
7637
|
status: "75%",
|
|
7880
7638
|
install(app) {
|
|
7881
|
-
app.
|
|
7882
|
-
app.
|
|
7883
|
-
app.
|
|
7884
|
-
app.
|
|
7885
|
-
app.
|
|
7639
|
+
app.component(Form.name, Form);
|
|
7640
|
+
app.component(FormLabel.name, FormLabel);
|
|
7641
|
+
app.component(FormItem.name, FormItem);
|
|
7642
|
+
app.component(FormControl.name, FormControl);
|
|
7643
|
+
app.component(FormOperation.name, FormOperation);
|
|
7886
7644
|
}
|
|
7887
7645
|
};
|
|
7888
|
-
export { Form, FormControl, FormItem, FormLabel, FormOperation, index as default };
|
|
7646
|
+
export { FORM_ITEM_TOKEN, FORM_TOKEN, Form, FormControl, FormItem, FormLabel, FormOperation, index as default, formControlProps, formItemProps, formProps };
|