@fountain-ui/core 3.0.0-alpha.14 → 3.0.0-alpha.16
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/Accordion/Accordion.js +3 -3
- package/build/commonjs/Accordion/Accordion.js.map +1 -1
- package/build/commonjs/Accordion/useVariantStyleMap.js +6 -2
- package/build/commonjs/Accordion/useVariantStyleMap.js.map +1 -1
- package/build/commonjs/BottomSheetTitle/BottomSheetTitle.js +1 -0
- package/build/commonjs/BottomSheetTitle/BottomSheetTitle.js.map +1 -1
- package/build/commonjs/BottomSheetTitle/BottomSheetTitleProps.js.map +1 -1
- package/build/commonjs/Button/Button.js +11 -9
- package/build/commonjs/Button/Button.js.map +1 -1
- package/build/commonjs/Dialog/Dialog.js +8 -4
- package/build/commonjs/Dialog/Dialog.js.map +1 -1
- package/build/commonjs/Dialog/FullDialogCloseButton.js +55 -0
- package/build/commonjs/Dialog/FullDialogCloseButton.js.map +1 -0
- package/build/commonjs/Dialog/useDialogStyle.js +13 -3
- package/build/commonjs/Dialog/useDialogStyle.js.map +1 -1
- package/build/commonjs/ImageCore/ImageCoreNative.js +1 -1
- package/build/commonjs/ImageCore/ImageCoreNative.js.map +1 -1
- 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 +18 -12
- 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/Accordion/Accordion.js +3 -3
- package/build/module/Accordion/Accordion.js.map +1 -1
- package/build/module/Accordion/useVariantStyleMap.js +6 -2
- package/build/module/Accordion/useVariantStyleMap.js.map +1 -1
- package/build/module/BottomSheetTitle/BottomSheetTitle.js +1 -0
- package/build/module/BottomSheetTitle/BottomSheetTitle.js.map +1 -1
- package/build/module/BottomSheetTitle/BottomSheetTitleProps.js.map +1 -1
- package/build/module/Button/Button.js +11 -9
- package/build/module/Button/Button.js.map +1 -1
- package/build/module/Dialog/Dialog.js +7 -3
- package/build/module/Dialog/Dialog.js.map +1 -1
- package/build/module/Dialog/FullDialogCloseButton.js +42 -0
- package/build/module/Dialog/FullDialogCloseButton.js.map +1 -0
- package/build/module/Dialog/useDialogStyle.js +12 -3
- package/build/module/Dialog/useDialogStyle.js.map +1 -1
- package/build/module/ImageCore/ImageCoreNative.js +1 -1
- package/build/module/ImageCore/ImageCoreNative.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 +18 -12
- 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/BottomSheetTitle/BottomSheetTitleProps.d.ts +1 -0
- package/build/typescript/Dialog/Dialog.d.ts +6 -1
- package/build/typescript/Dialog/FullDialogCloseButton.d.ts +10 -0
- 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 +4 -4
- package/src/Accordion/Accordion.tsx +7 -7
- package/src/Accordion/useVariantStyleMap.ts +4 -0
- package/src/BottomSheetTitle/BottomSheetTitle.tsx +1 -0
- package/src/BottomSheetTitle/BottomSheetTitleProps.ts +1 -0
- package/src/Button/Button.tsx +9 -8
- package/src/Dialog/Dialog.tsx +6 -1
- package/src/Dialog/FullDialogCloseButton.tsx +63 -0
- package/src/Dialog/useDialogStyle.ts +12 -2
- package/src/ImageCore/ImageCoreNative.tsx +1 -1
- 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 +18 -12
- package/src/Tabs/Tabs.tsx +4 -7
- package/src/Tabs/TabsProps.ts +7 -1
- package/src/Tabs/useTabsStyle.ts +14 -6
|
@@ -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,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;;AAWA,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;IAQHC,mBAAmB,EAAE;MACjBC,iBAAiB,EAAEP,KAAK,CAACQ,OAAN,CAAc,CAAd;IADF,CARlB;IAWHC,aAAa,EAAE;MACXC,iBAAiB,EAAEV,KAAK,CAACW,OAAN,CAAcC,MAAd,CAAqBC,IAD7B;MAEXC,iBAAiB,EAAE;IAFR;EAXZ,CAAP;AAgBH,CAnBD;;AAqBA,MAAMC,IAAI,gBAAG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I,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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AK,CAACQ,OAAN,CAAc+E,UAAd,CAAyBC;EAFoB,CAAtD;EAKA,oBACI,oBAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAE;MAAEtC;IAAF;EAAjC,gBACI,oBAAC,IAAD;IACI,KAAK,EAAE/D,GAAG,CAAC,CACPyD,MAAM,CAAC3C,IADA,EAEPoC,cAFO,EAGP;MAAEoD,eAAe,EAAEJ,kBAAkB,CAACrE,KAAD;IAArC,CAHO,EAIPS,WAAW,GAAGmB,MAAM,CAACtC,aAAV,GAA0B2E,SAJ9B,EAKP1D,UAAU,GAAG0D,SAAH,GAAerC,MAAM,CAAC1C,SALzB,EAMPyB,KANO,CAAD;EADd,GAUKJ,UAAU,gBACP,oBAAC,kBAAD;IACI,gCAAgC,EAAE,KADtC;IAEI,OAAO,EAAE,KAFb;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"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type DialogProps from './DialogProps';
|
|
3
|
-
|
|
3
|
+
import FullDialogCloseButton from './FullDialogCloseButton';
|
|
4
|
+
declare const Dialog: {
|
|
5
|
+
(props: DialogProps): JSX.Element;
|
|
6
|
+
FullDialogCloseButton: typeof FullDialogCloseButton;
|
|
7
|
+
};
|
|
8
|
+
export default Dialog;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type { IconButtonProps } from '../IconButton';
|
|
4
|
+
import type { OverridableComponentProps } from '../types';
|
|
5
|
+
interface FullDialogCloseButtonProps extends OverridableComponentProps<ViewProps, {
|
|
6
|
+
onPress: IconButtonProps['onPress'];
|
|
7
|
+
}> {
|
|
8
|
+
}
|
|
9
|
+
export default function FullDialogCloseButton(props: FullDialogCloseButtonProps): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -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.16",
|
|
4
4
|
"author": "Fountain-UI Team",
|
|
5
5
|
"description": "React components that implement Tappytoon's Fountain Design.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"@fountain-ui/utils": "^3.0.0-alpha.1"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
+
"@d11/react-native-fast-image": "^8.11.1",
|
|
21
22
|
"@react-native-community/slider": "^4.1.6",
|
|
22
23
|
"react": "^16.8.0 || ^17.0.0",
|
|
23
24
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
24
25
|
"react-native": "^0.63.0",
|
|
25
|
-
"react-native-fast-image": "8.6.3",
|
|
26
26
|
"react-native-reanimated": "^2.0.0",
|
|
27
27
|
"react-native-safe-area-context": "^4.0.0",
|
|
28
28
|
"react-native-svg": "^13.14.0"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"react-native": {
|
|
38
38
|
"optional": true
|
|
39
39
|
},
|
|
40
|
-
"react-native-fast-image": {
|
|
40
|
+
"@d11/react-native-fast-image": {
|
|
41
41
|
"optional": true
|
|
42
42
|
}
|
|
43
43
|
},
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "7b89ae070ab492f408e51043a2afa60deb607cdd"
|
|
71
71
|
}
|
|
@@ -140,20 +140,20 @@ export default function Accordion(props: AccordionProps) {
|
|
|
140
140
|
/>
|
|
141
141
|
</Row>
|
|
142
142
|
|
|
143
|
-
{subTitle && variant === 'solid' ?
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
<Spacer size={1.5}/>
|
|
143
|
+
{subTitle && variant === 'solid' ? (
|
|
144
|
+
<React.Fragment>
|
|
145
|
+
<Spacer size={1.5}/>
|
|
147
146
|
|
|
147
|
+
{typeof subTitle === 'string' ? (
|
|
148
148
|
<Text
|
|
149
149
|
allowFontScaling={false}
|
|
150
150
|
children={subTitle}
|
|
151
151
|
numberOfLines={1}
|
|
152
152
|
style={subTitleFontStyle}
|
|
153
153
|
/>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
) : (subTitle)}
|
|
155
|
+
</React.Fragment>
|
|
156
|
+
) : null}
|
|
157
157
|
</Column>
|
|
158
158
|
|
|
159
159
|
<Spacer flex={1}/>
|
|
@@ -30,10 +30,12 @@ export default function useVariantStyleMap(variant: AccordionVariant): VariantSt
|
|
|
30
30
|
content: {
|
|
31
31
|
borderTopColor: theme.palette.border.weak,
|
|
32
32
|
borderTopWidth: 0.5,
|
|
33
|
+
left: 0,
|
|
33
34
|
marginHorizontal: theme.spacing(4),
|
|
34
35
|
paddingBottom: theme.spacing(5),
|
|
35
36
|
paddingTop: theme.spacing(4),
|
|
36
37
|
position: 'absolute',
|
|
38
|
+
right: 0,
|
|
37
39
|
},
|
|
38
40
|
contentFont: createFontStyle(theme, {
|
|
39
41
|
selector: (typography) => typography.body3.regular,
|
|
@@ -69,10 +71,12 @@ export default function useVariantStyleMap(variant: AccordionVariant): VariantSt
|
|
|
69
71
|
content: {
|
|
70
72
|
borderTopColor: theme.palette.border.weak,
|
|
71
73
|
borderTopWidth: 0.5,
|
|
74
|
+
left: 0,
|
|
72
75
|
marginHorizontal: theme.spacing(4),
|
|
73
76
|
paddingBottom: theme.spacing(4),
|
|
74
77
|
paddingTop: theme.spacing(3),
|
|
75
78
|
position: 'absolute',
|
|
79
|
+
right: 0,
|
|
76
80
|
},
|
|
77
81
|
contentFont: createFontStyle(theme, {
|
|
78
82
|
selector: (typography) => typography.caption2.regular,
|
|
@@ -72,6 +72,7 @@ export default function BottomSheetTitle(props: BottomSheetTitleProps) {
|
|
|
72
72
|
<Button
|
|
73
73
|
children={actionButtonProps.title}
|
|
74
74
|
color={'accent'}
|
|
75
|
+
disabled={actionButtonProps.disabled ?? false}
|
|
75
76
|
disableMinWidth={true}
|
|
76
77
|
onPress={actionButtonProps.onPress}
|
|
77
78
|
size={'large'}
|
package/src/Button/Button.tsx
CHANGED
|
@@ -27,21 +27,21 @@ const useStyles: UseStyles<ButtonStyles> = function (): ButtonStyles {
|
|
|
27
27
|
width: '100%',
|
|
28
28
|
},
|
|
29
29
|
large: {
|
|
30
|
-
gap:
|
|
30
|
+
gap: 8,
|
|
31
31
|
minWidth: 104,
|
|
32
|
-
paddingHorizontal:
|
|
33
|
-
paddingVertical:
|
|
32
|
+
paddingHorizontal: 24,
|
|
33
|
+
paddingVertical: 14,
|
|
34
34
|
},
|
|
35
35
|
medium: {
|
|
36
|
-
gap:
|
|
36
|
+
gap: 6,
|
|
37
37
|
minWidth: 88,
|
|
38
|
-
paddingHorizontal:
|
|
39
|
-
paddingVertical:
|
|
38
|
+
paddingHorizontal: 16,
|
|
39
|
+
paddingVertical: 11,
|
|
40
40
|
},
|
|
41
41
|
small: {
|
|
42
42
|
minWidth: 64,
|
|
43
|
-
paddingHorizontal:
|
|
44
|
-
paddingVertical:
|
|
43
|
+
paddingHorizontal: 10,
|
|
44
|
+
paddingVertical: 8,
|
|
45
45
|
},
|
|
46
46
|
loadingSpinner: {
|
|
47
47
|
position: 'absolute',
|
|
@@ -134,6 +134,7 @@ export default function Button(props: ButtonProps) {
|
|
|
134
134
|
styles.root,
|
|
135
135
|
containerStyle,
|
|
136
136
|
styles[size],
|
|
137
|
+
(variant === 'capsuleSolid' || variant === 'capsuleOutlined') && size === 'small' ? { paddingHorizontal: 12 } : undefined,
|
|
137
138
|
fullWidth ? styles.fullWidth : undefined,
|
|
138
139
|
disableMinWidth ? { minWidth: 0 } : undefined,
|
|
139
140
|
disablePadding ? { paddingHorizontal: 0, paddingVertical: 0 } : undefined,
|
package/src/Dialog/Dialog.tsx
CHANGED
|
@@ -6,11 +6,12 @@ import Modal, { ANIMATION_TYPE, AnimationUnit } from '../Modal';
|
|
|
6
6
|
import ShadowView from '../ShadowView';
|
|
7
7
|
import type DialogProps from './DialogProps';
|
|
8
8
|
import { DialogProvider } from './DialogContext';
|
|
9
|
+
import FullDialogCloseButton from './FullDialogCloseButton';
|
|
9
10
|
import useDialogStyle from './useDialogStyle';
|
|
10
11
|
|
|
11
12
|
const TOP_ELEMENT_OFFSET = 20;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
const Dialog = (props: DialogProps) => {
|
|
14
15
|
const {
|
|
15
16
|
animationType = ANIMATION_TYPE.SLIDE,
|
|
16
17
|
children,
|
|
@@ -143,3 +144,7 @@ export default function Dialog(props: DialogProps) {
|
|
|
143
144
|
</Modal>
|
|
144
145
|
);
|
|
145
146
|
};
|
|
147
|
+
|
|
148
|
+
Dialog.FullDialogCloseButton = FullDialogCloseButton;
|
|
149
|
+
|
|
150
|
+
export default Dialog;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
|
|
5
|
+
import type { IconButtonProps } from '../IconButton';
|
|
6
|
+
import { css, useTheme } from '../styles';
|
|
7
|
+
import type { OverridableComponentProps } from '../types';
|
|
8
|
+
import IconButton from '../IconButton';
|
|
9
|
+
import { Close } from '../internal';
|
|
10
|
+
|
|
11
|
+
type TabsStyles = NamedStylesStringUnion<'root' | 'button'>;
|
|
12
|
+
|
|
13
|
+
const useStyles: UseStyles<TabsStyles> = function (): TabsStyles {
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
root: {
|
|
18
|
+
paddingBottom: 40,
|
|
19
|
+
paddingTop: 16,
|
|
20
|
+
},
|
|
21
|
+
button: {
|
|
22
|
+
alignSelf: 'center',
|
|
23
|
+
backgroundColor: theme.palette.fill.baseAlt,
|
|
24
|
+
borderRadius: theme.shape.radius.full,
|
|
25
|
+
height: 48,
|
|
26
|
+
width: 48,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
interface FullDialogCloseButtonProps extends OverridableComponentProps<ViewProps, {
|
|
32
|
+
onPress: IconButtonProps['onPress'];
|
|
33
|
+
}> {}
|
|
34
|
+
|
|
35
|
+
export default function FullDialogCloseButton(props: FullDialogCloseButtonProps) {
|
|
36
|
+
const {
|
|
37
|
+
onPress,
|
|
38
|
+
style: styleProp,
|
|
39
|
+
...otherProps
|
|
40
|
+
} = props;
|
|
41
|
+
|
|
42
|
+
const styles = useStyles();
|
|
43
|
+
|
|
44
|
+
const rootStyle = css([
|
|
45
|
+
styles.root,
|
|
46
|
+
styleProp,
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<View
|
|
51
|
+
style={rootStyle}
|
|
52
|
+
{...otherProps}
|
|
53
|
+
>
|
|
54
|
+
<IconButton
|
|
55
|
+
iconSize={'large'}
|
|
56
|
+
onPress={onPress}
|
|
57
|
+
style={styles.button}
|
|
58
|
+
>
|
|
59
|
+
<Close/>
|
|
60
|
+
</IconButton>
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useWindowDimensions } from 'react-native';
|
|
3
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
3
4
|
import type { FountainUiStyle, NamedStylesStringUnion } from '@fountain-ui/styles';
|
|
4
5
|
import { useTheme } from '../styles';
|
|
5
6
|
import type { DialogSize } from './DialogProps';
|
|
@@ -21,6 +22,11 @@ export default function useDialogStyle(size: DialogSize): DialogStyles {
|
|
|
21
22
|
width: windowWidth,
|
|
22
23
|
} = useWindowDimensions();
|
|
23
24
|
|
|
25
|
+
const {
|
|
26
|
+
bottom: bottomSafeAreaInset,
|
|
27
|
+
top: topSafeAreaInset,
|
|
28
|
+
} = useSafeAreaInsets();
|
|
29
|
+
|
|
24
30
|
return useMemo(() => {
|
|
25
31
|
const sizeStyleMap: Record<DialogSize, FountainUiStyle> = {
|
|
26
32
|
small: {
|
|
@@ -34,7 +40,10 @@ export default function useDialogStyle(size: DialogSize): DialogStyles {
|
|
|
34
40
|
minHeight: 360,
|
|
35
41
|
width: 512,
|
|
36
42
|
},
|
|
37
|
-
full: {
|
|
43
|
+
full: {
|
|
44
|
+
paddingBottom: bottomSafeAreaInset,
|
|
45
|
+
paddingTop: topSafeAreaInset,
|
|
46
|
+
},
|
|
38
47
|
};
|
|
39
48
|
|
|
40
49
|
const containerPaddingVertical = 24;
|
|
@@ -62,6 +71,7 @@ export default function useDialogStyle(size: DialogSize): DialogStyles {
|
|
|
62
71
|
backgroundColor: theme.palette.surface.base,
|
|
63
72
|
height: '100%',
|
|
64
73
|
width: '100%',
|
|
74
|
+
...sizeStyleMap[size],
|
|
65
75
|
} : {
|
|
66
76
|
backgroundColor: theme.palette.surface.base,
|
|
67
77
|
borderRadius: theme.shape.radius.xl,
|
|
@@ -80,5 +90,5 @@ export default function useDialogStyle(size: DialogSize): DialogStyles {
|
|
|
80
90
|
width: '100%',
|
|
81
91
|
},
|
|
82
92
|
};
|
|
83
|
-
}, [theme, windowHeight, windowWidth, size]);
|
|
93
|
+
}, [theme, windowHeight, windowWidth, size, bottomSafeAreaInset, topSafeAreaInset]);
|
|
84
94
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useContext } from 'react';
|
|
2
2
|
import { Animated } from 'react-native';
|
|
3
|
-
import FastImage from 'react-native-fast-image';
|
|
3
|
+
import FastImage from '@d11/react-native-fast-image';
|
|
4
4
|
import { useAnimatedValue } from '../hooks';
|
|
5
5
|
import { isNotAndroid12 } from '../utils';
|
|
6
6
|
import type ImageCoreProps from './ImageCoreProps';
|