vue-devui 1.0.0-rc.6 → 1.0.0-rc.7
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 +2 -0
- package/auto-complete/style.css +1 -1
- package/badge/index.es.js +2 -1
- package/badge/index.umd.js +1 -1
- package/button/index.es.js +3 -2
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/card/index.es.js +35 -29
- package/card/index.umd.js +1 -1
- package/card/style.css +1 -1
- package/checkbox/index.es.js +1 -1
- package/checkbox/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/drawer/style.css +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 +113 -483
- package/form/index.umd.js +18 -18
- package/form/style.css +1 -1
- package/fullscreen/index.es.js +1 -1
- package/fullscreen/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/input/style.css +1 -1
- package/loading/style.css +1 -1
- package/modal/style.css +1 -1
- package/notification/style.css +1 -1
- 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/formControlProps.js +3 -0
- package/nuxt/components/formItemProps.js +3 -0
- package/nuxt/components/formProps.js +3 -0
- package/overlay/style.css +1 -1
- package/package.json +1 -1
- package/pagination/index.es.js +80 -96
- package/pagination/index.umd.js +1 -1
- package/pagination/style.css +1 -1
- package/popover/style.css +1 -1
- package/progress/index.es.js +48 -14
- package/progress/index.umd.js +3 -3
- package/progress/style.css +1 -1
- package/rate/index.es.js +3 -3
- package/rate/index.umd.js +1 -1
- package/rate/style.css +1 -1
- package/search/index.es.js +2 -0
- package/search/index.umd.js +2 -2
- package/search/style.css +1 -1
- package/select/style.css +1 -1
- package/splitter/style.css +1 -1
- package/style.css +1 -1
- package/table/index.es.js +3 -2
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/style.css +1 -1
- package/textarea/style.css +1 -1
- package/tooltip/style.css +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +409 -1078
- package/vue-devui.umd.js +20 -20
- package/comment/index.d.ts +0 -7
- package/comment/index.es.js +0 -84
- package/comment/index.umd.js +0 -1
- package/comment/package.json +0 -7
- package/comment/style.css +0 -1
- package/nuxt/components/Comment.js +0 -3
- package/nuxt/components/ReadTip.js +0 -3
- package/nuxt/components/commentProps.js +0 -3
- package/nuxt/components/readTipProps.js +0 -3
- package/read-tip/index.d.ts +0 -7
- package/read-tip/index.es.js +0 -261
- package/read-tip/index.umd.js +0 -1
- package/read-tip/package.json +0 -7
- package/read-tip/style.css +0 -1
package/form/index.es.js
CHANGED
|
@@ -29,24 +29,8 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
import { defineComponent,
|
|
32
|
+
import { defineComponent, provide, reactive, toRefs, createVNode, Teleport, Transition, renderSlot, isVNode, computed, onMounted, watch, onUnmounted, ref, unref, nextTick, mergeProps, Fragment, inject, onBeforeUnmount } from "vue";
|
|
33
33
|
import { offset, autoPlacement, arrow, shift, computePosition } from "@floating-ui/dom";
|
|
34
|
-
function mitt(n) {
|
|
35
|
-
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
36
|
-
var i = n.get(t);
|
|
37
|
-
i ? i.push(e) : n.set(t, [e]);
|
|
38
|
-
}, off: function(t, e) {
|
|
39
|
-
var i = n.get(t);
|
|
40
|
-
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
41
|
-
}, emit: function(t, e) {
|
|
42
|
-
var i = n.get(t);
|
|
43
|
-
i && i.slice().map(function(n2) {
|
|
44
|
-
n2(e);
|
|
45
|
-
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
46
|
-
n2(t, e);
|
|
47
|
-
});
|
|
48
|
-
} };
|
|
49
|
-
}
|
|
50
34
|
const formProps = {
|
|
51
35
|
data: {
|
|
52
36
|
type: Object,
|
|
@@ -67,27 +51,16 @@ const formProps = {
|
|
|
67
51
|
rules: {
|
|
68
52
|
type: Object
|
|
69
53
|
},
|
|
70
|
-
|
|
54
|
+
messageType: {
|
|
71
55
|
type: String,
|
|
72
56
|
default: "popover"
|
|
57
|
+
},
|
|
58
|
+
popPosition: {
|
|
59
|
+
type: Array,
|
|
60
|
+
default: ["right", "bottom"]
|
|
73
61
|
}
|
|
74
62
|
};
|
|
75
|
-
const dFormEvents = {
|
|
76
|
-
addField: "d.form.addField",
|
|
77
|
-
removeField: "d.form.removeField"
|
|
78
|
-
};
|
|
79
63
|
const FORM_TOKEN = Symbol("dForm");
|
|
80
|
-
var eventBus = mitt();
|
|
81
|
-
const EventBus = eventBus;
|
|
82
|
-
function isObject(obj) {
|
|
83
|
-
return Object.prototype.toString.call(obj).slice(8, -1) === "Object";
|
|
84
|
-
}
|
|
85
|
-
function hasKey(obj, key) {
|
|
86
|
-
if (!isObject(obj)) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
90
|
-
}
|
|
91
64
|
function createBem(namespace, element, modifier) {
|
|
92
65
|
let cls = namespace;
|
|
93
66
|
if (element) {
|
|
@@ -863,7 +836,7 @@ var lodash = { exports: {} };
|
|
|
863
836
|
function object4() {
|
|
864
837
|
}
|
|
865
838
|
return function(proto) {
|
|
866
|
-
if (!
|
|
839
|
+
if (!isObject(proto)) {
|
|
867
840
|
return {};
|
|
868
841
|
}
|
|
869
842
|
if (objectCreate) {
|
|
@@ -1225,7 +1198,7 @@ var lodash = { exports: {} };
|
|
|
1225
1198
|
if (result2 !== undefined$1) {
|
|
1226
1199
|
return result2;
|
|
1227
1200
|
}
|
|
1228
|
-
if (!
|
|
1201
|
+
if (!isObject(value)) {
|
|
1229
1202
|
return value;
|
|
1230
1203
|
}
|
|
1231
1204
|
var isArr = isArray(value);
|
|
@@ -1572,7 +1545,7 @@ var lodash = { exports: {} };
|
|
|
1572
1545
|
return true;
|
|
1573
1546
|
}
|
|
1574
1547
|
function baseIsNative(value) {
|
|
1575
|
-
if (!
|
|
1548
|
+
if (!isObject(value) || isMasked(value)) {
|
|
1576
1549
|
return false;
|
|
1577
1550
|
}
|
|
1578
1551
|
var pattern4 = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
@@ -1612,7 +1585,7 @@ var lodash = { exports: {} };
|
|
|
1612
1585
|
return result2;
|
|
1613
1586
|
}
|
|
1614
1587
|
function baseKeysIn(object4) {
|
|
1615
|
-
if (!
|
|
1588
|
+
if (!isObject(object4)) {
|
|
1616
1589
|
return nativeKeysIn(object4);
|
|
1617
1590
|
}
|
|
1618
1591
|
var isProto = isPrototype(object4), result2 = [];
|
|
@@ -1657,7 +1630,7 @@ var lodash = { exports: {} };
|
|
|
1657
1630
|
}
|
|
1658
1631
|
baseFor(source, function(srcValue, key) {
|
|
1659
1632
|
stack || (stack = new Stack());
|
|
1660
|
-
if (
|
|
1633
|
+
if (isObject(srcValue)) {
|
|
1661
1634
|
baseMergeDeep(object4, source, key, srcIndex, baseMerge, customizer, stack);
|
|
1662
1635
|
} else {
|
|
1663
1636
|
var newValue = customizer ? customizer(safeGet(object4, key), srcValue, key + "", object4, source, stack) : undefined$1;
|
|
@@ -1697,7 +1670,7 @@ var lodash = { exports: {} };
|
|
|
1697
1670
|
newValue = objValue;
|
|
1698
1671
|
if (isArguments(objValue)) {
|
|
1699
1672
|
newValue = toPlainObject(objValue);
|
|
1700
|
-
} else if (!
|
|
1673
|
+
} else if (!isObject(objValue) || isFunction(objValue)) {
|
|
1701
1674
|
newValue = initCloneObject(srcValue);
|
|
1702
1675
|
}
|
|
1703
1676
|
} else {
|
|
@@ -1836,7 +1809,7 @@ var lodash = { exports: {} };
|
|
|
1836
1809
|
return shuffleSelf(array4, baseClamp(n, 0, array4.length));
|
|
1837
1810
|
}
|
|
1838
1811
|
function baseSet(object4, path, value, customizer) {
|
|
1839
|
-
if (!
|
|
1812
|
+
if (!isObject(object4)) {
|
|
1840
1813
|
return object4;
|
|
1841
1814
|
}
|
|
1842
1815
|
path = castPath(path, object4);
|
|
@@ -1850,7 +1823,7 @@ var lodash = { exports: {} };
|
|
|
1850
1823
|
var objValue = nested[key];
|
|
1851
1824
|
newValue = customizer ? customizer(objValue, key, nested) : undefined$1;
|
|
1852
1825
|
if (newValue === undefined$1) {
|
|
1853
|
-
newValue =
|
|
1826
|
+
newValue = isObject(objValue) ? objValue : isIndex(path[index2 + 1]) ? [] : {};
|
|
1854
1827
|
}
|
|
1855
1828
|
}
|
|
1856
1829
|
assignValue(nested, key, newValue);
|
|
@@ -2300,7 +2273,7 @@ var lodash = { exports: {} };
|
|
|
2300
2273
|
return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
2301
2274
|
}
|
|
2302
2275
|
var thisBinding = baseCreate(Ctor.prototype), result2 = Ctor.apply(thisBinding, args);
|
|
2303
|
-
return
|
|
2276
|
+
return isObject(result2) ? result2 : thisBinding;
|
|
2304
2277
|
};
|
|
2305
2278
|
}
|
|
2306
2279
|
function createCurry(func, bitmask, arity) {
|
|
@@ -2614,7 +2587,7 @@ var lodash = { exports: {} };
|
|
|
2614
2587
|
return objValue;
|
|
2615
2588
|
}
|
|
2616
2589
|
function customDefaultsMerge(objValue, srcValue, key, object4, source, stack) {
|
|
2617
|
-
if (
|
|
2590
|
+
if (isObject(objValue) && isObject(srcValue)) {
|
|
2618
2591
|
stack.set(srcValue, objValue);
|
|
2619
2592
|
baseMerge(objValue, srcValue, undefined$1, customDefaultsMerge, stack);
|
|
2620
2593
|
stack["delete"](srcValue);
|
|
@@ -2962,7 +2935,7 @@ var lodash = { exports: {} };
|
|
|
2962
2935
|
return !!length && (type4 == "number" || type4 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
2963
2936
|
}
|
|
2964
2937
|
function isIterateeCall(value, index2, object4) {
|
|
2965
|
-
if (!
|
|
2938
|
+
if (!isObject(object4)) {
|
|
2966
2939
|
return false;
|
|
2967
2940
|
}
|
|
2968
2941
|
var type4 = typeof index2;
|
|
@@ -3005,7 +2978,7 @@ var lodash = { exports: {} };
|
|
|
3005
2978
|
return value === proto;
|
|
3006
2979
|
}
|
|
3007
2980
|
function isStrictComparable(value) {
|
|
3008
|
-
return value === value && !
|
|
2981
|
+
return value === value && !isObject(value);
|
|
3009
2982
|
}
|
|
3010
2983
|
function matchesStrictComparable(key, srcValue) {
|
|
3011
2984
|
return function(object4) {
|
|
@@ -3887,7 +3860,7 @@ var lodash = { exports: {} };
|
|
|
3887
3860
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
3888
3861
|
}
|
|
3889
3862
|
wait = toNumber(wait) || 0;
|
|
3890
|
-
if (
|
|
3863
|
+
if (isObject(options)) {
|
|
3891
3864
|
leading = !!options.leading;
|
|
3892
3865
|
maxing = "maxWait" in options;
|
|
3893
3866
|
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
@@ -4057,7 +4030,7 @@ var lodash = { exports: {} };
|
|
|
4057
4030
|
if (typeof func != "function") {
|
|
4058
4031
|
throw new TypeError2(FUNC_ERROR_TEXT);
|
|
4059
4032
|
}
|
|
4060
|
-
if (
|
|
4033
|
+
if (isObject(options)) {
|
|
4061
4034
|
leading = "leading" in options ? !!options.leading : leading;
|
|
4062
4035
|
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
4063
4036
|
}
|
|
@@ -4165,7 +4138,7 @@ var lodash = { exports: {} };
|
|
|
4165
4138
|
return typeof value == "number" && nativeIsFinite(value);
|
|
4166
4139
|
}
|
|
4167
4140
|
function isFunction(value) {
|
|
4168
|
-
if (!
|
|
4141
|
+
if (!isObject(value)) {
|
|
4169
4142
|
return false;
|
|
4170
4143
|
}
|
|
4171
4144
|
var tag = baseGetTag(value);
|
|
@@ -4177,7 +4150,7 @@ var lodash = { exports: {} };
|
|
|
4177
4150
|
function isLength(value) {
|
|
4178
4151
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
4179
4152
|
}
|
|
4180
|
-
function
|
|
4153
|
+
function isObject(value) {
|
|
4181
4154
|
var type4 = typeof value;
|
|
4182
4155
|
return value != null && (type4 == "object" || type4 == "function");
|
|
4183
4156
|
}
|
|
@@ -4284,9 +4257,9 @@ var lodash = { exports: {} };
|
|
|
4284
4257
|
if (isSymbol(value)) {
|
|
4285
4258
|
return NAN;
|
|
4286
4259
|
}
|
|
4287
|
-
if (
|
|
4260
|
+
if (isObject(value)) {
|
|
4288
4261
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
4289
|
-
value =
|
|
4262
|
+
value = isObject(other) ? other + "" : other;
|
|
4290
4263
|
}
|
|
4291
4264
|
if (typeof value != "string") {
|
|
4292
4265
|
return value === 0 ? value : +value;
|
|
@@ -4507,7 +4480,7 @@ var lodash = { exports: {} };
|
|
|
4507
4480
|
var Ctor = object4 && object4.constructor;
|
|
4508
4481
|
if (isArrLike) {
|
|
4509
4482
|
accumulator = isArr ? new Ctor() : [];
|
|
4510
|
-
} else if (
|
|
4483
|
+
} else if (isObject(object4)) {
|
|
4511
4484
|
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object4)) : {};
|
|
4512
4485
|
} else {
|
|
4513
4486
|
accumulator = {};
|
|
@@ -4789,7 +4762,7 @@ var lodash = { exports: {} };
|
|
|
4789
4762
|
}
|
|
4790
4763
|
function truncate(string3, options) {
|
|
4791
4764
|
var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
|
|
4792
|
-
if (
|
|
4765
|
+
if (isObject(options)) {
|
|
4793
4766
|
var separator = "separator" in options ? options.separator : separator;
|
|
4794
4767
|
length = "length" in options ? toInteger(options.length) : length;
|
|
4795
4768
|
omission = "omission" in options ? baseToString(options.omission) : omission;
|
|
@@ -4919,13 +4892,13 @@ var lodash = { exports: {} };
|
|
|
4919
4892
|
});
|
|
4920
4893
|
function mixin(object4, source, options) {
|
|
4921
4894
|
var props = keys(source), methodNames = baseFunctions(source, props);
|
|
4922
|
-
if (options == null && !(
|
|
4895
|
+
if (options == null && !(isObject(source) && (methodNames.length || !props.length))) {
|
|
4923
4896
|
options = source;
|
|
4924
4897
|
source = object4;
|
|
4925
4898
|
object4 = this;
|
|
4926
4899
|
methodNames = baseFunctions(source, keys(source));
|
|
4927
4900
|
}
|
|
4928
|
-
var chain2 = !(
|
|
4901
|
+
var chain2 = !(isObject(options) && "chain" in options) || !!options.chain, isFunc = isFunction(object4);
|
|
4929
4902
|
arrayEach(methodNames, function(methodName) {
|
|
4930
4903
|
var func = source[methodName];
|
|
4931
4904
|
object4[methodName] = func;
|
|
@@ -5271,7 +5244,7 @@ var lodash = { exports: {} };
|
|
|
5271
5244
|
lodash2.isNil = isNil;
|
|
5272
5245
|
lodash2.isNull = isNull;
|
|
5273
5246
|
lodash2.isNumber = isNumber;
|
|
5274
|
-
lodash2.isObject =
|
|
5247
|
+
lodash2.isObject = isObject;
|
|
5275
5248
|
lodash2.isObjectLike = isObjectLike;
|
|
5276
5249
|
lodash2.isPlainObject = isPlainObject;
|
|
5277
5250
|
lodash2.isRegExp = isRegExp;
|
|
@@ -5582,16 +5555,8 @@ function useFormValidation(itemContexts) {
|
|
|
5582
5555
|
var Form = defineComponent({
|
|
5583
5556
|
name: "DForm",
|
|
5584
5557
|
props: formProps,
|
|
5585
|
-
emits: ["submit"],
|
|
5586
5558
|
setup(props, ctx) {
|
|
5587
|
-
const formMitt = mitt();
|
|
5588
5559
|
const ns = useNamespace("form");
|
|
5589
|
-
const {
|
|
5590
|
-
data,
|
|
5591
|
-
layout,
|
|
5592
|
-
labelSize,
|
|
5593
|
-
labelAlign
|
|
5594
|
-
} = toRefs(props);
|
|
5595
5560
|
const {
|
|
5596
5561
|
itemContexts,
|
|
5597
5562
|
addItemContext,
|
|
@@ -5601,34 +5566,17 @@ var Form = defineComponent({
|
|
|
5601
5566
|
validate,
|
|
5602
5567
|
validateFields
|
|
5603
5568
|
} = useFormValidation(itemContexts);
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
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",
|
|
5569
|
+
const onSubmit = (e) => {
|
|
5570
|
+
e.preventDefault();
|
|
5571
|
+
};
|
|
5572
|
+
provide(FORM_TOKEN, reactive(__spreadProps(__spreadValues({}, toRefs(props)), {
|
|
5620
5573
|
addItemContext,
|
|
5621
5574
|
removeItemContext
|
|
5622
|
-
}));
|
|
5575
|
+
})));
|
|
5623
5576
|
ctx.expose({
|
|
5624
5577
|
validate,
|
|
5625
5578
|
validateFields
|
|
5626
5579
|
});
|
|
5627
|
-
const onSubmit = (e) => {
|
|
5628
|
-
e.preventDefault();
|
|
5629
|
-
ctx.emit("submit", e);
|
|
5630
|
-
EventBus.emit(`formSubmit:${props.name}`);
|
|
5631
|
-
};
|
|
5632
5580
|
return () => {
|
|
5633
5581
|
var _a, _b;
|
|
5634
5582
|
return createVNode("form", {
|
|
@@ -5809,8 +5757,8 @@ const flexibleOverlayProps = {
|
|
|
5809
5757
|
function getScrollParent(element) {
|
|
5810
5758
|
const overflowRegex = /(auto|scroll|hidden)/;
|
|
5811
5759
|
for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
|
|
5812
|
-
const
|
|
5813
|
-
if (overflowRegex.test(
|
|
5760
|
+
const style = window.getComputedStyle(parent);
|
|
5761
|
+
if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
5814
5762
|
return parent;
|
|
5815
5763
|
}
|
|
5816
5764
|
}
|
|
@@ -6241,23 +6189,30 @@ const formItemProps = {
|
|
|
6241
6189
|
type: Boolean,
|
|
6242
6190
|
default: false
|
|
6243
6191
|
},
|
|
6192
|
+
messageType: {
|
|
6193
|
+
type: String
|
|
6194
|
+
},
|
|
6195
|
+
popPosition: {
|
|
6196
|
+
type: Array
|
|
6197
|
+
},
|
|
6244
6198
|
rules: {
|
|
6245
6199
|
type: [Object, Array]
|
|
6246
6200
|
}
|
|
6247
6201
|
};
|
|
6248
6202
|
const FORM_ITEM_TOKEN = Symbol("dFormItem");
|
|
6249
6203
|
function useFormLabel() {
|
|
6250
|
-
const
|
|
6204
|
+
const formContext = inject(FORM_TOKEN);
|
|
6251
6205
|
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
6252
6206
|
const ns = useNamespace("form");
|
|
6253
6207
|
const labelClasses = computed(() => ({
|
|
6254
6208
|
[`${ns.e("label")}`]: true,
|
|
6255
|
-
[`${ns.em("label", "vertical")}`]:
|
|
6256
|
-
[`${ns.em("label",
|
|
6257
|
-
[`${ns.em("label",
|
|
6209
|
+
[`${ns.em("label", "vertical")}`]: formContext.layout === "vertical",
|
|
6210
|
+
[`${ns.em("label", formContext.labelSize)}`]: formContext.layout === "horizontal",
|
|
6211
|
+
[`${ns.em("label", formContext.labelAlign)}`]: formContext.layout === "horizontal"
|
|
6258
6212
|
}));
|
|
6259
6213
|
const labelInnerClasses = computed(() => ({
|
|
6260
|
-
[`${ns.
|
|
6214
|
+
[`${ns.e("label-span")}`]: true,
|
|
6215
|
+
[`${ns.em("label", "required")}`]: formItemContext.isRequired
|
|
6261
6216
|
}));
|
|
6262
6217
|
return { labelClasses, labelInnerClasses };
|
|
6263
6218
|
}
|
|
@@ -7292,15 +7247,16 @@ Schema.register = function register(type4, validator) {
|
|
|
7292
7247
|
Schema.warning = warning;
|
|
7293
7248
|
Schema.messages = messages;
|
|
7294
7249
|
Schema.validators = validators;
|
|
7295
|
-
function useFormItem() {
|
|
7296
|
-
const formContext =
|
|
7297
|
-
const labelData = reactive(formContext.labelData);
|
|
7250
|
+
function useFormItem(messageType, _rules, validateState) {
|
|
7251
|
+
const formContext = inject(FORM_TOKEN);
|
|
7298
7252
|
const ns = useNamespace("form");
|
|
7299
7253
|
const itemClasses = computed(() => ({
|
|
7300
|
-
[`${ns.em("item", "horizontal")}`]:
|
|
7301
|
-
[`${ns.em("item", "vertical")}`]:
|
|
7254
|
+
[`${ns.em("item", "horizontal")}`]: formContext.layout === "horizontal",
|
|
7255
|
+
[`${ns.em("item", "vertical")}`]: formContext.layout === "vertical",
|
|
7256
|
+
[`${ns.em("item", "error")}`]: messageType.value === "text" && validateState.value === "error"
|
|
7302
7257
|
}));
|
|
7303
|
-
|
|
7258
|
+
const isRequired = computed(() => _rules.value.some((rule) => Boolean(rule.required)));
|
|
7259
|
+
return { itemClasses, isRequired };
|
|
7304
7260
|
}
|
|
7305
7261
|
function useFormItemRule(props) {
|
|
7306
7262
|
const formContext = inject(FORM_TOKEN);
|
|
@@ -7328,7 +7284,7 @@ function useFormItemValidate(props, _rules) {
|
|
|
7328
7284
|
return typeof props.field === "string" ? props.field : "";
|
|
7329
7285
|
});
|
|
7330
7286
|
const fieldValue = computed(() => {
|
|
7331
|
-
const formData = formContext.
|
|
7287
|
+
const formData = formContext.data;
|
|
7332
7288
|
if (!formData || !props.field) {
|
|
7333
7289
|
return;
|
|
7334
7290
|
}
|
|
@@ -7395,9 +7351,15 @@ var FormItem = defineComponent({
|
|
|
7395
7351
|
props: formItemProps,
|
|
7396
7352
|
setup(props, ctx) {
|
|
7397
7353
|
const formContext = inject(FORM_TOKEN);
|
|
7398
|
-
const {
|
|
7399
|
-
|
|
7400
|
-
|
|
7354
|
+
const _a = toRefs(props), {
|
|
7355
|
+
messageType: itemMessageType,
|
|
7356
|
+
popPosition: itemPopPosition
|
|
7357
|
+
} = _a, otherProps = __objRest(_a, [
|
|
7358
|
+
"messageType",
|
|
7359
|
+
"popPosition"
|
|
7360
|
+
]);
|
|
7361
|
+
const messageType = computed(() => (itemMessageType == null ? void 0 : itemMessageType.value) || formContext.messageType);
|
|
7362
|
+
const popPosition = computed(() => (itemPopPosition == null ? void 0 : itemPopPosition.value) || formContext.popPosition);
|
|
7401
7363
|
const {
|
|
7402
7364
|
_rules
|
|
7403
7365
|
} = useFormItemRule(props);
|
|
@@ -7406,7 +7368,14 @@ var FormItem = defineComponent({
|
|
|
7406
7368
|
validateMessage,
|
|
7407
7369
|
validate
|
|
7408
7370
|
} = useFormItemValidate(props, _rules);
|
|
7409
|
-
const
|
|
7371
|
+
const {
|
|
7372
|
+
itemClasses,
|
|
7373
|
+
isRequired
|
|
7374
|
+
} = useFormItem(messageType, _rules, validateState);
|
|
7375
|
+
const context = reactive(__spreadProps(__spreadValues({}, otherProps), {
|
|
7376
|
+
messageType,
|
|
7377
|
+
popPosition,
|
|
7378
|
+
isRequired,
|
|
7410
7379
|
validateState,
|
|
7411
7380
|
validateMessage,
|
|
7412
7381
|
validate
|
|
@@ -7421,10 +7390,10 @@ var FormItem = defineComponent({
|
|
|
7421
7390
|
formContext == null ? void 0 : formContext.removeItemContext(context);
|
|
7422
7391
|
});
|
|
7423
7392
|
return () => {
|
|
7424
|
-
var
|
|
7393
|
+
var _a2, _b;
|
|
7425
7394
|
return createVNode("div", {
|
|
7426
7395
|
"class": itemClasses.value
|
|
7427
|
-
}, [(_b = (
|
|
7396
|
+
}, [(_b = (_a2 = ctx.slots).default) == null ? void 0 : _b.call(_a2)]);
|
|
7428
7397
|
};
|
|
7429
7398
|
}
|
|
7430
7399
|
});
|
|
@@ -7439,16 +7408,15 @@ const formControlProps = {
|
|
|
7439
7408
|
};
|
|
7440
7409
|
function useFormControl(props) {
|
|
7441
7410
|
const formContext = inject(FORM_TOKEN);
|
|
7442
|
-
const labelData = reactive(formContext.labelData);
|
|
7443
7411
|
const ns = useNamespace("form");
|
|
7444
7412
|
const { feedbackStatus } = toRefs(props);
|
|
7445
7413
|
const controlClasses = computed(() => ({
|
|
7446
7414
|
[`${ns.e("control")}`]: true,
|
|
7447
|
-
[`${ns.em("control", "horizontal")}`]:
|
|
7415
|
+
[`${ns.em("control", "horizontal")}`]: formContext.layout === "horizontal"
|
|
7448
7416
|
}));
|
|
7449
7417
|
const controlContainerClasses = computed(() => ({
|
|
7450
7418
|
[`${ns.e("control-container")}`]: true,
|
|
7451
|
-
[`${ns.em("control-container", "horizontal")}`]:
|
|
7419
|
+
[`${ns.em("control-container", "horizontal")}`]: formContext.layout === "horizontal",
|
|
7452
7420
|
[`${ns.em("control-container", "has-feedback")}`]: Boolean(feedbackStatus.value),
|
|
7453
7421
|
[`${ns.em("control-container", "feedback-error")}`]: Boolean(feedbackStatus.value === "error")
|
|
7454
7422
|
}));
|
|
@@ -7456,8 +7424,11 @@ function useFormControl(props) {
|
|
|
7456
7424
|
}
|
|
7457
7425
|
function useFormControlValidate() {
|
|
7458
7426
|
const formItemContext = inject(FORM_ITEM_TOKEN);
|
|
7427
|
+
const showPopover = computed(() => formItemContext.messageType === "popover" && formItemContext.validateState === "error");
|
|
7428
|
+
const showMessage = computed(() => formItemContext.messageType === "text" && formItemContext.validateState === "error");
|
|
7459
7429
|
const errorMessage = computed(() => formItemContext.validateMessage);
|
|
7460
|
-
|
|
7430
|
+
const popPosition = computed(() => formItemContext.popPosition);
|
|
7431
|
+
return { showPopover, showMessage, errorMessage, popPosition };
|
|
7461
7432
|
}
|
|
7462
7433
|
var formControl = "";
|
|
7463
7434
|
var FormControl = defineComponent({
|
|
@@ -7465,49 +7436,56 @@ var FormControl = defineComponent({
|
|
|
7465
7436
|
props: formControlProps,
|
|
7466
7437
|
setup(props, ctx) {
|
|
7467
7438
|
const formControl2 = ref();
|
|
7468
|
-
const uid = lodash.exports.uniqueId("dfc-");
|
|
7469
7439
|
const ns = useNamespace("form");
|
|
7470
7440
|
const {
|
|
7471
7441
|
controlClasses,
|
|
7472
7442
|
controlContainerClasses
|
|
7473
7443
|
} = useFormControl(props);
|
|
7474
7444
|
const {
|
|
7475
|
-
|
|
7445
|
+
showPopover,
|
|
7446
|
+
showMessage,
|
|
7447
|
+
errorMessage,
|
|
7448
|
+
popPosition
|
|
7476
7449
|
} = useFormControlValidate();
|
|
7477
|
-
return () => {
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
"
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
}
|
|
7495
|
-
}
|
|
7450
|
+
return () => createVNode("div", {
|
|
7451
|
+
"class": controlClasses.value,
|
|
7452
|
+
"ref": formControl2
|
|
7453
|
+
}, [createVNode("div", {
|
|
7454
|
+
"class": controlContainerClasses.value
|
|
7455
|
+
}, [createVNode(Popover, {
|
|
7456
|
+
"is-open": showPopover.value,
|
|
7457
|
+
"trigger": "manually",
|
|
7458
|
+
"content": errorMessage.value,
|
|
7459
|
+
"pop-type": "error",
|
|
7460
|
+
"position": popPosition.value
|
|
7461
|
+
}, {
|
|
7462
|
+
reference: () => {
|
|
7463
|
+
var _a, _b;
|
|
7464
|
+
return createVNode("div", {
|
|
7465
|
+
"class": ns.e("control-content")
|
|
7466
|
+
}, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)]);
|
|
7467
|
+
}
|
|
7468
|
+
})]), createVNode("div", {
|
|
7469
|
+
"class": ns.e("control-info")
|
|
7470
|
+
}, [showMessage.value && createVNode("div", {
|
|
7471
|
+
"class": "error-message"
|
|
7472
|
+
}, [errorMessage.value]), props.extraInfo && createVNode("div", {
|
|
7473
|
+
"class": ns.e("control-extra")
|
|
7474
|
+
}, [props.extraInfo])])]);
|
|
7496
7475
|
}
|
|
7497
7476
|
});
|
|
7498
7477
|
var formOperation = "";
|
|
7499
7478
|
var FormOperation = defineComponent({
|
|
7500
7479
|
name: "DFormOperation",
|
|
7501
7480
|
setup(props, ctx) {
|
|
7502
|
-
const formContext =
|
|
7503
|
-
const labelData = reactive(formContext.labelData);
|
|
7481
|
+
const formContext = inject(FORM_TOKEN);
|
|
7504
7482
|
const LabelSizeMap = {
|
|
7505
7483
|
sm: 80,
|
|
7506
7484
|
md: 100,
|
|
7507
7485
|
lg: 150
|
|
7508
7486
|
};
|
|
7509
7487
|
const styles = computed(() => ({
|
|
7510
|
-
marginLeft:
|
|
7488
|
+
marginLeft: formContext.layout === "horizontal" ? `${LabelSizeMap[formContext.labelSize] + 16}px` : void 0
|
|
7511
7489
|
}));
|
|
7512
7490
|
return () => {
|
|
7513
7491
|
var _a, _b;
|
|
@@ -7518,364 +7496,16 @@ var FormOperation = defineComponent({
|
|
|
7518
7496
|
};
|
|
7519
7497
|
}
|
|
7520
7498
|
});
|
|
7521
|
-
var style = "";
|
|
7522
|
-
function getAvaliableRuleObj(ruleName, value) {
|
|
7523
|
-
if (!ruleName) {
|
|
7524
|
-
console.error("[v-d-validate] validator's key is invalid");
|
|
7525
|
-
return null;
|
|
7526
|
-
}
|
|
7527
|
-
switch (ruleName) {
|
|
7528
|
-
case "maxlength":
|
|
7529
|
-
return {
|
|
7530
|
-
type: "string",
|
|
7531
|
-
max: value,
|
|
7532
|
-
asyncValidator: (rule, val) => {
|
|
7533
|
-
return new Promise((resolve, reject) => {
|
|
7534
|
-
if (val.length > value) {
|
|
7535
|
-
reject("\u6700\u5927\u957F\u5EA6\u4E3A" + value);
|
|
7536
|
-
} else {
|
|
7537
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7538
|
-
}
|
|
7539
|
-
});
|
|
7540
|
-
}
|
|
7541
|
-
};
|
|
7542
|
-
case "minlength":
|
|
7543
|
-
return {
|
|
7544
|
-
type: "string",
|
|
7545
|
-
min: value,
|
|
7546
|
-
asyncValidator: (rule, val) => {
|
|
7547
|
-
return new Promise((resolve, reject) => {
|
|
7548
|
-
if (val.length < value) {
|
|
7549
|
-
reject("\u6700\u5C0F\u957F\u5EA6\u4E3A" + value);
|
|
7550
|
-
} else {
|
|
7551
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7552
|
-
}
|
|
7553
|
-
});
|
|
7554
|
-
}
|
|
7555
|
-
};
|
|
7556
|
-
case "min":
|
|
7557
|
-
return {
|
|
7558
|
-
type: "number",
|
|
7559
|
-
asyncValidator: (rule, val) => {
|
|
7560
|
-
return new Promise((resolve, reject) => {
|
|
7561
|
-
if (val < value) {
|
|
7562
|
-
reject("\u6700\u5C0F\u503C\u4E3A" + value);
|
|
7563
|
-
} else {
|
|
7564
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7565
|
-
}
|
|
7566
|
-
});
|
|
7567
|
-
}
|
|
7568
|
-
};
|
|
7569
|
-
case "max":
|
|
7570
|
-
return {
|
|
7571
|
-
type: "number",
|
|
7572
|
-
asyncValidator: (rule, val) => {
|
|
7573
|
-
return new Promise((resolve, reject) => {
|
|
7574
|
-
if (val > value) {
|
|
7575
|
-
reject("\u6700\u5927\u503C\u4E3A" + value);
|
|
7576
|
-
} else {
|
|
7577
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7578
|
-
}
|
|
7579
|
-
});
|
|
7580
|
-
}
|
|
7581
|
-
};
|
|
7582
|
-
case "required":
|
|
7583
|
-
return {
|
|
7584
|
-
reqiured: true,
|
|
7585
|
-
asyncValidator: (rule, val) => {
|
|
7586
|
-
return new Promise((resolve, reject) => {
|
|
7587
|
-
if (!val) {
|
|
7588
|
-
reject("\u5FC5\u586B\u9879");
|
|
7589
|
-
} else {
|
|
7590
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7591
|
-
}
|
|
7592
|
-
});
|
|
7593
|
-
}
|
|
7594
|
-
};
|
|
7595
|
-
case "requiredTrue":
|
|
7596
|
-
return {
|
|
7597
|
-
asyncValidator: (rule, val) => {
|
|
7598
|
-
return new Promise((resolve, reject) => {
|
|
7599
|
-
if (!val) {
|
|
7600
|
-
reject("\u5FC5\u987B\u4E3Atrue\u503C");
|
|
7601
|
-
} else {
|
|
7602
|
-
resolve("\u6821\u9A8C\u901A\u8FC7");
|
|
7603
|
-
}
|
|
7604
|
-
});
|
|
7605
|
-
}
|
|
7606
|
-
};
|
|
7607
|
-
case "email":
|
|
7608
|
-
return {
|
|
7609
|
-
type: "email",
|
|
7610
|
-
message: "\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E"
|
|
7611
|
-
};
|
|
7612
|
-
case "pattern":
|
|
7613
|
-
return {
|
|
7614
|
-
type: "regexp",
|
|
7615
|
-
pattern: value,
|
|
7616
|
-
message: "\u53EA\u80FD\u5305\u542B\u6570\u5B57\u4E0E\u5927\u5C0F\u5199\u5B57\u7B26",
|
|
7617
|
-
validator: (rule, val) => value.test(val)
|
|
7618
|
-
};
|
|
7619
|
-
case "whitespace":
|
|
7620
|
-
return {
|
|
7621
|
-
message: "\u8F93\u5165\u4E0D\u80FD\u5168\u90E8\u4E3A\u7A7A\u683C\u6216\u7A7A\u5B57\u7B26",
|
|
7622
|
-
validator: (rule, val) => !!val.trim()
|
|
7623
|
-
};
|
|
7624
|
-
default:
|
|
7625
|
-
return {
|
|
7626
|
-
[ruleName]: value
|
|
7627
|
-
};
|
|
7628
|
-
}
|
|
7629
|
-
}
|
|
7630
|
-
function getKeyValueOfObjectList(obj) {
|
|
7631
|
-
const kvArr = [];
|
|
7632
|
-
for (const key in obj) {
|
|
7633
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
7634
|
-
kvArr.push({
|
|
7635
|
-
key,
|
|
7636
|
-
value: obj[key]
|
|
7637
|
-
});
|
|
7638
|
-
}
|
|
7639
|
-
}
|
|
7640
|
-
return kvArr;
|
|
7641
|
-
}
|
|
7642
|
-
function handleErrorStrategy(el) {
|
|
7643
|
-
const classList = [...el.classList];
|
|
7644
|
-
classList.push("devui-validate-rules-error-pristine");
|
|
7645
|
-
el.setAttribute("class", classList.join(" "));
|
|
7646
|
-
}
|
|
7647
|
-
function handleErrorStrategyPass(el) {
|
|
7648
|
-
const classList = [...el.classList];
|
|
7649
|
-
const index2 = classList.indexOf("devui-validate-rules-error-pristine");
|
|
7650
|
-
index2 !== -1 && classList.splice(index2, 1);
|
|
7651
|
-
el.setAttribute("class", classList.join(" "));
|
|
7652
|
-
}
|
|
7653
|
-
function getFormControlUID(el) {
|
|
7654
|
-
if (el.tagName.toLocaleLowerCase() === "body") {
|
|
7655
|
-
return "";
|
|
7656
|
-
}
|
|
7657
|
-
if (el.parentElement.id.startsWith("dfc-")) {
|
|
7658
|
-
return el.parentElement.id;
|
|
7659
|
-
} else {
|
|
7660
|
-
getFormControlUID(el.parentElement);
|
|
7661
|
-
}
|
|
7662
|
-
}
|
|
7663
|
-
function handleValidateError({
|
|
7664
|
-
el,
|
|
7665
|
-
tipEl,
|
|
7666
|
-
message = "",
|
|
7667
|
-
isFormTag,
|
|
7668
|
-
messageShowType,
|
|
7669
|
-
dfcUID,
|
|
7670
|
-
popPosition = "right-bottom",
|
|
7671
|
-
updateOn
|
|
7672
|
-
}) {
|
|
7673
|
-
if (isFormTag && messageShowType === "toast") {
|
|
7674
|
-
alert(message);
|
|
7675
|
-
return;
|
|
7676
|
-
}
|
|
7677
|
-
if (!dfcUID) {
|
|
7678
|
-
dfcUID = getFormControlUID(el);
|
|
7679
|
-
}
|
|
7680
|
-
if (messageShowType === "popover") {
|
|
7681
|
-
EventBus.emit("showPopoverErrorMessage", {
|
|
7682
|
-
showPopover: true,
|
|
7683
|
-
message,
|
|
7684
|
-
uid: dfcUID,
|
|
7685
|
-
popPosition,
|
|
7686
|
-
updateOn
|
|
7687
|
-
});
|
|
7688
|
-
return;
|
|
7689
|
-
}
|
|
7690
|
-
tipEl.innerText = "" + message;
|
|
7691
|
-
tipEl.style.display = "inline-flex";
|
|
7692
|
-
tipEl.setAttribute("class", "devui-validate-tip");
|
|
7693
|
-
handleErrorStrategy(el);
|
|
7694
|
-
}
|
|
7695
|
-
function handleValidatePass(el, tipEl) {
|
|
7696
|
-
tipEl.style.display = "none";
|
|
7697
|
-
handleErrorStrategyPass(el);
|
|
7698
|
-
}
|
|
7699
|
-
function getRefName(binding) {
|
|
7700
|
-
const _refs = binding.instance.$refs;
|
|
7701
|
-
const refName = Object.keys(_refs)[0];
|
|
7702
|
-
return refName;
|
|
7703
|
-
}
|
|
7704
|
-
function getFormName(binding) {
|
|
7705
|
-
const _refs = binding.instance.$refs;
|
|
7706
|
-
const key = Object.keys(_refs)[0];
|
|
7707
|
-
return _refs[key]["name"];
|
|
7708
|
-
}
|
|
7709
|
-
function validateFn({
|
|
7710
|
-
validator,
|
|
7711
|
-
modelValue,
|
|
7712
|
-
el,
|
|
7713
|
-
tipEl,
|
|
7714
|
-
isFormTag,
|
|
7715
|
-
messageShowType,
|
|
7716
|
-
dfcUID,
|
|
7717
|
-
popPosition,
|
|
7718
|
-
updateOn
|
|
7719
|
-
}) {
|
|
7720
|
-
validator.validate({ modelName: modelValue }).then(() => {
|
|
7721
|
-
handleValidatePass(el, tipEl);
|
|
7722
|
-
}).catch((err) => {
|
|
7723
|
-
const { errors } = err;
|
|
7724
|
-
if (!errors || errors.length === 0) {
|
|
7725
|
-
return;
|
|
7726
|
-
}
|
|
7727
|
-
let msg = "";
|
|
7728
|
-
if (typeof errors[0].message === "object") {
|
|
7729
|
-
msg = errors[0].message.default;
|
|
7730
|
-
} else {
|
|
7731
|
-
msg = errors[0].message;
|
|
7732
|
-
}
|
|
7733
|
-
handleValidateError({ el, tipEl, message: msg, isFormTag, messageShowType, dfcUID, popPosition, updateOn });
|
|
7734
|
-
});
|
|
7735
|
-
}
|
|
7736
|
-
function checkValidPopsition(positionStr) {
|
|
7737
|
-
const validPosition = [
|
|
7738
|
-
"left",
|
|
7739
|
-
"right",
|
|
7740
|
-
"top",
|
|
7741
|
-
"bottom",
|
|
7742
|
-
"left-top",
|
|
7743
|
-
"left-bottom",
|
|
7744
|
-
"top-left",
|
|
7745
|
-
"top-right",
|
|
7746
|
-
"right-top",
|
|
7747
|
-
"right-bottom",
|
|
7748
|
-
"bottom-left",
|
|
7749
|
-
"bottom-right"
|
|
7750
|
-
];
|
|
7751
|
-
const isValid = validPosition.includes(positionStr);
|
|
7752
|
-
!isValid && console.warn(`invalid popPosition value '${positionStr}'.`);
|
|
7753
|
-
return isValid;
|
|
7754
|
-
}
|
|
7755
|
-
var dValidateRules = {
|
|
7756
|
-
mounted(el, binding, vnode) {
|
|
7757
|
-
var _a;
|
|
7758
|
-
const isFormTag = el.tagName === "FORM";
|
|
7759
|
-
const dfcUID = el.parentNode.parentNode.parentElement.dataset.uid;
|
|
7760
|
-
const refName = getRefName(binding);
|
|
7761
|
-
const hasOptions = isObject(binding.value) && hasKey(binding.value, "options");
|
|
7762
|
-
let { rules: bindingRules, options = {}, messageShowType = "popover" } = binding.value;
|
|
7763
|
-
let { errorStrategy } = binding.value;
|
|
7764
|
-
if (refName) {
|
|
7765
|
-
messageShowType = (_a = binding.instance[refName]["messageShowType"]) != null ? _a : "popover";
|
|
7766
|
-
}
|
|
7767
|
-
let {
|
|
7768
|
-
updateOn = "change",
|
|
7769
|
-
errorStrategy: ErrorStrategy = "dirty",
|
|
7770
|
-
asyncDebounceTime = 300,
|
|
7771
|
-
popPosition = ["right", "bottom"]
|
|
7772
|
-
} = options;
|
|
7773
|
-
if (messageShowType === "popover") {
|
|
7774
|
-
if (Array.isArray(popPosition)) {
|
|
7775
|
-
popPosition = popPosition.length > 1 ? popPosition.join("-") : popPosition[0];
|
|
7776
|
-
if (!checkValidPopsition(popPosition)) {
|
|
7777
|
-
popPosition = "right-bottom";
|
|
7778
|
-
}
|
|
7779
|
-
} else if (!checkValidPopsition(popPosition)) {
|
|
7780
|
-
popPosition = "right-bottom";
|
|
7781
|
-
}
|
|
7782
|
-
}
|
|
7783
|
-
if (!errorStrategy) {
|
|
7784
|
-
errorStrategy = ErrorStrategy;
|
|
7785
|
-
}
|
|
7786
|
-
let customRule = {};
|
|
7787
|
-
if (hasOptions) {
|
|
7788
|
-
customRule = bindingRules != null ? bindingRules : binding.value;
|
|
7789
|
-
} else {
|
|
7790
|
-
customRule = binding.value;
|
|
7791
|
-
}
|
|
7792
|
-
const isCustomValidator = customRule && isObject(customRule) && (hasKey(customRule, "validators") || hasKey(customRule, "asyncValidators"));
|
|
7793
|
-
const rules2 = Array.isArray(customRule) ? customRule : [customRule];
|
|
7794
|
-
const tipEl = document.createElement("span");
|
|
7795
|
-
if (messageShowType !== "none") {
|
|
7796
|
-
el.parentNode.append(tipEl);
|
|
7797
|
-
}
|
|
7798
|
-
const descriptor = {
|
|
7799
|
-
modelName: []
|
|
7800
|
-
};
|
|
7801
|
-
rules2.forEach((rule) => {
|
|
7802
|
-
const kvObjList = !Array.isArray(rule) && getKeyValueOfObjectList(rule);
|
|
7803
|
-
let ruleObj = {};
|
|
7804
|
-
let avaliableRuleObj = {};
|
|
7805
|
-
kvObjList.forEach((item) => {
|
|
7806
|
-
avaliableRuleObj = getAvaliableRuleObj(item.key, item.value);
|
|
7807
|
-
ruleObj = __spreadValues(__spreadValues({}, ruleObj), avaliableRuleObj);
|
|
7808
|
-
});
|
|
7809
|
-
descriptor.modelName.push(ruleObj);
|
|
7810
|
-
});
|
|
7811
|
-
if (isCustomValidator) {
|
|
7812
|
-
const { validators: validators2, asyncValidators } = customRule;
|
|
7813
|
-
validators2 && validators2.forEach((item) => {
|
|
7814
|
-
const ruleObj = {
|
|
7815
|
-
message: (item == null ? void 0 : item.message) || "",
|
|
7816
|
-
validator: (rule, value) => item.validator(rule, value)
|
|
7817
|
-
};
|
|
7818
|
-
descriptor.modelName.push(ruleObj);
|
|
7819
|
-
});
|
|
7820
|
-
asyncValidators && asyncValidators.forEach((item) => {
|
|
7821
|
-
const ruleObj = {
|
|
7822
|
-
message: (item == null ? void 0 : item.message) || "",
|
|
7823
|
-
asyncValidator: (rule, value) => {
|
|
7824
|
-
return new Promise(lodash.exports.debounce((resolve, reject) => {
|
|
7825
|
-
const res = item.asyncValidator(rule, value);
|
|
7826
|
-
if (res) {
|
|
7827
|
-
resolve("");
|
|
7828
|
-
} else {
|
|
7829
|
-
reject(rule.message);
|
|
7830
|
-
}
|
|
7831
|
-
}, asyncDebounceTime));
|
|
7832
|
-
}
|
|
7833
|
-
};
|
|
7834
|
-
descriptor.modelName.push(ruleObj);
|
|
7835
|
-
});
|
|
7836
|
-
}
|
|
7837
|
-
const validator = new Schema(descriptor);
|
|
7838
|
-
const htmlEventValidateHandler = (e) => {
|
|
7839
|
-
const modelValue = e.target.value;
|
|
7840
|
-
if (messageShowType === "popover") {
|
|
7841
|
-
EventBus.emit("showPopoverErrorMessage", {
|
|
7842
|
-
showPopover: false,
|
|
7843
|
-
message: "",
|
|
7844
|
-
uid: dfcUID,
|
|
7845
|
-
popPosition,
|
|
7846
|
-
updateOn
|
|
7847
|
-
});
|
|
7848
|
-
}
|
|
7849
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag: false, messageShowType, dfcUID, popPosition, updateOn });
|
|
7850
|
-
};
|
|
7851
|
-
vnode.children[0].el.addEventListener(updateOn, htmlEventValidateHandler);
|
|
7852
|
-
if (messageShowType === "popover" && updateOn === "change") {
|
|
7853
|
-
vnode.children[0].el.addEventListener("focus", () => {
|
|
7854
|
-
EventBus.emit("showPopoverErrorMessage", { showPopover: false, uid: dfcUID, updateOn });
|
|
7855
|
-
});
|
|
7856
|
-
}
|
|
7857
|
-
if (errorStrategy === "pristine") {
|
|
7858
|
-
handleErrorStrategy(el);
|
|
7859
|
-
vnode.children[0].props.value = "" + vnode.children[0].props.value;
|
|
7860
|
-
}
|
|
7861
|
-
const formName = getFormName(binding);
|
|
7862
|
-
formName && EventBus.on(`formSubmit:${formName}`, () => {
|
|
7863
|
-
const modelValue = isFormTag ? "" : vnode.children[0].el.value;
|
|
7864
|
-
validateFn({ validator, modelValue, el, tipEl, isFormTag, messageShowType, updateOn: "submit" });
|
|
7865
|
-
});
|
|
7866
|
-
}
|
|
7867
|
-
};
|
|
7868
7499
|
var index = {
|
|
7869
7500
|
title: "Form \u8868\u5355",
|
|
7870
7501
|
category: "\u6570\u636E\u5F55\u5165",
|
|
7871
7502
|
status: "75%",
|
|
7872
7503
|
install(app) {
|
|
7873
7504
|
app.component(Form.name, Form);
|
|
7874
|
-
app.directive("d-validate-rules", dValidateRules);
|
|
7875
7505
|
app.component(FormLabel.name, FormLabel);
|
|
7876
7506
|
app.component(FormItem.name, FormItem);
|
|
7877
7507
|
app.component(FormControl.name, FormControl);
|
|
7878
7508
|
app.component(FormOperation.name, FormOperation);
|
|
7879
7509
|
}
|
|
7880
7510
|
};
|
|
7881
|
-
export { Form, FormControl, FormItem, FormLabel, FormOperation, index as default };
|
|
7511
|
+
export { FORM_ITEM_TOKEN, FORM_TOKEN, Form, FormControl, FormItem, FormLabel, FormOperation, index as default, formControlProps, formItemProps, formProps };
|