react-native-system-ui 1.0.1 → 1.0.3

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 (496) hide show
  1. package/README.md +44 -24
  2. package/dist/cjs/components/action-sheet/ActionSheet.js +1 -297
  3. package/dist/cjs/components/action-sheet/index.js +1 -16
  4. package/dist/cjs/components/action-sheet/tokens.js +1 -133
  5. package/dist/cjs/components/area/Area.js +1 -127
  6. package/dist/cjs/components/area/index.js +1 -9
  7. package/dist/cjs/components/area/tokens.js +1 -14
  8. package/dist/cjs/components/avatar/Avatar.js +1 -125
  9. package/dist/cjs/components/avatar/index.js +1 -18
  10. package/dist/cjs/components/avatar/tokens.js +1 -56
  11. package/dist/cjs/components/badge/Badge.js +1 -166
  12. package/dist/cjs/components/badge/index.js +1 -8
  13. package/dist/cjs/components/badge/tokens.js +1 -81
  14. package/dist/cjs/components/button/Button.js +1 -203
  15. package/dist/cjs/components/button/ButtonContext.js +1 -12
  16. package/dist/cjs/components/button/ButtonGroup.js +1 -65
  17. package/dist/cjs/components/button/index.js +1 -12
  18. package/dist/cjs/components/button/tokens.js +1 -176
  19. package/dist/cjs/components/calendar/Calendar.js +1 -452
  20. package/dist/cjs/components/calendar/index.js +1 -9
  21. package/dist/cjs/components/calendar/tokens.js +1 -129
  22. package/dist/cjs/components/cascader/Cascader.js +1 -481
  23. package/dist/cjs/components/cascader/index.js +1 -15
  24. package/dist/cjs/components/cascader/tokens.js +1 -138
  25. package/dist/cjs/components/cascader/useCascaderExtend.js +1 -39
  26. package/dist/cjs/components/cell/Cell.js +1 -181
  27. package/dist/cjs/components/cell/CellContext.js +1 -19
  28. package/dist/cjs/components/cell/CellGroup.js +1 -100
  29. package/dist/cjs/components/cell/index.js +1 -19
  30. package/dist/cjs/components/cell/tokens.js +1 -173
  31. package/dist/cjs/components/checkbox/Checkbox.js +1 -251
  32. package/dist/cjs/components/checkbox/CheckboxContext.js +1 -12
  33. package/dist/cjs/components/checkbox/CheckboxGroup.js +1 -148
  34. package/dist/cjs/components/checkbox/index.js +1 -16
  35. package/dist/cjs/components/checkbox/tokens.js +1 -97
  36. package/dist/cjs/components/circle/Circle.js +1 -212
  37. package/dist/cjs/components/circle/index.js +1 -9
  38. package/dist/cjs/components/circle/tokens.js +1 -55
  39. package/dist/cjs/components/collapse/Collapse.js +1 -311
  40. package/dist/cjs/components/collapse/index.js +1 -8
  41. package/dist/cjs/components/collapse/tokens.js +1 -81
  42. package/dist/cjs/components/config-provider/ConfigProvider.js +1 -44
  43. package/dist/cjs/components/config-provider/DirectionContext.js +1 -15
  44. package/dist/cjs/components/config-provider/LocaleContext.js +1 -16
  45. package/dist/cjs/components/config-provider/index.js +1 -40
  46. package/dist/cjs/components/config-provider/locale/en-US.js +1 -112
  47. package/dist/cjs/components/config-provider/locale/zh-CN.js +1 -112
  48. package/dist/cjs/components/config-provider/tokens.js +1 -11
  49. package/dist/cjs/components/config-provider/useDirection.js +1 -16
  50. package/dist/cjs/components/config-provider/useLocale.js +1 -16
  51. package/dist/cjs/components/count-down/CountDown.js +1 -88
  52. package/dist/cjs/components/count-down/index.js +1 -15
  53. package/dist/cjs/components/count-down/tokens.js +1 -34
  54. package/dist/cjs/components/datetime-picker/DatetimePicker.js +1 -319
  55. package/dist/cjs/components/datetime-picker/index.js +1 -9
  56. package/dist/cjs/components/datetime-picker/tokens.js +1 -22
  57. package/dist/cjs/components/dialog/Dialog.js +1 -433
  58. package/dist/cjs/components/dialog/imperative.js +1 -199
  59. package/dist/cjs/components/dialog/index.js +1 -23
  60. package/dist/cjs/components/dialog/tokens.js +1 -64
  61. package/dist/cjs/components/divider/Divider.js +1 -126
  62. package/dist/cjs/components/divider/index.js +1 -8
  63. package/dist/cjs/components/divider/tokens.js +1 -62
  64. package/dist/cjs/components/empty/Empty.js +1 -125
  65. package/dist/cjs/components/empty/index.js +1 -8
  66. package/dist/cjs/components/empty/tokens.js +1 -55
  67. package/dist/cjs/components/error-boundary/ErrorBoundary.js +1 -74
  68. package/dist/cjs/components/error-boundary/index.js +1 -19
  69. package/dist/cjs/components/field/Field.js +1 -565
  70. package/dist/cjs/components/field/index.js +1 -29
  71. package/dist/cjs/components/field/tokens.js +1 -150
  72. package/dist/cjs/components/flex/Flex.js +1 -85
  73. package/dist/cjs/components/flex/FlexContext.js +1 -12
  74. package/dist/cjs/components/flex/FlexItem.js +1 -95
  75. package/dist/cjs/components/flex/index.js +1 -19
  76. package/dist/cjs/components/flex/tokens.js +1 -21
  77. package/dist/cjs/components/form/Form.js +1 -340
  78. package/dist/cjs/components/form/FormContext.js +1 -12
  79. package/dist/cjs/components/form/FormItem.js +1 -151
  80. package/dist/cjs/components/form/FormList.js +1 -95
  81. package/dist/cjs/components/form/index.js +1 -50
  82. package/dist/cjs/components/form/tokens.js +1 -14
  83. package/dist/cjs/components/form/utils.js +1 -56
  84. package/dist/cjs/components/grid/Grid.js +1 -118
  85. package/dist/cjs/components/grid/GridContext.js +1 -12
  86. package/dist/cjs/components/grid/GridItem.js +1 -158
  87. package/dist/cjs/components/grid/index.js +1 -12
  88. package/dist/cjs/components/grid/tokens.js +1 -105
  89. package/dist/cjs/components/image/Image.js +1 -263
  90. package/dist/cjs/components/image/index.js +1 -16
  91. package/dist/cjs/components/image/tokens.js +1 -66
  92. package/dist/cjs/components/image-preview/ImagePreview.js +1 -398
  93. package/dist/cjs/components/image-preview/imperative.js +1 -72
  94. package/dist/cjs/components/image-preview/index.js +1 -17
  95. package/dist/cjs/components/image-preview/tokens.js +1 -43
  96. package/dist/cjs/components/index.js +1 -769
  97. package/dist/cjs/components/input/Input.js +1 -122
  98. package/dist/cjs/components/input/index.js +1 -15
  99. package/dist/cjs/components/input/tokens.js +1 -22
  100. package/dist/cjs/components/loading/Loading.js +1 -76
  101. package/dist/cjs/components/loading/index.js +1 -8
  102. package/dist/cjs/components/loading/tokens.js +1 -32
  103. package/dist/cjs/components/nav-bar/NavBar.js +1 -196
  104. package/dist/cjs/components/nav-bar/index.js +1 -16
  105. package/dist/cjs/components/nav-bar/tokens.js +1 -90
  106. package/dist/cjs/components/notice-bar/NoticeBar.js +1 -369
  107. package/dist/cjs/components/notice-bar/index.js +1 -8
  108. package/dist/cjs/components/notice-bar/tokens.js +1 -39
  109. package/dist/cjs/components/notify/Notify.js +1 -262
  110. package/dist/cjs/components/notify/imperative.js +1 -145
  111. package/dist/cjs/components/notify/index.js +1 -10
  112. package/dist/cjs/components/notify/tokens.js +1 -74
  113. package/dist/cjs/components/number-keyboard/NumberKeyboard.js +1 -487
  114. package/dist/cjs/components/number-keyboard/index.js +1 -15
  115. package/dist/cjs/components/number-keyboard/tokens.js +1 -59
  116. package/dist/cjs/components/overlay/Overlay.js +1 -81
  117. package/dist/cjs/components/overlay/index.js +1 -28
  118. package/dist/cjs/components/overlay/tokens.js +1 -13
  119. package/dist/cjs/components/password-input/PasswordInput.js +1 -346
  120. package/dist/cjs/components/password-input/index.js +1 -13
  121. package/dist/cjs/components/password-input/tokens.js +1 -53
  122. package/dist/cjs/components/picker/Picker.js +1 -1056
  123. package/dist/cjs/components/picker/index.js +1 -15
  124. package/dist/cjs/components/picker/tokens.js +1 -53
  125. package/dist/cjs/components/popup/Popup.js +1 -518
  126. package/dist/cjs/components/popup/index.js +1 -15
  127. package/dist/cjs/components/popup/tokens.js +1 -62
  128. package/dist/cjs/components/portal/Portal.js +1 -50
  129. package/dist/cjs/components/portal/PortalContext.js +1 -15
  130. package/dist/cjs/components/portal/PortalHost.js +1 -253
  131. package/dist/cjs/components/portal/index.js +1 -25
  132. package/dist/cjs/components/portal/tokens.js +1 -11
  133. package/dist/cjs/components/progress/Progress.js +1 -216
  134. package/dist/cjs/components/progress/index.js +1 -14
  135. package/dist/cjs/components/progress/tokens.js +1 -52
  136. package/dist/cjs/components/radio/Radio.js +1 -245
  137. package/dist/cjs/components/radio/RadioContext.js +1 -12
  138. package/dist/cjs/components/radio/RadioGroup.js +1 -113
  139. package/dist/cjs/components/radio/index.js +1 -16
  140. package/dist/cjs/components/radio/tokens.js +1 -92
  141. package/dist/cjs/components/safe-area-view/SafeAreaView.js +1 -59
  142. package/dist/cjs/components/safe-area-view/index.js +1 -12
  143. package/dist/cjs/components/safe-area-view/tokens.js +1 -11
  144. package/dist/cjs/components/search/Search.js +1 -215
  145. package/dist/cjs/components/search/index.js +1 -15
  146. package/dist/cjs/components/search/tokens.js +1 -54
  147. package/dist/cjs/components/selector/Selector.js +1 -185
  148. package/dist/cjs/components/selector/index.js +1 -15
  149. package/dist/cjs/components/selector/tokens.js +1 -100
  150. package/dist/cjs/components/share-sheet/ShareSheet.js +1 -286
  151. package/dist/cjs/components/share-sheet/index.js +1 -16
  152. package/dist/cjs/components/share-sheet/tokens.js +1 -55
  153. package/dist/cjs/components/sidebar/Sidebar.js +1 -103
  154. package/dist/cjs/components/sidebar/SidebarContext.js +1 -17
  155. package/dist/cjs/components/sidebar/SidebarItem.js +1 -103
  156. package/dist/cjs/components/sidebar/index.js +1 -26
  157. package/dist/cjs/components/sidebar/tokens.js +1 -93
  158. package/dist/cjs/components/skeleton/Skeleton.js +1 -162
  159. package/dist/cjs/components/skeleton/index.js +1 -22
  160. package/dist/cjs/components/skeleton/tokens.js +1 -39
  161. package/dist/cjs/components/slider/Slider.js +1 -633
  162. package/dist/cjs/components/slider/index.js +1 -8
  163. package/dist/cjs/components/slider/tokens.js +1 -37
  164. package/dist/cjs/components/space/Space.js +1 -134
  165. package/dist/cjs/components/space/index.js +1 -18
  166. package/dist/cjs/components/space/tokens.js +1 -39
  167. package/dist/cjs/components/stepper/Stepper.js +1 -484
  168. package/dist/cjs/components/stepper/index.js +1 -15
  169. package/dist/cjs/components/stepper/tokens.js +1 -60
  170. package/dist/cjs/components/swiper/Swiper.js +1 -364
  171. package/dist/cjs/components/swiper/SwiperItem.js +1 -12
  172. package/dist/cjs/components/swiper/SwiperPagIndicator.js +1 -106
  173. package/dist/cjs/components/swiper/index.js +1 -40
  174. package/dist/cjs/components/swiper/tokens.js +1 -18
  175. package/dist/cjs/components/switch/Switch.js +1 -102
  176. package/dist/cjs/components/switch/index.js +1 -15
  177. package/dist/cjs/components/switch/tokens.js +1 -31
  178. package/dist/cjs/components/tabbar/Tabbar.js +1 -149
  179. package/dist/cjs/components/tabbar/TabbarContext.js +1 -17
  180. package/dist/cjs/components/tabbar/TabbarItem.js +1 -153
  181. package/dist/cjs/components/tabbar/index.js +1 -25
  182. package/dist/cjs/components/tabbar/tokens.js +1 -41
  183. package/dist/cjs/components/tabs/Tabs.js +1 -860
  184. package/dist/cjs/components/tabs/index.js +1 -25
  185. package/dist/cjs/components/tabs/tokens.js +1 -111
  186. package/dist/cjs/components/tag/Tag.js +1 -130
  187. package/dist/cjs/components/tag/index.js +1 -8
  188. package/dist/cjs/components/tag/tokens.js +1 -104
  189. package/dist/cjs/components/toast/Toast.js +1 -303
  190. package/dist/cjs/components/toast/imperative.js +1 -144
  191. package/dist/cjs/components/toast/index.js +1 -10
  192. package/dist/cjs/components/toast/tokens.js +1 -43
  193. package/dist/cjs/components/typography/Typography.js +1 -181
  194. package/dist/cjs/components/typography/index.js +1 -9
  195. package/dist/cjs/components/typography/tokens.js +1 -88
  196. package/dist/cjs/components/water-mark/WaterMark.js +1 -172
  197. package/dist/cjs/components/water-mark/index.js +1 -22
  198. package/dist/cjs/components/water-mark/tokens.js +1 -54
  199. package/dist/cjs/design-system/Text.js +1 -38
  200. package/dist/cjs/design-system/ThemeContext.js +1 -19
  201. package/dist/cjs/design-system/ThemeProvider.js +1 -31
  202. package/dist/cjs/design-system/createComponentTokensHook.js +1 -28
  203. package/dist/cjs/design-system/index.js +1 -66
  204. package/dist/cjs/design-system/mergeTokensOverride.js +1 -9
  205. package/dist/cjs/design-system/presets.js +1 -146
  206. package/dist/cjs/design-system/tokens.js +1 -135
  207. package/dist/cjs/design-system/useTheme.js +1 -16
  208. package/dist/cjs/hooks/animation/index.js +1 -25
  209. package/dist/cjs/hooks/animation/useAnimatedTransition.js +1 -72
  210. package/dist/cjs/hooks/animation/useReducedMotion.js +1 -75
  211. package/dist/cjs/hooks/aria/index.js +1 -49
  212. package/dist/cjs/hooks/aria/useAriaListBox.js +1 -50
  213. package/dist/cjs/hooks/aria/useAriaOverlay.js +1 -50
  214. package/dist/cjs/hooks/aria/useAriaPress.js +1 -94
  215. package/dist/cjs/hooks/aria/useAriaToggle.js +1 -41
  216. package/dist/cjs/hooks/gesture/index.js +1 -16
  217. package/dist/cjs/hooks/gesture/useGestureScroll.js +1 -129
  218. package/dist/cjs/hooks/index.js +1 -96
  219. package/dist/cjs/hooks/overlay/OverlayStackStore.js +1 -106
  220. package/dist/cjs/hooks/overlay/index.js +1 -27
  221. package/dist/cjs/hooks/overlay/useOverlayStack.js +1 -53
  222. package/dist/cjs/hooks/useControllableValue.js +1 -41
  223. package/dist/cjs/hooks/useCountDown.js +1 -99
  224. package/dist/cjs/hooks/useHairline.js +1 -46
  225. package/dist/cjs/hooks/useSafeAreaPadding.js +1 -38
  226. package/dist/cjs/index.js +1 -104
  227. package/dist/cjs/nativewind.js +1 -0
  228. package/dist/cjs/platform/animation.js +1 -22
  229. package/dist/cjs/platform/history.js +1 -14
  230. package/dist/cjs/platform/index.js +1 -60
  231. package/dist/cjs/platform/measure.js +1 -39
  232. package/dist/cjs/platform/runtime.js +1 -19
  233. package/dist/cjs/platform/scrollLock.js +1 -24
  234. package/dist/cjs/utils/array.js +1 -12
  235. package/dist/cjs/utils/color.js +1 -33
  236. package/dist/cjs/utils/compare.js +1 -21
  237. package/dist/cjs/utils/createPlatformShadow.js +1 -52
  238. package/dist/cjs/utils/date.js +1 -45
  239. package/dist/cjs/utils/deepMerge.js +1 -27
  240. package/dist/cjs/utils/hairline.js +1 -107
  241. package/dist/cjs/utils/index.js +1 -148
  242. package/dist/cjs/utils/number.js +1 -65
  243. package/dist/cjs/utils/promise.js +1 -9
  244. package/dist/cjs/utils/render.js +1 -21
  245. package/dist/cjs/utils/rtl.js +1 -25
  246. package/dist/cjs/utils/string.js +1 -22
  247. package/dist/cjs/utils/validate.js +1 -39
  248. package/dist/es/components/action-sheet/ActionSheet.js +1 -271
  249. package/dist/es/components/action-sheet/index.js +1 -3
  250. package/dist/es/components/action-sheet/tokens.js +1 -126
  251. package/dist/es/components/area/Area.js +1 -113
  252. package/dist/es/components/area/index.js +1 -2
  253. package/dist/es/components/area/tokens.js +1 -8
  254. package/dist/es/components/avatar/Avatar.js +1 -106
  255. package/dist/es/components/avatar/index.js +1 -1
  256. package/dist/es/components/avatar/tokens.js +1 -49
  257. package/dist/es/components/badge/Badge.js +1 -147
  258. package/dist/es/components/badge/index.js +1 -2
  259. package/dist/es/components/badge/tokens.js +1 -75
  260. package/dist/es/components/button/Button.js +1 -184
  261. package/dist/es/components/button/ButtonContext.js +1 -1
  262. package/dist/es/components/button/ButtonGroup.js +1 -46
  263. package/dist/es/components/button/index.js +1 -7
  264. package/dist/es/components/button/tokens.js +1 -170
  265. package/dist/es/components/calendar/Calendar.js +1 -432
  266. package/dist/es/components/calendar/index.js +1 -2
  267. package/dist/es/components/calendar/tokens.js +1 -122
  268. package/dist/es/components/cascader/Cascader.js +1 -455
  269. package/dist/es/components/cascader/index.js +1 -3
  270. package/dist/es/components/cascader/tokens.js +1 -131
  271. package/dist/es/components/cascader/useCascaderExtend.js +1 -32
  272. package/dist/es/components/cell/Cell.js +1 -156
  273. package/dist/es/components/cell/CellContext.js +1 -6
  274. package/dist/es/components/cell/CellGroup.js +1 -81
  275. package/dist/es/components/cell/index.js +1 -8
  276. package/dist/es/components/cell/tokens.js +1 -160
  277. package/dist/es/components/checkbox/Checkbox.js +1 -220
  278. package/dist/es/components/checkbox/CheckboxContext.js +1 -1
  279. package/dist/es/components/checkbox/CheckboxGroup.js +1 -117
  280. package/dist/es/components/checkbox/index.js +1 -5
  281. package/dist/es/components/checkbox/tokens.js +1 -85
  282. package/dist/es/components/circle/Circle.js +1 -187
  283. package/dist/es/components/circle/index.js +1 -2
  284. package/dist/es/components/circle/tokens.js +1 -48
  285. package/dist/es/components/collapse/Collapse.js +1 -286
  286. package/dist/es/components/collapse/index.js +1 -2
  287. package/dist/es/components/collapse/tokens.js +1 -74
  288. package/dist/es/components/config-provider/ConfigProvider.js +1 -25
  289. package/dist/es/components/config-provider/DirectionContext.js +1 -2
  290. package/dist/es/components/config-provider/LocaleContext.js +1 -3
  291. package/dist/es/components/config-provider/index.js +1 -5
  292. package/dist/es/components/config-provider/locale/en-US.js +1 -106
  293. package/dist/es/components/config-provider/locale/zh-CN.js +1 -106
  294. package/dist/es/components/config-provider/tokens.js +1 -5
  295. package/dist/es/components/config-provider/useDirection.js +1 -3
  296. package/dist/es/components/config-provider/useLocale.js +1 -3
  297. package/dist/es/components/count-down/CountDown.js +1 -69
  298. package/dist/es/components/count-down/index.js +1 -3
  299. package/dist/es/components/count-down/tokens.js +1 -27
  300. package/dist/es/components/datetime-picker/DatetimePicker.js +1 -305
  301. package/dist/es/components/datetime-picker/index.js +1 -2
  302. package/dist/es/components/datetime-picker/tokens.js +1 -16
  303. package/dist/es/components/dialog/Dialog.js +1 -407
  304. package/dist/es/components/dialog/imperative.js +1 -185
  305. package/dist/es/components/dialog/index.js +1 -17
  306. package/dist/es/components/dialog/tokens.js +1 -57
  307. package/dist/es/components/divider/Divider.js +1 -107
  308. package/dist/es/components/divider/index.js +1 -2
  309. package/dist/es/components/divider/tokens.js +1 -55
  310. package/dist/es/components/empty/Empty.js +1 -100
  311. package/dist/es/components/empty/index.js +1 -2
  312. package/dist/es/components/empty/tokens.js +1 -48
  313. package/dist/es/components/error-boundary/ErrorBoundary.js +1 -62
  314. package/dist/es/components/error-boundary/index.js +1 -1
  315. package/dist/es/components/field/Field.js +1 -539
  316. package/dist/es/components/field/index.js +1 -6
  317. package/dist/es/components/field/tokens.js +1 -138
  318. package/dist/es/components/flex/Flex.js +1 -66
  319. package/dist/es/components/flex/FlexContext.js +1 -1
  320. package/dist/es/components/flex/FlexItem.js +1 -76
  321. package/dist/es/components/flex/index.js +1 -8
  322. package/dist/es/components/flex/tokens.js +1 -15
  323. package/dist/es/components/form/Form.js +1 -319
  324. package/dist/es/components/form/FormContext.js +1 -1
  325. package/dist/es/components/form/FormItem.js +1 -138
  326. package/dist/es/components/form/FormList.js +1 -81
  327. package/dist/es/components/form/index.js +1 -13
  328. package/dist/es/components/form/tokens.js +1 -8
  329. package/dist/es/components/form/utils.js +1 -45
  330. package/dist/es/components/grid/Grid.js +1 -99
  331. package/dist/es/components/grid/GridContext.js +1 -1
  332. package/dist/es/components/grid/GridItem.js +1 -138
  333. package/dist/es/components/grid/index.js +1 -6
  334. package/dist/es/components/grid/tokens.js +1 -98
  335. package/dist/es/components/image/Image.js +1 -238
  336. package/dist/es/components/image/index.js +1 -3
  337. package/dist/es/components/image/tokens.js +1 -60
  338. package/dist/es/components/image-preview/ImagePreview.js +1 -378
  339. package/dist/es/components/image-preview/imperative.js +1 -58
  340. package/dist/es/components/image-preview/index.js +1 -11
  341. package/dist/es/components/image-preview/tokens.js +1 -37
  342. package/dist/es/components/index.js +1 -110
  343. package/dist/es/components/input/Input.js +1 -109
  344. package/dist/es/components/input/index.js +1 -3
  345. package/dist/es/components/input/tokens.js +1 -16
  346. package/dist/es/components/loading/Loading.js +1 -57
  347. package/dist/es/components/loading/index.js +1 -2
  348. package/dist/es/components/loading/tokens.js +1 -25
  349. package/dist/es/components/nav-bar/NavBar.js +1 -171
  350. package/dist/es/components/nav-bar/index.js +1 -3
  351. package/dist/es/components/nav-bar/tokens.js +1 -83
  352. package/dist/es/components/notice-bar/NoticeBar.js +1 -344
  353. package/dist/es/components/notice-bar/index.js +1 -2
  354. package/dist/es/components/notice-bar/tokens.js +1 -32
  355. package/dist/es/components/notify/Notify.js +1 -242
  356. package/dist/es/components/notify/imperative.js +1 -131
  357. package/dist/es/components/notify/index.js +1 -5
  358. package/dist/es/components/notify/tokens.js +1 -67
  359. package/dist/es/components/number-keyboard/NumberKeyboard.js +1 -467
  360. package/dist/es/components/number-keyboard/index.js +1 -3
  361. package/dist/es/components/number-keyboard/tokens.js +1 -53
  362. package/dist/es/components/overlay/Overlay.js +1 -50
  363. package/dist/es/components/overlay/index.js +1 -4
  364. package/dist/es/components/overlay/tokens.js +1 -7
  365. package/dist/es/components/password-input/PasswordInput.js +1 -327
  366. package/dist/es/components/password-input/index.js +1 -1
  367. package/dist/es/components/password-input/tokens.js +1 -41
  368. package/dist/es/components/picker/Picker.js +1 -1031
  369. package/dist/es/components/picker/index.js +1 -3
  370. package/dist/es/components/picker/tokens.js +1 -47
  371. package/dist/es/components/popup/Popup.js +1 -492
  372. package/dist/es/components/popup/index.js +1 -3
  373. package/dist/es/components/popup/tokens.js +1 -55
  374. package/dist/es/components/portal/Portal.js +1 -37
  375. package/dist/es/components/portal/PortalContext.js +1 -2
  376. package/dist/es/components/portal/PortalHost.js +1 -234
  377. package/dist/es/components/portal/index.js +1 -3
  378. package/dist/es/components/portal/tokens.js +1 -5
  379. package/dist/es/components/progress/Progress.js +1 -196
  380. package/dist/es/components/progress/index.js +1 -3
  381. package/dist/es/components/progress/tokens.js +1 -45
  382. package/dist/es/components/radio/Radio.js +1 -214
  383. package/dist/es/components/radio/RadioContext.js +1 -1
  384. package/dist/es/components/radio/RadioGroup.js +1 -82
  385. package/dist/es/components/radio/index.js +1 -5
  386. package/dist/es/components/radio/tokens.js +1 -80
  387. package/dist/es/components/safe-area-view/SafeAreaView.js +1 -40
  388. package/dist/es/components/safe-area-view/index.js +1 -1
  389. package/dist/es/components/safe-area-view/tokens.js +1 -5
  390. package/dist/es/components/search/Search.js +1 -189
  391. package/dist/es/components/search/index.js +1 -3
  392. package/dist/es/components/search/tokens.js +1 -48
  393. package/dist/es/components/selector/Selector.js +1 -166
  394. package/dist/es/components/selector/index.js +1 -3
  395. package/dist/es/components/selector/tokens.js +1 -88
  396. package/dist/es/components/share-sheet/ShareSheet.js +1 -266
  397. package/dist/es/components/share-sheet/index.js +1 -3
  398. package/dist/es/components/share-sheet/tokens.js +1 -49
  399. package/dist/es/components/sidebar/Sidebar.js +1 -84
  400. package/dist/es/components/sidebar/SidebarContext.js +1 -3
  401. package/dist/es/components/sidebar/SidebarItem.js +1 -84
  402. package/dist/es/components/sidebar/index.js +1 -8
  403. package/dist/es/components/sidebar/tokens.js +1 -80
  404. package/dist/es/components/skeleton/Skeleton.js +1 -143
  405. package/dist/es/components/skeleton/index.js +1 -4
  406. package/dist/es/components/skeleton/tokens.js +1 -33
  407. package/dist/es/components/slider/Slider.js +1 -596
  408. package/dist/es/components/slider/index.js +1 -2
  409. package/dist/es/components/slider/tokens.js +1 -31
  410. package/dist/es/components/space/Space.js +1 -115
  411. package/dist/es/components/space/index.js +1 -2
  412. package/dist/es/components/space/tokens.js +1 -32
  413. package/dist/es/components/stepper/Stepper.js +1 -465
  414. package/dist/es/components/stepper/index.js +1 -3
  415. package/dist/es/components/stepper/tokens.js +1 -54
  416. package/dist/es/components/swiper/Swiper.js +1 -344
  417. package/dist/es/components/swiper/SwiperItem.js +1 -1
  418. package/dist/es/components/swiper/SwiperPagIndicator.js +1 -87
  419. package/dist/es/components/swiper/index.js +1 -10
  420. package/dist/es/components/swiper/tokens.js +1 -12
  421. package/dist/es/components/switch/Switch.js +1 -83
  422. package/dist/es/components/switch/index.js +1 -3
  423. package/dist/es/components/switch/tokens.js +1 -25
  424. package/dist/es/components/tabbar/Tabbar.js +1 -130
  425. package/dist/es/components/tabbar/TabbarContext.js +1 -3
  426. package/dist/es/components/tabbar/TabbarItem.js +1 -133
  427. package/dist/es/components/tabbar/index.js +1 -7
  428. package/dist/es/components/tabbar/tokens.js +1 -35
  429. package/dist/es/components/tabs/Tabs.js +1 -841
  430. package/dist/es/components/tabs/index.js +1 -7
  431. package/dist/es/components/tabs/tokens.js +1 -105
  432. package/dist/es/components/tag/Tag.js +1 -105
  433. package/dist/es/components/tag/index.js +1 -2
  434. package/dist/es/components/tag/tokens.js +1 -97
  435. package/dist/es/components/toast/Toast.js +1 -277
  436. package/dist/es/components/toast/imperative.js +1 -130
  437. package/dist/es/components/toast/index.js +1 -5
  438. package/dist/es/components/toast/tokens.js +1 -36
  439. package/dist/es/components/typography/Typography.js +1 -162
  440. package/dist/es/components/typography/index.js +1 -2
  441. package/dist/es/components/typography/tokens.js +1 -82
  442. package/dist/es/components/water-mark/WaterMark.js +1 -153
  443. package/dist/es/components/water-mark/index.js +1 -4
  444. package/dist/es/components/water-mark/tokens.js +1 -42
  445. package/dist/es/design-system/Text.js +1 -19
  446. package/dist/es/design-system/ThemeContext.js +1 -6
  447. package/dist/es/design-system/ThemeProvider.js +1 -17
  448. package/dist/es/design-system/createComponentTokensHook.js +1 -15
  449. package/dist/es/design-system/index.js +1 -7
  450. package/dist/es/design-system/mergeTokensOverride.js +1 -2
  451. package/dist/es/design-system/presets.js +1 -139
  452. package/dist/es/design-system/tokens.js +1 -128
  453. package/dist/es/design-system/useTheme.js +1 -3
  454. package/dist/es/hooks/animation/index.js +1 -2
  455. package/dist/es/hooks/animation/useAnimatedTransition.js +1 -53
  456. package/dist/es/hooks/animation/useReducedMotion.js +1 -54
  457. package/dist/es/hooks/aria/index.js +1 -5
  458. package/dist/es/hooks/aria/useAriaListBox.js +1 -25
  459. package/dist/es/hooks/aria/useAriaOverlay.js +1 -25
  460. package/dist/es/hooks/aria/useAriaPress.js +1 -57
  461. package/dist/es/hooks/aria/useAriaToggle.js +1 -16
  462. package/dist/es/hooks/gesture/index.js +1 -2
  463. package/dist/es/hooks/gesture/useGestureScroll.js +1 -110
  464. package/dist/es/hooks/index.js +1 -8
  465. package/dist/es/hooks/overlay/OverlayStackStore.js +1 -93
  466. package/dist/es/hooks/overlay/index.js +1 -3
  467. package/dist/es/hooks/overlay/useOverlayStack.js +1 -40
  468. package/dist/es/hooks/useControllableValue.js +1 -29
  469. package/dist/es/hooks/useCountDown.js +1 -87
  470. package/dist/es/hooks/useHairline.js +1 -26
  471. package/dist/es/hooks/useSafeAreaPadding.js +1 -20
  472. package/dist/es/index.js +1 -11
  473. package/dist/es/nativewind.js +1 -0
  474. package/dist/es/platform/animation.js +1 -10
  475. package/dist/es/platform/history.js +1 -7
  476. package/dist/es/platform/index.js +1 -6
  477. package/dist/es/platform/measure.js +1 -32
  478. package/dist/es/platform/runtime.js +1 -4
  479. package/dist/es/platform/scrollLock.js +1 -16
  480. package/dist/es/types.js +1 -1
  481. package/dist/es/utils/array.js +1 -5
  482. package/dist/es/utils/color.js +1 -25
  483. package/dist/es/utils/compare.js +1 -13
  484. package/dist/es/utils/createPlatformShadow.js +1 -39
  485. package/dist/es/utils/date.js +1 -33
  486. package/dist/es/utils/deepMerge.js +1 -21
  487. package/dist/es/utils/hairline.js +1 -93
  488. package/dist/es/utils/index.js +1 -14
  489. package/dist/es/utils/number.js +1 -48
  490. package/dist/es/utils/promise.js +1 -2
  491. package/dist/es/utils/render.js +1 -7
  492. package/dist/es/utils/rtl.js +1 -17
  493. package/dist/es/utils/string.js +1 -13
  494. package/dist/es/utils/validate.js +1 -14
  495. package/dist/types/nativewind.d.ts +4 -0
  496. package/package.json +15 -3
@@ -1,841 +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 } from 'react';
3
- import { Animated, Pressable, StyleSheet, Text, ScrollView, View, Platform } from 'react-native';
4
- import { useAriaPress, useControllableValue } from '../../hooks';
5
- import { useReducedMotion } from '../../hooks/animation';
6
- import { createHairlineView } from '../../utils/hairline';
7
- import { parseNumberLike } from '../../utils/number';
8
- import { isBoolean, isFunction, isObject, isRenderable, isText } from '../../utils/validate';
9
- import { useTabsTokens } from './tokens';
10
- const TabPane = () => null;
11
- TabPane.displayName = 'Tabs.TabPane';
12
- const hasRaf = typeof requestAnimationFrame === 'function' && typeof cancelAnimationFrame === 'function';
13
- const requestFrame = hasRaf ? requestAnimationFrame : cb => setTimeout(cb, 16);
14
- const cancelFrame = id => {
15
- if (id != null) (hasRaf ? cancelAnimationFrame : clearTimeout)(id);
16
- };
17
- const isTabPaneElement = child => {
18
- if (! /*#__PURE__*/React.isValidElement(child)) return false;
19
- if (child.type === TabPane) return true;
20
- return child.type.displayName === 'Tabs.TabPane';
21
- };
22
- const useTabsAnimation = ({
23
- type,
24
- animated,
25
- scrollable,
26
- align,
27
- panes,
28
- nameIndexMap,
29
- resolvedLineWidth,
30
- resolvedDuration,
31
- currentName,
32
- layoutMap,
33
- navContainerWidthRef
34
- }) => {
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);
39
- const animateIndicator = useCallback((name, immediate) => {
40
- if (name == null || type !== 'line') return false;
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
47
- } : layoutMap.current.get(name);
48
- if (!lay || idx < 0) return false;
49
- animRef.current?.stop();
50
- const timing = (v, to) => Animated.timing(v, {
51
- toValue: to,
52
- duration: immediate || !animated ? 0 : resolvedDuration,
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;
64
- });
65
- return true;
66
- }, [align, animated, indW, indX, nameIndexMap, panes.length, resolvedDuration, resolvedLineWidth, scrollable, type, layoutMap, navContainerWidthRef]);
67
- useEffect(() => {
68
- if (currentName == null) return;
69
- const should = indInitRef.current;
70
- const did = animateIndicator(currentName, !should);
71
- if (did && !indInitRef.current) indInitRef.current = true;
72
- }, [animateIndicator, currentName]);
73
- useEffect(() => () => {
74
- animRef.current?.stop();
75
- animRef.current = null;
76
- }, []);
77
- return {
78
- indicatorX: indX,
79
- indicatorWidth: indW,
80
- indicatorInitializedRef: indInitRef,
81
- animateIndicator
82
- };
83
- };
84
- const useTabsScroll = ({
85
- scrollable,
86
- animated,
87
- currentName,
88
- resolvedDuration,
89
- layoutMap,
90
- navContainerWidthRef,
91
- navContentWidthRef
92
- }) => {
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);
99
- const scrollIntoView = useCallback(immediate => {
100
- if (!scrollable || currentName == null) return;
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;
113
- if (immediate || !animated) {
114
- autoScrRef.current = true;
115
- navX.setValue(clampX);
116
- frameRef.current = requestFrame(() => {
117
- frameRef.current = null;
118
- autoScrRef.current = false;
119
- });
120
- return;
121
- }
122
- navX.setValue(lastXRef.current);
123
- autoScrRef.current = true;
124
- navAnimRef.current = Animated.timing(navX, {
125
- toValue: clampX,
126
- duration: resolvedDuration,
127
- useNativeDriver: false,
128
- isInteraction: false
129
- });
130
- navAnimRef.current.start(({
131
- finished
132
- }) => {
133
- navAnimRef.current = null;
134
- autoScrRef.current = false;
135
- if (finished) lastXRef.current = clampX;
136
- });
137
- }, [animated, currentName, navX, resolvedDuration, scrollable, layoutMap, navContainerWidthRef, navContentWidthRef]);
138
- useEffect(() => {
139
- if (!scrollable) return;
140
- const id = navX.addListener(({
141
- value
142
- }) => {
143
- const prev = lastXRef.current;
144
- lastXRef.current = value;
145
- if (Math.abs(value - prev) >= 0.5) navScrRef.current?.scrollTo({
146
- x: value,
147
- y: 0,
148
- animated: false
149
- });
150
- });
151
- return () => navX.removeListener(id);
152
- }, [navX, scrollable]);
153
- useEffect(() => () => {
154
- cancelFrame(frameRef.current);
155
- frameRef.current = null;
156
- }, []);
157
- const onNavBeginDrag = useCallback(e => {
158
- autoScrRef.current = false;
159
- navAnimRef.current?.stop();
160
- navAnimRef.current = null;
161
- lastXRef.current = e.nativeEvent.contentOffset.x;
162
- }, []);
163
- const onNavScroll = useCallback(e => {
164
- if (autoScrRef.current) return;
165
- lastXRef.current = e.nativeEvent.contentOffset.x;
166
- }, []);
167
- return {
168
- navScrollRef: navScrRef,
169
- navScrollX: navX,
170
- scrollIntoView,
171
- handleNavScrollBeginDrag: onNavBeginDrag,
172
- handleNavScroll: onNavScroll
173
- };
174
- };
175
- const TabBarItemInner = ({
176
- pane,
177
- isActive,
178
- align,
179
- scrollable,
180
- type,
181
- ellipsis,
182
- tokens,
183
- color,
184
- titleActiveColor,
185
- titleInactiveColor,
186
- tabStyle,
187
- titleStyle,
188
- descriptionStyle,
189
- onSelect,
190
- onLayout,
191
- isLast
192
- }) => {
193
- const dis = !!pane.disabled;
194
- const aria = useAriaPress({
195
- onPress: e => onSelect(pane, pane.index, e),
196
- extraProps: {
197
- accessibilityRole: 'tab',
198
- accessibilityState: {
199
- selected: isActive,
200
- disabled: dis
201
- },
202
- testID: `rv-tabs-item-${pane.name}`
203
- }
204
- });
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 ? [{
232
- flex: 1,
233
- alignSelf: 'stretch',
234
- justifyContent: 'center',
235
- alignItems: 'center',
236
- borderRadius: tokens.capsule.radius,
237
- backgroundColor: isActive ? color ?? tokens.colors.capsuleActiveBackground : tokens.colors.capsuleBackground
238
- }] : null;
239
- const titleStyleArr = [S.title, {
240
- color: txtClr,
241
- fontFamily: tokens.typography.fontFamily,
242
- fontSize: isJ ? tokens.typography.jumboTitleSize : tokens.typography.titleSize,
243
- fontWeight: isActive ? tokens.typography.titleActiveWeight : tokens.typography.titleWeight,
244
- lineHeight: isJ ? tokens.typography.jumboLineHeight : undefined,
245
- textAlign: 'center'
246
- }, ellipsis && !isJ ? S.ellipsis : null, titleStyle];
247
- const descMT = isJ ? tokens.spacing.jumboDescriptionMarginTop : tokens.spacing.descriptionMarginTop;
248
- const descJStyle = isJ ? {
249
- backgroundColor: isActive ? tokens.colors.jumboDescriptionActiveBackground : tokens.colors.jumboDescriptionBackground,
250
- paddingHorizontal: tokens.jumbo.descriptionPaddingHorizontal,
251
- paddingVertical: tokens.jumbo.descriptionPaddingVertical,
252
- borderRadius: tokens.jumbo.descriptionRadius
253
- } : null;
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 ? {
261
- backgroundColor: isActive ? color ?? tokens.colors.cardActiveBackground : tokens.colors.cardBackground
262
- } : null, tabStyle]
263
- }), /*#__PURE__*/React.createElement(View, {
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: {
288
- marginTop: tokens.spacing.badgeMarginTop
289
- }
290
- }, isText(pane.badge) ? /*#__PURE__*/React.createElement(Text, {
291
- style: {
292
- color: tokens.colors.badgeText,
293
- fontFamily: tokens.typography.fontFamily,
294
- fontSize: tokens.typography.badgeTextSize
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
- }));
304
- };
305
- const TabBarItem = /*#__PURE__*/memo(TabBarItemInner);
306
- const TabsBaseInner = (props, ref) => {
307
- const {
308
- tokensOverride,
309
- children,
310
- type: typeProp,
311
- align: alignProp,
312
- ellipsis: ellipsisProp,
313
- swipeThreshold: swipeThresholdProp,
314
- animated: animatedProp,
315
- duration: durationProp,
316
- lazyRender: lazyRenderProp,
317
- lazyRenderPlaceholder,
318
- scrollable: scrollableProp,
319
- swipeable,
320
- color,
321
- background: backgroundProp,
322
- border,
323
- navLeft,
324
- navRight,
325
- navBottom,
326
- tabBarStyle,
327
- tabStyle,
328
- titleStyle,
329
- descriptionStyle,
330
- contentStyle,
331
- lineWidth,
332
- lineHeight,
333
- titleActiveColor,
334
- titleInactiveColor,
335
- beforeChange,
336
- onClickTab,
337
- onChange,
338
- style,
339
- ...rest
340
- } = props;
341
- const tokens = useTabsTokens(tokensOverride);
342
- const reducedMotion = useReducedMotion();
343
- const type = typeProp ?? tokens.defaults.type;
344
- const align = alignProp ?? tokens.defaults.align;
345
- const ellipsis = ellipsisProp ?? tokens.defaults.ellipsis;
346
- const swipeThreshold = swipeThresholdProp ?? tokens.defaults.swipeThreshold;
347
- const animated = animatedProp ?? tokens.defaults.animated;
348
- const duration = durationProp ?? tokens.defaults.duration;
349
- const lazyRender = lazyRenderProp ?? tokens.defaults.lazyRender;
350
- const background = backgroundProp ?? tokens.tabList.background;
351
- const parsedLineWidth = parseNumberLike(lineWidth ?? tokens.indicator.width);
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) ? {
357
- autoHeight: swipeable.autoHeight ?? true,
358
- preventScroll: swipeable.preventScroll ?? true
359
- } : {
360
- autoHeight: true,
361
- preventScroll: true
362
- };
363
- const isSwipe = !!swipeCfg;
364
- const panes = useMemo(() => {
365
- const result = [];
366
- let paneIndex = 0;
367
- const walk = nodes => {
368
- Children.forEach(nodes, node => {
369
- if (! /*#__PURE__*/isValidElement(node)) return;
370
- const element = node;
371
- if (element.type === React.Fragment) {
372
- walk(element.props.children);
373
- return;
374
- }
375
- if (!isTabPaneElement(element)) return;
376
- const paneProps = element.props;
377
- const name = paneProps.name ?? paneIndex;
378
- result.push({
379
- ...paneProps,
380
- key: element.key ?? name,
381
- name,
382
- index: paneIndex
383
- });
384
- paneIndex += 1;
385
- });
386
- };
387
- walk(children);
388
- return result;
389
- }, [children]);
390
- const firstPaneName = panes[0]?.name;
391
- const [actVal, setActVal] = useControllableValue(props, {
392
- defaultValue: firstPaneName,
393
- valuePropName: 'active',
394
- defaultValuePropName: 'defaultActive',
395
- trigger: 'onChange'
396
- });
397
- const curName = actVal == null ? firstPaneName : panes.some(pane => pane.name === actVal) ? actVal : firstPaneName;
398
- const curNameRef = useRef(curName);
399
- useEffect(() => {
400
- curNameRef.current = curName;
401
- }, [curName]);
402
- const nameIdxMap = useMemo(() => {
403
- const map = new Map();
404
- panes.forEach(pane => {
405
- map.set(pane.name, pane.index);
406
- });
407
- return map;
408
- }, [panes]);
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);
420
- useEffect(() => {
421
- if (curName == null) return;
422
- visRef.current.add(curName);
423
- }, [curName]);
424
- useEffect(() => {
425
- const validNames = new Set(panes.map(pane => pane.name));
426
- Array.from(paneLayMap.current.keys()).forEach(name => {
427
- if (!validNames.has(name)) paneLayMap.current.delete(name);
428
- });
429
- Array.from(layMap.current.keys()).forEach(name => {
430
- if (!validNames.has(name)) layMap.current.delete(name);
431
- });
432
- }, [panes]);
433
- const trackPaneLay = isSwipe && swipeCfg?.autoHeight;
434
- useEffect(() => {
435
- if (!trackPaneLay) paneLayMap.current.clear();
436
- }, [trackPaneLay]);
437
- useEffect(() => {
438
- if (!isSwipe || !swipeCfg?.autoHeight) {
439
- setSwipeH(undefined);
440
- return;
441
- }
442
- const layout = curName != null ? paneLayMap.current.get(curName) : undefined;
443
- if (layout) setSwipeH(layout.height);else setSwipeH(undefined);
444
- }, [curName, isSwipe, swipeCfg?.autoHeight]);
445
- useEffect(() => {
446
- return () => {
447
- cancelFrame(navCntSyncRef.current);
448
- navCntSyncRef.current = null;
449
- };
450
- }, []);
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;
454
- const {
455
- indicatorX,
456
- indicatorWidth,
457
- indicatorInitializedRef,
458
- animateIndicator
459
- } = useTabsAnimation({
460
- type,
461
- animated,
462
- scrollable,
463
- align,
464
- panes,
465
- nameIndexMap: nameIdxMap,
466
- resolvedLineWidth: resLineW,
467
- resolvedLineHeight: resLineH,
468
- resolvedDuration: resDur,
469
- currentName: curName,
470
- layoutMap: layMap,
471
- navContainerWidthRef: navCtrWRef
472
- });
473
- const {
474
- navScrollRef,
475
- scrollIntoView,
476
- handleNavScrollBeginDrag,
477
- handleNavScroll
478
- } = useTabsScroll({
479
- scrollable,
480
- animated,
481
- currentName: curName,
482
- resolvedDuration: resDur,
483
- layoutMap: layMap,
484
- navContainerWidthRef: navCtrWRef,
485
- navContentWidthRef: navCntWRef
486
- });
487
- const onTabLayout = useCallback((name, event) => {
488
- const {
489
- x,
490
- width
491
- } = event.nativeEvent.layout;
492
- layMap.current.set(name, {
493
- x,
494
- width
495
- });
496
- if (name === curNameRef.current) {
497
- const shouldAnimate = indicatorInitializedRef.current;
498
- const didAnimate = animateIndicator(name, !shouldAnimate);
499
- if (didAnimate && !indicatorInitializedRef.current) indicatorInitializedRef.current = true;
500
- }
501
- }, [animateIndicator, indicatorInitializedRef]);
502
- const onNavCtrLayout = useCallback(event => {
503
- const {
504
- width
505
- } = event.nativeEvent.layout;
506
- navCtrWRef.current = width;
507
- if (!scrollable && align !== 'start' && type === 'line' && curName !== undefined && curName !== null) {
508
- const shouldAnimate = indicatorInitializedRef.current;
509
- const didAnimate = animateIndicator(curName, !shouldAnimate);
510
- if (didAnimate && !indicatorInitializedRef.current) indicatorInitializedRef.current = true;
511
- }
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);
516
- }, []);
517
- const beforeChgRef = useRef(beforeChange);
518
- beforeChgRef.current = beforeChange;
519
- const runBeforeChg = useCallback(name => {
520
- if (!beforeChgRef.current) return Promise.resolve(true);
521
- try {
522
- return Promise.resolve(beforeChgRef.current(name)).then(res => res !== false).catch(() => false);
523
- } catch (error) {
524
- return Promise.resolve(false);
525
- }
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 => {
532
- if (!canChange) return;
533
- if (chgSeqRef.current !== seq) return;
534
- setActVal(name, index);
535
- });
536
- }, [runBeforeChg, setActVal]);
537
- const onPaneLayout = useCallback((name, event) => {
538
- if (isSwipe && swipeCfg?.autoHeight) {
539
- const {
540
- height
541
- } = event.nativeEvent.layout;
542
- paneLayMap.current.set(name, {
543
- height
544
- });
545
- if (name === curName) setSwipeH(height);
546
- }
547
- }, [curName, isSwipe, swipeCfg?.autoHeight]);
548
- const swipeEndIdxRef = useRef(null);
549
- useEffect(() => {
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]);
568
- useEffect(() => {
569
- if (!isSwipe || !swipeScrRef.current || ctrW <= 0) return;
570
- if (swipeChgRef.current) {
571
- swipeChgRef.current = false;
572
- return;
573
- }
574
- if (actIdx < 0) return;
575
- const node = swipeScrRef.current?.getNode?.() ?? swipeScrRef.current;
576
- if (!node?.scrollTo) return;
577
- node.scrollTo({
578
- x: ctrW * actIdx,
579
- y: 0,
580
- animated: true
581
- });
582
- }, [actIdx, ctrW, isSwipe]);
583
- const onClickTabRef = useRef(onClickTab);
584
- onClickTabRef.current = onClickTab;
585
- const onSel = useCallback((pane, index, event) => {
586
- const payload = {
587
- name: pane.name,
588
- index,
589
- disabled: !!pane.disabled,
590
- event
591
- };
592
- onClickTabRef.current?.(payload);
593
- if (pane.disabled || pane.name === curNameRef.current) return;
594
- reqChg(pane.name, index);
595
- }, [reqChg]);
596
- const scrollTo = useCallback((name, _options) => {
597
- const target = panes.find(pane => pane.name === name && !pane.disabled);
598
- if (!target) return;
599
- setActVal(target.name, target.index);
600
- }, [panes, setActVal]);
601
- useImperativeHandle(ref, () => ({
602
- scrollTo
603
- }), [scrollTo]);
604
- const firstRndRef = useRef(true);
605
- useEffect(() => {
606
- if (firstRndRef.current) {
607
- firstRndRef.current = false;
608
- scrollIntoView(true);
609
- }
610
- }, [scrollIntoView]);
611
- useEffect(() => {
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
630
- }]
631
- }]
632
- }) : null;
633
- const navItems = useMemo(() => panes.map(pane => /*#__PURE__*/React.createElement(TabBarItem, {
634
- key: pane.key,
635
- pane: pane,
636
- isActive: pane.name === curName,
637
- align: align,
638
- scrollable: scrollable,
639
- type: type,
640
- ellipsis: ellipsis,
641
- tokens: tokens,
642
- color: color,
643
- titleActiveColor: titleActiveColor,
644
- titleInactiveColor: titleInactiveColor,
645
- tabStyle: tabStyle,
646
- titleStyle: titleStyle,
647
- descriptionStyle: descriptionStyle,
648
- onSelect: onSel,
649
- onLayout: onTabLayout,
650
- isLast: pane.index === panes.length - 1
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) {
656
- scrollIntoView(true);
657
- return;
658
- }
659
- if (Math.abs(w - prev) > 1) {
660
- cancelFrame(navCntSyncRef.current);
661
- navCntSyncRef.current = requestFrame(() => {
662
- navCntSyncRef.current = null;
663
- scrollIntoView();
664
- });
665
- }
666
- }, [scrollIntoView]);
667
- const navBody = scrollable ? /*#__PURE__*/React.createElement(ScrollView, {
668
- horizontal: true,
669
- ref: navScrollRef,
670
- accessibilityRole: "tablist",
671
- showsHorizontalScrollIndicator: false,
672
- scrollEventThrottle: 16,
673
- onScrollBeginDrag: handleNavScrollBeginDrag,
674
- onScroll: handleNavScroll,
675
- onContentSizeChange: onNavCntSizeChg,
676
- contentContainerStyle: S.navC
677
- }, navItems, indicatorNode) : /*#__PURE__*/React.createElement(View, {
678
- accessibilityRole: "tablist",
679
- style: [S.navC, S.navCSta]
680
- }, navItems, indicatorNode);
681
- const navContent = /*#__PURE__*/React.createElement(View, {
682
- style: [S.wrap, {
683
- backgroundColor: background
684
- }, tabBarStyle]
685
- }, navLeft && /*#__PURE__*/React.createElement(View, {
686
- style: {
687
- paddingHorizontal: tokens.spacing.navSidePaddingHorizontal
688
- }
689
- }, navLeft), /*#__PURE__*/React.createElement(View, {
690
- style: [S.nav, {
691
- minHeight: navH + navPB,
692
- paddingBottom: navPB
693
- }, type === 'card' ? {
694
- borderRadius: tokens.card.radius,
695
- marginHorizontal: tokens.card.marginHorizontal,
696
- overflow: 'hidden'
697
- } : null],
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: {
707
- paddingHorizontal: tokens.spacing.navSidePaddingHorizontal
708
- }
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];
725
- const paneContent = shouldRender ? pane.children : lazyRenderPlaceholder || null;
726
- return /*#__PURE__*/React.createElement(View, {
727
- key: pane.key,
728
- testID: `rv-tabs-pane-${pane.name}`,
729
- onLayout: layoutHandler,
730
- style: paneStyles
731
- }, paneContent);
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
739
- }, /*#__PURE__*/React.createElement(Animated.ScrollView, {
740
- ref: swipeScrRef,
741
- horizontal: true,
742
- pagingEnabled: true,
743
- scrollEventThrottle: 16,
744
- showsHorizontalScrollIndicator: false,
745
- onMomentumScrollEnd: onSwipeMomentumScrollEnd,
746
- onScrollEndDrag: onSwipeScrollEndDrag,
747
- nestedScrollEnabled: swipeCfg?.preventScroll === false,
748
- directionalLockEnabled: swipeCfg?.preventScroll !== false
749
- }, paneNodes)) : /*#__PURE__*/React.createElement(View, {
750
- style: baseContentStyle
751
- }, paneNodes);
752
- return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
753
- style: [S.ctr, style],
754
- onLayout: onCtrLayout
755
- }), navContent, navBottom && /*#__PURE__*/React.createElement(View, {
756
- style: {
757
- marginTop: tokens.spacing.navBottomMarginTop
758
- }
759
- }, navBottom), contentNode);
760
- };
761
- const S = StyleSheet.create({
762
- ctr: {
763
- width: '100%'
764
- },
765
- wrap: {
766
- flexDirection: 'row',
767
- alignItems: 'center',
768
- position: 'relative'
769
- },
770
- nav: {
771
- flex: 1,
772
- position: 'relative',
773
- alignSelf: 'stretch'
774
- },
775
- navC: {
776
- flexDirection: 'row',
777
- alignItems: 'center',
778
- height: '100%',
779
- position: 'relative'
780
- },
781
- navCSta: {
782
- flex: 1
783
- },
784
- lblW: {
785
- justifyContent: 'center',
786
- alignItems: 'center',
787
- flexDirection: 'column'
788
- },
789
- lblWJ: {
790
- alignItems: 'center'
791
- },
792
- cardLbl: {
793
- flexDirection: 'row',
794
- justifyContent: 'center',
795
- alignItems: 'center'
796
- },
797
- tabI: {
798
- flexShrink: 0,
799
- height: '100%',
800
- alignSelf: 'stretch',
801
- alignItems: 'center',
802
- justifyContent: 'center',
803
- flexDirection: 'row'
804
- },
805
- flexI: {
806
- flexGrow: 1
807
- },
808
- title: {
809
- includeFontPadding: false
810
- },
811
- descTxt: {
812
- includeFontPadding: false
813
- },
814
- ellipsis: {
815
- maxWidth: '100%',
816
- flexShrink: 1
817
- },
818
- ind: {
819
- position: 'absolute',
820
- bottom: 0,
821
- left: 0
822
- },
823
- content: {
824
- width: '100%'
825
- },
826
- pane: {
827
- width: '100%'
828
- },
829
- swipePane: {
830
- flexShrink: 0
831
- },
832
- hidPane: {
833
- display: 'none'
834
- }
835
- });
836
- const TabsBaseRef = /*#__PURE__*/React.forwardRef(TabsBaseInner);
837
- const TabsWithPane = Object.assign(/*#__PURE__*/React.memo(TabsBaseRef), {
838
- TabPane
839
- });
840
- export { TabPane };
841
- export default TabsWithPane;
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_extends.apply(null,arguments)}import React,{memo,useCallback,useEffect,useImperativeHandle,useRef,useState,useMemo,Children,isValidElement}from"react";import{Animated,Pressable,StyleSheet,Text,ScrollView,View,Platform}from"react-native";import{useAriaPress,useControllableValue}from"../../hooks";import{useReducedMotion}from"../../hooks/animation";import{createHairlineView}from"../../utils/hairline";import{parseNumberLike}from"../../utils/number";import{isBoolean,isFunction,isObject,isRenderable,isText}from"../../utils/validate";import{useTabsTokens}from"./tokens";const TabPane=()=>null;TabPane.displayName="Tabs.TabPane";const hasRaf="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame,requestFrame=hasRaf?requestAnimationFrame:e=>setTimeout(e,16),cancelFrame=e=>{null!=e&&(hasRaf?cancelAnimationFrame:clearTimeout)(e)},isTabPaneElement=e=>!!React.isValidElement(e)&&(e.type===TabPane||"Tabs.TabPane"===e.type.displayName),useTabsAnimation=({type:e,animated:t,scrollable:n,align:r,panes:a,nameIndexMap:i,resolvedLineWidth:l,resolvedDuration:o,currentName:c,layoutMap:s,navContainerWidthRef:u})=>{const d=useRef(new Animated.Value(0)).current,m=useRef(new Animated.Value(0)).current,f=useRef(!1),p=useRef(null),g=useCallback((c,f)=>{if(null==c||"line"!==e)return!1;const g=!n&&"start"!==r&&u.current>0&&a.length>0,b=i.get(c)??-1,h=g?u.current/a.length:0,y=g?{x:Math.max(b,0)*h,width:h}:s.current.get(c);if(!y||b<0)return!1;p.current?.stop();const v=(e,n)=>Animated.timing(e,{toValue:n,duration:f||!t?0:o,useNativeDriver:!1,isInteraction:!1}),R=l??y.width,S=l?y.x+(y.width-R)/2:y.x,x=Animated.parallel([v(d,S),v(m,R)]);return p.current=x,x.start(({finished:e})=>{e&&(p.current=null)}),!0},[r,t,m,d,i,a.length,o,l,n,e,s,u]);return useEffect(()=>{if(null==c)return;const e=f.current;g(c,!e)&&!f.current&&(f.current=!0)},[g,c]),useEffect(()=>()=>{p.current?.stop(),p.current=null},[]),{indicatorX:d,indicatorWidth:m,indicatorInitializedRef:f,animateIndicator:g}},useTabsScroll=({scrollable:e,animated:t,currentName:n,resolvedDuration:r,layoutMap:a,navContainerWidthRef:i,navContentWidthRef:l})=>{const o=useRef(null),c=useRef(new Animated.Value(0)).current,s=useRef(null),u=useRef(!1),d=useRef(0),m=useRef(null),f=useCallback(o=>{if(!e||null==n)return;const f=a.current.get(n),p=i.current;if(!f||!p)return;const g=l.current,b=f.x-(p-f.width)/2,h=Math.max(g-p,0),y=Math.max(0,Math.min(b,h));if(!(h<=0||Math.abs(y-d.current)<1)){if(s.current?.stop(),s.current=null,cancelFrame(m.current),m.current=null,o||!t)return u.current=!0,c.setValue(y),void(m.current=requestFrame(()=>{m.current=null,u.current=!1}));c.setValue(d.current),u.current=!0,s.current=Animated.timing(c,{toValue:y,duration:r,useNativeDriver:!1,isInteraction:!1}),s.current.start(({finished:e})=>{s.current=null,u.current=!1,e&&(d.current=y)})}},[t,n,c,r,e,a,i,l]);useEffect(()=>{if(!e)return;const t=c.addListener(({value:e})=>{const t=d.current;d.current=e,Math.abs(e-t)>=.5&&o.current?.scrollTo({x:e,y:0,animated:!1})});return()=>c.removeListener(t)},[c,e]),useEffect(()=>()=>{cancelFrame(m.current),m.current=null},[]);const p=useCallback(e=>{u.current=!1,s.current?.stop(),s.current=null,d.current=e.nativeEvent.contentOffset.x},[]),g=useCallback(e=>{u.current||(d.current=e.nativeEvent.contentOffset.x)},[]);return{navScrollRef:o,navScrollX:c,scrollIntoView:f,handleNavScrollBeginDrag:p,handleNavScroll:g}},TabBarItemInner=({pane:e,isActive:t,align:n,scrollable:r,type:a,ellipsis:i,tokens:l,color:o,titleActiveColor:c,titleInactiveColor:s,tabStyle:u,titleStyle:d,descriptionStyle:m,onSelect:f,onLayout:p,isLast:g})=>{const b=!!e.disabled,h=useAriaPress({onPress:t=>f(e,e.index,t),extraProps:{accessibilityRole:"tab",accessibilityState:{selected:t,disabled:b},testID:`rv-tabs-item-${e.name}`}}),y="capsule"===a,v="jumbo"===a,R="card"===a,x=isFunction(e.title)?e.title(t):e.title??e.name,w=isFunction(e.description)?e.description(t):e.description,T=c??(R?l.colors.cardActiveText:y?l.colors.capsuleActiveText:o??l.colors.textActive),E=s??(R?o??l.colors.cardBorder:y?l.colors.capsuleText:l.colors.text),k=e.disabled?l.colors.textDisabled:t?T:E,C=b?l.colors.textDisabled:v?t?l.colors.jumboDescriptionActive:l.colors.jumboDescription:t?l.colors.descriptionActive:l.colors.description,V=!r&&("start"!==n||R),I=R||v||y,H=I?0:l.tabList.paddingHorizontal,P=I?0:l.tabList.paddingVertical,A=[S.lblW,v&&S.lblWJ,R&&S.cardLbl,R&&{paddingHorizontal:l.card.paddingHorizontal,paddingVertical:l.card.paddingVertical},y&&{flex:1,alignSelf:"stretch",paddingHorizontal:l.capsule.paddingHorizontal,paddingVertical:l.capsule.paddingVertical},v&&{paddingHorizontal:l.jumbo.paddingHorizontal,paddingVertical:l.jumbo.paddingVertical,alignItems:"center"}].filter(Boolean),z=y?[{flex:1,alignSelf:"stretch",justifyContent:"center",alignItems:"center",borderRadius:l.capsule.radius,backgroundColor:t?o??l.colors.capsuleActiveBackground:l.colors.capsuleBackground}]:null,M=[S.title,{color:k,fontFamily:l.typography.fontFamily,fontSize:v?l.typography.jumboTitleSize:l.typography.titleSize,fontWeight:t?l.typography.titleActiveWeight:l.typography.titleWeight,lineHeight:v?l.typography.jumboLineHeight:void 0,textAlign:"center"},i&&!v?S.ellipsis:null,d],L=v?l.spacing.jumboDescriptionMarginTop:l.spacing.descriptionMarginTop,B=v?{backgroundColor:t?l.colors.jumboDescriptionActiveBackground:l.colors.jumboDescriptionBackground,paddingHorizontal:l.jumbo.descriptionPaddingHorizontal,paddingVertical:l.jumbo.descriptionPaddingVertical,borderRadius:l.jumbo.descriptionRadius}:null,D=useCallback(t=>p(e.name,t),[p,e.name]);return React.createElement(Pressable,_extends({},h.interactionProps,{onLayout:D,style:[S.tabI,V?S.flexI:null,{paddingHorizontal:H,paddingVertical:P},R?{backgroundColor:t?o??l.colors.cardActiveBackground:l.colors.cardBackground}:null,u]}),React.createElement(View,{style:A},z?React.createElement(View,{style:z},React.createElement(Text,{style:M,numberOfLines:i&&!v?1:void 0},x)):React.createElement(Text,{style:M,numberOfLines:i&&!v?1:void 0},x),isRenderable(w)&&(isText(w)?React.createElement(Text,{style:[S.descTxt,{color:C,fontFamily:l.typography.fontFamily,fontSize:l.typography.descriptionSize,marginTop:L,textAlign:"center"},B,m]},w):React.createElement(View,{style:[{marginTop:L,alignItems:"center"},B]},w)),isRenderable(e.badge)&&React.createElement(View,{style:{marginTop:l.spacing.badgeMarginTop}},isText(e.badge)?React.createElement(Text,{style:{color:l.colors.badgeText,fontFamily:l.typography.fontFamily,fontSize:l.typography.badgeTextSize}},e.badge):e.badge)),R&&!g&&React.createElement(View,{style:createHairlineView({position:"right",color:o??l.colors.cardBorder,top:0,bottom:0})}))},TabBarItem=memo(TabBarItemInner),TabsBaseInner=(e,t)=>{const{tokensOverride:n,children:r,type:a,align:i,ellipsis:l,swipeThreshold:o,animated:c,duration:s,lazyRender:u,lazyRenderPlaceholder:d,scrollable:m,swipeable:f,color:p,background:g,border:b,navLeft:h,navRight:y,navBottom:v,tabBarStyle:R,tabStyle:x,titleStyle:w,descriptionStyle:T,contentStyle:E,lineWidth:k,lineHeight:C,titleActiveColor:V,titleInactiveColor:I,beforeChange:H,onClickTab:P,onChange:A,style:z,...M}=e,L=useTabsTokens(n),B=useReducedMotion(),D=a??L.defaults.type,j=i??L.defaults.align,F=l??L.defaults.ellipsis,W=o??L.defaults.swipeThreshold,N=c??L.defaults.animated,O=s??L.defaults.duration,q=u??L.defaults.lazyRender,_=g??L.tabList.background,X=parseNumberLike(k??L.indicator.width),J=null!=X&&X<0?void 0:X,$=Math.max(0,parseNumberLike(C)??L.indicator.height),G=B?0:Math.max(0,parseNumberLike(O)??L.defaults.duration),K=Math.max(0,parseNumberLike(W)??L.defaults.swipeThreshold),Q=f?isObject(f)?{autoHeight:f.autoHeight??!0,preventScroll:f.preventScroll??!0}:{autoHeight:!0,preventScroll:!0}:void 0,U=!!Q,Y=useMemo(()=>{const e=[];let t=0;const n=r=>{Children.forEach(r,r=>{if(!isValidElement(r))return;const a=r;if(a.type===React.Fragment)return void n(a.props.children);if(!isTabPaneElement(a))return;const i=a.props,l=i.name??t;e.push({...i,key:a.key??l,name:l,index:t}),t+=1})};return n(r),e},[r]),Z=Y[0]?.name,[ee,te]=useControllableValue(e,{defaultValue:Z,valuePropName:"active",defaultValuePropName:"defaultActive",trigger:"onChange"}),ne=null==ee?Z:Y.some(e=>e.name===ee)?ee:Z,re=useRef(ne);useEffect(()=>{re.current=ne},[ne]);const ae=useMemo(()=>{const e=new Map;return Y.forEach(t=>{e.set(t.name,t.index)}),e},[Y]),ie=null==ne?-1:ae.get(ne)??-1,le=useRef(new Set),oe=useRef(new Map),ce=useRef(0),se=useRef(0),ue=useRef(null),de=useRef(new Map),me=useRef(null),fe=useRef(!1),[pe,ge]=useState(0),[be,he]=useState(void 0);useEffect(()=>{null!=ne&&le.current.add(ne)},[ne]),useEffect(()=>{const e=new Set(Y.map(e=>e.name));Array.from(de.current.keys()).forEach(t=>{e.has(t)||de.current.delete(t)}),Array.from(oe.current.keys()).forEach(t=>{e.has(t)||oe.current.delete(t)})},[Y]);const ye=U&&Q?.autoHeight;useEffect(()=>{ye||de.current.clear()},[ye]),useEffect(()=>{if(!U||!Q?.autoHeight)return void he(void 0);const e=null!=ne?de.current.get(ne):void 0;he(e?e.height:void 0)},[ne,U,Q?.autoHeight]),useEffect(()=>()=>{cancelFrame(ue.current),ue.current=null},[]);const ve=isBoolean(m)?m:Y.length>K||!1===F,Re=p??L.colors.indicator,Se=$?$/2:L.indicator.radius,{indicatorX:xe,indicatorWidth:we,indicatorInitializedRef:Te,animateIndicator:Ee}=useTabsAnimation({type:D,animated:N,scrollable:ve,align:j,panes:Y,nameIndexMap:ae,resolvedLineWidth:J,resolvedLineHeight:$,resolvedDuration:G,currentName:ne,layoutMap:oe,navContainerWidthRef:ce}),{navScrollRef:ke,scrollIntoView:Ce,handleNavScrollBeginDrag:Ve,handleNavScroll:Ie}=useTabsScroll({scrollable:ve,animated:N,currentName:ne,resolvedDuration:G,layoutMap:oe,navContainerWidthRef:ce,navContentWidthRef:se}),He=useCallback((e,t)=>{const{x:n,width:r}=t.nativeEvent.layout;if(oe.current.set(e,{x:n,width:r}),e===re.current){const t=Te.current;Ee(e,!t)&&!Te.current&&(Te.current=!0)}},[Ee,Te]),Pe=useCallback(e=>{const{width:t}=e.nativeEvent.layout;if(ce.current=t,!ve&&"start"!==j&&"line"===D&&null!=ne){const e=Te.current;Ee(ne,!e)&&!Te.current&&(Te.current=!0)}},[j,Ee,ne,ve,D,Te]),Ae=useCallback(e=>{const t=e.nativeEvent.layout.width;ge(e=>e===t?e:t)},[]),ze=useRef(H);ze.current=H;const Me=useCallback(e=>{if(!ze.current)return Promise.resolve(!0);try{return Promise.resolve(ze.current(e)).then(e=>!1!==e).catch(()=>!1)}catch(e){return Promise.resolve(!1)}},[]),Le=useRef(0),Be=useCallback((e,t)=>{Le.current+=1;const n=Le.current;Me(e).then(r=>{r&&Le.current===n&&te(e,t)})},[Me,te]),De=useCallback((e,t)=>{if(U&&Q?.autoHeight){const{height:n}=t.nativeEvent.layout;de.current.set(e,{height:n}),e===ne&&he(n)}},[ne,U,Q?.autoHeight]),je=useRef(null);useEffect(()=>{je.current=null},[ne]);const Fe=useCallback(e=>{if(!U||pe<=0)return;const t=Math.round(e/pe);if(je.current===t)return;je.current=t;const n=Y[t];n&&n.name!==re.current&&(fe.current=!0,Be(n.name,n.index))},[pe,U,Y,Be]),We=useCallback(e=>{Fe(e.nativeEvent.contentOffset.x)},[Fe]),Ne=useCallback(e=>{Fe(e.nativeEvent.contentOffset.x)},[Fe]);useEffect(()=>{if(!U||!me.current||pe<=0)return;if(fe.current)return void(fe.current=!1);if(ie<0)return;const e=me.current?.getNode?.()??me.current;e?.scrollTo&&e.scrollTo({x:pe*ie,y:0,animated:!0})},[ie,pe,U]);const Oe=useRef(P);Oe.current=P;const qe=useCallback((e,t,n)=>{const r={name:e.name,index:t,disabled:!!e.disabled,event:n};Oe.current?.(r),e.disabled||e.name===re.current||Be(e.name,t)},[Be]),_e=useCallback((e,t)=>{const n=Y.find(t=>t.name===e&&!t.disabled);n&&te(n.name,n.index)},[Y,te]);useImperativeHandle(t,()=>({scrollTo:_e}),[_e]);const Xe=useRef(!0);useEffect(()=>{Xe.current&&(Xe.current=!1,Ce(!0))},[Ce]),useEffect(()=>{Xe.current||Ce()},[ne,Ce]);const Je=b??!1,$e="line"===D,Ge="jumbo"===D?L.jumbo.height:"card"===D?L.card.height:L.tabList.height,Ke="web"===Platform.OS&&"line"!==D&&"card"!==D?L.tabList.paddingBottom:0,Qe=$e?"line"===D?0:L.indicator.offset:0;if(0===Y.length)return null;const Ue=$e?React.createElement(Animated.View,{testID:"rv-tabs-indicator",style:[S.ind,{height:$,borderRadius:Se,backgroundColor:Re,width:we,bottom:Qe,transform:[{translateX:xe}]}]}):null,Ye=useMemo(()=>Y.map(e=>React.createElement(TabBarItem,{key:e.key,pane:e,isActive:e.name===ne,align:j,scrollable:ve,type:D,ellipsis:F,tokens:L,color:p,titleActiveColor:V,titleInactiveColor:I,tabStyle:x,titleStyle:w,descriptionStyle:T,onSelect:qe,onLayout:He,isLast:e.index===Y.length-1})),[j,p,ne,T,F,qe,He,Y,ve,x,V,I,w,L,D]),Ze=useCallback(e=>{const t=se.current;se.current=e,0===t||Xe.current?Ce(!0):Math.abs(e-t)>1&&(cancelFrame(ue.current),ue.current=requestFrame(()=>{ue.current=null,Ce()}))},[Ce]),et=ve?React.createElement(ScrollView,{horizontal:!0,ref:ke,accessibilityRole:"tablist",showsHorizontalScrollIndicator:!1,scrollEventThrottle:16,onScrollBeginDrag:Ve,onScroll:Ie,onContentSizeChange:Ze,contentContainerStyle:S.navC},Ye,Ue):React.createElement(View,{accessibilityRole:"tablist",style:[S.navC,S.navCSta]},Ye,Ue),tt=React.createElement(View,{style:[S.wrap,{backgroundColor:_},R]},h&&React.createElement(View,{style:{paddingHorizontal:L.spacing.navSidePaddingHorizontal}},h),React.createElement(View,{style:[S.nav,{minHeight:Ge+Ke,paddingBottom:Ke},"card"===D?{borderRadius:L.card.radius,marginHorizontal:L.card.marginHorizontal,overflow:"hidden"}:null],onLayout:Pe},et,"card"===D&&React.createElement(View,{style:createHairlineView({position:"all",color:p??L.colors.cardBorder,borderRadius:L.card.radius})})),y&&React.createElement(View,{style:{paddingHorizontal:L.spacing.navSidePaddingHorizontal}},y),Je&&"line"===D&&React.createElement(View,{style:createHairlineView({position:"bottom",color:L.colors.border,left:0,right:0})})),nt=useMemo(()=>Y.map(e=>{const t=e.name===ne,n=!q||t||le.current.has(e.name);if(!n&&!U)return null;const r=U&&Q?.autoHeight?t=>De(e.name,t):void 0,a=[S.pane,U?S.swipePane:null,U&&pe>0&&{width:pe},U||t?null:S.hidPane],i=n?e.children:d||null;return React.createElement(View,{key:e.key,testID:`rv-tabs-pane-${e.name}`,onLayout:r,style:a},i)}),[pe,ne,De,U,q,d,Y,Q?.autoHeight]),rt=[S.content,E],at=[S.content,E,Q?.autoHeight&&void 0!==be&&{height:be}],it=U?React.createElement(View,{style:at},React.createElement(Animated.ScrollView,{ref:me,horizontal:!0,pagingEnabled:!0,scrollEventThrottle:16,showsHorizontalScrollIndicator:!1,onMomentumScrollEnd:We,onScrollEndDrag:Ne,nestedScrollEnabled:!1===Q?.preventScroll,directionalLockEnabled:!1!==Q?.preventScroll},nt)):React.createElement(View,{style:rt},nt);return React.createElement(View,_extends({},M,{style:[S.ctr,z],onLayout:Ae}),tt,v&&React.createElement(View,{style:{marginTop:L.spacing.navBottomMarginTop}},v),it)},S=StyleSheet.create({ctr:{width:"100%"},wrap:{flexDirection:"row",alignItems:"center",position:"relative"},nav:{flex:1,position:"relative",alignSelf:"stretch"},navC:{flexDirection:"row",alignItems:"center",height:"100%",position:"relative"},navCSta:{flex:1},lblW:{justifyContent:"center",alignItems:"center",flexDirection:"column"},lblWJ:{alignItems:"center"},cardLbl:{flexDirection:"row",justifyContent:"center",alignItems:"center"},tabI:{flexShrink:0,height:"100%",alignSelf:"stretch",alignItems:"center",justifyContent:"center",flexDirection:"row"},flexI:{flexGrow:1},title:{includeFontPadding:!1},descTxt:{includeFontPadding:!1},ellipsis:{maxWidth:"100%",flexShrink:1},ind:{position:"absolute",bottom:0,left:0},content:{width:"100%"},pane:{width:"100%"},swipePane:{flexShrink:0},hidPane:{display:"none"}}),TabsBaseRef=React.forwardRef(TabsBaseInner),TabsWithPane=Object.assign(React.memo(TabsBaseRef),{TabPane:TabPane});export{TabPane};export default TabsWithPane;