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
@@ -1,27 +1,23 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { memo, useCallback, useEffect, useImperativeHandle, useRef, useState, useMemo, Children, isValidElement, Fragment } from 'react';
2
+ import React, { memo, useCallback, useEffect, useImperativeHandle, useRef, useState, useMemo, Children, isValidElement } from 'react';
3
3
  import { Animated, Pressable, StyleSheet, Text, ScrollView, View, Platform } from 'react-native';
4
4
  import { useAriaPress, useControllableValue } from '../../hooks';
5
+ import { useReducedMotion } from '../../hooks/animation';
6
+ import { createHairlineView } from '../../utils/hairline';
5
7
  import { parseNumberLike } from '../../utils/number';
6
8
  import { isBoolean, isFunction, isObject, isRenderable, isText } from '../../utils/validate';
7
9
  import { useTabsTokens } from './tokens';
8
10
  const TabPane = () => null;
9
11
  TabPane.displayName = 'Tabs.TabPane';
10
- const canUseRaf = typeof requestAnimationFrame !== 'undefined' && isFunction(requestAnimationFrame) && typeof cancelAnimationFrame !== 'undefined' && isFunction(cancelAnimationFrame);
11
- const requestFrame = canUseRaf ? cb => requestAnimationFrame(cb) : cb => setTimeout(cb, 16);
12
+ const hasRaf = typeof requestAnimationFrame === 'function' && typeof cancelAnimationFrame === 'function';
13
+ const requestFrame = hasRaf ? requestAnimationFrame : cb => setTimeout(cb, 16);
12
14
  const cancelFrame = id => {
13
- if (id == null) return;
14
- if (canUseRaf) {
15
- cancelAnimationFrame(id);
16
- } else {
17
- clearTimeout(id);
18
- }
15
+ if (id != null) (hasRaf ? cancelAnimationFrame : clearTimeout)(id);
19
16
  };
20
17
  const isTabPaneElement = child => {
21
18
  if (! /*#__PURE__*/React.isValidElement(child)) return false;
22
19
  if (child.type === TabPane) return true;
23
- const type = child.type;
24
- return type.displayName === 'Tabs.TabPane';
20
+ return child.type.displayName === 'Tabs.TabPane';
25
21
  };
26
22
  const useTabsAnimation = ({
27
23
  type,
@@ -36,43 +32,52 @@ const useTabsAnimation = ({
36
32
  layoutMap,
37
33
  navContainerWidthRef
38
34
  }) => {
39
- const indicatorX = useRef(new Animated.Value(0)).current;
40
- const indicatorWidth = useRef(new Animated.Value(0)).current;
41
- const indicatorInitializedRef = useRef(false);
35
+ const indX = useRef(new Animated.Value(0)).current;
36
+ const indW = useRef(new Animated.Value(0)).current;
37
+ const indInitRef = useRef(false);
38
+ const animRef = useRef(null);
42
39
  const animateIndicator = useCallback((name, immediate) => {
43
40
  if (name == null || type !== 'line') return false;
44
- const shouldUseEqualWidth = !scrollable && align !== 'start' && navContainerWidthRef.current > 0 && panes.length > 0;
45
- const index = nameIndexMap.get(name) ?? -1;
46
- const equalTabWidth = shouldUseEqualWidth ? navContainerWidthRef.current / panes.length : 0;
47
- const layout = shouldUseEqualWidth ? {
48
- x: Math.max(index, 0) * equalTabWidth,
49
- width: equalTabWidth
41
+ const eqW = !scrollable && align !== 'start' && navContainerWidthRef.current > 0 && panes.length > 0;
42
+ const idx = nameIndexMap.get(name) ?? -1;
43
+ const eqTabW = eqW ? navContainerWidthRef.current / panes.length : 0;
44
+ const lay = eqW ? {
45
+ x: Math.max(idx, 0) * eqTabW,
46
+ width: eqTabW
50
47
  } : layoutMap.current.get(name);
51
- if (!layout || index < 0) {
52
- return false;
53
- }
54
- const timing = (value, toValue) => Animated.timing(value, {
55
- toValue,
48
+ if (!lay || idx < 0) return false;
49
+ animRef.current?.stop();
50
+ const timing = (v, to) => Animated.timing(v, {
51
+ toValue: to,
56
52
  duration: immediate || !animated ? 0 : resolvedDuration,
57
- useNativeDriver: false
53
+ useNativeDriver: false,
54
+ isInteraction: false
55
+ });
56
+ const tW = resolvedLineWidth ?? lay.width;
57
+ const tX = resolvedLineWidth ? lay.x + (lay.width - tW) / 2 : lay.x;
58
+ const anim = Animated.parallel([timing(indX, tX), timing(indW, tW)]);
59
+ animRef.current = anim;
60
+ anim.start(({
61
+ finished
62
+ }) => {
63
+ if (finished) animRef.current = null;
58
64
  });
59
- const targetWidth = resolvedLineWidth ?? layout.width;
60
- const targetX = resolvedLineWidth ? layout.x + (layout.width - targetWidth) / 2 : layout.x;
61
- Animated.parallel([timing(indicatorX, targetX), timing(indicatorWidth, targetWidth)]).start();
62
65
  return true;
63
- }, [align, animated, indicatorWidth, indicatorX, nameIndexMap, panes.length, resolvedDuration, resolvedLineWidth, scrollable, type, layoutMap, navContainerWidthRef]);
66
+ }, [align, animated, indW, indX, nameIndexMap, panes.length, resolvedDuration, resolvedLineWidth, scrollable, type, layoutMap, navContainerWidthRef]);
64
67
  useEffect(() => {
65
68
  if (currentName == null) return;
66
- const shouldAnimate = indicatorInitializedRef.current;
67
- const didAnimate = animateIndicator(currentName, !shouldAnimate);
68
- if (didAnimate && !indicatorInitializedRef.current) {
69
- indicatorInitializedRef.current = true;
70
- }
69
+ const should = indInitRef.current;
70
+ const did = animateIndicator(currentName, !should);
71
+ if (did && !indInitRef.current) indInitRef.current = true;
71
72
  }, [animateIndicator, currentName]);
73
+ useEffect(() => () => {
74
+ animRef.current?.stop();
75
+ animRef.current = null;
76
+ }, []);
72
77
  return {
73
- indicatorX,
74
- indicatorWidth,
75
- indicatorInitializedRef,
78
+ indicatorX: indX,
79
+ indicatorWidth: indW,
80
+ indicatorInitializedRef: indInitRef,
76
81
  animateIndicator
77
82
  };
78
83
  };
@@ -85,106 +90,86 @@ const useTabsScroll = ({
85
90
  navContainerWidthRef,
86
91
  navContentWidthRef
87
92
  }) => {
88
- const navScrollRef = useRef(null);
89
- const navScrollX = useRef(new Animated.Value(0)).current;
90
- const navScrollAnimRef = useRef(null);
91
- const navAutoScrollingRef = useRef(false);
92
- const navLastScrollXRef = useRef(0);
93
- const navAutoScrollFrameRef = useRef(null);
93
+ const navScrRef = useRef(null);
94
+ const navX = useRef(new Animated.Value(0)).current;
95
+ const navAnimRef = useRef(null);
96
+ const autoScrRef = useRef(false);
97
+ const lastXRef = useRef(0);
98
+ const frameRef = useRef(null);
94
99
  const scrollIntoView = useCallback(immediate => {
95
100
  if (!scrollable || currentName == null) return;
96
- const layout = layoutMap.current.get(currentName);
97
- const containerWidth = navContainerWidthRef.current;
98
- if (!layout || !containerWidth) return;
99
- const contentWidth = navContentWidthRef.current;
100
- const targetX = layout.x - (containerWidth - layout.width) / 2;
101
- const maxScroll = Math.max(contentWidth - containerWidth, 0);
102
- const clampedX = Math.max(0, Math.min(targetX, maxScroll));
103
- if (maxScroll <= 0) {
104
- return;
105
- }
106
- if (Math.abs(clampedX - navLastScrollXRef.current) < 1) {
107
- return;
108
- }
109
- if (navScrollAnimRef.current) {
110
- navScrollAnimRef.current.stop();
111
- navScrollAnimRef.current = null;
112
- }
113
- cancelFrame(navAutoScrollFrameRef.current);
114
- navAutoScrollFrameRef.current = null;
101
+ const lay = layoutMap.current.get(currentName);
102
+ const ctrW = navContainerWidthRef.current;
103
+ if (!lay || !ctrW) return;
104
+ const cntW = navContentWidthRef.current;
105
+ const tX = lay.x - (ctrW - lay.width) / 2;
106
+ const maxS = Math.max(cntW - ctrW, 0);
107
+ const clampX = Math.max(0, Math.min(tX, maxS));
108
+ if (maxS <= 0 || Math.abs(clampX - lastXRef.current) < 1) return;
109
+ navAnimRef.current?.stop();
110
+ navAnimRef.current = null;
111
+ cancelFrame(frameRef.current);
112
+ frameRef.current = null;
115
113
  if (immediate || !animated) {
116
- navAutoScrollingRef.current = true;
117
- navScrollX.setValue(clampedX);
118
- navAutoScrollFrameRef.current = requestFrame(() => {
119
- navAutoScrollFrameRef.current = null;
120
- navAutoScrollingRef.current = false;
114
+ autoScrRef.current = true;
115
+ navX.setValue(clampX);
116
+ frameRef.current = requestFrame(() => {
117
+ frameRef.current = null;
118
+ autoScrRef.current = false;
121
119
  });
122
120
  return;
123
121
  }
124
- navScrollX.setValue(navLastScrollXRef.current);
125
- navAutoScrollingRef.current = true;
126
- navScrollAnimRef.current = Animated.timing(navScrollX, {
127
- toValue: clampedX,
122
+ navX.setValue(lastXRef.current);
123
+ autoScrRef.current = true;
124
+ navAnimRef.current = Animated.timing(navX, {
125
+ toValue: clampX,
128
126
  duration: resolvedDuration,
129
- useNativeDriver: false
127
+ useNativeDriver: false,
128
+ isInteraction: false
130
129
  });
131
- navScrollAnimRef.current.start(({
130
+ navAnimRef.current.start(({
132
131
  finished
133
132
  }) => {
134
- navScrollAnimRef.current = null;
135
- navAutoScrollingRef.current = false;
136
- if (!finished) {
137
- return;
138
- }
139
- navLastScrollXRef.current = clampedX;
133
+ navAnimRef.current = null;
134
+ autoScrRef.current = false;
135
+ if (finished) lastXRef.current = clampX;
140
136
  });
141
- }, [animated, currentName, navScrollX, resolvedDuration, scrollable, layoutMap, navContainerWidthRef, navContentWidthRef]);
137
+ }, [animated, currentName, navX, resolvedDuration, scrollable, layoutMap, navContainerWidthRef, navContentWidthRef]);
142
138
  useEffect(() => {
143
139
  if (!scrollable) return;
144
- const listenerId = navScrollX.addListener(({
140
+ const id = navX.addListener(({
145
141
  value
146
142
  }) => {
147
- const prev = navLastScrollXRef.current;
148
- navLastScrollXRef.current = value;
149
- if (Math.abs(value - prev) < 0.5) {
150
- return;
151
- }
152
- navScrollRef.current?.scrollTo({
143
+ const prev = lastXRef.current;
144
+ lastXRef.current = value;
145
+ if (Math.abs(value - prev) >= 0.5) navScrRef.current?.scrollTo({
153
146
  x: value,
154
147
  y: 0,
155
148
  animated: false
156
149
  });
157
150
  });
158
- return () => {
159
- navScrollX.removeListener(listenerId);
160
- };
161
- }, [navScrollX, scrollable]);
162
- useEffect(() => {
163
- return () => {
164
- cancelFrame(navAutoScrollFrameRef.current);
165
- navAutoScrollFrameRef.current = null;
166
- };
151
+ return () => navX.removeListener(id);
152
+ }, [navX, scrollable]);
153
+ useEffect(() => () => {
154
+ cancelFrame(frameRef.current);
155
+ frameRef.current = null;
167
156
  }, []);
168
- const handleNavScrollBeginDrag = useCallback(event => {
169
- navAutoScrollingRef.current = false;
170
- if (navScrollAnimRef.current) {
171
- navScrollAnimRef.current.stop();
172
- navScrollAnimRef.current = null;
173
- }
174
- navLastScrollXRef.current = event.nativeEvent.contentOffset.x;
157
+ const onNavBeginDrag = useCallback(e => {
158
+ autoScrRef.current = false;
159
+ navAnimRef.current?.stop();
160
+ navAnimRef.current = null;
161
+ lastXRef.current = e.nativeEvent.contentOffset.x;
175
162
  }, []);
176
- const handleNavScroll = useCallback(event => {
177
- if (navAutoScrollingRef.current) {
178
- return;
179
- }
180
- navLastScrollXRef.current = event.nativeEvent.contentOffset.x;
163
+ const onNavScroll = useCallback(e => {
164
+ if (autoScrRef.current) return;
165
+ lastXRef.current = e.nativeEvent.contentOffset.x;
181
166
  }, []);
182
167
  return {
183
- navScrollRef,
184
- navScrollX,
168
+ navScrollRef: navScrRef,
169
+ navScrollX: navX,
185
170
  scrollIntoView,
186
- handleNavScrollBeginDrag,
187
- handleNavScroll
171
+ handleNavScrollBeginDrag: onNavBeginDrag,
172
+ handleNavScroll: onNavScroll
188
173
  };
189
174
  };
190
175
  const TabBarItemInner = ({
@@ -205,33 +190,45 @@ const TabBarItemInner = ({
205
190
  onLayout,
206
191
  isLast
207
192
  }) => {
208
- const isDisabled = !!pane.disabled;
209
- const ariaPress = useAriaPress({
210
- onPress: event => onSelect(pane, pane.index, event),
193
+ const dis = !!pane.disabled;
194
+ const aria = useAriaPress({
195
+ onPress: e => onSelect(pane, pane.index, e),
211
196
  extraProps: {
212
197
  accessibilityRole: 'tab',
213
198
  accessibilityState: {
214
199
  selected: isActive,
215
- disabled: isDisabled
200
+ disabled: dis
216
201
  },
217
202
  testID: `rv-tabs-item-${pane.name}`
218
203
  }
219
204
  });
220
- const isCapsule = type === 'capsule';
221
- const isJumbo = type === 'jumbo';
222
- const isCard = type === 'card';
223
- const renderTitle = isFunction(pane.title) ? pane.title(isActive) : pane.title ?? pane.name;
224
- const renderDescription = isFunction(pane.description) ? pane.description(isActive) : pane.description;
225
- const activeTitleColor = titleActiveColor ?? (isCard ? tokens.colors.cardActiveText : isCapsule ? tokens.colors.capsuleActiveText : color ?? tokens.colors.textActive);
226
- const inactiveTitleColor = titleInactiveColor ?? (isCard ? color ?? tokens.colors.cardBorder : isCapsule ? tokens.colors.capsuleText : tokens.colors.text);
227
- const textColor = pane.disabled ? tokens.colors.textDisabled : isActive ? activeTitleColor : inactiveTitleColor;
228
- const descriptionColor = isDisabled ? tokens.colors.textDisabled : isJumbo ? isActive ? tokens.colors.jumboDescriptionActive : tokens.colors.jumboDescription : isActive ? tokens.colors.descriptionActive : tokens.colors.description;
229
- const shouldFlex = !scrollable && (align !== 'start' || isCard);
230
- const isCompactType = isCard || isJumbo || isCapsule;
231
- const horizontalPadding = isCompactType ? 0 : tokens.tabList.paddingHorizontal;
232
- const verticalPadding = isCompactType ? 0 : tokens.tabList.paddingVertical;
233
- const labelWrapperStyles = [styles.labelWrapper];
234
- const labelTextWrapperStyles = isCapsule ? [{
205
+ const isCap = type === 'capsule';
206
+ const isJ = type === 'jumbo';
207
+ const isC = type === 'card';
208
+ const rTitle = isFunction(pane.title) ? pane.title(isActive) : pane.title ?? pane.name;
209
+ const rDesc = isFunction(pane.description) ? pane.description(isActive) : pane.description;
210
+ const actClr = titleActiveColor ?? (isC ? tokens.colors.cardActiveText : isCap ? tokens.colors.capsuleActiveText : color ?? tokens.colors.textActive);
211
+ const inactClr = titleInactiveColor ?? (isC ? color ?? tokens.colors.cardBorder : isCap ? tokens.colors.capsuleText : tokens.colors.text);
212
+ const txtClr = pane.disabled ? tokens.colors.textDisabled : isActive ? actClr : inactClr;
213
+ const descClr = dis ? tokens.colors.textDisabled : isJ ? isActive ? tokens.colors.jumboDescriptionActive : tokens.colors.jumboDescription : isActive ? tokens.colors.descriptionActive : tokens.colors.description;
214
+ const flex = !scrollable && (align !== 'start' || isC);
215
+ const compact = isC || isJ || isCap;
216
+ const hPad = compact ? 0 : tokens.tabList.paddingHorizontal;
217
+ const vPad = compact ? 0 : tokens.tabList.paddingVertical;
218
+ const lblWrap = [S.lblW, isJ && S.lblWJ, isC && S.cardLbl, isC && {
219
+ paddingHorizontal: tokens.card.paddingHorizontal,
220
+ paddingVertical: tokens.card.paddingVertical
221
+ }, isCap && {
222
+ flex: 1,
223
+ alignSelf: 'stretch',
224
+ paddingHorizontal: tokens.capsule.paddingHorizontal,
225
+ paddingVertical: tokens.capsule.paddingVertical
226
+ }, isJ && {
227
+ paddingHorizontal: tokens.jumbo.paddingHorizontal,
228
+ paddingVertical: tokens.jumbo.paddingVertical,
229
+ alignItems: 'center'
230
+ }].filter(Boolean);
231
+ const lblTxtWrap = isCap ? [{
235
232
  flex: 1,
236
233
  alignSelf: 'stretch',
237
234
  justifyContent: 'center',
@@ -239,89 +236,71 @@ const TabBarItemInner = ({
239
236
  borderRadius: tokens.capsule.radius,
240
237
  backgroundColor: isActive ? color ?? tokens.colors.capsuleActiveBackground : tokens.colors.capsuleBackground
241
238
  }] : null;
242
- if (isJumbo) {
243
- labelWrapperStyles.push(styles.labelWrapperJumbo);
244
- }
245
- if (isCard) {
246
- labelWrapperStyles.push(styles.cardLabel);
247
- labelWrapperStyles.push({
248
- paddingHorizontal: tokens.card.paddingHorizontal,
249
- paddingVertical: tokens.card.paddingVertical
250
- });
251
- }
252
- if (isCapsule) {
253
- labelWrapperStyles.push({
254
- flex: 1,
255
- alignSelf: 'stretch'
256
- });
257
- labelWrapperStyles.push({
258
- paddingHorizontal: tokens.capsule.paddingHorizontal,
259
- paddingVertical: tokens.capsule.paddingVertical
260
- });
261
- }
262
- if (isJumbo) {
263
- labelWrapperStyles.push({
264
- paddingHorizontal: tokens.jumbo.paddingHorizontal,
265
- paddingVertical: tokens.jumbo.paddingVertical,
266
- alignItems: 'center'
267
- });
268
- }
269
- const titleTextStyle = [styles.title, {
270
- color: textColor,
271
- fontSize: isJumbo ? tokens.typography.jumboTitleSize : tokens.typography.titleSize,
239
+ const titleStyleArr = [S.title, {
240
+ color: txtClr,
241
+ fontFamily: tokens.typography.fontFamily,
242
+ fontSize: isJ ? tokens.typography.jumboTitleSize : tokens.typography.titleSize,
272
243
  fontWeight: isActive ? tokens.typography.titleActiveWeight : tokens.typography.titleWeight,
273
- lineHeight: isJumbo ? tokens.typography.jumboLineHeight : undefined,
244
+ lineHeight: isJ ? tokens.typography.jumboLineHeight : undefined,
274
245
  textAlign: 'center'
275
- }, ellipsis && !isJumbo ? styles.ellipsis : null, titleStyle];
276
- const titleNode = /*#__PURE__*/React.createElement(Text, {
277
- style: titleTextStyle,
278
- numberOfLines: ellipsis && !isJumbo ? 1 : undefined
279
- }, renderTitle);
280
- const descriptionMarginTop = isJumbo ? tokens.spacing.jumboDescriptionMarginTop : tokens.spacing.descriptionMarginTop;
281
- const descriptionJumboStyle = isJumbo ? {
246
+ }, ellipsis && !isJ ? S.ellipsis : null, titleStyle];
247
+ const descMT = isJ ? tokens.spacing.jumboDescriptionMarginTop : tokens.spacing.descriptionMarginTop;
248
+ const descJStyle = isJ ? {
282
249
  backgroundColor: isActive ? tokens.colors.jumboDescriptionActiveBackground : tokens.colors.jumboDescriptionBackground,
283
250
  paddingHorizontal: tokens.jumbo.descriptionPaddingHorizontal,
284
251
  paddingVertical: tokens.jumbo.descriptionPaddingVertical,
285
252
  borderRadius: tokens.jumbo.descriptionRadius
286
253
  } : null;
287
- const descriptionTextStyle = [styles.descriptionText, {
288
- color: descriptionColor,
289
- fontSize: tokens.typography.descriptionSize,
290
- marginTop: descriptionMarginTop,
291
- textAlign: 'center'
292
- }, descriptionJumboStyle, descriptionStyle];
293
- const descriptionViewStyle = [styles.descriptionView, {
294
- marginTop: descriptionMarginTop,
295
- alignItems: 'center'
296
- }, descriptionJumboStyle];
297
- return /*#__PURE__*/React.createElement(Pressable, _extends({}, ariaPress.interactionProps, {
298
- onLayout: event => onLayout(pane.name, event),
299
- style: [styles.tabItem, shouldFlex ? styles.flexItem : null, {
300
- paddingHorizontal: horizontalPadding,
301
- paddingVertical: verticalPadding
302
- }, isCard ? {
303
- borderRightWidth: isLast ? 0 : StyleSheet.hairlineWidth,
304
- borderRightColor: color ?? tokens.colors.cardBorder,
254
+ const onLay = useCallback(e => onLayout(pane.name, e), [onLayout, pane.name]);
255
+ return /*#__PURE__*/React.createElement(Pressable, _extends({}, aria.interactionProps, {
256
+ onLayout: onLay,
257
+ style: [S.tabI, flex ? S.flexI : null, {
258
+ paddingHorizontal: hPad,
259
+ paddingVertical: vPad
260
+ }, isC ? {
305
261
  backgroundColor: isActive ? color ?? tokens.colors.cardActiveBackground : tokens.colors.cardBackground
306
262
  } : null, tabStyle]
307
263
  }), /*#__PURE__*/React.createElement(View, {
308
- style: labelWrapperStyles
309
- }, labelTextWrapperStyles ? /*#__PURE__*/React.createElement(View, {
310
- style: labelTextWrapperStyles
311
- }, titleNode) : titleNode, isRenderable(renderDescription) && (isText(renderDescription) ? /*#__PURE__*/React.createElement(Text, {
312
- style: descriptionTextStyle
313
- }, renderDescription) : /*#__PURE__*/React.createElement(View, {
314
- style: descriptionViewStyle
315
- }, renderDescription)), isRenderable(pane.badge) && /*#__PURE__*/React.createElement(View, {
316
- style: [styles.badge, {
264
+ style: lblWrap
265
+ }, lblTxtWrap ? /*#__PURE__*/React.createElement(View, {
266
+ style: lblTxtWrap
267
+ }, /*#__PURE__*/React.createElement(Text, {
268
+ style: titleStyleArr,
269
+ numberOfLines: ellipsis && !isJ ? 1 : undefined
270
+ }, rTitle)) : /*#__PURE__*/React.createElement(Text, {
271
+ style: titleStyleArr,
272
+ numberOfLines: ellipsis && !isJ ? 1 : undefined
273
+ }, rTitle), isRenderable(rDesc) && (isText(rDesc) ? /*#__PURE__*/React.createElement(Text, {
274
+ style: [S.descTxt, {
275
+ color: descClr,
276
+ fontFamily: tokens.typography.fontFamily,
277
+ fontSize: tokens.typography.descriptionSize,
278
+ marginTop: descMT,
279
+ textAlign: 'center'
280
+ }, descJStyle, descriptionStyle]
281
+ }, rDesc) : /*#__PURE__*/React.createElement(View, {
282
+ style: [{
283
+ marginTop: descMT,
284
+ alignItems: 'center'
285
+ }, descJStyle]
286
+ }, rDesc)), isRenderable(pane.badge) && /*#__PURE__*/React.createElement(View, {
287
+ style: {
317
288
  marginTop: tokens.spacing.badgeMarginTop
318
- }]
289
+ }
319
290
  }, isText(pane.badge) ? /*#__PURE__*/React.createElement(Text, {
320
- style: [styles.badgeText, {
291
+ style: {
321
292
  color: tokens.colors.badgeText,
293
+ fontFamily: tokens.typography.fontFamily,
322
294
  fontSize: tokens.typography.badgeTextSize
323
- }]
324
- }, pane.badge) : pane.badge)));
295
+ }
296
+ }, pane.badge) : pane.badge)), isC && !isLast && /*#__PURE__*/React.createElement(View, {
297
+ style: createHairlineView({
298
+ position: 'right',
299
+ color: color ?? tokens.colors.cardBorder,
300
+ top: 0,
301
+ bottom: 0
302
+ })
303
+ }));
325
304
  };
326
305
  const TabBarItem = /*#__PURE__*/memo(TabBarItemInner);
327
306
  const TabsBaseInner = (props, ref) => {
@@ -360,6 +339,7 @@ const TabsBaseInner = (props, ref) => {
360
339
  ...rest
361
340
  } = props;
362
341
  const tokens = useTabsTokens(tokensOverride);
342
+ const reducedMotion = useReducedMotion();
363
343
  const type = typeProp ?? tokens.defaults.type;
364
344
  const align = alignProp ?? tokens.defaults.align;
365
345
  const ellipsis = ellipsisProp ?? tokens.defaults.ellipsis;
@@ -369,18 +349,18 @@ const TabsBaseInner = (props, ref) => {
369
349
  const lazyRender = lazyRenderProp ?? tokens.defaults.lazyRender;
370
350
  const background = backgroundProp ?? tokens.tabList.background;
371
351
  const parsedLineWidth = parseNumberLike(lineWidth ?? tokens.indicator.width);
372
- const resolvedLineWidth = parsedLineWidth != null && parsedLineWidth < 0 ? undefined : parsedLineWidth;
373
- const resolvedLineHeight = Math.max(0, parseNumberLike(lineHeight) ?? tokens.indicator.height);
374
- const resolvedDuration = Math.max(0, parseNumberLike(duration) ?? tokens.defaults.duration);
375
- const resolvedSwipeThreshold = Math.max(0, parseNumberLike(swipeThreshold) ?? tokens.defaults.swipeThreshold);
376
- const swipeableConfig = !swipeable ? undefined : isObject(swipeable) ? {
352
+ const resLineW = parsedLineWidth != null && parsedLineWidth < 0 ? undefined : parsedLineWidth;
353
+ const resLineH = Math.max(0, parseNumberLike(lineHeight) ?? tokens.indicator.height);
354
+ const resDur = reducedMotion ? 0 : Math.max(0, parseNumberLike(duration) ?? tokens.defaults.duration);
355
+ const resSwipeTh = Math.max(0, parseNumberLike(swipeThreshold) ?? tokens.defaults.swipeThreshold);
356
+ const swipeCfg = !swipeable ? undefined : isObject(swipeable) ? {
377
357
  autoHeight: swipeable.autoHeight ?? true,
378
358
  preventScroll: swipeable.preventScroll ?? true
379
359
  } : {
380
360
  autoHeight: true,
381
361
  preventScroll: true
382
362
  };
383
- const isSwipeable = !!swipeableConfig;
363
+ const isSwipe = !!swipeCfg;
384
364
  const panes = useMemo(() => {
385
365
  const result = [];
386
366
  let paneIndex = 0;
@@ -388,13 +368,11 @@ const TabsBaseInner = (props, ref) => {
388
368
  Children.forEach(nodes, node => {
389
369
  if (! /*#__PURE__*/isValidElement(node)) return;
390
370
  const element = node;
391
- if (element.type === Fragment) {
371
+ if (element.type === React.Fragment) {
392
372
  walk(element.props.children);
393
373
  return;
394
374
  }
395
- if (!isTabPaneElement(element)) {
396
- return;
397
- }
375
+ if (!isTabPaneElement(element)) return;
398
376
  const paneProps = element.props;
399
377
  const name = paneProps.name ?? paneIndex;
400
378
  result.push({
@@ -410,75 +388,69 @@ const TabsBaseInner = (props, ref) => {
410
388
  return result;
411
389
  }, [children]);
412
390
  const firstPaneName = panes[0]?.name;
413
- const [activeValue, setActiveValue] = useControllableValue(props, {
391
+ const [actVal, setActVal] = useControllableValue(props, {
414
392
  defaultValue: firstPaneName,
415
393
  valuePropName: 'active',
416
394
  defaultValuePropName: 'defaultActive',
417
395
  trigger: 'onChange'
418
396
  });
419
- const currentName = activeValue == null ? firstPaneName : panes.some(pane => pane.name === activeValue) ? activeValue : firstPaneName;
420
- const currentNameRef = useRef(currentName);
397
+ const curName = actVal == null ? firstPaneName : panes.some(pane => pane.name === actVal) ? actVal : firstPaneName;
398
+ const curNameRef = useRef(curName);
421
399
  useEffect(() => {
422
- currentNameRef.current = currentName;
423
- }, [currentName]);
424
- const nameIndexMap = useMemo(() => {
400
+ curNameRef.current = curName;
401
+ }, [curName]);
402
+ const nameIdxMap = useMemo(() => {
425
403
  const map = new Map();
426
404
  panes.forEach(pane => {
427
405
  map.set(pane.name, pane.index);
428
406
  });
429
407
  return map;
430
408
  }, [panes]);
431
- const activeIndex = currentName == null ? -1 : nameIndexMap.get(currentName) ?? -1;
432
- const visitedRef = useRef(new Set());
409
+ const actIdx = curName == null ? -1 : nameIdxMap.get(curName) ?? -1;
410
+ const visRef = useRef(new Set());
411
+ const layMap = useRef(new Map());
412
+ const navCtrWRef = useRef(0);
413
+ const navCntWRef = useRef(0);
414
+ const navCntSyncRef = useRef(null);
415
+ const paneLayMap = useRef(new Map());
416
+ const swipeScrRef = useRef(null);
417
+ const swipeChgRef = useRef(false);
418
+ const [ctrW, setCtrW] = useState(0);
419
+ const [swipeH, setSwipeH] = useState(undefined);
433
420
  useEffect(() => {
434
- if (currentName == null) return;
435
- visitedRef.current.add(currentName);
436
- }, [currentName]);
421
+ if (curName == null) return;
422
+ visRef.current.add(curName);
423
+ }, [curName]);
437
424
  useEffect(() => {
438
425
  const validNames = new Set(panes.map(pane => pane.name));
439
- Array.from(paneLayoutMap.current.keys()).forEach(name => {
440
- if (!validNames.has(name)) paneLayoutMap.current.delete(name);
426
+ Array.from(paneLayMap.current.keys()).forEach(name => {
427
+ if (!validNames.has(name)) paneLayMap.current.delete(name);
441
428
  });
442
- Array.from(layoutMap.current.keys()).forEach(name => {
443
- if (!validNames.has(name)) layoutMap.current.delete(name);
429
+ Array.from(layMap.current.keys()).forEach(name => {
430
+ if (!validNames.has(name)) layMap.current.delete(name);
444
431
  });
445
432
  }, [panes]);
446
- const shouldTrackPaneLayouts = isSwipeable && swipeableConfig?.autoHeight;
433
+ const trackPaneLay = isSwipe && swipeCfg?.autoHeight;
447
434
  useEffect(() => {
448
- if (!shouldTrackPaneLayouts) {
449
- paneLayoutMap.current.clear();
450
- }
451
- }, [shouldTrackPaneLayouts]);
435
+ if (!trackPaneLay) paneLayMap.current.clear();
436
+ }, [trackPaneLay]);
452
437
  useEffect(() => {
453
- if (!isSwipeable || !swipeableConfig?.autoHeight) {
454
- setSwipeableHeight(undefined);
438
+ if (!isSwipe || !swipeCfg?.autoHeight) {
439
+ setSwipeH(undefined);
455
440
  return;
456
441
  }
457
- const layout = currentName != null ? paneLayoutMap.current.get(currentName) : undefined;
458
- if (layout) {
459
- setSwipeableHeight(layout.height);
460
- } else {
461
- setSwipeableHeight(undefined);
462
- }
463
- }, [currentName, isSwipeable, swipeableConfig?.autoHeight]);
464
- const layoutMap = useRef(new Map());
465
- const navContainerWidthRef = useRef(0);
466
- const navContentWidthRef = useRef(0);
467
- const navContentSizeSyncFrameRef = useRef(null);
468
- const paneLayoutMap = useRef(new Map());
469
- const swipeableScrollRef = useRef(null);
470
- const swipeableChangeByScrollRef = useRef(false);
471
- const [containerWidth, setContainerWidth] = useState(0);
472
- const [swipeableHeight, setSwipeableHeight] = useState(undefined);
442
+ const layout = curName != null ? paneLayMap.current.get(curName) : undefined;
443
+ if (layout) setSwipeH(layout.height);else setSwipeH(undefined);
444
+ }, [curName, isSwipe, swipeCfg?.autoHeight]);
473
445
  useEffect(() => {
474
446
  return () => {
475
- cancelFrame(navContentSizeSyncFrameRef.current);
476
- navContentSizeSyncFrameRef.current = null;
447
+ cancelFrame(navCntSyncRef.current);
448
+ navCntSyncRef.current = null;
477
449
  };
478
450
  }, []);
479
- const scrollable = isBoolean(scrollableProp) ? scrollableProp : panes.length > resolvedSwipeThreshold || ellipsis === false;
480
- const indicatorColor = color ?? tokens.colors.indicator;
481
- const indicatorCornerRadius = resolvedLineHeight ? resolvedLineHeight / 2 : tokens.indicator.radius;
451
+ const scrollable = isBoolean(scrollableProp) ? scrollableProp : panes.length > resSwipeTh || ellipsis === false;
452
+ const indColor = color ?? tokens.colors.indicator;
453
+ const indRad = resLineH ? resLineH / 2 : tokens.indicator.radius;
482
454
  const {
483
455
  indicatorX,
484
456
  indicatorWidth,
@@ -490,13 +462,13 @@ const TabsBaseInner = (props, ref) => {
490
462
  scrollable,
491
463
  align,
492
464
  panes,
493
- nameIndexMap,
494
- resolvedLineWidth,
495
- resolvedLineHeight,
496
- resolvedDuration,
497
- currentName,
498
- layoutMap,
499
- navContainerWidthRef
465
+ nameIndexMap: nameIdxMap,
466
+ resolvedLineWidth: resLineW,
467
+ resolvedLineHeight: resLineH,
468
+ resolvedDuration: resDur,
469
+ currentName: curName,
470
+ layoutMap: layMap,
471
+ navContainerWidthRef: navCtrWRef
500
472
  });
501
473
  const {
502
474
  navScrollRef,
@@ -506,171 +478,162 @@ const TabsBaseInner = (props, ref) => {
506
478
  } = useTabsScroll({
507
479
  scrollable,
508
480
  animated,
509
- currentName,
510
- resolvedDuration,
511
- layoutMap,
512
- navContainerWidthRef,
513
- navContentWidthRef
481
+ currentName: curName,
482
+ resolvedDuration: resDur,
483
+ layoutMap: layMap,
484
+ navContainerWidthRef: navCtrWRef,
485
+ navContentWidthRef: navCntWRef
514
486
  });
515
- const handleTabLayout = useCallback((name, event) => {
487
+ const onTabLayout = useCallback((name, event) => {
516
488
  const {
517
489
  x,
518
490
  width
519
491
  } = event.nativeEvent.layout;
520
- layoutMap.current.set(name, {
492
+ layMap.current.set(name, {
521
493
  x,
522
494
  width
523
495
  });
524
- if (name === currentNameRef.current) {
496
+ if (name === curNameRef.current) {
525
497
  const shouldAnimate = indicatorInitializedRef.current;
526
498
  const didAnimate = animateIndicator(name, !shouldAnimate);
527
499
  if (didAnimate && !indicatorInitializedRef.current) indicatorInitializedRef.current = true;
528
500
  }
529
501
  }, [animateIndicator, indicatorInitializedRef]);
530
- const handleNavContainerLayout = useCallback(event => {
502
+ const onNavCtrLayout = useCallback(event => {
531
503
  const {
532
504
  width
533
505
  } = event.nativeEvent.layout;
534
- navContainerWidthRef.current = width;
535
- if (!scrollable && align !== 'start' && type === 'line' && currentName !== undefined && currentName !== null) {
506
+ navCtrWRef.current = width;
507
+ if (!scrollable && align !== 'start' && type === 'line' && curName !== undefined && curName !== null) {
536
508
  const shouldAnimate = indicatorInitializedRef.current;
537
- const didAnimate = animateIndicator(currentName, !shouldAnimate);
509
+ const didAnimate = animateIndicator(curName, !shouldAnimate);
538
510
  if (didAnimate && !indicatorInitializedRef.current) indicatorInitializedRef.current = true;
539
511
  }
540
- }, [align, animateIndicator, currentName, scrollable, type, indicatorInitializedRef]);
541
- const handleContainerLayout = useCallback(event => {
542
- const nextWidth = event.nativeEvent.layout.width;
543
- setContainerWidth(prev => prev === nextWidth ? prev : nextWidth);
512
+ }, [align, animateIndicator, curName, scrollable, type, indicatorInitializedRef]);
513
+ const onCtrLayout = useCallback(event => {
514
+ const nextW = event.nativeEvent.layout.width;
515
+ setCtrW(prev => prev === nextW ? prev : nextW);
544
516
  }, []);
545
- const runBeforeChange = useCallback(name => {
546
- if (!beforeChange) return Promise.resolve(true);
517
+ const beforeChgRef = useRef(beforeChange);
518
+ beforeChgRef.current = beforeChange;
519
+ const runBeforeChg = useCallback(name => {
520
+ if (!beforeChgRef.current) return Promise.resolve(true);
547
521
  try {
548
- return Promise.resolve(beforeChange(name)).then(res => res !== false).catch(() => false);
522
+ return Promise.resolve(beforeChgRef.current(name)).then(res => res !== false).catch(() => false);
549
523
  } catch (error) {
550
524
  return Promise.resolve(false);
551
525
  }
552
- }, [beforeChange]);
553
- const changeSeqRef = useRef(0);
554
- const requestChange = useCallback((name, index) => {
555
- changeSeqRef.current += 1;
556
- const seq = changeSeqRef.current;
557
- runBeforeChange(name).then(canChange => {
526
+ }, []);
527
+ const chgSeqRef = useRef(0);
528
+ const reqChg = useCallback((name, index) => {
529
+ chgSeqRef.current += 1;
530
+ const seq = chgSeqRef.current;
531
+ runBeforeChg(name).then(canChange => {
558
532
  if (!canChange) return;
559
- if (changeSeqRef.current !== seq) return;
560
- setActiveValue(name, index);
533
+ if (chgSeqRef.current !== seq) return;
534
+ setActVal(name, index);
561
535
  });
562
- }, [runBeforeChange, setActiveValue]);
563
- const handlePaneLayout = useCallback((name, event) => {
564
- if (isSwipeable && swipeableConfig?.autoHeight) {
536
+ }, [runBeforeChg, setActVal]);
537
+ const onPaneLayout = useCallback((name, event) => {
538
+ if (isSwipe && swipeCfg?.autoHeight) {
565
539
  const {
566
540
  height
567
541
  } = event.nativeEvent.layout;
568
- paneLayoutMap.current.set(name, {
542
+ paneLayMap.current.set(name, {
569
543
  height
570
544
  });
571
- if (name === currentName) setSwipeableHeight(height);
545
+ if (name === curName) setSwipeH(height);
572
546
  }
573
- }, [currentName, isSwipeable, swipeableConfig?.autoHeight]);
574
- const swipeEndIndexRef = useRef(null);
547
+ }, [curName, isSwipe, swipeCfg?.autoHeight]);
548
+ const swipeEndIdxRef = useRef(null);
575
549
  useEffect(() => {
576
- swipeEndIndexRef.current = null;
577
- }, [currentName]);
578
- const handleSwipeEnd = useCallback(offsetX => {
579
- if (!isSwipeable || containerWidth <= 0) return;
580
- const pageIndex = Math.round(offsetX / containerWidth);
581
- if (swipeEndIndexRef.current === pageIndex) return;
582
- swipeEndIndexRef.current = pageIndex;
583
- const nextPane = panes[pageIndex];
584
- if (!nextPane || nextPane.name === currentNameRef.current) return;
585
- swipeableChangeByScrollRef.current = true;
586
- requestChange(nextPane.name, nextPane.index);
587
- }, [containerWidth, isSwipeable, panes, requestChange]);
588
- const handleSwipeMomentumScrollEnd = useCallback(event => {
589
- handleSwipeEnd(event.nativeEvent.contentOffset.x);
590
- }, [handleSwipeEnd]);
591
- const handleSwipeScrollEndDrag = useCallback(event => {
592
- handleSwipeEnd(event.nativeEvent.contentOffset.x);
593
- }, [handleSwipeEnd]);
550
+ swipeEndIdxRef.current = null;
551
+ }, [curName]);
552
+ const onSwipeEnd = useCallback(offsetX => {
553
+ if (!isSwipe || ctrW <= 0) return;
554
+ const pageIdx = Math.round(offsetX / ctrW);
555
+ if (swipeEndIdxRef.current === pageIdx) return;
556
+ swipeEndIdxRef.current = pageIdx;
557
+ const nextPane = panes[pageIdx];
558
+ if (!nextPane || nextPane.name === curNameRef.current) return;
559
+ swipeChgRef.current = true;
560
+ reqChg(nextPane.name, nextPane.index);
561
+ }, [ctrW, isSwipe, panes, reqChg]);
562
+ const onSwipeMomentumScrollEnd = useCallback(event => {
563
+ onSwipeEnd(event.nativeEvent.contentOffset.x);
564
+ }, [onSwipeEnd]);
565
+ const onSwipeScrollEndDrag = useCallback(event => {
566
+ onSwipeEnd(event.nativeEvent.contentOffset.x);
567
+ }, [onSwipeEnd]);
594
568
  useEffect(() => {
595
- if (!isSwipeable || !swipeableScrollRef.current || containerWidth <= 0) {
596
- return;
597
- }
598
- if (swipeableChangeByScrollRef.current) {
599
- swipeableChangeByScrollRef.current = false;
600
- return;
601
- }
602
- if (activeIndex < 0) {
603
- return;
604
- }
605
- const node = swipeableScrollRef.current?.getNode?.() ?? swipeableScrollRef.current;
606
- if (!node?.scrollTo) {
569
+ if (!isSwipe || !swipeScrRef.current || ctrW <= 0) return;
570
+ if (swipeChgRef.current) {
571
+ swipeChgRef.current = false;
607
572
  return;
608
573
  }
574
+ if (actIdx < 0) return;
575
+ const node = swipeScrRef.current?.getNode?.() ?? swipeScrRef.current;
576
+ if (!node?.scrollTo) return;
609
577
  node.scrollTo({
610
- x: containerWidth * activeIndex,
578
+ x: ctrW * actIdx,
611
579
  y: 0,
612
580
  animated: true
613
581
  });
614
- }, [activeIndex, containerWidth, isSwipeable]);
615
- const handleSelect = useCallback((pane, index, event) => {
582
+ }, [actIdx, ctrW, isSwipe]);
583
+ const onClickTabRef = useRef(onClickTab);
584
+ onClickTabRef.current = onClickTab;
585
+ const onSel = useCallback((pane, index, event) => {
616
586
  const payload = {
617
587
  name: pane.name,
618
588
  index,
619
589
  disabled: !!pane.disabled,
620
590
  event
621
591
  };
622
- onClickTab?.(payload);
623
- if (pane.disabled || pane.name === currentNameRef.current) return;
624
- requestChange(pane.name, index);
625
- }, [onClickTab, requestChange]);
592
+ onClickTabRef.current?.(payload);
593
+ if (pane.disabled || pane.name === curNameRef.current) return;
594
+ reqChg(pane.name, index);
595
+ }, [reqChg]);
626
596
  const scrollTo = useCallback((name, _options) => {
627
597
  const target = panes.find(pane => pane.name === name && !pane.disabled);
628
598
  if (!target) return;
629
- setActiveValue(target.name, target.index);
630
- }, [panes, setActiveValue]);
599
+ setActVal(target.name, target.index);
600
+ }, [panes, setActVal]);
631
601
  useImperativeHandle(ref, () => ({
632
602
  scrollTo
633
603
  }), [scrollTo]);
634
- const firstRenderRef = useRef(true);
604
+ const firstRndRef = useRef(true);
635
605
  useEffect(() => {
636
- if (firstRenderRef.current) {
637
- firstRenderRef.current = false;
606
+ if (firstRndRef.current) {
607
+ firstRndRef.current = false;
638
608
  scrollIntoView(true);
639
609
  }
640
610
  }, [scrollIntoView]);
641
611
  useEffect(() => {
642
- if (!firstRenderRef.current) {
643
- scrollIntoView();
644
- }
645
- }, [currentName, scrollIntoView]);
646
- const borderEnabled = border ?? false;
647
- const showIndicator = type === 'line';
648
- const navHeight = type === 'jumbo' ? tokens.jumbo.height : type === 'card' ? tokens.card.height : tokens.tabList.height;
649
- const navPaddingBottom = Platform.OS === 'web' && type !== 'line' && type !== 'card' ? tokens.tabList.paddingBottom : 0;
650
- const indicatorBottom = showIndicator ? type === 'line' ? 0 : tokens.indicator.offset : 0;
651
- if (panes.length === 0) {
652
- return null;
653
- }
654
- const indicatorNode = useMemo(() => {
655
- if (!showIndicator) return null;
656
- return /*#__PURE__*/React.createElement(Animated.View, {
657
- testID: "rv-tabs-indicator",
658
- style: [styles.indicator, {
659
- height: resolvedLineHeight,
660
- borderRadius: indicatorCornerRadius,
661
- backgroundColor: indicatorColor,
662
- width: indicatorWidth,
663
- bottom: indicatorBottom,
664
- transform: [{
665
- translateX: indicatorX
666
- }]
612
+ if (!firstRndRef.current) scrollIntoView();
613
+ }, [curName, scrollIntoView]);
614
+ const hasBorder = border ?? false;
615
+ const showInd = type === 'line';
616
+ const navH = type === 'jumbo' ? tokens.jumbo.height : type === 'card' ? tokens.card.height : tokens.tabList.height;
617
+ const navPB = Platform.OS === 'web' && type !== 'line' && type !== 'card' ? tokens.tabList.paddingBottom : 0;
618
+ const indBot = showInd ? type === 'line' ? 0 : tokens.indicator.offset : 0;
619
+ if (panes.length === 0) return null;
620
+ const indicatorNode = showInd ? /*#__PURE__*/React.createElement(Animated.View, {
621
+ testID: "rv-tabs-indicator",
622
+ style: [S.ind, {
623
+ height: resLineH,
624
+ borderRadius: indRad,
625
+ backgroundColor: indColor,
626
+ width: indicatorWidth,
627
+ bottom: indBot,
628
+ transform: [{
629
+ translateX: indicatorX
667
630
  }]
668
- });
669
- }, [indicatorBottom, indicatorColor, indicatorCornerRadius, indicatorWidth, indicatorX, resolvedLineHeight, showIndicator]);
631
+ }]
632
+ }) : null;
670
633
  const navItems = useMemo(() => panes.map(pane => /*#__PURE__*/React.createElement(TabBarItem, {
671
634
  key: pane.key,
672
635
  pane: pane,
673
- isActive: pane.name === currentName,
636
+ isActive: pane.name === curName,
674
637
  align: align,
675
638
  scrollable: scrollable,
676
639
  type: type,
@@ -682,21 +645,21 @@ const TabsBaseInner = (props, ref) => {
682
645
  tabStyle: tabStyle,
683
646
  titleStyle: titleStyle,
684
647
  descriptionStyle: descriptionStyle,
685
- onSelect: handleSelect,
686
- onLayout: handleTabLayout,
648
+ onSelect: onSel,
649
+ onLayout: onTabLayout,
687
650
  isLast: pane.index === panes.length - 1
688
- })), [align, color, currentName, descriptionStyle, ellipsis, handleSelect, handleTabLayout, panes, scrollable, tabStyle, titleActiveColor, titleInactiveColor, titleStyle, tokens, type]);
689
- const handleNavContentSizeChange = useCallback(w => {
690
- const prev = navContentWidthRef.current;
691
- navContentWidthRef.current = w;
692
- if (prev === 0 || firstRenderRef.current) {
651
+ })), [align, color, curName, descriptionStyle, ellipsis, onSel, onTabLayout, panes, scrollable, tabStyle, titleActiveColor, titleInactiveColor, titleStyle, tokens, type]);
652
+ const onNavCntSizeChg = useCallback(w => {
653
+ const prev = navCntWRef.current;
654
+ navCntWRef.current = w;
655
+ if (prev === 0 || firstRndRef.current) {
693
656
  scrollIntoView(true);
694
657
  return;
695
658
  }
696
659
  if (Math.abs(w - prev) > 1) {
697
- cancelFrame(navContentSizeSyncFrameRef.current);
698
- navContentSizeSyncFrameRef.current = requestFrame(() => {
699
- navContentSizeSyncFrameRef.current = null;
660
+ cancelFrame(navCntSyncRef.current);
661
+ navCntSyncRef.current = requestFrame(() => {
662
+ navCntSyncRef.current = null;
700
663
  scrollIntoView();
701
664
  });
702
665
  }
@@ -709,50 +672,56 @@ const TabsBaseInner = (props, ref) => {
709
672
  scrollEventThrottle: 16,
710
673
  onScrollBeginDrag: handleNavScrollBeginDrag,
711
674
  onScroll: handleNavScroll,
712
- onContentSizeChange: handleNavContentSizeChange,
713
- contentContainerStyle: styles.navContent
675
+ onContentSizeChange: onNavCntSizeChg,
676
+ contentContainerStyle: S.navC
714
677
  }, navItems, indicatorNode) : /*#__PURE__*/React.createElement(View, {
715
678
  accessibilityRole: "tablist",
716
- style: [styles.navContent, styles.navContentStatic]
679
+ style: [S.navC, S.navCSta]
717
680
  }, navItems, indicatorNode);
718
681
  const navContent = /*#__PURE__*/React.createElement(View, {
719
- style: [styles.wrap, borderEnabled && type === 'line' ? {
720
- borderBottomWidth: StyleSheet.hairlineWidth,
721
- borderBottomColor: tokens.colors.border
722
- } : null, {
682
+ style: [S.wrap, {
723
683
  backgroundColor: background
724
684
  }, tabBarStyle]
725
685
  }, navLeft && /*#__PURE__*/React.createElement(View, {
726
- style: [styles.navSide, {
686
+ style: {
727
687
  paddingHorizontal: tokens.spacing.navSidePaddingHorizontal
728
- }]
688
+ }
729
689
  }, navLeft), /*#__PURE__*/React.createElement(View, {
730
- style: [styles.nav, {
731
- minHeight: navHeight + navPaddingBottom,
732
- paddingBottom: navPaddingBottom
690
+ style: [S.nav, {
691
+ minHeight: navH + navPB,
692
+ paddingBottom: navPB
733
693
  }, type === 'card' ? {
734
- borderWidth: StyleSheet.hairlineWidth,
735
694
  borderRadius: tokens.card.radius,
736
- borderColor: color ?? tokens.colors.cardBorder,
737
695
  marginHorizontal: tokens.card.marginHorizontal,
738
696
  overflow: 'hidden'
739
697
  } : null],
740
- onLayout: handleNavContainerLayout
741
- }, navBody), navRight && /*#__PURE__*/React.createElement(View, {
742
- style: [styles.navSide, {
698
+ onLayout: onNavCtrLayout
699
+ }, navBody, type === 'card' && /*#__PURE__*/React.createElement(View, {
700
+ style: createHairlineView({
701
+ position: 'all',
702
+ color: color ?? tokens.colors.cardBorder,
703
+ borderRadius: tokens.card.radius
704
+ })
705
+ })), navRight && /*#__PURE__*/React.createElement(View, {
706
+ style: {
743
707
  paddingHorizontal: tokens.spacing.navSidePaddingHorizontal
744
- }]
745
- }, navRight));
746
- const paneNodes = useMemo(() => panes.map(pane => {
747
- const isActive = pane.name === currentName;
748
- const shouldRender = !lazyRender || isActive || visitedRef.current.has(pane.name);
749
- if (!shouldRender && !isSwipeable) {
750
- return null;
751
708
  }
752
- const layoutHandler = isSwipeable && swipeableConfig?.autoHeight ? event => handlePaneLayout(pane.name, event) : undefined;
753
- const paneStyles = [styles.pane, isSwipeable ? styles.swipeablePane : null, isSwipeable && containerWidth > 0 && {
754
- width: containerWidth
755
- }, !isSwipeable && !isActive ? styles.hiddenPane : null];
709
+ }, navRight), hasBorder && type === 'line' && /*#__PURE__*/React.createElement(View, {
710
+ style: createHairlineView({
711
+ position: 'bottom',
712
+ color: tokens.colors.border,
713
+ left: 0,
714
+ right: 0
715
+ })
716
+ }));
717
+ const paneNodes = useMemo(() => panes.map(pane => {
718
+ const isActive = pane.name === curName;
719
+ const shouldRender = !lazyRender || isActive || visRef.current.has(pane.name);
720
+ if (!shouldRender && !isSwipe) return null;
721
+ const layoutHandler = isSwipe && swipeCfg?.autoHeight ? event => onPaneLayout(pane.name, event) : undefined;
722
+ const paneStyles = [S.pane, isSwipe ? S.swipePane : null, isSwipe && ctrW > 0 && {
723
+ width: ctrW
724
+ }, !isSwipe && !isActive ? S.hidPane : null];
756
725
  const paneContent = shouldRender ? pane.children : lazyRenderPlaceholder || null;
757
726
  return /*#__PURE__*/React.createElement(View, {
758
727
  key: pane.key,
@@ -760,37 +729,37 @@ const TabsBaseInner = (props, ref) => {
760
729
  onLayout: layoutHandler,
761
730
  style: paneStyles
762
731
  }, paneContent);
763
- }), [containerWidth, currentName, handlePaneLayout, isSwipeable, lazyRender, lazyRenderPlaceholder, panes, swipeableConfig?.autoHeight]);
764
- const baseContentStyle = useMemo(() => [styles.content, contentStyle], [contentStyle]);
765
- const swipeableContentStyle = useMemo(() => [styles.content, contentStyle, swipeableConfig?.autoHeight && swipeableHeight !== undefined && {
766
- height: swipeableHeight
767
- }], [contentStyle, swipeableConfig?.autoHeight, swipeableHeight]);
768
- const contentNode = isSwipeable ? /*#__PURE__*/React.createElement(View, {
769
- style: swipeableContentStyle
732
+ }), [ctrW, curName, onPaneLayout, isSwipe, lazyRender, lazyRenderPlaceholder, panes, swipeCfg?.autoHeight]);
733
+ const baseContentStyle = [S.content, contentStyle];
734
+ const swipeContentStyle = [S.content, contentStyle, swipeCfg?.autoHeight && swipeH !== undefined && {
735
+ height: swipeH
736
+ }];
737
+ const contentNode = isSwipe ? /*#__PURE__*/React.createElement(View, {
738
+ style: swipeContentStyle
770
739
  }, /*#__PURE__*/React.createElement(Animated.ScrollView, {
771
- ref: swipeableScrollRef,
740
+ ref: swipeScrRef,
772
741
  horizontal: true,
773
742
  pagingEnabled: true,
774
743
  scrollEventThrottle: 16,
775
744
  showsHorizontalScrollIndicator: false,
776
- onMomentumScrollEnd: handleSwipeMomentumScrollEnd,
777
- onScrollEndDrag: handleSwipeScrollEndDrag,
778
- nestedScrollEnabled: swipeableConfig?.preventScroll === false,
779
- directionalLockEnabled: swipeableConfig?.preventScroll !== false
745
+ onMomentumScrollEnd: onSwipeMomentumScrollEnd,
746
+ onScrollEndDrag: onSwipeScrollEndDrag,
747
+ nestedScrollEnabled: swipeCfg?.preventScroll === false,
748
+ directionalLockEnabled: swipeCfg?.preventScroll !== false
780
749
  }, paneNodes)) : /*#__PURE__*/React.createElement(View, {
781
750
  style: baseContentStyle
782
751
  }, paneNodes);
783
752
  return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
784
- style: [styles.container, style],
785
- onLayout: handleContainerLayout
753
+ style: [S.ctr, style],
754
+ onLayout: onCtrLayout
786
755
  }), navContent, navBottom && /*#__PURE__*/React.createElement(View, {
787
- style: [styles.navBottom, {
756
+ style: {
788
757
  marginTop: tokens.spacing.navBottomMarginTop
789
- }]
758
+ }
790
759
  }, navBottom), contentNode);
791
760
  };
792
- const styles = StyleSheet.create({
793
- container: {
761
+ const S = StyleSheet.create({
762
+ ctr: {
794
763
  width: '100%'
795
764
  },
796
765
  wrap: {
@@ -803,31 +772,29 @@ const styles = StyleSheet.create({
803
772
  position: 'relative',
804
773
  alignSelf: 'stretch'
805
774
  },
806
- navContent: {
775
+ navC: {
807
776
  flexDirection: 'row',
808
777
  alignItems: 'center',
809
778
  height: '100%',
810
779
  position: 'relative'
811
780
  },
812
- navContentStatic: {
781
+ navCSta: {
813
782
  flex: 1
814
783
  },
815
- navSide: {},
816
- navBottom: {},
817
- labelWrapper: {
784
+ lblW: {
818
785
  justifyContent: 'center',
819
786
  alignItems: 'center',
820
787
  flexDirection: 'column'
821
788
  },
822
- labelWrapperJumbo: {
789
+ lblWJ: {
823
790
  alignItems: 'center'
824
791
  },
825
- cardLabel: {
792
+ cardLbl: {
826
793
  flexDirection: 'row',
827
794
  justifyContent: 'center',
828
795
  alignItems: 'center'
829
796
  },
830
- tabItem: {
797
+ tabI: {
831
798
  flexShrink: 0,
832
799
  height: '100%',
833
800
  alignSelf: 'stretch',
@@ -835,23 +802,20 @@ const styles = StyleSheet.create({
835
802
  justifyContent: 'center',
836
803
  flexDirection: 'row'
837
804
  },
838
- flexItem: {
805
+ flexI: {
839
806
  flexGrow: 1
840
807
  },
841
808
  title: {
842
809
  includeFontPadding: false
843
810
  },
844
- descriptionText: {
811
+ descTxt: {
845
812
  includeFontPadding: false
846
813
  },
847
- descriptionView: {},
848
814
  ellipsis: {
849
815
  maxWidth: '100%',
850
816
  flexShrink: 1
851
817
  },
852
- badge: {},
853
- badgeText: {},
854
- indicator: {
818
+ ind: {
855
819
  position: 'absolute',
856
820
  bottom: 0,
857
821
  left: 0
@@ -862,16 +826,15 @@ const styles = StyleSheet.create({
862
826
  pane: {
863
827
  width: '100%'
864
828
  },
865
- swipeablePane: {
829
+ swipePane: {
866
830
  flexShrink: 0
867
831
  },
868
- hiddenPane: {
832
+ hidPane: {
869
833
  display: 'none'
870
834
  }
871
835
  });
872
- const TabsBase = /*#__PURE__*/React.forwardRef(TabsBaseInner);
873
- TabsBase.displayName = 'Tabs';
874
- const TabsWithPane = Object.assign(TabsBase, {
836
+ const TabsBaseRef = /*#__PURE__*/React.forwardRef(TabsBaseInner);
837
+ const TabsWithPane = Object.assign(/*#__PURE__*/React.memo(TabsBaseRef), {
875
838
  TabPane
876
839
  });
877
840
  export { TabPane };