@fountain-ui/core 2.0.0-beta.9 → 2.0.0-beta.91

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 (573) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/build/commonjs/Accordion/Accordion.js +110 -27
  3. package/build/commonjs/Accordion/Accordion.js.map +1 -1
  4. package/build/commonjs/Accordion/AccordionProps.js.map +1 -1
  5. package/build/commonjs/Badge/Badge.js +5 -14
  6. package/build/commonjs/Badge/Badge.js.map +1 -1
  7. package/build/commonjs/Badge/BadgeProps.js.map +1 -1
  8. package/build/commonjs/Button/Button.js +6 -3
  9. package/build/commonjs/Button/Button.js.map +1 -1
  10. package/build/commonjs/ButtonBase/ButtonBase.js +65 -51
  11. package/build/commonjs/ButtonBase/ButtonBase.js.map +1 -1
  12. package/build/commonjs/ButtonBase/ButtonBaseProps.js.map +1 -1
  13. package/build/commonjs/Checkbox/CheckboxProps.js.map +1 -1
  14. package/build/commonjs/Chip/Chip.js +11 -9
  15. package/build/commonjs/Chip/Chip.js.map +1 -1
  16. package/build/commonjs/Chip/ChipProps.js.map +1 -1
  17. package/build/commonjs/CircularProgress/CircularProgress.js +27 -28
  18. package/build/commonjs/CircularProgress/CircularProgress.js.map +1 -1
  19. package/build/commonjs/Dialog/Dialog.js +118 -10
  20. package/build/commonjs/Dialog/Dialog.js.map +1 -1
  21. package/build/commonjs/Dialog/DialogProps.js.map +1 -1
  22. package/build/commonjs/Divider/Divider.js +26 -18
  23. package/build/commonjs/Divider/Divider.js.map +1 -1
  24. package/build/commonjs/Divider/DividerProps.js.map +1 -1
  25. package/build/commonjs/Image/Image.js +58 -14
  26. package/build/commonjs/Image/Image.js.map +1 -1
  27. package/build/commonjs/Image/ImageProps.js.map +1 -1
  28. package/build/commonjs/Image/index.js.map +1 -1
  29. package/build/commonjs/ImageCore/ImageCoreNative.js +36 -26
  30. package/build/commonjs/ImageCore/ImageCoreNative.js.map +1 -1
  31. package/build/commonjs/ImageCore/ImageCoreProps.js.map +1 -1
  32. package/build/commonjs/ImageCore/ImageCoreWeb.js +19 -1
  33. package/build/commonjs/ImageCore/ImageCoreWeb.js.map +1 -1
  34. package/build/commonjs/ImageCore/ImageFileExtensionContext.js +14 -0
  35. package/build/commonjs/ImageCore/ImageFileExtensionContext.js.map +1 -0
  36. package/build/commonjs/ImageCore/ImageFileExtensionProvider.js +42 -0
  37. package/build/commonjs/ImageCore/ImageFileExtensionProvider.js.map +1 -0
  38. package/build/commonjs/ImageCore/index.js +17 -5
  39. package/build/commonjs/ImageCore/index.js.map +1 -1
  40. package/build/commonjs/ImageCore/index.native.js +27 -0
  41. package/build/commonjs/ImageCore/index.native.js.map +1 -1
  42. package/build/commonjs/Modal/AnimatedContainer/index.js +167 -0
  43. package/build/commonjs/Modal/AnimatedContainer/index.js.map +1 -0
  44. package/build/commonjs/Modal/Modal.js +43 -9
  45. package/build/commonjs/Modal/Modal.js.map +1 -1
  46. package/build/commonjs/Modal/ModalProps.js +12 -0
  47. package/build/commonjs/Modal/ModalProps.js.map +1 -1
  48. package/build/commonjs/Modal/index.js +18 -0
  49. package/build/commonjs/Modal/index.js.map +1 -1
  50. package/build/commonjs/Paper/Paper.js +1 -1
  51. package/build/commonjs/Paper/Paper.js.map +1 -1
  52. package/build/commonjs/Radio/Radio.js +11 -4
  53. package/build/commonjs/Radio/Radio.js.map +1 -1
  54. package/build/commonjs/Radio/RadioProps.js.map +1 -1
  55. package/build/commonjs/Slide/Slide.js +41 -27
  56. package/build/commonjs/Slide/Slide.js.map +1 -1
  57. package/build/commonjs/Slide/SlideProps.js.map +1 -1
  58. package/build/commonjs/Snackbar/Snackbar.js +34 -7
  59. package/build/commonjs/Snackbar/Snackbar.js.map +1 -1
  60. package/build/commonjs/Snackbar/SnackbarProps.js.map +1 -1
  61. package/build/commonjs/SnackbarContent/SnackbarContent.js +32 -14
  62. package/build/commonjs/SnackbarContent/SnackbarContent.js.map +1 -1
  63. package/build/commonjs/SnackbarContent/SnackbarContentProps.js.map +1 -1
  64. package/build/commonjs/SvgIcon/SvgIcon.js +1 -1
  65. package/build/commonjs/SvgIcon/SvgIcon.js.map +1 -1
  66. package/build/commonjs/Tab/Tab.js +66 -20
  67. package/build/commonjs/Tab/Tab.js.map +1 -1
  68. package/build/commonjs/Tab/TabIndicator.js +11 -7
  69. package/build/commonjs/Tab/TabIndicator.js.map +1 -1
  70. package/build/commonjs/Tab/TabProps.js.map +1 -1
  71. package/build/commonjs/Tab/index.js.map +1 -1
  72. package/build/commonjs/Tabs/IndexAwareTab.js +35 -0
  73. package/build/commonjs/Tabs/IndexAwareTab.js.map +1 -0
  74. package/build/commonjs/Tabs/InternalContext.js +17 -0
  75. package/build/commonjs/Tabs/InternalContext.js.map +1 -0
  76. package/build/commonjs/Tabs/ScrollableTabsView.js +35 -0
  77. package/build/commonjs/Tabs/ScrollableTabsView.js.map +1 -0
  78. package/build/commonjs/Tabs/TabIndicator.js +73 -28
  79. package/build/commonjs/Tabs/TabIndicator.js.map +1 -1
  80. package/build/commonjs/Tabs/TabIndicatorProps.js.map +1 -1
  81. package/build/commonjs/Tabs/Tabs.js +119 -83
  82. package/build/commonjs/Tabs/Tabs.js.map +1 -1
  83. package/build/commonjs/Tabs/TabsProps.js.map +1 -1
  84. package/build/commonjs/Tabs/index.js.map +1 -1
  85. package/build/commonjs/Tabs/types.js +2 -0
  86. package/build/commonjs/Tabs/types.js.map +1 -0
  87. package/build/commonjs/Tabs/useIndexStore.js +35 -0
  88. package/build/commonjs/Tabs/useIndexStore.js.map +1 -0
  89. package/build/commonjs/Tabs/useScrollViewReaction.js +69 -0
  90. package/build/commonjs/Tabs/useScrollViewReaction.js.map +1 -0
  91. package/build/commonjs/Tabs/useTabCoordinates.js +30 -0
  92. package/build/commonjs/Tabs/useTabCoordinates.js.map +1 -0
  93. package/build/commonjs/Tabs/useTabInnerContentsWidth.js +30 -0
  94. package/build/commonjs/Tabs/useTabInnerContentsWidth.js.map +1 -0
  95. package/build/commonjs/Tabs/utils.js +19 -0
  96. package/build/commonjs/Tabs/utils.js.map +1 -0
  97. package/build/commonjs/TextField/InputLabel.js +6 -3
  98. package/build/commonjs/TextField/InputLabel.js.map +1 -1
  99. package/build/commonjs/TextField/OutlinedTextField.js +6 -2
  100. package/build/commonjs/TextField/OutlinedTextField.js.map +1 -1
  101. package/build/commonjs/TextField/TextField.js +15 -8
  102. package/build/commonjs/TextField/TextField.js.map +1 -1
  103. package/build/commonjs/TextField/TextFieldProps.js.map +1 -1
  104. package/build/commonjs/Tooltip/Tooltip.js +50 -31
  105. package/build/commonjs/Tooltip/Tooltip.js.map +1 -1
  106. package/build/commonjs/Tooltip/TooltipProps.js.map +1 -1
  107. package/build/commonjs/Typography/Typography.js +14 -5
  108. package/build/commonjs/Typography/Typography.js.map +1 -1
  109. package/build/commonjs/Typography/TypographyProps.js.map +1 -1
  110. package/build/commonjs/animated/AnimatedPressable.js +2 -3
  111. package/build/commonjs/animated/AnimatedPressable.js.map +1 -1
  112. package/build/commonjs/hooks/index.js +32 -0
  113. package/build/commonjs/hooks/index.js.map +1 -1
  114. package/build/commonjs/hooks/useAnimatedValue.js +31 -0
  115. package/build/commonjs/hooks/useAnimatedValue.js.map +1 -0
  116. package/build/commonjs/hooks/useCollapsibleAppBar.js +41 -54
  117. package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
  118. package/build/commonjs/hooks/useDebounce.js +33 -0
  119. package/build/commonjs/hooks/useDebounce.js.map +1 -0
  120. package/build/commonjs/hooks/useFadeInAppBar.js +21 -23
  121. package/build/commonjs/hooks/useFadeInAppBar.js.map +1 -1
  122. package/build/commonjs/hooks/useImperativeState.js +26 -0
  123. package/build/commonjs/hooks/useImperativeState.js.map +1 -0
  124. package/build/commonjs/hooks/useSyncAnimatedValue.js +40 -0
  125. package/build/commonjs/hooks/useSyncAnimatedValue.js.map +1 -0
  126. package/build/commonjs/hooks/useThrottle.js +3 -7
  127. package/build/commonjs/hooks/useThrottle.js.map +1 -1
  128. package/build/commonjs/hooks/useValidWindowDimensions/index.ios.js +14 -7
  129. package/build/commonjs/hooks/useValidWindowDimensions/index.ios.js.map +1 -1
  130. package/build/commonjs/index.js +35 -0
  131. package/build/commonjs/index.js.map +1 -1
  132. package/build/commonjs/internal/hooks/index.js +0 -8
  133. package/build/commonjs/internal/hooks/index.js.map +1 -1
  134. package/build/commonjs/internal/hooks/useHeight.js +3 -9
  135. package/build/commonjs/internal/hooks/useHeight.js.map +1 -1
  136. package/build/commonjs/internal/icons/Checkbox.js +1 -1
  137. package/build/commonjs/internal/icons/Checkbox.js.map +1 -1
  138. package/build/commonjs/internal/icons/CheckboxChecked.js +1 -1
  139. package/build/commonjs/internal/icons/CheckboxChecked.js.map +1 -1
  140. package/build/commonjs/internal/icons/ChevronDown.js +1 -1
  141. package/build/commonjs/internal/icons/ChevronDown.js.map +1 -1
  142. package/build/commonjs/internal/icons/ChevronLeft.js +1 -1
  143. package/build/commonjs/internal/icons/ChevronLeft.js.map +1 -1
  144. package/build/commonjs/internal/icons/ChevronRight.js +1 -1
  145. package/build/commonjs/internal/icons/ChevronRight.js.map +1 -1
  146. package/build/commonjs/internal/icons/Close.js +1 -1
  147. package/build/commonjs/internal/icons/Close.js.map +1 -1
  148. package/build/commonjs/internal/icons/Radio.js +1 -1
  149. package/build/commonjs/internal/icons/Radio.js.map +1 -1
  150. package/build/commonjs/internal/icons/RadioChecked.js +1 -1
  151. package/build/commonjs/internal/icons/RadioChecked.js.map +1 -1
  152. package/build/commonjs/store/MockStore.js +27 -0
  153. package/build/commonjs/store/MockStore.js.map +1 -0
  154. package/build/commonjs/store/SimpleStore.js +59 -0
  155. package/build/commonjs/store/SimpleStore.js.map +1 -0
  156. package/build/commonjs/store/index.js +24 -0
  157. package/build/commonjs/store/index.js.map +1 -0
  158. package/build/commonjs/store/types.js +2 -0
  159. package/build/commonjs/store/types.js.map +1 -0
  160. package/build/commonjs/types/index.js.map +1 -1
  161. package/build/commonjs/utils/index.js +8 -0
  162. package/build/commonjs/utils/index.js.map +1 -1
  163. package/build/commonjs/utils/isNotAndroid12.js +20 -0
  164. package/build/commonjs/utils/isNotAndroid12.js.map +1 -0
  165. package/build/module/Accordion/Accordion.js +111 -29
  166. package/build/module/Accordion/Accordion.js.map +1 -1
  167. package/build/module/Accordion/AccordionProps.js.map +1 -1
  168. package/build/module/Badge/Badge.js +5 -14
  169. package/build/module/Badge/Badge.js.map +1 -1
  170. package/build/module/Badge/BadgeProps.js.map +1 -1
  171. package/build/module/Button/Button.js +6 -3
  172. package/build/module/Button/Button.js.map +1 -1
  173. package/build/module/ButtonBase/ButtonBase.js +64 -49
  174. package/build/module/ButtonBase/ButtonBase.js.map +1 -1
  175. package/build/module/ButtonBase/ButtonBaseProps.js.map +1 -1
  176. package/build/module/Checkbox/CheckboxProps.js.map +1 -1
  177. package/build/module/Chip/Chip.js +11 -9
  178. package/build/module/Chip/Chip.js.map +1 -1
  179. package/build/module/Chip/ChipProps.js.map +1 -1
  180. package/build/module/CircularProgress/CircularProgress.js +25 -23
  181. package/build/module/CircularProgress/CircularProgress.js.map +1 -1
  182. package/build/module/Dialog/Dialog.js +109 -8
  183. package/build/module/Dialog/Dialog.js.map +1 -1
  184. package/build/module/Dialog/DialogProps.js.map +1 -1
  185. package/build/module/Divider/Divider.js +26 -18
  186. package/build/module/Divider/Divider.js.map +1 -1
  187. package/build/module/Divider/DividerProps.js.map +1 -1
  188. package/build/module/Image/Image.js +54 -12
  189. package/build/module/Image/Image.js.map +1 -1
  190. package/build/module/Image/ImageProps.js.map +1 -1
  191. package/build/module/Image/index.js.map +1 -1
  192. package/build/module/ImageCore/ImageCoreNative.js +31 -25
  193. package/build/module/ImageCore/ImageCoreNative.js.map +1 -1
  194. package/build/module/ImageCore/ImageCoreProps.js.map +1 -1
  195. package/build/module/ImageCore/ImageCoreWeb.js +19 -1
  196. package/build/module/ImageCore/ImageCoreWeb.js.map +1 -1
  197. package/build/module/ImageCore/ImageFileExtensionContext.js +5 -0
  198. package/build/module/ImageCore/ImageFileExtensionContext.js.map +1 -0
  199. package/build/module/ImageCore/ImageFileExtensionProvider.js +24 -0
  200. package/build/module/ImageCore/ImageFileExtensionProvider.js.map +1 -0
  201. package/build/module/ImageCore/index.js +2 -1
  202. package/build/module/ImageCore/index.js.map +1 -1
  203. package/build/module/ImageCore/index.native.js +2 -0
  204. package/build/module/ImageCore/index.native.js.map +1 -1
  205. package/build/module/Modal/AnimatedContainer/index.js +144 -0
  206. package/build/module/Modal/AnimatedContainer/index.js.map +1 -0
  207. package/build/module/Modal/Modal.js +43 -9
  208. package/build/module/Modal/Modal.js.map +1 -1
  209. package/build/module/Modal/ModalProps.js +5 -0
  210. package/build/module/Modal/ModalProps.js.map +1 -1
  211. package/build/module/Modal/index.js +2 -0
  212. package/build/module/Modal/index.js.map +1 -1
  213. package/build/module/Paper/Paper.js +1 -1
  214. package/build/module/Paper/Paper.js.map +1 -1
  215. package/build/module/Radio/Radio.js +9 -5
  216. package/build/module/Radio/Radio.js.map +1 -1
  217. package/build/module/Radio/RadioProps.js.map +1 -1
  218. package/build/module/Slide/Slide.js +39 -23
  219. package/build/module/Slide/Slide.js.map +1 -1
  220. package/build/module/Slide/SlideProps.js.map +1 -1
  221. package/build/module/Snackbar/Snackbar.js +25 -5
  222. package/build/module/Snackbar/Snackbar.js.map +1 -1
  223. package/build/module/Snackbar/SnackbarProps.js.map +1 -1
  224. package/build/module/SnackbarContent/SnackbarContent.js +21 -6
  225. package/build/module/SnackbarContent/SnackbarContent.js.map +1 -1
  226. package/build/module/SnackbarContent/SnackbarContentProps.js.map +1 -1
  227. package/build/module/SvgIcon/SvgIcon.js +1 -1
  228. package/build/module/SvgIcon/SvgIcon.js.map +1 -1
  229. package/build/module/Tab/Tab.js +63 -21
  230. package/build/module/Tab/Tab.js.map +1 -1
  231. package/build/module/Tab/TabIndicator.js +11 -7
  232. package/build/module/Tab/TabIndicator.js.map +1 -1
  233. package/build/module/Tab/TabProps.js.map +1 -1
  234. package/build/module/Tab/index.js.map +1 -1
  235. package/build/module/Tabs/IndexAwareTab.js +23 -0
  236. package/build/module/Tabs/IndexAwareTab.js.map +1 -0
  237. package/build/module/Tabs/InternalContext.js +7 -0
  238. package/build/module/Tabs/InternalContext.js.map +1 -0
  239. package/build/module/Tabs/ScrollableTabsView.js +22 -0
  240. package/build/module/Tabs/ScrollableTabsView.js.map +1 -0
  241. package/build/module/Tabs/TabIndicator.js +66 -25
  242. package/build/module/Tabs/TabIndicator.js.map +1 -1
  243. package/build/module/Tabs/TabIndicatorProps.js.map +1 -1
  244. package/build/module/Tabs/Tabs.js +109 -72
  245. package/build/module/Tabs/Tabs.js.map +1 -1
  246. package/build/module/Tabs/TabsProps.js.map +1 -1
  247. package/build/module/Tabs/index.js.map +1 -1
  248. package/build/module/Tabs/types.js +2 -0
  249. package/build/module/Tabs/types.js.map +1 -0
  250. package/build/module/Tabs/useIndexStore.js +25 -0
  251. package/build/module/Tabs/useIndexStore.js.map +1 -0
  252. package/build/module/Tabs/useScrollViewReaction.js +57 -0
  253. package/build/module/Tabs/useScrollViewReaction.js.map +1 -0
  254. package/build/module/Tabs/useTabCoordinates.js +21 -0
  255. package/build/module/Tabs/useTabCoordinates.js.map +1 -0
  256. package/build/module/Tabs/useTabInnerContentsWidth.js +21 -0
  257. package/build/module/Tabs/useTabInnerContentsWidth.js.map +1 -0
  258. package/build/module/Tabs/utils.js +9 -0
  259. package/build/module/Tabs/utils.js.map +1 -0
  260. package/build/module/TextField/InputLabel.js +7 -4
  261. package/build/module/TextField/InputLabel.js.map +1 -1
  262. package/build/module/TextField/OutlinedTextField.js +7 -3
  263. package/build/module/TextField/OutlinedTextField.js.map +1 -1
  264. package/build/module/TextField/TextField.js +13 -5
  265. package/build/module/TextField/TextField.js.map +1 -1
  266. package/build/module/TextField/TextFieldProps.js.map +1 -1
  267. package/build/module/Tooltip/Tooltip.js +48 -25
  268. package/build/module/Tooltip/Tooltip.js.map +1 -1
  269. package/build/module/Tooltip/TooltipProps.js.map +1 -1
  270. package/build/module/Typography/Typography.js +14 -5
  271. package/build/module/Typography/Typography.js.map +1 -1
  272. package/build/module/Typography/TypographyProps.js.map +1 -1
  273. package/build/module/animated/AnimatedPressable.js +2 -3
  274. package/build/module/animated/AnimatedPressable.js.map +1 -1
  275. package/build/module/hooks/index.js +4 -0
  276. package/build/module/hooks/index.js.map +1 -1
  277. package/build/module/hooks/useAnimatedValue.js +22 -0
  278. package/build/module/hooks/useAnimatedValue.js.map +1 -0
  279. package/build/module/hooks/useCollapsibleAppBar.js +42 -52
  280. package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
  281. package/build/module/hooks/useDebounce.js +25 -0
  282. package/build/module/hooks/useDebounce.js.map +1 -0
  283. package/build/module/hooks/useFadeInAppBar.js +23 -20
  284. package/build/module/hooks/useFadeInAppBar.js.map +1 -1
  285. package/build/module/hooks/useImperativeState.js +17 -0
  286. package/build/module/hooks/useImperativeState.js.map +1 -0
  287. package/build/module/hooks/useSyncAnimatedValue.js +28 -0
  288. package/build/module/hooks/useSyncAnimatedValue.js.map +1 -0
  289. package/build/module/hooks/useThrottle.js +3 -3
  290. package/build/module/hooks/useThrottle.js.map +1 -1
  291. package/build/module/hooks/useValidWindowDimensions/index.ios.js +15 -9
  292. package/build/module/hooks/useValidWindowDimensions/index.ios.js.map +1 -1
  293. package/build/module/index.js +3 -1
  294. package/build/module/index.js.map +1 -1
  295. package/build/module/internal/hooks/index.js +0 -1
  296. package/build/module/internal/hooks/index.js.map +1 -1
  297. package/build/module/internal/hooks/useHeight.js +3 -4
  298. package/build/module/internal/hooks/useHeight.js.map +1 -1
  299. package/build/module/internal/icons/Checkbox.js +1 -1
  300. package/build/module/internal/icons/Checkbox.js.map +1 -1
  301. package/build/module/internal/icons/CheckboxChecked.js +1 -1
  302. package/build/module/internal/icons/CheckboxChecked.js.map +1 -1
  303. package/build/module/internal/icons/ChevronDown.js +1 -1
  304. package/build/module/internal/icons/ChevronDown.js.map +1 -1
  305. package/build/module/internal/icons/ChevronLeft.js +1 -1
  306. package/build/module/internal/icons/ChevronLeft.js.map +1 -1
  307. package/build/module/internal/icons/ChevronRight.js +1 -1
  308. package/build/module/internal/icons/ChevronRight.js.map +1 -1
  309. package/build/module/internal/icons/Close.js +1 -1
  310. package/build/module/internal/icons/Close.js.map +1 -1
  311. package/build/module/internal/icons/Radio.js +1 -1
  312. package/build/module/internal/icons/Radio.js.map +1 -1
  313. package/build/module/internal/icons/RadioChecked.js +1 -1
  314. package/build/module/internal/icons/RadioChecked.js.map +1 -1
  315. package/build/module/store/MockStore.js +18 -0
  316. package/build/module/store/MockStore.js.map +1 -0
  317. package/build/module/store/SimpleStore.js +50 -0
  318. package/build/module/store/SimpleStore.js.map +1 -0
  319. package/build/module/store/index.js +3 -0
  320. package/build/module/store/index.js.map +1 -0
  321. package/build/module/store/types.js +2 -0
  322. package/build/module/store/types.js.map +1 -0
  323. package/build/module/types/index.js.map +1 -1
  324. package/build/module/utils/index.js +1 -0
  325. package/build/module/utils/index.js.map +1 -1
  326. package/build/module/utils/isNotAndroid12.js +6 -0
  327. package/build/module/utils/isNotAndroid12.js.map +1 -0
  328. package/build/typescript/Accordion/Accordion.d.ts +1 -0
  329. package/build/typescript/Accordion/AccordionProps.d.ts +14 -11
  330. package/build/typescript/AspectRatio/AspectRatioNative.d.ts +1 -0
  331. package/build/typescript/AspectRatio/AspectRatioWeb.d.ts +1 -0
  332. package/build/typescript/Avatar/Avatar.d.ts +1 -0
  333. package/build/typescript/Badge/Badge.d.ts +1 -0
  334. package/build/typescript/Badge/BadgeProps.d.ts +5 -0
  335. package/build/typescript/Button/Button.d.ts +1 -0
  336. package/build/typescript/ButtonBase/ButtonBase.d.ts +1 -0
  337. package/build/typescript/ButtonBase/ButtonBaseProps.d.ts +8 -0
  338. package/build/typescript/Card/Card.d.ts +1 -0
  339. package/build/typescript/CardActions/CardActions.d.ts +1 -0
  340. package/build/typescript/CardContent/CardContent.d.ts +1 -0
  341. package/build/typescript/CardMedia/CardMedia.d.ts +1 -0
  342. package/build/typescript/Checkbox/Checkbox.d.ts +1 -0
  343. package/build/typescript/Checkbox/CheckboxProps.d.ts +1 -1
  344. package/build/typescript/Chip/Chip.d.ts +1 -0
  345. package/build/typescript/Chip/ChipProps.d.ts +4 -0
  346. package/build/typescript/CircularProgress/CircularProgress.d.ts +3 -2
  347. package/build/typescript/Column/Column.d.ts +1 -0
  348. package/build/typescript/Dialog/Dialog.d.ts +1 -0
  349. package/build/typescript/Dialog/DialogProps.d.ts +10 -0
  350. package/build/typescript/DialogActions/DialogActions.d.ts +1 -0
  351. package/build/typescript/DialogContent/DialogContent.d.ts +1 -0
  352. package/build/typescript/DialogMedia/DialogMedia.d.ts +1 -0
  353. package/build/typescript/DialogTitle/DialogTitle.d.ts +1 -0
  354. package/build/typescript/Divider/Divider.d.ts +1 -0
  355. package/build/typescript/Divider/DividerProps.d.ts +22 -1
  356. package/build/typescript/Fab/Fab.d.ts +1 -0
  357. package/build/typescript/Flexbox/Flexbox.d.ts +1 -0
  358. package/build/typescript/IconButton/IconButton.d.ts +1 -0
  359. package/build/typescript/Image/Image.d.ts +1 -0
  360. package/build/typescript/Image/ImageProps.d.ts +30 -2
  361. package/build/typescript/Image/index.d.ts +1 -1
  362. package/build/typescript/ImageCore/ImageCoreNative.d.ts +1 -0
  363. package/build/typescript/ImageCore/ImageCoreProps.d.ts +5 -1
  364. package/build/typescript/ImageCore/ImageCoreWeb.d.ts +1 -0
  365. package/build/typescript/ImageCore/ImageFileExtensionContext.d.ts +3 -0
  366. package/build/typescript/ImageCore/ImageFileExtensionProvider.d.ts +13 -0
  367. package/build/typescript/ImageCore/index.d.ts +3 -1
  368. package/build/typescript/ImageCore/index.native.d.ts +2 -0
  369. package/build/typescript/Link/Link.d.ts +1 -0
  370. package/build/typescript/List/List.d.ts +1 -0
  371. package/build/typescript/ListItem/ListItem.d.ts +1 -0
  372. package/build/typescript/ListItemIcon/ListItemIcon.d.ts +1 -0
  373. package/build/typescript/ListItemSecondaryAction/ListItemSecondaryAction.d.ts +1 -0
  374. package/build/typescript/ListItemText/ListItemText.d.ts +1 -0
  375. package/build/typescript/ListSubheader/ListSubheader.d.ts +1 -0
  376. package/build/typescript/Menu/Menu.d.ts +1 -0
  377. package/build/typescript/MenuItem/MenuItem.d.ts +1 -0
  378. package/build/typescript/Modal/AnimatedContainer/index.d.ts +5 -0
  379. package/build/typescript/Modal/Modal.d.ts +1 -0
  380. package/build/typescript/Modal/ModalProps.d.ts +47 -0
  381. package/build/typescript/Modal/index.d.ts +4 -1
  382. package/build/typescript/Pagination/Pagination.d.ts +1 -0
  383. package/build/typescript/Portal/Portal.d.ts +1 -0
  384. package/build/typescript/Radio/Radio.d.ts +1 -0
  385. package/build/typescript/Radio/RadioProps.d.ts +13 -0
  386. package/build/typescript/RadioGroup/RadioGroup.d.ts +1 -0
  387. package/build/typescript/Row/Row.d.ts +1 -0
  388. package/build/typescript/Slide/Slide.d.ts +1 -0
  389. package/build/typescript/Slide/SlideProps.d.ts +2 -3
  390. package/build/typescript/Slider/Slider.d.ts +1 -1
  391. package/build/typescript/Snackbar/Snackbar.d.ts +1 -0
  392. package/build/typescript/Snackbar/SnackbarProps.d.ts +10 -3
  393. package/build/typescript/SnackbarContent/SnackbarContent.d.ts +1 -0
  394. package/build/typescript/SnackbarContent/SnackbarContentProps.d.ts +9 -0
  395. package/build/typescript/Spacer/Spacer.d.ts +1 -0
  396. package/build/typescript/SvgIcon/SvgIcon.d.ts +1 -0
  397. package/build/typescript/Switch/Switch.d.ts +1 -0
  398. package/build/typescript/Tab/Tab.d.ts +1 -0
  399. package/build/typescript/Tab/TabIndicator.d.ts +5 -1
  400. package/build/typescript/Tab/TabProps.d.ts +21 -2
  401. package/build/typescript/Tab/index.d.ts +1 -1
  402. package/build/typescript/TabBase/TabBase.d.ts +1 -0
  403. package/build/typescript/Tabs/IndexAwareTab.d.ts +8 -0
  404. package/build/typescript/Tabs/InternalContext.d.ts +7 -0
  405. package/build/typescript/Tabs/ScrollableTabsView.d.ts +8 -0
  406. package/build/typescript/Tabs/TabIndicator.d.ts +1 -0
  407. package/build/typescript/Tabs/TabIndicatorProps.d.ts +10 -5
  408. package/build/typescript/Tabs/Tabs.d.ts +4 -1
  409. package/build/typescript/Tabs/TabsProps.d.ts +37 -13
  410. package/build/typescript/Tabs/index.d.ts +1 -0
  411. package/build/typescript/Tabs/types.d.ts +9 -0
  412. package/build/typescript/Tabs/useIndexStore.d.ts +3 -0
  413. package/build/typescript/Tabs/useScrollViewReaction.d.ts +8 -0
  414. package/build/typescript/Tabs/useTabCoordinates.d.ts +6 -0
  415. package/build/typescript/Tabs/useTabInnerContentsWidth.d.ts +6 -0
  416. package/build/typescript/Tabs/utils.d.ts +3 -0
  417. package/build/typescript/TextField/InputLabel.d.ts +1 -0
  418. package/build/typescript/TextField/TextFieldProps.d.ts +3 -0
  419. package/build/typescript/Toolbar/Toolbar.d.ts +1 -0
  420. package/build/typescript/Tooltip/Tooltip.d.ts +1 -0
  421. package/build/typescript/Tooltip/TooltipProps.d.ts +26 -1
  422. package/build/typescript/Typography/TypographyProps.d.ts +22 -1
  423. package/build/typescript/animated/AnimatedPressable.d.ts +2 -2
  424. package/build/typescript/hooks/index.d.ts +5 -0
  425. package/build/typescript/hooks/useAnimatedValue.d.ts +2 -0
  426. package/build/typescript/hooks/useCollapsibleAppBar.d.ts +2 -0
  427. package/build/typescript/hooks/useDebounce.d.ts +1 -0
  428. package/build/typescript/hooks/useFadeInAppBar.d.ts +1 -0
  429. package/build/typescript/hooks/useImperativeState.d.ts +6 -0
  430. package/build/typescript/hooks/useSyncAnimatedValue.d.ts +6 -0
  431. package/build/typescript/hooks/useValidWindowDimensions/index.ios.d.ts +2 -1
  432. package/build/typescript/index.d.ts +4 -2
  433. package/build/typescript/internal/hooks/index.d.ts +0 -1
  434. package/build/typescript/internal/icons/Checkbox.d.ts +9 -7
  435. package/build/typescript/internal/icons/CheckboxChecked.d.ts +9 -7
  436. package/build/typescript/internal/icons/ChevronDown.d.ts +9 -7
  437. package/build/typescript/internal/icons/ChevronLeft.d.ts +9 -7
  438. package/build/typescript/internal/icons/ChevronRight.d.ts +9 -7
  439. package/build/typescript/internal/icons/CircularProgress.d.ts +1 -0
  440. package/build/typescript/internal/icons/Close.d.ts +9 -7
  441. package/build/typescript/internal/icons/Radio.d.ts +9 -7
  442. package/build/typescript/internal/icons/RadioChecked.d.ts +9 -7
  443. package/build/typescript/store/MockStore.d.ts +7 -0
  444. package/build/typescript/store/SimpleStore.d.ts +10 -0
  445. package/build/typescript/store/index.d.ts +3 -0
  446. package/build/typescript/store/types.d.ts +10 -0
  447. package/build/typescript/types/index.d.ts +6 -0
  448. package/build/typescript/utils/index.d.ts +1 -0
  449. package/build/typescript/utils/isNotAndroid12.d.ts +2 -0
  450. package/package.json +9 -9
  451. package/src/Accordion/Accordion.tsx +147 -51
  452. package/src/Accordion/AccordionProps.ts +15 -11
  453. package/src/Badge/Badge.tsx +6 -16
  454. package/src/Badge/BadgeProps.ts +6 -0
  455. package/src/Button/Button.tsx +8 -2
  456. package/src/ButtonBase/ButtonBase.tsx +79 -44
  457. package/src/ButtonBase/ButtonBaseProps.ts +10 -0
  458. package/src/Checkbox/CheckboxProps.ts +1 -1
  459. package/src/Chip/Chip.tsx +13 -9
  460. package/src/Chip/ChipProps.ts +5 -0
  461. package/src/CircularProgress/CircularProgress.tsx +41 -33
  462. package/src/Dialog/Dialog.tsx +136 -14
  463. package/src/Dialog/DialogProps.ts +12 -0
  464. package/src/Divider/Divider.tsx +23 -14
  465. package/src/Divider/DividerProps.ts +27 -1
  466. package/src/Image/Image.tsx +78 -16
  467. package/src/Image/ImageProps.ts +36 -2
  468. package/src/Image/index.ts +1 -1
  469. package/src/ImageCore/ImageCoreNative.tsx +29 -19
  470. package/src/ImageCore/ImageCoreProps.ts +6 -1
  471. package/src/ImageCore/ImageCoreWeb.tsx +22 -2
  472. package/src/ImageCore/ImageFileExtensionContext.ts +7 -0
  473. package/src/ImageCore/ImageFileExtensionProvider.tsx +33 -0
  474. package/src/ImageCore/index.native.ts +3 -1
  475. package/src/ImageCore/index.ts +4 -1
  476. package/src/Modal/AnimatedContainer/index.tsx +172 -0
  477. package/src/Modal/Modal.tsx +44 -12
  478. package/src/Modal/ModalProps.ts +59 -1
  479. package/src/Modal/index.ts +4 -1
  480. package/src/Paper/Paper.tsx +1 -1
  481. package/src/Radio/Radio.tsx +10 -7
  482. package/src/Radio/RadioProps.ts +16 -0
  483. package/src/Slide/Slide.tsx +33 -27
  484. package/src/Slide/SlideProps.ts +2 -3
  485. package/src/Snackbar/Snackbar.tsx +33 -7
  486. package/src/Snackbar/SnackbarProps.ts +19 -9
  487. package/src/SnackbarContent/SnackbarContent.tsx +42 -10
  488. package/src/SnackbarContent/SnackbarContentProps.ts +14 -3
  489. package/src/SvgIcon/SvgIcon.tsx +1 -1
  490. package/src/Tab/Tab.tsx +85 -28
  491. package/src/Tab/TabIndicator.tsx +17 -15
  492. package/src/Tab/TabProps.ts +24 -2
  493. package/src/Tab/index.ts +1 -1
  494. package/src/Tabs/IndexAwareTab.tsx +29 -0
  495. package/src/Tabs/InternalContext.ts +13 -0
  496. package/src/Tabs/ScrollableTabsView.tsx +28 -0
  497. package/src/Tabs/TabIndicator.tsx +74 -37
  498. package/src/Tabs/TabIndicatorProps.ts +12 -5
  499. package/src/Tabs/Tabs.tsx +139 -93
  500. package/src/Tabs/TabsProps.ts +43 -23
  501. package/src/Tabs/index.ts +2 -1
  502. package/src/Tabs/types.ts +18 -0
  503. package/src/Tabs/useIndexStore.ts +31 -0
  504. package/src/Tabs/useScrollViewReaction.ts +62 -0
  505. package/src/Tabs/useTabCoordinates.ts +25 -0
  506. package/src/Tabs/useTabInnerContentsWidth.ts +26 -0
  507. package/src/Tabs/utils.ts +14 -0
  508. package/src/TextField/InputLabel.tsx +6 -1
  509. package/src/TextField/OutlinedTextField.tsx +8 -2
  510. package/src/TextField/TextField.tsx +10 -4
  511. package/src/TextField/TextFieldProps.ts +4 -0
  512. package/src/Tooltip/Tooltip.tsx +57 -26
  513. package/src/Tooltip/TooltipProps.ts +26 -1
  514. package/src/Typography/Typography.tsx +12 -3
  515. package/src/Typography/TypographyProps.ts +30 -1
  516. package/src/animated/AnimatedPressable.tsx +1 -2
  517. package/src/hooks/index.ts +6 -0
  518. package/src/hooks/useAnimatedValue.ts +21 -0
  519. package/src/hooks/useCollapsibleAppBar.ts +64 -47
  520. package/src/hooks/useDebounce.ts +23 -0
  521. package/src/hooks/useFadeInAppBar.ts +23 -17
  522. package/src/hooks/useImperativeState.ts +24 -0
  523. package/src/hooks/useSyncAnimatedValue.ts +38 -0
  524. package/src/hooks/useThrottle.ts +3 -3
  525. package/src/hooks/useValidWindowDimensions/index.ios.ts +16 -10
  526. package/src/index.ts +6 -2
  527. package/src/internal/hooks/index.ts +0 -1
  528. package/src/internal/hooks/useHeight.ts +4 -5
  529. package/src/internal/icons/Checkbox.tsx +1 -1
  530. package/src/internal/icons/CheckboxChecked.tsx +1 -1
  531. package/src/internal/icons/ChevronDown.tsx +1 -1
  532. package/src/internal/icons/ChevronLeft.tsx +1 -1
  533. package/src/internal/icons/ChevronRight.tsx +1 -1
  534. package/src/internal/icons/Close.tsx +1 -1
  535. package/src/internal/icons/Radio.tsx +1 -1
  536. package/src/internal/icons/RadioChecked.tsx +1 -1
  537. package/src/store/MockStore.ts +21 -0
  538. package/src/store/SimpleStore.ts +50 -0
  539. package/src/store/index.ts +3 -0
  540. package/src/store/types.ts +12 -0
  541. package/src/types/index.ts +7 -0
  542. package/src/utils/index.ts +1 -0
  543. package/src/utils/isNotAndroid12.ts +7 -0
  544. package/build/commonjs/ButtonBase/ButtonBase.ios.js +0 -101
  545. package/build/commonjs/ButtonBase/ButtonBase.ios.js.map +0 -1
  546. package/build/commonjs/ButtonBase/useDisabledReaction/index.js +0 -21
  547. package/build/commonjs/ButtonBase/useDisabledReaction/index.js.map +0 -1
  548. package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js +0 -9
  549. package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js.map +0 -1
  550. package/build/commonjs/ImageCore/ImageCoreNative.ios.js +0 -60
  551. package/build/commonjs/ImageCore/ImageCoreNative.ios.js.map +0 -1
  552. package/build/commonjs/internal/hooks/useWidth.js +0 -29
  553. package/build/commonjs/internal/hooks/useWidth.js.map +0 -1
  554. package/build/module/ButtonBase/ButtonBase.ios.js +0 -82
  555. package/build/module/ButtonBase/ButtonBase.ios.js.map +0 -1
  556. package/build/module/ButtonBase/useDisabledReaction/index.js +0 -12
  557. package/build/module/ButtonBase/useDisabledReaction/index.js.map +0 -1
  558. package/build/module/ButtonBase/useDisabledReaction/index.native.js +0 -2
  559. package/build/module/ButtonBase/useDisabledReaction/index.native.js.map +0 -1
  560. package/build/module/ImageCore/ImageCoreNative.ios.js +0 -45
  561. package/build/module/ImageCore/ImageCoreNative.ios.js.map +0 -1
  562. package/build/module/internal/hooks/useWidth.js +0 -15
  563. package/build/module/internal/hooks/useWidth.js.map +0 -1
  564. package/build/typescript/ButtonBase/ButtonBase.ios.d.ts +0 -2
  565. package/build/typescript/ButtonBase/useDisabledReaction/index.d.ts +0 -2
  566. package/build/typescript/ButtonBase/useDisabledReaction/index.native.d.ts +0 -2
  567. package/build/typescript/ImageCore/ImageCoreNative.ios.d.ts +0 -2
  568. package/build/typescript/internal/hooks/useWidth.d.ts +0 -2
  569. package/src/ButtonBase/ButtonBase.ios.tsx +0 -95
  570. package/src/ButtonBase/useDisabledReaction/index.native.ts +0 -4
  571. package/src/ButtonBase/useDisabledReaction/index.ts +0 -16
  572. package/src/ImageCore/ImageCoreNative.ios.tsx +0 -46
  573. package/src/internal/hooks/useWidth.ts +0 -17
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = ScrollableTabsView;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _useScrollViewReaction = _interopRequireDefault(require("./useScrollViewReaction"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
+
18
+ function ScrollableTabsView(props) {
19
+ const {
20
+ coordinates,
21
+ initialIndex,
22
+ ...scrollViewProps
23
+ } = props;
24
+ const {
25
+ scrollViewRef,
26
+ onLayout
27
+ } = (0, _useScrollViewReaction.default)(initialIndex, coordinates);
28
+ return /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, _extends({
29
+ ref: scrollViewRef,
30
+ onLayout: onLayout
31
+ }, scrollViewProps));
32
+ }
33
+
34
+ ;
35
+ //# sourceMappingURL=ScrollableTabsView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ScrollableTabsView","props","coordinates","initialIndex","scrollViewProps","scrollViewRef","onLayout","useScrollViewReaction"],"sources":["ScrollableTabsView.tsx"],"sourcesContent":["import React from 'react';\nimport type { ScrollViewProps } from 'react-native';\nimport { ScrollView } from 'react-native';\nimport TabCoordinate from './TabCoordinate';\nimport useScrollViewReaction from './useScrollViewReaction';\n\nexport interface ScrollableTabsViewProps extends ScrollViewProps {\n initialIndex: number;\n coordinates: TabCoordinate[];\n}\n\nexport default function ScrollableTabsView(props: ScrollableTabsViewProps) {\n const {\n coordinates,\n initialIndex,\n ...scrollViewProps\n } = props;\n\n const { scrollViewRef, onLayout } = useScrollViewReaction(initialIndex, coordinates);\n\n return (\n <ScrollView\n ref={scrollViewRef}\n onLayout={onLayout}\n {...scrollViewProps}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;;;;;AAOe,SAASA,kBAAT,CAA4BC,KAA5B,EAA4D;EACvE,MAAM;IACFC,WADE;IAEFC,YAFE;IAGF,GAAGC;EAHD,IAIFH,KAJJ;EAMA,MAAM;IAAEI,aAAF;IAAiBC;EAAjB,IAA8B,IAAAC,8BAAA,EAAsBJ,YAAtB,EAAoCD,WAApC,CAApC;EAEA,oBACI,6BAAC,uBAAD;IACI,GAAG,EAAEG,aADT;IAEI,QAAQ,EAAEC;EAFd,GAGQF,eAHR,EADJ;AAOH;;AAAA"}
@@ -5,29 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = TabIndicator;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNative = require("react-native");
11
11
 
12
12
  var _styles = require("../styles");
13
13
 
14
+ var _hooks = require("../hooks");
15
+
16
+ var _utils = require("../utils");
17
+
14
18
  var _TabCoordinate = require("./TabCoordinate");
15
19
 
20
+ var _InternalContext = _interopRequireDefault(require("./InternalContext"));
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
16
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
25
 
18
26
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
27
 
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
28
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
29
 
24
- const useStyles = function () {
30
+ const INDICATOR_WIDTH = 10;
31
+ const INDICATOR_HEIGHT = 2;
32
+ const SCROLLABLE_TABS_INSET = 12 * 2;
33
+
34
+ const useStyles = function (color) {
25
35
  const theme = (0, _styles.useTheme)();
26
36
  return {
27
37
  root: {
28
- backgroundColor: theme.palette.secondary.main,
38
+ backgroundColor: theme.palette[color].main,
39
+ left: 0,
29
40
  bottom: 0,
30
- height: 4,
41
+ width: INDICATOR_WIDTH,
42
+ height: INDICATOR_HEIGHT,
31
43
  position: 'absolute'
32
44
  },
33
45
  disabled: {
@@ -36,37 +48,70 @@ const useStyles = function () {
36
48
  };
37
49
  };
38
50
 
51
+ const startAnimation = (value, toValue) => {
52
+ _reactNative.Animated.timing(value, {
53
+ toValue: toValue,
54
+ duration: 300,
55
+ easing: _reactNative.Easing.bezier(0.25, 1, 0.5, 1),
56
+ useNativeDriver: _utils.isNotAndroid12
57
+ }).start();
58
+ };
59
+
39
60
  function TabIndicator(props) {
40
61
  const {
62
+ color = 'primary',
41
63
  coordinates,
42
64
  disabled,
65
+ initialIndex,
43
66
  scrollable,
44
- scrollValue,
45
67
  style,
46
68
  ...otherProps
47
69
  } = props;
48
- const styles = useStyles();
49
- const layout = (0, _reactNativeReanimated.useDerivedValue)(() => {
50
- const rawScrollValue = scrollValue.value;
51
- const index = Math.floor(rawScrollValue);
52
- const offset = rawScrollValue % 1;
53
- const coordinate = coordinates[index] ?? _TabCoordinate.defaultCoordinate;
54
- const nextCoordinate = coordinates[index + 1] ?? _TabCoordinate.defaultCoordinate;
55
- const x1 = offset * nextCoordinate.x1 + (1 - offset) * coordinate.x1;
56
- const x2 = offset * nextCoordinate.x2 + (1 - offset) * coordinate.x2;
57
- const leftInset = scrollable ? 12 : 0;
58
- const rightInset = scrollable ? 24 : 0;
70
+ const styles = useStyles(color);
71
+ const computeAnimationValues = (0, _react.useCallback)(currentIndex => {
72
+ const {
73
+ x1,
74
+ x2
75
+ } = coordinates[currentIndex] ?? _TabCoordinate.defaultCoordinate;
76
+ const tabWidth = x2 - x1;
77
+ const nextTranslateX = x1 + (tabWidth - INDICATOR_WIDTH) / 2;
78
+ const inset = scrollable ? SCROLLABLE_TABS_INSET : 0;
79
+ const nextScaleX = (tabWidth - inset) / INDICATOR_WIDTH;
59
80
  return {
60
- left: x1 + leftInset,
61
- width: Math.max(x2 - x1 - rightInset, 0)
81
+ tx: nextTranslateX,
82
+ sx: nextScaleX
62
83
  };
63
- });
64
- const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
65
- left: layout.value.left,
66
- width: layout.value.width
67
- }));
68
- return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, _extends({
69
- style: [styles.root, disabled ? styles.disabled : undefined, animatedStyle, style]
84
+ }, [coordinates, scrollable]);
85
+ const {
86
+ tx: initialTx,
87
+ sx: initialSx
88
+ } = computeAnimationValues(initialIndex);
89
+ const translateX = (0, _hooks.useAnimatedValue)(initialTx);
90
+ const scaleX = (0, _hooks.useAnimatedValue)(initialSx);
91
+ const {
92
+ indexStore
93
+ } = (0, _react.useContext)(_InternalContext.default);
94
+ (0, _react.useEffect)(() => {
95
+ const scrollToIndex = index => {
96
+ const {
97
+ tx,
98
+ sx
99
+ } = computeAnimationValues(index);
100
+ startAnimation(translateX, tx);
101
+ startAnimation(scaleX, sx);
102
+ };
103
+
104
+ scrollToIndex(indexStore.getState());
105
+ return indexStore.subscribe(scrollToIndex);
106
+ }, [computeAnimationValues, coordinates, indexStore]);
107
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, _extends({
108
+ style: [styles.root, disabled ? styles.disabled : undefined, {
109
+ transform: [{
110
+ translateX
111
+ }, {
112
+ scaleX
113
+ }]
114
+ }, style]
70
115
  }, otherProps));
71
116
  }
72
117
 
@@ -1 +1 @@
1
- {"version":3,"names":["useStyles","theme","useTheme","root","backgroundColor","palette","secondary","main","bottom","height","position","disabled","TabIndicator","props","coordinates","scrollable","scrollValue","style","otherProps","styles","layout","useDerivedValue","rawScrollValue","value","index","Math","floor","offset","coordinate","defaultCoordinate","nextCoordinate","x1","x2","leftInset","rightInset","left","width","max","animatedStyle","useAnimatedStyle","undefined"],"sources":["TabIndicator.tsx"],"sourcesContent":["import React from 'react';\nimport Animated, { useAnimatedStyle, useDerivedValue } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport type TabIndicatorProps from './TabIndicatorProps';\nimport { defaultCoordinate } from './TabCoordinate';\n\ntype TabIndicatorStyles = NamedStylesStringUnion<'root' | 'disabled'>;\n\nconst useStyles: UseStyles<TabIndicatorStyles> = function (): TabIndicatorStyles {\n const theme = useTheme();\n\n return {\n root: {\n backgroundColor: theme.palette.secondary.main,\n bottom: 0,\n height: 4,\n position: 'absolute',\n },\n disabled: {\n height: 0,\n },\n };\n};\n\nexport default function TabIndicator(props: TabIndicatorProps) {\n const {\n coordinates,\n disabled,\n scrollable,\n scrollValue,\n style,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const layout = useDerivedValue(() => {\n const rawScrollValue = scrollValue.value;\n const index = Math.floor(rawScrollValue);\n const offset = rawScrollValue % 1;\n\n const coordinate = coordinates[index] ?? defaultCoordinate;\n const nextCoordinate = coordinates[index + 1] ?? defaultCoordinate;\n\n const x1 = (offset * nextCoordinate.x1 + (1 - offset) * coordinate.x1);\n const x2 = (offset * nextCoordinate.x2 + (1 - offset) * coordinate.x2);\n\n const leftInset = scrollable ? 12 : 0;\n const rightInset = scrollable ? 24 : 0;\n\n return {\n left: x1 + leftInset,\n width: Math.max(x2 - x1 - rightInset, 0),\n };\n });\n\n const animatedStyle = useAnimatedStyle(() => ({\n left: layout.value.left,\n width: layout.value.width,\n }));\n\n return (\n <Animated.View\n style={[\n styles.root,\n disabled ? styles.disabled : undefined,\n animatedStyle,\n style,\n ]}\n {...otherProps}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAEA;;;;;;;;;;AAIA,MAAMA,SAAwC,GAAG,YAAgC;EAC7E,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,eAAe,EAAEH,KAAK,CAACI,OAAN,CAAcC,SAAd,CAAwBC,IADvC;MAEFC,MAAM,EAAE,CAFN;MAGFC,MAAM,EAAE,CAHN;MAIFC,QAAQ,EAAE;IAJR,CADH;IAOHC,QAAQ,EAAE;MACNF,MAAM,EAAE;IADF;EAPP,CAAP;AAWH,CAdD;;AAgBe,SAASG,YAAT,CAAsBC,KAAtB,EAAgD;EAC3D,MAAM;IACFC,WADE;IAEFH,QAFE;IAGFI,UAHE;IAIFC,WAJE;IAKFC,KALE;IAMF,GAAGC;EAND,IAOFL,KAPJ;EASA,MAAMM,MAAM,GAAGnB,SAAS,EAAxB;EAEA,MAAMoB,MAAM,GAAG,IAAAC,sCAAA,EAAgB,MAAM;IACjC,MAAMC,cAAc,GAAGN,WAAW,CAACO,KAAnC;IACA,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAWJ,cAAX,CAAd;IACA,MAAMK,MAAM,GAAGL,cAAc,GAAG,CAAhC;IAEA,MAAMM,UAAU,GAAGd,WAAW,CAACU,KAAD,CAAX,IAAsBK,gCAAzC;IACA,MAAMC,cAAc,GAAGhB,WAAW,CAACU,KAAK,GAAG,CAAT,CAAX,IAA0BK,gCAAjD;IAEA,MAAME,EAAE,GAAIJ,MAAM,GAAGG,cAAc,CAACC,EAAxB,GAA6B,CAAC,IAAIJ,MAAL,IAAeC,UAAU,CAACG,EAAnE;IACA,MAAMC,EAAE,GAAIL,MAAM,GAAGG,cAAc,CAACE,EAAxB,GAA6B,CAAC,IAAIL,MAAL,IAAeC,UAAU,CAACI,EAAnE;IAEA,MAAMC,SAAS,GAAGlB,UAAU,GAAG,EAAH,GAAQ,CAApC;IACA,MAAMmB,UAAU,GAAGnB,UAAU,GAAG,EAAH,GAAQ,CAArC;IAEA,OAAO;MACHoB,IAAI,EAAEJ,EAAE,GAAGE,SADR;MAEHG,KAAK,EAAEX,IAAI,CAACY,GAAL,CAASL,EAAE,GAAGD,EAAL,GAAUG,UAAnB,EAA+B,CAA/B;IAFJ,CAAP;EAIH,CAlBc,CAAf;EAoBA,MAAMI,aAAa,GAAG,IAAAC,uCAAA,EAAiB,OAAO;IAC1CJ,IAAI,EAAEf,MAAM,CAACG,KAAP,CAAaY,IADuB;IAE1CC,KAAK,EAAEhB,MAAM,CAACG,KAAP,CAAaa;EAFsB,CAAP,CAAjB,CAAtB;EAKA,oBACI,6BAAC,8BAAD,CAAU,IAAV;IACI,KAAK,EAAE,CACHjB,MAAM,CAAChB,IADJ,EAEHQ,QAAQ,GAAGQ,MAAM,CAACR,QAAV,GAAqB6B,SAF1B,EAGHF,aAHG,EAIHrB,KAJG;EADX,GAOQC,UAPR,EADJ;AAWH;;AAAA"}
1
+ {"version":3,"names":["INDICATOR_WIDTH","INDICATOR_HEIGHT","SCROLLABLE_TABS_INSET","useStyles","color","theme","useTheme","root","backgroundColor","palette","main","left","bottom","width","height","position","disabled","startAnimation","value","toValue","Animated","timing","duration","easing","Easing","bezier","useNativeDriver","isNotAndroid12","start","TabIndicator","props","coordinates","initialIndex","scrollable","style","otherProps","styles","computeAnimationValues","useCallback","currentIndex","x1","x2","defaultCoordinate","tabWidth","nextTranslateX","inset","nextScaleX","tx","sx","initialTx","initialSx","translateX","useAnimatedValue","scaleX","indexStore","useContext","InternalContext","useEffect","scrollToIndex","index","getState","subscribe","undefined","transform"],"sources":["TabIndicator.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect } from 'react';\nimport { Animated, Easing } from 'react-native';\nimport { NamedStylesStringUnion } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport { useAnimatedValue } from '../hooks';\nimport { isNotAndroid12 } from '../utils';\nimport type TabIndicatorProps from './TabIndicatorProps';\nimport type { TabIndicatorColor } from './TabIndicatorProps';\nimport { defaultCoordinate } from './TabCoordinate';\nimport InternalContext from './InternalContext';\n\ntype TabIndicatorStyles = NamedStylesStringUnion<'root' | 'disabled'>;\n\nconst INDICATOR_WIDTH = 10;\nconst INDICATOR_HEIGHT = 2;\n\nconst SCROLLABLE_TABS_INSET = 12 * 2;\n\nconst useStyles: (color: TabIndicatorColor) => TabIndicatorStyles =\n function (color: TabIndicatorColor): TabIndicatorStyles {\n const theme = useTheme();\n\n return {\n root: {\n backgroundColor: theme.palette[color].main,\n left: 0,\n bottom: 0,\n width: INDICATOR_WIDTH,\n height: INDICATOR_HEIGHT,\n position: 'absolute',\n },\n disabled: {\n height: 0,\n },\n };\n };\n\nconst startAnimation = (value: Animated.Value, toValue: number) => {\n Animated.timing(value, {\n toValue: toValue,\n duration: 300,\n easing: Easing.bezier(0.25, 1, 0.5, 1),\n useNativeDriver: isNotAndroid12,\n }).start();\n};\n\nexport default function TabIndicator(props: TabIndicatorProps) {\n const {\n color = 'primary',\n coordinates,\n disabled,\n initialIndex,\n scrollable,\n style,\n ...otherProps\n } = props;\n\n const styles = useStyles(color);\n\n const computeAnimationValues = useCallback((currentIndex: number) => {\n const { x1, x2 } = coordinates[currentIndex] ?? defaultCoordinate;\n\n const tabWidth = x2 - x1;\n\n const nextTranslateX = x1 + (tabWidth - INDICATOR_WIDTH) / 2;\n\n const inset = scrollable ? SCROLLABLE_TABS_INSET : 0;\n const nextScaleX = (tabWidth - inset) / INDICATOR_WIDTH;\n\n return { tx: nextTranslateX, sx: nextScaleX };\n }, [coordinates, scrollable]);\n\n const {\n tx: initialTx,\n sx: initialSx,\n } = computeAnimationValues(initialIndex);\n\n const translateX = useAnimatedValue(initialTx);\n const scaleX = useAnimatedValue(initialSx);\n\n const { indexStore } = useContext(InternalContext);\n\n useEffect(() => {\n const scrollToIndex = (index: number) => {\n const { tx, sx } = computeAnimationValues(index);\n\n startAnimation(translateX, tx);\n startAnimation(scaleX, sx);\n };\n\n scrollToIndex(indexStore.getState());\n\n return indexStore.subscribe(scrollToIndex);\n }, [\n computeAnimationValues,\n coordinates,\n indexStore,\n ]);\n\n return (\n <Animated.View\n style={[\n styles.root,\n disabled ? styles.disabled : undefined,\n { transform: [{ translateX }, { scaleX }] },\n style,\n ]}\n {...otherProps}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;;;AAIA,MAAMA,eAAe,GAAG,EAAxB;AACA,MAAMC,gBAAgB,GAAG,CAAzB;AAEA,MAAMC,qBAAqB,GAAG,KAAK,CAAnC;;AAEA,MAAMC,SAA2D,GAC7D,UAAUC,KAAV,EAAwD;EACpD,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,eAAe,EAAEH,KAAK,CAACI,OAAN,CAAcL,KAAd,EAAqBM,IADpC;MAEFC,IAAI,EAAE,CAFJ;MAGFC,MAAM,EAAE,CAHN;MAIFC,KAAK,EAAEb,eAJL;MAKFc,MAAM,EAAEb,gBALN;MAMFc,QAAQ,EAAE;IANR,CADH;IASHC,QAAQ,EAAE;MACNF,MAAM,EAAE;IADF;EATP,CAAP;AAaH,CAjBL;;AAmBA,MAAMG,cAAc,GAAG,CAACC,KAAD,EAAwBC,OAAxB,KAA4C;EAC/DC,qBAAA,CAASC,MAAT,CAAgBH,KAAhB,EAAuB;IACnBC,OAAO,EAAEA,OADU;IAEnBG,QAAQ,EAAE,GAFS;IAGnBC,MAAM,EAAEC,mBAAA,CAA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ACZ,MAAMC,aAAa,GAAIC,KAAD,IAAmB;MACrC,MAAM;QAAEZ,EAAF;QAAMC;MAAN,IAAaX,sBAAsB,CAACsB,KAAD,CAAzC;MAEA1C,cAAc,CAACkC,UAAD,EAAaJ,EAAb,CAAd;MACA9B,cAAc,CAACoC,MAAD,EAASL,EAAT,CAAd;IACH,CALD;;IAOAU,aAAa,CAACJ,UAAU,CAACM,QAAX,EAAD,CAAb;IAEA,OAAON,UAAU,CAACO,SAAX,CAAqBH,aAArB,CAAP;EACH,CAXD,EAWG,CACCrB,sBADD,EAECN,WAFD,EAGCuB,UAHD,CAXH;EAiBA,oBACI,6BAAC,qBAAD,CAAU,IAAV;IACI,KAAK,EAAE,CACHlB,MAAM,CAAC7B,IADJ,EAEHS,QAAQ,GAAGoB,MAAM,CAACpB,QAAV,GAAqB8C,SAF1B,EAGH;MAAEC,SAAS,EAAE,CAAC;QAAEZ;MAAF,CAAD,EAAiB;QAAEE;MAAF,CAAjB;IAAb,CAHG,EAIHnB,KAJG;EADX,GAOQC,UAPR,EADJ;AAWH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TabIndicatorProps.ts"],"sourcesContent":["import type { ViewProps } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { OverridableComponentProps } from '../types';\nimport type TabCoordinate from './TabCoordinate';\n\nexport default interface TabIndicatorProps extends OverridableComponentProps<ViewProps, {\n /**\n * Tab item coordinates.\n */\n coordinates: TabCoordinate[];\n\n /**\n * If `true`, the indicator is disabled.\n */\n disabled: boolean;\n\n /**\n * If `true`, the tab will be able to scroll.\n */\n scrollable: boolean;\n\n /**\n * Scrollable value for using animated interpolation.\n */\n scrollValue: SharedValue<number>;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["TabIndicatorProps.ts"],"sourcesContent":["import type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\nimport type TabCoordinate from './TabCoordinate';\n\nexport type TabIndicatorColor = 'primary' | 'secondary';\n\nexport default interface TabIndicatorProps extends OverridableComponentProps<ViewProps, {\n /**\n * Tab item coordinates.\n */\n coordinates: TabCoordinate[];\n\n /**\n * Indicator color.\n * @default: 'primary'\n */\n color?: TabIndicatorColor;\n\n /**\n * If `true`, the indicator is disabled.\n */\n disabled: boolean;\n\n /**\n * Initial index.\n */\n initialIndex: number;\n\n /**\n * If `true`, the tab will be able to scroll.\n */\n scrollable: boolean;\n}> {}\n"],"mappings":""}
@@ -3,27 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = Tabs;
6
+ exports.default = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
- var _reactNativeReanimated = require("react-native-reanimated");
12
+ var _styles = require("../styles");
13
13
 
14
- var _utils = require("@fountain-ui/utils");
14
+ var _hooks = require("../hooks");
15
15
 
16
- var _styles = require("../styles");
16
+ var _TabIndicator = _interopRequireDefault(require("./TabIndicator"));
17
17
 
18
- var _hooks = require("../internal/hooks");
18
+ var _ScrollableTabsView = _interopRequireDefault(require("./ScrollableTabsView"));
19
19
 
20
- var _TabCoordinate = require("./TabCoordinate");
20
+ var _IndexAwareTab = _interopRequireDefault(require("./IndexAwareTab"));
21
21
 
22
- var _TabIndicator = _interopRequireDefault(require("./TabIndicator"));
22
+ var _useTabCoordinates = _interopRequireDefault(require("./useTabCoordinates"));
23
+
24
+ var _useTabInnerContentsWidth = _interopRequireDefault(require("./useTabInnerContentsWidth"));
25
+
26
+ var _useIndexStore = _interopRequireDefault(require("./useIndexStore"));
27
+
28
+ var _InternalContext = _interopRequireDefault(require("./InternalContext"));
29
+
30
+ var _utils = require("./utils");
23
31
 
24
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
33
 
26
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
34
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
+
36
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
37
 
28
38
  const useStyles = function () {
29
39
  const theme = (0, _styles.useTheme)();
@@ -41,75 +51,93 @@ const useStyles = function () {
41
51
  };
42
52
  };
43
53
 
44
- function Tabs(props) {
54
+ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(function Tabs(props, ref) {
55
+ var _React$Children$map;
56
+
45
57
  const {
46
58
  children,
47
- index: indexProp,
59
+ indicatorColor = 'primary',
60
+ initialIndex = 0,
48
61
  disableIndicator = false,
62
+ indicatorSize = 'full',
49
63
  keyboardDismissMode = 'none',
50
64
  keyboardShouldPersistTaps = 'never',
51
65
  onChange,
52
66
  scrollable = false,
53
- scrollValue: scrollValueProp,
67
+ scrollViewContentContainerStyle,
54
68
  style,
55
69
  variant = 'primary',
56
- ...otherProps
70
+ UNSTABLE_sharedIndex,
71
+ onTabSelected
57
72
  } = props;
58
- const styles = useStyles();
59
- const [containerWidth, handleLayout] = (0, _hooks.useWidth)();
60
-
61
- const scrollViewRef = _react.default.useRef(null);
62
-
63
- const tabCount = _react.default.Children.count(children);
64
-
65
- const [coordinates, setCoordinates] = _react.default.useState(() => new Array(tabCount));
66
-
67
- const internalScrollValue = (0, _reactNativeReanimated.useSharedValue)(0);
68
- const scrollValue = scrollValueProp || internalScrollValue;
69
- const isReadyToRenderIndicator = (0, _utils.isEveryDefined)(coordinates);
73
+ const fallbackSharedIndex = (0, _hooks.useSyncAnimatedValue)({
74
+ initialValue: initialIndex
75
+ });
76
+ const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;
77
+ const realInitialIndex = sharedIndex.initialValue;
78
+ const currentIndexRef = (0, _react.useRef)(initialIndex);
79
+
80
+ const setTab = newIndex => {
81
+ const currentIndex = currentIndexRef.current;
82
+ onTabSelected === null || onTabSelected === void 0 ? void 0 : onTabSelected(newIndex, currentIndex);
83
+ sharedIndex.animatedValue.setValue(newIndex);
84
+ };
70
85
 
71
- _react.default.useEffect(() => {
72
- const animateTab = index => {
73
- internalScrollValue.value = (0, _reactNativeReanimated.withTiming)(index, {
74
- duration: 200,
75
- easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.exp)
76
- });
77
- };
86
+ (0, _react.useImperativeHandle)(ref, () => ({
87
+ setTab
88
+ }), [sharedIndex]);
89
+ const styles = useStyles();
90
+ const [outerCoordinates, updateCoordinate] = (0, _useTabCoordinates.default)(children);
91
+ const [innerContentsWidthList, updateInnerContentsWidth] = (0, _useTabInnerContentsWidth.default)(children);
92
+ const canRenderIndicator = indicatorSize === 'fit-content' ? (0, _utils.isEveryTabCoordinatesDefined)(innerContentsWidthList, children) : (0, _utils.isEveryTabCoordinatesDefined)(outerCoordinates, children);
93
+ const indexStore = (0, _useIndexStore.default)(sharedIndex);
94
+ const coordinates = (0, _react.useMemo)(() => {
95
+ if (indicatorSize !== 'fit-content') {
96
+ return outerCoordinates;
97
+ }
78
98
 
79
- if (scrollValueProp === undefined) {
80
- animateTab(indexProp);
99
+ return innerContentsWidthList.map((innerContentWidth, idx) => {
100
+ const {
101
+ x1: outerX1,
102
+ x2: outerX2
103
+ } = outerCoordinates[idx];
104
+ const tabWidth = outerX2 - outerX1;
105
+ const distanceFromParent = (tabWidth - innerContentWidth) / 2;
106
+ const indicatorStartCoordinate = outerX1 + distanceFromParent;
107
+ return {
108
+ x1: indicatorStartCoordinate,
109
+ x2: indicatorStartCoordinate + innerContentWidth
110
+ };
111
+ });
112
+ }, [outerCoordinates, innerContentsWidthList, variant]);
113
+ (0, _react.useEffect)(() => {
114
+ return indexStore.subscribe(newIndex => {
115
+ onChange === null || onChange === void 0 ? void 0 : onChange(newIndex);
116
+ currentIndexRef.current = newIndex;
117
+ });
118
+ }, [indexStore, onChange]);
119
+ const tabElements = (_React$Children$map = _react.default.Children.map(children, (child, index) => {
120
+ if (!child) {
121
+ return null;
81
122
  }
82
- }, [indexProp, scrollValueProp, internalScrollValue]);
83
-
84
- _react.default.useEffect(() => {
85
- const snapTab = index => {
86
- const scrollView = scrollViewRef.current;
87
- const coordinate = coordinates[index - 1] || _TabCoordinate.defaultCoordinate;
88
-
89
- if (scrollView) {
90
- const tabWidth = coordinate.x2 - coordinate.x1;
91
- const x = coordinate.x1 + tabWidth / 2;
92
- scrollView.scrollTo({
93
- x,
94
- y: 0,
95
- animated: true
96
- });
97
- }
98
- };
99
123
 
100
- snapTab(indexProp);
101
- }, [indexProp, containerWidth, coordinates]);
124
+ const onTabInnerLayout = event => {
125
+ const {
126
+ width
127
+ } = event.nativeEvent.layout;
128
+ updateInnerContentsWidth(index, width);
129
+ };
102
130
 
103
- const tabElements = _react.default.Children.map(children, (child, index) => {
104
131
  const onLayout = event => {
132
+ var _child$props$onLayout, _child$props;
133
+
105
134
  const {
106
135
  x,
107
136
  width
108
137
  } = event.nativeEvent.layout;
109
- setCoordinates(prev => [...prev.slice(0, index), {
110
- x1: x,
111
- x2: x + width
112
- }, ...prev.slice(index + 1)]);
138
+ updateCoordinate(index, x, width); // @ts-ignore
139
+
140
+ (_child$props$onLayout = (_child$props = child.props).onLayout) === null || _child$props$onLayout === void 0 ? void 0 : _child$props$onLayout.call(_child$props, event);
113
141
  };
114
142
 
115
143
  const onMouseDown = e => {
@@ -119,51 +147,59 @@ function Tabs(props) {
119
147
  };
120
148
 
121
149
  const onPress = () => {
122
- var _child$props$onPress, _child$props;
150
+ var _child$props$onPress, _child$props2;
123
151
 
124
- onChange === null || onChange === void 0 ? void 0 : onChange(index); // @ts-ignore
152
+ setTab(index); // @ts-ignore
125
153
 
126
- (_child$props$onPress = (_child$props = child.props).onPress) === null || _child$props$onPress === void 0 ? void 0 : _child$props$onPress.call(_child$props);
127
- };
154
+ (_child$props$onPress = (_child$props2 = child.props).onPress) === null || _child$props$onPress === void 0 ? void 0 : _child$props$onPress.call(_child$props2);
155
+ }; // @ts-ignore
128
156
 
129
- const selected = index === indexProp;
130
- const enableIndicatorPlaceholder = disableIndicator ? false : isReadyToRenderIndicator ? false : selected; //@ts-ignore
131
157
 
132
- return /*#__PURE__*/_react.default.cloneElement(child, {
133
- enableIndicator: enableIndicatorPlaceholder,
158
+ const tabElement = /*#__PURE__*/(0, _react.cloneElement)(child, {
159
+ enableIndicator: !disableIndicator && !canRenderIndicator,
160
+ indicatorColor,
161
+ onTabInnerLayout,
134
162
  onLayout,
135
163
  onPress,
136
164
  onMouseDown,
137
165
  variant,
138
- selected,
166
+ indicatorSize,
139
167
  style: scrollable ? undefined : styles.fixedTab
140
168
  });
141
- });
142
-
143
- const indicator = /*#__PURE__*/_react.default.createElement(_TabIndicator.default, {
169
+ return /*#__PURE__*/_react.default.createElement(_IndexAwareTab.default, {
170
+ children: tabElement,
171
+ index: index,
172
+ initialIndex: realInitialIndex
173
+ });
174
+ })) === null || _React$Children$map === void 0 ? void 0 : _React$Children$map.filter(Boolean);
175
+ const tabIndicator = canRenderIndicator ? /*#__PURE__*/_react.default.createElement(_TabIndicator.default, {
176
+ color: indicatorColor,
144
177
  coordinates: coordinates,
145
178
  disabled: disableIndicator,
146
- scrollable: scrollable,
147
- scrollValue: scrollValue
148
- });
149
-
150
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
151
- onLayout: handleLayout,
179
+ initialIndex: realInitialIndex,
180
+ scrollable: scrollable
181
+ }) : null;
182
+ return /*#__PURE__*/_react.default.createElement(_InternalContext.default.Provider, {
183
+ value: {
184
+ indexStore
185
+ }
186
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
152
187
  style: (0, _styles.css)([styles.root, scrollable ? undefined : styles.fixedRoot, style])
153
- }, otherProps), scrollable ? /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, {
188
+ }, scrollable ? /*#__PURE__*/_react.default.createElement(_ScrollableTabsView.default, {
154
189
  automaticallyAdjustContentInsets: false,
155
190
  bounces: false,
156
- contentContainerStyle: styles.scrollableContainer,
191
+ contentContainerStyle: (0, _styles.css)([styles.scrollableContainer, scrollViewContentContainerStyle]),
192
+ coordinates: coordinates,
157
193
  directionalLockEnabled: true,
158
194
  horizontal: true,
159
- ref: scrollViewRef,
195
+ initialIndex: realInitialIndex,
160
196
  scrollsToTop: false,
161
197
  showsHorizontalScrollIndicator: false,
162
198
  showsVerticalScrollIndicator: false,
163
199
  keyboardDismissMode: keyboardDismissMode,
164
200
  keyboardShouldPersistTaps: keyboardShouldPersistTaps
165
- }, tabElements, indicator) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tabElements, indicator));
166
- }
167
-
168
- ;
201
+ }, tabElements, tabIndicator) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tabElements, tabIndicator)));
202
+ });
203
+ var _default = Tabs;
204
+ exports.default = _default;
169
205
  //# sourceMappingURL=Tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useStyles","theme","useTheme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","children","index","indexProp","disableIndicator","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollValue","scrollValueProp","style","variant","otherProps","styles","containerWidth","handleLayout","useWidth","scrollViewRef","React","useRef","tabCount","Children","count","coordinates","setCoordinates","useState","Array","internalScrollValue","useSharedValue","isReadyToRenderIndicator","isEveryDefined","useEffect","animateTab","value","withTiming","duration","easing","Easing","out","exp","undefined","snapTab","scrollView","current","coordinate","defaultCoordinate","tabWidth","x2","x1","x","scrollTo","y","animated","tabElements","map","child","onLayout","event","width","nativeEvent","layout","prev","slice","onMouseDown","e","preventDefault","onPress","selected","enableIndicatorPlaceholder","cloneElement","enableIndicator","indicator","css"],"sources":["Tabs.tsx"],"sourcesContent":["import React from 'react';\nimport { GestureResponderEvent, LayoutChangeEvent, ScrollView, View } from 'react-native';\nimport { Easing, useSharedValue, withTiming } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { isEveryDefined } from '@fountain-ui/utils';\nimport { css, useTheme } from '../styles';\nimport { useWidth } from '../internal/hooks';\nimport type TabsProps from './TabsProps';\nimport TabCoordinate, { defaultCoordinate } from './TabCoordinate';\nimport TabIndicator from './TabIndicator';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'scrollableContainer';\n\ntype TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;\n\nconst useStyles: UseStyles<TabsStyles> = function (): TabsStyles {\n const theme = useTheme();\n\n return {\n root: {},\n fixedRoot: {\n flexDirection: 'row',\n },\n fixedTab: {\n flex: 1,\n },\n scrollableContainer: {\n paddingHorizontal: theme.spacing(1),\n },\n };\n};\n\nexport default function Tabs(props: TabsProps) {\n const {\n children,\n index: indexProp,\n disableIndicator = false,\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollValue: scrollValueProp,\n style,\n variant = 'primary',\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const [containerWidth, handleLayout] = useWidth();\n\n const scrollViewRef = React.useRef<ScrollView | null>(null);\n\n const tabCount = React.Children.count(children);\n const [coordinates, setCoordinates] = React.useState<TabCoordinate[]>(() => new Array(tabCount));\n\n const internalScrollValue = useSharedValue(0);\n const scrollValue = scrollValueProp || internalScrollValue;\n\n const isReadyToRenderIndicator = isEveryDefined(coordinates);\n\n React.useEffect(() => {\n const animateTab = (index: number) => {\n internalScrollValue.value = withTiming(index, {\n duration: 200,\n easing: Easing.out(Easing.exp),\n });\n };\n\n if (scrollValueProp === undefined) {\n animateTab(indexProp);\n }\n }, [indexProp, scrollValueProp, internalScrollValue]);\n\n React.useEffect(() => {\n const snapTab = (index: number) => {\n const scrollView = scrollViewRef.current;\n const coordinate: TabCoordinate = coordinates[index - 1] || defaultCoordinate;\n\n if (scrollView) {\n const tabWidth = coordinate.x2 - coordinate.x1;\n const x = coordinate.x1 + tabWidth / 2;\n\n scrollView.scrollTo({ x, y: 0, animated: true });\n }\n };\n\n snapTab(indexProp);\n }, [indexProp, containerWidth, coordinates]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n setCoordinates(prev => ([\n ...prev.slice(0, index),\n { x1: x, x2: x + width },\n ...prev.slice(index + 1),\n ]));\n };\n\n const onMouseDown = (e: GestureResponderEvent) => {\n if (keyboardShouldPersistTaps === 'always') {\n e.preventDefault();\n }\n };\n\n const onPress = () => {\n onChange?.(index);\n // @ts-ignore\n child.props.onPress?.();\n };\n\n const selected = index === indexProp;\n const enableIndicatorPlaceholder = disableIndicator\n ? false\n : (isReadyToRenderIndicator ? false : selected);\n\n //@ts-ignore\n return React.cloneElement(child, {\n enableIndicator: enableIndicatorPlaceholder,\n onLayout,\n onPress,\n onMouseDown,\n variant,\n selected,\n style: scrollable ? undefined : styles.fixedTab,\n });\n });\n\n const indicator = (\n <TabIndicator\n coordinates={coordinates}\n disabled={disableIndicator}\n scrollable={scrollable}\n scrollValue={scrollValue}\n />\n );\n\n return (\n <View\n onLayout={handleLayout}\n style={css([\n styles.root,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n {...otherProps}\n >\n {scrollable ? (\n <ScrollView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={styles.scrollableContainer}\n directionalLockEnabled={true}\n horizontal={true}\n ref={scrollViewRef}\n scrollsToTop={false}\n showsHorizontalScrollIndicator={false}\n showsVerticalScrollIndicator={false}\n keyboardDismissMode={keyboardDismissMode}\n keyboardShouldPersistTaps={keyboardShouldPersistTaps}\n >\n {tabElements}\n {indicator}\n </ScrollView>\n ) : (\n <>\n {tabElements}\n {indicator}\n </>\n )}\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAUA,MAAMA,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE,EADH;IAEHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAFR;IAKHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CALP;IAQHC,mBAAmB,EAAE;MACjBC,iBAAiB,EAAER,KAAK,CAACS,OAAN,CAAc,CAAd;IADF;EARlB,CAAP;AAYH,CAfD;;AAiBe,SAASC,IAAT,CAAcC,KAAd,EAAgC;EAC3C,MAAM;IACFC,QADE;IAEFC,KAAK,EAAEC,SAFL;IAGFC,gBAAgB,GAAG,KAHjB;IAIFC,mBAAmB,GAAG,MAJpB;IAKFC,yBAAyB,GAAG,OAL1B;IAMFC,QANE;IAOFC,UAAU,GAAG,KAPX;IAQFC,WAAW,EAAEC,eARX;IASFC,KATE;IAUFC,OAAO,GAAG,SAVR;IAWF,GAAGC;EAXD,IAYFb,KAZJ;EAcA,MAAMc,MAAM,GAAG1B,SAAS,EAAxB;EAEA,MAAM,CAAC2B,cAAD,EAAi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,KAD6C,GAE5C0B,wBAAwB,GAAG,KAAH,GAAWsC,QAF1C,CAxB+D,CA4B/D;;IACA,oBAAOjD,cAAA,CAAMmD,YAAN,CAAmBd,KAAnB,EAA0B;MAC7Be,eAAe,EAAEF,0BADY;MAE7BZ,QAF6B;MAG7BU,OAH6B;MAI7BH,WAJ6B;MAK7BpD,OAL6B;MAM7BwD,QAN6B;MAO7BzD,KAAK,EAAEH,UAAU,GAAGiC,SAAH,GAAe3B,MAAM,CAACpB;IAPV,CAA1B,CAAP;EASH,CAtCmB,CAApB;;EAwCA,MAAM8E,SAAS,gBACX,6BAAC,qBAAD;IACI,WAAW,EAAEhD,WADjB;IAEI,QAAQ,EAAEpB,gBAFd;IAGI,UAAU,EAAEI,UAHhB;IAII,WAAW,EAAEC;EAJjB,EADJ;;EASA,oBACI,6BAAC,iBAAD;IACI,QAAQ,EAAEO,YADd;IAEI,KAAK,EAAE,IAAAyD,WAAA,EAAI,CACP3D,MAAM,CAACvB,IADA,EAEPiB,UAAU,GAAGiC,SAAH,GAAe3B,MAAM,CAACtB,SAFzB,EAGPmB,KAHO,CAAJ;EAFX,GAOQE,UAPR,GASKL,UAAU,gBACP,6BAAC,uBAAD;IACI,gCAAgC,EAAE,KADtC;IAEI,OAAO,EAAE,KAFb;IAGI,qBAAqB,EAAEM,MAAM,CAAClB,mBAHlC;IAII,sBAAsB,EAAE,IAJ5B;IAKI,UAAU,EAAE,IALhB;IAMI,GAAG,EAAEsB,aANT;IAOI,YAAY,EAAE,KAPlB;IAQI,8BAA8B,EAAE,KARpC;IASI,4BAA4B,EAAE,KATlC;IAUI,mBAAmB,EAAEb,mBAVzB;IAWI,yBAAyB,EAAEC;EAX/B,GAaKgD,WAbL,EAcKkB,SAdL,CADO,gBAkBP,4DACKlB,WADL,EAEKkB,SAFL,CA3BR,CADJ;AAmCH;;AAAA"}
1
+ {"version":3,"names":["useStyles","theme","useTheme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","forwardRef","props","ref","children","indicatorColor","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","useSyncAnimatedValue","initialValue","sharedIndex","realInitialIndex","currentIndexRef","useRef","setTab","newIndex","currentIndex","current","animatedValue","setValue","useImperativeHandle","styles","outerCoordinates","updateCoordinate","useTabCoordinates","innerContentsWidthList","updateInnerContentsWidth","useTabInnerContentsWidth","canRenderIndicator","isEveryTabCoordinatesDefined","indexStore","useIndexStore","coordinates","useMemo","map","innerContentWidth","idx","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","useEffect","subscribe","tabElements","React","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabElement","cloneElement","enableIndicator","undefined","filter","Boolean","tabIndicator","css"],"sources":["Tabs.tsx"],"sourcesContent":["import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { css, useTheme } from '../styles';\nimport { useSyncAnimatedValue } from '../hooks';\nimport type TabsProps from './TabsProps';\nimport type { TabsInstance } from './types';\nimport TabIndicator from './TabIndicator';\nimport ScrollableTabsView from './ScrollableTabsView';\nimport IndexAwareTab from './IndexAwareTab';\nimport useTabCoordinates from './useTabCoordinates';\nimport useTabInnerContentsWidth from './useTabInnerContentsWidth';\nimport useIndexStore from './useIndexStore';\nimport InternalContext from './InternalContext';\nimport { isEveryTabCoordinatesDefined } from './utils';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'scrollableContainer';\n\ntype TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;\n\nconst useStyles: UseStyles<TabsStyles> = function (): TabsStyles {\n const theme = useTheme();\n\n return {\n root: {},\n fixedRoot: {\n flexDirection: 'row',\n },\n fixedTab: {\n flex: 1,\n },\n scrollableContainer: {\n paddingHorizontal: theme.spacing(1),\n },\n };\n};\n\nconst Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {\n const {\n children,\n indicatorColor = 'primary',\n initialIndex = 0,\n disableIndicator = false,\n indicatorSize = 'full',\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollViewContentContainerStyle,\n style,\n variant = 'primary',\n UNSTABLE_sharedIndex,\n onTabSelected,\n } = props;\n\n const fallbackSharedIndex = useSyncAnimatedValue({ initialValue: initialIndex });\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n const realInitialIndex = sharedIndex.initialValue;\n\n const currentIndexRef = useRef(initialIndex);\n\n const setTab = (newIndex: number) => {\n const currentIndex = currentIndexRef.current;\n onTabSelected?.(newIndex, currentIndex);\n\n sharedIndex.animatedValue.setValue(newIndex);\n };\n\n useImperativeHandle(\n ref,\n () => ({\n setTab,\n }),\n [sharedIndex],\n );\n\n const styles = useStyles();\n\n const [outerCoordinates, updateCoordinate] = useTabCoordinates(children);\n const [innerContentsWidthList, updateInnerContentsWidth] = useTabInnerContentsWidth(children);\n\n const canRenderIndicator = indicatorSize === 'fit-content'\n ? isEveryTabCoordinatesDefined(innerContentsWidthList, children)\n : isEveryTabCoordinatesDefined(outerCoordinates, children);\n\n const indexStore = useIndexStore(sharedIndex);\n\n const coordinates = useMemo(() => {\n if (indicatorSize !== 'fit-content') {\n return outerCoordinates;\n }\n\n return innerContentsWidthList.map((innerContentWidth, idx) => {\n const { x1: outerX1, x2: outerX2 } = outerCoordinates[idx];\n\n const tabWidth = outerX2 - outerX1;\n const distanceFromParent = (tabWidth - innerContentWidth) / 2;\n const indicatorStartCoordinate = outerX1 + distanceFromParent;\n\n return {\n x1: indicatorStartCoordinate,\n x2: indicatorStartCoordinate + innerContentWidth,\n };\n });\n }, [outerCoordinates, innerContentsWidthList, variant]);\n\n useEffect(() => {\n return indexStore.subscribe(newIndex => {\n onChange?.(newIndex);\n currentIndexRef.current = newIndex;\n });\n }, [indexStore, onChange]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n if (!child) {\n return null;\n }\n\n const onTabInnerLayout = (event: LayoutChangeEvent) => {\n const { width } = event.nativeEvent.layout;\n\n updateInnerContentsWidth(index, width);\n };\n\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n updateCoordinate(index, x, width);\n\n // @ts-ignore\n child.props.onLayout?.(event);\n };\n\n const onMouseDown = (e: GestureResponderEvent) => {\n if (keyboardShouldPersistTaps === 'always') {\n e.preventDefault();\n }\n };\n\n const onPress = () => {\n setTab(index);\n\n // @ts-ignore\n child.props.onPress?.();\n };\n\n // @ts-ignore\n const tabElement = cloneElement(child, {\n enableIndicator: !disableIndicator && !canRenderIndicator,\n indicatorColor,\n onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n variant,\n indicatorSize,\n style: scrollable ? undefined : styles.fixedTab,\n });\n\n return (\n <IndexAwareTab\n children={tabElement}\n index={index}\n initialIndex={realInitialIndex}\n />\n );\n })?.filter(Boolean);\n\n const tabIndicator = canRenderIndicator ? (\n <TabIndicator\n color={indicatorColor}\n coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={realInitialIndex}\n scrollable={scrollable}\n />\n ) : null;\n\n return (\n <InternalContext.Provider value={{ indexStore }}>\n <View\n style={css([\n styles.root,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n >\n {scrollable ? (\n <ScrollableTabsView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={css([\n styles.scrollableContainer,\n scrollViewContentContainerStyle,\n ])}\n coordinates={coordinates}\n directionalLockEnabled={true}\n horizontal={true}\n initialIndex={realInitialIndex}\n scrollsToTop={false}\n showsHorizontalScrollIndicator={false}\n showsVerticalScrollIndicator={false}\n keyboardDismissMode={keyboardDismissMode}\n keyboardShouldPersistTaps={keyboardShouldPersistTaps}\n >\n {tabElements}\n {tabIndicator}\n </ScrollableTabsView>\n ) : (\n <React.Fragment>\n {tabElements}\n {tabIndicator}\n </React.Fragment>\n )}\n </View>\n </InternalContext.Provider>\n );\n});\n\nexport default Tabs;\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAUA,MAAMA,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE,EADH;IAEHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAFR;IAKHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CALP;IAQHC,mBAAmB,EAAE;MACjBC,iBAAiB,EAAER,KAAK,CAACS,OAAN,CAAc,CAAd;IADF;EARlB,CAAP;AAYH,CAfD;;AAiBA,MAAMC,IAAI,gBAAG,IAAAC,iBAAA,EAAoC,SAASD,IAAT,CAAcE,KAAd,EAAqBC,GAArB,EAA0B;EAAA;;EACvE,MAAM;IACFC,QADE;IAEFC,cAAc,GAAG,SAFf;IAGFC,YAAY,GAAG,CAHb;IAIFC,gBAAgB,GAAG,KAJjB;IAKFC,aAAa,GAAG,MALd;IAMFC,mBAAmB,GAAG,MANpB;IAOFC,yBAAyB,GAAG,OAP1B;IAQFC,QARE;IASFC,UAAU,GAAG,KATX;IAUFC,+BAVE;IAWFC,KAXE;IAYFC,OAAO,GAAG,SAZR;IAaFC,oBAbE;IAcFC;EAdE,IAeFf,KAfJ;EAiBA,MAAMgB,mBAAmB,GAAG,IAAAC,2BAAA,EAAqB;IAAEC,YAAY,EAAEd;EAAhB,CAArB,CAA5B;EACA,MAAMe,WAAW,GAAGL,oBAAoB,IAAIE,mBAA5C;EACA,MAAMI,gBAAgB,GAAGD,WAAW,C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I,gCAAgC,EAAE,KADtC;IAEI,OAAO,EAAE,KAFb;IAGI,qBAAqB,EAAE,IAAAoE,WAAA,EAAI,CACvBhD,MAAM,CAACnC,mBADgB,EAEvBgB,+BAFuB,CAAJ,CAH3B;IAOI,WAAW,EAAE8B,WAPjB;IAQI,sBAAsB,EAAE,IAR5B;IASI,UAAU,EAAE,IAThB;IAUI,YAAY,EAAErB,gBAVlB;IAWI,YAAY,EAAE,KAXlB;IAYI,8BAA8B,EAAE,KAZpC;IAaI,4BAA4B,EAAE,KAblC;IAcI,mBAAmB,EAAEb,mBAdzB;IAeI,yBAAyB,EAAEC;EAf/B,GAiBK+C,WAjBL,EAkBKsB,YAlBL,CADO,gBAsBP,6BAAC,cAAD,CAAO,QAAP,QACKtB,WADL,EAEKsB,YAFL,CA7BR,CADJ,CADJ;AAuCH,CApLY,CAAb;eAsLe/E,I"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TabsProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport type { TabVariant } from '../Tab';\nimport type { OverridableComponentProps } from '../types';\n\nexport type KeyboardDismissMode =\n 'none'\n | 'on-drag'\n | 'interactive'; // ios only\n\nexport type KeyboardShouldPersistTaps =\n 'never'\n | boolean\n | 'always'\n | 'handled'; // app only\n\nexport default interface TabsProps extends OverridableComponentProps<ViewProps, {\n /**\n * Collection of Tab components.\n */\n children: React.ReactNode;\n\n /**\n * Selected index.\n */\n index: number;\n\n /**\n * If `true`, the indicator is disabled.\n * @default false\n */\n disableIndicator?: boolean;\n\n /**\n * keyboard dismissing condition of dragging.\n * @default 'none'\n */\n keyboardDismissMode?: KeyboardDismissMode,\n\n /**\n * keyboard persisting condition of tapping.\n * @default 'never'\n */\n keyboardShouldPersistTaps?: KeyboardShouldPersistTaps,\n\n /**\n * Callback fired when a tab is selected.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * If `true`, the component will be able to scroll.\n * @default false\n */\n scrollable?: boolean;\n\n /**\n * Scrollable value for using animated interpolation.\n */\n scrollValue?: Animated.SharedValue<number>;\n\n /**\n * The variant to use.\n * @default 'primary'\n */\n variant?: TabVariant;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["TabsProps.ts"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { TabIndicatorColor } from './TabIndicatorProps';\nimport type { TabVariant, TabIndicatorSize } from '../Tab';\nimport type { OverridableComponentProps, SyncAnimatedValue } from '../types';\nimport type { KeyboardDismissMode, KeyboardShouldPersistTaps, TabsInstance } from './types';\nimport type { ExtendedStyle } from '../types';\n\nexport default interface TabsProps extends OverridableComponentProps<ViewProps, {\n ref?: Ref<TabsInstance>;\n\n /**\n * Collection of Tab components.\n */\n children: ReactNode;\n\n /**\n * If `true`, the indicator is disabled.\n * @default false\n */\n disableIndicator?: boolean;\n\n /**\n * The color of tab indicator\n * @default 'primary'\n */\n indicatorColor?: TabIndicatorColor;\n\n /**\n * The size of tab indicator.\n * 'full' adjusts the indicator to the size of the Tab,\n * while 'fit-content' adjusts the indicator to the size of the content inside the Tab.\n * @default 'full'\n */\n indicatorSize?: TabIndicatorSize;\n\n /**\n * Index of initial tab that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * keyboard dismissing condition of dragging.\n * @default 'none'\n */\n keyboardDismissMode?: KeyboardDismissMode,\n\n /**\n * keyboard persisting condition of tapping.\n * @default 'never'\n */\n keyboardShouldPersistTaps?: KeyboardShouldPersistTaps,\n\n /**\n * Callback fired when a tab is selected.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * If `true`, the component will be able to scroll.\n * @default false\n */\n scrollable?: boolean;\n\n /**\n * These styles will be applied to the scroll view content container which wraps all of the child views.\n */\n scrollViewContentContainerStyle?: ExtendedStyle | ExtendedStyle[];\n\n /**\n * Unstable API.\n */\n UNSTABLE_sharedIndex?: SyncAnimatedValue;\n\n /**\n * The variant to use.\n * @default 'primary'\n */\n variant?: TabVariant;\n\n /**\n * Callback function executed when a Tab is selected.\n * Executed even if the index does not change when a Tab is pressed.\n * Receives the next tab index and the current tab index as parameters.\n */\n onTabSelected?: (newIndex: number, currentIndex: number) => void;\n}> {}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './Tabs';\nexport type { default as TabsProps } from './TabsProps';"],"mappings":";;;;;;;;;;;;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './Tabs';\nexport type { default as TabsProps } from './TabsProps';\nexport type { TabsInstance } from './types';\n"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type KeyboardDismissMode =\n 'none'\n | 'on-drag'\n | 'interactive'; // ios only\n\nexport type KeyboardShouldPersistTaps =\n 'never'\n | boolean\n | 'always'\n | 'handled'; // app only\n\nexport interface TabsInstance {\n /**\n * Function to scroll to a specific tab. Invalid index is ignored.\n * @param index\n */\n setTab: (index: number) => void;\n}\n"],"mappings":""}