@nutui/nutui 4.0.0 → 4.0.1-2.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.
Files changed (285) hide show
  1. package/CHANGELOG.md +226 -0
  2. package/README.md +34 -65
  3. package/dist/nutui.es.js +10 -17
  4. package/dist/nutui.js +16202 -0
  5. package/dist/nutui.umd.js +1 -7
  6. package/dist/packages/_es/ActionSheet.js +79 -94
  7. package/dist/packages/_es/Address.js +260 -345
  8. package/dist/packages/_es/AddressList.js +269 -354
  9. package/dist/packages/_es/Animate.js +46 -38
  10. package/dist/packages/_es/Audio.js +128 -180
  11. package/dist/packages/_es/AudioOperate.js +60 -52
  12. package/dist/packages/_es/Avatar.js +67 -75
  13. package/dist/packages/_es/AvatarGroup.js +23 -31
  14. package/dist/packages/_es/Backtop.js +59 -99
  15. package/dist/packages/_es/Badge.js +39 -46
  16. package/dist/packages/_es/Barrage.js +68 -145
  17. package/dist/packages/_es/Button.js +47 -66
  18. package/dist/packages/_es/Calendar.js +135 -152
  19. package/dist/packages/_es/CalendarItem.js +6 -6
  20. package/dist/packages/_es/Card.js +42 -56
  21. package/dist/packages/_es/Cascader.js +323 -433
  22. package/dist/packages/_es/Category.js +29 -39
  23. package/dist/packages/_es/CategoryPane.js +57 -83
  24. package/dist/packages/_es/Cell.js +56 -71
  25. package/dist/packages/_es/CellGroup.js +19 -27
  26. package/dist/packages/_es/Checkbox.js +109 -138
  27. package/dist/packages/_es/CheckboxGroup.js +38 -61
  28. package/dist/packages/_es/CircleProgress.js +67 -96
  29. package/dist/packages/_es/Col.js +23 -31
  30. package/dist/packages/_es/Collapse.js +37 -67
  31. package/dist/packages/_es/CollapseItem.js +91 -184
  32. package/dist/packages/_es/Comment.js +207 -279
  33. package/dist/packages/_es/ConfigProvider.js +38 -56
  34. package/dist/packages/_es/Countdown.js +100 -194
  35. package/dist/packages/_es/Countup.js +232 -428
  36. package/dist/packages/_es/DatePicker.js +169 -245
  37. package/dist/packages/_es/Dialog.js +163 -188
  38. package/dist/packages/_es/Divider.js +42 -40
  39. package/dist/packages/_es/Drag.js +70 -153
  40. package/dist/packages/_es/Ecard.js +64 -104
  41. package/dist/packages/_es/Elevator.js +144 -201
  42. package/dist/packages/_es/Ellipsis.js +95 -159
  43. package/dist/packages/_es/Empty.js +23 -39
  44. package/dist/packages/_es/FixedNav.js +93 -116
  45. package/dist/packages/_es/Form.js +108 -164
  46. package/dist/packages/_es/FormItem.js +48 -61
  47. package/dist/packages/_es/Grid.js +5 -6
  48. package/dist/packages/_es/GridItem.js +58 -84
  49. package/dist/packages/_es/Image.js +98 -88
  50. package/dist/packages/_es/ImagePreview.js +262 -392
  51. package/dist/packages/_es/Indicator.js +30 -34
  52. package/dist/packages/_es/InfiniteLoading.js +83 -117
  53. package/dist/packages/_es/Input.js +176 -223
  54. package/dist/packages/_es/InputNumber.js +81 -117
  55. package/dist/packages/_es/Interceptor-6e26b757.js +18 -0
  56. package/dist/packages/_es/Invoice.js +105 -113
  57. package/dist/packages/_es/Layout.js +3 -4
  58. package/dist/packages/_es/List.js +147 -89
  59. package/dist/packages/_es/Menu.js +96 -152
  60. package/dist/packages/_es/MenuItem.js +117 -153
  61. package/dist/packages/_es/Navbar.js +103 -119
  62. package/dist/packages/_es/Noticebar.js +207 -273
  63. package/dist/packages/_es/Notify.js +110 -147
  64. package/dist/packages/_es/NumberKeyboard.js +127 -202
  65. package/dist/packages/_es/Overlay.js +53 -66
  66. package/dist/packages/_es/Pagination.js +70 -100
  67. package/dist/packages/_es/Picker.js +276 -425
  68. package/dist/packages/_es/Popover.js +122 -225
  69. package/dist/packages/_es/Popup.js +4 -4
  70. package/dist/packages/_es/Price.js +47 -80
  71. package/dist/packages/_es/Progress.js +63 -79
  72. package/dist/packages/_es/PullRefresh.js +96 -157
  73. package/dist/packages/_es/Radio.js +4 -4
  74. package/dist/packages/_es/RadioGroup.js +3 -3
  75. package/dist/packages/_es/Range.js +205 -329
  76. package/dist/packages/_es/Rate.js +93 -122
  77. package/dist/packages/_es/Row.js +21 -27
  78. package/dist/packages/_es/Searchbar.js +130 -160
  79. package/dist/packages/_es/ShortPassword.js +69 -93
  80. package/dist/packages/_es/SideNavbar.js +49 -59
  81. package/dist/packages/_es/SideNavbarItem.js +22 -32
  82. package/dist/packages/_es/Signature.js +83 -128
  83. package/dist/packages/_es/Skeleton.js +110 -130
  84. package/dist/packages/_es/Sku.js +251 -326
  85. package/dist/packages/_es/Step.js +60 -69
  86. package/dist/packages/_es/Steps.js +26 -31
  87. package/dist/packages/_es/Sticky.js +4 -4
  88. package/dist/packages/_es/SubSideNavbar.js +52 -56
  89. package/dist/packages/_es/Swipe.js +84 -137
  90. package/dist/packages/_es/Swiper.js +175 -310
  91. package/dist/packages/_es/SwiperItem.js +28 -44
  92. package/dist/packages/_es/Switch.js +55 -67
  93. package/dist/packages/_es/TabPane.js +32 -20
  94. package/dist/packages/_es/Tabbar.js +41 -52
  95. package/dist/packages/_es/TabbarItem.js +61 -81
  96. package/dist/packages/_es/Table.js +110 -148
  97. package/dist/packages/_es/Tabs.js +284 -205
  98. package/dist/packages/_es/Tag.js +44 -61
  99. package/dist/packages/_es/Textarea.js +80 -124
  100. package/dist/packages/_es/TimeDetail.js +49 -57
  101. package/dist/packages/_es/TimePannel.js +35 -31
  102. package/dist/packages/_es/TimeSelect.js +47 -68
  103. package/dist/packages/_es/Toast.js +150 -203
  104. package/dist/packages/_es/Tour.js +139 -175
  105. package/dist/packages/_es/TrendArrow.js +57 -58
  106. package/dist/packages/_es/Uploader.js +235 -359
  107. package/dist/packages/_es/Video.js +191 -298
  108. package/dist/packages/_es/Watermark.js +84 -98
  109. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +9 -0
  110. package/dist/packages/_es/common-d218746f.js +116 -0
  111. package/dist/packages/_es/component-234624bc.js +89 -0
  112. package/dist/packages/_es/index-14dfadc4.js +561 -0
  113. package/dist/packages/_es/index-192a3ef6.js +29 -0
  114. package/dist/packages/_es/index-360c5092.js +210 -0
  115. package/dist/packages/_es/index-496e6e05.js +24 -0
  116. package/dist/packages/_es/index-50eed3d9.js +7 -0
  117. package/dist/packages/_es/index-53ec2d4d.js +34 -0
  118. package/dist/packages/_es/index-fadb0974.js +8 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +43 -0
  120. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +77 -0
  121. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +110 -0
  122. package/dist/packages/_es/mountComponent-6d4ff200.js +23 -0
  123. package/dist/packages/_es/pxCheck-38173291.js +4 -0
  124. package/dist/packages/_es/raf-a74f1a06.js +16 -0
  125. package/dist/packages/_es/renderIcon-47498b32.js +5 -0
  126. package/dist/packages/actionsheet/index.scss +2 -0
  127. package/dist/packages/actionsheet/style.mjs +0 -2
  128. package/dist/packages/address/index.scss +5 -2
  129. package/dist/packages/address/style.mjs +0 -3
  130. package/dist/packages/addresslist/index.scss +3 -0
  131. package/dist/packages/addresslist/style.mjs +0 -2
  132. package/dist/packages/audio/index.scss +2 -0
  133. package/dist/packages/audio/style.mjs +0 -1
  134. package/dist/packages/audiooperate/index.scss +2 -0
  135. package/dist/packages/audiooperate/style.mjs +0 -1
  136. package/dist/packages/badge/index.scss +3 -0
  137. package/dist/packages/button/index.scss +1 -1
  138. package/dist/packages/calendar/index.scss +3 -0
  139. package/dist/packages/calendar/style.mjs +0 -3
  140. package/dist/packages/card/index.scss +3 -0
  141. package/dist/packages/card/style.mjs +0 -2
  142. package/dist/packages/cascader/index.scss +4 -0
  143. package/dist/packages/cascader/style.mjs +0 -5
  144. package/dist/packages/cellgroup/index.scss +1 -1
  145. package/dist/packages/checkbox/index.scss +41 -0
  146. package/dist/packages/col/index.scss +2 -2
  147. package/dist/packages/comment/index.scss +2 -0
  148. package/dist/packages/comment/style.mjs +0 -1
  149. package/dist/packages/datepicker/index.scss +1 -2
  150. package/dist/packages/datepicker/style.mjs +0 -3
  151. package/dist/packages/dialog/index.scss +11 -0
  152. package/dist/packages/dialog/style.mjs +0 -3
  153. package/dist/packages/ecard/index.scss +2 -0
  154. package/dist/packages/ecard/style.mjs +0 -1
  155. package/dist/packages/fixednav/index.scss +2 -0
  156. package/dist/packages/fixednav/style.mjs +0 -1
  157. package/dist/packages/form/index.scss +1 -2
  158. package/dist/packages/form/style.mjs +0 -1
  159. package/dist/packages/formitem/index.scss +3 -0
  160. package/dist/packages/formitem/style.mjs +0 -1
  161. package/dist/packages/imagepreview/index.scss +5 -5
  162. package/dist/packages/imagepreview/style.mjs +0 -5
  163. package/dist/packages/input/index.scss +13 -13
  164. package/dist/packages/invoice/index.scss +6 -0
  165. package/dist/packages/invoice/style.mjs +0 -7
  166. package/dist/packages/list/index.scss +8 -8
  167. package/dist/packages/menuitem/index.scss +9 -10
  168. package/dist/packages/menuitem/style.mjs +0 -2
  169. package/dist/packages/navbar/index.scss +0 -1
  170. package/dist/packages/noticebar/index.scss +12 -2
  171. package/dist/packages/notify/index.scss +2 -0
  172. package/dist/packages/notify/style.mjs +0 -2
  173. package/dist/packages/numberkeyboard/index.scss +2 -0
  174. package/dist/packages/numberkeyboard/style.mjs +0 -2
  175. package/dist/packages/picker/index.scss +4 -9
  176. package/dist/packages/picker/style.mjs +0 -2
  177. package/dist/packages/popover/index.scss +2 -0
  178. package/dist/packages/popover/style.mjs +0 -2
  179. package/dist/packages/popup/index.scss +2 -0
  180. package/dist/packages/popup/style.mjs +0 -1
  181. package/dist/packages/price/index.scss +5 -10
  182. package/dist/packages/rate/index.scss +6 -9
  183. package/dist/packages/searchbar/index.scss +4 -0
  184. package/dist/packages/shortpassword/index.scss +18 -0
  185. package/dist/packages/shortpassword/style.mjs +0 -2
  186. package/dist/packages/signature/index.scss +2 -0
  187. package/dist/packages/signature/style.mjs +0 -1
  188. package/dist/packages/skeleton/index.scss +2 -0
  189. package/dist/packages/skeleton/style.mjs +0 -1
  190. package/dist/packages/sku/index.scss +4 -0
  191. package/dist/packages/sku/style.mjs +0 -4
  192. package/dist/packages/tabbaritem/index.scss +2 -0
  193. package/dist/packages/tabbaritem/style.mjs +0 -1
  194. package/dist/packages/tabs/index.scss +36 -2
  195. package/dist/packages/tabs/style.mjs +0 -1
  196. package/dist/packages/textarea/index.scss +2 -0
  197. package/dist/packages/timeselect/index.scss +2 -0
  198. package/dist/packages/timeselect/style.mjs +0 -2
  199. package/dist/packages/tour/index.scss +2 -0
  200. package/dist/packages/tour/style.mjs +0 -3
  201. package/dist/packages/uploader/index.scss +10 -2
  202. package/dist/packages/uploader/style.mjs +0 -2
  203. package/dist/resolver/index.d.ts +6 -0
  204. package/dist/resolver/index.js +1 -0
  205. package/dist/resolver/index.mjs +24 -0
  206. package/dist/resolver/package.json +20 -0
  207. package/dist/smartips/web-types.json +114 -15
  208. package/dist/style.css +1 -1
  209. package/dist/styles/themes/default.scss +155 -52
  210. package/dist/styles/themes/jdb.scss +155 -52
  211. package/dist/styles/themes/jddkh.scss +155 -52
  212. package/dist/styles/themes/jdt.scss +155 -52
  213. package/dist/styles/variables-jdb.scss +9 -1
  214. package/dist/styles/variables-jddkh.scss +9 -1
  215. package/dist/styles/variables-jdt.scss +9 -1
  216. package/dist/styles/variables.scss +8 -0
  217. package/dist/types/__VUE/address/index.vue.d.ts +2 -1
  218. package/dist/types/__VUE/addresslist/components/GeneralShell.vue.d.ts +1 -1
  219. package/dist/types/__VUE/addresslist/components/ItemContents.vue.d.ts +1 -1
  220. package/dist/types/__VUE/addresslist/index.vue.d.ts +1 -1
  221. package/dist/types/__VUE/animate/index.vue.d.ts +6 -0
  222. package/dist/types/__VUE/audiooperate/index.vue.d.ts +4 -4
  223. package/dist/types/__VUE/badge/index.vue.d.ts +9 -0
  224. package/dist/types/__VUE/button/type.d.ts +1 -0
  225. package/dist/types/__VUE/calendaritem/type.d.ts +1 -0
  226. package/dist/types/__VUE/collapse/index.vue.d.ts +31 -5
  227. package/dist/types/__VUE/collapseitem/index.vue.d.ts +117 -11
  228. package/dist/types/__VUE/configprovider/index.vue.d.ts +2 -2
  229. package/dist/types/__VUE/datepicker/index.vue.d.ts +1 -1
  230. package/dist/types/__VUE/dialog/index.d.ts +1 -0
  231. package/dist/types/__VUE/dialog/index.vue.d.ts +1 -0
  232. package/dist/types/__VUE/grid/index.vue.d.ts +1 -1
  233. package/dist/types/__VUE/image/index.vue.d.ts +14 -3
  234. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +9 -0
  235. package/dist/types/__VUE/imagepreview/index.vue.d.ts +1 -1
  236. package/dist/types/__VUE/input/index.vue.d.ts +27 -2
  237. package/dist/types/__VUE/list/index.vue.d.ts +42 -13
  238. package/dist/types/__VUE/list/type.d.ts +13 -0
  239. package/dist/types/__VUE/menu/index.vue.d.ts +0 -2
  240. package/dist/types/__VUE/menuitem/index.vue.d.ts +9 -17
  241. package/dist/types/__VUE/navbar/index.vue.d.ts +1 -1
  242. package/dist/types/__VUE/noticebar/index.vue.d.ts +5 -2
  243. package/dist/types/__VUE/picker/common.d.ts +2 -0
  244. package/dist/types/__VUE/picker/usePicker.d.ts +1 -1
  245. package/dist/types/__VUE/price/index.vue.d.ts +9 -0
  246. package/dist/types/__VUE/rate/index.vue.d.ts +110 -3
  247. package/dist/types/__VUE/row/index.vue.d.ts +1 -1
  248. package/dist/types/__VUE/searchbar/index.vue.d.ts +121 -5
  249. package/dist/types/__VUE/skeleton/index.vue.d.ts +2 -2
  250. package/dist/types/__VUE/swiper/index.vue.d.ts +9 -2
  251. package/dist/types/__VUE/switch/index.vue.d.ts +1 -0
  252. package/dist/types/__VUE/table/common.d.ts +55 -2
  253. package/dist/types/__VUE/tabpane/index.vue.d.ts +1 -4
  254. package/dist/types/__VUE/tabs/hooks.d.ts +12 -0
  255. package/dist/types/__VUE/tabs/index.vue.d.ts +35 -5
  256. package/dist/types/__VUE/tabs/types.d.ts +12 -0
  257. package/dist/types/__VUE/timeselect/index.vue.d.ts +1 -1
  258. package/dist/types/__VUE/toast/index.vue.d.ts +11 -4
  259. package/dist/types/__VUE/uploader/type.d.ts +2 -1
  260. package/dist/types/__VUE/watermark/index.vue.d.ts +1 -1
  261. package/dist/types/index.d.ts +1 -2
  262. package/dist/types/resolver/index.d.ts +6 -0
  263. package/dist/types/utils/date.d.ts +4 -0
  264. package/dist/types/utils/useTaroRect/index.d.ts +1 -1
  265. package/dist/types/utils/util.d.ts +1 -1
  266. package/package.json +13 -6
  267. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +0 -10
  268. package/dist/packages/_es/common-b9a5e726.js +0 -145
  269. package/dist/packages/_es/component-81a4c1d0.js +0 -145
  270. package/dist/packages/_es/index-29892cda.js +0 -33
  271. package/dist/packages/_es/index-2ae3ae87.js +0 -846
  272. package/dist/packages/_es/index-43c34ac6.js +0 -30
  273. package/dist/packages/_es/index-54d03fc1.js +0 -8
  274. package/dist/packages/_es/index-79c5dc33.js +0 -10
  275. package/dist/packages/_es/index-7a7385e4.js +0 -67
  276. package/dist/packages/_es/index-991c279f.js +0 -244
  277. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +0 -46
  278. package/dist/packages/_es/index.vue_vue_type_script_lang-442e4704.js +0 -98
  279. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +0 -151
  280. package/dist/packages/_es/interceptor-956b24fc.js +0 -29
  281. package/dist/packages/_es/mountComponent-1ece4110.js +0 -39
  282. package/dist/packages/_es/pxCheck-c6b9f6b7.js +0 -6
  283. package/dist/packages/_es/raf-729dad54.js +0 -25
  284. package/dist/packages/_es/renderIcon-3d0fd47c.js +0 -9
  285. /package/dist/types/utils/{interceptor.d.ts → Interceptor.d.ts} +0 -0
@@ -1,181 +1,125 @@
1
- import { g as isObject, h as getPropByPath, f as isPromise, c as createComponent } from "./component-81a4c1d0.js";
2
- import { computed, reactive, provide, watch, resolveComponent, openBlock, createElementBlock, withModifiers, createVNode, withCtx, renderSlot } from "vue";
3
- import CellGroup from "./CellGroup.js";
4
- import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
1
+ var $ = Object.getOwnPropertySymbols;
2
+ var F = Object.prototype.hasOwnProperty, I = Object.prototype.propertyIsEnumerable;
3
+ var x = (l, i) => {
4
+ var m = {};
5
+ for (var o in l)
6
+ F.call(l, o) && i.indexOf(o) < 0 && (m[o] = l[o]);
7
+ if (l != null && $)
8
+ for (var o of $(l))
9
+ i.indexOf(o) < 0 && I.call(l, o) && (m[o] = l[o]);
10
+ return m;
11
+ };
12
+ import { g as T, h as A, f as N, c as W } from "./component-234624bc.js";
13
+ import { computed as q, reactive as G, provide as U, watch as z, resolveComponent as D, openBlock as H, createElementBlock as J, withModifiers as K, createVNode as L, withCtx as Q, renderSlot as X } from "vue";
14
+ import C from "./CellGroup.js";
15
+ import { _ as Y } from "./_plugin-vue_export-helper-dad06003.js";
5
16
  import "../locale/lang";
6
- const component = (components) => {
7
- return {
8
- props: {
9
- modelValue: {
10
- type: Object,
11
- default: {}
12
- },
13
- rules: {
14
- type: Object,
15
- default: {}
16
- }
17
+ const Z = (l) => ({
18
+ props: {
19
+ modelValue: {
20
+ type: Object,
21
+ default: {}
17
22
  },
18
- components,
19
- emits: ["validate"],
20
- setup(props, { emit, slots }) {
21
- const formErrorTip = computed(() => reactive({}));
22
- provide("formErrorTip", formErrorTip);
23
- const clearErrorTips = () => {
24
- Object.keys(formErrorTip.value).forEach((item) => {
25
- formErrorTip.value[item] = "";
26
- });
27
- };
28
- const reset = () => {
29
- clearErrorTips();
30
- };
31
- watch(
32
- () => props.modelValue,
33
- () => {
34
- clearErrorTips();
35
- },
36
- { immediate: true }
37
- );
38
- const findFormItem = (vnodes) => {
39
- let task = [];
40
- vnodes.forEach((vnode) => {
41
- var _a, _b, _c, _d;
42
- let type = vnode.type;
43
- type = type.name || type;
44
- if (type == "nut-form-item" || (type == null ? void 0 : type.toString().endsWith("form-item"))) {
45
- task.push({
46
- prop: (_a = vnode.props) == null ? void 0 : _a["prop"],
47
- rules: ((_b = vnode.props) == null ? void 0 : _b["rules"]) || []
48
- });
49
- } else if (Array.isArray(vnode.children) && ((_c = vnode.children) == null ? void 0 : _c.length)) {
50
- task = task.concat(findFormItem(vnode.children));
51
- } else if (isObject(vnode.children) && Object.keys(vnode.children)) {
52
- if ((_d = vnode.children) == null ? void 0 : _d.default) {
53
- vnode.children = vnode.children.default();
54
- task = task.concat(findFormItem(vnode.children));
55
- }
56
- }
57
- });
58
- return task;
59
- };
60
- const tipMessage = (errorMsg) => {
61
- if (errorMsg.message) {
62
- emit("validate", errorMsg);
63
- }
64
- formErrorTip.value[errorMsg.prop] = errorMsg.message;
65
- };
66
- const checkRule = (item) => {
67
- const { rules, prop } = item;
68
- const _Promise = (errorMsg) => {
69
- return new Promise((resolve, reject) => {
70
- try {
71
- tipMessage(errorMsg);
72
- resolve(errorMsg);
73
- } catch (error) {
74
- reject(error);
75
- }
76
- });
77
- };
78
- if (!prop) {
79
- console.warn("[NutUI] <FormItem> 使用 rules 校验规则时 , 必须设置 prop 参数");
80
- }
81
- const value = getPropByPath(props.modelValue, prop || "");
82
- tipMessage({ prop, message: "" });
83
- const formRules = props.rules || {};
84
- const _rules = [...(formRules == null ? void 0 : formRules[prop]) || [], ...rules];
85
- while (_rules.length) {
86
- const rule = _rules.shift();
87
- const { validator, ...ruleWithoutValidator } = rule;
88
- const { required, regex, message } = ruleWithoutValidator;
89
- const errorMsg = { prop, message };
90
- if (required) {
91
- if (!value) {
92
- return _Promise(errorMsg);
93
- }
94
- }
95
- if (regex && !regex.test(String(value))) {
96
- return _Promise(errorMsg);
97
- }
98
- if (validator) {
99
- const result = validator(value, ruleWithoutValidator);
100
- if (isPromise(result)) {
101
- return new Promise((r, j) => {
102
- result.then((res) => {
103
- if (!res) {
104
- tipMessage(errorMsg);
105
- r(errorMsg);
106
- } else {
107
- r(true);
108
- }
109
- }).catch((e) => j(e));
110
- });
111
- } else {
112
- if (!result) {
113
- return _Promise(errorMsg);
114
- }
115
- }
116
- }
23
+ rules: {
24
+ type: Object,
25
+ default: {}
26
+ }
27
+ },
28
+ components: l,
29
+ emits: ["validate"],
30
+ setup(i, { emit: m, slots: o }) {
31
+ const f = q(() => G({}));
32
+ U("formErrorTip", f);
33
+ const _ = () => {
34
+ Object.keys(f.value).forEach((s) => {
35
+ f.value[s] = "";
36
+ });
37
+ }, g = () => {
38
+ _();
39
+ };
40
+ z(
41
+ () => i.modelValue,
42
+ () => {
43
+ _();
44
+ },
45
+ { immediate: !0 }
46
+ );
47
+ const y = (s) => {
48
+ let n = [];
49
+ return s.forEach((e) => {
50
+ var c, t, a, u;
51
+ let r = e.type;
52
+ r = r.name || r, r == "nut-form-item" || r != null && r.toString().endsWith("form-item") ? n.push({
53
+ prop: (c = e.props) == null ? void 0 : c.prop,
54
+ rules: ((t = e.props) == null ? void 0 : t.rules) || []
55
+ }) : Array.isArray(e.children) && ((a = e.children) != null && a.length) ? n = n.concat(y(e.children)) : T(e.children) && Object.keys(e.children) && (u = e.children) != null && u.default && (e.children = e.children.default(), n = n.concat(y(e.children)));
56
+ }), n;
57
+ }, P = (s) => {
58
+ s.message && m("validate", s), f.value[s.prop] = s.message;
59
+ }, j = (s) => {
60
+ const { rules: n, prop: e } = s, r = (b) => new Promise((h, d) => {
61
+ try {
62
+ P(b), h(b);
63
+ } catch (k) {
64
+ d(k);
117
65
  }
118
- return Promise.resolve(true);
119
- };
120
- const validate = (customProp = "") => {
121
- return new Promise((resolve, reject) => {
122
- try {
123
- const task = findFormItem(slots.default());
124
- const errors = task.map((item) => {
125
- if (customProp) {
126
- if (customProp == item.prop) {
127
- return checkRule(item);
128
- } else {
129
- return Promise.resolve(true);
130
- }
131
- } else {
132
- return checkRule(item);
133
- }
66
+ });
67
+ e || console.warn("[NutUI] <FormItem> 使用 rules 校验规则时 , 必须设置 prop 参数");
68
+ const c = A(i.modelValue, e || "");
69
+ P({ prop: e, message: "" });
70
+ const t = i.rules || {}, a = [...(t == null ? void 0 : t[e]) || [], ...n];
71
+ for (; a.length; ) {
72
+ const u = a.shift(), { validator: h } = u, d = x(u, ["validator"]), { required: k, regex: O, message: S } = d, p = { prop: e, message: S };
73
+ if (k && !c && c !== 0 || O && !O.test(String(c)))
74
+ return r(p);
75
+ if (h) {
76
+ const w = h(c, d);
77
+ if (N(w))
78
+ return new Promise((V, B) => {
79
+ w.then((E) => {
80
+ E ? V(!0) : (P(p), V(p));
81
+ }).catch((E) => B(E));
134
82
  });
135
- Promise.all(errors).then((errorRes) => {
136
- errorRes = errorRes.filter((item) => item != true);
137
- const res = { valid: true, errors: [] };
138
- if (errorRes.length) {
139
- res.valid = false;
140
- res.errors = errorRes;
141
- }
142
- resolve(res);
143
- });
144
- } catch (error) {
145
- reject(error);
146
- }
83
+ if (!w)
84
+ return r(p);
85
+ }
86
+ }
87
+ return Promise.resolve(!0);
88
+ }, v = (s = "") => new Promise((n, e) => {
89
+ try {
90
+ const c = y(o.default()).map((t) => s ? s == t.prop ? j(t) : Promise.resolve(!0) : j(t));
91
+ Promise.all(c).then((t) => {
92
+ t = t.filter((u) => u != !0);
93
+ const a = { valid: !0, errors: [] };
94
+ t.length && (a.valid = !1, a.errors = t), n(a);
147
95
  });
148
- };
149
- const submit = () => {
150
- validate();
151
- return false;
152
- };
153
- return { validate, reset, submit, formErrorTip };
154
- }
155
- };
156
- };
157
- const { create } = createComponent("form");
158
- const _sfc_main = create(
159
- component({
160
- [CellGroup.name]: CellGroup
96
+ } catch (r) {
97
+ e(r);
98
+ }
99
+ });
100
+ return { validate: v, reset: g, submit: () => (v(), !1), formErrorTip: f };
101
+ }
102
+ }), { create: M } = W("form"), R = M(
103
+ Z({
104
+ [C.name]: C
161
105
  })
162
106
  );
163
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
164
- const _component_nut_cell_group = resolveComponent("nut-cell-group");
165
- return openBlock(), createElementBlock("form", {
107
+ function ee(l, i, m, o, f, _) {
108
+ const g = D("nut-cell-group");
109
+ return H(), J("form", {
166
110
  class: "nut-form",
167
111
  action: "#",
168
- onSubmit: _cache[0] || (_cache[0] = withModifiers(() => false, ["prevent"]))
112
+ onSubmit: i[0] || (i[0] = K(() => !1, ["prevent"]))
169
113
  }, [
170
- createVNode(_component_nut_cell_group, null, {
171
- default: withCtx(() => [
172
- renderSlot(_ctx.$slots, "default")
114
+ L(g, null, {
115
+ default: Q(() => [
116
+ X(l.$slots, "default")
173
117
  ]),
174
118
  _: 3
175
119
  })
176
120
  ], 32);
177
121
  }
178
- const Form = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
122
+ const ce = /* @__PURE__ */ Y(R, [["render", ee]]);
179
123
  export {
180
- Form as default
124
+ ce as default
181
125
  };
@@ -1,14 +1,13 @@
1
- import { p as pxCheck } from "./pxCheck-c6b9f6b7.js";
2
- import { inject, provide, computed, resolveComponent, openBlock, createBlock, normalizeClass, normalizeStyle, withCtx, createElementBlock, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createElementVNode } from "vue";
3
- import { c as createComponent } from "./component-81a4c1d0.js";
4
- import Cell from "./Cell.js";
5
- import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
1
+ import { p as S } from "./pxCheck-38173291.js";
2
+ import { inject as h, provide as _, computed as l, resolveComponent as A, openBlock as o, createBlock as w, normalizeClass as m, normalizeStyle as t, withCtx as $, createElementBlock as p, renderSlot as u, createTextVNode as v, toDisplayString as d, createCommentVNode as y, createElementVNode as f } from "vue";
3
+ import { c as C } from "./component-234624bc.js";
4
+ import c from "./Cell.js";
5
+ import { _ as E } from "./_plugin-vue_export-helper-dad06003.js";
6
6
  import "../locale/lang";
7
- import "./index-54d03fc1.js";
7
+ import "./index-50eed3d9.js";
8
8
  import "@nutui/icons-vue";
9
- const { componentName, create } = createComponent("form-item");
10
- const _sfc_main = create({
11
- inheritAttrs: false,
9
+ const { componentName: I, create: k } = C("form-item"), B = k({
10
+ inheritAttrs: !1,
12
11
  props: {
13
12
  prop: {
14
13
  type: String,
@@ -20,21 +19,19 @@ const _sfc_main = create({
20
19
  },
21
20
  rules: {
22
21
  type: Array,
23
- default: () => {
24
- return [];
25
- }
22
+ default: () => []
26
23
  },
27
24
  required: {
28
25
  type: Boolean,
29
- default: false
26
+ default: !1
30
27
  },
31
28
  showErrorMessage: {
32
29
  type: Boolean,
33
- default: true
30
+ default: !0
34
31
  },
35
32
  showErrorLine: {
36
33
  type: Boolean,
37
- default: true
34
+ default: !0
38
35
  },
39
36
  labelWidth: {
40
37
  type: [String, Number],
@@ -54,69 +51,59 @@ const _sfc_main = create({
54
51
  }
55
52
  },
56
53
  components: {
57
- [Cell.name]: Cell
54
+ [c.name]: c
58
55
  },
59
56
  emits: [""],
60
- setup(props, { emit, slots }) {
61
- const parent = inject("formErrorTip");
62
- provide("form", {
63
- props
57
+ setup(e, { emit: g, slots: n }) {
58
+ const s = h("formErrorTip");
59
+ _("form", {
60
+ props: e
64
61
  });
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
- const getSlots = (name) => slots[name];
82
- return { parent, labelStyle, bodyStyle, errorMessageStyle, getSlots };
62
+ const a = l(() => ({
63
+ width: S(e.labelWidth),
64
+ textAlign: e.labelAlign
65
+ })), i = l(() => ({
66
+ textAlign: e.bodyAlign
67
+ })), r = l(() => ({
68
+ textAlign: e.errorMessageAlign
69
+ }));
70
+ return { parent: s, labelStyle: a, bodyStyle: i, errorMessageStyle: r, getSlots: (b) => n[b] };
83
71
  }
84
- });
85
- const _hoisted_1 = { class: "nut-cell__value nut-form-item__body" };
86
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
87
- const _component_nut_cell = resolveComponent("nut-cell");
88
- return openBlock(), createBlock(_component_nut_cell, {
89
- class: normalizeClass(["nut-form-item", [{ error: _ctx.parent[_ctx.prop], line: _ctx.showErrorLine }, _ctx.$attrs.class]]),
90
- style: normalizeStyle(_ctx.$attrs.style)
72
+ }), M = { class: "nut-cell__value nut-form-item__body" };
73
+ function N(e, g, n, s, a, i) {
74
+ const r = A("nut-cell");
75
+ return o(), w(r, {
76
+ class: m(["nut-form-item", [{ error: e.parent[e.prop], line: e.showErrorLine }, e.$attrs.class]]),
77
+ style: t(e.$attrs.style)
91
78
  }, {
92
- default: withCtx(() => [
93
- _ctx.label || _ctx.getSlots("label") ? (openBlock(), createElementBlock("view", {
79
+ default: $(() => [
80
+ e.label || e.getSlots("label") ? (o(), p("view", {
94
81
  key: 0,
95
- class: normalizeClass(["nut-cell__title nut-form-item__label", { required: _ctx.required }]),
96
- style: normalizeStyle(_ctx.labelStyle)
82
+ class: m(["nut-cell__title nut-form-item__label", { required: e.required }]),
83
+ style: t(e.labelStyle)
97
84
  }, [
98
- renderSlot(_ctx.$slots, "label", {}, () => [
99
- createTextVNode(toDisplayString(_ctx.label), 1)
85
+ u(e.$slots, "label", {}, () => [
86
+ v(d(e.label), 1)
100
87
  ])
101
- ], 6)) : createCommentVNode("", true),
102
- createElementVNode("view", _hoisted_1, [
103
- createElementVNode("view", {
88
+ ], 6)) : y("", !0),
89
+ f("view", M, [
90
+ f("view", {
104
91
  class: "nut-form-item__body__slots",
105
- style: normalizeStyle(_ctx.bodyStyle)
92
+ style: t(e.bodyStyle)
106
93
  }, [
107
- renderSlot(_ctx.$slots, "default")
94
+ u(e.$slots, "default")
108
95
  ], 4),
109
- _ctx.parent[_ctx.prop] && _ctx.showErrorMessage ? (openBlock(), createElementBlock("view", {
96
+ e.parent[e.prop] && e.showErrorMessage ? (o(), p("view", {
110
97
  key: 0,
111
98
  class: "nut-form-item__body__tips",
112
- style: normalizeStyle(_ctx.errorMessageStyle)
113
- }, toDisplayString(_ctx.parent[_ctx.prop]), 5)) : createCommentVNode("", true)
99
+ style: t(e.errorMessageStyle)
100
+ }, d(e.parent[e.prop]), 5)) : y("", !0)
114
101
  ])
115
102
  ]),
116
103
  _: 3
117
104
  }, 8, ["class", "style"]);
118
105
  }
119
- const FormItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
106
+ const G = /* @__PURE__ */ E(B, [["render", N]]);
120
107
  export {
121
- FormItem as default
108
+ G as default
122
109
  };
@@ -1,10 +1,9 @@
1
- import { c as createComponent } from "./component-81a4c1d0.js";
1
+ import { c as o } from "./component-234624bc.js";
2
2
  import "vue";
3
- import { c as component } from "./common-b9a5e726.js";
3
+ import { c as t } from "./common-d218746f.js";
4
4
  import "../locale/lang";
5
- import "./pxCheck-c6b9f6b7.js";
6
- const { create } = createComponent("grid");
7
- const _sfc_main = create(component);
5
+ import "./pxCheck-38173291.js";
6
+ const { create: r } = o("grid"), i = r(t);
8
7
  export {
9
- _sfc_main as default
8
+ i as default
10
9
  };
@@ -1,30 +1,27 @@
1
- import { inject, getCurrentInstance, onUnmounted, computed, ref, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot, Fragment, createTextVNode, toDisplayString } from "vue";
2
- import { u as useRouter } from "./index-54d03fc1.js";
3
- import { c as createComponent } from "./component-81a4c1d0.js";
4
- import { p as pxCheck } from "./pxCheck-c6b9f6b7.js";
5
- import { G as GRID_KEY } from "./common-b9a5e726.js";
6
- import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
1
+ import { inject as k, getCurrentInstance as y, onUnmounted as x, computed as a, ref as h, openBlock as u, createElementBlock as d, normalizeClass as m, normalizeStyle as S, createElementVNode as p, renderSlot as f, Fragment as v, createTextVNode as b, toDisplayString as N } from "vue";
2
+ import { u as _ } from "./index-50eed3d9.js";
3
+ import { c as B } from "./component-234624bc.js";
4
+ import { p as $ } from "./pxCheck-38173291.js";
5
+ import { G as j } from "./common-d218746f.js";
6
+ import { _ as q } from "./_plugin-vue_export-helper-dad06003.js";
7
7
  import "../locale/lang";
8
- function useInject(key) {
9
- const parent = inject(key, null);
10
- if (parent) {
11
- const instance = getCurrentInstance();
12
- const { add, remove, internalChildren } = parent;
13
- add(instance);
14
- onUnmounted(() => remove(instance));
15
- const index2 = computed(() => internalChildren.indexOf(instance));
8
+ function w(e) {
9
+ const n = k(e, null);
10
+ if (n) {
11
+ const o = y(), { add: s, remove: t, internalChildren: i } = n;
12
+ s(o), x(() => t(o));
13
+ const l = a(() => i.indexOf(o));
16
14
  return {
17
- parent,
18
- index: index2
15
+ parent: n,
16
+ index: l
19
17
  };
20
18
  }
21
19
  return {
22
20
  parent: null,
23
- index: ref(-1)
21
+ index: h(-1)
24
22
  };
25
23
  }
26
- const { create, componentName } = createComponent("grid-item");
27
- const _sfc_main = create({
24
+ const { create: E, componentName: C } = B("grid-item"), I = E({
28
25
  props: {
29
26
  text: {
30
27
  type: String
@@ -39,86 +36,63 @@ const _sfc_main = create({
39
36
  },
40
37
  replace: {
41
38
  type: Boolean,
42
- default: false
39
+ default: !1
43
40
  }
44
41
  },
45
42
  emits: ["click"],
46
- setup(props, { emit }) {
47
- const Parent = useInject(GRID_KEY);
48
- if (!Parent.parent)
43
+ setup(e, { emit: n }) {
44
+ const o = w(j);
45
+ if (!o.parent)
49
46
  return {};
50
- const index2 = Parent.index;
51
- const parent = Parent.parent.props;
52
- const rootClass = computed(() => {
53
- const prefixCls = componentName;
54
- return {
55
- [prefixCls]: true
56
- };
57
- });
58
- const rootStyle = computed(() => {
59
- const style = {
60
- flexBasis: `${100 / +parent.columnNum}%`
47
+ const s = o.index, t = o.parent.props, i = a(() => ({
48
+ [C]: !0
49
+ })), l = a(() => {
50
+ const r = {
51
+ flexBasis: `${100 / +t.columnNum}%`
61
52
  };
62
- if (parent.square) {
63
- style.paddingTop = `${100 / +parent.columnNum}%`;
64
- } else if (parent.gutter) {
65
- style.paddingRight = pxCheck(parent.gutter);
66
- if (index2.value >= parent.columnNum) {
67
- style.marginTop = pxCheck(parent.gutter);
68
- }
69
- }
70
- return style;
71
- });
72
- const contentClass = computed(() => {
73
- const prefixCls = `${componentName}__content`;
53
+ return t.square ? r.paddingTop = `${100 / +t.columnNum}%` : t.gutter && (r.paddingRight = $(t.gutter), s.value >= t.columnNum && (r.marginTop = $(t.gutter))), r;
54
+ }), g = a(() => {
55
+ const r = `${C}__content`;
74
56
  return {
75
- [`${prefixCls}`]: true,
76
- [`${prefixCls}--border`]: parent.border,
77
- [`${prefixCls}--surround`]: parent.border && parent.gutter,
78
- [`${prefixCls}--center`]: parent.center,
79
- [`${prefixCls}--square`]: parent.square,
80
- [`${prefixCls}--reverse`]: parent.reverse,
81
- [`${prefixCls}--${parent.direction}`]: !!parent.direction,
82
- [`${prefixCls}--clickable`]: parent.clickable || props.to || props.url
57
+ [`${r}`]: !0,
58
+ [`${r}--border`]: t.border,
59
+ [`${r}--surround`]: t.border && t.gutter,
60
+ [`${r}--center`]: t.center,
61
+ [`${r}--square`]: t.square,
62
+ [`${r}--reverse`]: t.reverse,
63
+ [`${r}--${t.direction}`]: !!t.direction,
64
+ [`${r}--clickable`]: t.clickable || e.to || e.url
83
65
  };
84
- });
85
- const router = useRouter();
86
- const handleClick = (event) => {
87
- emit("click", event);
88
- if (props.to && router) {
89
- router[props.replace ? "replace" : "push"](props.to);
90
- } else if (props.url) {
91
- props.replace ? location.replace(props.url) : location.href = props.url;
92
- }
93
- };
66
+ }), c = _();
94
67
  return {
95
- rootClass,
96
- rootStyle,
97
- contentClass,
98
- handleClick
68
+ rootClass: i,
69
+ rootStyle: l,
70
+ contentClass: g,
71
+ handleClick: (r) => {
72
+ n("click", r), e.to && c ? c[e.replace ? "replace" : "push"](e.to) : e.url && (e.replace ? location.replace(e.url) : location.href = e.url);
73
+ }
99
74
  };
100
75
  }
101
- });
102
- const _hoisted_1 = { class: "nut-grid-item__text" };
103
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
104
- return openBlock(), createElementBlock("view", {
105
- class: normalizeClass(_ctx.rootClass),
106
- style: normalizeStyle(_ctx.rootStyle),
107
- onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
76
+ }), R = { class: "nut-grid-item__text" };
77
+ function T(e, n, o, s, t, i) {
78
+ return u(), d("view", {
79
+ class: m(e.rootClass),
80
+ style: S(e.rootStyle),
81
+ onClick: n[0] || (n[0] = (...l) => e.handleClick && e.handleClick(...l))
108
82
  }, [
109
- createElementVNode("view", {
110
- class: normalizeClass(_ctx.contentClass)
83
+ p("view", {
84
+ class: m(e.contentClass)
111
85
  }, [
112
- renderSlot(_ctx.$slots, "default"),
113
- createElementVNode("view", _hoisted_1, [
114
- _ctx.text ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
115
- createTextVNode(toDisplayString(_ctx.text), 1)
116
- ], 64)) : renderSlot(_ctx.$slots, "text", { key: 1 })
86
+ f(e.$slots, "default"),
87
+ p("view", R, [
88
+ e.text ? (u(), d(v, { key: 0 }, [
89
+ b(N(e.text), 1)
90
+ ], 64)) : f(e.$slots, "text", { key: 1 })
117
91
  ])
118
92
  ], 2)
119
93
  ], 6);
120
94
  }
121
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
95
+ const U = /* @__PURE__ */ q(I, [["render", T]]);
122
96
  export {
123
- index as default
97
+ U as default
124
98
  };