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

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 +14 -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-a8d2148e.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-56e46dd3.js +137 -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 +505 -447
  208. package/dist/nutui.react.umd.js +504 -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,791 +0,0 @@
1
- import React, { useState, useRef, useEffect } from 'react';
2
- import classNames from 'classnames';
3
- import { ScrollView } from '@tarojs/components';
4
- import { nextTick } from '@tarojs/taro';
5
- import { c as cn } from './bem-350c1702.js';
6
- import { u as useConfig } from './configprovider.taro-ce34d482.js';
7
-
8
- const Utils = {
9
- /**
10
- * 是否为闫年
11
- * @return {Boolse} true|false
12
- */
13
- isLeapYear(y) {
14
- return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
15
- },
16
- /**
17
- * 返回星期数
18
- * @return {String}
19
- */
20
- getWhatDay(year, month, day) {
21
- const date = new Date(`${year}/${month}/${day}`);
22
- const index = date.getDay();
23
- const dayNames = [
24
- '星期日',
25
- '星期一',
26
- '星期二',
27
- '星期三',
28
- '星期四',
29
- '星期五',
30
- '星期六',
31
- ];
32
- return dayNames[index];
33
- },
34
- /**
35
- * 返回星期数
36
- * @return {Number}
37
- */
38
- getMonthPreDay(year, month) {
39
- const date = new Date(`${year}/${month}/01`);
40
- let day = date.getDay();
41
- if (day == 0) {
42
- day = 7;
43
- }
44
- return day;
45
- },
46
- /**
47
- * 返回月份天数
48
- * @return {Number}
49
- */
50
- getMonthDays(year, month) {
51
- if (/^0/.test(month)) {
52
- month = month.split('')[1];
53
- }
54
- return [
55
- 0,
56
- 31,
57
- this.isLeapYear(Number(year)) ? 29 : 28,
58
- 31,
59
- 30,
60
- 31,
61
- 30,
62
- 31,
63
- 31,
64
- 30,
65
- 31,
66
- 30,
67
- 31,
68
- ][month];
69
- },
70
- /**
71
- * 补齐数字位数
72
- * @return {string}
73
- */
74
- getNumTwoBit(n) {
75
- n = Number(n);
76
- return (n > 9 ? '' : '0') + n;
77
- },
78
- /**
79
- * 日期对象转成字符串
80
- * @return {string}
81
- */
82
- date2Str(date, split) {
83
- split = split || '-';
84
- const y = date.getFullYear();
85
- const m = this.getNumTwoBit(date.getMonth() + 1);
86
- const d = this.getNumTwoBit(date.getDate());
87
- return [y, m, d].join(split);
88
- },
89
- /**
90
- * 返回日期格式字符串
91
- * @param {Number} 0返回今天的日期、1返回明天的日期,2返回后天得日期,依次类推
92
- * @return {string} '2014-12-31'
93
- */
94
- getDay(i) {
95
- i = i || 0;
96
- let date = new Date();
97
- const diff = i * (1000 * 60 * 60 * 24);
98
- date = new Date(date.getTime() + diff);
99
- return this.date2Str(date);
100
- },
101
- /**
102
- * 时间比较
103
- * @return {Boolean}
104
- */
105
- compareDate(date1, date2) {
106
- const startTime = new Date(date1.replace('-', '/').replace('-', '/'));
107
- const endTime = new Date(date2.replace('-', '/').replace('-', '/'));
108
- if (startTime >= endTime) {
109
- return false;
110
- }
111
- return true;
112
- },
113
- /**
114
- * 时间是否相等
115
- * @return {Boolean}
116
- */
117
- isEqual(date1, date2) {
118
- const startTime = new Date(date1).getTime();
119
- const endTime = new Date(date2).getTime();
120
- if (startTime == endTime) {
121
- return true;
122
- }
123
- return false;
124
- },
125
- };
126
-
127
- const _window = window;
128
- function requestAniFrame() {
129
- if (typeof _window !== 'undefined') {
130
- return (_window.requestAnimationFrame ||
131
- _window.webkitRequestAnimationFrame ||
132
- function (callback) {
133
- _window.setTimeout(callback, 1000 / 60);
134
- });
135
- }
136
- else {
137
- return function (callback) {
138
- setTimeout(callback, 1000 / 60);
139
- };
140
- }
141
- }
142
- var requestAniFrame$1 = requestAniFrame();
143
-
144
- const defaultProps = {
145
- type: 'one',
146
- isAutoBackFill: false,
147
- poppable: true,
148
- visible: false,
149
- title: '日历选择',
150
- defaultValue: '',
151
- startDate: Utils.getDay(0),
152
- endDate: Utils.getDay(365),
153
- showToday: true,
154
- startText: '开始',
155
- endText: '结束',
156
- confirmText: '确认',
157
- showTitle: true,
158
- showSubTitle: true,
159
- toDateAnimation: true,
160
- onBtn: undefined,
161
- onDay: undefined,
162
- onTopInfo: undefined,
163
- onBottomInfo: undefined,
164
- onChoose: (data) => { },
165
- onUpdate: () => { },
166
- onSelected: (data) => { },
167
- onYearMonthChange: (data) => { },
168
- };
169
- const CalendarItem = React.forwardRef((props, ref) => {
170
- const { locale } = useConfig();
171
- const { type, isAutoBackFill, poppable, title, defaultValue, showToday, startText, endText, confirmText, showTitle, showSubTitle, toDateAnimation, onBtn, onDay, onTopInfo, onBottomInfo, onChoose, onUpdate, onSelected, onYearMonthChange, } = { ...defaultProps, ...props };
172
- const weeks = locale.calendaritem.weekdays;
173
- const [yearMonthTitle, setYearMonthTitle] = useState('');
174
- const [monthsData, setMonthsData] = useState([]);
175
- const [translateY, setTranslateY] = useState(0);
176
- const [monthDefaultRange, setMonthDefaultRange] = useState([]);
177
- const [scrollTop, setScrollTop] = useState(0);
178
- const [scrollWithAnimation, setScrollWithAnimation] = useState(false);
179
- const [state] = useState({
180
- currDate: '',
181
- propStartDate: '',
182
- propEndDate: '',
183
- unLoadPrev: false,
184
- touchParams: {
185
- startY: 0,
186
- endY: 0,
187
- startTime: 0,
188
- endTime: 0,
189
- lastY: 0,
190
- lastTime: 0,
191
- },
192
- transformY: 0,
193
- scrollDistance: 0,
194
- defaultData: [],
195
- chooseData: [],
196
- monthsData: [],
197
- dayPrefix: 'calendar-month-day',
198
- startData: '',
199
- endData: '',
200
- isRange: props.type === 'range',
201
- timer: 0,
202
- currentIndex: 0,
203
- avgHeight: 0,
204
- monthsNum: 0,
205
- });
206
- const weeksPanel = useRef(null);
207
- const months = useRef(null);
208
- const monthsPanel = useRef(null);
209
- const viewArea = useRef(null);
210
- let viewHeight = 0;
211
- const b = cn('calendar');
212
- const classes = classNames({
213
- [`${b('')}-tile`]: !poppable,
214
- [`${b('')}-nofooter`]: !!isAutoBackFill,
215
- }, b(''));
216
- const headerClasses = classNames({
217
- [`${b('')}-header`]: true,
218
- [`${b('')}-header-tile`]: !poppable,
219
- });
220
- const monthitemclasses = classNames({
221
- 'calendar-month-item': true,
222
- [`${type === 'range' ? 'month-item-range' : ''}`]: true,
223
- });
224
- const splitDate = (date) => {
225
- return date.split('-');
226
- };
227
- const isStart = (currDate) => {
228
- return Utils.isEqual(state.currDate[0], currDate);
229
- };
230
- const isEnd = (currDate) => {
231
- return Utils.isEqual(state.currDate[1], currDate);
232
- };
233
- const isMultiple = (currDate) => {
234
- if (state.currDate.length > 0) {
235
- return state.currDate.some((item) => {
236
- return Utils.isEqual(item, currDate);
237
- });
238
- }
239
- return false;
240
- };
241
- const getCurrDate = (day, month) => {
242
- return `${month.curData[0]}-${month.curData[1]}-${Utils.getNumTwoBit(+day.day)}`;
243
- };
244
- const getClass = (day, month) => {
245
- const currDate = getCurrDate(day, month);
246
- if (day.type === 'curr') {
247
- if (Utils.isEqual(state.currDate, currDate) ||
248
- (type === 'range' && (isStart(currDate) || isEnd(currDate))) ||
249
- (type === 'multiple' && isMultiple(currDate))) {
250
- return `${state.dayPrefix}-active`;
251
- }
252
- if ((state.propStartDate &&
253
- Utils.compareDate(currDate, state.propStartDate)) ||
254
- (state.propEndDate && Utils.compareDate(state.propEndDate, currDate))) {
255
- return `${state.dayPrefix}-disabled`;
256
- }
257
- if (type === 'range' &&
258
- Array.isArray(state.currDate) &&
259
- Object.values(state.currDate).length === 2 &&
260
- Utils.compareDate(state.currDate[0], currDate) &&
261
- Utils.compareDate(currDate, state.currDate[1])) {
262
- return `${state.dayPrefix}-choose`;
263
- }
264
- return null;
265
- }
266
- return `${state.dayPrefix}-disabled`;
267
- };
268
- const isActive = (day, month) => {
269
- return (state.isRange &&
270
- day.type === 'curr' &&
271
- getClass(day, month) === 'calendar-month-day-active');
272
- };
273
- const isCurrDay = (month, day) => {
274
- const date = `${month.curData[0]}-${month.curData[1]}-${day}`;
275
- return Utils.isEqual(date, Utils.date2Str(new Date()));
276
- };
277
- const confirm = () => {
278
- const { type } = props;
279
- if ((type === 'range' && state.chooseData.length === 2) ||
280
- type !== 'range') {
281
- const chooseData = state.chooseData.slice(0);
282
- onChoose && onChoose(chooseData);
283
- if (poppable) {
284
- onUpdate && onUpdate();
285
- }
286
- }
287
- };
288
- const chooseDay = (day, month, isFirst) => {
289
- if (getClass(day, month) !== `${state.dayPrefix}-disabled`) {
290
- const { type } = props;
291
- const days = [...month.curData];
292
- days[2] =
293
- typeof day.day === 'number' ? Utils.getNumTwoBit(day.day) : day.day;
294
- days[3] = `${days[0]}-${days[1]}-${days[2]}`;
295
- days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
296
- if (type === 'multiple') {
297
- if (state.currDate.length > 0) {
298
- let hasIndex = '';
299
- state.currDate.forEach((item, index) => {
300
- if (item === days[3]) {
301
- hasIndex = index;
302
- }
303
- });
304
- if (isFirst) {
305
- state.chooseData.push([...days]);
306
- }
307
- else if (hasIndex !== '') {
308
- state.currDate.splice(hasIndex, 1);
309
- state.chooseData.splice(hasIndex, 1);
310
- }
311
- else {
312
- state.currDate.push(days[3]);
313
- state.chooseData.push([...days]);
314
- }
315
- }
316
- else {
317
- state.currDate = [days[3]];
318
- state.chooseData = [[...days]];
319
- }
320
- }
321
- else if (type === 'range') {
322
- const curDataLength = Object.values(state.currDate).length;
323
- if (curDataLength === 2 || curDataLength === 0) {
324
- state.currDate = [days[3]];
325
- }
326
- else if (Utils.compareDate(state.currDate[0], days[3])) {
327
- Array.isArray(state.currDate) && state.currDate.push(days[3]);
328
- }
329
- else {
330
- Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
331
- }
332
- if (state.chooseData.length === 2 || !state.chooseData.length) {
333
- state.chooseData = [[...days]];
334
- }
335
- else if (Utils.compareDate(state.chooseData[0][3], days[3])) {
336
- state.chooseData = [...state.chooseData, [...days]];
337
- }
338
- else {
339
- state.chooseData = [[...days], ...state.chooseData];
340
- }
341
- }
342
- else {
343
- state.currDate = days[3];
344
- state.chooseData = [...days];
345
- }
346
- if (!isFirst) {
347
- // 点击日期 触发
348
- onSelected && onSelected(state.chooseData);
349
- if (isAutoBackFill || !poppable) {
350
- confirm();
351
- }
352
- }
353
- setMonthsData(state.monthsData.slice());
354
- }
355
- };
356
- const isStartTip = (day, month) => {
357
- return isActive(day, month) && isStart(getCurrDate(day, month));
358
- };
359
- // 是否有结束提示
360
- const isEndTip = (day, month) => {
361
- if (state.currDate.length >= 2 && isEnd(getCurrDate(day, month))) {
362
- return isActive(day, month);
363
- }
364
- return false;
365
- };
366
- // 开始结束时间是否相等
367
- const rangeTip = () => {
368
- if (state.currDate.length >= 2) {
369
- return Utils.isEqual(state.currDate[0], state.currDate[1]);
370
- }
371
- return false;
372
- };
373
- // 获取当前月数据
374
- const getCurrData = (type) => {
375
- const monthData = type === 'prev'
376
- ? state.monthsData[0]
377
- : state.monthsData[state.monthsData.length - 1];
378
- let year = parseInt(monthData.curData[0]);
379
- let month = parseInt(monthData.curData[1].toString().replace(/^0/, ''));
380
- switch (type) {
381
- case 'prev':
382
- month === 1 && (year -= 1);
383
- month = month === 1 ? 12 : --month;
384
- break;
385
- case 'next':
386
- month === 12 && (year += 1);
387
- month = month === 12 ? 1 : ++month;
388
- break;
389
- }
390
- return [
391
- year,
392
- Utils.getNumTwoBit(month),
393
- Utils.getMonthDays(String(year), String(month)),
394
- ];
395
- };
396
- // 获取日期状态
397
- const getDaysStatus = (days, type, dateInfo) => {
398
- // 修复:当某个月的1号是周日时,月份下方会空出来一行
399
- const { year, month } = dateInfo;
400
- if (type === 'prev' && days >= 7) {
401
- days -= 7;
402
- }
403
- return Array.from(Array(days), (v, k) => {
404
- return {
405
- day: k + 1,
406
- type,
407
- year,
408
- month,
409
- };
410
- });
411
- };
412
- // 获取上一个月的最后一周天数,填充当月空白
413
- const getPreDaysStatus = (days, type, dateInfo, preCurrMonthDays) => {
414
- // 修复:当某个月的1号是周日时,月份下方会空出来一行
415
- const { year, month } = dateInfo;
416
- if (type === 'prev' && days >= 7) {
417
- days -= 7;
418
- }
419
- const months = Array.from(Array(preCurrMonthDays), (v, k) => {
420
- return {
421
- day: k + 1,
422
- type,
423
- year,
424
- month,
425
- };
426
- });
427
- return months.slice(preCurrMonthDays - days);
428
- };
429
- // 获取月数据
430
- const getMonth = (curData, type) => {
431
- const preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
432
- let preMonth = +curData[1] - 1;
433
- let preYear = curData[0];
434
- if (preMonth <= 0) {
435
- preMonth = 12;
436
- preYear += 1;
437
- }
438
- const currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
439
- const preCurrMonthDays = Utils.getMonthDays(`${preYear}`, `${preMonth}`);
440
- const title = {
441
- year: curData[0],
442
- month: curData[1],
443
- };
444
- const monthInfo = {
445
- curData,
446
- title: locale.calendaritem.monthTitle(title.year, title.month),
447
- monthData: [
448
- ...getPreDaysStatus(preMonthDays, 'prev', { month: preMonth, year: preYear }, preCurrMonthDays),
449
- ...getDaysStatus(currMonthDays, 'curr', title),
450
- ],
451
- };
452
- monthInfo.cssHeight = 39 + (monthInfo.monthData.length > 35 ? 384 : 320);
453
- let cssScrollHeight = 0;
454
- if (state.monthsData.length > 0) {
455
- cssScrollHeight =
456
- state.monthsData[state.monthsData.length - 1].cssScrollHeight +
457
- state.monthsData[state.monthsData.length - 1].cssHeight;
458
- }
459
- monthInfo.cssScrollHeight = cssScrollHeight;
460
- if (type === 'next') {
461
- if (!state.endData ||
462
- !Utils.compareDate(`${state.endData[0]}-${state.endData[1]}-${Utils.getMonthDays(state.endData[0], state.endData[1])}`, `${curData[0]}-${curData[1]}-${curData[2]}`)) {
463
- state.monthsData.push(monthInfo);
464
- }
465
- }
466
- else if (!state.startData ||
467
- !Utils.compareDate(`${curData[0]}-${curData[1]}-${curData[2]}`, `${state.startData[0]}-${state.startData[1]}-01`)) {
468
- state.monthsData.unshift(monthInfo);
469
- }
470
- setMonthsData(state.monthsData);
471
- };
472
- const setReachedYearMonthInfo = () => {
473
- const currentMonthsData = state.monthsData[state.currentIndex];
474
- const [year, month] = currentMonthsData.curData;
475
- if (currentMonthsData.title === yearMonthTitle)
476
- return;
477
- onYearMonthChange && onYearMonthChange([year, month, `${year}-${month}`]);
478
- setYearMonthTitle(currentMonthsData.title);
479
- };
480
- const setDefaultRange = (monthsNum, current) => {
481
- let start = 0;
482
- let end = 0;
483
- if (monthsNum >= 3) {
484
- if (current > 0 && current < monthsNum) {
485
- start = current - 1;
486
- end = current + 3;
487
- }
488
- else if (current === 0) {
489
- start = current;
490
- end = current + 4;
491
- }
492
- else if (current === monthsNum) {
493
- start = current - 2;
494
- end = current + 2;
495
- }
496
- }
497
- else {
498
- start = 0;
499
- end = monthsNum + 2;
500
- }
501
- setMonthDefaultRange([start, end]);
502
- setTranslateY(state.monthsData[start].cssScrollHeight);
503
- };
504
- const monthsViewScroll = (e) => {
505
- if (state.monthsData.length <= 1) {
506
- return;
507
- }
508
- const target = e.target;
509
- const currentScrollTop = target.scrollTop;
510
- let current = Math.floor(currentScrollTop / state.avgHeight);
511
- if (current === 0) {
512
- if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
513
- current += 1;
514
- }
515
- }
516
- else if (current > 0 && current < state.monthsNum - 1) {
517
- if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
518
- current += 1;
519
- }
520
- if (currentScrollTop < state.monthsData[current].cssScrollHeight) {
521
- current -= 1;
522
- }
523
- }
524
- else {
525
- const viewPosition = Math.round(currentScrollTop + viewHeight);
526
- if (viewPosition <
527
- state.monthsData[current].cssScrollHeight +
528
- state.monthsData[current].cssHeight &&
529
- currentScrollTop > state.monthsData[current - 1].cssScrollHeight) {
530
- current -= 1;
531
- }
532
- if (current + 1 <= state.monthsNum &&
533
- viewPosition >=
534
- state.monthsData[current + 1].cssScrollHeight +
535
- state.monthsData[current + 1].cssHeight) {
536
- current += 1;
537
- }
538
- if (current >= 1 &&
539
- currentScrollTop < state.monthsData[current - 1].cssScrollHeight) {
540
- current -= 1;
541
- }
542
- }
543
- if (state.currentIndex !== current) {
544
- state.currentIndex = current;
545
- setDefaultRange(state.monthsNum, current);
546
- }
547
- setReachedYearMonthInfo();
548
- };
549
- const initData = () => {
550
- // 初始化开始结束数据
551
- const propStartDate = props.startDate ? props.startDate : Utils.getDay(0);
552
- const propEndDate = props.endDate ? props.endDate : Utils.getDay(365);
553
- state.propStartDate = propStartDate;
554
- state.propEndDate = propEndDate;
555
- state.startData = splitDate(propStartDate);
556
- state.endData = splitDate(propEndDate);
557
- // 根据是否存在默认时间,初始化当前日期
558
- if (defaultValue ||
559
- (Array.isArray(defaultValue) && defaultValue.length > 0)) {
560
- state.currDate =
561
- props.type !== 'one'
562
- ? [...props.defaultValue]
563
- : props.defaultValue;
564
- }
565
- // 判断时间范围内存在多少个月
566
- const startDate = {
567
- year: Number(state.startData[0]),
568
- month: Number(state.startData[1]),
569
- };
570
- const endDate = {
571
- year: Number(state.endData[0]),
572
- month: Number(state.endData[1]),
573
- };
574
- let monthsNum = endDate.month - startDate.month;
575
- if (endDate.year - startDate.year > 0) {
576
- monthsNum += 12 * (endDate.year - startDate.year);
577
- }
578
- if (monthsNum <= 0) {
579
- monthsNum = 1;
580
- }
581
- // 设置月份数据
582
- getMonth(state.startData, 'next');
583
- let i = 1;
584
- do {
585
- getMonth(getCurrData('next'), 'next');
586
- } while (i++ < monthsNum);
587
- state.monthsNum = monthsNum;
588
- // 日期转化为数组,限制初始日期。判断时间范围
589
- if (type === 'range' && Array.isArray(state.currDate)) {
590
- if (state.currDate.length > 0) {
591
- if (propStartDate &&
592
- Utils.compareDate(state.currDate[0], propStartDate)) {
593
- state.currDate.splice(0, 1, propStartDate);
594
- }
595
- if (propEndDate &&
596
- Utils.compareDate(propEndDate, state.currDate[1])) {
597
- state.currDate.splice(1, 1, propEndDate);
598
- }
599
- state.defaultData = [
600
- ...splitDate(state.currDate[0]),
601
- ...splitDate(state.currDate[1]),
602
- ];
603
- }
604
- }
605
- else if (props.type === 'multiple' && Array.isArray(state.currDate)) {
606
- if (state.currDate.length > 0) {
607
- const defaultArr = [];
608
- const obj = {};
609
- state.currDate.forEach((item) => {
610
- if (propStartDate &&
611
- !Utils.compareDate(item, propStartDate) &&
612
- propEndDate &&
613
- !Utils.compareDate(propEndDate, item)) {
614
- if (!Object.hasOwnProperty.call(obj, item)) {
615
- defaultArr.push(item);
616
- obj[item] = item;
617
- }
618
- }
619
- });
620
- state.currDate = [...defaultArr];
621
- state.defaultData = [...splitDate(defaultArr[0])];
622
- }
623
- }
624
- else if (state.currDate) {
625
- if (propStartDate &&
626
- Utils.compareDate(state.currDate, propStartDate)) {
627
- state.currDate = propStartDate;
628
- }
629
- else if (propEndDate &&
630
- !Utils.compareDate(state.currDate, propEndDate)) {
631
- state.currDate = propEndDate;
632
- }
633
- state.defaultData = [...splitDate(state.currDate)];
634
- }
635
- // 设置默认可见区域
636
- let current = 0;
637
- let lastCurrent = 0;
638
- if (state.defaultData.length > 0) {
639
- state.monthsData.forEach((item, index) => {
640
- if (item.title ===
641
- locale.calendaritem.monthTitle(state.defaultData[0], state.defaultData[1])) {
642
- current = index;
643
- }
644
- if (props.type === 'range') {
645
- if (item.title ===
646
- locale.calendaritem.monthTitle(state.defaultData[3], state.defaultData[4])) {
647
- lastCurrent = index;
648
- }
649
- }
650
- });
651
- }
652
- else {
653
- // 当 defaultValue 为空时,如果月份列表包含当月,则默认定位到当月
654
- const currentYear = new Date().getFullYear();
655
- const currentMonth = new Date().getMonth() + 1;
656
- const currentYearMonthIndex = state.monthsData.findIndex((item) => {
657
- return (+item.curData[0] === currentYear && +item.curData[1] === currentMonth);
658
- });
659
- if (currentYearMonthIndex > -1) {
660
- current = currentYearMonthIndex;
661
- }
662
- }
663
- setDefaultRange(monthsNum, current);
664
- state.currentIndex = current;
665
- setReachedYearMonthInfo();
666
- if (state.defaultData.length > 0) {
667
- // 设置当前选中日期
668
- if (type === 'range') {
669
- chooseDay({ day: state.defaultData[2], type: 'curr' }, state.monthsData[state.currentIndex], true);
670
- chooseDay({ day: state.defaultData[5], type: 'curr' }, state.monthsData[lastCurrent], true);
671
- }
672
- else if (type === 'multiple') {
673
- [...state.currDate].forEach((item) => {
674
- const dateArr = splitDate(item);
675
- let current = state.currentIndex;
676
- state.monthsData.forEach((item, index) => {
677
- if (item.title ===
678
- locale.calendaritem.monthTitle(dateArr[0], dateArr[1])) {
679
- current = index;
680
- }
681
- });
682
- chooseDay({ day: dateArr[2], type: 'curr' }, state.monthsData[current], true);
683
- });
684
- }
685
- else {
686
- chooseDay({ day: state.defaultData[2], type: 'curr' }, state.monthsData[state.currentIndex], true);
687
- }
688
- }
689
- const lastItem = state.monthsData[state.monthsData.length - 1];
690
- const containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
691
- requestAniFrame$1(() => {
692
- // 初始化 日历位置
693
- if (months && monthsPanel && viewArea) {
694
- viewHeight = months.current.clientHeight;
695
- monthsPanel.current.style.height = `${containerHeight}px`;
696
- setScrollTop(state.monthsData[state.currentIndex].cssScrollHeight);
697
- nextTick(() => setScrollWithAnimation(true));
698
- }
699
- });
700
- state.avgHeight = Math.floor(containerHeight / (monthsNum + 1));
701
- };
702
- const resetRender = () => {
703
- state.chooseData.splice(0);
704
- state.monthsData.splice(0);
705
- initData();
706
- };
707
- // 暴露出的API
708
- const scrollToDate = (date) => {
709
- if (Utils.compareDate(date, state.propStartDate)) {
710
- date = state.propStartDate;
711
- }
712
- else if (!Utils.compareDate(date, state.propEndDate)) {
713
- date = state.propEndDate;
714
- }
715
- const dateArr = splitDate(date);
716
- state.monthsData.forEach((item, index) => {
717
- if (item.title === locale.calendaritem.monthTitle(dateArr[0], dateArr[1])) {
718
- if (months.current) {
719
- const distance = state.monthsData[index].cssScrollHeight - months.current.scrollTop;
720
- if (toDateAnimation) {
721
- let flag = 0;
722
- const interval = setInterval(() => {
723
- flag++;
724
- if (months.current) {
725
- const offset = distance / 10;
726
- months.current.scrollTop += offset;
727
- }
728
- if (flag >= 10) {
729
- clearInterval(interval);
730
- if (months.current) {
731
- months.current.scrollTop =
732
- state.monthsData[index].cssScrollHeight;
733
- setScrollTop(months.current.scrollTop);
734
- }
735
- }
736
- }, 40);
737
- }
738
- else {
739
- months.current.scrollTop = state.monthsData[index].cssScrollHeight;
740
- setScrollTop(months.current.scrollTop);
741
- }
742
- }
743
- }
744
- });
745
- };
746
- useEffect(() => {
747
- initData();
748
- }, []);
749
- useEffect(() => {
750
- poppable && resetRender();
751
- }, [defaultValue]);
752
- React.useImperativeHandle(ref, () => ({
753
- scrollToDate,
754
- }));
755
- return (React.createElement(React.Fragment, null,
756
- React.createElement("div", { className: classes },
757
- React.createElement("div", { className: headerClasses },
758
- showTitle && (React.createElement("div", { className: "calendar-title" }, title || locale.calendaritem.title)),
759
- onBtn && React.createElement("div", { className: "calendar-top-slot" }, onBtn()),
760
- showSubTitle && (React.createElement("div", { className: "calendar-curr-month" }, yearMonthTitle)),
761
- React.createElement("div", { className: "calendar-weeks", ref: weeksPanel }, weeks.map((item) => (React.createElement("div", { className: "calendar-week-item", key: item }, item))))),
762
- React.createElement(ScrollView, { scrollTop: scrollTop, scrollY: true, type: "list", scrollWithAnimation: scrollWithAnimation, className: "nut-calendar-content", onScroll: monthsViewScroll, ref: months },
763
- React.createElement("div", { className: "calendar-months-panel", ref: monthsPanel },
764
- React.createElement("div", { className: "viewArea", ref: viewArea, style: { transform: `translateY(${translateY}px)` } }, state.monthsData
765
- .slice(monthDefaultRange[0], monthDefaultRange[1])
766
- .map((month, key) => {
767
- return (React.createElement("div", { className: "calendar-month", key: key },
768
- React.createElement("div", { className: "calendar-month-title" }, month.title),
769
- React.createElement("div", { className: "calendar-month-con" },
770
- React.createElement("div", { className: monthitemclasses }, month.monthData.map((day, i) => (React.createElement("div", { className: [
771
- 'calendar-month-day',
772
- getClass(day, month),
773
- ].join(' '), onClick: () => {
774
- chooseDay(day, month);
775
- }, key: i },
776
- React.createElement("div", { className: "calendar-day" }, onDay ? onDay(day) : day.day),
777
- onTopInfo && (React.createElement("div", { className: "calendar-curr-tips calendar-curr-tips-top" }, onTopInfo(day))),
778
- onBottomInfo && (React.createElement("div", { className: "calendar-curr-tips calendar-curr-tips-bottom" }, onBottomInfo(day))),
779
- !onBottomInfo &&
780
- showToday &&
781
- isCurrDay(month, day.day) && (React.createElement("div", { className: "calendar-curr-tip-curr" }, locale.calendaritem.today)),
782
- isStartTip(day, month) && (React.createElement("div", { className: `calendar-day-tip ${rangeTip() ? 'calendar-curr-tips-top' : ''}` }, startText || locale.calendaritem.start)),
783
- isEndTip(day, month) && (React.createElement("div", { className: "calendar-day-tip" }, endText || locale.calendaritem.end)))))))));
784
- })))),
785
- poppable && !isAutoBackFill ? (React.createElement("div", { className: "nut-calendar-footer" },
786
- React.createElement("div", { className: "calendar-confirm-btn", onClick: confirm }, confirmText || locale.confirm))) : (''))));
787
- });
788
- CalendarItem.defaultProps = defaultProps;
789
- CalendarItem.displayName = 'NutCalendarItem';
790
-
791
- export { CalendarItem as C, Utils as U };