@fountain-ui/core 3.0.0-alpha.15 → 3.0.0-alpha.17
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.
- package/build/commonjs/Tab/Tab.js +2 -1
- package/build/commonjs/Tab/Tab.js.map +1 -1
- package/build/commonjs/Tab/TabProps.js +3 -1
- package/build/commonjs/Tab/TabProps.js.map +1 -1
- package/build/commonjs/Tab/index.js +14 -0
- package/build/commonjs/Tab/index.js.map +1 -1
- package/build/commonjs/Tab/useVariantStyleMap.js +20 -14
- package/build/commonjs/Tab/useVariantStyleMap.js.map +1 -1
- package/build/commonjs/Tabs/Tabs.js +4 -5
- package/build/commonjs/Tabs/Tabs.js.map +1 -1
- package/build/commonjs/Tabs/TabsProps.js.map +1 -1
- package/build/commonjs/Tabs/useTabsStyle.js +15 -6
- package/build/commonjs/Tabs/useTabsStyle.js.map +1 -1
- package/build/module/Tab/Tab.js +2 -1
- package/build/module/Tab/Tab.js.map +1 -1
- package/build/module/Tab/TabProps.js +1 -0
- package/build/module/Tab/TabProps.js.map +1 -1
- package/build/module/Tab/index.js +1 -0
- package/build/module/Tab/index.js.map +1 -1
- package/build/module/Tab/useVariantStyleMap.js +20 -14
- package/build/module/Tab/useVariantStyleMap.js.map +1 -1
- package/build/module/Tabs/Tabs.js +4 -5
- package/build/module/Tabs/Tabs.js.map +1 -1
- package/build/module/Tabs/TabsProps.js.map +1 -1
- package/build/module/Tabs/useTabsStyle.js +15 -6
- package/build/module/Tabs/useTabsStyle.js.map +1 -1
- package/build/typescript/Tab/TabProps.d.ts +7 -0
- package/build/typescript/Tab/index.d.ts +2 -1
- package/build/typescript/Tab/useVariantStyleMap.d.ts +2 -2
- package/build/typescript/Tabs/Tabs.d.ts +1 -1
- package/build/typescript/Tabs/TabsProps.d.ts +6 -1
- package/build/typescript/Tabs/useTabsStyle.d.ts +2 -2
- package/package.json +2 -2
- package/src/Tab/Tab.tsx +3 -2
- package/src/Tab/TabProps.ts +9 -0
- package/src/Tab/index.ts +2 -1
- package/src/Tab/useVariantStyleMap.ts +20 -14
- package/src/Tabs/Tabs.tsx +4 -7
- package/src/Tabs/TabsProps.ts +7 -1
- package/src/Tabs/useTabsStyle.ts +14 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","typographyOf","createFontStyle","useTheme","useVariantStyleMap","variant","selected","theme","container","paddingHorizontal","spacing","paddingVertical","inner","backgroundColor","palette","fill","base","weaker","borderRadius","shape","radius","full","flexDirection","gap","label","selector","_","fontSize","lineHeight","fontFamily","letterSpacing","color","text","strongInverse","surface","
|
|
1
|
+
{"version":3,"names":["useMemo","typographyOf","createFontStyle","useTheme","useVariantStyleMap","variant","selected","size","theme","container","paddingHorizontal","spacing","paddingVertical","inner","backgroundColor","palette","fill","base","weaker","borderRadius","shape","radius","full","flexDirection","gap","paddingBottom","paddingTop","label","selector","_","fontSize","lineHeight","fontFamily","letterSpacing","color","text","strongInverse","surface","borderWidth","undefined","borderColor","border","weak","alignItems","height","justifyContent","width","strong"],"sources":["useVariantStyleMap.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { TextStyle } from 'react-native';\nimport type { FountainUiStyle } from '@fountain-ui/styles';\nimport { typographyOf } from '@fountain-ui/styles';\nimport { createFontStyle, useTheme } from '../styles';\nimport type { TabSize, TabVariant } from './TabProps';\n\ninterface VariantStyle {\n container: FountainUiStyle;\n inner?: FountainUiStyle;\n label: TextStyle;\n}\n\nexport default function useVariantStyleMap(variant: TabVariant, selected: boolean, size: TabSize): VariantStyle {\n const theme = useTheme();\n\n return useMemo<VariantStyle>(() => {\n switch (variant) {\n case 'circular':\n return {\n container: {\n paddingHorizontal: theme.spacing(0.75),\n paddingVertical: theme.spacing(1),\n },\n inner: {\n backgroundColor: selected\n ? theme.palette.fill.base\n : theme.palette.fill.weaker,\n borderRadius: theme.shape.radius.full,\n flexDirection: 'row',\n gap: 5,\n paddingBottom: 7.5,\n paddingHorizontal: 14,\n paddingTop: 6.5,\n },\n label: createFontStyle(theme, {\n selector: (_) => typographyOf({\n fontSize: size === 'small' ? 14 : 15,\n lineHeight: size === 'small' ? 18.2 : 19.5,\n fontFamily: 'PretendardStd-SemiBold',\n letterSpacing: 0,\n }),\n color: selected\n ? theme.palette.text.strongInverse\n : theme.palette.text.base,\n }),\n };\n case 'circular-home':\n return {\n container: {\n paddingBottom: 4,\n paddingHorizontal: 3,\n },\n inner: {\n backgroundColor: selected\n ? theme.palette.fill.base\n : theme.palette.surface.base,\n borderRadius: theme.shape.radius.full,\n borderWidth: selected ? undefined : 0.5,\n borderColor: selected ? undefined : theme.palette.border.weak,\n flexDirection: 'row',\n gap: 5,\n paddingBottom: 6.5,\n paddingHorizontal: 14,\n paddingVertical: 7.5,\n },\n label: createFontStyle(theme, {\n selector: (_) => typographyOf({\n fontSize: 15,\n lineHeight: 19.5,\n fontFamily: 'LexendDeca-Medium',\n letterSpacing: 0,\n }),\n color: selected\n ? theme.palette.text.strongInverse\n : theme.palette.text.base,\n }),\n };\n case 'bottom-navigation':\n return {\n container: {\n alignItems: 'center',\n height: 49,\n justifyContent: 'flex-start',\n paddingTop: 10.5,\n width: 48,\n },\n inner: {\n flexDirection: 'column',\n gap: 4.75,\n },\n label: createFontStyle(theme, {\n selector: (_) => typographyOf({\n fontSize: 10,\n lineHeight: 10,\n fontFamily: 'PretendardStd-Medium',\n letterSpacing: -0.1,\n }),\n color: selected\n ? theme.palette.text.strong\n : theme.palette.text.base,\n }),\n };\n case 'default':\n default:\n return {\n container: {\n paddingHorizontal: 10,\n },\n inner: {\n flexDirection: 'row',\n gap: 5,\n paddingHorizontal: 1,\n paddingVertical: 10,\n },\n label: createFontStyle(theme, {\n selector: (_) => typographyOf({\n fontSize: size === 'small' ? 15 : 16,\n lineHeight: size === 'small' ? 18.75 : 20,\n fontFamily: selected ? 'PretendardStd-SemiBold' : 'PretendardStd-Medium',\n letterSpacing: 0,\n }),\n color: selected\n ? theme.palette.text.strong\n : theme.palette.text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AD,EAAQH,OAAR,EAAiBC,QAAjB,EAA2BC,IAA3B,CAhHW,CAAd;AAiHH"}
|
|
@@ -22,9 +22,6 @@ const useStyles = function () {
|
|
|
22
22
|
fixedTab: {
|
|
23
23
|
flex: 1
|
|
24
24
|
},
|
|
25
|
-
scrollableContainer: {
|
|
26
|
-
paddingHorizontal: theme.spacing(1)
|
|
27
|
-
},
|
|
28
25
|
bottomDivider: {
|
|
29
26
|
borderBottomColor: theme.palette.border.base,
|
|
30
27
|
borderBottomWidth: 0.5
|
|
@@ -47,6 +44,7 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
|
|
|
47
44
|
scrollable = false,
|
|
48
45
|
scrollViewContentContainerStyle,
|
|
49
46
|
showDivider = false,
|
|
47
|
+
size = 'medium',
|
|
50
48
|
style,
|
|
51
49
|
variant = 'default',
|
|
52
50
|
UNSTABLE_sharedIndex,
|
|
@@ -60,7 +58,7 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
|
|
|
60
58
|
const currentIndexRef = useRef(initialIndex);
|
|
61
59
|
const {
|
|
62
60
|
container: containerStyle
|
|
63
|
-
} = useTabsStyle(variant);
|
|
61
|
+
} = useTabsStyle(variant, size);
|
|
64
62
|
|
|
65
63
|
const setTab = newIndex => {
|
|
66
64
|
const currentIndex = currentIndexRef.current;
|
|
@@ -151,6 +149,7 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
|
|
|
151
149
|
onLayout,
|
|
152
150
|
onPress,
|
|
153
151
|
onMouseDown,
|
|
152
|
+
size,
|
|
154
153
|
variant,
|
|
155
154
|
indicatorSize,
|
|
156
155
|
style: scrollable ? undefined : styles.fixedTab
|
|
@@ -181,7 +180,7 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
|
|
|
181
180
|
}, scrollable ? /*#__PURE__*/React.createElement(ScrollableTabsView, {
|
|
182
181
|
automaticallyAdjustContentInsets: false,
|
|
183
182
|
bounces: false,
|
|
184
|
-
contentContainerStyle: css([
|
|
183
|
+
contentContainerStyle: css([scrollViewContentContainerStyle]),
|
|
185
184
|
coordinates: coordinates,
|
|
186
185
|
directionalLockEnabled: true,
|
|
187
186
|
horizontal: true,
|
|
@@ -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","useTabsStyle","useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","bottomDivider","borderBottomColor","palette","border","base","borderBottomWidth","Tabs","props","ref","children","color","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","showDivider","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","initialValue","sharedIndex","realInitialIndex","currentIndexRef","container","containerStyle","setTab","newIndex","currentIndex","current","animatedValue","setValue","styles","outerCoordinates","updateCoordinate","innerContentsWidthList","updateInnerContentsWidth","canRenderIndicator","indexStore","coordinates","length","map","innerContentWidth","idx","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","subscribe","tabElements","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabElement","enableIndicator","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 { 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 useTabsStyle from './useTabsStyle';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'scrollableContainer'\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 scrollableContainer: {\n paddingHorizontal: theme.spacing(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 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 { container: containerStyle } = useTabsStyle(variant);\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 { 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]);\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 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 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 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,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,kBA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c8E,UAAd,CAAyBC;EAFoB,CAAtD;EAKA,oBACI,oBAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAE;MAAEtC;IAAF;EAAjC,gBACI,oBAAC,IAAD;IACI,KAAK,EAAEjE,GAAG,CAAC,CACP2D,MAAM,CAAC7C,IADA,EAEPsC,cAFO,EAGP;MAAEoD,eAAe,EAAEJ,kBAAkB,CAACpE,KAAD;IAArC,CAHO,EAIPS,WAAW,GAAGkB,MAAM,CAACrC,aAAV,GAA0B0E,SAJ9B,EAKPzD,UAAU,GAAGyD,SAAH,GAAerC,MAAM,CAAC5C,SALzB,EAMP2B,KANO,CAAD;EADd,GAUKH,UAAU,gBACP,oBAAC,kBAAD;IACI,gCAAgC,EAAE,KADtC;IAEI,OAAO,EAAE,KAFb;IAGI,qBAAqB,EAAEvC,GAAG,CAAC,CACvB2D,MAAM,CAACxC,mBADgB,EAEvBqB,+BAFuB,CAAD,CAH9B;IAOI,WAAW,EAAE0B,WAPjB;IAQI,sBAAsB,EAAE,IAR5B;IASI,UAAU,EAAE,IAThB;IAUI,YAAY,EAAEjB,gBAVlB;IAWI,YAAY,EAAE,KAXlB;IAYI,8BAA8B,EAAE,KAZpC;IAaI,4BAA4B,EAAE,KAblC;IAcI,mBAAmB,EAAEb,mBAdzB;IAeI,yBAAyB,EAAEC;EAf/B,GAiBK0C,WAjBL,EAkBKoB,YAlBL,CADO,gBAsBP,oBAAC,KAAD,CAAO,QAAP,QACKpB,WADL,EAEKoB,YAFL,CAhCR,CADJ,CADJ;AA0CH,CAlMsB,CAAvB;AAoMA,eAAevE,IAAf"}
|
|
1
|
+
{"version":3,"names":["React","cloneElement","forwardRef","useEffect","useImperativeHandle","useMemo","useRef","View","css","useTheme","useSyncAnimatedValue","TabIndicator","ScrollableTabsView","IndexAwareTab","useTabCoordinates","useTabInnerContentsWidth","useIndexStore","InternalContext","isEveryTabCoordinatesDefined","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","setTab","newIndex","currentIndex","current","animatedValue","setValue","styles","outerCoordinates","updateCoordinate","innerContentsWidthList","updateInnerContentsWidth","canRenderIndicator","indexStore","coordinates","length","map","innerContentWidth","idx","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","subscribe","tabElements","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabElement","enableIndicator","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 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 { container: containerStyle } = useTabsStyle(variant, size);\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 { 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]);\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 onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n size,\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 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 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,OAAOC,YAAP,MAAyB,gBAAzB;;AAUA,MAAMC,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAGZ,QAAQ,EAAtB;EAEA,OAAO;IACHa,IAAI,EAAE,EADH;IAEHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAFR;IAKHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CALP;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b;IAGI,qBAAqB,EAAEpC,GAAG,CAAC,CACvBqC,+BADuB,CAAD,CAH9B;IAMI,WAAW,EAAE2B,WANjB;IAOI,sBAAsB,EAAE,IAP5B;IAQI,UAAU,EAAE,IARhB;IASI,YAAY,EAAEjB,gBATlB;IAUI,YAAY,EAAE,KAVlB;IAWI,8BAA8B,EAAE,KAXpC;IAYI,4BAA4B,EAAE,KAZlC;IAaI,mBAAmB,EAAEd,mBAbzB;IAcI,yBAAyB,EAAEC;EAd/B,GAgBK2C,WAhBL,EAiBKoB,YAjBL,CADO,gBAqBP,oBAAC,KAAD,CAAO,QAAP,QACKpB,WADL,EAEKoB,YAFL,CA/BR,CADJ,CADJ;AAyCH,CAnMsB,CAAvB;AAqMA,eAAexE,IAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["tabsColors","tabIndicatorSizes"],"sources":["TabsProps.ts"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { TabVariant } from '../Tab';\nimport type { ExtendedStyle, OverridableComponentProps, SyncAnimatedValue } from '../types';\nimport type { KeyboardDismissMode, KeyboardShouldPersistTaps, TabsInstance } from './types';\n\nexport const tabsColors = ['default', 'alt'] as const;\nexport type TabsColor = typeof tabsColors[number];\n\nexport const tabIndicatorSizes = ['fit-content', 'full'] as const;\nexport type TabIndicatorSize = typeof tabIndicatorSizes[number];\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 * The color of the component. It supports those theme colors that make sense for this component.\n * @default 'default'\n */\n color?: TabsColor;\n\n /**\n * If `true`, the indicator is disabled.\n * @default false\n */\n disableIndicator?: boolean;\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 'fit-content'\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 * Determines whether to display the bottom border.\n * @default false\n */\n showDivider?: boolean;\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":"AAMA,OAAO,MAAMA,UAAU,GAAG,CAAC,SAAD,EAAY,KAAZ,CAAnB;AAGP,OAAO,MAAMC,iBAAiB,GAAG,CAAC,aAAD,EAAgB,MAAhB,CAA1B"}
|
|
1
|
+
{"version":3,"names":["tabsColors","tabIndicatorSizes"],"sources":["TabsProps.ts"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { TabSize, TabVariant } from '../Tab';\nimport type { ExtendedStyle, OverridableComponentProps, SyncAnimatedValue } from '../types';\nimport type { KeyboardDismissMode, KeyboardShouldPersistTaps, TabsInstance } from './types';\n\nexport const tabsColors = ['default', 'alt'] as const;\nexport type TabsColor = typeof tabsColors[number];\n\nexport const tabIndicatorSizes = ['fit-content', 'full'] as const;\nexport type TabIndicatorSize = typeof tabIndicatorSizes[number];\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 * The color of the component. It supports those theme colors that make sense for this component.\n * @default 'default'\n */\n color?: TabsColor;\n\n /**\n * If `true`, the indicator is disabled.\n * @default false\n */\n disableIndicator?: boolean;\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 'fit-content'\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 * Determines whether to display the bottom border.\n * @default false\n */\n showDivider?: boolean;\n\n /**\n * The size of the Tab.\n * @default 'medium'\n */\n size?: TabSize;\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":"AAMA,OAAO,MAAMA,UAAU,GAAG,CAAC,SAAD,EAAY,KAAZ,CAAnB;AAGP,OAAO,MAAMC,iBAAiB,GAAG,CAAC,aAAD,EAAgB,MAAhB,CAA1B"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useBreakpointUp } from '../hooks';
|
|
3
3
|
import { useTheme } from '../styles';
|
|
4
|
-
export default function useTabsStyle(variant) {
|
|
4
|
+
export default function useTabsStyle(variant, size) {
|
|
5
5
|
const theme = useTheme();
|
|
6
|
-
const
|
|
6
|
+
const isTablet = useBreakpointUp('md', true, false);
|
|
7
7
|
return useMemo(() => {
|
|
8
8
|
switch (variant) {
|
|
9
9
|
case 'circular':
|
|
10
10
|
return {
|
|
11
11
|
container: {
|
|
12
12
|
paddingBottom: 8,
|
|
13
|
-
paddingHorizontal:
|
|
13
|
+
paddingHorizontal: isTablet ? 20 : size === 'small' ? 8 : 12
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
case 'circular-home':
|
|
18
|
+
return {
|
|
19
|
+
container: {
|
|
20
|
+
paddingBottom: 8,
|
|
21
|
+
paddingHorizontal: isTablet ? 20 : 8
|
|
14
22
|
}
|
|
15
23
|
};
|
|
16
24
|
|
|
@@ -18,7 +26,8 @@ export default function useTabsStyle(variant) {
|
|
|
18
26
|
return {
|
|
19
27
|
container: {
|
|
20
28
|
borderTopColor: theme.palette.border.base,
|
|
21
|
-
borderTopWidth: 0.5
|
|
29
|
+
borderTopWidth: 0.5,
|
|
30
|
+
paddingHorizontal: 20
|
|
22
31
|
}
|
|
23
32
|
};
|
|
24
33
|
|
|
@@ -26,10 +35,10 @@ export default function useTabsStyle(variant) {
|
|
|
26
35
|
default:
|
|
27
36
|
return {
|
|
28
37
|
container: {
|
|
29
|
-
paddingHorizontal:
|
|
38
|
+
paddingHorizontal: isTablet ? 14 : 6
|
|
30
39
|
}
|
|
31
40
|
};
|
|
32
41
|
}
|
|
33
|
-
}, [theme, variant,
|
|
42
|
+
}, [theme, variant, isTablet, size]);
|
|
34
43
|
}
|
|
35
44
|
//# sourceMappingURL=useTabsStyle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useBreakpointUp","useTheme","useTabsStyle","variant","theme","
|
|
1
|
+
{"version":3,"names":["useMemo","useBreakpointUp","useTheme","useTabsStyle","variant","size","theme","isTablet","container","paddingBottom","paddingHorizontal","borderTopColor","palette","border","base","borderTopWidth"],"sources":["useTabsStyle.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { FountainUiStyle } from '@fountain-ui/styles';\nimport { useBreakpointUp } from '../hooks';\nimport { useTheme } from '../styles';\nimport type { TabSize, TabVariant } from '../Tab';\n\ninterface TabsStyle {\n container: FountainUiStyle;\n}\n\nexport default function useTabsStyle(variant: TabVariant, size: TabSize) {\n const theme = useTheme();\n\n const isTablet = useBreakpointUp('md', true, false);\n\n return useMemo<TabsStyle>(() => {\n switch (variant) {\n case 'circular':\n return {\n container: {\n paddingBottom: 8,\n paddingHorizontal: isTablet ? 20 : (size === 'small' ? 8 : 12),\n },\n };\n case 'circular-home':\n return {\n container: {\n paddingBottom: 8,\n paddingHorizontal: isTablet ? 20 : 8,\n },\n };\n case 'bottom-navigation':\n return {\n container: {\n borderTopColor: theme.palette.border.base,\n borderTopWidth: 0.5,\n paddingHorizontal: 20,\n },\n };\n case 'default':\n default:\n return {\n container: {\n paddingHorizontal: isTablet ? 14 : 6,\n },\n };\n }\n }, [theme, variant, isTablet, size]);\n}\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,eAAT,QAAgC,UAAhC;AACA,SAASC,QAAT,QAAyB,WAAzB;AAOA,eAAe,SAASC,YAAT,CAAsBC,OAAtB,EAA2CC,IAA3C,EAA0D;EACrE,MAAMC,KAAK,GAAGJ,QAAQ,EAAtB;EAEA,MAAMK,QAAQ,GAAGN,eAAe,CAAC,IAAD,EAAO,IAAP,EAAa,KAAb,CAAhC;EAEA,OAAOD,OAAO,CAAY,MAAM;IAC5B,QAAQI,OAAR;MACI,KAAK,UAAL;QACI,OAAO;UACHI,SAAS,EAAE;YACPC,aAAa,EAAE,CADR;YAEPC,iBAAiB,EAAEH,QAAQ,GAAG,EAAH,GAASF,IAAI,KAAK,OAAT,GAAmB,CAAnB,GAAuB;UAFpD;QADR,CAAP;;MAMJ,KAAK,eAAL;QACI,OAAO;UACHG,SAAS,EAAE;YACPC,aAAa,EAAE,CADR;YAEPC,iBAAiB,EAAEH,QAAQ,GAAG,EAAH,GAAQ;UAF5B;QADR,CAAP;;MAMJ,KAAK,mBAAL;QACI,OAAO;UACHC,SAAS,EAAE;YACPG,cAAc,EAAEL,KAAK,CAACM,OAAN,CAAcC,MAAd,CAAqBC,IAD9B;YAEPC,cAAc,EAAE,GAFT;YAGPL,iBAAiB,EAAE;UAHZ;QADR,CAAP;;MAOJ,KAAK,SAAL;MACA;QACI,OAAO;UACHF,SAAS,EAAE;YACPE,iBAAiB,EAAEH,QAAQ,GAAG,EAAH,GAAQ;UAD5B;QADR,CAAP;IAzBR;EA+BH,CAhCa,EAgCX,CAACD,KAAD,EAAQF,OAAR,EAAiBG,QAAjB,EAA2BF,IAA3B,CAhCW,CAAd;AAiCH"}
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import type { LayoutChangeEvent } from 'react-native';
|
|
3
3
|
import type { TabBaseProps } from '../TabBase';
|
|
4
4
|
import type { OverridableComponentProps } from '../types';
|
|
5
|
+
export declare const tabSizes: readonly ["small", "medium"];
|
|
6
|
+
export declare type TabSize = typeof tabSizes[number];
|
|
5
7
|
export declare const tabVariants: readonly ["default", "circular", "circular-home", "bottom-navigation"];
|
|
6
8
|
export declare type TabVariant = typeof tabVariants[number];
|
|
7
9
|
export default interface TabProps extends OverridableComponentProps<TabBaseProps, {
|
|
@@ -32,6 +34,11 @@ export default interface TabProps extends OverridableComponentProps<TabBaseProps
|
|
|
32
34
|
* If supplied, use this icon on selected state.
|
|
33
35
|
*/
|
|
34
36
|
selectedIcon?: React.ReactElement;
|
|
37
|
+
/**
|
|
38
|
+
* The size of the Tab.
|
|
39
|
+
* @default 'medium'
|
|
40
|
+
*/
|
|
41
|
+
size?: TabSize;
|
|
35
42
|
/**
|
|
36
43
|
* The variant to use.
|
|
37
44
|
* @default 'default'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TextStyle } from 'react-native';
|
|
2
2
|
import type { FountainUiStyle } from '@fountain-ui/styles';
|
|
3
|
-
import type { TabVariant } from './TabProps';
|
|
3
|
+
import type { TabSize, TabVariant } from './TabProps';
|
|
4
4
|
interface VariantStyle {
|
|
5
5
|
container: FountainUiStyle;
|
|
6
6
|
inner?: FountainUiStyle;
|
|
7
7
|
label: TextStyle;
|
|
8
8
|
}
|
|
9
|
-
export default function useVariantStyleMap(variant: TabVariant, selected: boolean): VariantStyle;
|
|
9
|
+
export default function useVariantStyleMap(variant: TabVariant, selected: boolean, size: TabSize): VariantStyle;
|
|
10
10
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type TabsProps from './TabsProps';
|
|
3
3
|
import type { TabsInstance } from './types';
|
|
4
|
-
declare const Tabs: React.ForwardRefExoticComponent<Pick<TabsProps, "color" | "testID" | "style" | "onLayout" | "keyboardDismissMode" | "children" | "pointerEvents" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "accessibilityLabel" | "accessible" | "hitSlop" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessibilityActions" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "onChange" | "variant" | "keyboardShouldPersistTaps" | "disableIndicator" | "indicatorSize" | "initialIndex" | "scrollable" | "scrollViewContentContainerStyle" | "showDivider" | "UNSTABLE_sharedIndex" | "onTabSelected"> & React.RefAttributes<TabsInstance>>;
|
|
4
|
+
declare const Tabs: React.ForwardRefExoticComponent<Pick<TabsProps, "color" | "testID" | "style" | "onLayout" | "keyboardDismissMode" | "children" | "pointerEvents" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "accessibilityLabel" | "accessible" | "hitSlop" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessibilityActions" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "size" | "onChange" | "variant" | "keyboardShouldPersistTaps" | "disableIndicator" | "indicatorSize" | "initialIndex" | "scrollable" | "scrollViewContentContainerStyle" | "showDivider" | "UNSTABLE_sharedIndex" | "onTabSelected"> & React.RefAttributes<TabsInstance>>;
|
|
5
5
|
export default Tabs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import type { ViewProps } from 'react-native';
|
|
3
|
-
import type { TabVariant } from '../Tab';
|
|
3
|
+
import type { TabSize, TabVariant } from '../Tab';
|
|
4
4
|
import type { ExtendedStyle, OverridableComponentProps, SyncAnimatedValue } from '../types';
|
|
5
5
|
import type { KeyboardDismissMode, KeyboardShouldPersistTaps, TabsInstance } from './types';
|
|
6
6
|
export declare const tabsColors: readonly ["default", "alt"];
|
|
@@ -63,6 +63,11 @@ export default interface TabsProps extends OverridableComponentProps<ViewProps,
|
|
|
63
63
|
* @default false
|
|
64
64
|
*/
|
|
65
65
|
showDivider?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* The size of the Tab.
|
|
68
|
+
* @default 'medium'
|
|
69
|
+
*/
|
|
70
|
+
size?: TabSize;
|
|
66
71
|
/**
|
|
67
72
|
* Unstable API.
|
|
68
73
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FountainUiStyle } from '@fountain-ui/styles';
|
|
2
|
-
import type { TabVariant } from '../Tab';
|
|
2
|
+
import type { TabSize, TabVariant } from '../Tab';
|
|
3
3
|
interface TabsStyle {
|
|
4
4
|
container: FountainUiStyle;
|
|
5
5
|
}
|
|
6
|
-
export default function useTabsStyle(variant: TabVariant): TabsStyle;
|
|
6
|
+
export default function useTabsStyle(variant: TabVariant, size: TabSize): TabsStyle;
|
|
7
7
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fountain-ui/core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.17",
|
|
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": "
|
|
70
|
+
"gitHead": "a1cc03c803e63c95ee74237ffe7f809428ff0116"
|
|
71
71
|
}
|
package/src/Tab/Tab.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import TabBase from '../TabBase';
|
|
|
5
5
|
import { css, StyleSheet } from '../styles';
|
|
6
6
|
import { cloneElementSafely } from '../utils';
|
|
7
7
|
import type TabProps from './TabProps';
|
|
8
|
-
import type { TabVariant } from './TabProps';
|
|
8
|
+
import type { TabSize, TabVariant } from './TabProps';
|
|
9
9
|
import useVariantStyleMap from './useVariantStyleMap';
|
|
10
10
|
|
|
11
11
|
const styles = StyleSheet.create({
|
|
@@ -27,6 +27,7 @@ export default function Tab(props: TabProps) {
|
|
|
27
27
|
icon: defaultIcon,
|
|
28
28
|
selected = false,
|
|
29
29
|
selectedIcon,
|
|
30
|
+
size = 'medium' as TabSize,
|
|
30
31
|
variant = 'default' as TabVariant,
|
|
31
32
|
style: styleProp,
|
|
32
33
|
onTabInnerLayout,
|
|
@@ -37,7 +38,7 @@ export default function Tab(props: TabProps) {
|
|
|
37
38
|
container: containerStyle,
|
|
38
39
|
inner: innerStyle,
|
|
39
40
|
label: labelStyle,
|
|
40
|
-
} = useVariantStyleMap(variant, selected);
|
|
41
|
+
} = useVariantStyleMap(variant, selected, size);
|
|
41
42
|
|
|
42
43
|
const tabBaseStyle = css([
|
|
43
44
|
styles.root,
|
package/src/Tab/TabProps.ts
CHANGED
|
@@ -3,6 +3,9 @@ import type { LayoutChangeEvent } from 'react-native';
|
|
|
3
3
|
import type { TabBaseProps } from '../TabBase';
|
|
4
4
|
import type { OverridableComponentProps } from '../types';
|
|
5
5
|
|
|
6
|
+
export const tabSizes = ['small', 'medium'] as const;
|
|
7
|
+
export type TabSize = typeof tabSizes[number];
|
|
8
|
+
|
|
6
9
|
export const tabVariants = ['default', 'circular', 'circular-home', 'bottom-navigation'] as const;
|
|
7
10
|
export type TabVariant = typeof tabVariants[number];
|
|
8
11
|
|
|
@@ -40,6 +43,12 @@ export default interface TabProps extends OverridableComponentProps<TabBaseProps
|
|
|
40
43
|
*/
|
|
41
44
|
selectedIcon?: React.ReactElement;
|
|
42
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The size of the Tab.
|
|
48
|
+
* @default 'medium'
|
|
49
|
+
*/
|
|
50
|
+
size?: TabSize;
|
|
51
|
+
|
|
43
52
|
/**
|
|
44
53
|
* The variant to use.
|
|
45
54
|
* @default 'default'
|
package/src/Tab/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { TextStyle } from 'react-native';
|
|
|
3
3
|
import type { FountainUiStyle } from '@fountain-ui/styles';
|
|
4
4
|
import { typographyOf } from '@fountain-ui/styles';
|
|
5
5
|
import { createFontStyle, useTheme } from '../styles';
|
|
6
|
-
import type { TabVariant } from './TabProps';
|
|
6
|
+
import type { TabSize, TabVariant } from './TabProps';
|
|
7
7
|
|
|
8
8
|
interface VariantStyle {
|
|
9
9
|
container: FountainUiStyle;
|
|
@@ -11,7 +11,7 @@ interface VariantStyle {
|
|
|
11
11
|
label: TextStyle;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export default function useVariantStyleMap(variant: TabVariant, selected: boolean): VariantStyle {
|
|
14
|
+
export default function useVariantStyleMap(variant: TabVariant, selected: boolean, size: TabSize): VariantStyle {
|
|
15
15
|
const theme = useTheme();
|
|
16
16
|
|
|
17
17
|
return useMemo<VariantStyle>(() => {
|
|
@@ -29,13 +29,14 @@ export default function useVariantStyleMap(variant: TabVariant, selected: boolea
|
|
|
29
29
|
borderRadius: theme.shape.radius.full,
|
|
30
30
|
flexDirection: 'row',
|
|
31
31
|
gap: 5,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
paddingBottom: 7.5,
|
|
33
|
+
paddingHorizontal: 14,
|
|
34
|
+
paddingTop: 6.5,
|
|
34
35
|
},
|
|
35
36
|
label: createFontStyle(theme, {
|
|
36
37
|
selector: (_) => typographyOf({
|
|
37
|
-
fontSize: 14,
|
|
38
|
-
lineHeight: 18.2,
|
|
38
|
+
fontSize: size === 'small' ? 14 : 15,
|
|
39
|
+
lineHeight: size === 'small' ? 18.2 : 19.5,
|
|
39
40
|
fontFamily: 'PretendardStd-SemiBold',
|
|
40
41
|
letterSpacing: 0,
|
|
41
42
|
}),
|
|
@@ -47,18 +48,21 @@ export default function useVariantStyleMap(variant: TabVariant, selected: boolea
|
|
|
47
48
|
case 'circular-home':
|
|
48
49
|
return {
|
|
49
50
|
container: {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
paddingBottom: 4,
|
|
52
|
+
paddingHorizontal: 3,
|
|
52
53
|
},
|
|
53
54
|
inner: {
|
|
54
55
|
backgroundColor: selected
|
|
55
56
|
? theme.palette.fill.base
|
|
56
57
|
: theme.palette.surface.base,
|
|
57
58
|
borderRadius: theme.shape.radius.full,
|
|
59
|
+
borderWidth: selected ? undefined : 0.5,
|
|
60
|
+
borderColor: selected ? undefined : theme.palette.border.weak,
|
|
58
61
|
flexDirection: 'row',
|
|
59
62
|
gap: 5,
|
|
63
|
+
paddingBottom: 6.5,
|
|
60
64
|
paddingHorizontal: 14,
|
|
61
|
-
paddingVertical:
|
|
65
|
+
paddingVertical: 7.5,
|
|
62
66
|
},
|
|
63
67
|
label: createFontStyle(theme, {
|
|
64
68
|
selector: (_) => typographyOf({
|
|
@@ -78,7 +82,7 @@ export default function useVariantStyleMap(variant: TabVariant, selected: boolea
|
|
|
78
82
|
alignItems: 'center',
|
|
79
83
|
height: 49,
|
|
80
84
|
justifyContent: 'flex-start',
|
|
81
|
-
paddingTop:
|
|
85
|
+
paddingTop: 10.5,
|
|
82
86
|
width: 48,
|
|
83
87
|
},
|
|
84
88
|
inner: {
|
|
@@ -101,16 +105,18 @@ export default function useVariantStyleMap(variant: TabVariant, selected: boolea
|
|
|
101
105
|
default:
|
|
102
106
|
return {
|
|
103
107
|
container: {
|
|
104
|
-
|
|
108
|
+
paddingHorizontal: 10,
|
|
105
109
|
},
|
|
106
110
|
inner: {
|
|
107
111
|
flexDirection: 'row',
|
|
108
112
|
gap: 5,
|
|
113
|
+
paddingHorizontal: 1,
|
|
114
|
+
paddingVertical: 10,
|
|
109
115
|
},
|
|
110
116
|
label: createFontStyle(theme, {
|
|
111
117
|
selector: (_) => typographyOf({
|
|
112
|
-
fontSize: 15,
|
|
113
|
-
lineHeight: 18.75,
|
|
118
|
+
fontSize: size === 'small' ? 15 : 16,
|
|
119
|
+
lineHeight: size === 'small' ? 18.75 : 20,
|
|
114
120
|
fontFamily: selected ? 'PretendardStd-SemiBold' : 'PretendardStd-Medium',
|
|
115
121
|
letterSpacing: 0,
|
|
116
122
|
}),
|
|
@@ -120,5 +126,5 @@ export default function useVariantStyleMap(variant: TabVariant, selected: boolea
|
|
|
120
126
|
}),
|
|
121
127
|
};
|
|
122
128
|
}
|
|
123
|
-
}, [theme, variant, selected]);
|
|
129
|
+
}, [theme, variant, selected, size]);
|
|
124
130
|
}
|
package/src/Tabs/Tabs.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { 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';
|
|
7
|
-
import type { TabVariant } from '../Tab';
|
|
7
|
+
import type { TabSize, TabVariant } from '../Tab';
|
|
8
8
|
import type TabsProps from './TabsProps';
|
|
9
9
|
import type { TabsColor } from './TabsProps';
|
|
10
10
|
import type { TabsInstance } from './types';
|
|
@@ -22,7 +22,6 @@ type TabsStyleKeys =
|
|
|
22
22
|
| 'root'
|
|
23
23
|
| 'fixedRoot'
|
|
24
24
|
| 'fixedTab'
|
|
25
|
-
| 'scrollableContainer'
|
|
26
25
|
| 'bottomDivider';
|
|
27
26
|
|
|
28
27
|
type TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;
|
|
@@ -38,9 +37,6 @@ const useStyles: UseStyles<TabsStyles> = function (): TabsStyles {
|
|
|
38
37
|
fixedTab: {
|
|
39
38
|
flex: 1,
|
|
40
39
|
},
|
|
41
|
-
scrollableContainer: {
|
|
42
|
-
paddingHorizontal: theme.spacing(1),
|
|
43
|
-
},
|
|
44
40
|
bottomDivider: {
|
|
45
41
|
borderBottomColor: theme.palette.border.base,
|
|
46
42
|
borderBottomWidth: 0.5,
|
|
@@ -61,6 +57,7 @@ const Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {
|
|
|
61
57
|
scrollable = false,
|
|
62
58
|
scrollViewContentContainerStyle,
|
|
63
59
|
showDivider = false,
|
|
60
|
+
size = 'medium' as TabSize,
|
|
64
61
|
style,
|
|
65
62
|
variant = 'default' as TabVariant,
|
|
66
63
|
UNSTABLE_sharedIndex,
|
|
@@ -73,7 +70,7 @@ const Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {
|
|
|
73
70
|
|
|
74
71
|
const currentIndexRef = useRef(initialIndex);
|
|
75
72
|
|
|
76
|
-
const { container: containerStyle } = useTabsStyle(variant);
|
|
73
|
+
const { container: containerStyle } = useTabsStyle(variant, size);
|
|
77
74
|
|
|
78
75
|
const setTab = (newIndex: number) => {
|
|
79
76
|
const currentIndex = currentIndexRef.current;
|
|
@@ -173,6 +170,7 @@ const Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {
|
|
|
173
170
|
onLayout,
|
|
174
171
|
onPress,
|
|
175
172
|
onMouseDown,
|
|
173
|
+
size,
|
|
176
174
|
variant,
|
|
177
175
|
indicatorSize,
|
|
178
176
|
style: scrollable ? undefined : styles.fixedTab,
|
|
@@ -217,7 +215,6 @@ const Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {
|
|
|
217
215
|
automaticallyAdjustContentInsets={false}
|
|
218
216
|
bounces={false}
|
|
219
217
|
contentContainerStyle={css([
|
|
220
|
-
styles.scrollableContainer,
|
|
221
218
|
scrollViewContentContainerStyle,
|
|
222
219
|
])}
|
|
223
220
|
coordinates={coordinates}
|
package/src/Tabs/TabsProps.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import type { ViewProps } from 'react-native';
|
|
3
|
-
import type { TabVariant } from '../Tab';
|
|
3
|
+
import type { TabSize, TabVariant } from '../Tab';
|
|
4
4
|
import type { ExtendedStyle, OverridableComponentProps, SyncAnimatedValue } from '../types';
|
|
5
5
|
import type { KeyboardDismissMode, KeyboardShouldPersistTaps, TabsInstance } from './types';
|
|
6
6
|
|
|
@@ -78,6 +78,12 @@ export default interface TabsProps extends OverridableComponentProps<ViewProps,
|
|
|
78
78
|
*/
|
|
79
79
|
showDivider?: boolean;
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* The size of the Tab.
|
|
83
|
+
* @default 'medium'
|
|
84
|
+
*/
|
|
85
|
+
size?: TabSize;
|
|
86
|
+
|
|
81
87
|
/**
|
|
82
88
|
* Unstable API.
|
|
83
89
|
*/
|