@fountain-ui/core 3.0.0-alpha.41 → 3.0.0-alpha.42

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 (82) hide show
  1. package/build/commonjs/Tabs/Tabs.js +9 -4
  2. package/build/commonjs/Tabs/Tabs.js.map +1 -1
  3. package/build/module/Tabs/Tabs.js +10 -5
  4. package/build/module/Tabs/Tabs.js.map +1 -1
  5. package/build/typescript/Accordion/Accordion.d.ts +0 -1
  6. package/build/typescript/AspectRatio/AspectRatioNative.d.ts +0 -1
  7. package/build/typescript/AspectRatio/AspectRatioWeb.d.ts +0 -1
  8. package/build/typescript/Avatar/Avatar.d.ts +0 -1
  9. package/build/typescript/Badge/Badge.d.ts +0 -1
  10. package/build/typescript/BottomSheetActions/BottomSheetActions.d.ts +0 -1
  11. package/build/typescript/BottomSheetContent/BottomSheetContent.d.ts +0 -1
  12. package/build/typescript/BottomSheetTitle/BottomSheetTitle.d.ts +0 -1
  13. package/build/typescript/Button/Button.d.ts +0 -1
  14. package/build/typescript/ButtonBase/ButtonBase.d.ts +0 -1
  15. package/build/typescript/ButtonSet/ButtonSet.d.ts +0 -1
  16. package/build/typescript/Card/Card.d.ts +0 -1
  17. package/build/typescript/CardActions/CardActions.d.ts +0 -1
  18. package/build/typescript/CardContent/CardContent.d.ts +0 -1
  19. package/build/typescript/CardMedia/CardMedia.d.ts +0 -1
  20. package/build/typescript/Checkbox/Checkbox.d.ts +0 -1
  21. package/build/typescript/Chip/Chip.d.ts +0 -1
  22. package/build/typescript/CircularProgress/CircularProgress.d.ts +0 -1
  23. package/build/typescript/Column/Column.d.ts +0 -1
  24. package/build/typescript/Dialog/Dialog.d.ts +0 -1
  25. package/build/typescript/DialogActions/DialogActions.d.ts +0 -1
  26. package/build/typescript/DialogContent/DialogContent.d.ts +0 -1
  27. package/build/typescript/DialogMedia/DialogMedia.d.ts +0 -1
  28. package/build/typescript/DialogTitle/DialogLargeTitle.d.ts +0 -1
  29. package/build/typescript/DialogTitle/DialogTitle.d.ts +0 -1
  30. package/build/typescript/Divider/Divider.d.ts +0 -1
  31. package/build/typescript/Empty/Empty.d.ts +0 -1
  32. package/build/typescript/Fab/Fab.d.ts +0 -1
  33. package/build/typescript/Flexbox/Flexbox.d.ts +0 -1
  34. package/build/typescript/IconButton/IconButton.d.ts +0 -1
  35. package/build/typescript/Image/Image.d.ts +0 -1
  36. package/build/typescript/ImageCore/ImageCoreNative.d.ts +0 -1
  37. package/build/typescript/ImageCore/ImageCoreWeb.d.ts +0 -1
  38. package/build/typescript/Link/Link.d.ts +0 -1
  39. package/build/typescript/List/List.d.ts +0 -1
  40. package/build/typescript/ListItem/ListItem.d.ts +0 -1
  41. package/build/typescript/ListItemIcon/ListItemIcon.d.ts +0 -1
  42. package/build/typescript/ListItemSecondaryAction/ListItemSecondaryAction.d.ts +0 -1
  43. package/build/typescript/ListItemText/ListItemText.d.ts +0 -1
  44. package/build/typescript/ListSubheader/ListSubheader.d.ts +0 -1
  45. package/build/typescript/Menu/Menu.d.ts +0 -1
  46. package/build/typescript/MenuItem/MenuItem.d.ts +0 -1
  47. package/build/typescript/Modal/AnimatedContainer/index.d.ts +0 -1
  48. package/build/typescript/Modal/Modal.d.ts +0 -1
  49. package/build/typescript/Pagination/NumberPagination.d.ts +0 -1
  50. package/build/typescript/Pagination/Pagination.d.ts +0 -1
  51. package/build/typescript/Portal/Portal.d.ts +0 -1
  52. package/build/typescript/Radio/Radio.d.ts +0 -1
  53. package/build/typescript/RadioGroup/RadioGroup.d.ts +0 -1
  54. package/build/typescript/Row/Row.d.ts +0 -1
  55. package/build/typescript/Section/Section.d.ts +0 -1
  56. package/build/typescript/ShadowView/ShadowView.d.ts +0 -1
  57. package/build/typescript/ShadowView/ShadowView.native.d.ts +0 -1
  58. package/build/typescript/Slide/Slide.d.ts +0 -1
  59. package/build/typescript/Snackbar/Snackbar.d.ts +0 -1
  60. package/build/typescript/SnackbarContent/SnackbarContent.d.ts +0 -1
  61. package/build/typescript/SnackbarContent/StatusIcon.d.ts +0 -1
  62. package/build/typescript/Spacer/Spacer.d.ts +0 -1
  63. package/build/typescript/SvgIcon/SvgIcon.d.ts +0 -1
  64. package/build/typescript/Switch/Switch.d.ts +0 -1
  65. package/build/typescript/Tab/Tab.d.ts +0 -1
  66. package/build/typescript/TabBase/TabBase.d.ts +0 -1
  67. package/build/typescript/Tabs/ScrollableTabsView.d.ts +0 -1
  68. package/build/typescript/Tabs/TabIndicator.d.ts +0 -1
  69. package/build/typescript/Toggle/Toggle.d.ts +0 -1
  70. package/build/typescript/Toolbar/BackButton/BackButton.d.ts +0 -1
  71. package/build/typescript/Toolbar/Toolbar.d.ts +0 -1
  72. package/build/typescript/Tooltip/Beaks/Beak.d.ts +0 -1
  73. package/build/typescript/Tooltip/Beaks/HorizontalLargeBeak.d.ts +0 -1
  74. package/build/typescript/Tooltip/Beaks/HorizontalSmallBeak.d.ts +0 -1
  75. package/build/typescript/Tooltip/Beaks/VerticalLargeBeak.d.ts +0 -1
  76. package/build/typescript/Tooltip/Beaks/VerticalSmallBeak.d.ts +0 -1
  77. package/build/typescript/Tooltip/Tooltip.d.ts +0 -1
  78. package/build/typescript/internal/icons/CircularProgress.d.ts +0 -1
  79. package/build/typescript/internal/icons/LoadingSpinner/index.d.ts +0 -1
  80. package/build/typescript/internal/icons/LoadingSpinner/index.native.d.ts +0 -1
  81. package/package.json +2 -2
  82. package/src/Tabs/Tabs.tsx +14 -5
@@ -42,14 +42,16 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
42
42
  const useStyles = function () {
43
43
  const theme = (0, _styles.useTheme)();
44
44
  return {
45
- root: {},
45
+ root: {
46
+ position: 'relative'
47
+ },
46
48
  fixedRoot: {
47
49
  flexDirection: 'row'
48
50
  },
49
51
  fixedTab: {
50
52
  flex: 1
51
53
  },
52
- bottomDivider: {
54
+ borderContainer: { ..._reactNative.StyleSheet.absoluteFillObject,
53
55
  borderBottomColor: theme.palette.border.base,
54
56
  borderBottomWidth: 0.5
55
57
  }
@@ -213,7 +215,7 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(function Tabs(props, ref) {
213
215
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
214
216
  style: (0, _styles.css)([styles.root, containerStyle, {
215
217
  backgroundColor: backgroundColorMap[color]
216
- }, showDivider ? styles.bottomDivider : undefined, scrollable ? undefined : styles.fixedRoot, style])
218
+ }, scrollable ? undefined : styles.fixedRoot, style])
217
219
  }, scrollable ? /*#__PURE__*/_react.default.createElement(_ScrollableTabsView.default, {
218
220
  automaticallyAdjustContentInsets: false,
219
221
  bounces: false,
@@ -227,7 +229,10 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(function Tabs(props, ref) {
227
229
  showsVerticalScrollIndicator: false,
228
230
  keyboardDismissMode: keyboardDismissMode,
229
231
  keyboardShouldPersistTaps: keyboardShouldPersistTaps
230
- }, tabElements, tabIndicator) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tabElements, tabIndicator)));
232
+ }, tabElements, tabIndicator) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tabElements, tabIndicator), showDivider ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
233
+ pointerEvents: 'none',
234
+ style: styles.borderContainer
235
+ }) : null));
231
236
  });
232
237
  var _default = Tabs;
233
238
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["useStyles","theme","useTheme","root","fixedRoot","flexDirection","fixedTab","flex","bottomDivider","borderBottomColor","palette","border","base","borderBottomWidth","Tabs","forwardRef","props","ref","children","color","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","showDivider","size","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","useSyncAnimatedValue","initialValue","sharedIndex","realInitialIndex","currentIndexRef","useRef","container","containerStyle","contentContainer","contentContainerStyle","useTabsStyle","setTab","newIndex","currentIndex","current","animatedValue","setValue","useImperativeHandle","styles","outerCoordinates","updateCoordinate","useTabCoordinates","innerContentsWidthList","updateInnerContentsWidth","useTabInnerContentsWidth","canRenderIndicator","isEveryTabCoordinatesDefined","indexStore","useIndexStore","coordinates","useMemo","length","map","innerContentWidth","idx","outerCoordinate","defaultCoordinate","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","tabStyle","tabElement","cloneElement","enableIndicator","parentColor","css","undefined","filter","Boolean","tabIndicator","backgroundColorMap","default","background","alt","backgroundColor"],"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 { TabSize, TabVariant } from '../Tab';\nimport type TabsProps from './TabsProps';\nimport type { TabsColor } 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';\nimport { defaultCoordinate } from './TabCoordinate';\nimport useTabsStyle from './useTabsStyle';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'bottomDivider';\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 bottomDivider: {\n borderBottomColor: theme.palette.border.base,\n borderBottomWidth: 0.5,\n },\n };\n};\n\nconst Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {\n const {\n children,\n color = 'default',\n initialIndex = 0,\n disableIndicator = false,\n indicatorSize = 'fit-content',\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollViewContentContainerStyle,\n showDivider = false,\n size = 'medium' as TabSize,\n style,\n variant = 'default' as TabVariant,\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 {\n container: containerStyle,\n contentContainer: contentContainerStyle,\n } = useTabsStyle(variant, size, scrollable);\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 theme = useTheme();\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 (outerCoordinates.length === 0) {\n return [];\n }\n\n if (indicatorSize !== 'fit-content') {\n return outerCoordinates;\n }\n\n return innerContentsWidthList.map((innerContentWidth, idx) => {\n const outerCoordinate = outerCoordinates[idx];\n if (!outerCoordinate) {\n return defaultCoordinate;\n }\n\n const { x1: outerX1, x2: outerX2 } = outerCoordinate;\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]);\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 tabStyle = child.props.style;\n\n // @ts-ignore\n const tabElement = cloneElement(child, {\n enableIndicator: !disableIndicator && !canRenderIndicator,\n onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n parentColor: color,\n size,\n variant,\n indicatorSize,\n style: css([\n scrollable ? undefined : styles.fixedTab,\n tabStyle,\n ]),\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 coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={realInitialIndex}\n />\n ) : null;\n\n const backgroundColorMap: Record<TabsColor, string> = {\n default: theme.palette.background.base,\n alt: theme.palette.background.alt,\n };\n\n return (\n <InternalContext.Provider value={{ indexStore }}>\n <View\n style={css([\n styles.root,\n containerStyle,\n { backgroundColor: backgroundColorMap[color] },\n showDivider ? styles.bottomDivider : undefined,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n >\n {scrollable ? (\n <ScrollableTabsView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={css([\n contentContainerStyle,\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;;AAKA;;AACA;;AACA;;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,aAAa,EAAE;MACXC,iBAAiB,EAAER,KAAK,CAACS,OAAN,CAAcC,MAAd,CAAqBC,IAD7B;MAEXC,iBAAiB,EAAE;IAFR;EARZ,CAAP;AAaH,CAhBD;;AAkBA,MAAMC,IAAI,gBAAG,IAAAC,iBAAA,EAAoC,SAASD,IAAT,CAAcE,KAAd,EAAqBC,GAArB,EAA0B;EAAA;;EACvE,MAAM;IACFC,QADE;IAEFC,KAAK,GAAG,SAFN;IAGFC,YAAY,GAAG,CAHb;IAIFC,gBAAgB,GAAG,KAJjB;IAK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tC;IAEI,OAAO,EAAE,KAFb;IAGI,qBAAqB,EAAE,IAAA4E,WAAA,EAAI,CACvB1D,qBADuB,EAEvBjB,+BAFuB,CAAJ,CAH3B;IAOI,WAAW,EAAEqC,WAPjB;IAQI,sBAAsB,EAAE,IAR5B;IASI,UAAU,EAAE,IAThB;IAUI,YAAY,EAAE1B,gBAVlB;IAWI,YAAY,EAAE,KAXlB;IAYI,8BAA8B,EAAE,KAZpC;IAaI,4BAA4B,EAAE,KAblC;IAcI,mBAAmB,EAAEf,mBAdzB;IAeI,yBAAyB,EAAEC;EAf/B,GAiBKyD,WAjBL,EAkBKyB,YAlBL,CADO,gBAsBP,6BAAC,cAAD,CAAO,QAAP,QACKzB,WADL,EAEKyB,YAFL,CAhCR,CADJ,CADJ;AA0CH,CAnNY,CAAb;eAqNe5F,I"}
1
+ {"version":3,"names":["useStyles","theme","useTheme","root","position","fixedRoot","flexDirection","fixedTab","flex","borderContainer","StyleSheet","absoluteFillObject","borderBottomColor","palette","border","base","borderBottomWidth","Tabs","forwardRef","props","ref","children","color","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","showDivider","size","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","useSyncAnimatedValue","initialValue","sharedIndex","realInitialIndex","currentIndexRef","useRef","container","containerStyle","contentContainer","contentContainerStyle","useTabsStyle","setTab","newIndex","currentIndex","current","animatedValue","setValue","useImperativeHandle","styles","outerCoordinates","updateCoordinate","useTabCoordinates","innerContentsWidthList","updateInnerContentsWidth","useTabInnerContentsWidth","canRenderIndicator","isEveryTabCoordinatesDefined","indexStore","useIndexStore","coordinates","useMemo","length","map","innerContentWidth","idx","outerCoordinate","defaultCoordinate","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","tabStyle","tabElement","cloneElement","enableIndicator","parentColor","css","undefined","filter","Boolean","tabIndicator","backgroundColorMap","default","background","alt","backgroundColor"],"sources":["Tabs.tsx"],"sourcesContent":["import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { css, useTheme } from '../styles';\nimport { useSyncAnimatedValue } from '../hooks';\nimport type { TabSize, TabVariant } from '../Tab';\nimport type TabsProps from './TabsProps';\nimport type { TabsColor } 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';\nimport { defaultCoordinate } from './TabCoordinate';\nimport useTabsStyle from './useTabsStyle';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'borderContainer';\n\ntype TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;\n\nconst useStyles: UseStyles<TabsStyles> = function (): TabsStyles {\n const theme = useTheme();\n\n return {\n root: {\n position: 'relative',\n },\n fixedRoot: {\n flexDirection: 'row',\n },\n fixedTab: {\n flex: 1,\n },\n borderContainer: {\n ...StyleSheet.absoluteFillObject,\n borderBottomColor: theme.palette.border.base,\n borderBottomWidth: 0.5,\n },\n };\n};\n\nconst Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {\n const {\n children,\n color = 'default',\n initialIndex = 0,\n disableIndicator = false,\n indicatorSize = 'fit-content',\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollViewContentContainerStyle,\n showDivider = false,\n size = 'medium' as TabSize,\n style,\n variant = 'default' as TabVariant,\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 {\n container: containerStyle,\n contentContainer: contentContainerStyle,\n } = useTabsStyle(variant, size, scrollable);\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 theme = useTheme();\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 (outerCoordinates.length === 0) {\n return [];\n }\n\n if (indicatorSize !== 'fit-content') {\n return outerCoordinates;\n }\n\n return innerContentsWidthList.map((innerContentWidth, idx) => {\n const outerCoordinate = outerCoordinates[idx];\n if (!outerCoordinate) {\n return defaultCoordinate;\n }\n\n const { x1: outerX1, x2: outerX2 } = outerCoordinate;\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]);\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 tabStyle = child.props.style;\n\n // @ts-ignore\n const tabElement = cloneElement(child, {\n enableIndicator: !disableIndicator && !canRenderIndicator,\n onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n parentColor: color,\n size,\n variant,\n indicatorSize,\n style: css([\n scrollable ? undefined : styles.fixedTab,\n tabStyle,\n ]),\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 coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={realInitialIndex}\n />\n ) : null;\n\n const backgroundColorMap: Record<TabsColor, string> = {\n default: theme.palette.background.base,\n alt: theme.palette.background.alt,\n };\n\n return (\n <InternalContext.Provider value={{ indexStore }}>\n <View\n style={css([\n styles.root,\n containerStyle,\n { backgroundColor: backgroundColorMap[color] },\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n >\n {scrollable ? (\n <ScrollableTabsView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={css([\n contentContainerStyle,\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\n {showDivider ? (\n <View\n pointerEvents={'none'}\n style={styles.borderContainer}\n />\n ) : null}\n </View>\n </InternalContext.Provider>\n );\n});\n\nexport default Tabs;\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAUA,MAAMA,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,QAAQ,EAAE;IADR,CADH;IAIHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAJR;IAOHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CAPP;IAUHC,eAAe,EAAE,EACb,GAAGC,uBAAA,CAAWC,kBADD;MAEbC,iBAAiB,EAAEX,KAAK,CAACY,OAAN,CAAcC,MAAd,CAAqBC,IAF3B;MAGbC,iBAAiB,EAAE;IAHN;EAVd,CAAP;AAgBH,CAnBD;;AAqBA,MAAMC,IAAI,gBAAG,IAAAC,iBAAA,EAAoC,SAASD,IAAT,CAAcE,KAAd,EAAqBC,GAArB,EAA0B;EAAA;;EACvE,MAAM;IACFC,QADE;IAEFC,KAAK,GAAG,SAFN;IAGFC,YAAY,GAAG,CAHb;IAIFC,gBAAgB,GAAG,KAJjB;IAKFC,aAAa,GAAG,aALd;IAMFC,mBAAmB,GAAG,MANpB;IAOFC,yBAAyB,GAAG,OAP1B;IAQFC,QARE;IASFC,UAAU,GAAG,KATX;IAUFC,+BAVE;IAWFC,WAAW,GAAG,KAXZ;IAYFC,IAAI,GAAG,QAZL;IAaFC,KAbE;IAcFC,OAA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AAE,KAZpC;IAaI,4BAA4B,EAAE,KAblC;IAcI,mBAAmB,EAAEf,mBAdzB;IAeI,yBAAyB,EAAEC;EAf/B,GAiBKyD,WAjBL,EAkBKyB,YAlBL,CADO,gBAsBP,6BAAC,cAAD,CAAO,QAAP,QACKzB,WADL,EAEKyB,YAFL,CA/BR,EAqCK9E,WAAW,gBACR,6BAAC,iBAAD;IACI,aAAa,EAAE,MADnB;IAEI,KAAK,EAAEyB,MAAM,CAAC/C;EAFlB,EADQ,GAKR,IA1CR,CADJ,CADJ;AAgDH,CAzNY,CAAb;eA2NeQ,I"}
@@ -1,5 +1,5 @@
1
1
  import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
2
- import { View } from 'react-native';
2
+ import { StyleSheet, View } from 'react-native';
3
3
  import { css, useTheme } from '../styles';
4
4
  import { useSyncAnimatedValue } from '../hooks';
5
5
  import TabIndicator from './TabIndicator';
@@ -16,14 +16,16 @@ import useTabsStyle from './useTabsStyle';
16
16
  const useStyles = function () {
17
17
  const theme = useTheme();
18
18
  return {
19
- root: {},
19
+ root: {
20
+ position: 'relative'
21
+ },
20
22
  fixedRoot: {
21
23
  flexDirection: 'row'
22
24
  },
23
25
  fixedTab: {
24
26
  flex: 1
25
27
  },
26
- bottomDivider: {
28
+ borderContainer: { ...StyleSheet.absoluteFillObject,
27
29
  borderBottomColor: theme.palette.border.base,
28
30
  borderBottomWidth: 0.5
29
31
  }
@@ -187,7 +189,7 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
187
189
  }, /*#__PURE__*/React.createElement(View, {
188
190
  style: css([styles.root, containerStyle, {
189
191
  backgroundColor: backgroundColorMap[color]
190
- }, showDivider ? styles.bottomDivider : undefined, scrollable ? undefined : styles.fixedRoot, style])
192
+ }, scrollable ? undefined : styles.fixedRoot, style])
191
193
  }, scrollable ? /*#__PURE__*/React.createElement(ScrollableTabsView, {
192
194
  automaticallyAdjustContentInsets: false,
193
195
  bounces: false,
@@ -201,7 +203,10 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
201
203
  showsVerticalScrollIndicator: false,
202
204
  keyboardDismissMode: keyboardDismissMode,
203
205
  keyboardShouldPersistTaps: keyboardShouldPersistTaps
204
- }, tabElements, tabIndicator) : /*#__PURE__*/React.createElement(React.Fragment, null, tabElements, tabIndicator)));
206
+ }, tabElements, tabIndicator) : /*#__PURE__*/React.createElement(React.Fragment, null, tabElements, tabIndicator), showDivider ? /*#__PURE__*/React.createElement(View, {
207
+ pointerEvents: 'none',
208
+ style: styles.borderContainer
209
+ }) : null));
205
210
  });
206
211
  export default Tabs;
207
212
  //# sourceMappingURL=Tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","cloneElement","forwardRef","useEffect","useImperativeHandle","useMemo","useRef","View","css","useTheme","useSyncAnimatedValue","TabIndicator","ScrollableTabsView","IndexAwareTab","useTabCoordinates","useTabInnerContentsWidth","useIndexStore","InternalContext","isEveryTabCoordinatesDefined","defaultCoordinate","useTabsStyle","useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","bottomDivider","borderBottomColor","palette","border","base","borderBottomWidth","Tabs","props","ref","children","color","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","showDivider","size","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","initialValue","sharedIndex","realInitialIndex","currentIndexRef","container","containerStyle","contentContainer","contentContainerStyle","setTab","newIndex","currentIndex","current","animatedValue","setValue","styles","outerCoordinates","updateCoordinate","innerContentsWidthList","updateInnerContentsWidth","canRenderIndicator","indexStore","coordinates","length","map","innerContentWidth","idx","outerCoordinate","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","subscribe","tabElements","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabStyle","tabElement","enableIndicator","parentColor","undefined","filter","Boolean","tabIndicator","backgroundColorMap","default","background","alt","backgroundColor"],"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 { TabSize, TabVariant } from '../Tab';\nimport type TabsProps from './TabsProps';\nimport type { TabsColor } 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';\nimport { defaultCoordinate } from './TabCoordinate';\nimport useTabsStyle from './useTabsStyle';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'bottomDivider';\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 bottomDivider: {\n borderBottomColor: theme.palette.border.base,\n borderBottomWidth: 0.5,\n },\n };\n};\n\nconst Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {\n const {\n children,\n color = 'default',\n initialIndex = 0,\n disableIndicator = false,\n indicatorSize = 'fit-content',\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollViewContentContainerStyle,\n showDivider = false,\n size = 'medium' as TabSize,\n style,\n variant = 'default' as TabVariant,\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 {\n container: containerStyle,\n contentContainer: contentContainerStyle,\n } = useTabsStyle(variant, size, scrollable);\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 theme = useTheme();\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 (outerCoordinates.length === 0) {\n return [];\n }\n\n if (indicatorSize !== 'fit-content') {\n return outerCoordinates;\n }\n\n return innerContentsWidthList.map((innerContentWidth, idx) => {\n const outerCoordinate = outerCoordinates[idx];\n if (!outerCoordinate) {\n return defaultCoordinate;\n }\n\n const { x1: outerX1, x2: outerX2 } = outerCoordinate;\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]);\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 tabStyle = child.props.style;\n\n // @ts-ignore\n const tabElement = cloneElement(child, {\n enableIndicator: !disableIndicator && !canRenderIndicator,\n onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n parentColor: color,\n size,\n variant,\n indicatorSize,\n style: css([\n scrollable ? undefined : styles.fixedTab,\n tabStyle,\n ]),\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 coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={realInitialIndex}\n />\n ) : null;\n\n const backgroundColorMap: Record<TabsColor, string> = {\n default: theme.palette.background.base,\n alt: theme.palette.background.alt,\n };\n\n return (\n <InternalContext.Provider value={{ indexStore }}>\n <View\n style={css([\n styles.root,\n containerStyle,\n { backgroundColor: backgroundColorMap[color] },\n showDivider ? styles.bottomDivider : undefined,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n >\n {scrollable ? (\n <ScrollableTabsView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={css([\n contentContainerStyle,\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,OAAOA,KAAP,IAAgBC,YAAhB,EAA8BC,UAA9B,EAA0CC,SAA1C,EAAqDC,mBAArD,EAA0EC,OAA1E,EAAmFC,MAAnF,QAAiG,OAAjG;AAEA,SAASC,IAAT,QAAqB,cAArB;AAEA,SAASC,GAAT,EAAcC,QAAd,QAA8B,WAA9B;AACA,SAASC,oBAAT,QAAqC,UAArC;AAKA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,wBAAP,MAAqC,4BAArC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,SAASC,4BAAT,QAA6C,SAA7C;AACA,SAASC,iBAAT,QAAkC,iBAAlC;AACA,OAAOC,YAAP,MAAyB,gBAAzB;;AAUA,MAAMC,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAGb,QAAQ,EAAtB;EAEA,OAAO;IACHc,IAAI,EAAE,EADH;IAEHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAFR;IAKHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CALP;IAQHC,aAAa,EAAE;MACXC,iBAAiB,EAAEP,KAAK,CAACQ,OAAN,CAAcC,MAAd,CAAqBC,IAD7B;MAEXC,iBAAiB,EAAE;IAFR;EARZ,CAAP;AAaH,CAhBD;;AAkBA,MAAMC,IAAI,gBAAGhC,UAAU,CAA0B,SAASgC,IAAT,CAAcC,KAAd,EAAqBC,GAArB,EAA0B;EAAA;;EACvE,MAAM;IACFC,QADE;IAEFC,KA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EI,OAAO,EAAE,KAFb;IAGI,qBAAqB,EAAErC,GAAG,CAAC,CACvBqD,qBADuB,EAEvBf,+BAFuB,CAAD,CAH9B;IAOI,WAAW,EAAE6B,WAPjB;IAQI,sBAAsB,EAAE,IAR5B;IASI,UAAU,EAAE,IAThB;IAUI,YAAY,EAAEnB,gBAVlB;IAWI,YAAY,EAAE,KAXlB;IAYI,8BAA8B,EAAE,KAZpC;IAaI,4BAA4B,EAAE,KAblC;IAcI,mBAAmB,EAAEd,mBAdzB;IAeI,yBAAyB,EAAEC;EAf/B,GAiBK8C,WAjBL,EAkBKsB,YAlBL,CADO,gBAsBP,oBAAC,KAAD,CAAO,QAAP,QACKtB,WADL,EAEKsB,YAFL,CAhCR,CADJ,CADJ;AA0CH,CAnNsB,CAAvB;AAqNA,eAAe7E,IAAf"}
1
+ {"version":3,"names":["React","cloneElement","forwardRef","useEffect","useImperativeHandle","useMemo","useRef","StyleSheet","View","css","useTheme","useSyncAnimatedValue","TabIndicator","ScrollableTabsView","IndexAwareTab","useTabCoordinates","useTabInnerContentsWidth","useIndexStore","InternalContext","isEveryTabCoordinatesDefined","defaultCoordinate","useTabsStyle","useStyles","theme","root","position","fixedRoot","flexDirection","fixedTab","flex","borderContainer","absoluteFillObject","borderBottomColor","palette","border","base","borderBottomWidth","Tabs","props","ref","children","color","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","showDivider","size","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","initialValue","sharedIndex","realInitialIndex","currentIndexRef","container","containerStyle","contentContainer","contentContainerStyle","setTab","newIndex","currentIndex","current","animatedValue","setValue","styles","outerCoordinates","updateCoordinate","innerContentsWidthList","updateInnerContentsWidth","canRenderIndicator","indexStore","coordinates","length","map","innerContentWidth","idx","outerCoordinate","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","subscribe","tabElements","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabStyle","tabElement","enableIndicator","parentColor","undefined","filter","Boolean","tabIndicator","backgroundColorMap","default","background","alt","backgroundColor"],"sources":["Tabs.tsx"],"sourcesContent":["import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { css, useTheme } from '../styles';\nimport { useSyncAnimatedValue } from '../hooks';\nimport type { TabSize, TabVariant } from '../Tab';\nimport type TabsProps from './TabsProps';\nimport type { TabsColor } 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';\nimport { defaultCoordinate } from './TabCoordinate';\nimport useTabsStyle from './useTabsStyle';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'borderContainer';\n\ntype TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;\n\nconst useStyles: UseStyles<TabsStyles> = function (): TabsStyles {\n const theme = useTheme();\n\n return {\n root: {\n position: 'relative',\n },\n fixedRoot: {\n flexDirection: 'row',\n },\n fixedTab: {\n flex: 1,\n },\n borderContainer: {\n ...StyleSheet.absoluteFillObject,\n borderBottomColor: theme.palette.border.base,\n borderBottomWidth: 0.5,\n },\n };\n};\n\nconst Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {\n const {\n children,\n color = 'default',\n initialIndex = 0,\n disableIndicator = false,\n indicatorSize = 'fit-content',\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollViewContentContainerStyle,\n showDivider = false,\n size = 'medium' as TabSize,\n style,\n variant = 'default' as TabVariant,\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 {\n container: containerStyle,\n contentContainer: contentContainerStyle,\n } = useTabsStyle(variant, size, scrollable);\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 theme = useTheme();\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 (outerCoordinates.length === 0) {\n return [];\n }\n\n if (indicatorSize !== 'fit-content') {\n return outerCoordinates;\n }\n\n return innerContentsWidthList.map((innerContentWidth, idx) => {\n const outerCoordinate = outerCoordinates[idx];\n if (!outerCoordinate) {\n return defaultCoordinate;\n }\n\n const { x1: outerX1, x2: outerX2 } = outerCoordinate;\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]);\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 tabStyle = child.props.style;\n\n // @ts-ignore\n const tabElement = cloneElement(child, {\n enableIndicator: !disableIndicator && !canRenderIndicator,\n onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n parentColor: color,\n size,\n variant,\n indicatorSize,\n style: css([\n scrollable ? undefined : styles.fixedTab,\n tabStyle,\n ]),\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 coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={realInitialIndex}\n />\n ) : null;\n\n const backgroundColorMap: Record<TabsColor, string> = {\n default: theme.palette.background.base,\n alt: theme.palette.background.alt,\n };\n\n return (\n <InternalContext.Provider value={{ indexStore }}>\n <View\n style={css([\n styles.root,\n containerStyle,\n { backgroundColor: backgroundColorMap[color] },\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n >\n {scrollable ? (\n <ScrollableTabsView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={css([\n contentContainerStyle,\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\n {showDivider ? (\n <View\n pointerEvents={'none'}\n style={styles.borderContainer}\n />\n ) : null}\n </View>\n </InternalContext.Provider>\n );\n});\n\nexport default Tabs;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,YAAhB,EAA8BC,UAA9B,EAA0CC,SAA1C,EAAqDC,mBAArD,EAA0EC,OAA1E,EAAmFC,MAAnF,QAAiG,OAAjG;AAEA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAEA,SAASC,GAAT,EAAcC,QAAd,QAA8B,WAA9B;AACA,SAASC,oBAAT,QAAqC,UAArC;AAKA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,wBAAP,MAAqC,4BAArC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,SAASC,4BAAT,QAA6C,SAA7C;AACA,SAASC,iBAAT,QAAkC,iBAAlC;AACA,OAAOC,YAAP,MAAyB,gBAAzB;;AAUA,MAAMC,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAGb,QAAQ,EAAtB;EAEA,OAAO;IACHc,IAAI,EAAE;MACFC,QAAQ,EAAE;IADR,CADH;IAIHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAJR;IAOHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CAPP;IAUHC,eAAe,EAAE,EACb,GAAGvB,UAAU,CAACwB,kBADD;MAEbC,iBAAiB,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kBAAkB,CAAC1E,KAAD;IAArC,CAHO,EAIPO,UAAU,GAAG+D,SAAH,GAAexC,MAAM,CAAC7C,SAJzB,EAKP0B,KALO,CAAD;EADd,GASKJ,UAAU,gBACP,oBAAC,kBAAD;IACI,gCAAgC,EAAE,KADtC;IAEI,OAAO,EAAE,KAFb;IAGI,qBAAqB,EAAEvC,GAAG,CAAC,CACvBuD,qBADuB,EAEvBf,+BAFuB,CAAD,CAH9B;IAOI,WAAW,EAAE6B,WAPjB;IAQI,sBAAsB,EAAE,IAR5B;IASI,UAAU,EAAE,IAThB;IAUI,YAAY,EAAEnB,gBAVlB;IAWI,YAAY,EAAE,KAXlB;IAYI,8BAA8B,EAAE,KAZpC;IAaI,4BAA4B,EAAE,KAblC;IAcI,mBAAmB,EAAEd,mBAdzB;IAeI,yBAAyB,EAAEC;EAf/B,GAiBK8C,WAjBL,EAkBKsB,YAlBL,CADO,gBAsBP,oBAAC,KAAD,CAAO,QAAP,QACKtB,WADL,EAEKsB,YAFL,CA/BR,EAqCKhE,WAAW,gBACR,oBAAC,IAAD;IACI,aAAa,EAAE,MADnB;IAEI,KAAK,EAAEqB,MAAM,CAACzC;EAFlB,EADQ,GAKR,IA1CR,CADJ,CADJ;AAgDH,CAzNsB,CAAvB;AA2NA,eAAeO,IAAf"}
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type AccordionProps from './AccordionProps';
3
2
  export default function Accordion(props: AccordionProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type AspectRatioProps from './AspectRatioProps';
3
2
  export default function AspectRatio(props: AspectRatioProps): JSX.Element | null;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type AspectRatioProps from './AspectRatioProps';
3
2
  export default function AspectRatio(props: AspectRatioProps): JSX.Element | null;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type AvatarProps from './AvatarProps';
3
2
  export default function Avatar(props: AvatarProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type BadgeProps from './BadgeProps';
3
2
  export default function Badge(props: BadgeProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type BottomSheetActionsProps from './BottomSheetActionsProps';
3
2
  export default function BottomSheetActions(props: BottomSheetActionsProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type BottomSheetContentProps from './BottomSheetContentProps';
3
2
  export default function BottomSheetContent(props: BottomSheetContentProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type BottomSheetTitleProps from './BottomSheetTitleProps';
3
2
  export default function BottomSheetTitle(props: BottomSheetTitleProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ButtonProps from './ButtonProps';
3
2
  export default function Button(props: ButtonProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type ButtonBaseProps from './ButtonBaseProps';
3
2
  export declare const ORIGINAL_OPACITY = 1;
4
3
  export default function ButtonBase(props: ButtonBaseProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ButtonSetProps from './ButtonSetProps';
3
2
  export default function ButtonSet(props: ButtonSetProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type CardProps from './CardProps';
3
2
  export default function Card(props: CardProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type CardActionsProps from './CardActionsProps';
3
2
  export default function CardActions(props: CardActionsProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type CardContentProps from './CardContentProps';
3
2
  export default function CardContent(props: CardContentProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type CardMediaProps from './CardMediaProps';
3
2
  export default function CardMedia(props: CardMediaProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type CheckboxProps from './CheckboxProps';
3
2
  export default function Checkbox(props: CheckboxProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ChipProps from './ChipProps';
3
2
  export default function Chip(props: ChipProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ViewProps } from 'react-native';
3
2
  import type { OverridableComponentProps } from '../types';
4
3
  export default function CircularProgress(props: OverridableComponentProps<ViewProps>): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const _default: {
3
2
  (props: import("../Flexbox").FlexboxProps): JSX.Element;
4
3
  displayName: string;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type DialogProps from './DialogProps';
3
2
  export default function Dialog(props: DialogProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type DialogActionsProps from './DialogActionsProps';
3
2
  export default function DialogActions(props: DialogActionsProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type DialogContentProps from './DialogContentProps';
3
2
  export default function DialogContent(props: DialogContentProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type DialogMediaProps from './DialogMediaProps';
3
2
  export default function DialogMedia(props: DialogMediaProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { DialogProps } from '../Dialog';
3
2
  import type DialogTitleProps from './DialogTitleProps';
4
3
  interface DialogLargeTitleProps extends DialogTitleProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import DialogLargeTitle from './DialogLargeTitle';
3
2
  import type DialogTitleProps from './DialogTitleProps';
4
3
  declare const DialogTitle: {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type DividerProps from './DividerProps';
3
2
  export default function Divider(props: DividerProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type EmptyProps from './EmptyProps';
3
2
  export default function Empty(props: EmptyProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type FabProps from './FabProps';
3
2
  export default function Fab(props: FabProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type FlexboxProps from './FlexboxProps';
3
2
  export default function createFlexbox(direction: 'row' | 'column'): {
4
3
  (props: FlexboxProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type IconButtonProps from './IconButtonProps';
3
2
  export default function IconButton(props: IconButtonProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ImageProps from './ImageProps';
3
2
  export default function Image(props: ImageProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ImageCoreProps from './ImageCoreProps';
3
2
  export default function ImageCore(props: ImageCoreProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ImageCoreProps from './ImageCoreProps';
3
2
  export default function ImageCore(props: ImageCoreProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type LinkProps from './LinkProps';
3
2
  export default function Link(props: LinkProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ListProps from './ListProps';
3
2
  export default function List(props: ListProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ListItemProps from './ListItemProps';
3
2
  export default function ListItem(props: ListItemProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ListItemIconProps from './ListItemIconProps';
3
2
  export default function ListItemIcon(props: ListItemIconProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import ListItemSecondaryActionProps from './ListItemSecondaryActionProps';
3
2
  export default function ListItemSecondaryAction(props: ListItemSecondaryActionProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ListItemTextProps from './ListItemTextProps';
3
2
  export default function ListItemText(props: ListItemTextProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ListSubheaderProps from './ListSubheaderProps';
3
2
  export default function ListSubheader(props: ListSubheaderProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type MenuProps from './MenuProps';
3
2
  export default function Menu(props: MenuProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type MenuItemProps from './MenuItemProps';
3
2
  export default function MenuItem(props: MenuItemProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type ModalProps from '../ModalProps';
3
2
  declare type AnimatedContainerProps = Pick<ModalProps, 'children' | 'closeAnimation' | 'initialOpacity' | 'initialTranslateY' | 'onEnter' | 'onEntered' | 'onExit' | 'onExited' | 'openAnimation' | 'offsetAnimation' | 'style' | 'visible'>;
4
3
  export default function AnimatedContainer(props: AnimatedContainerProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type ModalProps from './ModalProps';
3
2
  export declare type ModalCloseReasonType = 'OUTSIDE_PRESS' | 'HARDWARE_BACK_PRESS' | 'CLOSE_BUTTON_PRESS' | 'UNKNOWN';
4
3
  export interface ModalCloseEvent {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type PaginationProps from './PaginationProps';
3
2
  interface NumberPaginationProps {
4
3
  currentPage: PaginationProps['page'];
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type PaginationProps from './PaginationProps';
3
2
  export default function Pagination(props: PaginationProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import PortalHost from './PortalHost';
3
2
  import type PortalProps from './PortalProps';
4
3
  declare function Portal(props: PortalProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type RadioProps from './RadioProps';
3
2
  export default function Radio(props: RadioProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type RadioGroupProps from './RadioGroupProps';
3
2
  export default function RadioGroup(props: RadioGroupProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const _default: {
3
2
  (props: import("../Flexbox").FlexboxProps): JSX.Element;
4
3
  displayName: string;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type SectionProps from './SectionProps';
3
2
  export default function Section(props: SectionProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ShadowViewProps from './ShadowViewProps';
3
2
  export default function ShadowView(props: ShadowViewProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ShadowViewProps from './ShadowViewProps';
3
2
  export default function ShadowView(props: ShadowViewProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type SlideProps from './SlideProps';
3
2
  export default function Slide(props: SlideProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type SnackbarProps from './SnackbarProps';
3
2
  export default function Snackbar(props: SnackbarProps): JSX.Element | null;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type SnackbarContentProps from './SnackbarContentProps';
3
2
  export default function SnackbarContent(props: SnackbarContentProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type SnackbarContentProps from './SnackbarContentProps';
3
2
  interface StatusIconProps {
4
3
  status: SnackbarContentProps['status'];
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type SpacerProps from './SpacerProps';
3
2
  export default function Spacer(props: SpacerProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type SvgIconProps from './SvgIconProps';
3
2
  export default function SvgIcon(props: SvgIconProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type SwitchProps from './SwitchProps';
3
2
  export default function Switch(props: SwitchProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type TabProps from './TabProps';
3
2
  export default function Tab(props: TabProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type TabBaseProps from './TabBaseProps';
3
2
  export default function TabBase(props: TabBaseProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ScrollViewProps } from 'react-native';
3
2
  import TabCoordinate from './TabCoordinate';
4
3
  export interface ScrollableTabsViewProps extends ScrollViewProps {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type TabIndicatorProps from './TabIndicatorProps';
3
2
  export default function TabIndicator(props: TabIndicatorProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ToggleProps from './ToggleProps';
3
2
  export default function Toggle(props: ToggleProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type BackButtonProps from './BackButtonProps';
3
2
  export default function BackButton(props: BackButtonProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import BackButton from './BackButton';
3
2
  import type ToolbarProps from './ToolbarProps';
4
3
  declare const Toolbar: {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type BeakProps from './BeakProps';
3
2
  export default function Beak(props: BeakProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SvgProps } from 'react-native-svg';
3
2
  export default function HorizontalLargeBeak(props: SvgProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SvgProps } from 'react-native-svg';
3
2
  export default function HorizontalSmallBeak(props: SvgProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SvgProps } from 'react-native-svg';
3
2
  export default function VerticalLargeBeak(props: SvgProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SvgProps } from 'react-native-svg';
3
2
  export default function VerticalSmallBeak(props: SvgProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type TooltipProps from './TooltipProps';
3
2
  export default function Tooltip(props: TooltipProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const _default: () => JSX.Element;
3
2
  export default _default;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type LoadingSpinnerProps from './LoadingSpinnerProps';
3
2
  export default function LoadingSpinner(props: LoadingSpinnerProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type LoadingSpinnerProps from './LoadingSpinnerProps';
3
2
  export default function LoadingSpinner(props: LoadingSpinnerProps): JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fountain-ui/core",
3
- "version": "3.0.0-alpha.41",
3
+ "version": "3.0.0-alpha.42",
4
4
  "author": "Fountain-UI Team",
5
5
  "description": "React components that implement Tappytoon's Fountain Design.",
6
6
  "license": "MIT",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "9e2a6b64b8a06914bf89b689a3376da01a8d9ee3"
70
+ "gitHead": "4a7de3f29299eb5f7ea9b6b874f232263756f854"
71
71
  }
package/src/Tabs/Tabs.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
2
2
  import type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';
3
- import { View } from 'react-native';
3
+ import { StyleSheet, View } from 'react-native';
4
4
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
5
5
  import { css, useTheme } from '../styles';
6
6
  import { useSyncAnimatedValue } from '../hooks';
@@ -23,7 +23,7 @@ type TabsStyleKeys =
23
23
  | 'root'
24
24
  | 'fixedRoot'
25
25
  | 'fixedTab'
26
- | 'bottomDivider';
26
+ | 'borderContainer';
27
27
 
28
28
  type TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;
29
29
 
@@ -31,14 +31,17 @@ const useStyles: UseStyles<TabsStyles> = function (): TabsStyles {
31
31
  const theme = useTheme();
32
32
 
33
33
  return {
34
- root: {},
34
+ root: {
35
+ position: 'relative',
36
+ },
35
37
  fixedRoot: {
36
38
  flexDirection: 'row',
37
39
  },
38
40
  fixedTab: {
39
41
  flex: 1,
40
42
  },
41
- bottomDivider: {
43
+ borderContainer: {
44
+ ...StyleSheet.absoluteFillObject,
42
45
  borderBottomColor: theme.palette.border.base,
43
46
  borderBottomWidth: 0.5,
44
47
  },
@@ -221,7 +224,6 @@ const Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {
221
224
  styles.root,
222
225
  containerStyle,
223
226
  { backgroundColor: backgroundColorMap[color] },
224
- showDivider ? styles.bottomDivider : undefined,
225
227
  scrollable ? undefined : styles.fixedRoot,
226
228
  style,
227
229
  ])}
@@ -253,6 +255,13 @@ const Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {
253
255
  {tabIndicator}
254
256
  </React.Fragment>
255
257
  )}
258
+
259
+ {showDivider ? (
260
+ <View
261
+ pointerEvents={'none'}
262
+ style={styles.borderContainer}
263
+ />
264
+ ) : null}
256
265
  </View>
257
266
  </InternalContext.Provider>
258
267
  );