@nutui/nutui 3.1.22-beta.3 → 3.1.23-beta.0

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.
Files changed (207) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +3 -4
  3. package/dist/nutui.es.js +20426 -4050
  4. package/dist/nutui.umd.js +20529 -4049
  5. package/dist/packages/_es/ActionSheet.js +149 -36
  6. package/dist/packages/_es/Address.js +535 -129
  7. package/dist/packages/_es/AddressList.js +615 -113
  8. package/dist/packages/_es/Animate.js +64 -0
  9. package/dist/packages/_es/Audio.js +257 -72
  10. package/dist/packages/_es/AudioOperate.js +100 -32
  11. package/dist/packages/_es/Avatar.js +162 -54
  12. package/dist/packages/_es/AvatarGroup.js +73 -14
  13. package/dist/packages/_es/BackTop.js +156 -43
  14. package/dist/packages/_es/Badge.js +86 -14
  15. package/dist/packages/_es/Barrage.js +120 -41
  16. package/dist/packages/_es/Button.js +128 -23
  17. package/dist/packages/_es/Calendar.js +246 -24
  18. package/dist/packages/_es/CalendarItem.js +2 -1
  19. package/dist/packages/_es/Card.js +107 -10
  20. package/dist/packages/_es/Cascader.js +496 -179
  21. package/dist/packages/_es/Category.js +58 -15
  22. package/dist/packages/_es/CategoryPane.js +111 -11
  23. package/dist/packages/_es/Cell.js +108 -21
  24. package/dist/packages/_es/CellGroup.js +44 -9
  25. package/dist/packages/_es/Checkbox.js +134 -29
  26. package/dist/packages/_es/CheckboxGroup.js +79 -29
  27. package/dist/packages/_es/CircleProgress.js +150 -28
  28. package/dist/packages/_es/Col.js +56 -14
  29. package/dist/packages/_es/Collapse.js +110 -24
  30. package/dist/packages/_es/CollapseItem.js +252 -80
  31. package/dist/packages/_es/Comment.js +434 -64
  32. package/dist/packages/_es/ConfigProvider.js +25 -0
  33. package/dist/packages/_es/CountDown.js +238 -75
  34. package/dist/packages/_es/CountUp.js +539 -159
  35. package/dist/packages/_es/DatePicker.js +315 -117
  36. package/dist/packages/_es/Dialog.js +289 -79
  37. package/dist/packages/_es/Divider.js +65 -32
  38. package/dist/packages/_es/Drag.js +197 -56
  39. package/dist/packages/_es/Ecard.js +159 -24
  40. package/dist/packages/_es/Elevator.js +255 -77
  41. package/dist/packages/_es/Ellipsis.js +206 -0
  42. package/dist/packages/_es/Empty.js +71 -12
  43. package/dist/packages/_es/FixedNav.js +122 -15
  44. package/dist/packages/_es/Form.js +151 -64
  45. package/dist/packages/_es/FormItem.js +114 -15
  46. package/dist/packages/_es/Grid.js +6 -5
  47. package/dist/packages/_es/GridItem.js +144 -33
  48. package/dist/packages/_es/Icon.js +40 -15
  49. package/dist/packages/_es/Image.js +142 -0
  50. package/dist/packages/_es/ImagePreview.js +547 -84
  51. package/dist/packages/_es/Indicator.js +62 -15
  52. package/dist/packages/_es/InfiniteLoading.js +249 -76
  53. package/dist/packages/_es/Input.js +433 -51
  54. package/dist/packages/_es/InputNumber.js +160 -41
  55. package/dist/packages/_es/Layout.js +5 -4
  56. package/dist/packages/_es/List.js +106 -37
  57. package/dist/packages/_es/Menu.js +168 -29
  58. package/dist/packages/_es/MenuItem.js +173 -34
  59. package/dist/packages/_es/Navbar.js +192 -30
  60. package/dist/packages/_es/NoticeBar.js +380 -93
  61. package/dist/packages/_es/Notify.js +227 -91
  62. package/dist/packages/_es/NumberKeyboard.js +272 -41
  63. package/dist/packages/_es/OldPicker.js +457 -149
  64. package/dist/packages/_es/OverLay.js +98 -40
  65. package/dist/packages/_es/Pagination.js +157 -39
  66. package/dist/packages/_es/Picker.js +460 -148
  67. package/dist/packages/_es/Popover.js +957 -337
  68. package/dist/packages/_es/Popup.js +299 -74
  69. package/dist/packages/_es/Price.js +118 -16
  70. package/dist/packages/_es/Progress.js +146 -14
  71. package/dist/packages/_es/PullRefresh.js +339 -100
  72. package/dist/packages/_es/Radio.js +90 -22
  73. package/dist/packages/_es/RadioGroup.js +37 -8
  74. package/dist/packages/_es/Range.js +408 -102
  75. package/dist/packages/_es/Rate.js +193 -16
  76. package/dist/packages/_es/Row.js +64 -22
  77. package/dist/packages/_es/SearchBar.js +238 -56
  78. package/dist/packages/_es/ShortPassword.js +225 -35
  79. package/dist/packages/_es/SideNavBar.js +81 -43
  80. package/dist/packages/_es/SideNavBarItem.js +46 -11
  81. package/dist/packages/_es/Signature.js +160 -60
  82. package/dist/packages/_es/Skeleton.js +136 -20
  83. package/dist/packages/_es/Sku.js +491 -103
  84. package/dist/packages/_es/Step.js +115 -39
  85. package/dist/packages/_es/Steps.js +53 -18
  86. package/dist/packages/_es/Sticky.js +138 -53
  87. package/dist/packages/_es/SubSideNavBar.js +82 -36
  88. package/dist/packages/_es/Swipe.js +178 -60
  89. package/dist/packages/_es/Swiper.js +433 -121
  90. package/dist/packages/_es/SwiperItem.js +53 -22
  91. package/dist/packages/_es/Switch.js +116 -21
  92. package/dist/packages/_es/TabPane.js +39 -12
  93. package/dist/packages/_es/Tabbar.js +72 -17
  94. package/dist/packages/_es/TabbarItem.js +151 -29
  95. package/dist/packages/_es/Table.js +178 -37
  96. package/dist/packages/_es/Tabs.js +202 -59
  97. package/dist/packages/_es/Tag.js +97 -20
  98. package/dist/packages/_es/TextArea.js +160 -42
  99. package/dist/packages/_es/TimeDetail.js +79 -37
  100. package/dist/packages/_es/TimePannel.js +48 -33
  101. package/dist/packages/_es/TimeSelect.js +112 -15
  102. package/dist/packages/_es/Toast.js +310 -90
  103. package/dist/packages/_es/Uploader.js +455 -120
  104. package/dist/packages/_es/Video.js +332 -93
  105. package/dist/packages/_es/common.js +128 -38
  106. package/dist/packages/_es/component.js +76 -35
  107. package/dist/packages/_es/index.js +6 -5
  108. package/dist/packages/_es/index2.js +30 -9
  109. package/dist/packages/_es/index3.js +8 -6
  110. package/dist/packages/_es/index4.js +64 -13
  111. package/dist/packages/_es/index5.js +783 -130
  112. package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
  113. package/dist/packages/_es/pxCheck.js +5 -3
  114. package/dist/packages/_es/raf.js +15 -8
  115. package/dist/packages/animate/index.scss +299 -0
  116. package/dist/packages/cell/index.scss +7 -1
  117. package/dist/packages/checkbox/index.scss +10 -0
  118. package/dist/packages/configprovider/index.scss +2 -0
  119. package/dist/packages/ellipsis/index.scss +12 -0
  120. package/dist/packages/formitem/index.scss +12 -0
  121. package/dist/packages/griditem/index.scss +11 -0
  122. package/dist/packages/image/index.scss +39 -0
  123. package/dist/packages/imagepreview/index.scss +26 -2
  124. package/dist/packages/input/index.scss +13 -0
  125. package/dist/packages/inputnumber/index.scss +21 -0
  126. package/dist/packages/locale/lang/baseLang.js +3 -3
  127. package/dist/packages/locale/lang/en-US.js +105 -5
  128. package/dist/packages/locale/lang/id-ID.js +105 -5
  129. package/dist/packages/locale/lang/index.js +38 -16
  130. package/dist/packages/locale/lang/zh-CN.js +105 -5
  131. package/dist/packages/locale/lang/zh-TW.js +105 -5
  132. package/dist/packages/menu/index.scss +45 -36
  133. package/dist/packages/menuitem/index.scss +4 -0
  134. package/dist/packages/navbar/index.scss +9 -0
  135. package/dist/packages/pagination/index.scss +19 -0
  136. package/dist/packages/radio/index.scss +18 -0
  137. package/dist/packages/range/index.scss +19 -0
  138. package/dist/packages/rate/index.scss +1 -1
  139. package/dist/packages/searchbar/index.scss +21 -0
  140. package/dist/packages/switch/index.scss +1 -0
  141. package/dist/packages/tabbar/index.scss +5 -0
  142. package/dist/packages/tabbaritem/index.scss +7 -0
  143. package/dist/packages/tabpane/index.scss +5 -0
  144. package/dist/packages/tabs/index.scss +22 -0
  145. package/dist/packages/textarea/index.scss +8 -0
  146. package/dist/smartips/attributes.json +140 -4
  147. package/dist/smartips/tags.json +55 -6
  148. package/dist/smartips/web-types.json +6963 -0
  149. package/dist/style.css +1 -1
  150. package/dist/style.es.js +1 -1
  151. package/dist/styles/font/config.json +3 -1
  152. package/dist/styles/font/demo_index.html +49 -3
  153. package/dist/styles/font/iconfont.css +11 -3
  154. package/dist/styles/font/iconfont.js +15 -15
  155. package/dist/styles/font/iconfont.json +14 -0
  156. package/dist/styles/font/iconfont.ttf +0 -0
  157. package/dist/styles/font/iconfont.woff +0 -0
  158. package/dist/styles/font/iconfont.woff2 +0 -0
  159. package/dist/styles/themes/default.scss +54 -50
  160. package/dist/styles/themes/jdb.scss +54 -50
  161. package/dist/styles/themes/jdt.scss +54 -50
  162. package/dist/styles/variables-jdb.scss +12 -0
  163. package/dist/styles/variables-jdt.scss +12 -0
  164. package/dist/styles/variables.scss +12 -0
  165. package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
  166. package/dist/types/__VUE/address/index.vue.d.ts +7 -7
  167. package/dist/types/__VUE/animate/index.vue.d.ts +48 -0
  168. package/dist/types/__VUE/animate/type.d.ts +6 -0
  169. package/dist/types/__VUE/avatar/index.vue.d.ts +3 -3
  170. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  171. package/dist/types/__VUE/calendaritem/index.vue.d.ts +10 -2
  172. package/dist/types/__VUE/cascader/index.vue.d.ts +2 -2
  173. package/dist/types/__VUE/circleprogress/index.vue.d.ts +2 -2
  174. package/dist/types/__VUE/collapse/index.vue.d.ts +3 -1
  175. package/dist/types/__VUE/configprovider/common.d.ts +20 -0
  176. package/dist/types/__VUE/configprovider/index.vue.d.ts +33 -0
  177. package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
  178. package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
  179. package/dist/types/__VUE/ellipsis/index.vue.d.ts +72 -0
  180. package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
  181. package/dist/types/__VUE/grid/index.vue.d.ts +2 -2
  182. package/dist/types/__VUE/image/index.vue.d.ts +105 -0
  183. package/dist/types/__VUE/image/type.d.ts +6 -0
  184. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
  185. package/dist/types/__VUE/imagepreview/index.vue.d.ts +56 -24
  186. package/dist/types/__VUE/menu/index.vue.d.ts +31 -4
  187. package/dist/types/__VUE/menuitem/index.vue.d.ts +12 -3
  188. package/dist/types/__VUE/noticebar/index.vue.d.ts +1 -1
  189. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  190. package/dist/types/__VUE/oldpicker/index.vue.d.ts +4 -4
  191. package/dist/types/__VUE/picker/index.vue.d.ts +4 -4
  192. package/dist/types/__VUE/popover/index.vue.d.ts +8 -8
  193. package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
  194. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  195. package/dist/types/__VUE/rate/common.d.ts +149 -0
  196. package/dist/types/__VUE/rate/index.vue.d.ts +17 -7
  197. package/dist/types/__VUE/row/index.vue.d.ts +2 -2
  198. package/dist/types/__VUE/shortpassword/index.vue.d.ts +2 -2
  199. package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
  200. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  201. package/dist/types/__VUE/swiper/index.vue.d.ts +2 -2
  202. package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
  203. package/dist/types/__VUE/timeselect/index.vue.d.ts +3 -2
  204. package/dist/types/__VUE/uploader/uploader.d.ts +1 -0
  205. package/dist/types/index.d.ts +1 -1
  206. package/dist/types/nutui.d.ts +5 -1
  207. package/package.json +5 -4
@@ -1,20 +1,127 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.22-beta.3 Wed Jun 15 2022 20:12:30 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { computed as e, resolveComponent as t, openBlock as i, createElementBlock as l, normalizeClass as s, normalizeStyle as a, createBlock as n, createCommentVNode as o, renderSlot as c, createElementVNode as u, Fragment as v, renderList as r, toDisplayString as p, createVNode as d } from "vue";
7
- import { c as m } from "./component.js";
8
- import f from "./OverLay.js";
9
- import { _ as y } from "./plugin-vue_export-helper.js";
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: x, create: b, translate: _ } = m("fixednav"), g = b({ components: { [f.name]: f }, props: { visible: { type: Boolean, default: false }, overlay: { type: Boolean, default: true }, navList: { default: () => [], type: Array }, activeText: { default: "", type: String }, unActiveText: { default: "", type: String }, position: { default: () => ({ top: "auto", bottom: "auto" }), type: Object }, type: { default: "right", type: String } }, emits: ["update:visible", "selected"], setup: (t2, { emit: i2 }) => ({ classes: e(() => ({ [x]: true, active: t2.visible, [t2.type]: true })), updateValue: (e2 = !t2.visible) => {
12
- i2("update:visible", e2);
13
- }, selected: (e2, t3) => {
14
- i2("selected", { item: e2, event: t3 });
15
- }, translate: _ }) }), k = { class: "nut-fixednav__list" }, w = ["onClick"], T = ["src"], j = { class: "span" }, A = { key: 0, class: "b" }, C = { class: "text" };
16
- var L = y(g, [["render", function(e2, m2, f2, y2, x2, b2) {
17
- const _2 = t("nut-overlay"), g2 = t("nut-icon");
18
- return i(), l("view", { class: s(e2.classes), style: a(e2.position) }, [e2.overlay ? (i(), n(_2, { key: 0, visible: e2.visible, "z-index": 200, onClick: m2[0] || (m2[0] = (t2) => e2.updateValue(false)) }, null, 8, ["visible"])) : o("", true), c(e2.$slots, "list", {}, () => [u("view", k, [(i(true), l(v, null, r(e2.navList, (t2, s2) => (i(), l("view", { class: "nut-fixednav__list-item", onClick: (i2) => e2.selected(t2, i2), key: t2.id || s2 }, [u("img", { src: t2.icon }, null, 8, T), u("view", j, p(t2.text), 1), t2.num ? (i(), l("view", A, p(t2.num), 1)) : o("", true)], 8, w))), 128))])]), u("div", { class: "nut-fixednav__btn", onClick: m2[1] || (m2[1] = (t2) => e2.updateValue()) }, [c(e2.$slots, "btn", {}, () => [d(g2, { name: "left", color: "#fff" }), u("view", C, p(e2.visible ? e2.activeText || e2.translate("activeText") : e2.unActiveText || e2.translate("unActiveText")), 1)])])], 6);
19
- }]]);
20
- export { L as default };
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.22-beta.3 Wed Jun 15 2022 20:12:30 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { i as e, g as r, a as t, c as o } from "./component.js";
7
- import { computed as l, reactive as s, provide as n, watch as a, resolveComponent as i, openBlock as m, createElementBlock as p, withModifiers as u, createVNode as c, withCtx as d, renderSlot as f } from "vue";
8
- import { _ as h } from "./plugin-vue_export-helper.js";
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 v = { props: { modelValue: { type: Object, default: {} } }, components: {}, emits: ["validate"], setup(o2, { emit: i2, slots: m2 }) {
11
- const p2 = l(() => s({}));
12
- n("formErrorTip", p2);
13
- const u2 = (e2 = o2.modelValue) => {
14
- Object.keys(p2.value).forEach((e3) => {
15
- p2.value[e3] = "";
16
- });
17
- };
18
- a(() => o2.modelValue, (e2) => {
19
- u2();
20
- }, { immediate: true });
21
- const c2 = (r2) => {
22
- let t2 = [];
23
- return r2.forEach((r3, o3) => {
24
- var _a, _b, _c, _d;
25
- let l2 = r3.type;
26
- l2 = l2.name || l2, l2 == "nut-form-item" ? t2.push({ prop: (_a = r3.props) == null ? void 0 : _a.prop, rules: ((_b = r3.props) == null ? void 0 : _b.rules) || [] }) : Array.isArray(r3.children) && ((_c = r3.children) == null ? void 0 : _c.length) ? t2 = t2.concat(c2(r3.children)) : e(r3.children) && Object.keys(r3.children) && ((_d = r3.children) == null ? void 0 : _d.default) && (r3.children = r3.children.default(), t2 = t2.concat(c2(r3.children)));
27
- }), t2;
28
- }, d2 = (e2) => {
29
- e2.message && i2("validate", e2), p2.value[e2.prop] = e2.message;
30
- }, f2 = (e2) => {
31
- const { rules: l2, prop: s2 } = e2, n2 = (e3) => new Promise((r2, t2) => {
32
- d2(e3), r2(e3);
33
- });
34
- let a2 = r(o2.modelValue, s2 || "");
35
- d2({ prop: s2, message: "" });
36
- let i3 = [...l2];
37
- for (; i3.length; ) {
38
- const { required: e3, validator: r2, regex: o3, message: l3 } = i3.shift(), m3 = { prop: s2, message: l3 };
39
- if (e3 && !a2)
40
- return n2(m3);
41
- if (o3 && !o3.test(String(a2)))
42
- return n2(m3);
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 (!e4)
52
- return n2(m3);
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
- return Promise.resolve(true);
56
- }, h2 = (e2 = "") => new Promise((r2, t2) => {
57
- let o3 = c2(m2.default()).map((r3) => e2 ? e2 == r3.prop ? f2(r3) : Promise.resolve(true) : f2(r3));
58
- Promise.all(o3).then((e3) => {
59
- const t3 = { valid: true, errors: [] };
60
- (e3 = e3.filter((e4) => e4 != 1)).length && (t3.valid = false, t3.errors = e3), r2(t3);
61
- });
62
- });
63
- return { validate: h2, reset: () => {
64
- u2();
65
- }, onSubmit: () => (h2(), false), formErrorTip: p2 };
66
- } }, { create: g } = o("form");
67
- var y = h(g(v), [["render", function(e2, r2, t2, o2, l2, s2) {
68
- const n2 = i("nut-cell-group");
69
- return m(), p("form", { class: "nut-form", action: "#", onSubmit: r2[0] || (r2[0] = u(() => false, ["prevent"])) }, [c(n2, null, { default: d(() => [f(e2.$slots, "default")]), _: 3 })], 32);
70
- }]]);
71
- export { y as default };
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.22-beta.3 Wed Jun 15 2022 20:12:30 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { p as e } from "./pxCheck.js";
7
- import { inject as t, provide as r, computed as l, resolveComponent as o, openBlock as s, createBlock as a, normalizeClass as n, normalizeStyle as i, withCtx as p, createElementBlock as u, renderSlot as y, createTextVNode as m, toDisplayString as d, createCommentVNode as f, createElementVNode as g } from "vue";
8
- import { c } from "./component.js";
9
- import { _ as b } from "./plugin-vue_export-helper.js";
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: _, create: S } = c("form-item"), A = S({ inheritAttrs: false, props: { prop: { type: String, default: "" }, label: { type: String, default: "" }, rules: { type: Array, default: () => [] }, required: { type: Boolean, default: false }, showErrorMessage: { type: Boolean, default: true }, showErrorLine: { type: Boolean, default: true }, labelWidth: { type: [String, Number], default: "" }, labelAlign: { type: String, default: "" }, errorMessageAlign: { type: String, default: "" }, bodyAlign: { type: String, default: "" } }, components: {}, emits: [""], setup(o2, { emit: s2 }) {
12
- const a2 = t("formErrorTip");
13
- r("form", { props: o2 });
14
- return { parent: a2, labelStyle: l(() => ({ width: e(o2.labelWidth), textAlign: o2.labelAlign })), bodyStyle: l(() => ({ textAlign: o2.bodyAlign })), errorMessageStyle: l(() => ({ textAlign: o2.errorMessageAlign })) };
15
- } }), h = { class: "nut-cell__value nut-form-item__body" };
16
- var w = b(A, [["render", function(e2, t2, r2, l2, c2, b2) {
17
- const _2 = o("nut-cell");
18
- return s(), a(_2, { class: n(["nut-form-item", [{ error: e2.parent[e2.prop], line: e2.showErrorLine }, e2.$attrs.class]]), style: i(e2.$attrs.style) }, { default: p(() => [e2.label ? (s(), u("view", { key: 0, class: n(["nut-cell__title nut-form-item__label", { required: e2.required }]), style: i(e2.labelStyle) }, [y(e2.$slots, "label", {}, () => [m(d(e2.label), 1)])], 6)) : f("", true), g("view", h, [g("view", { class: "nut-form-item__body__slots", style: i(e2.bodyStyle) }, [y(e2.$slots, "default")], 4), e2.parent[e2.prop] && e2.showErrorMessage ? (s(), u("view", { key: 0, class: "nut-form-item__body__tips", style: i(e2.errorMessageStyle) }, d(e2.parent[e2.prop]), 5)) : f("", true)])]), _: 3 }, 8, ["class", "style"]);
19
- }]]);
20
- export { w as default };
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.22-beta.3 Wed Jun 15 2022 20:12:30 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { c as o } from "./component.js";
7
- import { c as m } from "./common.js";
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: r } = o("grid"), t = r(m);
12
- export { t as default };
11
+ const { create } = createComponent("grid");
12
+ const _sfc_main = create(component);
13
+ export { _sfc_main as default };