react-native-system-ui 0.0.7 → 1.0.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 (366) hide show
  1. package/README.md +46 -31
  2. package/dist/cjs/components/action-sheet/ActionSheet.js +97 -105
  3. package/dist/cjs/components/action-sheet/tokens.js +16 -27
  4. package/dist/cjs/components/area/Area.js +54 -67
  5. package/dist/cjs/components/area/tokens.js +6 -3
  6. package/dist/cjs/components/avatar/Avatar.js +25 -23
  7. package/dist/cjs/components/badge/Badge.js +31 -31
  8. package/dist/cjs/components/badge/tokens.js +6 -8
  9. package/dist/cjs/components/button/Button.js +115 -151
  10. package/dist/cjs/components/button/ButtonGroup.js +8 -42
  11. package/dist/cjs/components/button/tokens.js +1 -8
  12. package/dist/cjs/components/calendar/Calendar.js +212 -223
  13. package/dist/cjs/components/calendar/tokens.js +3 -3
  14. package/dist/cjs/components/cascader/Cascader.js +177 -180
  15. package/dist/cjs/components/cascader/tokens.js +2 -2
  16. package/dist/cjs/components/cascader/useCascaderExtend.js +25 -29
  17. package/dist/cjs/components/cell/Cell.js +70 -83
  18. package/dist/cjs/components/cell/CellGroup.js +16 -29
  19. package/dist/cjs/components/checkbox/Checkbox.js +139 -132
  20. package/dist/cjs/components/checkbox/CheckboxGroup.js +4 -35
  21. package/dist/cjs/components/checkbox/tokens.js +7 -10
  22. package/dist/cjs/components/circle/Circle.js +25 -24
  23. package/dist/cjs/components/collapse/Collapse.js +75 -91
  24. package/dist/cjs/components/config-provider/ConfigProvider.js +16 -3
  25. package/dist/cjs/components/config-provider/DirectionContext.js +15 -0
  26. package/dist/cjs/components/config-provider/index.js +7 -0
  27. package/dist/cjs/components/config-provider/locale/en-US.js +32 -0
  28. package/dist/cjs/components/config-provider/locale/zh-CN.js +32 -0
  29. package/dist/cjs/components/config-provider/useDirection.js +16 -0
  30. package/dist/cjs/components/count-down/CountDown.js +20 -15
  31. package/dist/cjs/components/datetime-picker/DatetimePicker.js +61 -84
  32. package/dist/cjs/components/datetime-picker/tokens.js +14 -3
  33. package/dist/cjs/components/dialog/Dialog.js +153 -121
  34. package/dist/cjs/components/dialog/imperative.js +17 -30
  35. package/dist/cjs/components/divider/Divider.js +26 -28
  36. package/dist/cjs/components/empty/Empty.js +35 -39
  37. package/dist/cjs/components/error-boundary/ErrorBoundary.js +73 -0
  38. package/dist/cjs/components/error-boundary/index.js +19 -0
  39. package/dist/cjs/components/field/Field.js +109 -106
  40. package/dist/cjs/components/flex/Flex.js +18 -18
  41. package/dist/cjs/components/flex/FlexItem.js +26 -27
  42. package/dist/cjs/components/form/Form.js +142 -161
  43. package/dist/cjs/components/form/FormItem.js +69 -97
  44. package/dist/cjs/components/form/FormList.js +49 -37
  45. package/dist/cjs/components/form/tokens.js +6 -3
  46. package/dist/cjs/components/form/utils.js +15 -34
  47. package/dist/cjs/components/grid/Grid.js +30 -29
  48. package/dist/cjs/components/grid/GridItem.js +84 -85
  49. package/dist/cjs/components/image/Image.js +55 -59
  50. package/dist/cjs/components/image/tokens.js +2 -2
  51. package/dist/cjs/components/image-preview/ImagePreview.js +124 -112
  52. package/dist/cjs/components/image-preview/imperative.js +4 -13
  53. package/dist/cjs/components/index.js +13 -0
  54. package/dist/cjs/components/input/Input.js +30 -22
  55. package/dist/cjs/components/loading/Loading.js +14 -15
  56. package/dist/cjs/components/nav-bar/NavBar.js +68 -83
  57. package/dist/cjs/components/nav-bar/tokens.js +1 -9
  58. package/dist/cjs/components/notice-bar/NoticeBar.js +74 -77
  59. package/dist/cjs/components/notify/Notify.js +88 -84
  60. package/dist/cjs/components/notify/imperative.js +20 -43
  61. package/dist/cjs/components/notify/tokens.js +1 -11
  62. package/dist/cjs/components/number-keyboard/NumberKeyboard.js +187 -209
  63. package/dist/cjs/components/overlay/Overlay.js +37 -52
  64. package/dist/cjs/components/overlay/tokens.js +5 -3
  65. package/dist/cjs/components/password-input/PasswordInput.js +98 -79
  66. package/dist/cjs/components/picker/Picker.js +440 -421
  67. package/dist/cjs/components/picker/tokens.js +1 -1
  68. package/dist/cjs/components/popup/Popup.js +263 -293
  69. package/dist/cjs/components/portal/Portal.js +12 -29
  70. package/dist/cjs/components/portal/PortalHost.js +151 -234
  71. package/dist/cjs/components/progress/Progress.js +51 -48
  72. package/dist/cjs/components/radio/Radio.js +45 -42
  73. package/dist/cjs/components/radio/RadioGroup.js +8 -40
  74. package/dist/cjs/components/radio/tokens.js +7 -10
  75. package/dist/cjs/components/safe-area-view/SafeAreaView.js +22 -26
  76. package/dist/cjs/components/search/Search.js +51 -43
  77. package/dist/cjs/components/selector/Selector.js +14 -13
  78. package/dist/cjs/components/share-sheet/ShareSheet.js +160 -161
  79. package/dist/cjs/components/sidebar/Sidebar.js +39 -45
  80. package/dist/cjs/components/sidebar/SidebarContext.js +1 -2
  81. package/dist/cjs/components/sidebar/SidebarItem.js +13 -16
  82. package/dist/cjs/components/sidebar/tokens.js +1 -3
  83. package/dist/cjs/components/skeleton/Skeleton.js +30 -37
  84. package/dist/cjs/components/skeleton/tokens.js +1 -2
  85. package/dist/cjs/components/slider/Slider.js +156 -135
  86. package/dist/cjs/components/space/Space.js +46 -69
  87. package/dist/cjs/components/stepper/Stepper.js +177 -155
  88. package/dist/cjs/components/swiper/Swiper.js +251 -253
  89. package/dist/cjs/components/swiper/SwiperPagIndicator.js +25 -27
  90. package/dist/cjs/components/swiper/tokens.js +10 -3
  91. package/dist/cjs/components/switch/Switch.js +13 -15
  92. package/dist/cjs/components/tabbar/Tabbar.js +35 -27
  93. package/dist/cjs/components/tabbar/TabbarContext.js +1 -2
  94. package/dist/cjs/components/tabbar/TabbarItem.js +65 -68
  95. package/dist/cjs/components/tabs/Tabs.js +286 -313
  96. package/dist/cjs/components/tag/Tag.js +46 -37
  97. package/dist/cjs/components/toast/Toast.js +90 -90
  98. package/dist/cjs/components/toast/imperative.js +16 -41
  99. package/dist/cjs/components/typography/Typography.js +3 -5
  100. package/dist/cjs/components/water-mark/WaterMark.js +31 -29
  101. package/dist/cjs/design-system/ThemeProvider.js +5 -11
  102. package/dist/cjs/design-system/createComponentTokensHook.js +11 -13
  103. package/dist/cjs/design-system/presets.js +2 -3
  104. package/dist/cjs/design-system/tokens.js +2 -11
  105. package/dist/cjs/hooks/animation/index.js +25 -0
  106. package/dist/cjs/hooks/animation/useAnimatedTransition.js +72 -0
  107. package/dist/cjs/hooks/animation/useReducedMotion.js +75 -0
  108. package/dist/cjs/hooks/aria/useAriaListBox.js +8 -16
  109. package/dist/cjs/hooks/aria/useAriaOverlay.js +3 -3
  110. package/dist/cjs/hooks/aria/useAriaPress.js +8 -21
  111. package/dist/cjs/hooks/aria/useAriaToggle.js +3 -3
  112. package/dist/cjs/hooks/gesture/useGestureScroll.js +60 -61
  113. package/dist/cjs/hooks/index.js +12 -0
  114. package/dist/cjs/hooks/overlay/OverlayStackStore.js +49 -69
  115. package/dist/cjs/hooks/overlay/useOverlayStack.js +13 -19
  116. package/dist/cjs/hooks/useControllableValue.js +10 -21
  117. package/dist/cjs/hooks/useCountDown.js +14 -22
  118. package/dist/cjs/hooks/useHairline.js +17 -29
  119. package/dist/cjs/hooks/useSafeAreaPadding.js +1 -4
  120. package/dist/cjs/index.js +67 -1
  121. package/dist/cjs/platform/animation.js +10 -2
  122. package/dist/cjs/platform/measure.js +18 -36
  123. package/dist/cjs/utils/color.js +21 -35
  124. package/dist/cjs/utils/compare.js +7 -12
  125. package/dist/cjs/utils/createPlatformShadow.js +28 -39
  126. package/dist/cjs/utils/date.js +20 -50
  127. package/dist/cjs/utils/deepMerge.js +16 -26
  128. package/dist/cjs/utils/hairline.js +74 -71
  129. package/dist/cjs/utils/index.js +22 -0
  130. package/dist/cjs/utils/number.js +21 -29
  131. package/dist/cjs/utils/render.js +27 -0
  132. package/dist/cjs/utils/rtl.js +25 -0
  133. package/dist/cjs/utils/string.js +8 -25
  134. package/dist/es/components/action-sheet/ActionSheet.js +99 -107
  135. package/dist/es/components/action-sheet/tokens.js +16 -27
  136. package/dist/es/components/area/Area.js +55 -68
  137. package/dist/es/components/area/tokens.js +6 -3
  138. package/dist/es/components/avatar/Avatar.js +25 -23
  139. package/dist/es/components/avatar/index.js +1 -2
  140. package/dist/es/components/badge/Badge.js +33 -33
  141. package/dist/es/components/badge/tokens.js +6 -8
  142. package/dist/es/components/button/Button.js +116 -152
  143. package/dist/es/components/button/ButtonGroup.js +9 -43
  144. package/dist/es/components/button/tokens.js +2 -3
  145. package/dist/es/components/calendar/Calendar.js +214 -225
  146. package/dist/es/components/calendar/tokens.js +3 -3
  147. package/dist/es/components/cascader/Cascader.js +180 -183
  148. package/dist/es/components/cascader/tokens.js +2 -2
  149. package/dist/es/components/cascader/useCascaderExtend.js +25 -29
  150. package/dist/es/components/cell/Cell.js +71 -84
  151. package/dist/es/components/cell/CellGroup.js +16 -28
  152. package/dist/es/components/checkbox/Checkbox.js +140 -133
  153. package/dist/es/components/checkbox/CheckboxGroup.js +5 -36
  154. package/dist/es/components/checkbox/tokens.js +7 -10
  155. package/dist/es/components/circle/Circle.js +25 -23
  156. package/dist/es/components/collapse/Collapse.js +77 -92
  157. package/dist/es/components/config-provider/ConfigProvider.js +10 -3
  158. package/dist/es/components/config-provider/DirectionContext.js +2 -0
  159. package/dist/es/components/config-provider/index.js +1 -0
  160. package/dist/es/components/config-provider/locale/en-US.js +32 -0
  161. package/dist/es/components/config-provider/locale/zh-CN.js +32 -0
  162. package/dist/es/components/config-provider/useDirection.js +3 -0
  163. package/dist/es/components/count-down/CountDown.js +23 -18
  164. package/dist/es/components/datetime-picker/DatetimePicker.js +61 -84
  165. package/dist/es/components/datetime-picker/tokens.js +14 -3
  166. package/dist/es/components/dialog/Dialog.js +154 -121
  167. package/dist/es/components/dialog/imperative.js +17 -30
  168. package/dist/es/components/divider/Divider.js +28 -29
  169. package/dist/es/components/empty/Empty.js +36 -39
  170. package/dist/es/components/error-boundary/ErrorBoundary.js +61 -0
  171. package/dist/es/components/error-boundary/index.js +1 -0
  172. package/dist/es/components/field/Field.js +109 -106
  173. package/dist/es/components/flex/Flex.js +18 -17
  174. package/dist/es/components/flex/FlexItem.js +27 -27
  175. package/dist/es/components/form/Form.js +143 -162
  176. package/dist/es/components/form/FormItem.js +68 -95
  177. package/dist/es/components/form/FormList.js +49 -37
  178. package/dist/es/components/form/tokens.js +6 -3
  179. package/dist/es/components/form/utils.js +15 -34
  180. package/dist/es/components/grid/Grid.js +30 -28
  181. package/dist/es/components/grid/GridItem.js +84 -84
  182. package/dist/es/components/image/Image.js +58 -62
  183. package/dist/es/components/image/tokens.js +2 -2
  184. package/dist/es/components/image-preview/ImagePreview.js +124 -112
  185. package/dist/es/components/image-preview/imperative.js +4 -13
  186. package/dist/es/components/index.js +3 -1
  187. package/dist/es/components/input/Input.js +31 -23
  188. package/dist/es/components/loading/Loading.js +16 -16
  189. package/dist/es/components/nav-bar/NavBar.js +68 -83
  190. package/dist/es/components/nav-bar/tokens.js +1 -3
  191. package/dist/es/components/notice-bar/NoticeBar.js +74 -76
  192. package/dist/es/components/notify/Notify.js +92 -87
  193. package/dist/es/components/notify/imperative.js +21 -44
  194. package/dist/es/components/notify/tokens.js +1 -5
  195. package/dist/es/components/number-keyboard/NumberKeyboard.js +187 -209
  196. package/dist/es/components/overlay/Overlay.js +36 -51
  197. package/dist/es/components/overlay/tokens.js +5 -3
  198. package/dist/es/components/password-input/PasswordInput.js +98 -79
  199. package/dist/es/components/picker/Picker.js +440 -421
  200. package/dist/es/components/picker/tokens.js +1 -1
  201. package/dist/es/components/popup/Popup.js +263 -292
  202. package/dist/es/components/portal/Portal.js +13 -29
  203. package/dist/es/components/portal/PortalHost.js +152 -234
  204. package/dist/es/components/progress/Progress.js +51 -48
  205. package/dist/es/components/radio/Radio.js +47 -44
  206. package/dist/es/components/radio/RadioGroup.js +10 -41
  207. package/dist/es/components/radio/tokens.js +7 -10
  208. package/dist/es/components/safe-area-view/SafeAreaView.js +22 -25
  209. package/dist/es/components/search/Search.js +52 -44
  210. package/dist/es/components/selector/Selector.js +14 -13
  211. package/dist/es/components/share-sheet/ShareSheet.js +162 -163
  212. package/dist/es/components/sidebar/Sidebar.js +41 -47
  213. package/dist/es/components/sidebar/SidebarContext.js +1 -2
  214. package/dist/es/components/sidebar/SidebarItem.js +13 -15
  215. package/dist/es/components/sidebar/tokens.js +1 -3
  216. package/dist/es/components/skeleton/Skeleton.js +30 -37
  217. package/dist/es/components/skeleton/tokens.js +1 -2
  218. package/dist/es/components/slider/Slider.js +156 -134
  219. package/dist/es/components/space/Space.js +48 -71
  220. package/dist/es/components/stepper/Stepper.js +178 -156
  221. package/dist/es/components/swiper/Swiper.js +252 -254
  222. package/dist/es/components/swiper/SwiperPagIndicator.js +25 -27
  223. package/dist/es/components/swiper/tokens.js +10 -3
  224. package/dist/es/components/switch/Switch.js +13 -15
  225. package/dist/es/components/tabbar/Tabbar.js +36 -28
  226. package/dist/es/components/tabbar/TabbarContext.js +1 -2
  227. package/dist/es/components/tabbar/TabbarItem.js +66 -69
  228. package/dist/es/components/tabs/Tabs.js +286 -313
  229. package/dist/es/components/tag/Tag.js +49 -39
  230. package/dist/es/components/toast/Toast.js +93 -91
  231. package/dist/es/components/toast/imperative.js +16 -41
  232. package/dist/es/components/typography/Typography.js +3 -5
  233. package/dist/es/components/water-mark/WaterMark.js +32 -30
  234. package/dist/es/design-system/ThemeProvider.js +5 -11
  235. package/dist/es/design-system/createComponentTokensHook.js +11 -13
  236. package/dist/es/design-system/presets.js +2 -3
  237. package/dist/es/design-system/tokens.js +1 -9
  238. package/dist/es/hooks/animation/index.js +2 -0
  239. package/dist/es/hooks/animation/useAnimatedTransition.js +53 -0
  240. package/dist/es/hooks/animation/useReducedMotion.js +54 -0
  241. package/dist/es/hooks/aria/useAriaListBox.js +8 -16
  242. package/dist/es/hooks/aria/useAriaOverlay.js +3 -3
  243. package/dist/es/hooks/aria/useAriaPress.js +8 -21
  244. package/dist/es/hooks/aria/useAriaToggle.js +3 -3
  245. package/dist/es/hooks/gesture/useGestureScroll.js +60 -61
  246. package/dist/es/hooks/index.js +1 -0
  247. package/dist/es/hooks/overlay/OverlayStackStore.js +49 -69
  248. package/dist/es/hooks/overlay/useOverlayStack.js +13 -19
  249. package/dist/es/hooks/useControllableValue.js +10 -21
  250. package/dist/es/hooks/useCountDown.js +14 -22
  251. package/dist/es/hooks/useHairline.js +16 -28
  252. package/dist/es/hooks/useSafeAreaPadding.js +1 -4
  253. package/dist/es/index.js +8 -1
  254. package/dist/es/platform/animation.js +9 -1
  255. package/dist/es/platform/measure.js +18 -36
  256. package/dist/es/utils/color.js +21 -35
  257. package/dist/es/utils/compare.js +7 -12
  258. package/dist/es/utils/createPlatformShadow.js +28 -39
  259. package/dist/es/utils/date.js +20 -50
  260. package/dist/es/utils/deepMerge.js +16 -26
  261. package/dist/es/utils/hairline.js +73 -65
  262. package/dist/es/utils/index.js +2 -0
  263. package/dist/es/utils/number.js +21 -29
  264. package/dist/es/utils/render.js +7 -0
  265. package/dist/es/utils/rtl.js +17 -0
  266. package/dist/es/utils/string.js +8 -25
  267. package/dist/types/components/action-sheet/ActionSheet.d.ts +1 -1
  268. package/dist/types/components/area/Area.d.ts +1 -1
  269. package/dist/types/components/area/tokens.d.ts +4 -0
  270. package/dist/types/components/avatar/Avatar.d.ts +1 -1
  271. package/dist/types/components/avatar/index.d.ts +1 -2
  272. package/dist/types/components/badge/Badge.d.ts +1 -1
  273. package/dist/types/components/button/Button.d.ts +1 -1
  274. package/dist/types/components/button/index.d.ts +1 -1
  275. package/dist/types/components/calendar/Calendar.d.ts +1 -1
  276. package/dist/types/components/cascader/Cascader.d.ts +1 -1
  277. package/dist/types/components/cell/Cell.d.ts +1 -1
  278. package/dist/types/components/cell/CellGroup.d.ts +1 -1
  279. package/dist/types/components/cell/index.d.ts +2 -2
  280. package/dist/types/components/checkbox/Checkbox.d.ts +1 -1
  281. package/dist/types/components/circle/Circle.d.ts +1 -1
  282. package/dist/types/components/collapse/Collapse.d.ts +1 -2
  283. package/dist/types/components/config-provider/DirectionContext.d.ts +3 -0
  284. package/dist/types/components/config-provider/index.d.ts +2 -1
  285. package/dist/types/components/config-provider/locale/en-US.d.ts +32 -0
  286. package/dist/types/components/config-provider/locale/zh-CN.d.ts +32 -0
  287. package/dist/types/components/config-provider/useDirection.d.ts +1 -0
  288. package/dist/types/components/count-down/CountDown.d.ts +1 -1
  289. package/dist/types/components/datetime-picker/DatetimePicker.d.ts +1 -1
  290. package/dist/types/components/datetime-picker/tokens.d.ts +12 -0
  291. package/dist/types/components/dialog/Dialog.d.ts +1 -1
  292. package/dist/types/components/divider/Divider.d.ts +1 -1
  293. package/dist/types/components/empty/Empty.d.ts +1 -1
  294. package/dist/types/components/error-boundary/ErrorBoundary.d.ts +6 -0
  295. package/dist/types/components/error-boundary/index.d.ts +2 -0
  296. package/dist/types/components/field/Field.d.ts +1 -1
  297. package/dist/types/components/flex/Flex.d.ts +1 -1
  298. package/dist/types/components/flex/FlexItem.d.ts +1 -1
  299. package/dist/types/components/flex/index.d.ts +2 -2
  300. package/dist/types/components/form/Form.d.ts +1 -1
  301. package/dist/types/components/form/FormItem.d.ts +2 -1
  302. package/dist/types/components/form/index.d.ts +2 -2
  303. package/dist/types/components/form/tokens.d.ts +4 -0
  304. package/dist/types/components/grid/Grid.d.ts +1 -1
  305. package/dist/types/components/grid/GridItem.d.ts +1 -1
  306. package/dist/types/components/grid/index.d.ts +2 -2
  307. package/dist/types/components/image/Image.d.ts +1 -1
  308. package/dist/types/components/image-preview/ImagePreview.d.ts +1 -1
  309. package/dist/types/components/index.d.ts +4 -1
  310. package/dist/types/components/input/Input.d.ts +3 -3
  311. package/dist/types/components/loading/Loading.d.ts +1 -1
  312. package/dist/types/components/nav-bar/NavBar.d.ts +1 -1
  313. package/dist/types/components/notice-bar/NoticeBar.d.ts +1 -1
  314. package/dist/types/components/notify/Notify.d.ts +2 -2
  315. package/dist/types/components/notify/index.d.ts +1 -1
  316. package/dist/types/components/overlay/Overlay.d.ts +1 -5
  317. package/dist/types/components/overlay/tokens.d.ts +3 -0
  318. package/dist/types/components/password-input/PasswordInput.d.ts +1 -1
  319. package/dist/types/components/picker/Picker.d.ts +5 -5
  320. package/dist/types/components/popup/Popup.d.ts +3 -42
  321. package/dist/types/components/portal/Portal.d.ts +9 -6
  322. package/dist/types/components/portal/PortalHost.d.ts +1 -1
  323. package/dist/types/components/radio/RadioGroup.d.ts +1 -1
  324. package/dist/types/components/safe-area-view/SafeAreaView.d.ts +1 -1
  325. package/dist/types/components/search/Search.d.ts +1 -1
  326. package/dist/types/components/share-sheet/ShareSheet.d.ts +1 -1
  327. package/dist/types/components/sidebar/Sidebar.d.ts +1 -1
  328. package/dist/types/components/sidebar/SidebarContext.d.ts +1 -1
  329. package/dist/types/components/sidebar/SidebarItem.d.ts +1 -1
  330. package/dist/types/components/sidebar/index.d.ts +2 -2
  331. package/dist/types/components/skeleton/Skeleton.d.ts +1 -1
  332. package/dist/types/components/slider/Slider.d.ts +1 -1
  333. package/dist/types/components/stepper/Stepper.d.ts +1 -1
  334. package/dist/types/components/swiper/Swiper.d.ts +1 -1
  335. package/dist/types/components/swiper/index.d.ts +1 -1
  336. package/dist/types/components/swiper/tokens.d.ts +8 -0
  337. package/dist/types/components/tabbar/Tabbar.d.ts +2 -2
  338. package/dist/types/components/tabbar/TabbarContext.d.ts +1 -1
  339. package/dist/types/components/tabbar/TabbarItem.d.ts +2 -2
  340. package/dist/types/components/tabs/Tabs.d.ts +1 -1
  341. package/dist/types/components/tabs/index.d.ts +1 -1
  342. package/dist/types/components/tag/Tag.d.ts +1 -1
  343. package/dist/types/components/toast/Toast.d.ts +2 -2
  344. package/dist/types/components/toast/index.d.ts +1 -1
  345. package/dist/types/components/water-mark/WaterMark.d.ts +1 -1
  346. package/dist/types/design-system/tokens.d.ts +0 -1
  347. package/dist/types/hooks/animation/index.d.ts +3 -0
  348. package/dist/types/hooks/animation/useAnimatedTransition.d.ts +13 -0
  349. package/dist/types/hooks/animation/useReducedMotion.d.ts +3 -0
  350. package/dist/types/hooks/aria/useAriaOverlay.d.ts +1 -1
  351. package/dist/types/hooks/gesture/useGestureScroll.d.ts +11 -10
  352. package/dist/types/hooks/index.d.ts +1 -0
  353. package/dist/types/hooks/overlay/OverlayStackStore.d.ts +8 -8
  354. package/dist/types/hooks/useHairline.d.ts +1 -1
  355. package/dist/types/index.d.ts +5 -0
  356. package/dist/types/platform/animation.d.ts +8 -0
  357. package/dist/types/platform/measure.d.ts +1 -1
  358. package/dist/types/utils/compare.d.ts +1 -1
  359. package/dist/types/utils/createPlatformShadow.d.ts +2 -2
  360. package/dist/types/utils/date.d.ts +2 -2
  361. package/dist/types/utils/hairline.d.ts +5 -10
  362. package/dist/types/utils/index.d.ts +2 -0
  363. package/dist/types/utils/number.d.ts +2 -2
  364. package/dist/types/utils/render.d.ts +5 -0
  365. package/dist/types/utils/rtl.d.ts +5 -0
  366. package/package.json +9 -2
@@ -17,7 +17,7 @@ const createCalendarTokens = foundations => {
17
17
  return {
18
18
  defaults: {
19
19
  type: "single",
20
- title: "选择日期",
20
+ title: "Select Date",
21
21
  showSubtitle: true,
22
22
  showHeader: true,
23
23
  showConfirm: {
@@ -25,9 +25,9 @@ const createCalendarTokens = foundations => {
25
25
  range: true,
26
26
  multiple: true
27
27
  },
28
- confirmText: "确定",
28
+ confirmText: "Confirm",
29
29
  weekStartsOn: 0,
30
- weekdays: ["", "", "", "", "", "", ""],
30
+ weekdays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
31
31
  allowSameDay: false,
32
32
  poppable: false,
33
33
  closeOnClickOverlay: true,
@@ -30,6 +30,7 @@ var _utils = require("../../utils");
30
30
  var _validate = require("../../utils/validate");
31
31
  var _popup = _interopRequireDefault(require("../popup"));
32
32
  var _tabs = _interopRequireDefault(require("../tabs"));
33
+ var _useLocale = require("../config-provider/useLocale");
33
34
  var _tokens = require("./tokens");
34
35
  var _useCascaderExtend = require("./useCascaderExtend");
35
36
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -40,29 +41,29 @@ const getFieldKeys = fieldNames => ({
40
41
  valueKey: fieldNames?.value ?? "value",
41
42
  childrenKey: fieldNames?.children ?? "children"
42
43
  });
43
- const resolveSelectedRows = (options = [], keys, value) => {
44
+ const resolveRows = (options = [], keys, values) => {
44
45
  const selected = [];
45
46
  let current = options;
46
- value.forEach(val => {
47
+ values.forEach(val => {
47
48
  if (!current || !current.length) return;
48
- const match = current.find(option => option[keys.valueKey] === val);
49
- if (match) {
50
- selected.push(match);
51
- current = match[keys.childrenKey] ?? [];
49
+ const matched = current.find(o => o[keys.valueKey] === val);
50
+ if (matched) {
51
+ selected.push(matched);
52
+ current = matched[keys.childrenKey] ?? [];
52
53
  }
53
54
  });
54
55
  return selected;
55
56
  };
56
- const Cascader = props => {
57
+ const CascaderImpl = props => {
57
58
  const {
58
59
  tokensOverride,
59
60
  options = [],
60
- title: titleProp,
61
- placeholder: placeholderProp,
62
- activeColor: activeColorProp,
61
+ title,
62
+ placeholder,
63
+ activeColor,
63
64
  fieldNames,
64
65
  optionRender,
65
- showHeader: showHeaderProp,
66
+ showHeader,
66
67
  closeable,
67
68
  closeIcon,
68
69
  onChange,
@@ -70,54 +71,55 @@ const Cascader = props => {
70
71
  onFinish,
71
72
  onClickTab,
72
73
  onTabChange,
73
- swipeable: swipeableProp,
74
+ swipeable,
74
75
  style,
75
76
  testID,
76
77
  children,
77
- poppable: poppableProp,
78
+ poppable,
78
79
  visible: _visible,
79
80
  defaultVisible: _defaultVisible,
80
81
  onVisibleChange: _onVisibleChange,
81
- closeOnClickOverlay: closeOnClickOverlayProp,
82
- closeOnFinish: closeOnFinishProp,
83
- popupPlacement: popupPlacementProp,
84
- popupRound: popupRoundProp,
85
- popupProps: popupPropsOverrides,
86
- loadingText: loadingTextProp,
82
+ closeOnClickOverlay,
83
+ closeOnFinish,
84
+ popupPlacement,
85
+ popupRound,
86
+ popupProps,
87
+ loadingText,
87
88
  ...rest
88
89
  } = props;
90
+ const locale = (0, _useLocale.useLocale)();
89
91
  const tokens = (0, _tokens.useCascaderTokens)(tokensOverride);
90
- const title = titleProp ?? tokens.defaults.title;
91
- const placeholder = placeholderProp ?? tokens.defaults.placeholder;
92
- const activeColor = activeColorProp ?? tokens.colors.tabActive;
93
- const showHeader = showHeaderProp ?? tokens.defaults.showHeader;
94
- const swipeable = swipeableProp ?? tokens.defaults.swipeable;
95
- const poppable = poppableProp ?? tokens.defaults.poppable;
96
- const closeOnClickOverlay = closeOnClickOverlayProp ?? tokens.defaults.closeOnClickOverlay;
97
- const closeOnFinish = closeOnFinishProp ?? tokens.defaults.closeOnFinish;
98
- const popupPlacement = popupPlacementProp ?? tokens.defaults.popupPlacement;
99
- const popupRound = popupRoundProp ?? tokens.defaults.popupRound;
100
- const loadingText = loadingTextProp ?? tokens.defaults.loadingText;
92
+ const resolvedTitle = title ?? locale?.vanCascader?.placeholder ?? tokens.defaults.title;
93
+ const resolvedPlaceholder = placeholder ?? locale?.vanCascader?.placeholder ?? tokens.defaults.placeholder;
94
+ const resolvedActiveColor = activeColor ?? tokens.colors.tabActive;
95
+ const resolvedShowHeader = showHeader ?? tokens.defaults.showHeader;
96
+ const resolvedSwipeable = swipeable ?? tokens.defaults.swipeable;
97
+ const resolvedPoppable = poppable ?? tokens.defaults.poppable;
98
+ const resolvedCloseOnClickOverlay = closeOnClickOverlay ?? tokens.defaults.closeOnClickOverlay;
99
+ const resolvedCloseOnFinish = closeOnFinish ?? tokens.defaults.closeOnFinish;
100
+ const resolvedPopupPlacement = popupPlacement ?? tokens.defaults.popupPlacement;
101
+ const resolvedPopupRound = popupRound ?? tokens.defaults.popupRound;
102
+ const resolvedLoadingText = loadingText ?? tokens.defaults.loadingText;
101
103
  const [value, setValue] = (0, _hooks.useControllableValue)(props, {
102
104
  defaultValue: [],
103
105
  trigger: "onChange"
104
106
  });
105
107
  const keys = getFieldKeys(fieldNames);
106
- const cascaderValue = Array.isArray(value) ? value : [];
107
- const [panelValue, setPanelValue] = (0, _react().useState)(cascaderValue);
108
- const resolvedCloseable = closeable ?? tokens.defaults.closeable;
108
+ const currentValue = Array.isArray(value) ? value : [];
109
+ const [pendingValue, setPendingValue] = (0, _react().useState)(currentValue);
110
+ const showClose = closeable ?? tokens.defaults.closeable;
109
111
  const [popupVisible, setPopupVisible] = (0, _hooks.useControllableValue)(props, {
110
112
  defaultValue: false,
111
113
  valuePropName: "visible",
112
114
  defaultValuePropName: "defaultVisible",
113
115
  trigger: "onVisibleChange"
114
116
  });
115
- const currentValue = poppable ? panelValue : cascaderValue;
117
+ const current = resolvedPoppable ? pendingValue : currentValue;
116
118
  const {
117
119
  tabs,
118
120
  items,
119
121
  depth
120
- } = (0, _useCascaderExtend.useCascaderExtend)(options, keys, currentValue);
122
+ } = (0, _useCascaderExtend.useCascaderExtend)(options, keys, current);
121
123
  const {
122
124
  width: windowWidth
123
125
  } = (0, _reactNative().useWindowDimensions)();
@@ -127,105 +129,105 @@ const Cascader = props => {
127
129
  if (!width) return;
128
130
  setMeasuredWidth(prev => prev === width ? prev : width);
129
131
  }, []);
130
- const confirmedRows = resolveSelectedRows(options, keys, cascaderValue);
132
+ const currentRows = resolveRows(options, keys, currentValue);
131
133
  const [activeTab, setActiveTab] = (0, _react().useState)(0);
132
134
  (0, _react().useEffect)(() => {
133
- const currentLength = Array.isArray(currentValue) ? currentValue.length : 0;
135
+ const currentLength = Array.isArray(current) ? current.length : 0;
134
136
  let tabIndex = currentLength;
135
137
  if (tabIndex >= depth) tabIndex = Math.max(depth - 1, 0);
136
138
  setActiveTab(prev => prev === tabIndex ? prev : tabIndex);
137
- }, [currentValue.length, depth]);
139
+ }, [current.length, depth]);
138
140
  (0, _react().useEffect)(() => {
139
- if (!poppable) {
140
- setPanelValue(prev => (0, _utils.shallowEqualArray)(prev, cascaderValue) ? prev : cascaderValue);
141
- return;
142
- }
143
- if (!popupVisible) {
144
- setPanelValue(prev => (0, _utils.shallowEqualArray)(prev, cascaderValue) ? prev : cascaderValue);
145
- }
146
- }, [cascaderValue, poppable, popupVisible]);
141
+ if (!resolvedPoppable || !popupVisible) setPendingValue(prev => (0, _utils.shallowEqualArray)(prev, currentValue) ? prev : currentValue);
142
+ }, [currentValue, resolvedPoppable, popupVisible]);
147
143
  const openPopup = (0, _react().useCallback)(() => {
148
- if (!poppable || popupVisible) return;
149
- setPanelValue(prev => (0, _utils.shallowEqualArray)(prev, cascaderValue) ? prev : cascaderValue);
144
+ if (!resolvedPoppable || popupVisible) return;
145
+ setPendingValue(prev => (0, _utils.shallowEqualArray)(prev, currentValue) ? prev : currentValue);
150
146
  setPopupVisible(true);
151
- }, [cascaderValue, poppable, popupVisible, setPopupVisible]);
147
+ }, [currentValue, resolvedPoppable, popupVisible, setPopupVisible]);
148
+ const onCloseRef = (0, _react().useRef)(onClose),
149
+ onChangeRef = (0, _react().useRef)(onChange),
150
+ onFinishRef = (0, _react().useRef)(onFinish),
151
+ onClickTabRef = (0, _react().useRef)(onClickTab),
152
+ onTabChangeRef = (0, _react().useRef)(onTabChange);
153
+ onCloseRef.current = onClose;
154
+ onChangeRef.current = onChange;
155
+ onFinishRef.current = onFinish;
156
+ onClickTabRef.current = onClickTab;
157
+ onTabChangeRef.current = onTabChange;
152
158
  const closePopup = (0, _react().useCallback)(notify => {
153
- if (!poppable || !popupVisible) return;
159
+ if (!resolvedPoppable || !popupVisible) return;
154
160
  setPopupVisible(false);
155
- if (notify) onClose?.();
156
- }, [onClose, poppable, popupVisible, setPopupVisible]);
161
+ if (notify) onCloseRef.current?.();
162
+ }, [resolvedPoppable, popupVisible, setPopupVisible]);
157
163
  const togglePopup = (0, _react().useCallback)(() => {
158
- if (!poppable) return;
164
+ if (!resolvedPoppable) return;
159
165
  popupVisible ? closePopup(true) : openPopup();
160
- }, [closePopup, openPopup, poppable, popupVisible]);
161
- const isRenderProp = (0, _validate.isFunction)(children);
162
- const renderProp = isRenderProp ? children : null;
163
- const handleClickTab = (0, _react().useCallback)(event => {
164
- const index = (0, _validate.isNumber)(event.index) ? event.index : Number(event.name);
166
+ }, [closePopup, openPopup, resolvedPoppable, popupVisible]);
167
+ const isRenderProps = (0, _validate.isFunction)(children);
168
+ const renderProps = isRenderProps ? children : null;
169
+ const handleClickTab = (0, _react().useCallback)(e => {
170
+ const index = (0, _validate.isNumber)(e.index) ? e.index : Number(e.name);
165
171
  if (Number.isNaN(index)) return;
166
- const titleNode = items[index]?.[keys.textKey];
167
- const titleText = (0, _validate.isText)(titleNode) ? String(titleNode) : placeholder;
168
- onClickTab?.(index, titleText);
169
- }, [items, keys.textKey, onClickTab, placeholder]);
170
- const handleTabChange = (0, _react().useCallback)((tabValue, indexFromEvent) => {
171
- const index = (0, _validate.isNumber)(indexFromEvent) ? indexFromEvent : Number(tabValue);
172
+ const tabName = items[index]?.[keys.textKey];
173
+ const tabText = (0, _validate.isText)(tabName) ? String(tabName) : resolvedPlaceholder;
174
+ onClickTabRef.current?.(index, tabText);
175
+ }, [items, keys.textKey, resolvedPlaceholder]);
176
+ const handleTabChange = (0, _react().useCallback)((tabValue, indexExplicit) => {
177
+ const index = (0, _validate.isNumber)(indexExplicit) ? indexExplicit : Number(tabValue);
172
178
  if (Number.isNaN(index)) return;
173
179
  setActiveTab(index);
174
- onTabChange?.(index);
175
- }, [onTabChange]);
180
+ onTabChangeRef.current?.(index);
181
+ }, []);
176
182
  const handleSelect = (0, _react().useCallback)((option, tabIndex) => {
177
183
  if (option.disabled) return;
178
184
  const optionValue = option[keys.valueKey];
179
- if (optionValue === undefined || optionValue === null) return;
180
- const base = (poppable ? panelValue : cascaderValue).slice(0, tabIndex);
185
+ if (optionValue == null) return;
186
+ const base = (resolvedPoppable ? pendingValue : currentValue).slice(0, tabIndex);
181
187
  const nextValue = [...base, optionValue];
182
- const rows = resolveSelectedRows(options, keys, nextValue);
183
- const childrenOptions = option[keys.childrenKey] ?? [];
188
+ const rows = resolveRows(options, keys, nextValue);
189
+ const children = option[keys.childrenKey] ?? [];
184
190
  const hasChildrenProp = Object.prototype.hasOwnProperty.call(option, keys.childrenKey);
185
- const hasChildren = childrenOptions.length > 0;
186
- const asyncBranch = hasChildrenProp && !hasChildren;
187
- const reachDepth = nextValue.length >= depth;
188
- const isLeaf = !hasChildren && !asyncBranch;
189
- if (poppable) {
190
- setPanelValue(nextValue);
191
- onChange?.(nextValue, rows);
192
- } else {
193
- setValue(nextValue, rows);
194
- }
195
- if (isLeaf || reachDepth) {
196
- if (poppable) {
191
+ const hasChildren = children.length > 0;
192
+ const isAsync = hasChildrenProp && !hasChildren;
193
+ const reachedDepth = nextValue.length >= depth;
194
+ const isLeaf = !hasChildren && !isAsync;
195
+ if (resolvedPoppable) {
196
+ setPendingValue(nextValue);
197
+ onChangeRef.current?.(nextValue, rows);
198
+ } else setValue(nextValue, rows);
199
+ if (isLeaf || reachedDepth) {
200
+ if (resolvedPoppable) {
197
201
  setValue(nextValue, rows);
198
- if (closeOnFinish) closePopup(true);
202
+ if (resolvedCloseOnFinish) closePopup(true);
199
203
  }
200
- onFinish?.(nextValue, rows);
204
+ onFinishRef.current?.(nextValue, rows);
201
205
  }
202
- }, [cascaderValue, closeOnFinish, closePopup, depth, keys, onChange, onFinish, options, panelValue, poppable, setValue]);
206
+ }, [currentValue, resolvedCloseOnFinish, closePopup, depth, keys, options, pendingValue, resolvedPoppable, setValue]);
203
207
  const getEmptyText = (0, _react().useCallback)(tabIndex => {
204
- if (tabIndex <= 0) return placeholder;
208
+ if (tabIndex <= 0) return resolvedPlaceholder;
205
209
  const parent = items[tabIndex - 1];
206
- if (!parent) return placeholder;
210
+ if (!parent) return resolvedPlaceholder;
207
211
  const hasChildrenProp = Object.prototype.hasOwnProperty.call(parent, keys.childrenKey);
208
- if (!hasChildrenProp) return placeholder;
212
+ if (!hasChildrenProp) return resolvedPlaceholder;
209
213
  const children = parent[keys.childrenKey] ?? [];
210
- const asyncBranch = children.length === 0 && currentValue.length === tabIndex;
211
- return asyncBranch ? loadingText : placeholder;
212
- }, [currentValue.length, items, keys.childrenKey, loadingText, placeholder]);
214
+ const isAsync = children.length === 0 && current.length === tabIndex;
215
+ return isAsync ? resolvedLoadingText : resolvedPlaceholder;
216
+ }, [current.length, items, keys.childrenKey, resolvedLoadingText, resolvedPlaceholder]);
213
217
  const renderTabs = () => {
214
- if (!tabs.length) {
215
- return /*#__PURE__*/_react().default.createElement(CascaderOptionList, {
216
- optionList: [],
217
- tabIndex: 0,
218
- selectedValue: currentValue[0],
219
- activeColor: activeColor,
220
- keys: keys,
221
- optionRender: optionRender,
222
- onSelect: handleSelect,
223
- tokens: tokens,
224
- emptyText: getEmptyText(0)
225
- });
226
- }
227
- const swipeableEnabled = !!swipeable;
228
- const resolvedTabsWidth = measuredWidth || windowWidth || undefined;
218
+ if (!tabs.length) return /*#__PURE__*/_react().default.createElement(CascaderOptionList, {
219
+ optionList: [],
220
+ tabIndex: 0,
221
+ selectedValue: current[0],
222
+ activeColor: resolvedActiveColor,
223
+ keys: keys,
224
+ optionRender: optionRender,
225
+ onSelect: handleSelect,
226
+ tokens: tokens,
227
+ emptyText: getEmptyText(0)
228
+ });
229
+ const swipeEnabled = !!resolvedSwipeable;
230
+ const renderTabsWidth = measuredWidth || windowWidth || undefined;
229
231
  const tabBarStyle = {
230
232
  height: tokens.sizing.headerHeight,
231
233
  paddingHorizontal: tokens.spacing.tabNavPaddingHorizontal,
@@ -236,19 +238,19 @@ const Cascader = props => {
236
238
  style: tokens.layout.tabsWrapper,
237
239
  onLayout: handleTabsLayout
238
240
  }, /*#__PURE__*/_react().default.createElement(_tabs.default, {
239
- style: resolvedTabsWidth ? {
240
- width: resolvedTabsWidth
241
+ style: renderTabsWidth ? {
242
+ width: renderTabsWidth
241
243
  } : undefined,
242
244
  active: activeTab,
243
245
  onChange: handleTabChange,
244
246
  onClickTab: handleClickTab,
245
247
  align: "center",
246
- swipeable: swipeableEnabled,
248
+ swipeable: swipeEnabled,
247
249
  swipeThreshold: 0,
248
250
  scrollable: true,
249
251
  animated: true,
250
252
  duration: 300,
251
- color: activeColor,
253
+ color: resolvedActiveColor,
252
254
  lineHeight: tokens.sizing.indicatorHeight,
253
255
  titleActiveColor: tokens.colors.tabText,
254
256
  titleInactiveColor: tokens.colors.tabInactive,
@@ -259,66 +261,60 @@ const Cascader = props => {
259
261
  titleStyle: [tokens.layout.tabsTitle, {
260
262
  fontSize: tokens.typography.tabsTitleSize
261
263
  }],
262
- contentStyle: !swipeableEnabled ? tokens.layout.tabsContentStatic : undefined
263
- }, tabs.map((optionList, index) => {
264
- const selectedOption = items[index];
264
+ contentStyle: !swipeEnabled ? tokens.layout.tabsContentStatic : undefined
265
+ }, tabs.map((optionList, i) => {
266
+ const selectedOption = items[i];
265
267
  const labelValue = selectedOption?.[keys.textKey];
266
- const labelText = (0, _validate.isText)(labelValue) ? String(labelValue) : "";
267
- const unselected = !labelText;
268
- const titleNode = _active => /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
268
+ const label = (0, _validate.isText)(labelValue) ? String(labelValue) : "";
269
+ const usePlaceholder = !label;
270
+ const titleNode = _ => /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
269
271
  style: [tokens.layout.tabTitleNode, {
270
- color: unselected ? tokens.colors.tabInactive : tokens.colors.tabText,
271
- fontWeight: unselected ? tokens.typography.tabTitlePlaceholderWeight : tokens.typography.tabTitleWeight
272
+ color: usePlaceholder ? tokens.colors.tabInactive : tokens.colors.tabText,
273
+ fontWeight: usePlaceholder ? tokens.typography.tabTitlePlaceholderWeight : tokens.typography.tabTitleWeight
272
274
  }]
273
- }, unselected ? placeholder : labelText);
275
+ }, usePlaceholder ? resolvedPlaceholder : label);
274
276
  return /*#__PURE__*/_react().default.createElement(_tabs.default.TabPane, {
275
- key: index,
276
- name: index,
277
+ key: i,
278
+ name: i,
277
279
  title: titleNode
278
280
  }, /*#__PURE__*/_react().default.createElement(CascaderOptionList, {
279
281
  optionList: optionList,
280
- tabIndex: index,
281
- selectedValue: currentValue[index],
282
- activeColor: activeColor,
282
+ tabIndex: i,
283
+ selectedValue: current[i],
284
+ activeColor: resolvedActiveColor,
283
285
  keys: keys,
284
286
  optionRender: optionRender,
285
287
  onSelect: handleSelect,
286
288
  tokens: tokens,
287
- emptyText: getEmptyText(index)
289
+ emptyText: getEmptyText(i)
288
290
  }));
289
291
  })));
290
292
  };
291
- const inlineChildren = !poppable && !isRenderProp ? children : null;
293
+ const inlineChildren = !resolvedPoppable && !isRenderProps ? children : null;
292
294
  const content = /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({
293
295
  testID: testID,
294
296
  style: [tokens.layout.container, {
295
297
  backgroundColor: tokens.colors.background
296
298
  }, style]
297
- }, rest), showHeader ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
299
+ }, rest), resolvedShowHeader ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
298
300
  style: [tokens.layout.header, {
299
301
  height: tokens.sizing.headerHeight,
300
302
  paddingHorizontal: tokens.spacing.headerPaddingHorizontal
301
303
  }]
302
- }, (0, _validate.isText)(title) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
303
- style: [tokens.layout.title, {
304
- color: tokens.colors.headerText,
305
- fontSize: tokens.typography.titleSize,
306
- fontWeight: tokens.typography.titleWeight
307
- }]
308
- }, title) : title, resolvedCloseable ? /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
304
+ }, (0, _utils.renderTextOrNode)(resolvedTitle, [tokens.layout.title, {
305
+ color: tokens.colors.headerText,
306
+ fontSize: tokens.typography.titleSize,
307
+ fontWeight: tokens.typography.titleWeight
308
+ }]), showClose ? /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
309
309
  hitSlop: 8,
310
310
  onPress: () => {
311
- if (poppable) {
312
- closePopup(true);
313
- } else {
314
- onClose?.();
315
- }
311
+ if (resolvedPoppable) closePopup(true);else onCloseRef.current?.();
316
312
  },
317
313
  style: [tokens.layout.closeButton, {
318
314
  marginLeft: tokens.spacing.closeButtonMarginLeft
319
315
  }],
320
316
  accessibilityRole: "button",
321
- accessibilityLabel: "\u5173\u95ED"
317
+ accessibilityLabel: locale?.vanCascader?.close ?? 'Close'
322
318
  }, closeIcon ?? (state => /*#__PURE__*/_react().default.createElement(_reactNativeSystemIcon().Cross, {
323
319
  size: tokens.sizing.closeIconSize,
324
320
  fill: state.pressed ? tokens.colors.closeIconActive : tokens.colors.closeIcon,
@@ -329,19 +325,25 @@ const Cascader = props => {
329
325
  paddingHorizontal: tokens.spacing.headerPaddingHorizontal
330
326
  }]
331
327
  }, inlineChildren) : null);
332
- if (!poppable) return content;
328
+ if (!resolvedPoppable) return content;
333
329
  const {
334
- closeOnOverlayPress: overrideCloseOnOverlayPress,
330
+ closeOnOverlayPress: overlayCloseOnPress,
335
331
  overlay: popupOverlay,
336
332
  onOpen: popupOnOpen,
337
333
  onOpened: popupOnOpened,
338
334
  onClose: popupOnClose,
339
335
  onClosed: popupOnClosed,
340
336
  ...popupRestProps
341
- } = popupPropsOverrides ?? {};
342
- const resolvedOverlay = popupOverlay ?? true;
343
- const resolvedCloseOnOverlayPress = overrideCloseOnOverlayPress ?? closeOnClickOverlay;
344
- const cascaderActions = {
337
+ } = popupProps ?? {};
338
+ const renderOverlay = popupOverlay ?? true;
339
+ const renderCloseOnPress = overlayCloseOnPress ?? resolvedCloseOnClickOverlay;
340
+ const popupOnCloseRef = (0, _react().useRef)(popupOnClose);
341
+ popupOnCloseRef.current = popupOnClose;
342
+ const handlePopupClose = (0, _react().useCallback)(() => {
343
+ popupOnCloseRef.current?.();
344
+ closePopup(true);
345
+ }, [closePopup]);
346
+ const controlActions = {
345
347
  open: openPopup,
346
348
  close: () => closePopup(true),
347
349
  toggle: togglePopup
@@ -359,22 +361,19 @@ const Cascader = props => {
359
361
  onClick: handlePress
360
362
  });
361
363
  }, [openPopup]);
362
- const triggerNode = renderProp ? renderProp(cascaderValue, confirmedRows, cascaderActions) : isRenderProp ? null : children || null;
363
- const resolvedTriggerNode = enhanceTriggerNode(triggerNode);
364
- return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, resolvedTriggerNode, /*#__PURE__*/_react().default.createElement(_popup.default, _extends({
364
+ const triggerNode = renderProps ? renderProps(currentValue, currentRows, controlActions) : isRenderProps ? null : children || null;
365
+ const renderTriggerNode = enhanceTriggerNode(triggerNode);
366
+ return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, renderTriggerNode, /*#__PURE__*/_react().default.createElement(_popup.default, _extends({
365
367
  visible: popupVisible,
366
- placement: popupPlacement,
367
- round: popupRound,
368
- closeOnOverlayPress: resolvedCloseOnOverlayPress,
369
- overlay: resolvedOverlay,
370
- safeAreaInsetTop: popupRestProps?.safeAreaInsetTop !== undefined ? popupRestProps.safeAreaInsetTop : showHeader && resolvedCloseable,
371
- safeAreaInsetBottom: popupRestProps?.safeAreaInsetBottom !== undefined ? popupRestProps.safeAreaInsetBottom : popupPlacement === 'bottom',
368
+ placement: resolvedPopupPlacement,
369
+ round: resolvedPopupRound,
370
+ closeOnOverlayPress: renderCloseOnPress,
371
+ overlay: renderOverlay,
372
+ safeAreaInsetTop: popupRestProps?.safeAreaInsetTop != null ? popupRestProps.safeAreaInsetTop : resolvedShowHeader && showClose,
373
+ safeAreaInsetBottom: popupRestProps?.safeAreaInsetBottom != null ? popupRestProps.safeAreaInsetBottom : resolvedPopupPlacement === 'bottom',
372
374
  onOpen: popupOnOpen,
373
375
  onOpened: popupOnOpened,
374
- onClose: () => {
375
- popupOnClose?.();
376
- closePopup(true);
377
- },
376
+ onClose: handlePopupClose,
378
377
  onClosed: popupOnClosed
379
378
  }, popupRestProps, {
380
379
  style: {
@@ -398,17 +397,16 @@ const CascaderOptionItem = /*#__PURE__*/_react().default.memo(({
398
397
  const disabled = !!option.disabled;
399
398
  const baseColor = option.color ?? tokens.colors.optionText;
400
399
  const textColor = disabled ? tokens.colors.optionDisabled : selected ? option.color ?? activeColor : baseColor;
400
+ const optionTextStyle = [tokens.layout.optionText, {
401
+ color: textColor,
402
+ fontSize: tokens.typography.optionTextSize
403
+ }, selected ? {
404
+ fontWeight: tokens.typography.optionTextActiveWeight
405
+ } : null];
401
406
  const content = optionRender ? optionRender({
402
407
  option,
403
408
  selected
404
- }) : (0, _validate.isText)(label) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
405
- style: [tokens.layout.optionText, {
406
- color: textColor,
407
- fontSize: tokens.typography.optionTextSize
408
- }, selected && {
409
- fontWeight: tokens.typography.optionTextActiveWeight
410
- }]
411
- }, label) : (0, _validate.isRenderable)(label) ? label : null;
409
+ }) : (0, _utils.renderTextOrNode)(label, optionTextStyle);
412
410
  return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
413
411
  testID: `cascader-option-${tabIndex}-${String(optionValue)}`,
414
412
  style: ({
@@ -445,19 +443,6 @@ const CascaderOptionList = /*#__PURE__*/_react().default.memo(({
445
443
  tokens,
446
444
  emptyText
447
445
  }) => {
448
- if (!optionList.length) {
449
- return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
450
- style: [tokens.layout.optionList, {
451
- height: tokens.sizing.optionListHeight
452
- }]
453
- }, /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
454
- style: [tokens.layout.empty, {
455
- color: tokens.colors.placeholder,
456
- paddingVertical: tokens.spacing.emptyPaddingVertical,
457
- fontSize: tokens.typography.emptyTextSize
458
- }]
459
- }, emptyText));
460
- }
461
446
  const renderItem = (0, _react().useCallback)(({
462
447
  item
463
448
  }) => /*#__PURE__*/_react().default.createElement(CascaderOptionItem, {
@@ -471,6 +456,17 @@ const CascaderOptionList = /*#__PURE__*/_react().default.memo(({
471
456
  tokens: tokens
472
457
  }), [activeColor, keys, onSelect, optionRender, selectedValue, tabIndex, tokens]);
473
458
  const keyExtractor = (0, _react().useCallback)(item => String(item[keys.valueKey]), [keys.valueKey]);
459
+ if (!optionList.length) return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
460
+ style: [tokens.layout.optionList, {
461
+ height: tokens.sizing.optionListHeight
462
+ }]
463
+ }, /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
464
+ style: [tokens.layout.empty, {
465
+ color: tokens.colors.placeholder,
466
+ paddingVertical: tokens.spacing.emptyPaddingVertical,
467
+ fontSize: tokens.typography.emptyTextSize
468
+ }]
469
+ }, emptyText));
474
470
  return /*#__PURE__*/_react().default.createElement(_reactNative().FlatList, {
475
471
  data: optionList,
476
472
  style: [tokens.layout.optionList, {
@@ -488,4 +484,5 @@ const CascaderOptionList = /*#__PURE__*/_react().default.memo(({
488
484
  windowSize: 5
489
485
  });
490
486
  });
487
+ const Cascader = /*#__PURE__*/_react().default.memo(CascaderImpl);
491
488
  var _default = exports.default = Cascader;
@@ -12,7 +12,7 @@ const createCascaderTokens = foundations => {
12
12
  radii
13
13
  } = foundations;
14
14
  const surfaceMuted = palette.default[100];
15
- const placeholderText = "请选择";
15
+ const placeholderText = "Select";
16
16
  return {
17
17
  defaults: {
18
18
  placeholder: placeholderText,
@@ -25,7 +25,7 @@ const createCascaderTokens = foundations => {
25
25
  closeOnFinish: true,
26
26
  popupPlacement: "bottom",
27
27
  popupRound: true,
28
- loadingText: "加载中..."
28
+ loadingText: "Loading..."
29
29
  },
30
30
  layout: {
31
31
  container: {
@@ -4,36 +4,32 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useCascaderExtend = void 0;
7
+ const getDepth = (options, childrenKey) => {
8
+ let max = 1;
9
+ const traverse = (opts, level) => {
10
+ if (!opts?.length) return;
11
+ if (level > max) max = level;
12
+ opts.forEach(o => {
13
+ const has = Object.prototype.hasOwnProperty.call(o, childrenKey);
14
+ if (has && level + 1 > max) max = level + 1;
15
+ const ch = o[childrenKey];
16
+ if (ch?.length) traverse(ch, level + 1);
17
+ });
18
+ };
19
+ traverse(options, 1);
20
+ return max;
21
+ };
7
22
  const useCascaderExtend = (options = [], keys, value) => {
8
- const depth = (() => {
9
- let maxDepth = 1;
10
- const traverse = (opts, level) => {
11
- if (!opts || !opts.length) return;
12
- if (level > maxDepth) maxDepth = level;
13
- const next = level + 1;
14
- opts.forEach(option => {
15
- const hasChildrenProp = Object.prototype.hasOwnProperty.call(option, keys.childrenKey);
16
- if (hasChildrenProp && next > maxDepth) maxDepth = next;
17
- const children = option[keys.childrenKey];
18
- if (children && children.length) traverse(children, next);
19
- });
20
- };
21
- traverse(options, 1);
22
- return maxDepth;
23
- })();
24
- const tabs = (() => {
25
- if (!value || !value.length) return [options];
26
- return value.reduce((acc, val, index) => {
27
- if (val == null) return acc;
28
- const current = acc[index];
29
- if (!current) return acc;
30
- const next = current.find(option => option[keys.valueKey] === value[index]);
31
- const children = next?.[keys.childrenKey];
32
- if (children) acc.push(children);
33
- return acc;
34
- }, [options]);
35
- })();
36
- const items = !value || !value.length ? [] : value.map((val, index) => tabs[index]?.find(option => option[keys.valueKey] === val));
23
+ const depth = getDepth(options, keys.childrenKey);
24
+ const tabs = !value?.length ? [options] : value.reduce((acc, val, i) => {
25
+ if (val == null) return acc;
26
+ const cur = acc[i];
27
+ if (!cur) return acc;
28
+ const ch = cur.find(o => o[keys.valueKey] === value[i])?.[keys.childrenKey];
29
+ if (ch) acc.push(ch);
30
+ return acc;
31
+ }, [options]);
32
+ const items = !value?.length ? [] : value.map((val, i) => tabs[i]?.find(o => o[keys.valueKey] === val));
37
33
  return {
38
34
  tabs,
39
35
  items,