vue-devui 1.0.0-rc.5 → 1.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -8
- package/auto-complete/index.es.js +11 -1
- package/auto-complete/index.umd.js +3 -3
- package/button/index.es.js +1 -1
- package/button/index.umd.js +1 -1
- package/date-picker/index.es.js +13 -19
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dropdown/index.es.js +3 -1
- package/dropdown/index.umd.js +1 -1
- package/form/index.es.js +800 -807
- package/form/index.umd.js +16 -16
- package/form/style.css +1 -1
- package/input/index.es.js +13 -19
- package/input/index.umd.js +1 -1
- package/input/style.css +1 -1
- package/input-number/index.es.js +27 -5
- package/input-number/index.umd.js +1 -1
- package/input-number/style.css +1 -1
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/treeProps.js +3 -0
- package/package.json +1 -1
- package/popover/style.css +1 -1
- package/search/index.es.js +13 -19
- package/search/index.umd.js +12 -12
- package/search/style.css +1 -1
- package/slider/index.es.js +18 -6
- package/slider/index.umd.js +1 -1
- package/style.css +1 -1
- package/table/index.es.js +794 -509
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tooltip/index.es.js +1 -1
- package/tooltip/index.umd.js +1 -1
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +1021 -0
- package/tree/index.umd.js +1 -0
- package/tree/package.json +7 -0
- package/tree/style.css +1 -0
- package/vue-devui.es.js +1575 -669
- package/vue-devui.umd.js +16 -16
package/form/index.es.js
CHANGED
|
@@ -17,7 +17,19 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { defineComponent, toRefs, provide, reactive, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted, ref, unref, nextTick, mergeProps, Fragment, inject, onBeforeUnmount } from "vue";
|
|
21
33
|
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
22
34
|
function mitt(n) {
|
|
23
35
|
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
@@ -36,9 +48,9 @@ function mitt(n) {
|
|
|
36
48
|
} };
|
|
37
49
|
}
|
|
38
50
|
const formProps = {
|
|
39
|
-
|
|
51
|
+
data: {
|
|
40
52
|
type: Object,
|
|
41
|
-
default: {}
|
|
53
|
+
default: () => ({})
|
|
42
54
|
},
|
|
43
55
|
layout: {
|
|
44
56
|
type: String,
|
|
@@ -46,74 +58,25 @@ const formProps = {
|
|
|
46
58
|
},
|
|
47
59
|
labelSize: {
|
|
48
60
|
type: String,
|
|
49
|
-
default: ""
|
|
61
|
+
default: "md"
|
|
50
62
|
},
|
|
51
63
|
labelAlign: {
|
|
52
64
|
type: String,
|
|
53
65
|
default: "start"
|
|
54
66
|
},
|
|
55
67
|
rules: {
|
|
56
|
-
type: Object
|
|
57
|
-
default: {}
|
|
58
|
-
},
|
|
59
|
-
columnsClass: {
|
|
60
|
-
type: String,
|
|
61
|
-
default: ""
|
|
62
|
-
},
|
|
63
|
-
name: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: ""
|
|
68
|
+
type: Object
|
|
66
69
|
},
|
|
67
70
|
messageShowType: {
|
|
68
71
|
type: String,
|
|
69
72
|
default: "popover"
|
|
70
73
|
}
|
|
71
74
|
};
|
|
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
75
|
const dFormEvents = {
|
|
107
76
|
addField: "d.form.addField",
|
|
108
77
|
removeField: "d.form.removeField"
|
|
109
78
|
};
|
|
110
|
-
const
|
|
111
|
-
const formItemInjectionKey = Symbol("dFormItem");
|
|
112
|
-
const dFormItemEvents = {
|
|
113
|
-
blur: "d.form.blur",
|
|
114
|
-
change: "d.form.change",
|
|
115
|
-
input: "d.form.input"
|
|
116
|
-
};
|
|
79
|
+
const FORM_TOKEN = Symbol("dForm");
|
|
117
80
|
var eventBus = mitt();
|
|
118
81
|
const EventBus = eventBus;
|
|
119
82
|
function isObject(obj) {
|
|
@@ -125,464 +88,39 @@ function hasKey(obj, key) {
|
|
|
125
88
|
}
|
|
126
89
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
127
90
|
}
|
|
128
|
-
function
|
|
129
|
-
let
|
|
130
|
-
|
|
131
|
-
|
|
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"
|
|
91
|
+
function createBem(namespace, element, modifier) {
|
|
92
|
+
let cls = namespace;
|
|
93
|
+
if (element) {
|
|
94
|
+
cls += `__${element}`;
|
|
220
95
|
}
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
};
|
|
96
|
+
if (modifier) {
|
|
97
|
+
cls += `--${modifier}`;
|
|
248
98
|
}
|
|
249
|
-
|
|
250
|
-
var baseOverlay = "";
|
|
251
|
-
function _isSlot(s) {
|
|
252
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
99
|
+
return cls;
|
|
253
100
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
});
|
|
101
|
+
function useNamespace(block) {
|
|
102
|
+
const namespace = `devui-${block}`;
|
|
103
|
+
const b = () => createBem(namespace);
|
|
104
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
105
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
106
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
347
107
|
return {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
108
|
+
b,
|
|
109
|
+
e,
|
|
110
|
+
m,
|
|
111
|
+
em
|
|
352
112
|
};
|
|
353
113
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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;
|
|
114
|
+
function useFieldCollection() {
|
|
115
|
+
const itemContexts = [];
|
|
116
|
+
const addItemContext = (field) => {
|
|
117
|
+
itemContexts.push(field);
|
|
118
|
+
};
|
|
119
|
+
const removeItemContext = (field) => {
|
|
120
|
+
itemContexts.splice(itemContexts.indexOf(field), 1);
|
|
121
|
+
};
|
|
122
|
+
return { itemContexts, addItemContext, removeItemContext };
|
|
421
123
|
}
|
|
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);
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
onUnmounted(() => {
|
|
505
|
-
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
506
|
-
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
507
|
-
window.removeEventListener("resize", updatePosition);
|
|
508
|
-
});
|
|
509
|
-
return { arrowRef, overlayRef, updatePosition };
|
|
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"]
|
|
552
|
-
},
|
|
553
|
-
align: {
|
|
554
|
-
type: String,
|
|
555
|
-
default: null
|
|
556
|
-
},
|
|
557
|
-
offset: {
|
|
558
|
-
type: [Number, Object],
|
|
559
|
-
default: 8
|
|
560
|
-
},
|
|
561
|
-
content: {
|
|
562
|
-
type: String,
|
|
563
|
-
default: ""
|
|
564
|
-
},
|
|
565
|
-
trigger: {
|
|
566
|
-
type: String,
|
|
567
|
-
default: "click"
|
|
568
|
-
},
|
|
569
|
-
popType: {
|
|
570
|
-
type: String,
|
|
571
|
-
default: "default"
|
|
572
|
-
},
|
|
573
|
-
showAnimation: {
|
|
574
|
-
type: Boolean,
|
|
575
|
-
default: true
|
|
576
|
-
},
|
|
577
|
-
mouseEnterDelay: {
|
|
578
|
-
type: Number,
|
|
579
|
-
default: 150
|
|
580
|
-
},
|
|
581
|
-
mouseLeaveDelay: {
|
|
582
|
-
type: Number,
|
|
583
|
-
default: 100
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
124
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
587
125
|
var lodash = { exports: {} };
|
|
588
126
|
/**
|
|
@@ -5991,10 +5529,456 @@ var lodash = { exports: {} };
|
|
|
5991
5529
|
(freeModule.exports = _)._ = _;
|
|
5992
5530
|
freeExports._ = _;
|
|
5993
5531
|
} else {
|
|
5994
|
-
root._ = _;
|
|
5532
|
+
root._ = _;
|
|
5533
|
+
}
|
|
5534
|
+
}).call(commonjsGlobal);
|
|
5535
|
+
})(lodash, lodash.exports);
|
|
5536
|
+
function useFormValidation(itemContexts) {
|
|
5537
|
+
const getValidateFields = (fields) => {
|
|
5538
|
+
if (!itemContexts.length) {
|
|
5539
|
+
return [];
|
|
5540
|
+
}
|
|
5541
|
+
const normalizedFields = lodash.exports.castArray(fields);
|
|
5542
|
+
const filteredFields = normalizedFields.length ? itemContexts.filter((context) => context.field && normalizedFields.includes(context.field)) : itemContexts;
|
|
5543
|
+
if (!filteredFields.length) {
|
|
5544
|
+
return [];
|
|
5545
|
+
}
|
|
5546
|
+
return filteredFields;
|
|
5547
|
+
};
|
|
5548
|
+
const execValidateFields = async (fields = []) => {
|
|
5549
|
+
const validateFields2 = getValidateFields(fields);
|
|
5550
|
+
if (!validateFields2.length) {
|
|
5551
|
+
return true;
|
|
5552
|
+
}
|
|
5553
|
+
let errors = {};
|
|
5554
|
+
for (const field of validateFields2) {
|
|
5555
|
+
try {
|
|
5556
|
+
await field.validate("");
|
|
5557
|
+
} catch (err) {
|
|
5558
|
+
errors = __spreadValues(__spreadValues({}, errors), err);
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
if (!Object.keys(errors).length) {
|
|
5562
|
+
return true;
|
|
5563
|
+
}
|
|
5564
|
+
return Promise.reject(errors);
|
|
5565
|
+
};
|
|
5566
|
+
const validateFields = async (fields = [], callback) => {
|
|
5567
|
+
try {
|
|
5568
|
+
const result = await execValidateFields(fields);
|
|
5569
|
+
if (result) {
|
|
5570
|
+
callback == null ? void 0 : callback(result);
|
|
5571
|
+
}
|
|
5572
|
+
return result;
|
|
5573
|
+
} catch (err) {
|
|
5574
|
+
const invalidFields = err;
|
|
5575
|
+
callback == null ? void 0 : callback(false, invalidFields);
|
|
5576
|
+
return !callback && Promise.reject(invalidFields);
|
|
5577
|
+
}
|
|
5578
|
+
};
|
|
5579
|
+
const validate = async (callback) => validateFields(void 0, callback);
|
|
5580
|
+
return { validate, validateFields };
|
|
5581
|
+
}
|
|
5582
|
+
var Form = defineComponent({
|
|
5583
|
+
name: "DForm",
|
|
5584
|
+
props: formProps,
|
|
5585
|
+
emits: ["submit"],
|
|
5586
|
+
setup(props, ctx) {
|
|
5587
|
+
const formMitt = mitt();
|
|
5588
|
+
const ns = useNamespace("form");
|
|
5589
|
+
const {
|
|
5590
|
+
data,
|
|
5591
|
+
layout,
|
|
5592
|
+
labelSize,
|
|
5593
|
+
labelAlign
|
|
5594
|
+
} = toRefs(props);
|
|
5595
|
+
const {
|
|
5596
|
+
itemContexts,
|
|
5597
|
+
addItemContext,
|
|
5598
|
+
removeItemContext
|
|
5599
|
+
} = useFieldCollection();
|
|
5600
|
+
const {
|
|
5601
|
+
validate,
|
|
5602
|
+
validateFields
|
|
5603
|
+
} = useFormValidation(itemContexts);
|
|
5604
|
+
formMitt.on(dFormEvents.addField, (field) => {
|
|
5605
|
+
});
|
|
5606
|
+
formMitt.on(dFormEvents.removeField, (field) => {
|
|
5607
|
+
if (field.prop)
|
|
5608
|
+
;
|
|
5609
|
+
});
|
|
5610
|
+
provide(FORM_TOKEN, reactive({
|
|
5611
|
+
formData: data,
|
|
5612
|
+
formMitt,
|
|
5613
|
+
labelData: {
|
|
5614
|
+
layout,
|
|
5615
|
+
labelSize,
|
|
5616
|
+
labelAlign
|
|
5617
|
+
},
|
|
5618
|
+
rules: props.rules,
|
|
5619
|
+
messageShowType: "popover",
|
|
5620
|
+
addItemContext,
|
|
5621
|
+
removeItemContext
|
|
5622
|
+
}));
|
|
5623
|
+
ctx.expose({
|
|
5624
|
+
validate,
|
|
5625
|
+
validateFields
|
|
5626
|
+
});
|
|
5627
|
+
const onSubmit = (e) => {
|
|
5628
|
+
e.preventDefault();
|
|
5629
|
+
ctx.emit("submit", e);
|
|
5630
|
+
EventBus.emit(`formSubmit:${props.name}`);
|
|
5631
|
+
};
|
|
5632
|
+
return () => {
|
|
5633
|
+
var _a, _b;
|
|
5634
|
+
return createVNode("form", {
|
|
5635
|
+
"onSubmit": onSubmit,
|
|
5636
|
+
"class": ns.b()
|
|
5637
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
5638
|
+
};
|
|
5639
|
+
}
|
|
5640
|
+
});
|
|
5641
|
+
const formLabelProps = {
|
|
5642
|
+
helpTips: {
|
|
5643
|
+
type: String,
|
|
5644
|
+
default: ""
|
|
5645
|
+
}
|
|
5646
|
+
};
|
|
5647
|
+
var baseOverlay = "";
|
|
5648
|
+
function _isSlot(s) {
|
|
5649
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
5650
|
+
}
|
|
5651
|
+
const CommonOverlay = defineComponent({
|
|
5652
|
+
setup(props, ctx) {
|
|
5653
|
+
return () => {
|
|
5654
|
+
let _slot;
|
|
5655
|
+
return createVNode(Teleport, {
|
|
5656
|
+
"to": "#d-overlay-anchor"
|
|
5657
|
+
}, {
|
|
5658
|
+
default: () => [createVNode(Transition, {
|
|
5659
|
+
"name": "devui-overlay-fade"
|
|
5660
|
+
}, _isSlot(_slot = renderSlot(ctx.slots, "default")) ? _slot : {
|
|
5661
|
+
default: () => [_slot]
|
|
5662
|
+
})]
|
|
5663
|
+
});
|
|
5664
|
+
};
|
|
5665
|
+
}
|
|
5666
|
+
});
|
|
5667
|
+
const overlayProps = {
|
|
5668
|
+
visible: {
|
|
5669
|
+
type: Boolean
|
|
5670
|
+
},
|
|
5671
|
+
backgroundBlock: {
|
|
5672
|
+
type: Boolean,
|
|
5673
|
+
default: false
|
|
5674
|
+
},
|
|
5675
|
+
backgroundClass: {
|
|
5676
|
+
type: String,
|
|
5677
|
+
default: ""
|
|
5678
|
+
},
|
|
5679
|
+
backgroundStyle: {
|
|
5680
|
+
type: [String, Object]
|
|
5681
|
+
},
|
|
5682
|
+
onBackdropClick: {
|
|
5683
|
+
type: Function
|
|
5684
|
+
},
|
|
5685
|
+
backdropClose: {
|
|
5686
|
+
type: Boolean,
|
|
5687
|
+
default: true
|
|
5688
|
+
},
|
|
5689
|
+
hasBackdrop: {
|
|
5690
|
+
type: Boolean,
|
|
5691
|
+
default: true
|
|
5692
|
+
}
|
|
5693
|
+
};
|
|
5694
|
+
const fixedOverlayProps = __spreadProps(__spreadValues({}, overlayProps), {
|
|
5695
|
+
overlayStyle: {
|
|
5696
|
+
type: [String, Object],
|
|
5697
|
+
default: void 0
|
|
5698
|
+
}
|
|
5699
|
+
});
|
|
5700
|
+
const overlayEmits = ["update:visible", "backdropClick"];
|
|
5701
|
+
function useOverlayLogic(props, ctx) {
|
|
5702
|
+
const backgroundClass = computed(() => {
|
|
5703
|
+
return [
|
|
5704
|
+
"devui-overlay-background",
|
|
5705
|
+
props.backgroundClass,
|
|
5706
|
+
!props.hasBackdrop ? "devui-overlay-background__disabled" : "devui-overlay-background__color"
|
|
5707
|
+
];
|
|
5708
|
+
});
|
|
5709
|
+
const overlayClass = computed(() => {
|
|
5710
|
+
return "devui-overlay";
|
|
5711
|
+
});
|
|
5712
|
+
const handleBackdropClick = (event) => {
|
|
5713
|
+
var _a;
|
|
5714
|
+
event.preventDefault();
|
|
5715
|
+
(_a = props.onBackdropClick) == null ? void 0 : _a.call(props);
|
|
5716
|
+
if (props.backdropClose) {
|
|
5717
|
+
ctx.emit("update:visible", false);
|
|
5718
|
+
}
|
|
5719
|
+
};
|
|
5720
|
+
const handleOverlayBubbleCancel = (event) => event.cancelBubble = true;
|
|
5721
|
+
onMounted(() => {
|
|
5722
|
+
const body = document.body;
|
|
5723
|
+
const originOverflow = body.style.overflow;
|
|
5724
|
+
const originPosition = body.style.position;
|
|
5725
|
+
watch([() => props.visible, () => props.backgroundBlock], ([visible, backgroundBlock]) => {
|
|
5726
|
+
if (backgroundBlock) {
|
|
5727
|
+
const top = body.getBoundingClientRect().y;
|
|
5728
|
+
if (visible) {
|
|
5729
|
+
body.style.overflowY = "scroll";
|
|
5730
|
+
body.style.position = visible ? "fixed" : "";
|
|
5731
|
+
body.style.top = `${top}px`;
|
|
5732
|
+
} else {
|
|
5733
|
+
body.style.overflowY = originOverflow;
|
|
5734
|
+
body.style.position = originPosition;
|
|
5735
|
+
body.style.top = "";
|
|
5736
|
+
window.scrollTo(0, -top);
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5739
|
+
});
|
|
5740
|
+
onUnmounted(() => {
|
|
5741
|
+
document.body.style.overflow = originOverflow;
|
|
5742
|
+
});
|
|
5743
|
+
});
|
|
5744
|
+
return {
|
|
5745
|
+
backgroundClass,
|
|
5746
|
+
overlayClass,
|
|
5747
|
+
handleBackdropClick,
|
|
5748
|
+
handleOverlayBubbleCancel
|
|
5749
|
+
};
|
|
5750
|
+
}
|
|
5751
|
+
var fixedOverlay = "";
|
|
5752
|
+
defineComponent({
|
|
5753
|
+
name: "DFixedOverlay",
|
|
5754
|
+
props: fixedOverlayProps,
|
|
5755
|
+
emits: overlayEmits,
|
|
5756
|
+
setup(props, ctx) {
|
|
5757
|
+
const {
|
|
5758
|
+
backgroundClass,
|
|
5759
|
+
overlayClass,
|
|
5760
|
+
handleBackdropClick,
|
|
5761
|
+
handleOverlayBubbleCancel
|
|
5762
|
+
} = useOverlayLogic(props, ctx);
|
|
5763
|
+
return () => createVNode(CommonOverlay, null, {
|
|
5764
|
+
default: () => [props.visible && createVNode("div", {
|
|
5765
|
+
"class": backgroundClass.value,
|
|
5766
|
+
"style": props.backgroundStyle,
|
|
5767
|
+
"onClick": handleBackdropClick
|
|
5768
|
+
}, [createVNode("div", {
|
|
5769
|
+
"class": overlayClass.value,
|
|
5770
|
+
"style": props.overlayStyle,
|
|
5771
|
+
"onClick": handleOverlayBubbleCancel
|
|
5772
|
+
}, [renderSlot(ctx.slots, "default")])])]
|
|
5773
|
+
});
|
|
5774
|
+
}
|
|
5775
|
+
});
|
|
5776
|
+
const flexibleOverlayProps = {
|
|
5777
|
+
modelValue: {
|
|
5778
|
+
type: Boolean,
|
|
5779
|
+
default: false
|
|
5780
|
+
},
|
|
5781
|
+
origin: {
|
|
5782
|
+
type: Object,
|
|
5783
|
+
require: true
|
|
5784
|
+
},
|
|
5785
|
+
position: {
|
|
5786
|
+
type: Array,
|
|
5787
|
+
default: ["bottom"]
|
|
5788
|
+
},
|
|
5789
|
+
offset: {
|
|
5790
|
+
type: [Number, Object],
|
|
5791
|
+
default: 8
|
|
5792
|
+
},
|
|
5793
|
+
shiftOffset: {
|
|
5794
|
+
type: Number
|
|
5795
|
+
},
|
|
5796
|
+
align: {
|
|
5797
|
+
type: String,
|
|
5798
|
+
default: null
|
|
5799
|
+
},
|
|
5800
|
+
showArrow: {
|
|
5801
|
+
type: Boolean,
|
|
5802
|
+
default: false
|
|
5803
|
+
},
|
|
5804
|
+
isArrowCenter: {
|
|
5805
|
+
type: Boolean,
|
|
5806
|
+
default: true
|
|
5807
|
+
}
|
|
5808
|
+
};
|
|
5809
|
+
function getScrollParent(element) {
|
|
5810
|
+
const overflowRegex = /(auto|scroll|hidden)/;
|
|
5811
|
+
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
5812
|
+
const style2 = window.getComputedStyle(parent);
|
|
5813
|
+
if (overflowRegex.test(style2.overflow + style2.overflowX + style2.overflowY)) {
|
|
5814
|
+
return parent;
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5817
|
+
return window;
|
|
5818
|
+
}
|
|
5819
|
+
function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
|
|
5820
|
+
let { x, y } = point;
|
|
5821
|
+
if (!isArrowCenter) {
|
|
5822
|
+
const { width, height } = originRect;
|
|
5823
|
+
if (x && placement.includes("start")) {
|
|
5824
|
+
x = 12;
|
|
5825
|
+
}
|
|
5826
|
+
if (x && placement.includes("end")) {
|
|
5827
|
+
x = Math.round(width - 24);
|
|
5828
|
+
}
|
|
5829
|
+
if (y && placement.includes("start")) {
|
|
5830
|
+
y = 10;
|
|
5831
|
+
}
|
|
5832
|
+
if (y && placement.includes("end")) {
|
|
5833
|
+
y = height - 14;
|
|
5834
|
+
}
|
|
5835
|
+
}
|
|
5836
|
+
return { x, y };
|
|
5837
|
+
}
|
|
5838
|
+
function useOverlay(props, emit) {
|
|
5839
|
+
const overlayRef = ref();
|
|
5840
|
+
const arrowRef = ref();
|
|
5841
|
+
let originParent = null;
|
|
5842
|
+
const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
|
|
5843
|
+
const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
|
|
5844
|
+
const staticSide = {
|
|
5845
|
+
top: "bottom",
|
|
5846
|
+
right: "left",
|
|
5847
|
+
bottom: "top",
|
|
5848
|
+
left: "right"
|
|
5849
|
+
}[placement.split("-")[0]];
|
|
5850
|
+
Object.assign(arrowEl.style, {
|
|
5851
|
+
left: x ? `${x}px` : "",
|
|
5852
|
+
top: y ? `${y}px` : "",
|
|
5853
|
+
right: "",
|
|
5854
|
+
bottom: "",
|
|
5855
|
+
[staticSide]: "-4px"
|
|
5856
|
+
});
|
|
5857
|
+
};
|
|
5858
|
+
const updatePosition = async () => {
|
|
5859
|
+
const hostEl = props.origin;
|
|
5860
|
+
const overlayEl = unref(overlayRef.value);
|
|
5861
|
+
const arrowEl = unref(arrowRef.value);
|
|
5862
|
+
const middleware = [
|
|
5863
|
+
offset(props.offset),
|
|
5864
|
+
autoPlacement({
|
|
5865
|
+
alignment: props.align,
|
|
5866
|
+
allowedPlacements: props.position
|
|
5867
|
+
})
|
|
5868
|
+
];
|
|
5869
|
+
props.showArrow && middleware.push(arrow({ element: arrowEl }));
|
|
5870
|
+
props.shiftOffset !== void 0 && middleware.push(shift());
|
|
5871
|
+
const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
|
|
5872
|
+
strategy: "fixed",
|
|
5873
|
+
middleware
|
|
5874
|
+
});
|
|
5875
|
+
let applyX = x;
|
|
5876
|
+
let applyY = y;
|
|
5877
|
+
if (props.shiftOffset !== void 0) {
|
|
5878
|
+
const { x: shiftX, y: shiftY } = middlewareData.shift;
|
|
5879
|
+
shiftX < 0 && (applyX -= props.shiftOffset);
|
|
5880
|
+
shiftX > 0 && (applyX += props.shiftOffset);
|
|
5881
|
+
shiftY < 0 && (applyY -= props.shiftOffset);
|
|
5882
|
+
shiftY > 0 && (applyY += props.shiftOffset);
|
|
5883
|
+
}
|
|
5884
|
+
emit("positionChange", placement);
|
|
5885
|
+
Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
|
|
5886
|
+
props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
|
|
5887
|
+
};
|
|
5888
|
+
watch(() => props.modelValue, () => {
|
|
5889
|
+
if (props.modelValue && props.origin) {
|
|
5890
|
+
originParent = getScrollParent(props.origin);
|
|
5891
|
+
nextTick(updatePosition);
|
|
5892
|
+
originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
|
|
5893
|
+
originParent !== window && window.addEventListener("scroll", updatePosition);
|
|
5894
|
+
window.addEventListener("resize", updatePosition);
|
|
5895
|
+
} else {
|
|
5896
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
5897
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
5898
|
+
window.removeEventListener("resize", updatePosition);
|
|
5995
5899
|
}
|
|
5996
|
-
})
|
|
5997
|
-
|
|
5900
|
+
});
|
|
5901
|
+
onUnmounted(() => {
|
|
5902
|
+
originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
|
|
5903
|
+
originParent !== window && window.removeEventListener("scroll", updatePosition);
|
|
5904
|
+
window.removeEventListener("resize", updatePosition);
|
|
5905
|
+
});
|
|
5906
|
+
return { arrowRef, overlayRef, updatePosition };
|
|
5907
|
+
}
|
|
5908
|
+
var flexibleOverlay = "";
|
|
5909
|
+
const FlexibleOverlay = defineComponent({
|
|
5910
|
+
name: "DFlexibleOverlay",
|
|
5911
|
+
inheritAttrs: false,
|
|
5912
|
+
props: flexibleOverlayProps,
|
|
5913
|
+
emits: ["update:modelValue", "positionChange"],
|
|
5914
|
+
setup(props, {
|
|
5915
|
+
slots,
|
|
5916
|
+
attrs,
|
|
5917
|
+
emit,
|
|
5918
|
+
expose
|
|
5919
|
+
}) {
|
|
5920
|
+
const {
|
|
5921
|
+
arrowRef,
|
|
5922
|
+
overlayRef,
|
|
5923
|
+
updatePosition
|
|
5924
|
+
} = useOverlay(props, emit);
|
|
5925
|
+
expose({
|
|
5926
|
+
updatePosition
|
|
5927
|
+
});
|
|
5928
|
+
return () => {
|
|
5929
|
+
var _a;
|
|
5930
|
+
return props.modelValue && createVNode("div", mergeProps({
|
|
5931
|
+
"ref": overlayRef,
|
|
5932
|
+
"class": "devui-flexible-overlay"
|
|
5933
|
+
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
|
|
5934
|
+
"ref": arrowRef,
|
|
5935
|
+
"class": "devui-flexible-overlay-arrow"
|
|
5936
|
+
}, null)]);
|
|
5937
|
+
};
|
|
5938
|
+
}
|
|
5939
|
+
});
|
|
5940
|
+
const popoverProps = {
|
|
5941
|
+
isOpen: {
|
|
5942
|
+
type: Boolean,
|
|
5943
|
+
default: false
|
|
5944
|
+
},
|
|
5945
|
+
position: {
|
|
5946
|
+
type: Array,
|
|
5947
|
+
default: ["bottom"]
|
|
5948
|
+
},
|
|
5949
|
+
align: {
|
|
5950
|
+
type: String,
|
|
5951
|
+
default: null
|
|
5952
|
+
},
|
|
5953
|
+
offset: {
|
|
5954
|
+
type: [Number, Object],
|
|
5955
|
+
default: 8
|
|
5956
|
+
},
|
|
5957
|
+
content: {
|
|
5958
|
+
type: String,
|
|
5959
|
+
default: ""
|
|
5960
|
+
},
|
|
5961
|
+
trigger: {
|
|
5962
|
+
type: String,
|
|
5963
|
+
default: "click"
|
|
5964
|
+
},
|
|
5965
|
+
popType: {
|
|
5966
|
+
type: String,
|
|
5967
|
+
default: "default"
|
|
5968
|
+
},
|
|
5969
|
+
showAnimation: {
|
|
5970
|
+
type: Boolean,
|
|
5971
|
+
default: true
|
|
5972
|
+
},
|
|
5973
|
+
mouseEnterDelay: {
|
|
5974
|
+
type: Number,
|
|
5975
|
+
default: 150
|
|
5976
|
+
},
|
|
5977
|
+
mouseLeaveDelay: {
|
|
5978
|
+
type: Number,
|
|
5979
|
+
default: 100
|
|
5980
|
+
}
|
|
5981
|
+
};
|
|
5998
5982
|
const TransformOriginMap = {
|
|
5999
5983
|
top: "50% calc(100% + 8px)",
|
|
6000
5984
|
bottom: "50% -8px",
|
|
@@ -6228,43 +6212,81 @@ var Popover = defineComponent({
|
|
|
6228
6212
|
};
|
|
6229
6213
|
}
|
|
6230
6214
|
});
|
|
6215
|
+
function HelpTipsIcon() {
|
|
6216
|
+
return createVNode("svg", {
|
|
6217
|
+
"width": "16px",
|
|
6218
|
+
"height": "16px",
|
|
6219
|
+
"viewBox": "0 0 16 16"
|
|
6220
|
+
}, [createVNode("g", {
|
|
6221
|
+
"stroke": "none",
|
|
6222
|
+
"stroke-width": "1",
|
|
6223
|
+
"fill": "none",
|
|
6224
|
+
"fill-rule": "evenodd"
|
|
6225
|
+
}, [createVNode("g", null, [createVNode("path", {
|
|
6226
|
+
"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",
|
|
6227
|
+
"fill": "#293040",
|
|
6228
|
+
"fill-rule": "nonzero"
|
|
6229
|
+
}, null)])])]);
|
|
6230
|
+
}
|
|
6231
|
+
const formItemProps = {
|
|
6232
|
+
field: {
|
|
6233
|
+
type: String,
|
|
6234
|
+
default: ""
|
|
6235
|
+
},
|
|
6236
|
+
dHasFeedback: {
|
|
6237
|
+
type: Boolean,
|
|
6238
|
+
default: false
|
|
6239
|
+
},
|
|
6240
|
+
required: {
|
|
6241
|
+
type: Boolean,
|
|
6242
|
+
default: false
|
|
6243
|
+
},
|
|
6244
|
+
rules: {
|
|
6245
|
+
type: [Object, Array]
|
|
6246
|
+
}
|
|
6247
|
+
};
|
|
6248
|
+
const FORM_ITEM_TOKEN = Symbol("dFormItem");
|
|
6249
|
+
function useFormLabel() {
|
|
6250
|
+
const { labelData } = inject(FORM_TOKEN);
|
|
6251
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6252
|
+
const ns = useNamespace("form");
|
|
6253
|
+
const labelClasses = computed(() => ({
|
|
6254
|
+
[`${ns.e("label")}`]: true,
|
|
6255
|
+
[`${ns.em("label", "vertical")}`]: labelData.layout === "vertical",
|
|
6256
|
+
[`${ns.em("label", labelData.labelSize)}`]: labelData.layout === "horizontal",
|
|
6257
|
+
[`${ns.em("label", labelData.labelAlign)}`]: labelData.layout === "horizontal"
|
|
6258
|
+
}));
|
|
6259
|
+
const labelInnerClasses = computed(() => ({
|
|
6260
|
+
[`${ns.em("label", "required")}`]: formItemContext.required
|
|
6261
|
+
}));
|
|
6262
|
+
return { labelClasses, labelInnerClasses };
|
|
6263
|
+
}
|
|
6231
6264
|
var formLabel = "";
|
|
6232
6265
|
var FormLabel = defineComponent({
|
|
6233
6266
|
name: "DFormLabel",
|
|
6234
6267
|
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
|
-
};
|
|
6268
|
+
setup(props, ctx) {
|
|
6269
|
+
const ns = useNamespace("form");
|
|
6270
|
+
const {
|
|
6271
|
+
labelClasses,
|
|
6272
|
+
labelInnerClasses
|
|
6273
|
+
} = useFormLabel();
|
|
6248
6274
|
return () => {
|
|
6249
6275
|
var _a, _b;
|
|
6250
6276
|
return createVNode("span", {
|
|
6251
|
-
"class":
|
|
6252
|
-
"style": style2
|
|
6277
|
+
"class": labelClasses.value
|
|
6253
6278
|
}, [createVNode("span", {
|
|
6254
|
-
"class":
|
|
6255
|
-
}, [(_b = (_a =
|
|
6279
|
+
"class": labelInnerClasses.value
|
|
6280
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]), props.helpTips && createVNode(Popover, {
|
|
6256
6281
|
"content": props.helpTips,
|
|
6257
|
-
"
|
|
6258
|
-
"
|
|
6259
|
-
"
|
|
6282
|
+
"position": ["top"],
|
|
6283
|
+
"trigger": "hover",
|
|
6284
|
+
"pop-type": "info"
|
|
6260
6285
|
}, {
|
|
6261
|
-
reference: () => createVNode(
|
|
6262
|
-
"class": "
|
|
6263
|
-
},
|
|
6264
|
-
|
|
6265
|
-
"color": "#252b3a"
|
|
6266
|
-
}, null)])
|
|
6267
|
-
})])]);
|
|
6286
|
+
reference: () => createVNode(HelpTipsIcon, {
|
|
6287
|
+
"class": ns.e("label-help")
|
|
6288
|
+
}, null)
|
|
6289
|
+
})]);
|
|
6268
6290
|
};
|
|
6269
6291
|
}
|
|
6270
6292
|
});
|
|
@@ -7270,283 +7292,229 @@ Schema.register = function register(type4, validator) {
|
|
|
7270
7292
|
Schema.warning = warning;
|
|
7271
7293
|
Schema.messages = messages;
|
|
7272
7294
|
Schema.validators = validators;
|
|
7295
|
+
function useFormItem() {
|
|
7296
|
+
const formContext = reactive(inject(FORM_TOKEN));
|
|
7297
|
+
const labelData = reactive(formContext.labelData);
|
|
7298
|
+
const ns = useNamespace("form");
|
|
7299
|
+
const itemClasses = computed(() => ({
|
|
7300
|
+
[`${ns.em("item", "horizontal")}`]: labelData.layout === "horizontal",
|
|
7301
|
+
[`${ns.em("item", "vertical")}`]: labelData.layout === "vertical"
|
|
7302
|
+
}));
|
|
7303
|
+
return { itemClasses };
|
|
7304
|
+
}
|
|
7305
|
+
function useFormItemRule(props) {
|
|
7306
|
+
const formContext = inject(FORM_TOKEN);
|
|
7307
|
+
const _rules = computed(() => {
|
|
7308
|
+
const rules2 = props.rules ? lodash.exports.castArray(props.rules) : [];
|
|
7309
|
+
const formRules = formContext.rules;
|
|
7310
|
+
if (formRules && props.field) {
|
|
7311
|
+
const _itemRules = lodash.exports.get(formRules, props.field, void 0);
|
|
7312
|
+
if (_itemRules) {
|
|
7313
|
+
rules2.push(...lodash.exports.castArray(_itemRules));
|
|
7314
|
+
}
|
|
7315
|
+
}
|
|
7316
|
+
if (props.required) {
|
|
7317
|
+
rules2.push({ required: Boolean(props.required) });
|
|
7318
|
+
}
|
|
7319
|
+
return rules2;
|
|
7320
|
+
});
|
|
7321
|
+
return { _rules };
|
|
7322
|
+
}
|
|
7323
|
+
function useFormItemValidate(props, _rules) {
|
|
7324
|
+
const formContext = inject(FORM_TOKEN);
|
|
7325
|
+
const validateState = ref("");
|
|
7326
|
+
const validateMessage = ref("");
|
|
7327
|
+
const computedField = computed(() => {
|
|
7328
|
+
return typeof props.field === "string" ? props.field : "";
|
|
7329
|
+
});
|
|
7330
|
+
const fieldValue = computed(() => {
|
|
7331
|
+
const formData = formContext.formData;
|
|
7332
|
+
if (!formData || !props.field) {
|
|
7333
|
+
return;
|
|
7334
|
+
}
|
|
7335
|
+
return formData[props.field];
|
|
7336
|
+
});
|
|
7337
|
+
const getRuleByTrigger = (triggerVal) => {
|
|
7338
|
+
return _rules.value.filter((rule) => {
|
|
7339
|
+
if (!rule.trigger || !triggerVal) {
|
|
7340
|
+
return true;
|
|
7341
|
+
}
|
|
7342
|
+
if (Array.isArray(rule.trigger)) {
|
|
7343
|
+
return rule.trigger.includes(triggerVal);
|
|
7344
|
+
} else {
|
|
7345
|
+
return rule.trigger === triggerVal;
|
|
7346
|
+
}
|
|
7347
|
+
}).map((_a) => {
|
|
7348
|
+
var _b = _a, { trigger } = _b, rule = __objRest(_b, ["trigger"]);
|
|
7349
|
+
return rule;
|
|
7350
|
+
});
|
|
7351
|
+
};
|
|
7352
|
+
const onValidateSuccess = () => {
|
|
7353
|
+
validateState.value = "success";
|
|
7354
|
+
validateMessage.value = "";
|
|
7355
|
+
};
|
|
7356
|
+
const onValidateError = ({ errors }) => {
|
|
7357
|
+
var _a;
|
|
7358
|
+
validateState.value = "error";
|
|
7359
|
+
validateMessage.value = ((_a = errors == null ? void 0 : errors[0]) == null ? void 0 : _a.message) || "";
|
|
7360
|
+
};
|
|
7361
|
+
const execValidate = async (rules2) => {
|
|
7362
|
+
const ruleName = computedField.value;
|
|
7363
|
+
const validator = new Schema({
|
|
7364
|
+
[ruleName]: rules2
|
|
7365
|
+
});
|
|
7366
|
+
return validator.validate({ [ruleName]: fieldValue.value }, { firstFields: true }).then(() => {
|
|
7367
|
+
onValidateSuccess();
|
|
7368
|
+
return true;
|
|
7369
|
+
}).catch((error) => {
|
|
7370
|
+
onValidateError(error);
|
|
7371
|
+
return Promise.reject(error);
|
|
7372
|
+
});
|
|
7373
|
+
};
|
|
7374
|
+
const validate = async (trigger, callback) => {
|
|
7375
|
+
const rules2 = getRuleByTrigger(trigger);
|
|
7376
|
+
if (!rules2.length) {
|
|
7377
|
+
callback == null ? void 0 : callback(true);
|
|
7378
|
+
return true;
|
|
7379
|
+
}
|
|
7380
|
+
validateState.value = "pending";
|
|
7381
|
+
return execValidate(rules2).then(() => {
|
|
7382
|
+
callback == null ? void 0 : callback(true);
|
|
7383
|
+
return true;
|
|
7384
|
+
}).catch((error) => {
|
|
7385
|
+
const { fields } = error;
|
|
7386
|
+
callback == null ? void 0 : callback(false, fields);
|
|
7387
|
+
return lodash.exports.isFunction(callback) ? false : Promise.reject(fields);
|
|
7388
|
+
});
|
|
7389
|
+
};
|
|
7390
|
+
return { validateState, validateMessage, validate };
|
|
7391
|
+
}
|
|
7273
7392
|
var formItem = "";
|
|
7274
7393
|
var FormItem = defineComponent({
|
|
7275
7394
|
name: "DFormItem",
|
|
7276
7395
|
props: formItemProps,
|
|
7277
|
-
setup(props,
|
|
7278
|
-
const
|
|
7279
|
-
const
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
const
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
const
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
resetField
|
|
7297
|
-
});
|
|
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
|
-
};
|
|
7396
|
+
setup(props, ctx) {
|
|
7397
|
+
const formContext = inject(FORM_TOKEN);
|
|
7398
|
+
const {
|
|
7399
|
+
itemClasses
|
|
7400
|
+
} = useFormItem();
|
|
7401
|
+
const {
|
|
7402
|
+
_rules
|
|
7403
|
+
} = useFormItemRule(props);
|
|
7404
|
+
const {
|
|
7405
|
+
validateState,
|
|
7406
|
+
validateMessage,
|
|
7407
|
+
validate
|
|
7408
|
+
} = useFormItemValidate(props, _rules);
|
|
7409
|
+
const context = reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
|
|
7410
|
+
validateState,
|
|
7411
|
+
validateMessage,
|
|
7412
|
+
validate
|
|
7413
|
+
}));
|
|
7414
|
+
provide(FORM_ITEM_TOKEN, context);
|
|
7352
7415
|
onMounted(() => {
|
|
7353
|
-
|
|
7354
|
-
|
|
7416
|
+
if (props.field) {
|
|
7417
|
+
formContext == null ? void 0 : formContext.addItemContext(context);
|
|
7418
|
+
}
|
|
7355
7419
|
});
|
|
7356
7420
|
onBeforeUnmount(() => {
|
|
7357
|
-
|
|
7358
|
-
removeValidateEvents();
|
|
7421
|
+
formContext == null ? void 0 : formContext.removeItemContext(context);
|
|
7359
7422
|
});
|
|
7360
7423
|
return () => {
|
|
7361
7424
|
var _a, _b;
|
|
7362
7425
|
return createVNode("div", {
|
|
7363
|
-
"class":
|
|
7364
|
-
}, [(_b = (_a =
|
|
7365
|
-
"class": `devui-validate-tip${isHorizontal ? " devui-validate-tip-horizontal" : ""}`
|
|
7366
|
-
}, [showMessage.value && tipMessage.value])]);
|
|
7426
|
+
"class": itemClasses.value
|
|
7427
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
7367
7428
|
};
|
|
7368
7429
|
}
|
|
7369
7430
|
});
|
|
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;
|
|
7431
|
+
const formControlProps = {
|
|
7432
|
+
feedbackStatus: {
|
|
7433
|
+
type: String
|
|
7418
7434
|
},
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7435
|
+
extraInfo: {
|
|
7436
|
+
type: String,
|
|
7437
|
+
default: ""
|
|
7422
7438
|
}
|
|
7423
7439
|
};
|
|
7440
|
+
function useFormControl(props) {
|
|
7441
|
+
const formContext = inject(FORM_TOKEN);
|
|
7442
|
+
const labelData = reactive(formContext.labelData);
|
|
7443
|
+
const ns = useNamespace("form");
|
|
7444
|
+
const { feedbackStatus } = toRefs(props);
|
|
7445
|
+
const controlClasses = computed(() => ({
|
|
7446
|
+
[`${ns.e("control")}`]: true,
|
|
7447
|
+
[`${ns.em("control", "horizontal")}`]: labelData.layout === "horizontal"
|
|
7448
|
+
}));
|
|
7449
|
+
const controlContainerClasses = computed(() => ({
|
|
7450
|
+
[`${ns.e("control-container")}`]: true,
|
|
7451
|
+
[`${ns.em("control-container", "horizontal")}`]: labelData.layout === "horizontal",
|
|
7452
|
+
[`${ns.em("control-container", "has-feedback")}`]: Boolean(feedbackStatus.value),
|
|
7453
|
+
[`${ns.em("control-container", "feedback-error")}`]: Boolean(feedbackStatus.value === "error")
|
|
7454
|
+
}));
|
|
7455
|
+
return { controlClasses, controlContainerClasses };
|
|
7456
|
+
}
|
|
7457
|
+
function useFormControlValidate() {
|
|
7458
|
+
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
7459
|
+
const errorMessage = computed(() => formItemContext.validateMessage);
|
|
7460
|
+
return { errorMessage };
|
|
7461
|
+
}
|
|
7424
7462
|
var formControl = "";
|
|
7425
7463
|
var FormControl = defineComponent({
|
|
7426
7464
|
name: "DFormControl",
|
|
7427
|
-
directives: {
|
|
7428
|
-
clickoutside: clickoutsideDirective
|
|
7429
|
-
},
|
|
7430
7465
|
props: formControlProps,
|
|
7431
|
-
setup(props,
|
|
7466
|
+
setup(props, ctx) {
|
|
7432
7467
|
const formControl2 = ref();
|
|
7433
|
-
const dForm = reactive(inject(formInjectionKey, {}));
|
|
7434
|
-
const labelData = reactive(dForm.labelData);
|
|
7435
|
-
const isHorizontal = labelData.layout === "horizontal";
|
|
7436
7468
|
const uid = lodash.exports.uniqueId("dfc-");
|
|
7437
|
-
const
|
|
7438
|
-
const
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
};
|
|
7445
|
-
let elOffset = {
|
|
7446
|
-
left: 0,
|
|
7447
|
-
top: 0
|
|
7448
|
-
};
|
|
7449
|
-
let popoverLeftPosition = 0;
|
|
7450
|
-
let popoverTopPosition = 0;
|
|
7451
|
-
onMounted(() => {
|
|
7452
|
-
const el = document.getElementById(uid);
|
|
7453
|
-
elOffset = getElOffset(el);
|
|
7454
|
-
EventBus.on("showPopoverErrorMessage", (data) => {
|
|
7455
|
-
var _a;
|
|
7456
|
-
if (uid === data.uid) {
|
|
7457
|
-
rectInfo = el.getBoundingClientRect();
|
|
7458
|
-
showPopover.value = data.showPopover;
|
|
7459
|
-
tipMessage.value = data.message;
|
|
7460
|
-
popPosition.value = data.popPosition;
|
|
7461
|
-
popoverLeftPosition = popPosition.value === "top" || popPosition.value === "bottom" ? rectInfo.right - rectInfo.width / 2 : rectInfo.right;
|
|
7462
|
-
popoverTopPosition = popPosition.value === "top" ? elOffset.top + rectInfo.height / 2 - rectInfo.height : elOffset.top + rectInfo.height / 2;
|
|
7463
|
-
updateOn.value = (_a = data.updateOn) != null ? _a : "change";
|
|
7464
|
-
}
|
|
7465
|
-
});
|
|
7466
|
-
});
|
|
7467
|
-
const iconData = computed(() => {
|
|
7468
|
-
switch (props.feedbackStatus) {
|
|
7469
|
-
case "pending":
|
|
7470
|
-
return {
|
|
7471
|
-
name: "priority",
|
|
7472
|
-
color: "#e9edfa"
|
|
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
|
-
};
|
|
7469
|
+
const ns = useNamespace("form");
|
|
7470
|
+
const {
|
|
7471
|
+
controlClasses,
|
|
7472
|
+
controlContainerClasses
|
|
7473
|
+
} = useFormControl(props);
|
|
7474
|
+
const {
|
|
7475
|
+
errorMessage
|
|
7476
|
+
} = useFormControlValidate();
|
|
7496
7477
|
return () => {
|
|
7497
|
-
var _a, _b
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
extraInfo
|
|
7501
|
-
} = props;
|
|
7502
|
-
return withDirectives(createVNode("div", {
|
|
7503
|
-
"class": "devui-form-control",
|
|
7478
|
+
var _a, _b;
|
|
7479
|
+
return createVNode("div", {
|
|
7480
|
+
"class": controlClasses.value,
|
|
7504
7481
|
"ref": formControl2,
|
|
7505
7482
|
"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
7483
|
}, [createVNode("div", {
|
|
7527
|
-
"class":
|
|
7484
|
+
"class": controlContainerClasses.value
|
|
7485
|
+
}, [createVNode("div", {
|
|
7486
|
+
"class": ns.e("control-content"),
|
|
7528
7487
|
"id": uid
|
|
7529
|
-
}, [(_b = (_a =
|
|
7530
|
-
"class": "
|
|
7531
|
-
}, [
|
|
7532
|
-
"
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
}, [extraInfo])]), [[resolveDirective("clickoutside"), handleClickOutside]]);
|
|
7488
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])]), createVNode("div", {
|
|
7489
|
+
"class": ns.e("control-info")
|
|
7490
|
+
}, [errorMessage.value && createVNode("div", {
|
|
7491
|
+
"class": "error-message"
|
|
7492
|
+
}, [errorMessage.value]), props.extraInfo && createVNode("div", {
|
|
7493
|
+
"class": ns.e("control-extra")
|
|
7494
|
+
}, [props.extraInfo])])]);
|
|
7537
7495
|
};
|
|
7538
7496
|
}
|
|
7539
7497
|
});
|
|
7540
7498
|
var formOperation = "";
|
|
7541
7499
|
var FormOperation = defineComponent({
|
|
7542
7500
|
name: "DFormOperation",
|
|
7543
|
-
props
|
|
7544
|
-
|
|
7501
|
+
setup(props, ctx) {
|
|
7502
|
+
const formContext = reactive(inject(FORM_TOKEN));
|
|
7503
|
+
const labelData = reactive(formContext.labelData);
|
|
7504
|
+
const LabelSizeMap = {
|
|
7505
|
+
sm: 80,
|
|
7506
|
+
md: 100,
|
|
7507
|
+
lg: 150
|
|
7508
|
+
};
|
|
7509
|
+
const styles = computed(() => ({
|
|
7510
|
+
marginLeft: labelData.layout === "horizontal" ? `${LabelSizeMap[labelData.labelSize] + 16}px` : void 0
|
|
7511
|
+
}));
|
|
7545
7512
|
return () => {
|
|
7546
7513
|
var _a, _b;
|
|
7547
7514
|
return createVNode("div", {
|
|
7548
|
-
"class": "devui-form-operation"
|
|
7549
|
-
|
|
7515
|
+
"class": "devui-form-operation",
|
|
7516
|
+
"style": styles.value
|
|
7517
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
7550
7518
|
};
|
|
7551
7519
|
}
|
|
7552
7520
|
});
|
|
@@ -7692,7 +7660,16 @@ function getFormControlUID(el) {
|
|
|
7692
7660
|
getFormControlUID(el.parentElement);
|
|
7693
7661
|
}
|
|
7694
7662
|
}
|
|
7695
|
-
function handleValidateError({
|
|
7663
|
+
function handleValidateError({
|
|
7664
|
+
el,
|
|
7665
|
+
tipEl,
|
|
7666
|
+
message = "",
|
|
7667
|
+
isFormTag,
|
|
7668
|
+
messageShowType,
|
|
7669
|
+
dfcUID,
|
|
7670
|
+
popPosition = "right-bottom",
|
|
7671
|
+
updateOn
|
|
7672
|
+
}) {
|
|
7696
7673
|
if (isFormTag && messageShowType === "toast") {
|
|
7697
7674
|
alert(message);
|
|
7698
7675
|
return;
|
|
@@ -7701,7 +7678,13 @@ function handleValidateError({ el, tipEl, message = "", isFormTag, messageShowTy
|
|
|
7701
7678
|
dfcUID = getFormControlUID(el);
|
|
7702
7679
|
}
|
|
7703
7680
|
if (messageShowType === "popover") {
|
|
7704
|
-
EventBus.emit("showPopoverErrorMessage", {
|
|
7681
|
+
EventBus.emit("showPopoverErrorMessage", {
|
|
7682
|
+
showPopover: true,
|
|
7683
|
+
message,
|
|
7684
|
+
uid: dfcUID,
|
|
7685
|
+
popPosition,
|
|
7686
|
+
updateOn
|
|
7687
|
+
});
|
|
7705
7688
|
return;
|
|
7706
7689
|
}
|
|
7707
7690
|
tipEl.innerText = "" + message;
|
|
@@ -7723,7 +7706,17 @@ function getFormName(binding) {
|
|
|
7723
7706
|
const key = Object.keys(_refs)[0];
|
|
7724
7707
|
return _refs[key]["name"];
|
|
7725
7708
|
}
|
|
7726
|
-
function validateFn({
|
|
7709
|
+
function validateFn({
|
|
7710
|
+
validator,
|
|
7711
|
+
modelValue,
|
|
7712
|
+
el,
|
|
7713
|
+
tipEl,
|
|
7714
|
+
isFormTag,
|
|
7715
|
+
messageShowType,
|
|
7716
|
+
dfcUID,
|
|
7717
|
+
popPosition,
|
|
7718
|
+
updateOn
|
|
7719
|
+
}) {
|
|
7727
7720
|
validator.validate({ modelName: modelValue }).then(() => {
|
|
7728
7721
|
handleValidatePass(el, tipEl);
|
|
7729
7722
|
}).catch((err) => {
|
|
@@ -7741,7 +7734,20 @@ function validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowTy
|
|
|
7741
7734
|
});
|
|
7742
7735
|
}
|
|
7743
7736
|
function checkValidPopsition(positionStr) {
|
|
7744
|
-
const validPosition = [
|
|
7737
|
+
const validPosition = [
|
|
7738
|
+
"left",
|
|
7739
|
+
"right",
|
|
7740
|
+
"top",
|
|
7741
|
+
"bottom",
|
|
7742
|
+
"left-top",
|
|
7743
|
+
"left-bottom",
|
|
7744
|
+
"top-left",
|
|
7745
|
+
"top-right",
|
|
7746
|
+
"right-top",
|
|
7747
|
+
"right-bottom",
|
|
7748
|
+
"bottom-left",
|
|
7749
|
+
"bottom-right"
|
|
7750
|
+
];
|
|
7745
7751
|
const isValid = validPosition.includes(positionStr);
|
|
7746
7752
|
!isValid && console.warn(`invalid popPosition value '${positionStr}'.`);
|
|
7747
7753
|
return isValid;
|
|
@@ -7753,11 +7759,7 @@ var dValidateRules = {
|
|
|
7753
7759
|
const dfcUID = el.parentNode.parentNode.parentElement.dataset.uid;
|
|
7754
7760
|
const refName = getRefName(binding);
|
|
7755
7761
|
const hasOptions = isObject(binding.value) && hasKey(binding.value, "options");
|
|
7756
|
-
let {
|
|
7757
|
-
rules: bindingRules,
|
|
7758
|
-
options = {},
|
|
7759
|
-
messageShowType = "popover"
|
|
7760
|
-
} = binding.value;
|
|
7762
|
+
let { rules: bindingRules, options = {}, messageShowType = "popover" } = binding.value;
|
|
7761
7763
|
let { errorStrategy } = binding.value;
|
|
7762
7764
|
if (refName) {
|
|
7763
7765
|
messageShowType = (_a = binding.instance[refName]["messageShowType"]) != null ? _a : "popover";
|
|
@@ -7836,7 +7838,13 @@ var dValidateRules = {
|
|
|
7836
7838
|
const htmlEventValidateHandler = (e) => {
|
|
7837
7839
|
const modelValue = e.target.value;
|
|
7838
7840
|
if (messageShowType === "popover") {
|
|
7839
|
-
EventBus.emit("showPopoverErrorMessage", {
|
|
7841
|
+
EventBus.emit("showPopoverErrorMessage", {
|
|
7842
|
+
showPopover: false,
|
|
7843
|
+
message: "",
|
|
7844
|
+
uid: dfcUID,
|
|
7845
|
+
popPosition,
|
|
7846
|
+
updateOn
|
|
7847
|
+
});
|
|
7840
7848
|
}
|
|
7841
7849
|
validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition, updateOn });
|
|
7842
7850
|
};
|
|
@@ -7857,32 +7865,17 @@ var dValidateRules = {
|
|
|
7857
7865
|
});
|
|
7858
7866
|
}
|
|
7859
7867
|
};
|
|
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
7868
|
var index = {
|
|
7877
7869
|
title: "Form \u8868\u5355",
|
|
7878
7870
|
category: "\u6570\u636E\u5F55\u5165",
|
|
7879
7871
|
status: "75%",
|
|
7880
7872
|
install(app) {
|
|
7881
|
-
app.
|
|
7882
|
-
app.
|
|
7883
|
-
app.
|
|
7884
|
-
app.
|
|
7885
|
-
app.
|
|
7873
|
+
app.component(Form.name, Form);
|
|
7874
|
+
app.directive("d-validate-rules", dValidateRules);
|
|
7875
|
+
app.component(FormLabel.name, FormLabel);
|
|
7876
|
+
app.component(FormItem.name, FormItem);
|
|
7877
|
+
app.component(FormControl.name, FormControl);
|
|
7878
|
+
app.component(FormOperation.name, FormOperation);
|
|
7886
7879
|
}
|
|
7887
7880
|
};
|
|
7888
7881
|
export { Form, FormControl, FormItem, FormLabel, FormOperation, index as default };
|