@nutui/nutui-react-taro 1.5.1 → 2.0.0-alpha.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 (273) hide show
  1. package/CHANGELOG.md +1 -35
  2. package/dist/esm/ActionSheet.js +6 -6
  3. package/dist/esm/Address/style/index.js +0 -1
  4. package/dist/esm/Address.js +11 -12
  5. package/dist/esm/Audio/style/index.js +0 -1
  6. package/dist/esm/Audio.js +11 -12
  7. package/dist/esm/Avatar.js +2 -3
  8. package/dist/esm/AvatarGroup.js +3 -3
  9. package/dist/esm/BackTop/style/index.js +1 -1
  10. package/dist/esm/BackTop.js +4 -5
  11. package/dist/esm/Badge.js +2 -3
  12. package/dist/esm/Barrage.js +1 -1
  13. package/dist/esm/Button/style/index.js +1 -1
  14. package/dist/esm/Button.js +4 -5
  15. package/dist/esm/Calendar.js +10 -10
  16. package/dist/esm/CalendarItem.js +4 -4
  17. package/dist/esm/Card.js +4 -4
  18. package/dist/esm/Cascader.js +7 -7
  19. package/dist/esm/Cell/style/index.js +1 -1
  20. package/dist/esm/Cell.js +3 -6
  21. package/dist/esm/CellGroup.js +3 -3
  22. package/dist/esm/Checkbox/style/index.js +0 -1
  23. package/dist/esm/Checkbox.js +3 -3
  24. package/dist/esm/CheckboxGroup.js +3 -3
  25. package/dist/esm/Collapse.js +1 -1
  26. package/dist/esm/CollapseItem/style/index.js +1 -1
  27. package/dist/esm/CollapseItem.js +1 -3
  28. package/dist/esm/ConfigProvider.js +3 -2
  29. package/dist/esm/CountDown.js +3 -3
  30. package/dist/esm/DatePicker.js +10 -12
  31. package/dist/esm/Dialog.js +6 -8
  32. package/dist/esm/Divider.js +1 -3
  33. package/dist/esm/Elevator.js +1 -1
  34. package/dist/esm/Ellipsis.js +4 -4
  35. package/dist/esm/Empty.js +3 -3
  36. package/dist/esm/FixedNav/style/index.js +0 -1
  37. package/dist/esm/FixedNav.js +6 -8
  38. package/dist/esm/Form.js +6 -9
  39. package/dist/esm/FormItem.js +4 -7
  40. package/dist/esm/Grid/style/index.js +1 -1
  41. package/dist/esm/Grid.js +4 -6
  42. package/dist/esm/GridItem.js +3 -8
  43. package/dist/esm/Icon.js +60 -4
  44. package/dist/esm/Image.js +4 -6
  45. package/dist/esm/ImagePreview.js +6 -6
  46. package/dist/esm/Indicator.js +1 -3
  47. package/dist/esm/Infiniteloading/style/index.js +1 -1
  48. package/dist/esm/Infiniteloading.js +4 -5
  49. package/dist/esm/Input/style/index.js +1 -1
  50. package/dist/esm/Input.js +5 -7
  51. package/dist/esm/InputNumber/style/index.js +1 -1
  52. package/dist/esm/InputNumber.js +4 -5
  53. package/dist/esm/Menu.js +3 -5
  54. package/dist/esm/MenuItem/style/index.js +0 -1
  55. package/dist/esm/MenuItem.js +6 -8
  56. package/dist/esm/NavBar/style/index.js +1 -1
  57. package/dist/esm/NavBar.js +3 -3
  58. package/dist/esm/NoticeBar/style/index.js +1 -1
  59. package/dist/esm/NoticeBar.js +4 -4
  60. package/dist/esm/NumberKeyboard.js +7 -7
  61. package/dist/esm/Overlay.js +2 -3
  62. package/dist/esm/Pagination.js +6 -5
  63. package/dist/esm/Picker.js +9 -10
  64. package/dist/esm/Popover/style/index.js +0 -1
  65. package/dist/esm/Popover.js +4 -7
  66. package/dist/esm/Popup/style/index.js +0 -1
  67. package/dist/esm/Popup.js +5 -5
  68. package/dist/esm/Progress/style/index.js +1 -1
  69. package/dist/esm/Progress.js +3 -3
  70. package/dist/esm/PullToRefresh.js +3 -3
  71. package/dist/esm/Radio/style/index.js +0 -1
  72. package/dist/esm/Radio.js +3 -3
  73. package/dist/esm/RadioGroup.js +3 -3
  74. package/dist/esm/Range.js +7 -7
  75. package/dist/esm/Rate/style/index.js +1 -1
  76. package/dist/esm/Rate.js +4 -5
  77. package/dist/esm/SearchBar/style/index.js +1 -1
  78. package/dist/esm/SearchBar.js +5 -5
  79. package/dist/esm/ShortPassword/style/index.js +0 -1
  80. package/dist/esm/ShortPassword.js +7 -7
  81. package/dist/esm/SideNavBar.js +8 -8
  82. package/dist/esm/SideNavBarItem.js +1 -1
  83. package/dist/esm/Signature.js +7 -6
  84. package/dist/esm/Skeleton.js +3 -4
  85. package/dist/esm/Step/style/index.js +1 -1
  86. package/dist/esm/Step.js +2 -3
  87. package/dist/esm/Sticky.js +3 -4
  88. package/dist/esm/SubSideNavBar.js +1 -1
  89. package/dist/esm/Swipe.js +3 -3
  90. package/dist/esm/TabbarItem/style/index.js +1 -1
  91. package/dist/esm/TabbarItem.js +2 -3
  92. package/dist/esm/Table/style/index.js +1 -1
  93. package/dist/esm/Table.js +5 -5
  94. package/dist/esm/Tabs/style/index.js +1 -2
  95. package/dist/esm/Tabs.js +3 -3
  96. package/dist/esm/Tag/style/index.js +1 -1
  97. package/dist/esm/Tag.js +3 -5
  98. package/dist/esm/TextArea.js +3 -3
  99. package/dist/esm/TimeDetail.js +3 -3
  100. package/dist/esm/TimePannel.js +3 -3
  101. package/dist/esm/TimeSelect.js +10 -10
  102. package/dist/esm/Toast/style/index.js +1 -1
  103. package/dist/esm/Toast.js +2 -2
  104. package/dist/esm/TrendArrow/style/index.js +1 -1
  105. package/dist/esm/TrendArrow.js +2 -2
  106. package/dist/esm/Uploader/style/index.js +0 -1
  107. package/dist/esm/Uploader.js +8 -8
  108. package/dist/esm/Video.js +1 -1
  109. package/dist/esm/VirtualList.js +3 -3
  110. package/dist/esm/WaterMark.js +3 -3
  111. package/dist/esm/{actionsheet.taro-e6a51446.js → actionsheet.taro-b76a342e.js} +5 -5
  112. package/dist/esm/{address.taro-3a9b6396.js → address.taro-1812caeb.js} +24 -24
  113. package/dist/esm/{audio.taro-87ec8bf2.js → audio.taro-f672a68c.js} +7 -6
  114. package/dist/esm/{avatar.taro-3676f38f.js → avatar.taro-de157a1f.js} +8 -6
  115. package/dist/esm/{avatargroup-f3574510.js → avatargroup-b476ac68.js} +1 -1
  116. package/dist/esm/backtop.taro-ba271b8f.js +52 -0
  117. package/dist/esm/{badge.taro-a4e59c11.js → badge.taro-ae154f41.js} +4 -6
  118. package/dist/esm/{barrage.taro-0495a1b2.js → barrage.taro-80df08d3.js} +2 -2
  119. package/dist/esm/button.taro-a1c9512f.js +65 -0
  120. package/dist/esm/{calendar.taro-670842ea.js → calendar.taro-b6b147ca.js} +3 -3
  121. package/dist/esm/{calendaritem.taro-2a603571.js → calendaritem.taro-ae167e59.js} +3 -3
  122. package/dist/esm/{card.taro-e4c76dad.js → card.taro-5e9b34c8.js} +1 -1
  123. package/dist/esm/{cascader.taro-eb1fb011.js → cascader.taro-9c0a1a38.js} +17 -8
  124. package/dist/esm/cell.taro-26870740.js +43 -0
  125. package/dist/esm/cellgroup.taro-6e901b54.js +24 -0
  126. package/dist/esm/{checkbox.taro-6120e3e3.js → checkbox.taro-785c528b.js} +10 -13
  127. package/dist/esm/{collapse.taro-1a9e4ba2.js → collapse.taro-35a8a0d6.js} +3 -7
  128. package/dist/esm/{collapseitem-4d0bc55d.js → collapseitem-690eb91c.js} +6 -21
  129. package/dist/esm/{configprovider-67d19d3a.js → configprovider-9960f0fb.js} +1 -1
  130. package/dist/esm/{configprovider.taro-8d71eb49.js → configprovider.taro-c8c54556.js} +5 -2
  131. package/dist/esm/{countdown.taro-dbcb9a4f.js → countdown.taro-0e6bf7a2.js} +1 -1
  132. package/dist/esm/{datepicker.taro-6e9b4b8f.js → datepicker.taro-439e2080.js} +3 -3
  133. package/dist/esm/{dialog.taro-a3267d29.js → dialog.taro-00ac41fd.js} +5 -5
  134. package/dist/esm/divider.taro-6c1657ce.js +31 -0
  135. package/dist/esm/{elevator.taro-6019669e.js → elevator.taro-81a11ecc.js} +1 -1
  136. package/dist/esm/{ellipsis.taro-f15f26da.js → ellipsis.taro-b6cda065.js} +2 -2
  137. package/dist/esm/{empty.taro-04ae4389.js → empty.taro-fde835ca.js} +1 -1
  138. package/dist/esm/fixednav.taro-39fbd47a.js +54 -0
  139. package/dist/esm/{form.taro-0c8e7a39.js → form.taro-0d83f1e8.js} +3 -3
  140. package/dist/esm/{formitem.taro-190a3326.js → formitem.taro-0de07d1e.js} +2 -2
  141. package/dist/esm/{grid.taro-3503b82c.js → grid.taro-3797169c.js} +12 -24
  142. package/dist/esm/griditem.taro-04f59ae1.js +80 -0
  143. package/dist/esm/{image.taro-142cf512.js → image.taro-edb572bb.js} +4 -4
  144. package/dist/esm/{imagepreview.taro-c50bb0a3.js → imagepreview.taro-867ee24a.js} +1 -1
  145. package/dist/esm/indicator.taro-c10334e8.js +30 -0
  146. package/dist/esm/{infiniteloading.taro-183bccbf.js → infiniteloading.taro-73c9b8ca.js} +12 -15
  147. package/dist/esm/{input.taro-97af6c96.js → input.taro-10ed5500.js} +18 -21
  148. package/dist/esm/inputnumber.taro-108c4784.js +199 -0
  149. package/dist/esm/{menu.taro-7e4038a1.js → menu.taro-54951911.js} +6 -7
  150. package/dist/esm/{menuitem.taro-96cc4f15.js → menuitem.taro-86a6bb6c.js} +8 -10
  151. package/dist/esm/{navbar.taro-777c4705.js → navbar.taro-69f47d51.js} +8 -10
  152. package/dist/esm/{noticebar.taro-4a23cdee.js → noticebar.taro-49e7441f.js} +10 -31
  153. package/dist/esm/{numberkeyboard.taro-1bc24744.js → numberkeyboard.taro-81b36e5e.js} +2 -2
  154. package/dist/esm/nutui-react.es.js +87 -88
  155. package/dist/esm/{overlay.taro-21e87fb1.js → overlay.taro-ad0d4775.js} +20 -14
  156. package/dist/esm/pagination.taro-60b22b27.js +91 -0
  157. package/dist/esm/{picker.taro-9ad1b7c5.js → picker.taro-5c9030a7.js} +110 -160
  158. package/dist/esm/{popover.taro-ad5e76ea.js → popover.taro-2a57eae4.js} +12 -15
  159. package/dist/esm/{popup.taro-01676bff.js → popup.taro-124b9bab.js} +15 -10
  160. package/dist/esm/{progress.taro-f0ce38e9.js → progress.taro-24392ef3.js} +5 -7
  161. package/dist/esm/{pulltorefresh.taro-a294f656.js → pulltorefresh.taro-d5fcfcb0.js} +1 -1
  162. package/dist/esm/{radio.taro-a6eff96c.js → radio.taro-51e10152.js} +16 -7
  163. package/dist/esm/{range.taro-d8fc7656.js → range.taro-7a2b6ca1.js} +4 -4
  164. package/dist/esm/rate.taro-57341aa9.js +77 -0
  165. package/dist/esm/{searchbar.taro-0c25927b.js → searchbar.taro-eef468bb.js} +7 -7
  166. package/dist/esm/{shortpassword.taro-9ee034f7.js → shortpassword.taro-9a2c98ad.js} +17 -9
  167. package/dist/esm/{sidenavbar.taro-c307b35e.js → sidenavbar.taro-0265812f.js} +2 -2
  168. package/dist/esm/{sidenavbaritem.taro-5a7965d0.js → sidenavbaritem.taro-bb80dbf4.js} +2 -2
  169. package/dist/esm/{signature.taro-ec4e713b.js → signature.taro-f01b2b05.js} +2 -2
  170. package/dist/esm/{skeleton.taro-76faf63f.js → skeleton.taro-64e858a2.js} +1 -1
  171. package/dist/esm/{step.taro-b7903e8c.js → step.taro-2ec1f283.js} +5 -6
  172. package/dist/esm/{sticky.taro-218bda37.js → sticky.taro-b5bde7b1.js} +15 -17
  173. package/dist/esm/{subsidenavbar.taro-69cb9752.js → subsidenavbar.taro-3cce8442.js} +2 -2
  174. package/dist/esm/{swipe.taro-ea35f07f.js → swipe.taro-350c9a94.js} +2 -2
  175. package/dist/esm/{tabbaritem.taro-bf517487.js → tabbaritem.taro-42ba353f.js} +4 -7
  176. package/dist/esm/{table.taro-91fc0c01.js → table.taro-3946697c.js} +7 -5
  177. package/dist/esm/{tabs.taro-6a7524a4.js → tabs.taro-be8cacb5.js} +4 -4
  178. package/dist/esm/{tag.taro-23ba0834.js → tag.taro-0c2567de.js} +10 -10
  179. package/dist/esm/{textarea.taro-442e7350.js → textarea.taro-a0f79515.js} +1 -1
  180. package/dist/esm/{timedetail.taro-5b2f2269.js → timedetail.taro-fce4e614.js} +1 -1
  181. package/dist/esm/{timepannel.taro-d6e40180.js → timepannel.taro-fd3d008d.js} +1 -1
  182. package/dist/esm/{timeselect.taro-a07036f4.js → timeselect.taro-5b047850.js} +6 -6
  183. package/dist/esm/{toast.taro-d6c14811.js → toast.taro-e4f44812.js} +6 -7
  184. package/dist/esm/{trendarrow.taro-b8c5ccd9.js → trendarrow.taro-7cf90def.js} +5 -8
  185. package/dist/esm/typings-d8491423.js +6 -0
  186. package/dist/esm/{uploader.taro-5a53aa33.js → uploader.taro-0cca7e97.js} +57 -51
  187. package/dist/esm/use-props-value-ae7ee726.js +15 -0
  188. package/dist/esm/{video-f1be8a91.js → video-7ed508cc.js} +4 -4
  189. package/dist/esm/{virtuallist.taro-f0b0270d.js → virtuallist.taro-35b9bd9a.js} +2 -2
  190. package/dist/esm/{watermark.taro-9ce2ae37.js → watermark.taro-c780d360.js} +1 -1
  191. package/dist/esm/{zh-CN-c779e6c1.js → zh-CN-b4f493ba.js} +2 -2
  192. package/dist/locales/base.d.ts +2 -2
  193. package/dist/locales/base.js +1 -1
  194. package/dist/locales/en-US.js +3 -3
  195. package/dist/locales/id-ID.js +3 -3
  196. package/dist/locales/zh-CN.js +3 -3
  197. package/dist/locales/zh-TW.js +3 -3
  198. package/dist/locales/zh-UG.js +3 -3
  199. package/dist/nutui.react.mjs +7854 -5031
  200. package/dist/nutui.react.umd.js +7851 -5028
  201. package/dist/packages/actionsheet/actionsheet.scss +10 -2
  202. package/dist/packages/backtop/backtop.scss +0 -8
  203. package/dist/packages/badge/badge.scss +3 -4
  204. package/dist/packages/button/button.scss +80 -93
  205. package/dist/packages/cell/cell.scss +18 -90
  206. package/dist/packages/cellgroup/cellgroup.scss +26 -20
  207. package/dist/packages/collapseitem/collapseitem.scss +0 -1
  208. package/dist/packages/dialog/dialog.scss +1 -1
  209. package/dist/packages/divider/divider.scss +3 -17
  210. package/dist/packages/grid/grid.scss +1 -0
  211. package/dist/packages/griditem/griditem.scss +2 -17
  212. package/dist/packages/icon/icon.scss +0 -132
  213. package/dist/packages/image/image.scss +0 -12
  214. package/dist/packages/indicator/indicator.scss +21 -39
  215. package/dist/packages/infiniteloading/infiniteloading.scss +4 -12
  216. package/dist/packages/input/input.scss +4 -0
  217. package/dist/packages/inputnumber/inputnumber.scss +10 -26
  218. package/dist/packages/menuitem/menuitem.scss +2 -0
  219. package/dist/packages/navbar/navbar.scss +4 -5
  220. package/dist/packages/overlay/overlay.scss +0 -19
  221. package/dist/packages/picker/picker.scss +97 -103
  222. package/dist/packages/progress/progress.scss +0 -1
  223. package/dist/packages/radio/radio.scss +8 -0
  224. package/dist/packages/rate/rate.scss +29 -6
  225. package/dist/packages/searchbar/searchbar.scss +0 -1
  226. package/dist/packages/shortpassword/shortpassword.scss +4 -1
  227. package/dist/packages/step/step.scss +0 -1
  228. package/dist/packages/sticky/sticky.scss +1 -1
  229. package/dist/packages/swiper/swiper.scss +8 -0
  230. package/dist/packages/tabbaritem/tabbaritem.scss +0 -1
  231. package/dist/packages/table/table.scss +0 -1
  232. package/dist/packages/tag/tag.scss +9 -2
  233. package/dist/packages/timedetail/timedetail.scss +9 -3
  234. package/dist/packages/timeselect/timeselect.scss +1 -1
  235. package/dist/packages/toast/toast.scss +0 -1
  236. package/dist/style.css +1 -1
  237. package/dist/style.mjs +1 -1
  238. package/dist/styles/font-jmapp/config.json +175 -0
  239. package/dist/styles/font-jmapp/demo.css +539 -0
  240. package/dist/styles/font-jmapp/demo_index.html +1821 -0
  241. package/dist/styles/font-jmapp/iconfont.css +299 -0
  242. package/dist/styles/font-jmapp/iconfont.eot +0 -0
  243. package/dist/styles/font-jmapp/iconfont.js +68 -0
  244. package/dist/styles/font-jmapp/iconfont.json +506 -0
  245. package/dist/styles/font-jmapp/iconfont.svg +356 -0
  246. package/dist/styles/font-jmapp/iconfont.ttf +0 -0
  247. package/dist/styles/font-jmapp/iconfont.woff +0 -0
  248. package/dist/styles/font-jmapp/iconfont.woff2 +0 -0
  249. package/dist/styles/theme-default.scss +1 -0
  250. package/dist/styles/theme-jmapp.scss +41 -0
  251. package/dist/styles/themes/default.scss +0 -1
  252. package/dist/styles/variables-jmapp.scss +2601 -0
  253. package/dist/styles/variables.scss +49 -73
  254. package/dist/types/index.d.ts +145 -242
  255. package/package.json +23 -154
  256. package/dist/esm/Icon/style/index.js +0 -4
  257. package/dist/esm/backtop.taro-66394a36.js +0 -48
  258. package/dist/esm/button.taro-9244d065.js +0 -100
  259. package/dist/esm/cell.taro-a10a74d3.js +0 -64
  260. package/dist/esm/cellgroup.taro-abe501bc.js +0 -25
  261. package/dist/esm/divider.taro-26d1d8b4.js +0 -35
  262. package/dist/esm/fixednav.taro-1f05acaf.js +0 -53
  263. package/dist/esm/grid.taro.context-c2bbfb4f.js +0 -8
  264. package/dist/esm/griditem.taro-cdb3f119.js +0 -98
  265. package/dist/esm/icon-296a1bec.js +0 -63
  266. package/dist/esm/icon.taro-296a1bec.js +0 -63
  267. package/dist/esm/indicator.taro-cba8b010.js +0 -37
  268. package/dist/esm/inputnumber.taro-91f65d17.js +0 -130
  269. package/dist/esm/pagination.taro-715a173b.js +0 -124
  270. package/dist/esm/rate.taro-6cdf03bd.js +0 -75
  271. package/dist/esm/typings-b9828dba.js +0 -9
  272. /package/dist/esm/{useClientRect-1f8ed1fe.js → use-client-rect-1f8ed1fe.js} +0 -0
  273. /package/dist/esm/{useTouch-db24bb5c.js → use-touch-db24bb5c.js} +0 -0
@@ -1,11 +1,10 @@
1
1
  import React__default, { useState, useRef, useEffect, useImperativeHandle } from 'react';
2
- import Taro from '@tarojs/taro';
3
- import { View, PickerView, PickerViewColumn } from '@tarojs/components';
4
- import { P as Popup } from './popup.taro-01676bff.js';
5
- import { u as useTouch } from './useTouch-db24bb5c.js';
6
- import { g as getRectByTaro } from './useClientRect-1f8ed1fe.js';
2
+ import { View } from '@tarojs/components';
3
+ import { P as Popup } from './popup.taro-124b9bab.js';
4
+ import { u as useTouch } from './use-touch-db24bb5c.js';
5
+ import { g as getRectByTaro } from './use-client-rect-1f8ed1fe.js';
7
6
  import { p as passiveSupported } from './supports-passive-c85ef996.js';
8
- import { u as useConfig } from './configprovider.taro-8d71eb49.js';
7
+ import { u as useConfig } from './configprovider.taro-c8c54556.js';
9
8
  import { c as cn } from './bem-350c1702.js';
10
9
 
11
10
  const InternalPickerSlot = (props, ref) => {
@@ -18,13 +17,14 @@ const InternalPickerSlot = (props, ref) => {
18
17
  const INERTIA_TIME = 300;
19
18
  const INERTIA_DISTANCE = 15;
20
19
  const [currIndex, setCurrIndex] = useState(1);
20
+ // let lineSpacing = 36
21
21
  const lineSpacing = useRef(36);
22
22
  const [touchTime, setTouchTime] = useState(0);
23
23
  const [touchDeg, setTouchDeg] = useState('0deg');
24
24
  const rotation = 20;
25
25
  const moving = useRef(false);
26
26
  let timer;
27
- const listRef = useRef(null);
27
+ const listbox = useRef(null);
28
28
  const rollerRef = useRef(null);
29
29
  const pickerSlotRef = useRef(null);
30
30
  const [startTime, setStartTime] = useState(0);
@@ -164,7 +164,7 @@ const InternalPickerSlot = (props, ref) => {
164
164
  }
165
165
  };
166
166
  const getReference = async () => {
167
- const refe = await getRectByTaro(listRef?.current);
167
+ const refe = await getRectByTaro(listbox?.current);
168
168
  lineSpacing.current = refe.height ? refe.height : 36;
169
169
  modifyStatus(true);
170
170
  };
@@ -219,7 +219,7 @@ const InternalPickerSlot = (props, ref) => {
219
219
  React__default.createElement(React__default.Fragment, null, item.text ? item.text : item)));
220
220
  })),
221
221
  React__default.createElement("div", { className: "nut-picker-mask" }),
222
- React__default.createElement("div", { className: "nut-picker-indicator", ref: listRef })));
222
+ React__default.createElement("div", { className: "nut-picker-indicator", ref: listbox })));
223
223
  };
224
224
  const PickerSlot = React__default.forwardRef(InternalPickerSlot);
225
225
 
@@ -237,7 +237,7 @@ function useRefs() {
237
237
 
238
238
  const InternalPicker = (props, ref) => {
239
239
  const { locale } = useConfig();
240
- const { isVisible, title, listData = [], defaultValueData, onConfirm, onClose, onCloseUpdate, onChange, className, style, threeDimensional, swipeDuration, ...rest } = props;
240
+ const { visible, title, listData = [], defaultValueData, onConfirm, onClose, onCloseUpdate, onChange, className, style, threeDimensional, swipeDuration, ...rest } = props;
241
241
  const [chooseValueData, setchooseValueData] = useState([]); // 选择的数据的 value 值, 每一条数据的 value 值
242
242
  const [columnIndex, setcolumnIndex] = useState(0); // 选中列
243
243
  const pickerRef = useRef(null);
@@ -245,82 +245,52 @@ const InternalPicker = (props, ref) => {
245
245
  const [columnsList, setColumnsList] = useState([]); // 格式化后每一列的数据
246
246
  const b = cn('picker');
247
247
  const isConfirmEvent = useRef(false);
248
- // 级联数据格式化
249
- const formatCascade = (columns, values) => {
250
- const formatted = [];
251
- let cursor = {
252
- text: '',
253
- value: '',
254
- children: columns,
255
- };
256
- let columnIndex = 0;
257
- while (cursor && cursor.children) {
258
- const options = cursor.children;
259
- const value = values[columnIndex];
260
- let index = options.findIndex((columnItem) => columnItem.value === value);
261
- if (index === -1)
262
- index = 0;
263
- cursor = cursor.children[index];
264
- columnIndex++;
265
- formatted.push(options);
266
- }
267
- return formatted;
268
- };
269
- // 每一列的类型
270
- const columnsType = () => {
271
- const firstColumn = listData[0];
272
- if (firstColumn) {
273
- if (Array.isArray(firstColumn)) {
274
- return 'multiple';
275
- }
276
- if ('children' in firstColumn) {
277
- return 'cascade';
278
- }
279
- }
280
- return 'single';
281
- };
282
- // 传入的数据格式化
283
- const normalListData = () => {
284
- const type = columnsType();
285
- switch (type) {
286
- case 'multiple':
287
- return listData;
288
- case 'cascade':
289
- // 级联数据处理
290
- return formatCascade(listData, chooseValueData);
291
- default:
292
- return [listData];
293
- }
294
- };
295
- const init = () => {
296
- // const data: (string | number)[] = []
297
- const normalData = normalListData();
298
- setColumnsList(normalData);
299
- // normalData.length > 0 &&
300
- // normalData.map((item) => {
301
- // item[0] && data.push(item[0].value)
302
- // return item
303
- // })
304
- // 为何要重置呢?
305
- // if (!defaultValueData && chooseValueData.length === 0) {
306
- // setchooseValueData([...data])
307
- // }
308
- };
309
- // 列表格式修改
310
- useEffect(() => {
311
- init();
312
- }, [listData]);
313
248
  // 默认值修改
314
249
  useEffect(() => {
315
250
  if (defaultValueData &&
316
251
  defaultValueData.length !== 0 &&
317
- defaultValueData.toString() !== chooseValueData.toString() &&
318
- !currentValue.length) {
252
+ defaultValueData.toString() !== chooseValueData.toString()) {
319
253
  const data = [...defaultValueData];
320
254
  setchooseValueData(data);
321
255
  setColumnsList(normalListData());
322
256
  }
323
257
  }, [defaultValueData]);
258
+ // 选中值进行修改
259
+ useEffect(() => {
260
+ onChange && onChange(columnIndex, chooseValueData, selectedOptions());
261
+ if (isConfirmEvent.current) {
262
+ isConfirmEvent.current = false;
263
+ onConfirm && onConfirm(chooseValueData, selectedOptions());
264
+ }
265
+ }, [chooseValueData]);
266
+ // 列表格式修改
267
+ useEffect(() => {
268
+ init();
269
+ }, [listData]);
270
+ const closeActionSheet = () => {
271
+ onClose && onClose(chooseValueData, selectedOptions());
272
+ onCloseUpdate &&
273
+ onCloseUpdate(chooseValueData, selectedOptions(), pickerRef);
274
+ };
275
+ // 点击确定
276
+ const confirm = () => {
277
+ let movings = false;
278
+ refs.forEach((_ref) => {
279
+ if (_ref.moving)
280
+ movings = true;
281
+ _ref.stopMomentum();
282
+ });
283
+ if (movings) {
284
+ isConfirmEvent.current = true;
285
+ }
286
+ else {
287
+ onConfirm && onConfirm(chooseValueData, selectedOptions());
288
+ }
289
+ onClose && onClose(chooseValueData, selectedOptions());
290
+ setTimeout(() => {
291
+ isConfirmEvent.current = false;
292
+ }, 0);
293
+ };
324
294
  const selectedOptions = () => {
325
295
  const optins = [];
326
296
  columnsList.map((column, index) => {
@@ -336,20 +306,6 @@ const InternalPicker = (props, ref) => {
336
306
  });
337
307
  return optins;
338
308
  };
339
- // 选中值进行修改
340
- useEffect(() => {
341
- Taro.getEnv() !== 'WEB' && setCurrentValue(defaultValuesConvert());
342
- onChange && onChange(columnIndex, chooseValueData, selectedOptions());
343
- if (isConfirmEvent.current) {
344
- isConfirmEvent.current = false;
345
- onConfirm && onConfirm(chooseValueData, selectedOptions());
346
- }
347
- }, [chooseValueData]);
348
- const closeActionSheet = () => {
349
- onClose && onClose(chooseValueData, selectedOptions());
350
- onCloseUpdate &&
351
- onCloseUpdate(chooseValueData, selectedOptions(), pickerRef);
352
- };
353
309
  // 选择每一列的数据
354
310
  const chooseItem = (option, columnIndex) => {
355
311
  if (option && Object.keys(option).length) {
@@ -364,7 +320,8 @@ const InternalPicker = (props, ref) => {
364
320
  chooseValueData[index + 1] = cursor.children[0].value;
365
321
  setchooseValueData([...chooseValueData]);
366
322
  index++;
367
- cursor = cursor.children[0];
323
+ const cc = cursor.children[0];
324
+ cursor = cc;
368
325
  }
369
326
  // 当前改变列的下一列 children 值为空
370
327
  if (cursor && cursor.children) {
@@ -386,24 +343,65 @@ const InternalPicker = (props, ref) => {
386
343
  }
387
344
  }
388
345
  };
389
- // 点击确定
390
- const confirm = () => {
391
- let movings = false;
392
- refs.forEach((_ref) => {
393
- if (_ref.moving)
394
- movings = true;
395
- _ref.stopMomentum();
396
- });
397
- if (movings) {
398
- isConfirmEvent.current = true;
346
+ // 传入的数据格式化
347
+ const normalListData = () => {
348
+ const type = columnsType();
349
+ switch (type) {
350
+ case 'multiple':
351
+ return listData;
352
+ case 'cascade':
353
+ // 级联数据处理
354
+ return formatCascade(listData, chooseValueData);
355
+ default:
356
+ return [listData];
399
357
  }
400
- else {
401
- onConfirm && onConfirm(chooseValueData, selectedOptions());
358
+ };
359
+ // 每一列的类型
360
+ const columnsType = () => {
361
+ const firstColumn = listData[0];
362
+ if (firstColumn) {
363
+ if (Array.isArray(firstColumn)) {
364
+ return 'multiple';
365
+ }
366
+ if ('children' in firstColumn) {
367
+ return 'cascade';
368
+ }
369
+ }
370
+ return 'single';
371
+ };
372
+ // 级联数据格式化
373
+ const formatCascade = (columns, defaultValues) => {
374
+ const formatted = [];
375
+ let cursor = {
376
+ text: '',
377
+ value: '',
378
+ children: columns,
379
+ };
380
+ let columnIndex = 0;
381
+ while (cursor && cursor.children) {
382
+ const options = cursor.children;
383
+ const value = defaultValues[columnIndex];
384
+ let index = options.findIndex((columnItem) => columnItem.value === value);
385
+ if (index === -1)
386
+ index = 0;
387
+ cursor = cursor.children[index];
388
+ columnIndex++;
389
+ formatted.push(options);
390
+ }
391
+ return formatted;
392
+ };
393
+ const init = () => {
394
+ const data = [];
395
+ const normalData = normalListData();
396
+ setColumnsList(normalData);
397
+ normalData.length > 0 &&
398
+ normalData.map((item) => {
399
+ item[0] && data.push(item[0].value);
400
+ return item;
401
+ });
402
+ if (!defaultValueData && chooseValueData.length === 0) {
403
+ setchooseValueData([...data]);
402
404
  }
403
- onClose && onClose(chooseValueData, selectedOptions());
404
- setTimeout(() => {
405
- isConfirmEvent.current = false;
406
- }, 0);
407
405
  };
408
406
  const renderToolbar = () => {
409
407
  return (React__default.createElement("div", { className: b('control') },
@@ -411,62 +409,14 @@ const InternalPicker = (props, ref) => {
411
409
  React__default.createElement("div", { className: b('title') }, title || ''),
412
410
  React__default.createElement("span", { className: b('confirm-btn'), onClick: confirm }, locale.confirm)));
413
411
  };
414
- const [currentValue, setCurrentValue] = useState([]);
415
- const [pickingStatus, setPickingStatus] = useState(false);
416
- const defaultValuesConvert = () => {
417
- const defaultIndexs = [];
418
- if (chooseValueData.length > 0) {
419
- chooseValueData.forEach((value, index) => {
420
- for (let i = 0; i < columnsList[index].length; i++) {
421
- if (columnsList[index][i].value === value) {
422
- defaultIndexs.push(i);
423
- break;
424
- }
425
- }
426
- });
427
- }
428
- else if (columnsList && columnsList.length > 0) {
429
- columnsList.forEach((item) => {
430
- defaultIndexs.push(0);
431
- item.length > 0 && chooseValueData.push(item[0].value);
432
- });
433
- }
434
- return defaultIndexs;
435
- };
436
- const pickerStart = () => {
437
- setPickingStatus(true);
438
- };
439
- const pickerEnd = () => {
440
- setPickingStatus(false);
441
- };
442
- const pickerChange = (data) => {
443
- const prevDefaultValue = currentValue;
444
- let changeIndex = 0;
445
- console.log('chage', data);
446
- // 判断变化的是第几个
447
- const list = data.detail.value;
448
- for (let i = 0, len = list.length; i < len; i++) {
449
- if (prevDefaultValue[i] !== list[i]) {
450
- changeIndex = i;
451
- break;
452
- }
453
- }
454
- // 选择的是哪个 option
455
- chooseItem(columnsList[changeIndex][data.detail.value[changeIndex]], changeIndex);
456
- };
457
- return (React__default.createElement(Popup, { visible: isVisible, position: "bottom", onClose: () => {
412
+ return (React__default.createElement(Popup, { visible: visible, position: "bottom", onClose: () => {
458
413
  closeActionSheet();
459
414
  } },
460
415
  React__default.createElement(View, { className: `${b()} ${className || ''}`, style: style, ...rest, catchMove: true },
461
416
  renderToolbar(),
462
- React__default.createElement("div", { className: b('panel'), ref: pickerRef }, Taro.getEnv() === 'WEB' ? (columnsList?.map((item, index) => {
463
- return (React__default.createElement(PickerSlot, { ref: setRefs(index), defaultValue: chooseValueData?.[index], listData: item, threeDimensional: threeDimensional, chooseItem: (value, index) => chooseItem(value, index), swipeDuration: swipeDuration, key: index, keyIndex: index, itemShow: isVisible }));
464
- })) : (React__default.createElement(PickerView, { ref: pickerRef, value: currentValue, immediateChange: true, onPickStart: pickerStart, onChange: pickerChange, onPickEnd: pickerEnd, className: "picker-view-panel" }, columnsList?.map((column, index) => {
465
- return (React__default.createElement(PickerViewColumn, { key: `col${index}` }, column.map((item, index) => {
466
- return (React__default.createElement(View, { key: item.value || index, className: "nut-picker-roller-item-title" },
467
- React__default.createElement(React__default.Fragment, null, item.text || item)));
468
- })));
469
- })))))));
417
+ React__default.createElement("div", { className: b('panel'), ref: pickerRef }, columnsList?.map((item, index) => {
418
+ return (React__default.createElement(PickerSlot, { ref: setRefs(index), defaultValue: chooseValueData?.[index], listData: item, threeDimensional: threeDimensional, chooseItem: (value, index) => chooseItem(value, index), swipeDuration: swipeDuration, key: index, keyIndex: index, itemShow: visible }));
419
+ })))));
470
420
  };
471
421
  const Picker = React__default.forwardRef(InternalPicker);
472
422
 
@@ -1,8 +1,7 @@
1
1
  import React__default, { useRef, useState, useEffect } from 'react';
2
- import { I as Icon } from './icon.taro-296a1bec.js';
3
- import { O as Overlay } from './overlay.taro-21e87fb1.js';
4
- import { g as getRectByTaro } from './useClientRect-1f8ed1fe.js';
5
- import { C as ComponentDefaults } from './typings-b9828dba.js';
2
+ import { O as Overlay } from './overlay.taro-ad0d4775.js';
3
+ import { g as getRectByTaro } from './use-client-rect-1f8ed1fe.js';
4
+ import { C as ComponentDefaults } from './typings-d8491423.js';
6
5
 
7
6
  /**
8
7
  * 过滤ref
@@ -66,7 +65,7 @@ const defaultProps = {
66
65
  onChoose: (item, index) => { },
67
66
  };
68
67
  const Popover = (props) => {
69
- const { children, list, theme, location, visible, offset, className, style, onClick, onChoose, iconClassPrefix, iconFontClassName, ...reset } = {
68
+ const { children, list, theme, location, visible, offset, className, style, onClick, onChoose, ...reset } = {
70
69
  ...defaultProps,
71
70
  ...props,
72
71
  };
@@ -139,16 +138,14 @@ const Popover = (props) => {
139
138
  visible ? (React__default.createElement("div", { className: `${popoverContent}`, style: getStyle() },
140
139
  React__default.createElement("div", { className: `${popoverArrow}` }),
141
140
  Array.isArray(children) ? children[1] : '',
142
- React__default.createElement("div", null,
143
- ' ',
144
- list.map((item, i) => {
145
- return (React__default.createElement("div", { key: item.name, className: `popover-menu-item ${item.disabled ? 'disabled' : ''}`, onClick: () => {
146
- handleChoose(item, i);
147
- } },
148
- item.icon ? (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, className: "popover-menu-item-img", name: item.icon })) : (''),
149
- React__default.createElement("div", { className: "popover-menu-item-name" }, item.name)));
150
- })))) : null))),
151
- visible ? (React__default.createElement(Overlay, { visible: visible, onClick: (e) => handleClick(e), style: { background: 'transparent' } })) : ('')));
141
+ React__default.createElement("div", null, list.map((item, i) => {
142
+ return (React__default.createElement("div", { key: item.name, className: `popover-menu-item ${item.disabled ? 'disabled' : ''}`, onClick: () => {
143
+ handleChoose(item, i);
144
+ } },
145
+ item.icon ? item.icon : null,
146
+ React__default.createElement("div", { className: "popover-menu-item-name" }, item.name)));
147
+ })))) : null))),
148
+ visible ? (React__default.createElement(Overlay, { visible: visible, onClick: (e) => handleClick(e), style: { background: 'transparent' } })) : null));
152
149
  };
153
150
  Popover.defaultProps = defaultProps;
154
151
  Popover.displayName = 'NutPopover';
@@ -2,21 +2,21 @@ import React__default, { useState, useEffect } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import { CSSTransition } from 'react-transition-group';
4
4
  import classNames from 'classnames';
5
- import { d as defaultOverlayProps, O as Overlay } from './overlay.taro-21e87fb1.js';
6
- import { I as Icon } from './icon.taro-296a1bec.js';
5
+ import { Close } from '@nutui/icons-react-taro';
6
+ import { d as defaultOverlayProps, O as Overlay } from './overlay.taro-ad0d4775.js';
7
7
  import { c as cn } from './bem-350c1702.js';
8
- import { C as ComponentDefaults } from './typings-b9828dba.js';
8
+ import { C as ComponentDefaults } from './typings-d8491423.js';
9
9
 
10
10
  const defaultProps = {
11
11
  ...ComponentDefaults,
12
12
  position: 'center',
13
13
  transition: '',
14
- style: {},
14
+ overlayStyle: {},
15
+ overlayClass: '',
15
16
  popClass: '',
16
17
  closeable: false,
17
18
  closeIconPosition: 'top-right',
18
19
  closeIcon: 'close',
19
- closeIconSize: '12px',
20
20
  destroyOnClose: true,
21
21
  teleport: null,
22
22
  overlay: true,
@@ -31,7 +31,7 @@ const defaultProps = {
31
31
  };
32
32
  let _zIndex = 2000;
33
33
  const Popup = (props) => {
34
- const { children, visible, overlay, closeOnClickOverlay, overlayStyle, overlayClass, zIndex, lockScroll, duration, closeable, closeIconPosition, closeIcon, style, transition, round, position, popClass, className, destroyOnClose, teleport, onOpen, onClose, onClickOverlay, onClickCloseIcon, onOpened, onClosed, onClick, iconClassPrefix, iconFontClassName, closeIconSize, } = props;
34
+ const { children, visible, overlay, closeOnOverlayClick, overlayStyle, overlayClass, zIndex, lockScroll, duration, closeable, closeIconPosition, closeIcon, style, transition, round, position, popClass, className, destroyOnClose, teleport, onOpen, onClose, onClickOverlay, onClickCloseIcon, onOpened, onClosed, onClick, } = props;
35
35
  const [index, setIndex] = useState(zIndex || _zIndex);
36
36
  const [innerVisible, setInnerVisible] = useState(visible);
37
37
  const [showChildren, setShowChildren] = useState(true);
@@ -81,7 +81,7 @@ const Popup = (props) => {
81
81
  }
82
82
  };
83
83
  const onHandleClickOverlay = (e) => {
84
- if (closeOnClickOverlay) {
84
+ if (closeOnOverlayClick) {
85
85
  onClickOverlay && onClickOverlay(e);
86
86
  close();
87
87
  }
@@ -110,16 +110,21 @@ const Popup = (props) => {
110
110
  }
111
111
  return node;
112
112
  };
113
+ const renderIcon = () => {
114
+ if (closeable) {
115
+ return (React__default.createElement("div", { className: closeClasses, onClick: onHandleClickCloseIcon }, React__default.isValidElement(closeIcon) ? (closeIcon) : (React__default.createElement(Close, { width: 12, height: 12 }))));
116
+ }
117
+ return null;
118
+ };
113
119
  const renderPop = () => {
114
120
  return (React__default.createElement(CSSTransition, { classNames: transitionName, unmountOnExit: true, timeout: 500, in: innerVisible, onEntered: onHandleOpened, onExited: onHandleClosed },
115
121
  React__default.createElement("div", { style: popStyles, className: classes, onClick: onHandleClick },
116
122
  showChildren ? children : '',
117
- closeable ? (React__default.createElement("div", { className: closeClasses, onClick: onHandleClickCloseIcon },
118
- React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, name: closeIcon, size: closeIconSize }))) : (''))));
123
+ renderIcon())));
119
124
  };
120
125
  const renderNode = () => {
121
126
  return (React__default.createElement(React__default.Fragment, null, overlay ? (React__default.createElement(React__default.Fragment, null,
122
- React__default.createElement(Overlay, { style: overlayStyles, overlayClass: overlayClass, visible: innerVisible, closeOnClickOverlay: closeOnClickOverlay, zIndex: zIndex, lockScroll: lockScroll, duration: duration, onClick: onHandleClickOverlay }),
127
+ React__default.createElement(Overlay, { style: overlayStyles, className: overlayClass, visible: innerVisible, closeOnOverlayClick: closeOnOverlayClick, zIndex: zIndex, lockScroll: lockScroll, duration: duration, onClick: onHandleClickOverlay }),
123
128
  renderPop())) : (React__default.createElement(React__default.Fragment, null, renderPop()))));
124
129
  };
125
130
  useEffect(() => {
@@ -1,8 +1,8 @@
1
1
  import React__default from 'react';
2
2
  import classNames from 'classnames';
3
- import { I as Icon } from './icon.taro-296a1bec.js';
3
+ import { Checked } from '@nutui/icons-react-taro';
4
4
  import { c as cn } from './bem-350c1702.js';
5
- import { C as ComponentDefaults } from './typings-b9828dba.js';
5
+ import { C as ComponentDefaults } from './typings-d8491423.js';
6
6
 
7
7
  const defaultProps = {
8
8
  ...ComponentDefaults,
@@ -20,13 +20,11 @@ const defaultProps = {
20
20
  textBackground: 'linear-gradient(135deg, #fa2c19 0%, #fa6419 100%)',
21
21
  textType: 'text',
22
22
  status: false,
23
- iconName: 'checked',
24
- iconColor: '#439422',
25
- iconSize: '16px',
23
+ icon: null,
26
24
  children: undefined,
27
25
  };
28
26
  const Progress = (props) => {
29
- const { className, style, isShowPercentage, percentage, fillColor, strokeColor, strokeWidth, size, textColor, textWidth, showText, textInside, textBackground, textType, status, iconName, iconColor, iconSize, children, iconClassPrefix, iconFontClassName, ...rest } = {
27
+ const { className, style, isShowPercentage, percentage, fillColor, strokeColor, strokeWidth, size, textColor, textWidth, showText, textInside, textBackground, textType, status, icon, children, ...rest } = {
30
28
  ...defaultProps,
31
29
  ...props,
32
30
  };
@@ -82,7 +80,7 @@ const Progress = (props) => {
82
80
  textType === 'text' && (React__default.createElement("span", { className: classesTextInner, style: { color: textColor } },
83
81
  percentage,
84
82
  isShowPercentage ? '%' : '')),
85
- textType === 'icon' && (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, size: iconSize, name: iconName, color: iconColor }))))));
83
+ textType === 'icon' && (React__default.createElement(React__default.Fragment, null, icon || React__default.createElement(Checked, { width: 16, height: 16, color: "#439422" })))))));
86
84
  };
87
85
  Progress.defaultProps = defaultProps;
88
86
  Progress.displayName = 'NutProgress';
@@ -1,7 +1,7 @@
1
1
  import React__default, { useState, useRef, useEffect } from 'react';
2
2
  import { useDrag } from '@use-gesture/react';
3
3
  import { useSpring, animated } from '@react-spring/web';
4
- import { u as useConfig } from './configprovider.taro-8d71eb49.js';
4
+ import { u as useConfig } from './configprovider.taro-c8c54556.js';
5
5
  import { g as getScrollParent } from './get-scroll-parent-b4a07e65.js';
6
6
  import { p as passiveSupported } from './supports-passive-c85ef996.js';
7
7
 
@@ -1,6 +1,6 @@
1
1
  import React__default, { useState, useEffect, useCallback, useContext } from 'react';
2
- import { I as Icon } from './icon.taro-296a1bec.js';
3
- import { C as ComponentDefaults } from './typings-b9828dba.js';
2
+ import { CheckChecked, CheckNormal } from '@nutui/icons-react-taro';
3
+ import { C as ComponentDefaults } from './typings-d8491423.js';
4
4
  import { c as cn } from './bem-350c1702.js';
5
5
 
6
6
  const radioContext = {
@@ -100,8 +100,8 @@ const defaultProps = {
100
100
  shape: 'round',
101
101
  value: '',
102
102
  textPosition: 'right',
103
- iconName: 'check-normal',
104
- iconActiveName: 'check-checked',
103
+ icon: null,
104
+ checkedIcon: null,
105
105
  iconSize: 18,
106
106
  onChange: (e) => { },
107
107
  };
@@ -110,7 +110,7 @@ const Radio = (props) => {
110
110
  ...defaultProps,
111
111
  ...props,
112
112
  };
113
- const { className, disabled, checked, shape, textPosition, value, iconName, iconActiveName, iconSize, onChange, iconClassPrefix, iconFontClassName, ...rest } = props;
113
+ const { className, disabled, checked, shape, textPosition, value, icon, checkedIcon, iconSize, onChange, ...rest } = props;
114
114
  const componentName = 'nut-radio';
115
115
  const [checkedStatement, setCheckedStatement] = useState(checked);
116
116
  const [valueStatement, setValueStatement] = useState(value);
@@ -139,8 +139,17 @@ const Radio = (props) => {
139
139
  return 'nut-radio__icon--unchecked';
140
140
  };
141
141
  const renderIcon = () => {
142
- const { iconName, iconSize, iconActiveName } = props;
143
- return (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, name: !disabledStatement && checkedStatement ? iconActiveName : iconName, size: iconSize, className: color() }));
142
+ const { icon, iconSize, checkedIcon } = props;
143
+ if (!disabledStatement && checkedStatement) {
144
+ return React__default.isValidElement(checkedIcon) ? (React__default.cloneElement(checkedIcon, {
145
+ ...checkedIcon.props,
146
+ className: color(),
147
+ })) : (React__default.createElement(CheckChecked, { size: iconSize, className: color() }));
148
+ }
149
+ return React__default.isValidElement(icon) ? (React__default.cloneElement(icon, {
150
+ ...icon.props,
151
+ className: color(),
152
+ })) : (React__default.createElement(CheckNormal, { size: iconSize, className: color() }));
144
153
  };
145
154
  const reverseState = textPosition === 'left';
146
155
  const renderRadioItem = () => {
@@ -1,8 +1,8 @@
1
1
  import React__default, { useState, useRef, useEffect, useCallback } from 'react';
2
- import { u as useTouch } from './useTouch-db24bb5c.js';
3
- import { g as getRectByTaro } from './useClientRect-1f8ed1fe.js';
4
- import { T as Toast } from './toast.taro-d6c14811.js';
5
- import { u as useConfig } from './configprovider.taro-8d71eb49.js';
2
+ import { u as useTouch } from './use-touch-db24bb5c.js';
3
+ import { g as getRectByTaro } from './use-client-rect-1f8ed1fe.js';
4
+ import { T as Toast } from './toast.taro-e4f44812.js';
5
+ import { u as useConfig } from './configprovider.taro-c8c54556.js';
6
6
 
7
7
  const defaultProps = {
8
8
  range: false,
@@ -0,0 +1,77 @@
1
+ import React__default, { useState, useEffect } from 'react';
2
+ import classNames from 'classnames';
3
+ import { StarFillN } from '@nutui/icons-react-taro';
4
+ import { C as ComponentDefaults } from './typings-d8491423.js';
5
+ import { u as usePropsValue } from './use-props-value-ae7ee726.js';
6
+
7
+ const defaultProps = {
8
+ ...ComponentDefaults,
9
+ count: 5,
10
+ min: 0,
11
+ checkedIcon: null,
12
+ uncheckedIcon: null,
13
+ disabled: false,
14
+ readOnly: false,
15
+ allowHalf: false,
16
+ };
17
+ const Rate = (props) => {
18
+ const { className, style, count, value, defaultValue, min, checkedIcon, uncheckedIcon, disabled, readOnly, allowHalf, onChange, } = {
19
+ ...defaultProps,
20
+ ...props,
21
+ };
22
+ const classPrefix = 'nut-rate';
23
+ const [countArray, setCountArray] = useState([1, 2, 3, 4, 5]);
24
+ const [score, setScore] = usePropsValue({
25
+ value,
26
+ defaultValue: Math.max(defaultValue || 0, min),
27
+ finalValue: 0,
28
+ onChange,
29
+ });
30
+ useEffect(() => {
31
+ const tmp = [];
32
+ for (let i = 1; i <= Number(count); i++) {
33
+ tmp.push(i);
34
+ }
35
+ setCountArray(tmp);
36
+ }, [count]);
37
+ const renderIcon = (n) => {
38
+ return n <= score
39
+ ? checkedIcon || React__default.createElement(StarFillN, null)
40
+ : uncheckedIcon ||
41
+ (checkedIcon ? (React__default.cloneElement(checkedIcon, {
42
+ color: undefined,
43
+ })) : (React__default.createElement(StarFillN, null)));
44
+ };
45
+ const onClick = (e, index) => {
46
+ e.preventDefault();
47
+ e.stopPropagation();
48
+ if (disabled || readOnly)
49
+ return;
50
+ let value = 0;
51
+ if (!(index === 1 && score === index)) {
52
+ value = index;
53
+ }
54
+ value = Math.max(value, min);
55
+ setScore(value);
56
+ };
57
+ const onHalfClick = (event, n) => {
58
+ event.preventDefault();
59
+ event.stopPropagation();
60
+ const value = Math.max(min, n - 0.5);
61
+ setScore(value);
62
+ };
63
+ return (React__default.createElement("div", { className: classNames(classPrefix, className, {
64
+ disabled,
65
+ readonly: readOnly,
66
+ }), style: style }, countArray.map((n) => {
67
+ return (React__default.createElement("div", { className: `${classPrefix}-item`, key: n, onClick: (event) => onClick(event, n) },
68
+ React__default.createElement("div", { className: classNames(`${classPrefix}-item__icon`, {
69
+ [`${classPrefix}-item__icon--disabled`]: disabled || n > score,
70
+ }) }, renderIcon(n)),
71
+ allowHalf && score > n - 1 && (React__default.createElement("div", { className: classNames(`${classPrefix}-item__half`, `${classPrefix}-item__icon`, `${classPrefix}-item__icon--half`), onClick: (event) => onHalfClick(event, n) }, renderIcon(n)))));
72
+ })));
73
+ };
74
+ Rate.defaultProps = defaultProps;
75
+ Rate.displayName = 'NutRate';
76
+
77
+ export { Rate as R };