@nutui/nutui 4.3.0-beta.6 → 4.3.1
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/CHANGELOG.md +47 -0
- package/README.md +1 -1
- package/dist/nutui.es.js +1 -1
- package/dist/nutui.js +5939 -6035
- package/dist/nutui.umd.js +1 -1
- package/dist/packages/actionsheet/ActionSheet.js +0 -2
- package/dist/packages/address/Address.js +0 -3
- package/dist/packages/addresslist/AddressList.js +0 -4
- package/dist/packages/audio/Audio.js +0 -3
- package/dist/packages/audiooperate/AudioOperate.js +0 -4
- package/dist/packages/avatar/Avatar.js +0 -1
- package/dist/packages/avatarcropper/AvatarCropper.js +1 -2
- package/dist/packages/button/Button.js +17 -18
- package/dist/packages/calendar/Calendar.js +0 -6
- package/dist/packages/calendarcard/CalendarCard.js +6 -26
- package/dist/packages/calendaritem/CalendarItem.js +0 -2
- package/dist/packages/card/Card.js +0 -1
- package/dist/packages/cascader/Cascader.js +0 -9
- package/dist/packages/checkbox/Checkbox.js +4 -2
- package/dist/packages/collapse/Collapse.js +40 -28
- package/dist/packages/collapseitem/CollapseItem.js +112 -125
- package/dist/packages/comment/Comment.js +0 -5
- package/dist/packages/common-LvGbU-A3.js +13 -0
- package/dist/packages/countdown/Countdown.js +3 -4
- package/dist/packages/datepicker/DatePicker.js +0 -4
- package/dist/packages/dialog/Dialog.js +0 -4
- package/dist/packages/ecard/Ecard.js +0 -4
- package/dist/packages/empty/Empty.js +0 -2
- package/dist/packages/fixednav/FixedNav.js +0 -2
- package/dist/packages/form/Form.js +161 -157
- package/dist/packages/formitem/FormItem.js +76 -107
- package/dist/packages/grid/Grid.js +0 -1
- package/dist/packages/imagepreview/ImagePreview.js +1 -5
- package/dist/packages/{index-rf29bejW.js → index-cp6Ms_Qe.js} +1 -1
- package/dist/packages/{index.vue_vue_type_script_lang-MJYVRFbp.js → index.vue_vue_type_script_lang-w2sgcysj.js} +6 -4
- package/dist/packages/infiniteloading/InfiniteLoading.js +0 -1
- package/dist/packages/input/Input.js +10 -7
- package/dist/packages/inputnumber/InputNumber.js +12 -8
- package/dist/packages/invoice/Invoice.js +10 -21
- package/dist/packages/list/List.js +1 -1
- package/dist/packages/locale/lang/index.js +0 -1
- package/dist/packages/menu/Menu.js +1 -1
- package/dist/packages/menuitem/MenuItem.js +0 -2
- package/dist/packages/noticebar/Noticebar.js +9 -10
- package/dist/packages/notify/Notify.js +0 -3
- package/dist/packages/numberkeyboard/NumberKeyboard.js +0 -4
- package/dist/packages/pagination/Pagination.js +0 -2
- package/dist/packages/picker/Picker.js +10 -5
- package/dist/packages/popover/Popover.js +88 -89
- package/dist/packages/popover/index.css +1 -1
- package/dist/packages/popover/index.scss +3 -12
- package/dist/packages/popup/Popup.js +0 -4
- package/dist/packages/pullrefresh/PullRefresh.js +0 -1
- package/dist/packages/radio/Radio.js +1 -6
- package/dist/packages/radiogroup/RadioGroup.js +0 -3
- package/dist/packages/range/Range.js +11 -8
- package/dist/packages/rate/Rate.js +6 -3
- package/dist/packages/searchbar/Searchbar.js +5 -4
- package/dist/packages/shortpassword/ShortPassword.js +0 -3
- package/dist/packages/signature/Signature.js +0 -4
- package/dist/packages/sku/Sku.js +5 -9
- package/dist/packages/sticky/Sticky.js +1 -1
- package/dist/packages/switch/Switch.js +5 -3
- package/dist/packages/table/Table.js +0 -2
- package/dist/packages/tabs/Tabs.js +1 -2
- package/dist/packages/textarea/Textarea.js +7 -6
- package/dist/packages/timepannel/TimePannel.js +2 -2
- package/dist/packages/timeselect/TimeSelect.js +0 -4
- package/dist/packages/toast/Toast.js +3 -3
- package/dist/packages/tour/Tour.js +1 -5
- package/dist/packages/tour/index.css +1 -1
- package/dist/packages/uploader/Uploader.js +7 -5
- package/dist/packages/video/Video.js +0 -2
- package/dist/smartips/web-types.json +12 -3
- package/dist/style.css +1 -1
- package/dist/types/__VUE/address/index.vue.d.ts +43 -3
- package/dist/types/__VUE/calendarcard/calendar-card.vue.d.ts +59 -57
- package/dist/types/__VUE/calendarcard/index.d.ts +1 -0
- package/dist/types/__VUE/collapse/collapse.vue.d.ts +60 -0
- package/dist/types/__VUE/collapse/index.d.ts +6 -0
- package/dist/types/__VUE/collapse/types.d.ts +3 -2
- package/dist/types/__VUE/collapseitem/collapse-item.vue.d.ts +201 -0
- package/dist/types/__VUE/collapseitem/index.d.ts +5 -0
- package/dist/types/__VUE/countdown/index.vue.d.ts +23 -1
- package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
- package/dist/types/__VUE/form/common.d.ts +2 -30
- package/dist/types/__VUE/form/form.vue.d.ts +80 -0
- package/dist/types/__VUE/form/index.d.ts +6 -0
- package/dist/types/__VUE/form/types.d.ts +12 -4
- package/dist/types/__VUE/formitem/form-item.vue.d.ts +97 -0
- package/dist/types/__VUE/formitem/index.d.ts +5 -0
- package/dist/types/__VUE/input/index.vue.d.ts +2 -1
- package/dist/types/__VUE/inputnumber/index.vue.d.ts +1 -0
- package/dist/types/__VUE/noticebar/index.vue.d.ts +4 -3
- package/dist/types/__VUE/noticebar/types.d.ts +1 -0
- package/dist/types/__VUE/picker/index.vue.d.ts +1 -0
- package/dist/types/__VUE/picker/types.d.ts +1 -0
- package/dist/types/__VUE/picker/usePicker.d.ts +1 -0
- package/dist/types/__VUE/popover/index.vue.d.ts +0 -1
- package/dist/types/__VUE/popover/type.d.ts +7 -0
- package/dist/types/__VUE/range/index.vue.d.ts +1 -1
- package/dist/types/__VUE/rate/index.vue.d.ts +1 -0
- package/dist/types/__VUE/searchbar/index.vue.d.ts +1 -0
- package/dist/types/__VUE/skeleton/index.vue.d.ts +3 -3
- package/dist/types/__VUE/sku/components/SkuStepper.vue.d.ts +1 -1
- package/dist/types/__VUE/sku/index.vue.d.ts +1 -1
- package/dist/types/__VUE/table/index.vue.d.ts +4 -4
- package/dist/types/__VUE/tabs/index.vue.d.ts +4 -4
- package/dist/types/__VUE/textarea/index.vue.d.ts +1 -0
- package/dist/types/__VUE/toast/index.vue.d.ts +21 -1
- package/dist/types/index.d.ts +9 -5
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/types/__VUE/collapse/index.vue.d.ts +0 -39
- package/dist/types/__VUE/collapseitem/index.vue.d.ts +0 -212
- package/dist/types/__VUE/form/index.vue.d.ts +0 -58
- package/dist/types/__VUE/formitem/index.vue.d.ts +0 -134
- package/dist/types/__VUE/formitem/types.d.ts +0 -11
|
@@ -22,7 +22,6 @@ import { c as createComponent } from "../component-TCzwHGVq.js";
|
|
|
22
22
|
import { p as padZero } from "../util-4Jkyw4BJ.js";
|
|
23
23
|
import { u as useLocale } from "../index-s3RgMhc7.js";
|
|
24
24
|
import { _ as _export_sfc } from "../_plugin-vue_export-helper-yVxbj29m.js";
|
|
25
|
-
import "@nutui/nutui/dist/packages/locale/lang";
|
|
26
25
|
const getTimeStamp = (timeStr) => {
|
|
27
26
|
if (!timeStr)
|
|
28
27
|
return Date.now();
|
|
@@ -107,7 +106,7 @@ const _sfc_main = create({
|
|
|
107
106
|
return formatRemainTime(state.restTime);
|
|
108
107
|
});
|
|
109
108
|
const initTime = () => {
|
|
110
|
-
state.handleEndTime = props.endTime;
|
|
109
|
+
state.handleEndTime = Number(props.endTime);
|
|
111
110
|
state.diffTime = Date.now() - getTimeStamp(props.startTime);
|
|
112
111
|
if (!state.counting)
|
|
113
112
|
state.counting = true;
|
|
@@ -208,14 +207,14 @@ const _sfc_main = create({
|
|
|
208
207
|
const reset = () => {
|
|
209
208
|
if (!props.autoStart) {
|
|
210
209
|
pause();
|
|
211
|
-
state.restTime = props.time;
|
|
210
|
+
state.restTime = Number(props.time);
|
|
212
211
|
}
|
|
213
212
|
};
|
|
214
213
|
onBeforeMount(() => {
|
|
215
214
|
if (props.autoStart) {
|
|
216
215
|
initTime();
|
|
217
216
|
} else {
|
|
218
|
-
state.restTime = props.time;
|
|
217
|
+
state.restTime = Number(props.time);
|
|
219
218
|
}
|
|
220
219
|
});
|
|
221
220
|
watch(
|
|
@@ -22,10 +22,6 @@ import NutPicker from "../picker/Picker.js";
|
|
|
22
22
|
import { c as createComponent } from "../component-TCzwHGVq.js";
|
|
23
23
|
import { c as isDate$1, p as padZero } from "../util-4Jkyw4BJ.js";
|
|
24
24
|
import { _ as _export_sfc } from "../_plugin-vue_export-helper-yVxbj29m.js";
|
|
25
|
-
import "../pxCheck-OnXlN1NC.js";
|
|
26
|
-
import "../index-084nl_oE.js";
|
|
27
|
-
import "../index-s3RgMhc7.js";
|
|
28
|
-
import "@nutui/nutui/dist/packages/locale/lang";
|
|
29
25
|
const { create } = createComponent("date-picker");
|
|
30
26
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
31
27
|
function isDate(val) {
|
|
@@ -30,10 +30,6 @@ import { u as useLocale } from "../index-s3RgMhc7.js";
|
|
|
30
30
|
import { _ as _export_sfc } from "../_plugin-vue_export-helper-yVxbj29m.js";
|
|
31
31
|
import NutOverlay from "../overlay/Overlay.js";
|
|
32
32
|
import { C as CreateComponent } from "../mountComponent-uInXoTMp.js";
|
|
33
|
-
import "../util-4Jkyw4BJ.js";
|
|
34
|
-
import "@nutui/icons-vue";
|
|
35
|
-
import "../with-install-p59gYYU_.js";
|
|
36
|
-
import "@nutui/nutui/dist/packages/locale/lang";
|
|
37
33
|
const { create } = createComponent("dialog");
|
|
38
34
|
const cN = "NutDialog";
|
|
39
35
|
const _sfc_main = create({
|
|
@@ -3,10 +3,6 @@ import { c as createComponent } from "../component-TCzwHGVq.js";
|
|
|
3
3
|
import NutInputNumber from "../inputnumber/InputNumber.js";
|
|
4
4
|
import { u as useLocale } from "../index-s3RgMhc7.js";
|
|
5
5
|
import { _ as _export_sfc } from "../_plugin-vue_export-helper-yVxbj29m.js";
|
|
6
|
-
import "../pxCheck-OnXlN1NC.js";
|
|
7
|
-
import "@nutui/icons-vue";
|
|
8
|
-
import "@nutui/nutui/dist/packages/locale/lang";
|
|
9
|
-
import "../util-4Jkyw4BJ.js";
|
|
10
6
|
const { create } = createComponent("ecard");
|
|
11
7
|
const cN = "NutEcard";
|
|
12
8
|
const _sfc_main = create({
|
|
@@ -3,8 +3,6 @@ import { c as createComponent } from "../component-TCzwHGVq.js";
|
|
|
3
3
|
import { p as pxCheck } from "../pxCheck-OnXlN1NC.js";
|
|
4
4
|
import { u as useLocale } from "../index-s3RgMhc7.js";
|
|
5
5
|
import { _ as _export_sfc } from "../_plugin-vue_export-helper-yVxbj29m.js";
|
|
6
|
-
import "@nutui/nutui/dist/packages/locale/lang";
|
|
7
|
-
import "../util-4Jkyw4BJ.js";
|
|
8
6
|
const { create } = createComponent("empty");
|
|
9
7
|
const cN = "NutEmpty";
|
|
10
8
|
const defaultStatus = {
|
|
@@ -4,8 +4,6 @@ import NutOverlay from "../overlay/Overlay.js";
|
|
|
4
4
|
import { c as createComponent } from "../component-TCzwHGVq.js";
|
|
5
5
|
import { u as useLocale } from "../index-s3RgMhc7.js";
|
|
6
6
|
import { _ as _export_sfc } from "../_plugin-vue_export-helper-yVxbj29m.js";
|
|
7
|
-
import "../util-4Jkyw4BJ.js";
|
|
8
|
-
import "@nutui/nutui/dist/packages/locale/lang";
|
|
9
7
|
const { create } = createComponent("fixed-nav");
|
|
10
8
|
const cN = "NutFixedNav";
|
|
11
9
|
const _sfc_main = create({
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
4
20
|
var __objRest = (source, exclude) => {
|
|
5
21
|
var target = {};
|
|
6
22
|
for (var prop in source)
|
|
@@ -33,178 +49,166 @@ var __async = (__this, __arguments, generator) => {
|
|
|
33
49
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
34
50
|
});
|
|
35
51
|
};
|
|
36
|
-
import {
|
|
37
|
-
import { computed, reactive, provide, watch, resolveComponent, openBlock, createElementBlock, withModifiers, createVNode, withCtx, renderSlot } from "vue";
|
|
38
|
-
import { g as getPropByPath, f as isPromise } from "../util-4Jkyw4BJ.js";
|
|
39
|
-
import { F as FORM_KEY } from "../types-Ynmct7na.js";
|
|
52
|
+
import { defineComponent, computed, reactive, provide, watch, openBlock, createElementBlock, withModifiers, createVNode, withCtx, renderSlot } from "vue";
|
|
40
53
|
import { u as useChildren } from "../useChildren-GU_NVfD8.js";
|
|
54
|
+
import { g as getPropByPath, f as isPromise } from "../util-4Jkyw4BJ.js";
|
|
41
55
|
import NutCellGroup from "../cellgroup/CellGroup.js";
|
|
42
|
-
import {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
import { F as FORM_KEY } from "../types-Ynmct7na.js";
|
|
57
|
+
import { w as withInstall } from "../with-install-p59gYYU_.js";
|
|
58
|
+
const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
|
|
59
|
+
name: "NutForm"
|
|
60
|
+
}), {
|
|
61
|
+
__name: "form",
|
|
62
|
+
props: {
|
|
63
|
+
modelValue: { default: () => ({}) },
|
|
64
|
+
rules: { default: () => ({}) },
|
|
65
|
+
disabled: { type: Boolean, default: false },
|
|
66
|
+
labelPosition: { default: "left" },
|
|
67
|
+
starPosition: { default: "left" }
|
|
68
|
+
},
|
|
69
|
+
emits: ["validate"],
|
|
70
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
71
|
+
const props = __props;
|
|
72
|
+
const emit = __emit;
|
|
73
|
+
const { children, linkChildren } = useChildren(FORM_KEY);
|
|
74
|
+
linkChildren({ props });
|
|
75
|
+
const formErrorTip = computed(() => reactive({}));
|
|
76
|
+
provide("formErrorTip", formErrorTip);
|
|
77
|
+
const clearErrorTips = () => {
|
|
78
|
+
Object.keys(formErrorTip.value).forEach((item) => {
|
|
79
|
+
formErrorTip.value[item] = "";
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const reset = () => {
|
|
83
|
+
clearErrorTips();
|
|
84
|
+
};
|
|
85
|
+
watch(
|
|
86
|
+
() => props.modelValue,
|
|
87
|
+
() => {
|
|
88
|
+
clearErrorTips();
|
|
57
89
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const { children, linkChildren } = useChildren(FORM_KEY);
|
|
67
|
-
linkChildren({ props });
|
|
68
|
-
const formErrorTip = computed(() => reactive({}));
|
|
69
|
-
provide("formErrorTip", formErrorTip);
|
|
70
|
-
const clearErrorTips = () => {
|
|
71
|
-
Object.keys(formErrorTip.value).forEach((item) => {
|
|
72
|
-
formErrorTip.value[item] = "";
|
|
90
|
+
{ immediate: true }
|
|
91
|
+
);
|
|
92
|
+
const getTaskFromChildren = () => {
|
|
93
|
+
const task = [];
|
|
94
|
+
children.forEach((item) => {
|
|
95
|
+
task.push({
|
|
96
|
+
prop: item == null ? void 0 : item["prop"],
|
|
97
|
+
rules: (item == null ? void 0 : item["rules"]) || []
|
|
73
98
|
});
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
()
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
});
|
|
100
|
+
return task;
|
|
101
|
+
};
|
|
102
|
+
const tipMessage = (errorMsg) => {
|
|
103
|
+
if (errorMsg.message) {
|
|
104
|
+
emit("validate", errorMsg);
|
|
105
|
+
}
|
|
106
|
+
formErrorTip.value[errorMsg.prop] = errorMsg.message;
|
|
107
|
+
};
|
|
108
|
+
const checkRule = (item) => __async(this, null, function* () {
|
|
109
|
+
const { rules = [], prop } = item;
|
|
110
|
+
const _Promise = (errorMsg) => {
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
try {
|
|
113
|
+
tipMessage(errorMsg);
|
|
114
|
+
resolve(errorMsg);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
reject(error);
|
|
117
|
+
}
|
|
92
118
|
});
|
|
93
|
-
return task;
|
|
94
119
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
120
|
+
if (!prop) {
|
|
121
|
+
console.warn("[NutUI] <FormItem> 使用 rules 校验规则时 , 必须设置 prop 参数");
|
|
122
|
+
}
|
|
123
|
+
const value = getPropByPath(props.modelValue, prop || "");
|
|
124
|
+
tipMessage({ prop, message: "" });
|
|
125
|
+
const formRules = props.rules || {};
|
|
126
|
+
const _rules = [...(formRules == null ? void 0 : formRules[prop]) || [], ...rules];
|
|
127
|
+
while (_rules.length) {
|
|
128
|
+
const rule = _rules.shift();
|
|
129
|
+
const _a = rule, { validator } = _a, ruleWithoutValidator = __objRest(_a, ["validator"]);
|
|
130
|
+
const { required, regex, message } = ruleWithoutValidator;
|
|
131
|
+
const errorMsg = { prop, message: message || "" };
|
|
132
|
+
if (required) {
|
|
133
|
+
if (!value && value !== 0) {
|
|
134
|
+
return _Promise(errorMsg);
|
|
135
|
+
}
|
|
98
136
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
137
|
+
if (regex && !regex.test(String(value))) {
|
|
138
|
+
return _Promise(errorMsg);
|
|
139
|
+
}
|
|
140
|
+
if (validator) {
|
|
141
|
+
const result = validator(value, ruleWithoutValidator);
|
|
142
|
+
if (isPromise(result)) {
|
|
105
143
|
try {
|
|
106
|
-
|
|
107
|
-
|
|
144
|
+
const value2 = yield result;
|
|
145
|
+
if (value2 === false) {
|
|
146
|
+
return _Promise(errorMsg);
|
|
147
|
+
}
|
|
108
148
|
} catch (error) {
|
|
109
|
-
|
|
149
|
+
const validateErrorMsg = { prop, message: error };
|
|
150
|
+
return _Promise(validateErrorMsg);
|
|
110
151
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!prop) {
|
|
114
|
-
console.warn("[NutUI] <FormItem> 使用 rules 校验规则时 , 必须设置 prop 参数");
|
|
115
|
-
}
|
|
116
|
-
const value = getPropByPath(props.modelValue, prop || "");
|
|
117
|
-
tipMessage({ prop, message: "" });
|
|
118
|
-
const formRules = props.rules || {};
|
|
119
|
-
const _rules = [...(formRules == null ? void 0 : formRules[prop]) || [], ...rules];
|
|
120
|
-
while (_rules.length) {
|
|
121
|
-
const rule = _rules.shift();
|
|
122
|
-
const _a = rule, { validator } = _a, ruleWithoutValidator = __objRest(_a, ["validator"]);
|
|
123
|
-
const { required, regex, message } = ruleWithoutValidator;
|
|
124
|
-
const errorMsg = { prop, message: message || "" };
|
|
125
|
-
if (required) {
|
|
126
|
-
if (!value && value !== 0) {
|
|
152
|
+
} else {
|
|
153
|
+
if (!result) {
|
|
127
154
|
return _Promise(errorMsg);
|
|
128
155
|
}
|
|
129
156
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
} catch (error) {
|
|
142
|
-
const validateErrorMsg = { prop, message: error };
|
|
143
|
-
return _Promise(validateErrorMsg);
|
|
144
|
-
}
|
|
145
|
-
} else {
|
|
146
|
-
if (!result) {
|
|
147
|
-
return _Promise(errorMsg);
|
|
148
|
-
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return Promise.resolve(true);
|
|
160
|
+
});
|
|
161
|
+
const validate = (customProp = "") => {
|
|
162
|
+
return new Promise((resolve, reject) => {
|
|
163
|
+
try {
|
|
164
|
+
const task = getTaskFromChildren();
|
|
165
|
+
const errors = task.map((item) => {
|
|
166
|
+
if (customProp && customProp !== item.prop) {
|
|
167
|
+
return Promise.resolve(true);
|
|
149
168
|
}
|
|
150
|
-
|
|
169
|
+
return checkRule(item);
|
|
170
|
+
});
|
|
171
|
+
Promise.all(errors).then((errorRes) => {
|
|
172
|
+
errorRes = errorRes.filter((item) => item !== true);
|
|
173
|
+
const res = { valid: true, errors: [] };
|
|
174
|
+
if (errorRes.length) {
|
|
175
|
+
res.valid = false;
|
|
176
|
+
res.errors = errorRes;
|
|
177
|
+
}
|
|
178
|
+
resolve(res);
|
|
179
|
+
});
|
|
180
|
+
} catch (error) {
|
|
181
|
+
reject(error);
|
|
151
182
|
}
|
|
152
|
-
return Promise.resolve(true);
|
|
153
183
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
};
|
|
182
|
-
return { validate, reset, submit, formErrorTip };
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
const { create } = createComponent("form");
|
|
187
|
-
const _sfc_main = create(
|
|
188
|
-
component({
|
|
189
|
-
NutCellGroup
|
|
190
|
-
})
|
|
191
|
-
);
|
|
192
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
193
|
-
const _component_nut_cell_group = resolveComponent("nut-cell-group");
|
|
194
|
-
return openBlock(), createElementBlock("form", {
|
|
195
|
-
class: "nut-form",
|
|
196
|
-
action: "#",
|
|
197
|
-
onSubmit: withModifiers(() => false, ["prevent"])
|
|
198
|
-
}, [
|
|
199
|
-
createVNode(_component_nut_cell_group, null, {
|
|
200
|
-
default: withCtx(() => [
|
|
201
|
-
renderSlot(_ctx.$slots, "default")
|
|
202
|
-
]),
|
|
203
|
-
_: 3
|
|
204
|
-
})
|
|
205
|
-
], 32);
|
|
206
|
-
}
|
|
207
|
-
const NutForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
184
|
+
};
|
|
185
|
+
const submit = () => {
|
|
186
|
+
validate();
|
|
187
|
+
return false;
|
|
188
|
+
};
|
|
189
|
+
__expose({
|
|
190
|
+
submit,
|
|
191
|
+
reset,
|
|
192
|
+
validate
|
|
193
|
+
});
|
|
194
|
+
return (_ctx, _cache) => {
|
|
195
|
+
return openBlock(), createElementBlock("form", {
|
|
196
|
+
class: "nut-form",
|
|
197
|
+
action: "#",
|
|
198
|
+
onSubmit: withModifiers(() => false, ["prevent"])
|
|
199
|
+
}, [
|
|
200
|
+
createVNode(NutCellGroup, null, {
|
|
201
|
+
default: withCtx(() => [
|
|
202
|
+
renderSlot(_ctx.$slots, "default")
|
|
203
|
+
]),
|
|
204
|
+
_: 3
|
|
205
|
+
})
|
|
206
|
+
], 32);
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}));
|
|
210
|
+
withInstall(_sfc_main);
|
|
208
211
|
export {
|
|
209
|
-
|
|
212
|
+
_sfc_main as Form,
|
|
213
|
+
_sfc_main as default
|
|
210
214
|
};
|
|
@@ -1,69 +1,50 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { defineComponent, computed, inject, openBlock, createBlock, normalizeClass, unref, normalizeStyle, withCtx, createElementBlock, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createElementVNode } from "vue";
|
|
1
21
|
import { p as pxCheck } from "../pxCheck-OnXlN1NC.js";
|
|
2
|
-
import { computed, inject, resolveComponent, openBlock, createBlock, normalizeClass, normalizeStyle, withCtx, createElementBlock, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createElementVNode } from "vue";
|
|
3
|
-
import { c as createComponent } from "../component-TCzwHGVq.js";
|
|
4
22
|
import NutCell from "../cell/Cell.js";
|
|
5
23
|
import { F as FORM_KEY } from "../types-Ynmct7na.js";
|
|
6
24
|
import { u as useParent } from "../useParent-KIxqkovs.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
25
|
+
import { w as withInstall } from "../with-install-p59gYYU_.js";
|
|
26
|
+
const _hoisted_1 = { class: "nut-cell__value nut-form-item__body" };
|
|
27
|
+
const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
|
|
28
|
+
name: "NutFormItem",
|
|
29
|
+
inheritAttrs: false
|
|
30
|
+
}), {
|
|
31
|
+
__name: "form-item",
|
|
13
32
|
props: {
|
|
14
|
-
prop: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
required: {
|
|
27
|
-
type: Boolean,
|
|
28
|
-
default: false
|
|
29
|
-
},
|
|
30
|
-
showErrorMessage: {
|
|
31
|
-
type: Boolean,
|
|
32
|
-
default: true
|
|
33
|
-
},
|
|
34
|
-
showErrorLine: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
default: true
|
|
37
|
-
},
|
|
38
|
-
labelWidth: {
|
|
39
|
-
type: [String, Number],
|
|
40
|
-
default: ""
|
|
41
|
-
},
|
|
42
|
-
labelAlign: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: ""
|
|
45
|
-
},
|
|
46
|
-
errorMessageAlign: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: ""
|
|
49
|
-
},
|
|
50
|
-
bodyAlign: {
|
|
51
|
-
type: String,
|
|
52
|
-
default: ""
|
|
53
|
-
},
|
|
54
|
-
labelPosition: {
|
|
55
|
-
type: String,
|
|
56
|
-
default: ""
|
|
57
|
-
},
|
|
58
|
-
starPosition: {
|
|
59
|
-
type: String,
|
|
60
|
-
default: ""
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
components: {
|
|
64
|
-
NutCell
|
|
33
|
+
prop: { default: "" },
|
|
34
|
+
label: { default: "" },
|
|
35
|
+
rules: { default: () => [] },
|
|
36
|
+
required: { type: Boolean, default: false },
|
|
37
|
+
showErrorMessage: { type: Boolean, default: true },
|
|
38
|
+
showErrorLine: { type: Boolean, default: true },
|
|
39
|
+
labelWidth: {},
|
|
40
|
+
labelAlign: {},
|
|
41
|
+
errorMessageAlign: {},
|
|
42
|
+
bodyAlign: {},
|
|
43
|
+
labelPosition: {},
|
|
44
|
+
starPosition: {}
|
|
65
45
|
},
|
|
66
|
-
setup(
|
|
46
|
+
setup(__props) {
|
|
47
|
+
const props = __props;
|
|
67
48
|
const { parent: parentObj } = useParent(FORM_KEY);
|
|
68
49
|
const isRequired = computed(() => {
|
|
69
50
|
var _a;
|
|
@@ -103,54 +84,42 @@ const _sfc_main = create({
|
|
|
103
84
|
textAlign: props.errorMessageAlign
|
|
104
85
|
};
|
|
105
86
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
87
|
+
return (_ctx, _cache) => {
|
|
88
|
+
return openBlock(), createBlock(NutCell, {
|
|
89
|
+
class: normalizeClass(["nut-form-item", [{ error: unref(parent)[_ctx.prop], line: _ctx.showErrorLine }, _ctx.$attrs.class, labelPositionClass.value]]),
|
|
90
|
+
style: normalizeStyle(_ctx.$attrs.style)
|
|
91
|
+
}, {
|
|
92
|
+
default: withCtx(() => [
|
|
93
|
+
_ctx.label || _ctx.$slots.label ? (openBlock(), createElementBlock("view", {
|
|
94
|
+
key: 0,
|
|
95
|
+
class: normalizeClass(["nut-cell__title nut-form-item__label", { required: isRequired.value, [starPositionClass.value]: starPositionClass.value }]),
|
|
96
|
+
style: normalizeStyle(labelStyle.value)
|
|
97
|
+
}, [
|
|
98
|
+
renderSlot(_ctx.$slots, "label", {}, () => [
|
|
99
|
+
createTextVNode(toDisplayString(_ctx.label), 1)
|
|
100
|
+
])
|
|
101
|
+
], 6)) : createCommentVNode("", true),
|
|
102
|
+
createElementVNode("view", _hoisted_1, [
|
|
103
|
+
createElementVNode("view", {
|
|
104
|
+
class: "nut-form-item__body__slots",
|
|
105
|
+
style: normalizeStyle(bodyStyle.value)
|
|
106
|
+
}, [
|
|
107
|
+
renderSlot(_ctx.$slots, "default")
|
|
108
|
+
], 4),
|
|
109
|
+
unref(parent)[_ctx.prop] && _ctx.showErrorMessage ? (openBlock(), createElementBlock("view", {
|
|
110
|
+
key: 0,
|
|
111
|
+
class: "nut-form-item__body__tips",
|
|
112
|
+
style: normalizeStyle(errorMessageStyle.value)
|
|
113
|
+
}, toDisplayString(unref(parent)[_ctx.prop]), 5)) : createCommentVNode("", true)
|
|
114
|
+
])
|
|
115
|
+
]),
|
|
116
|
+
_: 3
|
|
117
|
+
}, 8, ["class", "style"]);
|
|
116
118
|
};
|
|
117
119
|
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
121
|
-
const _component_nut_cell = resolveComponent("nut-cell");
|
|
122
|
-
return openBlock(), createBlock(_component_nut_cell, {
|
|
123
|
-
class: normalizeClass(["nut-form-item", [{ error: _ctx.parent[_ctx.prop], line: _ctx.showErrorLine }, _ctx.$attrs.class, _ctx.labelPositionClass]]),
|
|
124
|
-
style: normalizeStyle(_ctx.$attrs.style)
|
|
125
|
-
}, {
|
|
126
|
-
default: withCtx(() => [
|
|
127
|
-
_ctx.label || _ctx.getSlots("label") ? (openBlock(), createElementBlock("view", {
|
|
128
|
-
key: 0,
|
|
129
|
-
class: normalizeClass(["nut-cell__title nut-form-item__label", { required: _ctx.isRequired, [_ctx.starPositionClass]: _ctx.starPositionClass }]),
|
|
130
|
-
style: normalizeStyle(_ctx.labelStyle)
|
|
131
|
-
}, [
|
|
132
|
-
renderSlot(_ctx.$slots, "label", {}, () => [
|
|
133
|
-
createTextVNode(toDisplayString(_ctx.label), 1)
|
|
134
|
-
])
|
|
135
|
-
], 6)) : createCommentVNode("", true),
|
|
136
|
-
createElementVNode("view", _hoisted_1, [
|
|
137
|
-
createElementVNode("view", {
|
|
138
|
-
class: "nut-form-item__body__slots",
|
|
139
|
-
style: normalizeStyle(_ctx.bodyStyle)
|
|
140
|
-
}, [
|
|
141
|
-
renderSlot(_ctx.$slots, "default")
|
|
142
|
-
], 4),
|
|
143
|
-
_ctx.parent[_ctx.prop] && _ctx.showErrorMessage ? (openBlock(), createElementBlock("view", {
|
|
144
|
-
key: 0,
|
|
145
|
-
class: "nut-form-item__body__tips",
|
|
146
|
-
style: normalizeStyle(_ctx.errorMessageStyle)
|
|
147
|
-
}, toDisplayString(_ctx.parent[_ctx.prop]), 5)) : createCommentVNode("", true)
|
|
148
|
-
])
|
|
149
|
-
]),
|
|
150
|
-
_: 3
|
|
151
|
-
}, 8, ["class", "style"]);
|
|
152
|
-
}
|
|
153
|
-
const NutFormItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
120
|
+
}));
|
|
121
|
+
withInstall(_sfc_main);
|
|
154
122
|
export {
|
|
155
|
-
|
|
123
|
+
_sfc_main as FormItem,
|
|
124
|
+
_sfc_main as default
|
|
156
125
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { c as createComponent } from "../component-TCzwHGVq.js";
|
|
2
2
|
import "vue";
|
|
3
3
|
import { c as component } from "../common-4inKawxR.js";
|
|
4
|
-
import "../pxCheck-OnXlN1NC.js";
|
|
5
4
|
const { create } = createComponent("grid");
|
|
6
5
|
const _sfc_main = create(component);
|
|
7
6
|
export {
|