react-native-system-ui 0.0.7 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) hide show
  1. package/README.md +46 -31
  2. package/dist/cjs/components/action-sheet/ActionSheet.js +128 -142
  3. package/dist/cjs/components/action-sheet/tokens.js +16 -27
  4. package/dist/cjs/components/area/Area.js +57 -70
  5. package/dist/cjs/components/area/tokens.js +6 -3
  6. package/dist/cjs/components/avatar/Avatar.js +38 -36
  7. package/dist/cjs/components/badge/Badge.js +68 -73
  8. package/dist/cjs/components/badge/tokens.js +6 -8
  9. package/dist/cjs/components/button/Button.js +135 -176
  10. package/dist/cjs/components/button/ButtonGroup.js +11 -45
  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 +257 -267
  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 +94 -104
  18. package/dist/cjs/components/cell/CellGroup.js +37 -49
  19. package/dist/cjs/components/checkbox/Checkbox.js +140 -132
  20. package/dist/cjs/components/checkbox/CheckboxGroup.js +21 -51
  21. package/dist/cjs/components/checkbox/tokens.js +7 -10
  22. package/dist/cjs/components/circle/Circle.js +87 -74
  23. package/dist/cjs/components/collapse/Collapse.js +88 -104
  24. package/dist/cjs/components/config-provider/ConfigProvider.js +17 -4
  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 +32 -27
  31. package/dist/cjs/components/datetime-picker/DatetimePicker.js +80 -104
  32. package/dist/cjs/components/datetime-picker/tokens.js +14 -3
  33. package/dist/cjs/components/dialog/Dialog.js +159 -121
  34. package/dist/cjs/components/dialog/imperative.js +24 -43
  35. package/dist/cjs/components/dialog/tokens.js +1 -0
  36. package/dist/cjs/components/divider/Divider.js +57 -62
  37. package/dist/cjs/components/empty/Empty.js +53 -52
  38. package/dist/cjs/components/error-boundary/ErrorBoundary.js +74 -0
  39. package/dist/cjs/components/error-boundary/index.js +19 -0
  40. package/dist/cjs/components/field/Field.js +109 -106
  41. package/dist/cjs/components/flex/Flex.js +32 -32
  42. package/dist/cjs/components/flex/FlexItem.js +27 -27
  43. package/dist/cjs/components/form/Form.js +178 -196
  44. package/dist/cjs/components/form/FormItem.js +87 -109
  45. package/dist/cjs/components/form/FormList.js +57 -45
  46. package/dist/cjs/components/form/tokens.js +6 -3
  47. package/dist/cjs/components/form/utils.js +15 -34
  48. package/dist/cjs/components/grid/Grid.js +44 -43
  49. package/dist/cjs/components/grid/GridItem.js +92 -86
  50. package/dist/cjs/components/image/Image.js +76 -79
  51. package/dist/cjs/components/image/tokens.js +5 -3
  52. package/dist/cjs/components/image-preview/ImagePreview.js +125 -113
  53. package/dist/cjs/components/image-preview/imperative.js +4 -13
  54. package/dist/cjs/components/image-preview/tokens.js +3 -1
  55. package/dist/cjs/components/index.js +13 -0
  56. package/dist/cjs/components/input/Input.js +40 -35
  57. package/dist/cjs/components/loading/Loading.js +32 -33
  58. package/dist/cjs/components/nav-bar/NavBar.js +88 -100
  59. package/dist/cjs/components/nav-bar/tokens.js +4 -10
  60. package/dist/cjs/components/notice-bar/NoticeBar.js +81 -80
  61. package/dist/cjs/components/notice-bar/tokens.js +3 -1
  62. package/dist/cjs/components/notify/Notify.js +89 -84
  63. package/dist/cjs/components/notify/imperative.js +32 -55
  64. package/dist/cjs/components/notify/tokens.js +2 -11
  65. package/dist/cjs/components/number-keyboard/NumberKeyboard.js +277 -283
  66. package/dist/cjs/components/number-keyboard/tokens.js +7 -1
  67. package/dist/cjs/components/overlay/Overlay.js +37 -52
  68. package/dist/cjs/components/overlay/tokens.js +5 -3
  69. package/dist/cjs/components/password-input/PasswordInput.js +114 -95
  70. package/dist/cjs/components/picker/Picker.js +465 -454
  71. package/dist/cjs/components/picker/tokens.js +1 -1
  72. package/dist/cjs/components/popup/Popup.js +269 -299
  73. package/dist/cjs/components/popup/tokens.js +1 -0
  74. package/dist/cjs/components/portal/Portal.js +12 -30
  75. package/dist/cjs/components/portal/PortalHost.js +151 -234
  76. package/dist/cjs/components/progress/Progress.js +103 -101
  77. package/dist/cjs/components/progress/tokens.js +1 -0
  78. package/dist/cjs/components/radio/Radio.js +98 -91
  79. package/dist/cjs/components/radio/RadioGroup.js +13 -45
  80. package/dist/cjs/components/radio/tokens.js +7 -10
  81. package/dist/cjs/components/safe-area-view/SafeAreaView.js +22 -26
  82. package/dist/cjs/components/search/Search.js +65 -57
  83. package/dist/cjs/components/selector/Selector.js +21 -27
  84. package/dist/cjs/components/share-sheet/ShareSheet.js +165 -161
  85. package/dist/cjs/components/share-sheet/tokens.js +3 -1
  86. package/dist/cjs/components/sidebar/Sidebar.js +51 -51
  87. package/dist/cjs/components/sidebar/SidebarContext.js +1 -2
  88. package/dist/cjs/components/sidebar/SidebarItem.js +19 -21
  89. package/dist/cjs/components/sidebar/tokens.js +4 -4
  90. package/dist/cjs/components/skeleton/Skeleton.js +71 -77
  91. package/dist/cjs/components/skeleton/tokens.js +1 -2
  92. package/dist/cjs/components/slider/Slider.js +156 -135
  93. package/dist/cjs/components/space/Space.js +57 -76
  94. package/dist/cjs/components/space/tokens.js +7 -1
  95. package/dist/cjs/components/stepper/Stepper.js +182 -158
  96. package/dist/cjs/components/stepper/tokens.js +1 -0
  97. package/dist/cjs/components/swiper/Swiper.js +256 -255
  98. package/dist/cjs/components/swiper/SwiperPagIndicator.js +26 -27
  99. package/dist/cjs/components/swiper/tokens.js +10 -3
  100. package/dist/cjs/components/switch/Switch.js +23 -25
  101. package/dist/cjs/components/tabbar/Tabbar.js +48 -40
  102. package/dist/cjs/components/tabbar/TabbarContext.js +1 -2
  103. package/dist/cjs/components/tabbar/TabbarItem.js +65 -68
  104. package/dist/cjs/components/tabs/Tabs.js +402 -439
  105. package/dist/cjs/components/tabs/tokens.js +3 -1
  106. package/dist/cjs/components/tag/Tag.js +68 -59
  107. package/dist/cjs/components/toast/Toast.js +91 -90
  108. package/dist/cjs/components/toast/imperative.js +16 -41
  109. package/dist/cjs/components/toast/tokens.js +1 -0
  110. package/dist/cjs/components/typography/Typography.js +25 -25
  111. package/dist/cjs/components/water-mark/WaterMark.js +80 -78
  112. package/dist/cjs/design-system/Text.js +38 -0
  113. package/dist/cjs/design-system/ThemeProvider.js +5 -11
  114. package/dist/cjs/design-system/createComponentTokensHook.js +11 -13
  115. package/dist/cjs/design-system/index.js +7 -0
  116. package/dist/cjs/design-system/mergeTokensOverride.js +1 -4
  117. package/dist/cjs/design-system/presets.js +2 -3
  118. package/dist/cjs/design-system/tokens.js +2 -11
  119. package/dist/cjs/hooks/animation/index.js +25 -0
  120. package/dist/cjs/hooks/animation/useAnimatedTransition.js +72 -0
  121. package/dist/cjs/hooks/animation/useReducedMotion.js +75 -0
  122. package/dist/cjs/hooks/aria/useAriaListBox.js +8 -16
  123. package/dist/cjs/hooks/aria/useAriaOverlay.js +3 -3
  124. package/dist/cjs/hooks/aria/useAriaPress.js +8 -21
  125. package/dist/cjs/hooks/aria/useAriaToggle.js +3 -3
  126. package/dist/cjs/hooks/gesture/useGestureScroll.js +60 -61
  127. package/dist/cjs/hooks/index.js +12 -0
  128. package/dist/cjs/hooks/overlay/OverlayStackStore.js +49 -69
  129. package/dist/cjs/hooks/overlay/useOverlayStack.js +13 -19
  130. package/dist/cjs/hooks/useControllableValue.js +13 -24
  131. package/dist/cjs/hooks/useCountDown.js +30 -38
  132. package/dist/cjs/hooks/useHairline.js +17 -29
  133. package/dist/cjs/hooks/useSafeAreaPadding.js +1 -4
  134. package/dist/cjs/index.js +67 -1
  135. package/dist/cjs/platform/animation.js +10 -2
  136. package/dist/cjs/platform/measure.js +21 -37
  137. package/dist/cjs/utils/color.js +20 -39
  138. package/dist/cjs/utils/compare.js +7 -12
  139. package/dist/cjs/utils/createPlatformShadow.js +28 -39
  140. package/dist/cjs/utils/date.js +20 -50
  141. package/dist/cjs/utils/deepMerge.js +16 -26
  142. package/dist/cjs/utils/hairline.js +75 -71
  143. package/dist/cjs/utils/index.js +22 -0
  144. package/dist/cjs/utils/number.js +21 -29
  145. package/dist/cjs/utils/render.js +21 -0
  146. package/dist/cjs/utils/rtl.js +25 -0
  147. package/dist/cjs/utils/string.js +8 -25
  148. package/dist/cjs/utils/validate.js +2 -4
  149. package/dist/es/components/action-sheet/ActionSheet.js +130 -144
  150. package/dist/es/components/action-sheet/tokens.js +16 -27
  151. package/dist/es/components/area/Area.js +58 -71
  152. package/dist/es/components/area/tokens.js +6 -3
  153. package/dist/es/components/avatar/Avatar.js +38 -36
  154. package/dist/es/components/avatar/index.js +1 -2
  155. package/dist/es/components/badge/Badge.js +70 -75
  156. package/dist/es/components/badge/tokens.js +6 -8
  157. package/dist/es/components/button/Button.js +136 -177
  158. package/dist/es/components/button/ButtonGroup.js +12 -46
  159. package/dist/es/components/button/tokens.js +2 -3
  160. package/dist/es/components/calendar/Calendar.js +214 -225
  161. package/dist/es/components/calendar/tokens.js +3 -3
  162. package/dist/es/components/cascader/Cascader.js +260 -270
  163. package/dist/es/components/cascader/tokens.js +2 -2
  164. package/dist/es/components/cascader/useCascaderExtend.js +25 -29
  165. package/dist/es/components/cell/Cell.js +95 -105
  166. package/dist/es/components/cell/CellGroup.js +37 -48
  167. package/dist/es/components/checkbox/Checkbox.js +141 -133
  168. package/dist/es/components/checkbox/CheckboxGroup.js +22 -52
  169. package/dist/es/components/checkbox/tokens.js +7 -10
  170. package/dist/es/components/circle/Circle.js +87 -73
  171. package/dist/es/components/collapse/Collapse.js +90 -105
  172. package/dist/es/components/config-provider/ConfigProvider.js +11 -4
  173. package/dist/es/components/config-provider/DirectionContext.js +2 -0
  174. package/dist/es/components/config-provider/index.js +1 -0
  175. package/dist/es/components/config-provider/locale/en-US.js +32 -0
  176. package/dist/es/components/config-provider/locale/zh-CN.js +32 -0
  177. package/dist/es/components/config-provider/useDirection.js +3 -0
  178. package/dist/es/components/count-down/CountDown.js +35 -30
  179. package/dist/es/components/datetime-picker/DatetimePicker.js +80 -104
  180. package/dist/es/components/datetime-picker/tokens.js +14 -3
  181. package/dist/es/components/dialog/Dialog.js +160 -121
  182. package/dist/es/components/dialog/imperative.js +24 -43
  183. package/dist/es/components/dialog/tokens.js +1 -0
  184. package/dist/es/components/divider/Divider.js +59 -63
  185. package/dist/es/components/empty/Empty.js +54 -52
  186. package/dist/es/components/error-boundary/ErrorBoundary.js +62 -0
  187. package/dist/es/components/error-boundary/index.js +1 -0
  188. package/dist/es/components/field/Field.js +109 -106
  189. package/dist/es/components/flex/Flex.js +32 -31
  190. package/dist/es/components/flex/FlexItem.js +28 -27
  191. package/dist/es/components/form/Form.js +179 -197
  192. package/dist/es/components/form/FormItem.js +86 -107
  193. package/dist/es/components/form/FormList.js +57 -45
  194. package/dist/es/components/form/tokens.js +6 -3
  195. package/dist/es/components/form/utils.js +15 -34
  196. package/dist/es/components/grid/Grid.js +44 -42
  197. package/dist/es/components/grid/GridItem.js +94 -87
  198. package/dist/es/components/image/Image.js +79 -82
  199. package/dist/es/components/image/tokens.js +5 -3
  200. package/dist/es/components/image-preview/ImagePreview.js +125 -113
  201. package/dist/es/components/image-preview/imperative.js +4 -13
  202. package/dist/es/components/image-preview/tokens.js +3 -1
  203. package/dist/es/components/index.js +3 -1
  204. package/dist/es/components/input/Input.js +41 -36
  205. package/dist/es/components/loading/Loading.js +34 -34
  206. package/dist/es/components/nav-bar/NavBar.js +88 -100
  207. package/dist/es/components/nav-bar/tokens.js +4 -4
  208. package/dist/es/components/notice-bar/NoticeBar.js +81 -79
  209. package/dist/es/components/notice-bar/tokens.js +3 -1
  210. package/dist/es/components/notify/Notify.js +93 -87
  211. package/dist/es/components/notify/imperative.js +33 -56
  212. package/dist/es/components/notify/tokens.js +2 -5
  213. package/dist/es/components/number-keyboard/NumberKeyboard.js +277 -283
  214. package/dist/es/components/number-keyboard/tokens.js +7 -1
  215. package/dist/es/components/overlay/Overlay.js +36 -51
  216. package/dist/es/components/overlay/tokens.js +5 -3
  217. package/dist/es/components/password-input/PasswordInput.js +114 -95
  218. package/dist/es/components/picker/Picker.js +465 -454
  219. package/dist/es/components/picker/tokens.js +1 -1
  220. package/dist/es/components/popup/Popup.js +269 -298
  221. package/dist/es/components/popup/tokens.js +1 -0
  222. package/dist/es/components/portal/Portal.js +13 -30
  223. package/dist/es/components/portal/PortalHost.js +152 -234
  224. package/dist/es/components/progress/Progress.js +103 -101
  225. package/dist/es/components/progress/tokens.js +1 -0
  226. package/dist/es/components/radio/Radio.js +100 -93
  227. package/dist/es/components/radio/RadioGroup.js +15 -46
  228. package/dist/es/components/radio/tokens.js +7 -10
  229. package/dist/es/components/safe-area-view/SafeAreaView.js +22 -25
  230. package/dist/es/components/search/Search.js +66 -58
  231. package/dist/es/components/selector/Selector.js +21 -27
  232. package/dist/es/components/share-sheet/ShareSheet.js +167 -163
  233. package/dist/es/components/share-sheet/tokens.js +3 -1
  234. package/dist/es/components/sidebar/Sidebar.js +53 -53
  235. package/dist/es/components/sidebar/SidebarContext.js +1 -2
  236. package/dist/es/components/sidebar/SidebarItem.js +19 -20
  237. package/dist/es/components/sidebar/tokens.js +4 -4
  238. package/dist/es/components/skeleton/Skeleton.js +71 -77
  239. package/dist/es/components/skeleton/tokens.js +1 -2
  240. package/dist/es/components/slider/Slider.js +156 -134
  241. package/dist/es/components/space/Space.js +59 -78
  242. package/dist/es/components/space/tokens.js +7 -1
  243. package/dist/es/components/stepper/Stepper.js +183 -159
  244. package/dist/es/components/stepper/tokens.js +1 -0
  245. package/dist/es/components/swiper/Swiper.js +258 -257
  246. package/dist/es/components/swiper/SwiperPagIndicator.js +26 -27
  247. package/dist/es/components/swiper/tokens.js +10 -3
  248. package/dist/es/components/switch/Switch.js +23 -25
  249. package/dist/es/components/tabbar/Tabbar.js +49 -41
  250. package/dist/es/components/tabbar/TabbarContext.js +1 -2
  251. package/dist/es/components/tabbar/TabbarItem.js +66 -69
  252. package/dist/es/components/tabs/Tabs.js +403 -440
  253. package/dist/es/components/tabs/tokens.js +3 -1
  254. package/dist/es/components/tag/Tag.js +71 -61
  255. package/dist/es/components/toast/Toast.js +94 -91
  256. package/dist/es/components/toast/imperative.js +16 -41
  257. package/dist/es/components/toast/tokens.js +1 -0
  258. package/dist/es/components/typography/Typography.js +25 -25
  259. package/dist/es/components/water-mark/WaterMark.js +81 -79
  260. package/dist/es/design-system/Text.js +19 -0
  261. package/dist/es/design-system/ThemeProvider.js +5 -11
  262. package/dist/es/design-system/createComponentTokensHook.js +11 -13
  263. package/dist/es/design-system/index.js +1 -0
  264. package/dist/es/design-system/mergeTokensOverride.js +1 -4
  265. package/dist/es/design-system/presets.js +2 -3
  266. package/dist/es/design-system/tokens.js +1 -9
  267. package/dist/es/hooks/animation/index.js +2 -0
  268. package/dist/es/hooks/animation/useAnimatedTransition.js +53 -0
  269. package/dist/es/hooks/animation/useReducedMotion.js +54 -0
  270. package/dist/es/hooks/aria/useAriaListBox.js +8 -16
  271. package/dist/es/hooks/aria/useAriaOverlay.js +3 -3
  272. package/dist/es/hooks/aria/useAriaPress.js +8 -21
  273. package/dist/es/hooks/aria/useAriaToggle.js +3 -3
  274. package/dist/es/hooks/gesture/useGestureScroll.js +60 -61
  275. package/dist/es/hooks/index.js +1 -0
  276. package/dist/es/hooks/overlay/OverlayStackStore.js +49 -69
  277. package/dist/es/hooks/overlay/useOverlayStack.js +13 -19
  278. package/dist/es/hooks/useControllableValue.js +13 -24
  279. package/dist/es/hooks/useCountDown.js +30 -38
  280. package/dist/es/hooks/useHairline.js +16 -28
  281. package/dist/es/hooks/useSafeAreaPadding.js +1 -4
  282. package/dist/es/index.js +8 -1
  283. package/dist/es/platform/animation.js +9 -1
  284. package/dist/es/platform/measure.js +21 -37
  285. package/dist/es/utils/color.js +18 -35
  286. package/dist/es/utils/compare.js +7 -12
  287. package/dist/es/utils/createPlatformShadow.js +28 -39
  288. package/dist/es/utils/date.js +20 -50
  289. package/dist/es/utils/deepMerge.js +16 -26
  290. package/dist/es/utils/hairline.js +74 -65
  291. package/dist/es/utils/index.js +2 -0
  292. package/dist/es/utils/number.js +21 -29
  293. package/dist/es/utils/render.js +7 -0
  294. package/dist/es/utils/rtl.js +17 -0
  295. package/dist/es/utils/string.js +8 -25
  296. package/dist/es/utils/validate.js +1 -2
  297. package/dist/types/components/action-sheet/ActionSheet.d.ts +1 -1
  298. package/dist/types/components/area/Area.d.ts +1 -1
  299. package/dist/types/components/area/tokens.d.ts +4 -0
  300. package/dist/types/components/avatar/Avatar.d.ts +1 -1
  301. package/dist/types/components/avatar/index.d.ts +1 -2
  302. package/dist/types/components/badge/Badge.d.ts +1 -1
  303. package/dist/types/components/button/Button.d.ts +1 -1
  304. package/dist/types/components/button/index.d.ts +1 -1
  305. package/dist/types/components/calendar/Calendar.d.ts +1 -1
  306. package/dist/types/components/cascader/Cascader.d.ts +1 -1
  307. package/dist/types/components/cell/Cell.d.ts +1 -1
  308. package/dist/types/components/cell/CellGroup.d.ts +1 -1
  309. package/dist/types/components/cell/index.d.ts +2 -2
  310. package/dist/types/components/checkbox/Checkbox.d.ts +1 -1
  311. package/dist/types/components/circle/Circle.d.ts +1 -1
  312. package/dist/types/components/collapse/Collapse.d.ts +1 -2
  313. package/dist/types/components/config-provider/DirectionContext.d.ts +3 -0
  314. package/dist/types/components/config-provider/index.d.ts +2 -1
  315. package/dist/types/components/config-provider/locale/en-US.d.ts +32 -0
  316. package/dist/types/components/config-provider/locale/zh-CN.d.ts +32 -0
  317. package/dist/types/components/config-provider/useDirection.d.ts +1 -0
  318. package/dist/types/components/count-down/CountDown.d.ts +1 -1
  319. package/dist/types/components/datetime-picker/DatetimePicker.d.ts +1 -1
  320. package/dist/types/components/datetime-picker/tokens.d.ts +12 -0
  321. package/dist/types/components/dialog/Dialog.d.ts +1 -1
  322. package/dist/types/components/dialog/tokens.d.ts +1 -0
  323. package/dist/types/components/divider/Divider.d.ts +1 -1
  324. package/dist/types/components/empty/Empty.d.ts +1 -1
  325. package/dist/types/components/error-boundary/ErrorBoundary.d.ts +6 -0
  326. package/dist/types/components/error-boundary/index.d.ts +2 -0
  327. package/dist/types/components/field/Field.d.ts +1 -1
  328. package/dist/types/components/flex/Flex.d.ts +1 -1
  329. package/dist/types/components/flex/FlexItem.d.ts +1 -1
  330. package/dist/types/components/flex/index.d.ts +2 -2
  331. package/dist/types/components/form/Form.d.ts +1 -1
  332. package/dist/types/components/form/FormItem.d.ts +2 -1
  333. package/dist/types/components/form/index.d.ts +2 -2
  334. package/dist/types/components/form/tokens.d.ts +4 -0
  335. package/dist/types/components/grid/Grid.d.ts +1 -1
  336. package/dist/types/components/grid/GridItem.d.ts +1 -1
  337. package/dist/types/components/grid/index.d.ts +2 -2
  338. package/dist/types/components/image/Image.d.ts +1 -1
  339. package/dist/types/components/image-preview/ImagePreview.d.ts +1 -1
  340. package/dist/types/components/image-preview/tokens.d.ts +1 -0
  341. package/dist/types/components/index.d.ts +4 -1
  342. package/dist/types/components/input/Input.d.ts +3 -3
  343. package/dist/types/components/loading/Loading.d.ts +1 -1
  344. package/dist/types/components/nav-bar/NavBar.d.ts +1 -1
  345. package/dist/types/components/nav-bar/tokens.d.ts +1 -1
  346. package/dist/types/components/notice-bar/NoticeBar.d.ts +1 -1
  347. package/dist/types/components/notice-bar/tokens.d.ts +1 -0
  348. package/dist/types/components/notify/Notify.d.ts +2 -2
  349. package/dist/types/components/notify/index.d.ts +1 -1
  350. package/dist/types/components/number-keyboard/tokens.d.ts +5 -0
  351. package/dist/types/components/overlay/Overlay.d.ts +1 -5
  352. package/dist/types/components/overlay/tokens.d.ts +3 -0
  353. package/dist/types/components/password-input/PasswordInput.d.ts +1 -1
  354. package/dist/types/components/picker/Picker.d.ts +6 -6
  355. package/dist/types/components/popup/Popup.d.ts +3 -42
  356. package/dist/types/components/popup/tokens.d.ts +1 -0
  357. package/dist/types/components/portal/Portal.d.ts +9 -6
  358. package/dist/types/components/portal/PortalHost.d.ts +1 -1
  359. package/dist/types/components/radio/RadioGroup.d.ts +1 -1
  360. package/dist/types/components/safe-area-view/SafeAreaView.d.ts +1 -1
  361. package/dist/types/components/search/Search.d.ts +1 -1
  362. package/dist/types/components/share-sheet/ShareSheet.d.ts +1 -1
  363. package/dist/types/components/share-sheet/tokens.d.ts +1 -0
  364. package/dist/types/components/sidebar/Sidebar.d.ts +1 -1
  365. package/dist/types/components/sidebar/SidebarContext.d.ts +1 -1
  366. package/dist/types/components/sidebar/SidebarItem.d.ts +1 -1
  367. package/dist/types/components/sidebar/index.d.ts +2 -2
  368. package/dist/types/components/skeleton/Skeleton.d.ts +1 -1
  369. package/dist/types/components/slider/Slider.d.ts +1 -1
  370. package/dist/types/components/stepper/Stepper.d.ts +1 -1
  371. package/dist/types/components/stepper/tokens.d.ts +1 -0
  372. package/dist/types/components/swiper/Swiper.d.ts +1 -1
  373. package/dist/types/components/swiper/index.d.ts +1 -1
  374. package/dist/types/components/swiper/tokens.d.ts +8 -0
  375. package/dist/types/components/tabbar/Tabbar.d.ts +2 -2
  376. package/dist/types/components/tabbar/TabbarContext.d.ts +1 -1
  377. package/dist/types/components/tabbar/TabbarItem.d.ts +2 -2
  378. package/dist/types/components/tabs/Tabs.d.ts +1 -1
  379. package/dist/types/components/tabs/index.d.ts +1 -1
  380. package/dist/types/components/tabs/tokens.d.ts +1 -0
  381. package/dist/types/components/tag/Tag.d.ts +1 -1
  382. package/dist/types/components/toast/Toast.d.ts +2 -2
  383. package/dist/types/components/toast/index.d.ts +1 -1
  384. package/dist/types/components/toast/tokens.d.ts +1 -0
  385. package/dist/types/components/water-mark/WaterMark.d.ts +1 -1
  386. package/dist/types/design-system/Text.d.ts +3 -0
  387. package/dist/types/design-system/index.d.ts +1 -0
  388. package/dist/types/design-system/tokens.d.ts +0 -1
  389. package/dist/types/hooks/animation/index.d.ts +3 -0
  390. package/dist/types/hooks/animation/useAnimatedTransition.d.ts +13 -0
  391. package/dist/types/hooks/animation/useReducedMotion.d.ts +3 -0
  392. package/dist/types/hooks/aria/useAriaOverlay.d.ts +1 -1
  393. package/dist/types/hooks/gesture/useGestureScroll.d.ts +11 -10
  394. package/dist/types/hooks/index.d.ts +1 -0
  395. package/dist/types/hooks/overlay/OverlayStackStore.d.ts +8 -8
  396. package/dist/types/hooks/useCountDown.d.ts +1 -1
  397. package/dist/types/hooks/useHairline.d.ts +1 -1
  398. package/dist/types/index.d.ts +5 -0
  399. package/dist/types/platform/animation.d.ts +8 -0
  400. package/dist/types/platform/measure.d.ts +1 -1
  401. package/dist/types/utils/color.d.ts +0 -2
  402. package/dist/types/utils/compare.d.ts +1 -1
  403. package/dist/types/utils/createPlatformShadow.d.ts +2 -2
  404. package/dist/types/utils/date.d.ts +2 -2
  405. package/dist/types/utils/hairline.d.ts +5 -10
  406. package/dist/types/utils/index.d.ts +2 -0
  407. package/dist/types/utils/number.d.ts +2 -2
  408. package/dist/types/utils/render.d.ts +5 -0
  409. package/dist/types/utils/rtl.d.ts +5 -0
  410. package/dist/types/utils/validate.d.ts +0 -1
  411. package/package.json +25 -4
@@ -2,130 +2,115 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
2
2
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { Pressable, Text, View, Platform, StyleSheet, ScrollView, PanResponder } from 'react-native';
4
4
  import Loading from '../loading';
5
+ import { useLocale } from '../config-provider/useLocale';
5
6
  import { withAlpha } from '../../utils/color';
6
7
  import { isFiniteNumber, isText } from '../../utils/validate';
7
8
  import { clamp, isObject, shallowEqualArray } from '../../utils';
8
9
  import { usePickerTokens } from './tokens';
9
- export const toArrayValue = value => {
10
- if (Array.isArray(value)) return value.filter(v => v !== undefined && v !== null);
11
- if (value === undefined || value === null) return [];
12
- return [value];
13
- };
10
+ import { createHairlineView } from '../../utils/hairline';
11
+ export const toArrayValue = value => Array.isArray(value) ? value.filter(v => v !== undefined && v !== null) : value == null ? [] : [value];
14
12
  const isColumnWithOptions = col => !!col && isObject(col) && 'options' in col && Array.isArray(col.options);
15
- const hasChildren = option => {
16
- return !!option && isObject(option) && Array.isArray(option.children) && option.children.length > 0;
17
- };
18
- export const findEnabledIndex = (options, startIndex) => {
13
+ const hasChildren = option => !!option && isObject(option) && Array.isArray(option.children) && option.children.length > 0;
14
+ export const findEnabledIndex = (options, startIdx) => {
19
15
  if (!options.length) return -1;
20
- const clampIndex = Math.min(Math.max(startIndex, 0), options.length - 1);
21
- if (!options[clampIndex]?.disabled) return clampIndex;
22
- for (let i = clampIndex + 1; i < options.length; i += 1) {
16
+ const clampIdx = Math.min(Math.max(startIdx, 0), options.length - 1);
17
+ if (!options[clampIdx]?.disabled) return clampIdx;
18
+ for (let i = clampIdx + 1; i < options.length; i += 1) {
23
19
  if (!options[i]?.disabled) return i;
24
20
  }
25
- for (let i = clampIndex - 1; i >= 0; i -= 1) {
21
+ for (let i = clampIdx - 1; i >= 0; i -= 1) {
26
22
  if (!options[i]?.disabled) return i;
27
23
  }
28
24
  return -1;
29
25
  };
30
- const normalizeMultiple = (columnsList, defaults, rawValue) => {
31
- const values = [];
32
- const options = [];
33
- columnsList.forEach((opts, index) => {
34
- const current = rawValue[index];
35
- const defaultIndex = defaults[index] !== undefined ? opts.findIndex(item => item.value === defaults[index]) : -1;
36
- const currentIndex = opts.findIndex(item => item.value === current);
37
- const startIndex = currentIndex >= 0 ? currentIndex : defaultIndex >= 0 ? defaultIndex : 0;
38
- const targetIndex = findEnabledIndex(opts, startIndex);
39
- const target = targetIndex >= 0 ? opts[targetIndex] : undefined;
40
- const valid = currentIndex >= 0 && !opts[currentIndex]?.disabled;
41
- values[index] = valid ? current : target?.value ?? defaults[index] ?? opts[0]?.value;
42
- options[index] = target;
26
+ const normalizeMultiple = (cols, defs, raw) => {
27
+ const vals = [],
28
+ opts = [];
29
+ cols.forEach((colOpts, idx) => {
30
+ const curr = raw[idx];
31
+ const defIdx = defs[idx] !== undefined ? colOpts.findIndex(item => item.value === defs[idx]) : -1;
32
+ const currIdx = colOpts.findIndex(item => item.value === curr);
33
+ const startIdx = currIdx >= 0 ? currIdx : defIdx >= 0 ? defIdx : 0;
34
+ const tgtIdx = findEnabledIndex(colOpts, startIdx);
35
+ const tgt = tgtIdx >= 0 ? colOpts[tgtIdx] : undefined;
36
+ const valid = currIdx >= 0 && !colOpts[currIdx]?.disabled;
37
+ vals[idx] = valid ? curr : tgt?.value ?? defs[idx] ?? colOpts[0]?.value;
38
+ opts[idx] = tgt;
43
39
  });
44
40
  return {
45
- columns: columnsList,
46
- values,
47
- options
41
+ columns: cols,
42
+ values: vals,
43
+ options: opts
48
44
  };
49
45
  };
50
- const normalizeCascade = (rootOptions, rawValue) => {
51
- const columns = [];
52
- const values = [];
53
- const options = [];
54
- let currentOptions = rootOptions;
55
- let depth = 0;
56
- while (currentOptions && currentOptions.length && depth < 10) {
57
- columns.push(currentOptions);
58
- const current = rawValue[depth];
59
- const startIndex = currentOptions.findIndex(item => item.value === current || String(item.value) === String(current));
60
- const targetIndex = findEnabledIndex(currentOptions, startIndex >= 0 ? startIndex : 0);
61
- const target = targetIndex >= 0 ? currentOptions[targetIndex] : currentOptions[0];
62
- values[depth] = target?.value;
63
- options[depth] = target;
64
- if (target && hasChildren(target)) {
65
- currentOptions = target.children;
66
- depth += 1;
67
- } else {
68
- break;
69
- }
46
+ const normalizeCascade = (root, raw) => {
47
+ const cols = [],
48
+ vals = [],
49
+ opts = [];
50
+ let curr = root;
51
+ let d = 0;
52
+ while (curr && curr.length && d < 10) {
53
+ cols.push(curr);
54
+ const c = raw[d];
55
+ const startIdx = curr.findIndex(item => item.value === c || String(item.value) === String(c));
56
+ const tgtIdx = findEnabledIndex(curr, startIdx >= 0 ? startIdx : 0);
57
+ const tgt = tgtIdx >= 0 ? curr[tgtIdx] : curr[0];
58
+ vals[d] = tgt?.value;
59
+ opts[d] = tgt;
60
+ if (tgt && hasChildren(tgt)) {
61
+ curr = tgt.children;
62
+ d += 1;
63
+ } else break;
70
64
  }
71
65
  return {
72
- columns,
73
- values,
74
- options
66
+ columns: cols,
67
+ values: vals,
68
+ options: opts
75
69
  };
76
70
  };
77
- export const prepareColumns = (columnsInput = []) => {
78
- if (!Array.isArray(columnsInput) || columnsInput.length === 0) {
79
- return {
80
- type: 'single',
81
- columnsList: [],
82
- defaults: [],
83
- cascadeRoot: []
84
- };
85
- }
86
- const everyPlainOption = columnsInput.every(item => !Array.isArray(item) && !isColumnWithOptions(item));
87
- const cascade = everyPlainOption && columnsInput.some(item => hasChildren(item));
88
- if (cascade) {
89
- return {
90
- type: 'cascade',
91
- columnsList: [],
92
- defaults: [],
93
- cascadeRoot: columnsInput
94
- };
95
- }
96
- const asArray = columnsInput;
97
- const columnsList = [];
98
- const defaults = [];
99
- const treatAsSingleColumn = everyPlainOption && !cascade;
100
- if (treatAsSingleColumn) {
101
- columnsList.push(columnsInput);
102
- defaults.push(undefined);
103
- } else {
104
- asArray.forEach(col => {
105
- if (Array.isArray(col)) {
106
- columnsList.push(col);
107
- defaults.push(undefined);
108
- } else if (isColumnWithOptions(col)) {
109
- const c = col;
110
- columnsList.push(c.options ?? []);
111
- defaults.push(c.defaultValue);
112
- }
113
- });
114
- }
71
+ export const prepareColumns = (input = []) => {
72
+ if (!Array.isArray(input) || input.length === 0) return {
73
+ type: 'single',
74
+ columnsList: [],
75
+ defaults: [],
76
+ cascadeRoot: []
77
+ };
78
+ const everyPlain = input.every(item => !Array.isArray(item) && !isColumnWithOptions(item));
79
+ const cascade = everyPlain && input.some(item => hasChildren(item));
80
+ if (cascade) return {
81
+ type: 'cascade',
82
+ columnsList: [],
83
+ defaults: [],
84
+ cascadeRoot: input
85
+ };
86
+ const asArray = input;
87
+ const cols = [],
88
+ defs = [];
89
+ const treatAsSingle = everyPlain && !cascade;
90
+ if (treatAsSingle) {
91
+ cols.push(input);
92
+ defs.push(undefined);
93
+ } else asArray.forEach(col => {
94
+ if (Array.isArray(col)) {
95
+ cols.push(col);
96
+ defs.push(undefined);
97
+ } else if (isColumnWithOptions(col)) {
98
+ const c = col;
99
+ cols.push(c.options ?? []);
100
+ defs.push(c.defaultValue);
101
+ }
102
+ });
115
103
  return {
116
104
  type: 'multiple',
117
- columnsList,
118
- defaults
105
+ columnsList: cols,
106
+ defaults: defs
119
107
  };
120
108
  };
121
- export const normalizePicker = (prepared, rawValueInput = []) => {
122
- const rawValue = Array.isArray(rawValueInput) ? rawValueInput : [];
123
- if (prepared.type === 'cascade' && prepared.cascadeRoot?.length) {
124
- return normalizeCascade(prepared.cascadeRoot, rawValue);
125
- }
126
- return normalizeMultiple(prepared.columnsList, prepared.defaults, rawValue);
109
+ export const normalizePicker = (prep, raw = []) => {
110
+ const rawVal = Array.isArray(raw) ? raw : [];
111
+ return prep.type === 'cascade' && prep.cascadeRoot?.length ? normalizeCascade(prep.cascadeRoot, rawVal) : normalizeMultiple(prep.columnsList, prep.defaults, rawVal);
127
112
  };
128
- const wheelStyles = StyleSheet.create({
113
+ const W = StyleSheet.create({
129
114
  column: {
130
115
  flex: 1
131
116
  },
@@ -133,13 +118,10 @@ const wheelStyles = StyleSheet.create({
133
118
  justifyContent: 'center',
134
119
  alignItems: 'center'
135
120
  },
136
- indicator: {
137
- position: 'absolute',
138
- left: 0,
139
- right: 0,
140
- borderTopWidth: StyleSheet.hairlineWidth,
141
- borderBottomWidth: StyleSheet.hairlineWidth,
142
- zIndex: 3
121
+ grab: {
122
+ cursor: 'pointer',
123
+ userSelect: 'none',
124
+ touchAction: 'none'
143
125
  }
144
126
  });
145
127
  const WheelPickerItemInner = ({
@@ -155,44 +137,44 @@ const WheelPickerItemInner = ({
155
137
  disabled
156
138
  });
157
139
  return /*#__PURE__*/React.createElement(View, {
158
- style: [wheelStyles.option, {
140
+ style: [W.option, {
159
141
  height: itemHeight
160
142
  }]
161
143
  }, content);
162
144
  };
163
- const WheelPickerItem = /*#__PURE__*/React.memo(WheelPickerItemInner, (prev, next) => prev.item === next.item && prev.index === next.index && prev.itemHeight === next.itemHeight && prev.active === next.active && prev.disabled === next.disabled && prev.renderItem === next.renderItem);
164
- const getVelocityBucket = velocity => {
165
- const abs = Math.abs(velocity);
145
+ const WheelPickerItem = /*#__PURE__*/React.memo(WheelPickerItemInner);
146
+ const getVelocityBucket = v => {
147
+ const abs = Math.abs(v);
166
148
  if (abs > 1.2) return 2;
167
149
  if (abs > 0.6) return 1;
168
150
  return 0;
169
151
  };
170
- const adjustIndex = (index, options) => {
171
- const total = options.length;
152
+ const adjustIndex = (idx, opts) => {
153
+ const total = opts.length;
172
154
  if (!total) return 0;
173
- const i = clamp(index, 0, total - 1);
174
- const next = findEnabledIndex(options, i);
155
+ const i = clamp(idx, 0, total - 1);
156
+ const next = findEnabledIndex(opts, i);
175
157
  return next >= 0 ? next : i;
176
158
  };
177
- const indexToOffset = (index, itemHeight) => -index * itemHeight;
178
- const offsetToIndex = (offset, itemHeight, total, options) => {
179
- const minOffset = -Math.max(0, total - 1) * itemHeight;
180
- const off = clamp(offset, minOffset, 0);
181
- let index = Math.round(-off / itemHeight);
182
- index = adjustIndex(index, options);
183
- const snapOffset = indexToOffset(index, itemHeight);
159
+ const indexToOffset = (idx, h) => -idx * h;
160
+ const offsetToIndex = (off, h, total, opts) => {
161
+ const minOff = -Math.max(0, total - 1) * h;
162
+ const offClamped = clamp(off, minOff, 0);
163
+ let idx = Math.round(-offClamped / h);
164
+ idx = adjustIndex(idx, opts);
165
+ const snapOff = indexToOffset(idx, h);
184
166
  return {
185
- index,
186
- snapOffset
167
+ index: idx,
168
+ snapOffset: snapOff
187
169
  };
188
170
  };
189
- const shouldMomentum = (distance, duration) => duration < 500 && Math.abs(distance) > 8;
190
- const momentumTarget = (distance, duration, currentOffset, itemHeight, minOffset) => {
191
- const speed = Math.abs(distance / duration);
192
- const extra = speed / 0.0025 * (distance < 0 ? -1 : 1);
193
- const target = clamp(currentOffset + extra, minOffset, 0);
194
- const snapIndex = Math.round(-target / itemHeight);
195
- return indexToOffset(snapIndex, itemHeight);
171
+ const shouldMomentum = (dist, dur) => dur < 500 && Math.abs(dist) > 8;
172
+ const momentumTarget = (dist, dur, currOff, h, minOff) => {
173
+ const speed = Math.abs(dist / dur);
174
+ const extra = speed / 0.0025 * (dist < 0 ? -1 : 1);
175
+ const tgt = clamp(currOff + extra, minOff, 0);
176
+ const snapIdx = Math.round(-tgt / h);
177
+ return indexToOffset(snapIdx, h);
196
178
  };
197
179
  const WheelPickerInner = ({
198
180
  data,
@@ -214,86 +196,89 @@ const WheelPickerInner = ({
214
196
  swipeDuration = 300
215
197
  }) => {
216
198
  const isWeb = Platform.OS === 'web';
217
- const listRef = useRef(null);
218
- const scrollRef = useRef(null);
199
+ const listRef = useRef(null),
200
+ scrollRef = useRef(null);
219
201
  const spacerHeight = visibleRest * itemHeight;
220
202
  const total = data.length;
221
- const maxIndex = Math.max(0, total - 1);
222
- const minOffset = -maxIndex * itemHeight;
203
+ const maxIdx = Math.max(0, total - 1);
204
+ const minOff = -maxIdx * itemHeight;
223
205
  const containerHeight = itemHeight * (visibleRest * 2 + 1);
224
- const rawSelectedIndex = clamp(selectedIndex, 0, maxIndex);
225
- const enabledSelectedIndex = findEnabledIndex(data, rawSelectedIndex);
226
- const safeSelectedIndex = enabledSelectedIndex >= 0 ? enabledSelectedIndex : rawSelectedIndex;
227
- const visibleCount = visibleRest * 2 + 1;
228
- const effectiveScrollThrottle = total > visibleCount * 20 ? 32 : scrollEventThrottle;
229
- const webVirtualEnabled = total > visibleCount * 4;
206
+ const rawSelIdx = clamp(selectedIndex, 0, maxIdx);
207
+ const enabledSelIdx = findEnabledIndex(data, rawSelIdx);
208
+ const safeSelIdx = enabledSelIdx >= 0 ? enabledSelIdx : rawSelIdx;
209
+ const visibleCnt = visibleRest * 2 + 1;
210
+ const effectiveScrollThrottle = total > visibleCnt * 20 ? 32 : scrollEventThrottle;
211
+ const webVirtualEnabled = total > visibleCnt * 4;
230
212
  const Spacer = useCallback(() => /*#__PURE__*/React.createElement(View, {
231
213
  style: {
232
214
  height: spacerHeight
233
215
  }
234
216
  }), [spacerHeight]);
235
- const indicatorStyle = useMemo(() => [wheelStyles.indicator, {
217
+ const indicatorStyle = useMemo(() => [S.indicator, {
236
218
  height: itemHeight,
237
- top: itemHeight * visibleRest,
238
- borderColor: indicatorColor
239
- }], [itemHeight, visibleRest, indicatorColor]);
240
- const dragEndTimerRef = useRef(null);
241
- const momentumRef = useRef(false);
242
- const lastOffsetRef = useRef(0);
219
+ top: itemHeight * visibleRest
220
+ }], [itemHeight, visibleRest]);
221
+ const dragEndTimerRef = useRef(null),
222
+ momentumRef = useRef(false),
223
+ lastOffsetRef = useRef(0);
243
224
  const clearDragEndTimer = useCallback(() => {
244
225
  if (dragEndTimerRef.current) {
245
226
  clearTimeout(dragEndTimerRef.current);
246
227
  dragEndTimerRef.current = null;
247
228
  }
248
229
  }, []);
249
- const emitIndexFromOffset = useCallback((offsetY, animated) => {
230
+ const emitIdx = useCallback((offsetY, animated) => {
250
231
  if (readOnly) return;
251
232
  const {
252
233
  index,
253
234
  snapOffset
254
235
  } = offsetToIndex(-offsetY, itemHeight, total, data);
255
- const nextOffset = -snapOffset;
256
- if (Math.abs(nextOffset - offsetY) > 0.5) {
236
+ const nextOff = -snapOffset;
237
+ if (Math.abs(nextOff - offsetY) > 0.5) {
257
238
  listRef.current?.scrollToOffset({
258
- offset: nextOffset,
239
+ offset: nextOff,
259
240
  animated
260
241
  });
261
242
  }
262
243
  onChange(index);
263
244
  }, [data, itemHeight, onChange, readOnly, total]);
264
245
  useEffect(() => {
265
- const offset = safeSelectedIndex * itemHeight;
246
+ const offset = safeSelIdx * itemHeight;
266
247
  if (isWeb) return;
267
248
  scrollRef.current?.scrollTo({
268
249
  y: offset,
269
250
  animated: false
270
251
  });
271
- }, [isWeb, itemHeight, safeSelectedIndex]);
272
- const [webOffset, setWebOffset] = useState(() => indexToOffset(safeSelectedIndex, itemHeight));
273
- const webOffsetRef = useRef(webOffset);
274
- const startOffsetRef = useRef(0);
275
- const startTimeRef = useRef(0);
252
+ }, [isWeb, itemHeight, safeSelIdx]);
253
+ const [webOffset, setWebOffset] = useState(() => indexToOffset(safeSelIdx, itemHeight));
254
+ const webOffsetRef = useRef(webOffset),
255
+ startOffsetRef = useRef(0),
256
+ startTimeRef = useRef(0);
276
257
  const [webTransition, setWebTransition] = useState(0);
277
258
  const [webVelocityBucket, setWebVelocityBucket] = useState(0);
278
- const webVelocityBucketRef = useRef(0);
279
- const lastWheelTimeRef = useRef(null);
280
- const wheelDeltaRef = useRef(0);
281
- const wheelRafRef = useRef(null);
282
- const pendingIndexRef = useRef(null);
283
- const pendingTimerRef = useRef(null);
284
- const rafIdRef = useRef(null);
285
- const isInteractingRef = useRef(false);
286
- const notifyInteractStart = useCallback(() => {
259
+ const webVelocityBucketRef = useRef(0),
260
+ lastWheelTimeRef = useRef(null),
261
+ wheelDeltaRef = useRef(0),
262
+ wheelRafRef = useRef(null),
263
+ pendingIndexRef = useRef(null),
264
+ pendingTimerRef = useRef(null),
265
+ rafIdRef = useRef(null),
266
+ isInteractingRef = useRef(false);
267
+ const onInteractStartRef = useRef(onInteractStart);
268
+ onInteractStartRef.current = onInteractStart;
269
+ const onInteractEndRef = useRef(onInteractEnd);
270
+ onInteractEndRef.current = onInteractEnd;
271
+ const notifyStart = useCallback(() => {
287
272
  if (readOnly) return;
288
273
  if (isInteractingRef.current) return;
289
274
  isInteractingRef.current = true;
290
- onInteractStart?.();
291
- }, [onInteractStart, readOnly]);
292
- const notifyInteractEnd = useCallback(() => {
275
+ onInteractStartRef.current?.();
276
+ }, [readOnly]);
277
+ const notifyEnd = useCallback(() => {
293
278
  if (!isInteractingRef.current) return;
294
279
  isInteractingRef.current = false;
295
- onInteractEnd?.();
296
- }, [onInteractEnd]);
280
+ onInteractEndRef.current?.();
281
+ }, []);
297
282
  const stopRaf = useCallback(() => {
298
283
  if (rafIdRef.current != null && typeof cancelAnimationFrame !== 'undefined') {
299
284
  cancelAnimationFrame(rafIdRef.current);
@@ -338,44 +323,42 @@ const WheelPickerInner = ({
338
323
  clearPendingTimer();
339
324
  pendingIndexRef.current = null;
340
325
  setWebTransition(0);
341
- const next = indexToOffset(safeSelectedIndex, itemHeight);
326
+ const next = indexToOffset(safeSelIdx, itemHeight);
342
327
  webOffsetRef.current = next;
343
328
  setWebOffset(next);
344
- }, [clearPendingTimer, isWeb, itemHeight, safeSelectedIndex, setWebTransition]);
329
+ }, [clearPendingTimer, isWeb, itemHeight, safeSelIdx, setWebTransition]);
345
330
  const finalizePendingChange = useCallback(() => {
346
331
  if (readOnly) return;
347
- const nextIndex = pendingIndexRef.current;
348
- if (nextIndex == null) return;
332
+ const nextIdx = pendingIndexRef.current;
333
+ if (nextIdx == null) return;
349
334
  pendingIndexRef.current = null;
350
335
  clearPendingTimer();
351
336
  setWebTransition(0);
352
- notifyInteractEnd();
353
- onChange(nextIndex);
337
+ notifyEnd();
338
+ onChange(nextIdx);
354
339
  }, [clearPendingTimer, onChange, readOnly, setWebTransition]);
355
- const startWebSnap = useCallback(targetIndex => {
340
+ const startWebSnap = useCallback(targetIdx => {
356
341
  if (readOnly) return;
357
- notifyInteractStart();
358
- const clampedIndex = clamp(targetIndex, 0, maxIndex);
359
- const targetOffset = indexToOffset(clampedIndex, itemHeight);
342
+ notifyStart();
343
+ const clampedIdx = clamp(targetIdx, 0, maxIdx);
344
+ const targetOff = indexToOffset(clampedIdx, itemHeight);
360
345
  clearPendingTimer();
361
- pendingIndexRef.current = clampedIndex;
362
- webOffsetRef.current = targetOffset;
346
+ pendingIndexRef.current = clampedIdx;
347
+ webOffsetRef.current = targetOff;
363
348
  setWebTransition(swipeDuration);
364
- setWebOffset(targetOffset);
349
+ setWebOffset(targetOff);
365
350
  if (swipeDuration <= 0) {
366
351
  finalizePendingChange();
367
352
  } else {
368
353
  pendingTimerRef.current = setTimeout(finalizePendingChange, swipeDuration + 80);
369
354
  }
370
- }, [clearPendingTimer, finalizePendingChange, itemHeight, maxIndex, readOnly, swipeDuration]);
355
+ }, [clearPendingTimer, finalizePendingChange, itemHeight, maxIdx, readOnly, swipeDuration]);
371
356
  const handleWheel = useCallback(event => {
372
357
  if (readOnly) return;
373
358
  const delta = event.nativeEvent?.deltaY ?? 0;
374
359
  if (!delta) return;
375
360
  wheelDeltaRef.current += delta;
376
- if (wheelRafRef.current != null || typeof requestAnimationFrame === 'undefined') {
377
- return;
378
- }
361
+ if (wheelRafRef.current != null || typeof requestAnimationFrame === 'undefined') return;
379
362
  wheelRafRef.current = requestAnimationFrame(() => {
380
363
  wheelRafRef.current = null;
381
364
  const queued = wheelDeltaRef.current;
@@ -386,11 +369,11 @@ const WheelPickerInner = ({
386
369
  const {
387
370
  index
388
371
  } = offsetToIndex(webOffsetRef.current, itemHeight, total, data);
389
- const nextIndex = clamp(index + direction, 0, maxIndex);
390
- startWebSnap(nextIndex);
372
+ const nextIdx = clamp(index + direction, 0, maxIdx);
373
+ startWebSnap(nextIdx);
391
374
  });
392
- }, [data, itemHeight, maxIndex, readOnly, startWebSnap, total, updateWheelVelocity]);
393
- const webIndex = clamp(Math.round(-webOffset / itemHeight), 0, maxIndex);
375
+ }, [data, itemHeight, maxIdx, readOnly, startWebSnap, total, updateWheelVelocity]);
376
+ const webIdx = clamp(Math.round(-webOffset / itemHeight), 0, maxIdx);
394
377
  const webRender = useMemo(() => {
395
378
  if (!isWeb || total <= 0) {
396
379
  return {
@@ -399,17 +382,17 @@ const WheelPickerInner = ({
399
382
  bottomSpacer: null
400
383
  };
401
384
  }
402
- let startIndex = 0;
403
- let endIndex = maxIndex;
385
+ let startIdx = 0;
386
+ let endIdx = maxIdx;
404
387
  if (webVirtualEnabled) {
405
- const baseBuffer = Math.max(visibleCount * 2, 8);
406
- const velocityBoost = webVelocityBucket === 2 ? visibleCount * 4 : webVelocityBucket === 1 ? visibleCount * 2 : 0;
407
- const buffer = Math.min(baseBuffer + velocityBoost, Math.max(visibleCount * 6, 24));
408
- startIndex = clamp(webIndex - buffer, 0, maxIndex);
409
- endIndex = clamp(webIndex + buffer, 0, maxIndex);
388
+ const baseBuffer = Math.max(visibleCnt * 2, 8);
389
+ const velocityBoost = webVelocityBucket === 2 ? visibleCnt * 4 : webVelocityBucket === 1 ? visibleCnt * 2 : 0;
390
+ const buffer = Math.min(baseBuffer + velocityBoost, Math.max(visibleCnt * 6, 24));
391
+ startIdx = clamp(webIdx - buffer, 0, maxIdx);
392
+ endIdx = clamp(webIdx + buffer, 0, maxIdx);
410
393
  }
411
394
  const items = [];
412
- for (let index = startIndex; index <= endIndex; index += 1) {
395
+ for (let index = startIdx; index <= endIdx; index += 1) {
413
396
  const item = data[index];
414
397
  if (!item) continue;
415
398
  items.push(/*#__PURE__*/React.createElement(WheelPickerItem, {
@@ -417,27 +400,27 @@ const WheelPickerInner = ({
417
400
  item: item,
418
401
  index: index,
419
402
  itemHeight: itemHeight,
420
- active: index === safeSelectedIndex,
403
+ active: index === safeSelIdx,
421
404
  disabled: !!item.disabled,
422
405
  renderItem: renderItem
423
406
  }));
424
407
  }
425
- const topHeight = startIndex * itemHeight;
426
- const bottomHeight = (maxIndex - endIndex) * itemHeight;
408
+ const topH = startIdx * itemHeight;
409
+ const bottomH = (maxIdx - endIdx) * itemHeight;
427
410
  return {
428
411
  items,
429
- topSpacer: topHeight > 0 && /*#__PURE__*/React.createElement(View, {
412
+ topSpacer: topH > 0 && /*#__PURE__*/React.createElement(View, {
430
413
  style: {
431
- height: topHeight
414
+ height: topH
432
415
  }
433
416
  }),
434
- bottomSpacer: bottomHeight > 0 && /*#__PURE__*/React.createElement(View, {
417
+ bottomSpacer: bottomH > 0 && /*#__PURE__*/React.createElement(View, {
435
418
  style: {
436
- height: bottomHeight
419
+ height: bottomH
437
420
  }
438
421
  })
439
422
  };
440
- }, [data, isWeb, itemHeight, maxIndex, renderItem, safeSelectedIndex, total, visibleCount, webIndex, webVelocityBucket, webVirtualEnabled]);
423
+ }, [data, isWeb, itemHeight, maxIdx, renderItem, safeSelIdx, total, visibleCnt, webIdx, webVelocityBucket, webVirtualEnabled]);
441
424
  const webTransform = useMemo(() => ({
442
425
  transform: [{
443
426
  translateY: webOffset
@@ -445,7 +428,7 @@ const WheelPickerInner = ({
445
428
  }), [webOffset]);
446
429
  const webTransitionStyle = useMemo(() => webTransition ? {
447
430
  transitionProperty: 'transform',
448
- transitionDuration: `${webTransition}ms`,
431
+ transitionDuration: webTransition + 'ms',
449
432
  transitionTimingFunction: 'cubic-bezier(0.23, 1, 0.68, 1)',
450
433
  willChange: 'transform'
451
434
  } : undefined, [webTransition]);
@@ -460,7 +443,7 @@ const WheelPickerInner = ({
460
443
  onPanResponderGrant: () => {
461
444
  stopRaf();
462
445
  pendingIndexRef.current = null;
463
- notifyInteractStart();
446
+ notifyStart();
464
447
  setWebTransition(0);
465
448
  startOffsetRef.current = webOffsetRef.current;
466
449
  startTimeRef.current = Date.now();
@@ -468,7 +451,7 @@ const WheelPickerInner = ({
468
451
  onPanResponderMove: (_, gesture) => {
469
452
  if (readOnly) return;
470
453
  setVelocityBucket(gesture.vy);
471
- const next = clamp(startOffsetRef.current + gesture.dy, minOffset, 0);
454
+ const next = clamp(startOffsetRef.current + gesture.dy, minOff, 0);
472
455
  webOffsetRef.current = next;
473
456
  if (typeof requestAnimationFrame === 'undefined') {
474
457
  setWebOffset(next);
@@ -485,9 +468,9 @@ const WheelPickerInner = ({
485
468
  setVelocityBucket(0);
486
469
  const duration = Date.now() - startTimeRef.current;
487
470
  const distance = gesture.dy;
488
- let target = clamp(startOffsetRef.current + distance, minOffset, 0);
471
+ let target = clamp(startOffsetRef.current + distance, minOff, 0);
489
472
  if (shouldMomentum(distance, duration)) {
490
- target = momentumTarget(distance, duration, startOffsetRef.current, itemHeight, minOffset);
473
+ target = momentumTarget(distance, duration, startOffsetRef.current, itemHeight, minOff);
491
474
  }
492
475
  const {
493
476
  index
@@ -496,37 +479,99 @@ const WheelPickerInner = ({
496
479
  },
497
480
  onPanResponderTerminationRequest: () => false,
498
481
  onPanResponderTerminate: () => {
499
- notifyInteractEnd();
482
+ notifyEnd();
500
483
  setWebTransition(0);
501
484
  }
502
- }), [data, itemHeight, minOffset, notifyInteractEnd, notifyInteractStart, readOnly, setVelocityBucket, startWebSnap, stopRaf, total]);
485
+ }), [data, itemHeight, minOff, notifyEnd, notifyStart, readOnly, setVelocityBucket, startWebSnap, stopRaf, total]);
486
+ const shouldCapture = !readOnly;
487
+ const handleResponderCapture = useCallback(() => shouldCapture, [shouldCapture]);
488
+ const nativeContainerStyle = useMemo(() => ({
489
+ paddingVertical: spacerHeight
490
+ }), [spacerHeight]);
491
+ const handleScroll = useCallback(e => {
492
+ lastOffsetRef.current = e.nativeEvent.contentOffset.y;
493
+ }, []);
494
+ const onDragStart = useCallback(() => {
495
+ momentumRef.current = false;
496
+ clearDragEndTimer();
497
+ notifyStart();
498
+ }, [clearDragEndTimer, notifyStart]);
499
+ const handleScrollEndDrag = useCallback(e => {
500
+ if (readOnly) return;
501
+ const y = e.nativeEvent.contentOffset.y;
502
+ lastOffsetRef.current = y;
503
+ clearDragEndTimer();
504
+ dragEndTimerRef.current = setTimeout(() => {
505
+ if (!momentumRef.current) {
506
+ emitIdx(lastOffsetRef.current, true);
507
+ notifyEnd();
508
+ }
509
+ }, 80);
510
+ }, [clearDragEndTimer, emitIdx, notifyEnd, readOnly]);
511
+ const handleMomentumScrollBegin = useCallback(() => {
512
+ momentumRef.current = true;
513
+ clearDragEndTimer();
514
+ notifyStart();
515
+ }, [clearDragEndTimer, notifyStart]);
516
+ const onMomEnd = useCallback(e => {
517
+ momentumRef.current = false;
518
+ clearDragEndTimer();
519
+ const y = e.nativeEvent.contentOffset.y;
520
+ lastOffsetRef.current = y;
521
+ emitIdx(y, false);
522
+ notifyEnd();
523
+ }, [clearDragEndTimer, emitIdx, notifyEnd]);
503
524
  if (isWeb) {
504
525
  return /*#__PURE__*/React.createElement(View, _extends({
505
- style: [wheelStyles.column, {
526
+ style: [W.column, {
506
527
  height: containerHeight
507
- }, webOnlyStyles.grab],
528
+ }, W.grab],
508
529
  onWheel: handleWheel
509
530
  }, panResponder.panHandlers), /*#__PURE__*/React.createElement(View, {
510
531
  style: indicatorStyle,
511
532
  pointerEvents: "none"
533
+ }, /*#__PURE__*/React.createElement(View, {
534
+ style: createHairlineView({
535
+ position: 'top',
536
+ color: indicatorColor,
537
+ left: 0,
538
+ right: 0
539
+ })
512
540
  }), /*#__PURE__*/React.createElement(View, {
513
- style: [webTransform, isWeb ? webTransitionStyle : undefined],
541
+ style: createHairlineView({
542
+ position: 'bottom',
543
+ color: indicatorColor,
544
+ left: 0,
545
+ right: 0
546
+ })
547
+ })), /*#__PURE__*/React.createElement(View, {
548
+ style: [webTransform, webTransitionStyle],
514
549
  onTransitionEnd: handleWebTransitionEnd
515
550
  }, /*#__PURE__*/React.createElement(Spacer, null), webRender.topSpacer, webRender.items, webRender.bottomSpacer, /*#__PURE__*/React.createElement(Spacer, null)));
516
551
  }
517
- const shouldCapture = !readOnly;
518
- const contentContainerStyle = useMemo(() => ({
519
- paddingVertical: spacerHeight
520
- }), [spacerHeight]);
521
552
  return /*#__PURE__*/React.createElement(View, {
522
- style: [wheelStyles.column, {
553
+ style: [W.column, {
523
554
  height: containerHeight
524
555
  }],
525
556
  collapsable: false
526
557
  }, /*#__PURE__*/React.createElement(View, {
527
558
  style: indicatorStyle,
528
559
  pointerEvents: "none"
529
- }), /*#__PURE__*/React.createElement(ScrollView, {
560
+ }, /*#__PURE__*/React.createElement(View, {
561
+ style: createHairlineView({
562
+ position: 'top',
563
+ color: indicatorColor,
564
+ left: 0,
565
+ right: 0
566
+ })
567
+ }), /*#__PURE__*/React.createElement(View, {
568
+ style: createHairlineView({
569
+ position: 'bottom',
570
+ color: indicatorColor,
571
+ left: 0,
572
+ right: 0
573
+ })
574
+ })), /*#__PURE__*/React.createElement(ScrollView, {
530
575
  ref: scrollRef,
531
576
  showsVerticalScrollIndicator: false,
532
577
  scrollEventThrottle: effectiveScrollThrottle,
@@ -536,61 +581,26 @@ const WheelPickerInner = ({
536
581
  bounces: false,
537
582
  overScrollMode: "never",
538
583
  nestedScrollEnabled: true,
539
- contentContainerStyle: contentContainerStyle,
540
- onStartShouldSetResponderCapture: () => shouldCapture,
541
- onMoveShouldSetResponderCapture: () => shouldCapture,
542
- onScroll: e => {
543
- lastOffsetRef.current = e.nativeEvent.contentOffset.y;
544
- },
545
- onScrollBeginDrag: () => {
546
- momentumRef.current = false;
547
- clearDragEndTimer();
548
- notifyInteractStart();
549
- },
550
- onScrollEndDrag: e => {
551
- if (readOnly) return;
552
- const y = e.nativeEvent.contentOffset.y;
553
- lastOffsetRef.current = y;
554
- clearDragEndTimer();
555
- dragEndTimerRef.current = setTimeout(() => {
556
- if (!momentumRef.current) {
557
- emitIndexFromOffset(lastOffsetRef.current, true);
558
- notifyInteractEnd();
559
- }
560
- }, 80);
561
- },
562
- onMomentumScrollBegin: () => {
563
- momentumRef.current = true;
564
- clearDragEndTimer();
565
- notifyInteractStart();
566
- },
567
- onMomentumScrollEnd: e => {
568
- momentumRef.current = false;
569
- clearDragEndTimer();
570
- const y = e.nativeEvent.contentOffset.y;
571
- lastOffsetRef.current = y;
572
- emitIndexFromOffset(y, false);
573
- notifyInteractEnd();
574
- },
584
+ contentContainerStyle: nativeContainerStyle,
585
+ onStartShouldSetResponderCapture: handleResponderCapture,
586
+ onMoveShouldSetResponderCapture: handleResponderCapture,
587
+ onScroll: handleScroll,
588
+ onScrollBeginDrag: onDragStart,
589
+ onScrollEndDrag: handleScrollEndDrag,
590
+ onMomentumScrollBegin: handleMomentumScrollBegin,
591
+ onMomentumScrollEnd: onMomEnd,
575
592
  scrollEnabled: !readOnly
576
593
  }, data.map((item, index) => /*#__PURE__*/React.createElement(WheelPickerItem, {
577
594
  key: `${index}-${String(item.value ?? '')}`,
578
595
  item: item,
579
596
  index: index,
580
597
  itemHeight: itemHeight,
581
- active: index === safeSelectedIndex,
598
+ active: index === safeSelIdx,
582
599
  disabled: !!item.disabled,
583
600
  renderItem: renderItem
584
601
  }))));
585
602
  };
586
603
  const WheelPicker = /*#__PURE__*/React.memo(WheelPickerInner);
587
- const webOnlyStyles = StyleSheet.create({
588
- grab: {
589
- cursor: 'pointer',
590
- userSelect: 'none',
591
- touchAction: 'none'
592
- }
593
- });
594
604
  export function usePickerValue({
595
605
  columns,
596
606
  valueProp,
@@ -599,13 +609,15 @@ export function usePickerValue({
599
609
  onChange,
600
610
  onConfirm
601
611
  }) {
602
- const preparedColumns = useMemo(() => prepareColumns(columns), [columns]);
612
+ const prep = useMemo(() => prepareColumns(columns), [columns]);
603
613
  const isControlled = valueProp !== undefined;
604
- const [innerValue, setInnerValue] = useState(() => {
605
- const initial = toArrayValue(valueProp ?? defaultValue);
606
- return normalizePicker(preparedColumns, initial).values;
607
- });
614
+ const onChangeRef = useRef(onChange);
615
+ const onConfirmRef = useRef(onConfirm);
616
+ onChangeRef.current = onChange;
617
+ onConfirmRef.current = onConfirm;
618
+ const [innerValue, setInnerValue] = useState(() => normalizePicker(prep, toArrayValue(valueProp ?? defaultValue)).values);
608
619
  const innerValueRef = useRef(innerValue);
620
+ innerValueRef.current = innerValue;
609
621
  const commitValue = useCallback(next => {
610
622
  innerValueRef.current = next;
611
623
  setInnerValue(next);
@@ -613,91 +625,79 @@ export function usePickerValue({
613
625
  useEffect(() => {
614
626
  if (!isControlled) return;
615
627
  const next = toArrayValue(valueProp);
616
- if (!shallowEqualArray(innerValueRef.current, next)) {
617
- commitValue(next);
618
- }
628
+ if (!shallowEqualArray(innerValueRef.current, next)) commitValue(next);
619
629
  }, [commitValue, isControlled, valueProp]);
620
- const normalized = useMemo(() => normalizePicker(preparedColumns, innerValue), [preparedColumns, innerValue]);
630
+ const norm = useMemo(() => normalizePicker(prep, innerValue), [prep, innerValue]);
621
631
  useEffect(() => {
622
632
  if (isControlled) return;
623
- if (!shallowEqualArray(innerValue, normalized.values)) {
624
- commitValue(normalized.values);
625
- onChange?.(normalized.values, normalized.options);
626
- if (emitConfirmOnAutoSelect) {
627
- onConfirm?.(normalized.values, normalized.options);
628
- }
633
+ if (!shallowEqualArray(innerValue, norm.values)) {
634
+ commitValue(norm.values);
635
+ onChangeRef.current?.(norm.values, norm.options);
636
+ if (emitConfirmOnAutoSelect) onConfirmRef.current?.(norm.values, norm.options);
629
637
  }
630
- }, [commitValue, emitConfirmOnAutoSelect, innerValue, isControlled, normalized, onChange, onConfirm]);
631
- const handleSelect = useCallback((option, columnIndex) => {
638
+ }, [commitValue, emitConfirmOnAutoSelect, innerValue, isControlled, norm]);
639
+ const handleSelect = useCallback((option, colIdx) => {
632
640
  const next = [...innerValueRef.current];
633
- next[columnIndex] = option.value;
634
- if (preparedColumns.type === 'cascade') {
635
- next.length = columnIndex + 1;
636
- }
637
- const final = normalizePicker(preparedColumns, next);
641
+ next[colIdx] = option.value;
642
+ if (prep.type === 'cascade') next.length = colIdx + 1;
643
+ const final = normalizePicker(prep, next);
638
644
  if (shallowEqualArray(innerValueRef.current, final.values)) return;
639
645
  commitValue(final.values);
640
- onChange?.(final.values, final.options);
641
- }, [commitValue, onChange, preparedColumns]);
646
+ onChangeRef.current?.(final.values, final.options);
647
+ }, [commitValue, prep]);
642
648
  const handleConfirm = useCallback(() => {
643
- onConfirm?.(normalized.values, normalized.options);
644
- }, [normalized, onConfirm]);
649
+ onConfirmRef.current?.(norm.values, norm.options);
650
+ }, [norm]);
645
651
  return {
646
- preparedColumns,
647
- normalized,
652
+ preparedColumns: prep,
653
+ normalized: norm,
648
654
  handleSelect,
649
655
  handleConfirm
650
656
  };
651
657
  }
652
658
  const getVisibleCount = count => {
653
- const normalized = isFiniteNumber(count) ? Math.max(3, Math.floor(count)) : 5;
654
- return normalized % 2 === 0 ? normalized + 1 : normalized;
659
+ const n = isFiniteNumber(count) ? Math.max(3, Math.floor(count)) : 5;
660
+ return n % 2 === 0 ? n + 1 : n;
655
661
  };
656
662
  const GRADIENT_OVERLAY_ALPHA = 0.25;
657
663
  const GRADIENT_STEPS = [0.95, 0.75, 0.55, 0.35];
658
- const GRADIENT_STEPS_REVERSED = [...GRADIENT_STEPS].reverse();
664
+ const GRADIENT_STEPS_REVERSED = [0.35, 0.55, 0.75, 0.95];
659
665
  const GradientMask = ({
660
666
  height,
661
667
  color,
662
668
  position,
663
669
  maskType
664
670
  }) => {
665
- const isWeb = Platform.OS === 'web';
666
- const baseStyle = useMemo(() => [styles.gradientMask, {
671
+ const baseStyle = [S.gMask, {
667
672
  height
668
673
  }, position === 'top' ? {
669
674
  top: 0
670
675
  } : {
671
676
  bottom: 0
672
- }], [height, position]);
673
- const overlayColor = useMemo(() => withAlpha(color, GRADIENT_OVERLAY_ALPHA), [color]);
674
- if (maskType === 'solid') {
675
- return /*#__PURE__*/React.createElement(View, {
676
- pointerEvents: "none",
677
- style: [...baseStyle, {
678
- backgroundColor: withAlpha(color, 0.9)
679
- }]
680
- });
681
- }
682
- if (isWeb) {
677
+ }];
678
+ const overlayColor = withAlpha(color, GRADIENT_OVERLAY_ALPHA);
679
+ if (maskType === 'solid') return /*#__PURE__*/React.createElement(View, {
680
+ pointerEvents: "none",
681
+ style: [...baseStyle, {
682
+ backgroundColor: withAlpha(color, 0.9)
683
+ }]
684
+ });
685
+ if (Platform.OS === 'web') {
683
686
  const angle = position === 'top' ? '180deg' : '0deg';
684
- const gradientStart = withAlpha(color, 0.98);
685
- const gradientEnd = withAlpha(color, 0.4);
686
687
  return /*#__PURE__*/React.createElement(View, {
687
688
  pointerEvents: "none",
688
689
  style: [...baseStyle, {
689
690
  backgroundColor: overlayColor,
690
- backgroundImage: `linear-gradient(${angle}, ${gradientStart}, ${gradientEnd})`
691
+ backgroundImage: `linear-gradient(${angle}, ${withAlpha(color, 0.98)}, ${withAlpha(color, 0.4)})`
691
692
  }]
692
693
  });
693
694
  }
694
- const steps = position === 'top' ? GRADIENT_STEPS : GRADIENT_STEPS_REVERSED;
695
695
  return /*#__PURE__*/React.createElement(View, {
696
696
  pointerEvents: "none",
697
697
  style: [...baseStyle, {
698
698
  backgroundColor: overlayColor
699
699
  }]
700
- }, steps.map((opacity, idx) => /*#__PURE__*/React.createElement(View, {
700
+ }, (position === 'top' ? GRADIENT_STEPS : GRADIENT_STEPS_REVERSED).map((opacity, idx) => /*#__PURE__*/React.createElement(View, {
701
701
  key: idx,
702
702
  style: {
703
703
  flex: 1,
@@ -723,74 +723,85 @@ const PickerColumn = /*#__PURE__*/React.memo(props => {
723
723
  swipeDuration
724
724
  } = props;
725
725
  const restVisible = Math.max(1, Math.floor((visibleItemCount - 1) / 2));
726
- const valueIndexMap = useMemo(() => new Map(options.map((option, idx) => [option.value, idx])), [options]);
727
- const selectedIndex = useMemo(() => {
726
+ const valueIndexMap = useMemo(() => new Map(options.map((opt, idx) => [opt.value, idx])), [options]);
727
+ const selIdx = useMemo(() => {
728
728
  if (!options.length) return 0;
729
729
  const idx = valueIndexMap.get(value);
730
- const startIndex = typeof idx === 'number' && idx >= 0 ? idx : 0;
731
- return findEnabledIndex(options, startIndex);
730
+ const startIdx = typeof idx === 'number' && idx >= 0 ? idx : 0;
731
+ return findEnabledIndex(options, startIdx);
732
732
  }, [options, value, valueIndexMap]);
733
733
  const handleChange = useCallback(index => {
734
- const target = findEnabledIndex(options, index);
735
- const option = options[target];
736
- if (!option || option.disabled) return;
737
- onSelect(option, columnIndex, target);
734
+ const tgt = findEnabledIndex(options, index);
735
+ const opt = options[tgt];
736
+ if (!opt || opt.disabled) return;
737
+ onSelect(opt, columnIndex, tgt);
738
738
  }, [columnIndex, onSelect, options]);
739
+ const {
740
+ text: cText,
741
+ textDisabled: cDisabled,
742
+ textMuted: cMuted
743
+ } = tokens.colors;
744
+ const optFont = {
745
+ fontSize: tokens.typography.optionSize,
746
+ fontFamily: tokens.typography.fontFamily,
747
+ fontWeight: tokens.typography.optionWeight
748
+ };
749
+ const renderItemStable = useCallback((item, _index, meta) => {
750
+ const {
751
+ active = false,
752
+ disabled = false
753
+ } = meta ?? {};
754
+ const clr = disabled ? cDisabled : active ? cText : cMuted;
755
+ const cnt = optionRender ? optionRender(item, {
756
+ columnIndex,
757
+ active
758
+ }) : item.label ?? item.value;
759
+ const testID = getOptionTestID?.(item, {
760
+ columnIndex,
761
+ active
762
+ });
763
+ const a11y = getOptionA11yLabel?.(item, {
764
+ columnIndex,
765
+ active
766
+ });
767
+ return /*#__PURE__*/React.createElement(View, {
768
+ style: [W.option, {
769
+ opacity: disabled ? 0.5 : 1,
770
+ minHeight: itemHeight
771
+ }],
772
+ testID: testID,
773
+ accessible: !!a11y,
774
+ accessibilityLabel: a11y
775
+ }, isText(cnt) ? /*#__PURE__*/React.createElement(Text, {
776
+ numberOfLines: 1,
777
+ style: [S.optTxt, optFont, {
778
+ color: clr
779
+ }]
780
+ }, cnt) : cnt);
781
+ }, [cText, cDisabled, cMuted, columnIndex, getOptionA11yLabel, getOptionTestID, itemHeight, optFont, optionRender]);
739
782
  return /*#__PURE__*/React.createElement(View, {
740
- style: [styles.column, {
783
+ style: [W.column, {
741
784
  height: itemHeight * visibleItemCount
742
785
  }]
743
786
  }, /*#__PURE__*/React.createElement(WheelPicker, {
744
787
  data: options,
745
788
  itemHeight: itemHeight,
746
789
  visibleRest: restVisible,
747
- selectedIndex: Math.max(0, selectedIndex),
790
+ selectedIndex: Math.max(0, selIdx),
748
791
  onChange: handleChange,
749
792
  readOnly: readOnly,
750
793
  indicatorColor: tokens.colors.indicator,
751
794
  decelerationRate: decelerationRate,
752
795
  scrollEventThrottle: scrollEventThrottle,
753
796
  swipeDuration: swipeDuration,
754
- renderItem: (item, _index, meta) => {
755
- const active = meta?.active ?? false;
756
- const disabled = meta?.disabled ?? false;
757
- const textColor = disabled ? tokens.colors.textDisabled : active ? tokens.colors.text : tokens.colors.textMuted;
758
- const content = optionRender ? optionRender(item, {
759
- columnIndex,
760
- active
761
- }) : item.label ?? item.value;
762
- const testID = getOptionTestID?.(item, {
763
- columnIndex,
764
- active
765
- });
766
- const a11yLabel = getOptionA11yLabel?.(item, {
767
- columnIndex,
768
- active
769
- });
770
- return /*#__PURE__*/React.createElement(View, {
771
- style: [styles.option, {
772
- opacity: disabled ? 0.5 : 1,
773
- minHeight: itemHeight
774
- }],
775
- testID: testID,
776
- accessible: !!a11yLabel,
777
- accessibilityLabel: a11yLabel
778
- }, isText(content) ? /*#__PURE__*/React.createElement(Text, {
779
- numberOfLines: 1,
780
- style: [styles.optionText, {
781
- color: textColor,
782
- fontSize: tokens.typography.optionSize,
783
- fontFamily: tokens.typography.fontFamily,
784
- fontWeight: tokens.typography.optionWeight
785
- }]
786
- }, content) : content);
787
- }
797
+ renderItem: renderItemStable
788
798
  }));
789
799
  });
790
- const Picker = props => {
800
+ const PickerImpl = props => {
791
801
  const {
792
802
  tokensOverride
793
803
  } = props;
804
+ const locale = useLocale();
794
805
  const tokens = usePickerTokens(tokensOverride);
795
806
  const {
796
807
  columns = [],
@@ -799,8 +810,8 @@ const Picker = props => {
799
810
  title,
800
811
  showToolbar = tokens.defaults.showToolbar,
801
812
  toolbarPosition = tokens.defaults.toolbarPosition,
802
- confirmButtonText = '确定',
803
- cancelButtonText = '取消',
813
+ confirmButtonText = locale?.confirm ?? 'Confirm',
814
+ cancelButtonText = locale?.cancel ?? 'Cancel',
804
815
  itemHeight = tokens.defaults.itemHeight,
805
816
  visibleItemCount: visibleItemCountProp = tokens.defaults.visibleItemCount,
806
817
  loading = false,
@@ -827,12 +838,12 @@ const Picker = props => {
827
838
  testID,
828
839
  ...rest
829
840
  } = props;
830
- const visibleItemCount = getVisibleCount(visibleItemCountProp ?? tokens.defaults.visibleItemCount);
841
+ const visCnt = getVisibleCount(visibleItemCountProp ?? tokens.defaults.visibleItemCount);
831
842
  const {
832
- normalized,
843
+ normalized: norm,
833
844
  handleSelect,
834
845
  handleConfirm,
835
- preparedColumns
846
+ preparedColumns: prep
836
847
  } = usePickerValue({
837
848
  columns,
838
849
  valueProp,
@@ -841,52 +852,33 @@ const Picker = props => {
841
852
  onChange,
842
853
  onConfirm
843
854
  });
844
- const isCascade = preparedColumns.type === 'cascade';
845
- const renderActionContent = (content, color) => {
846
- if (/*#__PURE__*/React.isValidElement(content)) return /*#__PURE__*/React.createElement(View, {
847
- style: {
848
- minWidth: 44,
849
- alignItems: 'center',
850
- justifyContent: 'center'
851
- }
852
- }, content);
853
- if (isText(content)) return /*#__PURE__*/React.createElement(Text, {
854
- numberOfLines: 1,
855
- style: [styles.actionText, {
856
- color,
857
- fontSize: tokens.typography.toolbarSize,
858
- fontFamily: tokens.typography.fontFamily,
859
- fontWeight: tokens.typography.toolbarWeight
860
- }]
861
- }, content);
862
- return /*#__PURE__*/React.createElement(View, {
863
- style: {
864
- minWidth: 44
865
- }
866
- });
867
- };
868
- const renderTitleContent = content => {
869
- if (content == null) return /*#__PURE__*/React.createElement(View, null);
870
- if (/*#__PURE__*/React.isValidElement(content)) return /*#__PURE__*/React.createElement(View, {
871
- style: [styles.title, {
872
- alignItems: 'center',
873
- justifyContent: 'center'
874
- }]
875
- }, content);
876
- return /*#__PURE__*/React.createElement(Text, {
877
- style: [styles.title, {
878
- fontSize: tokens.typography.toolbarSize,
879
- fontFamily: tokens.typography.fontFamily,
880
- color: tokens.colors.text,
881
- fontWeight: tokens.typography.toolbarWeight
882
- }],
883
- numberOfLines: 1
884
- }, content);
855
+ const isCascade = prep.type === 'cascade';
856
+ const toolbarFont = {
857
+ fontSize: tokens.typography.toolbarSize,
858
+ fontFamily: tokens.typography.fontFamily,
859
+ fontWeight: tokens.typography.toolbarWeight
885
860
  };
861
+ const renderActionContent = (content, color) => /*#__PURE__*/React.isValidElement(content) ? /*#__PURE__*/React.createElement(View, {
862
+ style: S.actW
863
+ }, content) : isText(content) ? /*#__PURE__*/React.createElement(Text, {
864
+ numberOfLines: 1,
865
+ style: [S.actTxt, toolbarFont, {
866
+ color
867
+ }]
868
+ }, content) : /*#__PURE__*/React.createElement(View, {
869
+ style: S.actW
870
+ });
871
+ const renderTitleContent = content => content == null ? /*#__PURE__*/React.createElement(View, null) : /*#__PURE__*/React.isValidElement(content) ? /*#__PURE__*/React.createElement(View, {
872
+ style: S.ttlW
873
+ }, content) : /*#__PURE__*/React.createElement(Text, {
874
+ style: [S.title, toolbarFont, {
875
+ color: tokens.colors.text
876
+ }],
877
+ numberOfLines: 1
878
+ }, content);
886
879
  const toolbar = showToolbar ? /*#__PURE__*/React.createElement(View, {
887
- style: [styles.toolbar, {
880
+ style: [S.toolbar, {
888
881
  height: tokens.spacing.toolbarHeight,
889
- borderColor: tokens.colors.indicator,
890
882
  paddingHorizontal: tokens.spacing.actionPadding
891
883
  }]
892
884
  }, /*#__PURE__*/React.createElement(Pressable, {
@@ -895,22 +887,29 @@ const Picker = props => {
895
887
  }, renderActionContent(cancelButtonText, tokens.colors.cancel)), renderTitleContent(title), /*#__PURE__*/React.createElement(Pressable, {
896
888
  onPress: handleConfirm,
897
889
  accessibilityRole: "button"
898
- }, renderActionContent(confirmButtonText, tokens.colors.confirm))) : null;
899
- const wrapperHeight = itemHeight * visibleItemCount;
900
- const maskVisibleCount = Math.max(1, Math.floor((visibleItemCount - 1) / 2));
901
- const indicatorOffset = itemHeight * maskVisibleCount;
902
- const maskHeight = indicatorOffset;
903
- const hasColumns = normalized.columns.length > 0;
904
- const effectiveMaskColor = maskColor ?? tokens.colors.mask;
905
- const columnsContent = hasColumns ? normalized.columns.map((column, columnIndex) => {
906
- const key = isCascade ? `${columnIndex}-${normalized.values.slice(0, columnIndex).map(String).join('|')}` : String(columnIndex);
890
+ }, renderActionContent(confirmButtonText, tokens.colors.confirm)), /*#__PURE__*/React.createElement(View, {
891
+ style: createHairlineView({
892
+ position: 'bottom',
893
+ color: tokens.colors.indicator,
894
+ left: 0,
895
+ right: 0
896
+ })
897
+ })) : null;
898
+ const wrapperH = itemHeight * visCnt;
899
+ const maskVisCnt = Math.max(1, Math.floor((visCnt - 1) / 2));
900
+ const indicatorOff = itemHeight * maskVisCnt;
901
+ const maskH = indicatorOff;
902
+ const hasCols = norm.columns.length > 0;
903
+ const effMaskColor = maskColor ?? tokens.colors.mask;
904
+ const columnsContent = hasCols ? norm.columns.map((column, colIdx) => {
905
+ const key = isCascade ? `${colIdx}-${norm.values.slice(0, colIdx).map(String).join('|')}` : String(colIdx);
907
906
  return /*#__PURE__*/React.createElement(PickerColumn, {
908
907
  key: key,
909
- columnIndex: columnIndex,
908
+ columnIndex: colIdx,
910
909
  options: column,
911
- value: normalized.values[columnIndex],
910
+ value: norm.values[colIdx],
912
911
  itemHeight: itemHeight,
913
- visibleItemCount: visibleItemCount,
912
+ visibleItemCount: visCnt,
914
913
  decelerationRate: decelerationRate,
915
914
  scrollEventThrottle: scrollEventThrottle,
916
915
  optionRender: optionRender,
@@ -923,43 +922,55 @@ const Picker = props => {
923
922
  });
924
923
  }) : null;
925
924
  return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
926
- style: [styles.container, {
925
+ style: [{
927
926
  backgroundColor: tokens.colors.background,
928
927
  borderRadius: tokens.radius.container
929
928
  }, style],
930
929
  testID: testID
931
930
  }), toolbarPosition === 'top' && toolbar, /*#__PURE__*/React.createElement(View, {
932
- style: [styles.body, {
933
- height: wrapperHeight
931
+ style: [S.body, {
932
+ height: wrapperH
934
933
  }]
935
934
  }, /*#__PURE__*/React.createElement(View, {
936
- style: styles.columns,
935
+ style: S.columns,
937
936
  pointerEvents: loading ? 'none' : 'auto'
938
- }, columnsTop, columnsContent, columnsBottom, hasColumns && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
937
+ }, columnsTop, columnsContent, columnsBottom, hasCols && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
939
938
  pointerEvents: "none",
940
- style: [styles.indicator, {
941
- top: indicatorOffset,
942
- height: itemHeight,
943
- borderColor: tokens.colors.indicator
939
+ style: [S.indicator, {
940
+ top: indicatorOff,
941
+ height: itemHeight
944
942
  }]
945
- }), /*#__PURE__*/React.createElement(GradientMask, {
943
+ }, /*#__PURE__*/React.createElement(View, {
944
+ style: createHairlineView({
945
+ position: 'top',
946
+ color: tokens.colors.indicator,
947
+ left: 0,
948
+ right: 0
949
+ })
950
+ }), /*#__PURE__*/React.createElement(View, {
951
+ style: createHairlineView({
952
+ position: 'bottom',
953
+ color: tokens.colors.indicator,
954
+ left: 0,
955
+ right: 0
956
+ })
957
+ })), /*#__PURE__*/React.createElement(GradientMask, {
946
958
  position: "top",
947
- height: maskHeight,
948
- color: effectiveMaskColor,
959
+ height: maskH,
960
+ color: effMaskColor,
949
961
  maskType: maskType
950
962
  }), /*#__PURE__*/React.createElement(GradientMask, {
951
963
  position: "bottom",
952
- height: maskHeight,
953
- color: effectiveMaskColor,
964
+ height: maskH,
965
+ color: effMaskColor,
954
966
  maskType: maskType
955
967
  }))), loading && /*#__PURE__*/React.createElement(View, {
956
- style: [styles.loading, {
968
+ style: [S.loading, {
957
969
  backgroundColor: tokens.colors.loadingMask
958
970
  }]
959
971
  }, /*#__PURE__*/React.createElement(Loading, null))), toolbarPosition === 'bottom' && toolbar);
960
972
  };
961
- const styles = StyleSheet.create({
962
- container: {},
973
+ const S = StyleSheet.create({
963
974
  body: {
964
975
  position: 'relative',
965
976
  overflow: 'hidden'
@@ -968,25 +979,16 @@ const styles = StyleSheet.create({
968
979
  flex: 1,
969
980
  flexDirection: 'row'
970
981
  },
971
- column: {
972
- flex: 1
973
- },
974
- option: {
975
- justifyContent: 'center',
976
- alignItems: 'center'
977
- },
978
- optionText: {
982
+ optTxt: {
979
983
  includeFontPadding: false
980
984
  },
981
985
  indicator: {
982
986
  position: 'absolute',
983
987
  left: 0,
984
988
  right: 0,
985
- borderTopWidth: StyleSheet.hairlineWidth,
986
- borderBottomWidth: StyleSheet.hairlineWidth,
987
989
  zIndex: 3
988
990
  },
989
- gradientMask: {
991
+ gMask: {
990
992
  position: 'absolute',
991
993
  left: 0,
992
994
  right: 0,
@@ -995,17 +997,26 @@ const styles = StyleSheet.create({
995
997
  toolbar: {
996
998
  flexDirection: 'row',
997
999
  alignItems: 'center',
998
- justifyContent: 'space-between',
999
- borderBottomWidth: StyleSheet.hairlineWidth
1000
+ justifyContent: 'space-between'
1000
1001
  },
1001
1002
  title: {
1002
1003
  flex: 1,
1003
1004
  textAlign: 'center'
1004
1005
  },
1005
- actionText: {
1006
+ ttlW: {
1007
+ flex: 1,
1008
+ alignItems: 'center',
1009
+ justifyContent: 'center'
1010
+ },
1011
+ actTxt: {
1006
1012
  minWidth: 44,
1007
1013
  textAlign: 'center'
1008
1014
  },
1015
+ actW: {
1016
+ minWidth: 44,
1017
+ alignItems: 'center',
1018
+ justifyContent: 'center'
1019
+ },
1009
1020
  loading: {
1010
1021
  position: 'absolute',
1011
1022
  top: 0,
@@ -1016,5 +1027,5 @@ const styles = StyleSheet.create({
1016
1027
  justifyContent: 'center'
1017
1028
  }
1018
1029
  });
1019
- Picker.displayName = 'Picker';
1030
+ const Picker = /*#__PURE__*/React.memo(PickerImpl);
1020
1031
  export default Picker;