@nutui/nutui-react-taro 2.0.0-alpha.5 → 2.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/esm/ActionSheet.js +15 -16
  3. package/dist/esm/Address.js +19 -20
  4. package/dist/esm/Animate.js +7 -8
  5. package/dist/esm/AnimatingNumbers.js +8 -9
  6. package/dist/esm/Audio.js +17 -19
  7. package/dist/esm/Avatar.js +11 -13
  8. package/dist/esm/AvatarGroup.js +8 -9
  9. package/dist/esm/BackTop.js +9 -10
  10. package/dist/esm/Badge.js +7 -8
  11. package/dist/esm/Barrage.js +9 -10
  12. package/dist/esm/Button.js +8 -9
  13. package/dist/esm/Calendar.js +18 -20
  14. package/dist/esm/CalendarItem.js +11 -13
  15. package/dist/esm/Card.js +12 -13
  16. package/dist/esm/Cascader.js +16 -19
  17. package/dist/esm/Cell.js +7 -8
  18. package/dist/esm/CellGroup.js +7 -8
  19. package/dist/esm/Checkbox.js +9 -10
  20. package/dist/esm/CheckboxGroup.js +9 -10
  21. package/dist/esm/CircleProgress.js +8 -9
  22. package/dist/esm/Col.js +8 -9
  23. package/dist/esm/Collapse.js +8 -9
  24. package/dist/esm/CollapseItem.js +7 -8
  25. package/dist/esm/ConfigProvider.js +9 -8
  26. package/dist/esm/CountDown.js +8 -10
  27. package/dist/esm/DatePicker.js +21 -23
  28. package/dist/esm/Dialog.js +13 -15
  29. package/dist/esm/Divider.js +7 -8
  30. package/dist/esm/Drag.js +7 -8
  31. package/dist/esm/Elevator.js +9 -10
  32. package/dist/esm/Ellipsis.js +9 -10
  33. package/dist/esm/Empty.js +7 -9
  34. package/dist/esm/FixedNav.js +11 -13
  35. package/dist/esm/Form.js +10 -11
  36. package/dist/esm/FormItem.js +8 -9
  37. package/dist/esm/Grid.js +8 -10
  38. package/dist/esm/GridItem.js +7 -9
  39. package/dist/esm/Image.js +7 -9
  40. package/dist/esm/ImagePreview.js +19 -20
  41. package/dist/esm/Indicator.js +6 -7
  42. package/dist/esm/Infiniteloading.js +12 -14
  43. package/dist/esm/Input.js +11 -13
  44. package/dist/esm/InputNumber.js +9 -10
  45. package/dist/esm/Layout.js +5 -6
  46. package/dist/esm/Menu.js +8 -9
  47. package/dist/esm/MenuItem.js +13 -14
  48. package/dist/esm/NavBar.js +7 -8
  49. package/dist/esm/NoticeBar.js +11 -12
  50. package/dist/esm/Notify.js +9 -10
  51. package/dist/esm/NumberKeyboard.js +16 -18
  52. package/dist/esm/Overlay.js +8 -9
  53. package/dist/esm/Pagination.js +9 -11
  54. package/dist/esm/Picker.js +20 -22
  55. package/dist/esm/Popover.js +10 -11
  56. package/dist/esm/Popup.js +12 -13
  57. package/dist/esm/Price.js +7 -8
  58. package/dist/esm/Progress.js +7 -8
  59. package/dist/esm/PullToRefresh.js +11 -13
  60. package/dist/esm/Radio.js +9 -10
  61. package/dist/esm/RadioGroup.js +9 -10
  62. package/dist/esm/Range.js +13 -15
  63. package/dist/esm/Rate.js +9 -10
  64. package/dist/esm/Row.js +8 -9
  65. package/dist/esm/SearchBar.js +11 -13
  66. package/dist/esm/ShortPassword.js +16 -18
  67. package/dist/esm/SideNavBar.js +14 -15
  68. package/dist/esm/SideNavBarItem.js +5 -6
  69. package/dist/esm/Signature.js +13 -15
  70. package/dist/esm/Skeleton.js +14 -16
  71. package/dist/esm/Step.js +10 -11
  72. package/dist/esm/Steps.js +9 -10
  73. package/dist/esm/Sticky.js +11 -12
  74. package/dist/esm/SubSideNavBar.js +6 -7
  75. package/dist/esm/Swipe.js +11 -12
  76. package/dist/esm/Swiper.js +10 -11
  77. package/dist/esm/SwiperItem.js +9 -10
  78. package/dist/esm/Switch.js +7 -8
  79. package/dist/esm/TabPane.js +6 -7
  80. package/dist/esm/Tabbar.js +10 -11
  81. package/dist/esm/TabbarItem.js +8 -9
  82. package/dist/esm/Table.js +9 -13
  83. package/dist/esm/Tabs.js +11 -12
  84. package/dist/esm/Tag.js +8 -9
  85. package/dist/esm/TextArea.js +11 -10
  86. package/dist/esm/TimeDetail.js +8 -10
  87. package/dist/esm/TimePannel.js +8 -10
  88. package/dist/esm/TimeSelect.js +18 -20
  89. package/dist/esm/Toast.js +9 -10
  90. package/dist/esm/TrendArrow.js +8 -9
  91. package/dist/esm/Uploader.js +14 -16
  92. package/dist/esm/UserContext-735db09f.js +5 -0
  93. package/dist/esm/UserContext-ab42ba7f.js +5 -0
  94. package/dist/esm/UserContext-fde5badc.js +5 -0
  95. package/dist/esm/Video.js +8 -9
  96. package/dist/esm/VirtualList.js +8 -10
  97. package/dist/esm/WaterMark.js +10 -12
  98. package/dist/esm/actionsheet.taro-d2217152.js +61 -0
  99. package/dist/esm/address.taro-1c534feb.js +470 -0
  100. package/dist/esm/animate.taro-c8b29242.js +44 -0
  101. package/dist/esm/animatingnumbers.taro-c2a52dbd.js +103 -0
  102. package/dist/esm/audio.taro-ec96ef80.js +185 -0
  103. package/dist/esm/avatar.taro-01536aff.js +100 -0
  104. package/dist/esm/avatargroup-ad5ffb46.js +34 -0
  105. package/dist/esm/backtop.taro-7de36464.js +48 -0
  106. package/dist/esm/badge.taro-872605bf.js +48 -0
  107. package/dist/esm/barrage.taro-c8cb9864.js +91 -0
  108. package/dist/esm/bem-cdccae08.js +5 -0
  109. package/dist/esm/button.taro-01eae688.js +72 -0
  110. package/dist/esm/calendar.taro-10a6cb11.js +70 -0
  111. package/dist/esm/calendaritem.taro-3e5f114e.js +732 -0
  112. package/dist/esm/can-use-dom-0e539bd3.js +4 -0
  113. package/dist/esm/card.taro-a46fdf25.js +51 -0
  114. package/dist/esm/cascader.taro-0a2694ed.js +463 -0
  115. package/dist/esm/cell.taro-4e31d1fa.js +48 -0
  116. package/dist/esm/cellgroup.taro-a790d91b.js +28 -0
  117. package/dist/esm/checkbox.taro-016074da.js +177 -0
  118. package/dist/esm/circleprogress.taro-7149e09d.js +104 -0
  119. package/dist/esm/col.taro-d6a46a7d.js +41 -0
  120. package/dist/esm/collapse.taro-3d997680.js +70 -0
  121. package/dist/esm/collapseitem-f4571575.js +76 -0
  122. package/dist/esm/configprovider.taro-25758d9f.js +462 -0
  123. package/dist/esm/context-d0fccf11.js +5 -0
  124. package/dist/esm/countdown.taro-22200811.js +210 -0
  125. package/dist/esm/datepicker.taro-3f718964.js +260 -0
  126. package/dist/esm/dialog.taro-290eb9a6.js +128 -0
  127. package/dist/esm/divider.taro-0cb5f894.js +31 -0
  128. package/dist/esm/drag.taro-48e1ff38.js +111 -0
  129. package/dist/esm/elevator.taro-bc162e4f.js +201 -0
  130. package/dist/esm/ellipsis.taro-f9688dd7.js +242 -0
  131. package/dist/esm/empty.taro-ca792f57.js +59 -0
  132. package/dist/esm/fixednav.taro-28e5f776.js +61 -0
  133. package/dist/esm/form.taro-b06754e8.js +182 -0
  134. package/dist/esm/formitem.taro-b326809d.js +108 -0
  135. package/dist/esm/get-scroll-parent-8da04f2e.js +24 -0
  136. package/dist/esm/grid.taro-fbbd8618.js +52 -0
  137. package/dist/esm/griditem.taro-b0c37077.js +85 -0
  138. package/dist/esm/image.taro-767aa000.js +65 -0
  139. package/dist/esm/imagepreview.taro-8832dc01.js +163 -0
  140. package/dist/esm/index-e3184f19.js +9 -0
  141. package/dist/esm/indicator.taro-f2bd212f.js +30 -0
  142. package/dist/esm/infiniteloading.taro-f8f23ac6.js +143 -0
  143. package/dist/esm/input.taro-27d686c9.js +164 -0
  144. package/dist/esm/inputnumber.taro-877dc947.js +197 -0
  145. package/dist/esm/layout.taro-9659a928.js +11 -0
  146. package/dist/esm/menu.taro-cd0fef41.js +122 -0
  147. package/dist/esm/menuitem.taro-6076bffa.js +142 -0
  148. package/dist/esm/navbar.taro-5e1a0835.js +61 -0
  149. package/dist/esm/noticebar.taro-b3bfd4fe.js +408 -0
  150. package/dist/esm/notify.taro-6b6eb6bf.js +82 -0
  151. package/dist/esm/numberkeyboard.taro-0a0e866a.js +183 -0
  152. package/dist/esm/nutui-react.es.js +211 -116
  153. package/dist/esm/offsetContext-f32a9246.js +5 -0
  154. package/dist/esm/overlay.taro-75012bd3.js +77 -0
  155. package/dist/esm/pagination.taro-63607c3b.js +94 -0
  156. package/dist/esm/picker.taro-a5603921.js +468 -0
  157. package/dist/esm/popover.taro-ad483372.js +162 -0
  158. package/dist/esm/popup.taro-e756f3fc.js +150 -0
  159. package/dist/esm/price.taro-c4f45310.js +80 -0
  160. package/dist/esm/progress.taro-ff63be75.js +49 -0
  161. package/dist/esm/pulltorefresh.taro-c611fd92.js +179 -0
  162. package/dist/esm/radio.taro-3a54f4c8.js +152 -0
  163. package/dist/esm/range.taro-52cda918.js +325 -0
  164. package/dist/esm/rate.taro-78c66969.js +77 -0
  165. package/dist/esm/row.taro-8b7febd4.js +48 -0
  166. package/dist/esm/searchbar.taro-37ade36e.js +159 -0
  167. package/dist/esm/shortpassword.taro-f7292032.js +146 -0
  168. package/dist/esm/sidenavbar.taro-9f210df4.js +51 -0
  169. package/dist/esm/sidenavbaritem.taro-32a45ce6.js +12 -0
  170. package/dist/esm/signature.taro-c57469aa.js +146 -0
  171. package/dist/esm/skeleton.taro-9ff9baf4.js +71 -0
  172. package/dist/esm/step.taro-3bc01c0c.js +66 -0
  173. package/dist/esm/steps.taro-77e301ab.js +30 -0
  174. package/dist/esm/sticky.taro-3c03eb0a.js +134 -0
  175. package/dist/esm/subsidenavbar.taro-abe07673.js +64 -0
  176. package/dist/esm/supports-passive-aaaf0eff.js +17 -0
  177. package/dist/esm/swipe.taro-de80fcd8.js +180 -0
  178. package/dist/esm/swiper.taro-74cf9306.js +430 -0
  179. package/dist/esm/swiperitem-80df464a.js +29 -0
  180. package/dist/esm/switch.taro-f0da73a3.js +44 -0
  181. package/dist/esm/tabbar.taro-18eee41f.js +55 -0
  182. package/dist/esm/tabbaritem.taro-89646ca1.js +47 -0
  183. package/dist/esm/table.taro-15a55c5d.js +100 -0
  184. package/dist/esm/tabpane.taro-f8d92ece.js +21 -0
  185. package/dist/esm/tabs.taro-b75f20ff.js +139 -0
  186. package/dist/esm/tag.taro-1b4134a5.js +92 -0
  187. package/dist/esm/textarea.taro-c110565e.js +102 -0
  188. package/dist/esm/timedetail.taro-8d2acbbf.js +41 -0
  189. package/dist/esm/timepannel.taro-ee4c5dfa.js +22 -0
  190. package/dist/esm/timeselect.taro-069deedd.js +133 -0
  191. package/dist/esm/toast.taro-92c10e1d.js +114 -0
  192. package/dist/esm/trendarrow.taro-0cf43935.js +72 -0
  193. package/dist/esm/typings-11d83a22.js +7 -0
  194. package/dist/esm/uploader.taro-92977813.js +519 -0
  195. package/dist/esm/use-client-rect-f317804e.js +10 -0
  196. package/dist/esm/use-props-value-7ac1b1b5.js +16 -0
  197. package/dist/esm/use-touch-ff43512c.js +69 -0
  198. package/dist/esm/video-5d106e33.js +73 -0
  199. package/dist/esm/virtuallist.taro-99f03769.js +195 -0
  200. package/dist/esm/watermark.taro-cef29c03.js +109 -0
  201. package/dist/locales/base.js +1 -1
  202. package/dist/locales/en-US.js +1 -1
  203. package/dist/locales/id-ID.js +1 -1
  204. package/dist/locales/zh-CN.js +1 -1
  205. package/dist/locales/zh-TW.js +1 -1
  206. package/dist/locales/zh-UG.js +1 -1
  207. package/dist/nutui.react.mjs +507 -447
  208. package/dist/nutui.react.umd.js +506 -446
  209. package/dist/packages/cascader/cascader.scss +0 -26
  210. package/dist/packages/picker/picker.scss +66 -137
  211. package/dist/packages/table/table.scss +0 -56
  212. package/dist/packages/textarea/textarea.scss +5 -12
  213. package/dist/style.css +1 -1
  214. package/dist/style.mjs +1 -1
  215. package/dist/styles/variables-jmapp.scss +1 -4
  216. package/dist/styles/variables.scss +2 -6
  217. package/dist/types/index.d.ts +42 -46
  218. package/package.json +1 -1
  219. package/dist/esm/UserContext-0aac9a82.js +0 -5
  220. package/dist/esm/UserContext-e402e1a6.js +0 -5
  221. package/dist/esm/UserContext-e8176108.js +0 -5
  222. package/dist/esm/actionsheet.taro-12cf5a3e.js +0 -53
  223. package/dist/esm/address.taro-cab0ea22.js +0 -475
  224. package/dist/esm/animate.taro-485331bb.js +0 -41
  225. package/dist/esm/animatingnumbers.taro-f6eaffef.js +0 -104
  226. package/dist/esm/audio.taro-ff280f5e.js +0 -162
  227. package/dist/esm/avatar.taro-6e8f1f5c.js +0 -107
  228. package/dist/esm/avatargroup-f4375806.js +0 -31
  229. package/dist/esm/backtop.taro-8ec80d02.js +0 -52
  230. package/dist/esm/badge.taro-e2169fbe.js +0 -45
  231. package/dist/esm/barrage.taro-aa08da6c.js +0 -94
  232. package/dist/esm/bem-350c1702.js +0 -5
  233. package/dist/esm/button.taro-b50bc217.js +0 -65
  234. package/dist/esm/calendar.taro-2fc9b899.js +0 -65
  235. package/dist/esm/calendaritem.taro-2d4a8c34.js +0 -791
  236. package/dist/esm/can-use-dom-3eeb5af4.js +0 -6
  237. package/dist/esm/card.taro-0e849e94.js +0 -33
  238. package/dist/esm/cascader.taro-467910b2.js +0 -447
  239. package/dist/esm/cell.taro-ea725a95.js +0 -43
  240. package/dist/esm/cellgroup.taro-e05ea802.js +0 -25
  241. package/dist/esm/checkbox.taro-9d02f86c.js +0 -175
  242. package/dist/esm/circleprogress.taro-d4943109.js +0 -103
  243. package/dist/esm/col.taro-4477c9f7.js +0 -43
  244. package/dist/esm/collapse.taro-89bcadf2.js +0 -79
  245. package/dist/esm/collapseitem-0e228cec.js +0 -68
  246. package/dist/esm/configprovider.taro-ce34d482.js +0 -174
  247. package/dist/esm/context-c96afdcc.js +0 -5
  248. package/dist/esm/countdown.taro-3118ba23.js +0 -225
  249. package/dist/esm/datepicker.taro-2e3e955b.js +0 -275
  250. package/dist/esm/dialog.taro-eab19eab.js +0 -107
  251. package/dist/esm/divider.taro-3993d7d5.js +0 -33
  252. package/dist/esm/drag.taro-347dfb84.js +0 -111
  253. package/dist/esm/elevator.taro-1a4e3356.js +0 -193
  254. package/dist/esm/ellipsis.taro-e1ac99a1.js +0 -244
  255. package/dist/esm/empty.taro-26363c66.js +0 -56
  256. package/dist/esm/fixednav.taro-ddb21e87.js +0 -54
  257. package/dist/esm/form.taro-423b0f0a.js +0 -179
  258. package/dist/esm/formitem.taro-b550d29c.js +0 -89
  259. package/dist/esm/get-scroll-parent-b4a07e65.js +0 -25
  260. package/dist/esm/grid.taro-883a9c35.js +0 -49
  261. package/dist/esm/griditem.taro-16c7055b.js +0 -80
  262. package/dist/esm/image.taro-3025e659.js +0 -64
  263. package/dist/esm/imagepreview.taro-d511342c.js +0 -167
  264. package/dist/esm/index-5bcb0ff8.js +0 -7
  265. package/dist/esm/indicator.taro-bfb21d45.js +0 -30
  266. package/dist/esm/infiniteloading.taro-721bca1f.js +0 -141
  267. package/dist/esm/input.taro-06c1e4d5.js +0 -167
  268. package/dist/esm/inputnumber.taro-1f893d42.js +0 -199
  269. package/dist/esm/layout.taro-e4bf83cb.js +0 -11
  270. package/dist/esm/menu.taro-e5c68cb8.js +0 -111
  271. package/dist/esm/menuitem.taro-37c18382.js +0 -129
  272. package/dist/esm/navbar.taro-92bab9c4.js +0 -57
  273. package/dist/esm/noticebar.taro-cbe93c9e.js +0 -427
  274. package/dist/esm/notify.taro-f1079218.js +0 -75
  275. package/dist/esm/numberkeyboard.taro-d9b1721b.js +0 -159
  276. package/dist/esm/offsetContext-c2a746fa.js +0 -5
  277. package/dist/esm/overlay.taro-067b7202.js +0 -73
  278. package/dist/esm/pagination.taro-94f9be5e.js +0 -91
  279. package/dist/esm/picker.taro-e16b4312.js +0 -423
  280. package/dist/esm/popover.taro-84a55ff9.js +0 -153
  281. package/dist/esm/popup.taro-89cc342a.js +0 -139
  282. package/dist/esm/price.taro-959d82f2.js +0 -83
  283. package/dist/esm/progress.taro-1a7ac8a4.js +0 -40
  284. package/dist/esm/pulltorefresh.taro-016d0079.js +0 -181
  285. package/dist/esm/radio.taro-36438449.js +0 -177
  286. package/dist/esm/range.taro-8953e8c3.js +0 -332
  287. package/dist/esm/rate.taro-895bb41c.js +0 -77
  288. package/dist/esm/row.taro-e929ec5c.js +0 -48
  289. package/dist/esm/searchbar.taro-4467040f.js +0 -152
  290. package/dist/esm/shortpassword.taro-433b86a4.js +0 -119
  291. package/dist/esm/sidenavbar.taro-f8ffb7dc.js +0 -33
  292. package/dist/esm/sidenavbaritem.taro-6cb0821e.js +0 -12
  293. package/dist/esm/signature.taro-a4d9b5c9.js +0 -143
  294. package/dist/esm/skeleton.taro-8ec11af9.js +0 -62
  295. package/dist/esm/step.taro-7ea33a76.js +0 -58
  296. package/dist/esm/steps.taro-86753d36.js +0 -30
  297. package/dist/esm/sticky.taro-a142a5f2.js +0 -136
  298. package/dist/esm/subsidenavbar.taro-85c03291.js +0 -63
  299. package/dist/esm/supports-passive-c85ef996.js +0 -18
  300. package/dist/esm/swipe.taro-0b8cc872.js +0 -175
  301. package/dist/esm/swiper.taro-c0e9a56b.js +0 -451
  302. package/dist/esm/swiperitem-abab7606.js +0 -29
  303. package/dist/esm/switch.taro-e82809f6.js +0 -38
  304. package/dist/esm/tabbar.taro-48413fb8.js +0 -51
  305. package/dist/esm/tabbaritem.taro-5afa3562.js +0 -37
  306. package/dist/esm/table.taro-327b4248.js +0 -95
  307. package/dist/esm/tabpane.taro-406cc0d3.js +0 -21
  308. package/dist/esm/tabs.taro-d47ccfc5.js +0 -120
  309. package/dist/esm/tag.taro-846ee805.js +0 -92
  310. package/dist/esm/textarea.taro-add72cf3.js +0 -94
  311. package/dist/esm/timedetail.taro-82a2900b.js +0 -44
  312. package/dist/esm/timepannel.taro-0573bb65.js +0 -22
  313. package/dist/esm/timeselect.taro-29124a34.js +0 -133
  314. package/dist/esm/toast.taro-c509a870.js +0 -108
  315. package/dist/esm/trendarrow.taro-dd83ec94.js +0 -70
  316. package/dist/esm/typings-d8491423.js +0 -6
  317. package/dist/esm/uploader.taro-c70d00de.js +0 -494
  318. package/dist/esm/use-client-rect-1f8ed1fe.js +0 -18
  319. package/dist/esm/use-props-value-ae7ee726.js +0 -15
  320. package/dist/esm/use-touch-db24bb5c.js +0 -69
  321. package/dist/esm/video-1c6405b4.js +0 -67
  322. package/dist/esm/virtuallist.taro-ba8e1f21.js +0 -214
  323. package/dist/esm/watermark.taro-168cdac5.js +0 -114
@@ -1,179 +0,0 @@
1
- import React, { useRef } from 'react';
2
- import { C as ComponentDefaults } from './typings-d8491423.js';
3
- import { C as CellGroup } from './cellgroup.taro-e05ea802.js';
4
- import { a as FormItemContext, F as FormItem } from './formitem.taro-b550d29c.js';
5
-
6
- /**
7
- * 用于存储表单的数据
8
- */
9
- class FormStore {
10
- store = {}; // 存放表单中所有的数据 eg. {password: "ddd",username: "123"}
11
- fieldEntities = []; // 所有的组件实例
12
- // 成功和失败的回调
13
- callbacks = {};
14
- errList = [];
15
- constructor() {
16
- this.callbacks = {
17
- onFinish: (value) => { },
18
- onFinishFailed: () => { },
19
- };
20
- }
21
- /**
22
- * 注册组件实例
23
- * @param field
24
- */
25
- registerField = (field) => {
26
- this.fieldEntities.push(field);
27
- return () => {
28
- this.fieldEntities = this.fieldEntities.filter((item) => item != field);
29
- delete this.store[field.props.name];
30
- };
31
- };
32
- getFieldValue = (name) => {
33
- return this.store[name];
34
- };
35
- /**
36
- * 存储组件数据
37
- * @param newStore { [name]: newValue }
38
- */
39
- setFieldsValue = (newStore) => {
40
- this.store = {
41
- ...this.store,
42
- ...newStore,
43
- };
44
- this.fieldEntities.forEach((enetity) => {
45
- const { name } = enetity.props;
46
- Object.keys(newStore).forEach((key) => {
47
- if (key === name) {
48
- enetity.onStoreChange();
49
- }
50
- });
51
- });
52
- };
53
- /**
54
- * 表单校验
55
- * rules: { required: true, message: '' }
56
- * descriptor: {
57
- * username: {
58
- * type: 'string',
59
- * required: true,
60
- * validator: (rule, value) => {
61
- * return /^[a-zA-Z0-9]+$/.test(value)
62
- * },
63
- * },
64
- * }
65
- */
66
- validate = () => {
67
- const err = [];
68
- this.errList.length = 0;
69
- this.fieldEntities.forEach((entity) => {
70
- const { name, rules = [] } = entity.props;
71
- const descriptor = {};
72
- if (rules.length) {
73
- // 多条校验规则
74
- if (rules.length > 1) {
75
- descriptor[name] = [];
76
- rules.map((v) => {
77
- descriptor[name].push(v);
78
- });
79
- }
80
- else {
81
- descriptor[name] = rules[0];
82
- }
83
- }
84
- // const validator = new Schema(descriptor)
85
- // validator.validate({ [name]: this.store[name] }, (errors) => {
86
- // if (errors) {
87
- // err.push(...errors)
88
- // this.errList.push(...errors)
89
- // // 表单项更新
90
- // }
91
- // entity.onStoreChange()
92
- // })
93
- });
94
- return err;
95
- };
96
- setCallback = (callback) => {
97
- this.callbacks = {
98
- ...this.callbacks,
99
- ...callback,
100
- };
101
- };
102
- submit = () => {
103
- const err = this.validate();
104
- if (err.length === 0) {
105
- this.callbacks.onFinish?.(this.store);
106
- }
107
- else if (err.length > 0) {
108
- this.callbacks.onFinishFailed?.(err);
109
- }
110
- };
111
- resetFields = () => { };
112
- getForm = () => {
113
- return {
114
- setCallback: this.setCallback,
115
- registerField: this.registerField,
116
- getFieldValue: this.getFieldValue,
117
- setFieldsValue: this.setFieldsValue,
118
- submit: this.submit,
119
- store: this.store,
120
- errList: this.errList,
121
- fieldEntities: this.fieldEntities,
122
- };
123
- };
124
- }
125
- const useForm = (form) => {
126
- const formRef = useRef();
127
- if (!formRef.current) {
128
- if (form) {
129
- formRef.current = form;
130
- }
131
- else {
132
- const formStore = new FormStore();
133
- formRef.current = formStore.getForm();
134
- }
135
- }
136
- return [formRef.current];
137
- };
138
-
139
- const defaultProps = {
140
- ...ComponentDefaults,
141
- className: '',
142
- style: undefined,
143
- form: {},
144
- labelPosition: 'Right',
145
- formGroupTitle: '',
146
- onFinish: (obj) => { },
147
- onFinishFailed: (value) => { },
148
- starPositon: 'Left',
149
- };
150
- const PositionInfo = {
151
- Top: 'form-layout-top',
152
- Left: 'form-layout-left',
153
- Right: 'form-layout-right',
154
- };
155
- const Form = (props) => {
156
- const { children, onFinish, onFinishFailed, labelPosition, starPositon, ...rest } = {
157
- ...defaultProps,
158
- ...props,
159
- };
160
- console.log('46 dddd');
161
- const [formInstance] = useForm();
162
- formInstance.starPositon = starPositon;
163
- const { setCallback, submit } = formInstance;
164
- setCallback({
165
- onFinish,
166
- onFinishFailed,
167
- });
168
- return (React.createElement("form", { className: `nut-form ${PositionInfo[labelPosition]} ${props.className}`, style: props.style, onSubmit: (e) => {
169
- e.preventDefault();
170
- submit();
171
- } },
172
- React.createElement(CellGroup, null,
173
- React.createElement(FormItemContext.Provider, { value: formInstance }, children))));
174
- };
175
- Form.defaultProps = defaultProps;
176
- Form.displayName = 'NutForm';
177
- Form.Item = FormItem;
178
-
179
- export { Form as F };
@@ -1,89 +0,0 @@
1
- import React, { createContext } from 'react';
2
- import { C as Cell } from './cell.taro-ea725a95.js';
3
- import { C as ComponentDefaults } from './typings-d8491423.js';
4
-
5
- const FormItemContext = createContext({});
6
-
7
- const defaultProps = {
8
- ...ComponentDefaults,
9
- name: '',
10
- label: '',
11
- className: '',
12
- rules: [{ required: false, message: '' }],
13
- disabled: false,
14
- labelWidth: 90,
15
- errorMessageAlign: 'left',
16
- showErrorLine: true,
17
- showErrorMessage: true,
18
- };
19
- class FormItem extends React.Component {
20
- static defaultProps = defaultProps;
21
- static contextType = FormItemContext;
22
- cancelRegister;
23
- componentDidMount() {
24
- // 注册组件实例到FormStore
25
- this.cancelRegister = this.context.registerField(this);
26
- }
27
- componentWillUnmount() {
28
- if (this.cancelRegister) {
29
- this.cancelRegister();
30
- }
31
- }
32
- // children添加value属性和onChange事件
33
- getControlled = (children) => {
34
- const { getFieldValue, setFieldsValue } = this.context;
35
- const { name } = this.props;
36
- const type = children.type.NAME;
37
- return {
38
- value: getFieldValue(name),
39
- onChange: (event) => {
40
- let newValue = event;
41
- switch (type) {
42
- case 'checkbox':
43
- newValue = event.target
44
- .value;
45
- break;
46
- }
47
- setFieldsValue({ [name]: newValue });
48
- },
49
- };
50
- };
51
- onStoreChange = () => {
52
- this.forceUpdate();
53
- };
54
- renderLayout = (childNode) => {
55
- const { label, name, rules = [{ required: false, message: '' }], className, labelWidth, errorMessageAlign, showErrorLine, showErrorMessage, } = {
56
- ...defaultProps,
57
- ...this.props,
58
- };
59
- const item = this.context.errList?.length > 0 &&
60
- this.context.errList?.filter((item) => {
61
- return item.field === name;
62
- });
63
- const { starPositon } = this.context;
64
- const renderStar = rules.length > 0 && rules[0].required && (React.createElement("i", { className: "required" }));
65
- const renderLabel = starPositon === 'Right' ? (React.createElement(React.Fragment, null,
66
- label,
67
- renderStar)) : (React.createElement(React.Fragment, null,
68
- renderStar,
69
- label));
70
- return (React.createElement(Cell, { className: `nut-form-item ${className}` },
71
- label ? (React.createElement("div", { className: "nut-cell__title nut-form-item__label", style: {
72
- width: this.pxCheck(labelWidth),
73
- } }, renderLabel)) : null,
74
- React.createElement("div", { className: "nut-cell__value nut-form-item__body" },
75
- React.createElement("div", { className: "nut-form-item__body__slots" }, childNode),
76
- item.length > 0 && (React.createElement("div", { className: "nut-form-item__body__tips", style: { textAlign: errorMessageAlign } }, item[0].message)))));
77
- };
78
- pxCheck = (value) => {
79
- return Number.isNaN(Number(value)) ? String(value) : `${value}px`;
80
- };
81
- render() {
82
- const { children } = this.props;
83
- const c = Array.isArray(children) ? children[0] : children;
84
- const returnChildNode = React.cloneElement(c, this.getControlled(c));
85
- return this.renderLayout(returnChildNode);
86
- }
87
- }
88
-
89
- export { FormItem as F, FormItemContext as a };
@@ -1,25 +0,0 @@
1
- import { c as canUseDom } from './can-use-dom-3eeb5af4.js';
2
-
3
- const defaultRoot = canUseDom ? window : undefined;
4
- const overflowStylePatterns = ['scroll', 'auto', 'overlay'];
5
- function isElement(node) {
6
- const ELEMENT_NODE_TYPE = 1;
7
- return node.nodeType === ELEMENT_NODE_TYPE;
8
- }
9
- function getScrollParent(el, root = defaultRoot) {
10
- let node = el;
11
- while (node && node !== root && isElement(node)) {
12
- if (node === document.body) {
13
- return root;
14
- }
15
- const { overflowY } = window.getComputedStyle(node);
16
- if (overflowStylePatterns.includes(overflowY) &&
17
- node.scrollHeight > node.clientHeight) {
18
- return node;
19
- }
20
- node = node.parentNode;
21
- }
22
- return root;
23
- }
24
-
25
- export { getScrollParent as g };
@@ -1,49 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
- import { a as GridContext, G as GridItem, p as pxCheck } from './griditem.taro-16c7055b.js';
4
-
5
- const defaultProps = {
6
- columns: 4,
7
- gap: 0,
8
- center: true,
9
- square: false,
10
- reverse: false,
11
- direction: 'vertical',
12
- };
13
- const Grid = (props) => {
14
- const { children, columns, gap, center, square, reverse, direction, style, className, onClick, ...rest } = { ...defaultProps, ...props };
15
- const childrenDom = React.Children.toArray(children);
16
- const classPrefix = 'nut-grid';
17
- const rootClass = () => {
18
- return classNames(className, classPrefix, {
19
- [`${classPrefix}__border`]: !gap,
20
- });
21
- };
22
- const rootStyle = () => {
23
- let styleSelf = {};
24
- if (style) {
25
- styleSelf = style;
26
- }
27
- if (gap) {
28
- styleSelf.paddingLeft = pxCheck(gap);
29
- }
30
- return styleSelf;
31
- };
32
- return (React.createElement("div", { className: rootClass(), style: rootStyle(), ...rest },
33
- React.createElement(GridContext.Provider, { value: { onClick } }, childrenDom.map((item, idex) => {
34
- return React.cloneElement(item, {
35
- index: idex,
36
- columns,
37
- center,
38
- gap,
39
- square,
40
- reverse,
41
- direction,
42
- });
43
- }))));
44
- };
45
- Grid.defaultProps = defaultProps;
46
- Grid.displayName = 'NutGrid';
47
- Grid.Item = GridItem;
48
-
49
- export { Grid as G };
@@ -1,80 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import classNames from 'classnames';
3
- import { u as useConfig } from './configprovider.taro-ce34d482.js';
4
-
5
- const gridContext = {
6
- onClick: (item, index) => { },
7
- };
8
- var GridContext = React.createContext(gridContext);
9
-
10
- const pxCheck = (value) => {
11
- return Number.isNaN(Number(value)) ? String(value) : `${value}px`;
12
- };
13
-
14
- const defaultProps = {
15
- text: '',
16
- columns: 4,
17
- gap: 0,
18
- center: true,
19
- square: false,
20
- reverse: false,
21
- direction: 'vertical',
22
- };
23
- const GridItem = (props) => {
24
- useConfig();
25
- const { children, style, columns, index, gap, square, text, center, reverse, direction, className, onClick, ...rest } = {
26
- ...defaultProps,
27
- ...props,
28
- };
29
- const classPrefix = 'nut-grid-item';
30
- const classes = classNames(classPrefix, className);
31
- const context = useContext(GridContext);
32
- const rootStyle = () => {
33
- const styles = {
34
- flexBasis: `${100 / +columns}%`,
35
- ...style,
36
- };
37
- if (square) {
38
- styles.paddingTop = `${100 / +columns}%`;
39
- }
40
- else if (gap) {
41
- styles.paddingRight = pxCheck(gap);
42
- if (index >= Number(columns)) {
43
- styles.marginTop = pxCheck(gap);
44
- }
45
- }
46
- return styles;
47
- };
48
- const contentClass = () => {
49
- return classNames(`${classPrefix}__content`, {
50
- [`${classPrefix}__content--border`]: true,
51
- [`${classPrefix}__content--surround`]: gap,
52
- [`${classPrefix}__content--center`]: center,
53
- [`${classPrefix}__content--square`]: square,
54
- [`${classPrefix}__content--reverse`]: reverse,
55
- [`${classPrefix}__content--${direction}`]: !!direction,
56
- });
57
- };
58
- const handleClick = (e) => {
59
- onClick && onClick(e);
60
- context.onClick &&
61
- context.onClick({
62
- text,
63
- index,
64
- columns,
65
- gap,
66
- center,
67
- square,
68
- reverse,
69
- direction,
70
- }, index);
71
- };
72
- return (React.createElement("div", { className: classes, style: rootStyle(), ...rest, onClick: handleClick },
73
- React.createElement("div", { className: contentClass() },
74
- children && React.createElement(React.Fragment, null, children),
75
- text && React.createElement("div", { className: `${classPrefix}__text` }, text))));
76
- };
77
- GridItem.defaultProps = defaultProps;
78
- GridItem.displayName = 'NutGridItem';
79
-
80
- export { GridItem as G, GridContext as a, pxCheck as p };
@@ -1,64 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import { Image as Image$1, ImageError } from '@nutui/icons-react-taro';
3
- import { u as useConfig } from './configprovider.taro-ce34d482.js';
4
-
5
- const defaultProps = {
6
- fit: 'fill',
7
- position: 'center',
8
- alt: '',
9
- width: 'center',
10
- height: '',
11
- round: false,
12
- showError: true,
13
- showLoading: true,
14
- };
15
- const Image = (props) => {
16
- useConfig();
17
- const { children, className, style, src, fit, position, alt, width, height, round, radius, showError, showLoading, slotError, slotLoding, onClick, onLoad, onError, } = { ...defaultProps, ...props };
18
- const [loading, setLoading] = useState(true);
19
- const [isError, setIsError] = useState(false);
20
- useEffect(() => {
21
- if (src) {
22
- setIsError(false);
23
- setLoading(true);
24
- }
25
- }, [src]);
26
- // 图片加载
27
- const load = () => {
28
- setLoading(false);
29
- onLoad && onLoad();
30
- };
31
- // 图片加载失败
32
- const error = () => {
33
- setIsError(true);
34
- setLoading(false);
35
- onError && onError();
36
- };
37
- const pxCheck = (value) => {
38
- return Number.isNaN(Number(value)) ? String(value) : `${value}px`;
39
- };
40
- const stylebox = {
41
- height: height ? pxCheck(height) : '',
42
- width: width ? pxCheck(width) : '',
43
- overflow: radius !== undefined && radius !== null ? 'hidden' : '',
44
- borderRadius: radius !== undefined && radius !== null ? pxCheck(radius) : '',
45
- };
46
- const styles = {
47
- objectFit: fit,
48
- objectPosition: position,
49
- ...style,
50
- };
51
- const imageClick = (event) => {
52
- onClick && onClick(event);
53
- };
54
- return (React.createElement("div", { className: `nut-image ${round ? 'nut-image-round' : ''}`, style: stylebox, onClick: (e) => {
55
- imageClick(e);
56
- } },
57
- React.createElement("img", { className: "nut-img", style: styles, src: src, alt: alt, onLoad: load, onError: error }),
58
- showLoading && loading ? (React.createElement("div", { className: "nut-img-loading" }, slotLoding || children || React.createElement(Image$1, null))) : null,
59
- showError && isError && !loading ? (React.createElement("div", { className: "nut-img-error" }, slotError || children || React.createElement(ImageError, null))) : null));
60
- };
61
- Image.defaultProps = defaultProps;
62
- Image.displayName = 'NutImage';
63
-
64
- export { Image as I };
@@ -1,167 +0,0 @@
1
- import React, { useRef, useState, useEffect } from 'react';
2
- import { P as Popup } from './popup.taro-89cc342a.js';
3
- import { S as Swiper } from './swiper.taro-c0e9a56b.js';
4
- import { S as SwiperItem } from './swiperitem-abab7606.js';
5
-
6
- const defaultProps = {
7
- images: [],
8
- videos: [],
9
- show: false,
10
- autoplay: 3000,
11
- initNo: 1,
12
- contentClose: false,
13
- paginationVisible: false,
14
- paginationColor: '#fff',
15
- onClose: () => { },
16
- };
17
- const ImagePreview = (props) => {
18
- const { images, videos, show, initNo, paginationColor, paginationVisible, autoplay, contentClose, onClose, } = props;
19
- const nutImagePreview = useRef(null);
20
- const [showPop, setShowPop] = useState(false);
21
- const [active, setActive] = useState(1);
22
- const [maxNo, setMaxNo] = useState(1);
23
- const [store, setStore] = useState({
24
- scale: 1,
25
- moveable: false,
26
- });
27
- const [lastTouchEndTime, setLastTouchEndTime] = useState(0); // 用来辅助监听双击
28
- const onTouchStart = (event) => {
29
- const touches = event.touches;
30
- const events = touches[0];
31
- const events2 = touches[1];
32
- // 如果已经放大,双击应变回原尺寸;如果是原尺寸,双击应放大
33
- const curTouchTime = new Date().getTime();
34
- if (curTouchTime - lastTouchEndTime < 300) {
35
- const store1 = store;
36
- if (store1.scale > 1) {
37
- store1.scale = 1;
38
- }
39
- else if (store1.scale === 1) {
40
- store1.scale = 2;
41
- }
42
- scaleNow();
43
- }
44
- const store1 = store;
45
- store1.moveable = true;
46
- if (events2) {
47
- // 如果开始两指操作,记录初始时刻两指间的距离
48
- store1.oriDistance = getDistance({
49
- x: events.pageX,
50
- y: events.pageY,
51
- }, {
52
- x: events2.pageX,
53
- y: events2.pageY,
54
- });
55
- }
56
- // 取到开始两指操作时的放大(缩小比例),store.scale 存储的是当前的放缩比(相对于标准大小 scale 为 1 的情况的放大缩小比)
57
- store1.originScale = store1.scale || 1;
58
- };
59
- const onTouchMove = (event) => {
60
- const touches = event.touches;
61
- const events = touches[0];
62
- const events2 = touches[1];
63
- if (!store.moveable) {
64
- return;
65
- }
66
- const store1 = store;
67
- // 双指移动
68
- if (events2) {
69
- // 获得当前两点间的距离
70
- const curDistance = getDistance({
71
- x: events.pageX,
72
- y: events.pageY,
73
- }, {
74
- x: events2.pageX,
75
- y: events2.pageY,
76
- });
77
- /** 此处计算倍数,距离放大(缩小) k 倍则 scale 也 扩大(缩小) k 倍。距离放大(缩小)倍数 = 结束时两点距离 除以 开始时两点距离
78
- * 注意此处的 scale 变化是基于 store.scale 的。
79
- * store.scale 是一个暂存值,比如第一次放大 2 倍,则 store.scale 为 2。
80
- * 再次两指触碰的时候,store.originScale 就为 store.scale 的值,基于此时的 store.scale 继续放大缩小。 * */
81
- const curScale = curDistance / store1.oriDistance;
82
- store1.scale = store1.originScale * curScale;
83
- // 最大放大 3 倍,缩小后松手要弹回原比例
84
- if (store1.scale > 3) {
85
- store1.scale = 3;
86
- }
87
- scaleNow();
88
- }
89
- };
90
- const onTouchEnd = () => {
91
- setLastTouchEndTime(new Date().getTime());
92
- const store1 = store;
93
- store1.moveable = false;
94
- if ((store1.scale < 1.1 && store1.scale > 1) || store1.scale < 1) {
95
- store1.scale = 1;
96
- scaleNow();
97
- }
98
- };
99
- const init = () => {
100
- document.addEventListener('touchmove', onTouchMove);
101
- document.addEventListener('touchend', onTouchEnd);
102
- document.addEventListener('touchcancel', onTouchEnd);
103
- };
104
- useEffect(() => {
105
- if (show !== undefined) {
106
- setShowPop(show);
107
- init();
108
- }
109
- }, [show]);
110
- useEffect(() => {
111
- if (initNo !== undefined) {
112
- setActive(initNo);
113
- }
114
- if (show !== undefined) {
115
- setShowPop(show);
116
- }
117
- if (images && videos) {
118
- setMaxNo(images.length + videos.length);
119
- }
120
- }, []);
121
- const scaleNow = () => {
122
- if (nutImagePreview.current) {
123
- nutImagePreview.current.style.transform = `scale(${store.scale})`;
124
- }
125
- };
126
- const onCloseInner = () => {
127
- setShowPop(false);
128
- setActive(1);
129
- scaleNow();
130
- onClose && onClose();
131
- setStore({
132
- ...store,
133
- scale: 1,
134
- });
135
- };
136
- // 计算两个点的距离
137
- const getDistance = (first, second) => {
138
- // 计算两个点起始时刻的距离和终止时刻的距离,终止时刻距离变大了则放大,变小了则缩小
139
- // 放大 k 倍则 scale 也 扩大 k 倍
140
- return Math.hypot(Math.abs(second.x - first.x), Math.abs(second.y - first.y));
141
- };
142
- const slideChangeEnd = (page) => {
143
- setActive(page + 1);
144
- };
145
- const closeOnImg = () => {
146
- // 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
147
- if (contentClose) {
148
- onCloseInner();
149
- }
150
- };
151
- return (React.createElement(Popup, { visible: showPop, className: "custom-pop", style: { width: '100%' }, onClick: onCloseInner },
152
- React.createElement("div", { className: "nut-imagepreview", ref: nutImagePreview, onClick: closeOnImg, onTouchStart: onTouchStart },
153
- React.createElement(Swiper, { autoPlay: autoplay, className: "nut-imagepreview-swiper", loop: true, isPreventDefault: false, style: { display: showPop ? 'block' : 'none' }, direction: "horizontal", onChange: slideChangeEnd, initPage: initNo && (initNo > maxNo ? maxNo - 1 : initNo - 1), paginationColor: paginationColor, paginationVisible: paginationVisible }, images && images.length > 0
154
- ? images.map((item, index) => {
155
- return (React.createElement(SwiperItem, { key: index },
156
- React.createElement("img", { src: item.src, alt: "", className: "nut-imagepreview-img" })));
157
- })
158
- : [])),
159
- React.createElement("div", { className: "nut-imagepreview-index" },
160
- active,
161
- "/",
162
- (images ? images.length : 0) + (videos ? videos.length : 0))));
163
- };
164
- ImagePreview.defaultProps = defaultProps;
165
- ImagePreview.displayName = 'NutImagePreview';
166
-
167
- export { ImagePreview as I };
@@ -1,7 +0,0 @@
1
- const isObject = (val) => val !== null && typeof val === 'object';
2
- const isFunction = (val) => typeof val === 'function';
3
- const isPromise = (val) => {
4
- return isObject(val) && isFunction(val.then) && isFunction(val.catch);
5
- };
6
-
7
- export { isObject as a, isPromise as i };
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
-
4
- const defaultProps = {
5
- total: 3,
6
- current: 1,
7
- direction: 'horizontal',
8
- };
9
- const classPrefix = `nut-indicator`;
10
- const Indicator = (props) => {
11
- const { total, current, children, className, direction, ...rest } = {
12
- ...defaultProps,
13
- ...props,
14
- };
15
- const classes = classNames({
16
- [`${classPrefix}__vertical`]: direction === 'vertical',
17
- });
18
- const renderElement = () => {
19
- const childs = [];
20
- for (let item = 1; item <= total; item++) {
21
- childs.push(item === current ? (React.createElement(React.Fragment, null, children || (React.createElement("div", { key: item, className: `${classPrefix}__dot ${classPrefix}__active` })))) : (React.createElement("div", { key: item, className: `${classPrefix}__dot` })));
22
- }
23
- return childs;
24
- };
25
- return (React.createElement("div", { className: classNames(classes, className), ...rest }, renderElement()));
26
- };
27
- Indicator.defaultProps = defaultProps;
28
- Indicator.displayName = 'NutIndicator';
29
-
30
- export { Indicator as I };