@nutui/nutui 3.1.22-beta.5 → 3.1.23-beta.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 +48 -0
- package/README.md +3 -4
- package/dist/nutui.es.js +20412 -4214
- package/dist/nutui.umd.js +20518 -4216
- package/dist/packages/_es/ActionSheet.js +149 -17
- package/dist/packages/_es/Address.js +535 -110
- package/dist/packages/_es/AddressList.js +615 -113
- package/dist/packages/_es/Animate.js +59 -17
- package/dist/packages/_es/Audio.js +257 -53
- package/dist/packages/_es/AudioOperate.js +100 -13
- package/dist/packages/_es/Avatar.js +162 -38
- package/dist/packages/_es/AvatarGroup.js +73 -14
- package/dist/packages/_es/BackTop.js +156 -43
- package/dist/packages/_es/Badge.js +86 -14
- package/dist/packages/_es/Barrage.js +120 -41
- package/dist/packages/_es/Button.js +128 -23
- package/dist/packages/_es/Calendar.js +246 -30
- package/dist/packages/_es/CalendarItem.js +1 -1
- package/dist/packages/_es/Card.js +107 -10
- package/dist/packages/_es/Cascader.js +496 -147
- package/dist/packages/_es/Category.js +58 -15
- package/dist/packages/_es/CategoryPane.js +111 -11
- package/dist/packages/_es/Cell.js +108 -21
- package/dist/packages/_es/CellGroup.js +44 -9
- package/dist/packages/_es/Checkbox.js +134 -29
- package/dist/packages/_es/CheckboxGroup.js +79 -29
- package/dist/packages/_es/CircleProgress.js +150 -28
- package/dist/packages/_es/Col.js +56 -14
- package/dist/packages/_es/Collapse.js +109 -32
- package/dist/packages/_es/CollapseItem.js +253 -59
- package/dist/packages/_es/Comment.js +434 -64
- package/dist/packages/_es/ConfigProvider.js +20 -8
- package/dist/packages/_es/CountDown.js +238 -56
- package/dist/packages/_es/CountUp.js +539 -140
- package/dist/packages/_es/DatePicker.js +315 -98
- package/dist/packages/_es/Dialog.js +289 -60
- package/dist/packages/_es/Divider.js +65 -13
- package/dist/packages/_es/Drag.js +197 -56
- package/dist/packages/_es/Ecard.js +159 -24
- package/dist/packages/_es/Elevator.js +255 -58
- package/dist/packages/_es/Ellipsis.js +200 -58
- package/dist/packages/_es/Empty.js +71 -12
- package/dist/packages/_es/FixedNav.js +122 -15
- package/dist/packages/_es/Form.js +151 -64
- package/dist/packages/_es/FormItem.js +114 -15
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +144 -33
- package/dist/packages/_es/Icon.js +40 -15
- package/dist/packages/_es/Image.js +137 -26
- package/dist/packages/_es/ImagePreview.js +547 -76
- package/dist/packages/_es/Indicator.js +62 -15
- package/dist/packages/_es/InfiniteLoading.js +249 -57
- package/dist/packages/_es/Input.js +433 -51
- package/dist/packages/_es/InputNumber.js +160 -41
- package/dist/packages/_es/Layout.js +5 -4
- package/dist/packages/_es/List.js +106 -18
- package/dist/packages/_es/Menu.js +168 -44
- package/dist/packages/_es/MenuItem.js +173 -37
- package/dist/packages/_es/Navbar.js +192 -30
- package/dist/packages/_es/NoticeBar.js +380 -74
- package/dist/packages/_es/Notify.js +227 -72
- package/dist/packages/_es/NumberKeyboard.js +272 -41
- package/dist/packages/_es/OldPicker.js +457 -130
- package/dist/packages/_es/OverLay.js +98 -24
- package/dist/packages/_es/Pagination.js +157 -39
- package/dist/packages/_es/Picker.js +454 -129
- package/dist/packages/_es/Popover.js +957 -318
- package/dist/packages/_es/Popup.js +299 -55
- package/dist/packages/_es/Price.js +118 -16
- package/dist/packages/_es/Progress.js +146 -14
- package/dist/packages/_es/PullRefresh.js +339 -84
- package/dist/packages/_es/Radio.js +90 -22
- package/dist/packages/_es/RadioGroup.js +37 -8
- package/dist/packages/_es/Range.js +408 -83
- package/dist/packages/_es/Rate.js +192 -36
- package/dist/packages/_es/Row.js +64 -22
- package/dist/packages/_es/SearchBar.js +238 -37
- package/dist/packages/_es/ShortPassword.js +225 -35
- package/dist/packages/_es/SideNavBar.js +81 -24
- package/dist/packages/_es/SideNavBarItem.js +46 -11
- package/dist/packages/_es/Signature.js +160 -41
- package/dist/packages/_es/Skeleton.js +136 -20
- package/dist/packages/_es/Sku.js +491 -84
- package/dist/packages/_es/Step.js +115 -20
- package/dist/packages/_es/Steps.js +53 -18
- package/dist/packages/_es/Sticky.js +138 -53
- package/dist/packages/_es/SubSideNavBar.js +82 -17
- package/dist/packages/_es/Swipe.js +178 -41
- package/dist/packages/_es/Swiper.js +433 -121
- package/dist/packages/_es/SwiperItem.js +53 -22
- package/dist/packages/_es/Switch.js +116 -21
- package/dist/packages/_es/TabPane.js +39 -12
- package/dist/packages/_es/Tabbar.js +72 -17
- package/dist/packages/_es/TabbarItem.js +151 -29
- package/dist/packages/_es/Table.js +178 -18
- package/dist/packages/_es/Tabs.js +202 -43
- package/dist/packages/_es/Tag.js +97 -20
- package/dist/packages/_es/TextArea.js +160 -42
- package/dist/packages/_es/TimeDetail.js +79 -18
- package/dist/packages/_es/TimePannel.js +48 -14
- package/dist/packages/_es/TimeSelect.js +112 -15
- package/dist/packages/_es/Toast.js +310 -71
- package/dist/packages/_es/Uploader.js +455 -104
- package/dist/packages/_es/Video.js +332 -74
- package/dist/packages/_es/common.js +128 -38
- package/dist/packages/_es/component.js +76 -35
- package/dist/packages/_es/index.js +6 -5
- package/dist/packages/_es/index2.js +30 -9
- package/dist/packages/_es/index3.js +8 -6
- package/dist/packages/_es/index4.js +64 -13
- package/dist/packages/_es/index5.js +780 -164
- package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
- package/dist/packages/_es/pxCheck.js +5 -3
- package/dist/packages/_es/raf.js +15 -8
- package/dist/packages/imagepreview/index.scss +6 -1
- package/dist/packages/locale/lang/baseLang.js +3 -3
- package/dist/packages/locale/lang/en-US.js +105 -5
- package/dist/packages/locale/lang/id-ID.js +105 -5
- package/dist/packages/locale/lang/index.js +38 -16
- package/dist/packages/locale/lang/zh-CN.js +105 -5
- package/dist/packages/locale/lang/zh-TW.js +105 -5
- package/dist/packages/picker/index.scss +13 -0
- package/dist/smartips/attributes.json +8 -0
- package/dist/smartips/tags.json +3 -1
- package/dist/smartips/web-types.json +19 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +49 -49
- package/dist/styles/themes/jdb.scss +49 -49
- package/dist/styles/themes/jdt.scss +49 -49
- package/dist/styles/variables-jdb.scss +4 -1
- package/dist/styles/variables-jdt.scss +4 -1
- package/dist/styles/variables.scss +1 -1
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
- package/dist/types/__VUE/address/index.vue.d.ts +4 -4
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
- package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
- package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
- package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
- package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
- package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
- package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
- package/dist/types/__VUE/infiniteloading/index.vue.d.ts +6 -6
- package/dist/types/__VUE/input/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
- package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +1 -1
- package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
- package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
- package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
- package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,17 +1,76 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { toRefs
|
|
7
|
-
import { c } from "./component.js";
|
|
8
|
-
import { _ as
|
|
6
|
+
import { toRefs, computed, openBlock, createElementBlock, createElementVNode, normalizeStyle, renderSlot, Fragment, createCommentVNode, toDisplayString } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
|
-
const { componentName
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const { componentName, create, translate } = createComponent("empty");
|
|
11
|
+
const defaultStatus = {
|
|
12
|
+
empty: "https://static-ftcms.jd.com/p/files/61a9e3183985005b3958672b.png",
|
|
13
|
+
error: "https://ftcms.jd.com/p/files/61a9e33ee7dcdbcc0ce62736.png",
|
|
14
|
+
network: "https://static-ftcms.jd.com/p/files/61a9e31de7dcdbcc0ce62734.png"
|
|
15
|
+
};
|
|
16
|
+
const _sfc_main = create({
|
|
17
|
+
props: {
|
|
18
|
+
image: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: "empty"
|
|
21
|
+
},
|
|
22
|
+
imageSize: {
|
|
23
|
+
type: [Number, String],
|
|
24
|
+
default: ""
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ""
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
setup(props) {
|
|
32
|
+
const { image, imageSize } = toRefs(props);
|
|
33
|
+
const imgStyle = computed(() => {
|
|
34
|
+
if (!imageSize.value) {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
if (typeof imageSize.value === "number") {
|
|
38
|
+
return `width:${imageSize.value}px;height:${imageSize.value}px`;
|
|
39
|
+
}
|
|
40
|
+
return `width:${imageSize.value};height:${imageSize.value}`;
|
|
41
|
+
});
|
|
42
|
+
const isHttpUrl = image.value.startsWith("https://") || image.value.startsWith("http://") || image.value.startsWith("//");
|
|
43
|
+
const imageUrl = isHttpUrl ? image.value : defaultStatus[image.value];
|
|
44
|
+
return {
|
|
45
|
+
imageUrl,
|
|
46
|
+
imgStyle,
|
|
47
|
+
translate
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const _hoisted_1 = { class: "nut-empty" };
|
|
52
|
+
const _hoisted_2 = ["src"];
|
|
53
|
+
const _hoisted_3 = {
|
|
54
|
+
key: 1,
|
|
55
|
+
class: "nut-empty-description"
|
|
56
|
+
};
|
|
57
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
58
|
+
return openBlock(), createElementBlock("view", _hoisted_1, [
|
|
59
|
+
createElementVNode("view", {
|
|
60
|
+
class: "nut-empty-image",
|
|
61
|
+
style: normalizeStyle(_ctx.imgStyle)
|
|
62
|
+
}, [
|
|
63
|
+
_ctx.$slots.image ? renderSlot(_ctx.$slots, "image", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
64
|
+
_ctx.imageUrl ? (openBlock(), createElementBlock("img", {
|
|
65
|
+
key: 0,
|
|
66
|
+
class: "img",
|
|
67
|
+
src: _ctx.imageUrl
|
|
68
|
+
}, null, 8, _hoisted_2)) : createCommentVNode("", true)
|
|
69
|
+
], 64))
|
|
70
|
+
], 4),
|
|
71
|
+
_ctx.$slots.description ? renderSlot(_ctx.$slots, "description", { key: 0 }) : (openBlock(), createElementBlock("view", _hoisted_3, toDisplayString(_ctx.description || _ctx.translate("noData")), 1)),
|
|
72
|
+
_ctx.$slots.default ? renderSlot(_ctx.$slots, "default", { key: 2 }) : createCommentVNode("", true)
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
76
|
+
export { index as default };
|
|
@@ -1,20 +1,127 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { computed
|
|
7
|
-
import { c as
|
|
8
|
-
import
|
|
9
|
-
import { _ as
|
|
6
|
+
import { computed, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createBlock, createCommentVNode, renderSlot, createElementVNode, Fragment, renderList, toDisplayString, createVNode } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import overlay from "./OverLay.js";
|
|
9
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
10
10
|
import "../locale/lang";
|
|
11
|
-
const { componentName
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const { componentName, create, translate } = createComponent("fixednav");
|
|
12
|
+
const _sfc_main = create({
|
|
13
|
+
components: {
|
|
14
|
+
[overlay.name]: overlay
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
visible: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
overlay: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true
|
|
24
|
+
},
|
|
25
|
+
navList: {
|
|
26
|
+
default: () => [],
|
|
27
|
+
type: Array
|
|
28
|
+
},
|
|
29
|
+
activeText: {
|
|
30
|
+
default: "",
|
|
31
|
+
type: String
|
|
32
|
+
},
|
|
33
|
+
unActiveText: {
|
|
34
|
+
default: "",
|
|
35
|
+
type: String
|
|
36
|
+
},
|
|
37
|
+
position: {
|
|
38
|
+
default: () => {
|
|
39
|
+
return {
|
|
40
|
+
top: "auto",
|
|
41
|
+
bottom: "auto"
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
type: Object
|
|
45
|
+
},
|
|
46
|
+
type: {
|
|
47
|
+
default: "right",
|
|
48
|
+
type: String
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
emits: ["update:visible", "selected"],
|
|
52
|
+
setup(props, { emit }) {
|
|
53
|
+
const classes = computed(() => {
|
|
54
|
+
const prefixCls = componentName;
|
|
55
|
+
return {
|
|
56
|
+
[prefixCls]: true,
|
|
57
|
+
active: props.visible,
|
|
58
|
+
[props.type]: true
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const updateValue = (value = !props.visible) => {
|
|
62
|
+
emit("update:visible", value);
|
|
63
|
+
};
|
|
64
|
+
const selected = (item, event) => {
|
|
65
|
+
emit("selected", {
|
|
66
|
+
item,
|
|
67
|
+
event
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return { classes, updateValue, selected, translate };
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const _hoisted_1 = { class: "nut-fixednav__list" };
|
|
74
|
+
const _hoisted_2 = ["onClick"];
|
|
75
|
+
const _hoisted_3 = ["src"];
|
|
76
|
+
const _hoisted_4 = { class: "span" };
|
|
77
|
+
const _hoisted_5 = {
|
|
78
|
+
key: 0,
|
|
79
|
+
class: "b"
|
|
80
|
+
};
|
|
81
|
+
const _hoisted_6 = { class: "text" };
|
|
82
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
83
|
+
const _component_nut_overlay = resolveComponent("nut-overlay");
|
|
84
|
+
const _component_nut_icon = resolveComponent("nut-icon");
|
|
85
|
+
return openBlock(), createElementBlock("view", {
|
|
86
|
+
class: normalizeClass(_ctx.classes),
|
|
87
|
+
style: normalizeStyle(_ctx.position)
|
|
88
|
+
}, [
|
|
89
|
+
_ctx.overlay ? (openBlock(), createBlock(_component_nut_overlay, {
|
|
90
|
+
key: 0,
|
|
91
|
+
visible: _ctx.visible,
|
|
92
|
+
"z-index": 200,
|
|
93
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.updateValue(false))
|
|
94
|
+
}, null, 8, ["visible"])) : createCommentVNode("", true),
|
|
95
|
+
renderSlot(_ctx.$slots, "list", {}, () => [
|
|
96
|
+
createElementVNode("view", _hoisted_1, [
|
|
97
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.navList, (item, index2) => {
|
|
98
|
+
return openBlock(), createElementBlock("view", {
|
|
99
|
+
class: "nut-fixednav__list-item",
|
|
100
|
+
onClick: ($event) => _ctx.selected(item, $event),
|
|
101
|
+
key: item.id || index2
|
|
102
|
+
}, [
|
|
103
|
+
createElementVNode("img", {
|
|
104
|
+
src: item.icon
|
|
105
|
+
}, null, 8, _hoisted_3),
|
|
106
|
+
createElementVNode("view", _hoisted_4, toDisplayString(item.text), 1),
|
|
107
|
+
item.num ? (openBlock(), createElementBlock("view", _hoisted_5, toDisplayString(item.num), 1)) : createCommentVNode("", true)
|
|
108
|
+
], 8, _hoisted_2);
|
|
109
|
+
}), 128))
|
|
110
|
+
])
|
|
111
|
+
]),
|
|
112
|
+
createElementVNode("div", {
|
|
113
|
+
class: "nut-fixednav__btn",
|
|
114
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.updateValue())
|
|
115
|
+
}, [
|
|
116
|
+
renderSlot(_ctx.$slots, "btn", {}, () => [
|
|
117
|
+
createVNode(_component_nut_icon, {
|
|
118
|
+
name: "left",
|
|
119
|
+
color: "#fff"
|
|
120
|
+
}),
|
|
121
|
+
createElementVNode("view", _hoisted_6, toDisplayString(_ctx.visible ? _ctx.activeText || _ctx.translate("activeText") : _ctx.unActiveText || _ctx.translate("unActiveText")), 1)
|
|
122
|
+
])
|
|
123
|
+
])
|
|
124
|
+
], 6);
|
|
125
|
+
}
|
|
126
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
127
|
+
export { index as default };
|
|
@@ -1,71 +1,158 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { i as
|
|
7
|
-
import { computed
|
|
8
|
-
import { _ as
|
|
6
|
+
import { i as isObject, g as getPropByPath, a as isPromise, c as createComponent } from "./component.js";
|
|
7
|
+
import { computed, reactive, provide, watch, resolveComponent, openBlock, createElementBlock, withModifiers, createVNode, withCtx, renderSlot } from "vue";
|
|
8
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (r2) {
|
|
44
|
-
const e4 = r2(a2);
|
|
45
|
-
if (t(e4))
|
|
46
|
-
return new Promise((r3, t2) => {
|
|
47
|
-
e4.then((e5) => {
|
|
48
|
-
e5 ? r3(true) : (d2(m3), r3(m3));
|
|
49
|
-
});
|
|
10
|
+
const component = {
|
|
11
|
+
props: {
|
|
12
|
+
modelValue: {
|
|
13
|
+
type: Object,
|
|
14
|
+
default: {}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
components: {},
|
|
18
|
+
emits: ["validate"],
|
|
19
|
+
setup(props, { emit, slots }) {
|
|
20
|
+
const formErrorTip = computed(() => reactive({}));
|
|
21
|
+
provide("formErrorTip", formErrorTip);
|
|
22
|
+
const clearErrorTips = (value = props.modelValue) => {
|
|
23
|
+
Object.keys(formErrorTip.value).forEach((item) => {
|
|
24
|
+
formErrorTip.value[item] = "";
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const reset = () => {
|
|
28
|
+
clearErrorTips();
|
|
29
|
+
};
|
|
30
|
+
watch(() => props.modelValue, (value) => {
|
|
31
|
+
clearErrorTips(value);
|
|
32
|
+
}, { immediate: true });
|
|
33
|
+
const findFormItem = (vnodes) => {
|
|
34
|
+
let task = [];
|
|
35
|
+
vnodes.forEach((vnode, index2) => {
|
|
36
|
+
var _a, _b, _c, _d;
|
|
37
|
+
let type = vnode.type;
|
|
38
|
+
type = type.name || type;
|
|
39
|
+
if (type == "nut-form-item") {
|
|
40
|
+
task.push({
|
|
41
|
+
prop: (_a = vnode.props) == null ? void 0 : _a["prop"],
|
|
42
|
+
rules: ((_b = vnode.props) == null ? void 0 : _b["rules"]) || []
|
|
50
43
|
});
|
|
51
|
-
if (
|
|
52
|
-
|
|
44
|
+
} else if (Array.isArray(vnode.children) && ((_c = vnode.children) == null ? void 0 : _c.length)) {
|
|
45
|
+
task = task.concat(findFormItem(vnode.children));
|
|
46
|
+
} else if (isObject(vnode.children) && Object.keys(vnode.children)) {
|
|
47
|
+
if ((_d = vnode.children) == null ? void 0 : _d.default) {
|
|
48
|
+
vnode.children = vnode.children.default();
|
|
49
|
+
task = task.concat(findFormItem(vnode.children));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return task;
|
|
54
|
+
};
|
|
55
|
+
const tipMessage = (errorMsg) => {
|
|
56
|
+
if (errorMsg.message) {
|
|
57
|
+
emit("validate", errorMsg);
|
|
53
58
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
formErrorTip.value[errorMsg.prop] = errorMsg.message;
|
|
60
|
+
};
|
|
61
|
+
const checkRule = (item) => {
|
|
62
|
+
const { rules, prop } = item;
|
|
63
|
+
const _Promise = (errorMsg) => {
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
tipMessage(errorMsg);
|
|
66
|
+
resolve(errorMsg);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
if (!prop) {
|
|
70
|
+
console.warn("[NutUI] <FormItem> \u4F7F\u7528 rules \u6821\u9A8C\u89C4\u5219\u65F6 , \u5FC5\u987B\u8BBE\u7F6E prop \u53C2\u6570");
|
|
71
|
+
}
|
|
72
|
+
let value = getPropByPath(props.modelValue, prop || "");
|
|
73
|
+
tipMessage({ prop, message: "" });
|
|
74
|
+
let _rules = [...rules];
|
|
75
|
+
while (_rules.length) {
|
|
76
|
+
const { required, validator, regex, message } = _rules.shift();
|
|
77
|
+
const errorMsg = { prop, message };
|
|
78
|
+
if (required) {
|
|
79
|
+
if (!value) {
|
|
80
|
+
return _Promise(errorMsg);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (regex && !regex.test(String(value))) {
|
|
84
|
+
return _Promise(errorMsg);
|
|
85
|
+
}
|
|
86
|
+
if (validator) {
|
|
87
|
+
const result = validator(value);
|
|
88
|
+
if (isPromise(result)) {
|
|
89
|
+
return new Promise((r, j) => {
|
|
90
|
+
result.then((res) => {
|
|
91
|
+
if (!res) {
|
|
92
|
+
tipMessage(errorMsg);
|
|
93
|
+
r(errorMsg);
|
|
94
|
+
} else {
|
|
95
|
+
r(true);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
if (!result) {
|
|
101
|
+
return _Promise(errorMsg);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return Promise.resolve(true);
|
|
107
|
+
};
|
|
108
|
+
const validate = (customProp = "") => {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
let task = findFormItem(slots.default());
|
|
111
|
+
let errors = task.map((item) => {
|
|
112
|
+
if (customProp) {
|
|
113
|
+
if (customProp == item.prop) {
|
|
114
|
+
return checkRule(item);
|
|
115
|
+
} else {
|
|
116
|
+
return Promise.resolve(true);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
return checkRule(item);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
Promise.all(errors).then((errorRes) => {
|
|
123
|
+
errorRes = errorRes.filter((item) => item != true);
|
|
124
|
+
const res = { valid: true, errors: [] };
|
|
125
|
+
if (errorRes.length) {
|
|
126
|
+
res.valid = false;
|
|
127
|
+
res.errors = errorRes;
|
|
128
|
+
}
|
|
129
|
+
resolve(res);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
const onSubmit = () => {
|
|
134
|
+
validate();
|
|
135
|
+
return false;
|
|
136
|
+
};
|
|
137
|
+
return { validate, reset, onSubmit, formErrorTip };
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const { create } = createComponent("form");
|
|
141
|
+
const _sfc_main = create(component);
|
|
142
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
143
|
+
const _component_nut_cell_group = resolveComponent("nut-cell-group");
|
|
144
|
+
return openBlock(), createElementBlock("form", {
|
|
145
|
+
class: "nut-form",
|
|
146
|
+
action: "#",
|
|
147
|
+
onSubmit: _cache[0] || (_cache[0] = withModifiers(() => false, ["prevent"]))
|
|
148
|
+
}, [
|
|
149
|
+
createVNode(_component_nut_cell_group, null, {
|
|
150
|
+
default: withCtx(() => [
|
|
151
|
+
renderSlot(_ctx.$slots, "default")
|
|
152
|
+
]),
|
|
153
|
+
_: 3
|
|
154
|
+
})
|
|
155
|
+
], 32);
|
|
156
|
+
}
|
|
157
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
158
|
+
export { index as default };
|
|
@@ -1,20 +1,119 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { p as
|
|
7
|
-
import { inject
|
|
8
|
-
import { c } from "./component.js";
|
|
9
|
-
import { _ as
|
|
6
|
+
import { p as pxCheck } from "./pxCheck.js";
|
|
7
|
+
import { inject, provide, computed, resolveComponent, openBlock, createBlock, normalizeClass, normalizeStyle, withCtx, createElementBlock, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createElementVNode } from "vue";
|
|
8
|
+
import { c as createComponent } from "./component.js";
|
|
9
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
10
10
|
import "../locale/lang";
|
|
11
|
-
const { componentName
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const { componentName, create } = createComponent("form-item");
|
|
12
|
+
const _sfc_main = create({
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: {
|
|
15
|
+
prop: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: ""
|
|
18
|
+
},
|
|
19
|
+
label: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default: () => {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
required: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
showErrorMessage: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
showErrorLine: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: true
|
|
40
|
+
},
|
|
41
|
+
labelWidth: {
|
|
42
|
+
type: [String, Number],
|
|
43
|
+
default: ""
|
|
44
|
+
},
|
|
45
|
+
labelAlign: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: ""
|
|
48
|
+
},
|
|
49
|
+
errorMessageAlign: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: ""
|
|
52
|
+
},
|
|
53
|
+
bodyAlign: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: ""
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
components: {},
|
|
59
|
+
emits: [""],
|
|
60
|
+
setup(props, { emit }) {
|
|
61
|
+
const parent = inject("formErrorTip");
|
|
62
|
+
provide("form", {
|
|
63
|
+
props
|
|
64
|
+
});
|
|
65
|
+
const labelStyle = computed(() => {
|
|
66
|
+
return {
|
|
67
|
+
width: pxCheck(props.labelWidth),
|
|
68
|
+
textAlign: props.labelAlign
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
const bodyStyle = computed(() => {
|
|
72
|
+
return {
|
|
73
|
+
textAlign: props.bodyAlign
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
const errorMessageStyle = computed(() => {
|
|
77
|
+
return {
|
|
78
|
+
textAlign: props.errorMessageAlign
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
return { parent, labelStyle, bodyStyle, errorMessageStyle };
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const _hoisted_1 = { class: "nut-cell__value nut-form-item__body" };
|
|
85
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
86
|
+
const _component_nut_cell = resolveComponent("nut-cell");
|
|
87
|
+
return openBlock(), createBlock(_component_nut_cell, {
|
|
88
|
+
class: normalizeClass(["nut-form-item", [{ error: _ctx.parent[_ctx.prop], line: _ctx.showErrorLine }, _ctx.$attrs.class]]),
|
|
89
|
+
style: normalizeStyle(_ctx.$attrs.style)
|
|
90
|
+
}, {
|
|
91
|
+
default: withCtx(() => [
|
|
92
|
+
_ctx.label ? (openBlock(), createElementBlock("view", {
|
|
93
|
+
key: 0,
|
|
94
|
+
class: normalizeClass(["nut-cell__title nut-form-item__label", { required: _ctx.required }]),
|
|
95
|
+
style: normalizeStyle(_ctx.labelStyle)
|
|
96
|
+
}, [
|
|
97
|
+
renderSlot(_ctx.$slots, "label", {}, () => [
|
|
98
|
+
createTextVNode(toDisplayString(_ctx.label), 1)
|
|
99
|
+
])
|
|
100
|
+
], 6)) : createCommentVNode("", true),
|
|
101
|
+
createElementVNode("view", _hoisted_1, [
|
|
102
|
+
createElementVNode("view", {
|
|
103
|
+
class: "nut-form-item__body__slots",
|
|
104
|
+
style: normalizeStyle(_ctx.bodyStyle)
|
|
105
|
+
}, [
|
|
106
|
+
renderSlot(_ctx.$slots, "default")
|
|
107
|
+
], 4),
|
|
108
|
+
_ctx.parent[_ctx.prop] && _ctx.showErrorMessage ? (openBlock(), createElementBlock("view", {
|
|
109
|
+
key: 0,
|
|
110
|
+
class: "nut-form-item__body__tips",
|
|
111
|
+
style: normalizeStyle(_ctx.errorMessageStyle)
|
|
112
|
+
}, toDisplayString(_ctx.parent[_ctx.prop]), 5)) : createCommentVNode("", true)
|
|
113
|
+
])
|
|
114
|
+
]),
|
|
115
|
+
_: 3
|
|
116
|
+
}, 8, ["class", "style"]);
|
|
117
|
+
}
|
|
118
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
119
|
+
export { index as default };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { c as
|
|
7
|
-
import { c as
|
|
6
|
+
import { c as createComponent } from "./component.js";
|
|
7
|
+
import { c as component } from "./common.js";
|
|
8
8
|
import "vue";
|
|
9
9
|
import "../locale/lang";
|
|
10
10
|
import "./pxCheck.js";
|
|
11
|
-
const { create
|
|
12
|
-
|
|
11
|
+
const { create } = createComponent("grid");
|
|
12
|
+
const _sfc_main = create(component);
|
|
13
|
+
export { _sfc_main as default };
|