@fountain-ui/core 3.0.0-alpha.21 → 3.0.0-alpha.22
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 +8 -4
- package/build/commonjs/Accordion/Accordion.js.map +1 -1
- package/build/commonjs/Accordion/AccordionProps.js.map +1 -1
- package/build/commonjs/AppBar/AppBar.js +1 -1
- package/build/commonjs/AppBar/AppBar.js.map +1 -1
- package/build/commonjs/ButtonBase/ButtonBase.js +1 -1
- package/build/commonjs/ButtonBase/ButtonBase.js.map +1 -1
- package/build/commonjs/Image/Image.js +1 -1
- package/build/commonjs/Image/Image.js.map +1 -1
- package/build/commonjs/Pagination/NumberPagination.js +3 -1
- package/build/commonjs/Pagination/NumberPagination.js.map +1 -1
- package/build/commonjs/Tab/useVariantStyleMap.js +1 -1
- package/build/commonjs/Tab/useVariantStyleMap.js.map +1 -1
- package/build/commonjs/Tabs/Tabs.js +7 -4
- package/build/commonjs/Tabs/Tabs.js.map +1 -1
- package/build/commonjs/Tabs/useTabsStyle.js +51 -26
- package/build/commonjs/Tabs/useTabsStyle.js.map +1 -1
- package/build/commonjs/TextField/TextField.js +26 -7
- package/build/commonjs/TextField/TextField.js.map +1 -1
- package/build/commonjs/TextField/useVariantStyleMap.js +6 -9
- package/build/commonjs/TextField/useVariantStyleMap.js.map +1 -1
- package/build/commonjs/hooks/useCollapsibleAppBar.js +2 -9
- package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
- package/build/commonjs/hooks/useFadeInAppBar.js +1 -1
- package/build/commonjs/hooks/useFadeInAppBar.js.map +1 -1
- package/build/commonjs/internal/icons/Clear.js +3 -3
- package/build/commonjs/internal/icons/Clear.js.map +1 -1
- package/build/commonjs/internal/icons/Search.js +2 -2
- package/build/commonjs/internal/icons/Search.js.map +1 -1
- package/build/module/Accordion/Accordion.js +8 -4
- package/build/module/Accordion/Accordion.js.map +1 -1
- package/build/module/Accordion/AccordionProps.js.map +1 -1
- package/build/module/AppBar/AppBar.js +1 -1
- package/build/module/AppBar/AppBar.js.map +1 -1
- package/build/module/ButtonBase/ButtonBase.js +1 -1
- package/build/module/ButtonBase/ButtonBase.js.map +1 -1
- package/build/module/Image/Image.js +1 -1
- package/build/module/Image/Image.js.map +1 -1
- package/build/module/Pagination/NumberPagination.js +3 -1
- package/build/module/Pagination/NumberPagination.js.map +1 -1
- package/build/module/Tab/useVariantStyleMap.js +1 -1
- package/build/module/Tab/useVariantStyleMap.js.map +1 -1
- package/build/module/Tabs/Tabs.js +7 -4
- package/build/module/Tabs/Tabs.js.map +1 -1
- package/build/module/Tabs/useTabsStyle.js +51 -26
- package/build/module/Tabs/useTabsStyle.js.map +1 -1
- package/build/module/TextField/TextField.js +26 -7
- package/build/module/TextField/TextField.js.map +1 -1
- package/build/module/TextField/useVariantStyleMap.js +6 -9
- package/build/module/TextField/useVariantStyleMap.js.map +1 -1
- package/build/module/hooks/useCollapsibleAppBar.js +3 -9
- package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
- package/build/module/hooks/useFadeInAppBar.js +1 -1
- package/build/module/hooks/useFadeInAppBar.js.map +1 -1
- package/build/module/internal/icons/Clear.js +3 -3
- package/build/module/internal/icons/Clear.js.map +1 -1
- package/build/module/internal/icons/Search.js +2 -2
- package/build/module/internal/icons/Search.js.map +1 -1
- package/build/typescript/Accordion/AccordionProps.d.ts +4 -1
- package/build/typescript/Tabs/useTabsStyle.d.ts +2 -1
- package/build/typescript/hooks/useCollapsibleAppBar.d.ts +0 -1
- package/package.json +2 -2
- package/src/Accordion/Accordion.tsx +7 -1
- package/src/Accordion/AccordionProps.ts +4 -2
- package/src/AppBar/AppBar.tsx +1 -1
- package/src/ButtonBase/ButtonBase.tsx +1 -1
- package/src/Image/Image.tsx +1 -1
- package/src/Pagination/NumberPagination.tsx +6 -1
- package/src/Tab/useVariantStyleMap.ts +1 -1
- package/src/Tabs/Tabs.tsx +12 -2
- package/src/Tabs/useTabsStyle.ts +36 -10
- package/src/TextField/TextField.tsx +28 -11
- package/src/TextField/useVariantStyleMap.ts +4 -6
- package/src/hooks/useCollapsibleAppBar.ts +3 -22
- package/src/hooks/useFadeInAppBar.ts +1 -1
- package/src/internal/icons/Clear.tsx +3 -3
- package/src/internal/icons/Search.tsx +2 -2
|
@@ -33,6 +33,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
33
33
|
|
|
34
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
35
|
|
|
36
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
37
|
+
|
|
36
38
|
const ROTATE_HIDE_DEGREE = 0;
|
|
37
39
|
const ROTATE_SHOW_DEGREE = 180;
|
|
38
40
|
const ANIMATION_CONFIG = {
|
|
@@ -64,7 +66,9 @@ function Accordion(props) {
|
|
|
64
66
|
RightIcon,
|
|
65
67
|
LeftComponent,
|
|
66
68
|
isInitialExpanded = false,
|
|
67
|
-
|
|
69
|
+
style: styleProp,
|
|
70
|
+
variant = 'solid',
|
|
71
|
+
...otherProps
|
|
68
72
|
} = props;
|
|
69
73
|
const styles = useStyles();
|
|
70
74
|
const theme = (0, _styles2.useTheme)();
|
|
@@ -116,10 +120,10 @@ function Accordion(props) {
|
|
|
116
120
|
animatedHeight.value = (0, _reactNativeReanimated.withTiming)(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);
|
|
117
121
|
animatedOpacity.value = isExpanded ? (0, _reactNativeReanimated.withDelay)(CONTENT_OPACITY_DELAY_MILLIS, (0, _reactNativeReanimated.withTiming)(1, ANIMATION_CONFIG)) : (0, _reactNativeReanimated.withTiming)(0, ANIMATION_CONFIG);
|
|
118
122
|
}, [isExpanded, contentHeight]);
|
|
119
|
-
const rootStyle = (0, _styles.css)([styles.root, containerStyle]);
|
|
120
|
-
return /*#__PURE__*/_react.default.createElement(_Column.default, {
|
|
123
|
+
const rootStyle = (0, _styles.css)([styles.root, containerStyle, styleProp]);
|
|
124
|
+
return /*#__PURE__*/_react.default.createElement(_Column.default, _extends({
|
|
121
125
|
style: rootStyle
|
|
122
|
-
}, /*#__PURE__*/_react.default.createElement(_ButtonBase.default, {
|
|
126
|
+
}, otherProps), /*#__PURE__*/_react.default.createElement(_ButtonBase.default, {
|
|
123
127
|
onPress: onPress
|
|
124
128
|
}, /*#__PURE__*/_react.default.createElement(_Row.default, {
|
|
125
129
|
style: titleStyle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ROTATE_HIDE_DEGREE","ROTATE_SHOW_DEGREE","ANIMATION_CONFIG","duration","INITIAL_EXPANDED_DELAY_MILLIS","CONTENT_OPACITY_DELAY_MILLIS","useStyles","theme","useTheme","root","marginBottom","spacing","rightIcon","alignItems","height","justifyContent","width","Accordion","props","title","subTitle","content","RightIcon","LeftComponent","isInitialExpanded","variant","styles","CONTENT_MARGIN_HEIGHT","isExpanded","setIsExpanded","useState","shouldInitialExpandedRef","useRef","container","containerStyle","contentStyle","contentFont","contentFontStyle","iconContainer","iconContainerStyle","subTitleFont","subTitleFontStyle","titleStyle","titleFont","titleFontStyle","useVariantStyleMap","rotate","useSharedValue","animatedOpacity","animatedHeight","contentHeight","setContentHeight","animatedChevronDownStyles","useAnimatedStyle","transform","value","animatedContentBackgroundStyles","overflow","animatedContentStyle","opacity","onPress","prev","onLayout","event","nativeEvent","layout","current","setTimeout","useEffect","withTiming","withDelay","rootStyle","css"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { LayoutChangeEvent, Text, View, ViewStyle } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n WithTimingConfig,\n} from 'react-native-reanimated';\nimport { css, NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport { ChevronDown } from '../internal/icons';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Row from '../Row';\nimport Spacer from '../Spacer';\nimport type AccordionProps from './AccordionProps';\nimport type { AccordionVariant } from './AccordionProps';\nimport useVariantStyleMap from './useVariantStyleMap';\n\ntype AccordionStyles = NamedStylesStringUnion<'root' | 'rightIcon'>;\n\nconst ROTATE_HIDE_DEGREE = 0;\nconst ROTATE_SHOW_DEGREE = 180;\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 200 };\nconst INITIAL_EXPANDED_DELAY_MILLIS = 100;\nconst CONTENT_OPACITY_DELAY_MILLIS = 200;\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: { marginBottom: theme.spacing(3) },\n rightIcon: {\n alignItems: 'center',\n height: 32,\n justifyContent: 'center',\n width: 32,\n },\n };\n};\n\nexport default function Accordion(props: AccordionProps) {\n const {\n title,\n subTitle,\n content,\n RightIcon,\n LeftComponent,\n isInitialExpanded = false,\n variant = 'solid' as AccordionVariant,\n } = props;\n\n const styles = useStyles();\n const theme = useTheme();\n const CONTENT_MARGIN_HEIGHT = theme.spacing(2);\n\n const [isExpanded, setIsExpanded] = useState<boolean>(false);\n const shouldInitialExpandedRef = useRef<boolean>(isInitialExpanded);\n\n const {\n container: containerStyle,\n content: contentStyle,\n contentFont: contentFontStyle,\n iconContainer: iconContainerStyle,\n subTitleFont: subTitleFontStyle,\n title: titleStyle,\n titleFont: titleFontStyle,\n } = useVariantStyleMap(variant);\n\n const rotate = useSharedValue(ROTATE_HIDE_DEGREE);\n const animatedOpacity = useSharedValue(0);\n\n const animatedHeight = useSharedValue(0);\n const [contentHeight, setContentHeight] = useState(0);\n\n const animatedChevronDownStyles = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }), []);\n\n const animatedContentBackgroundStyles = useAnimatedStyle(() => ({\n height: animatedHeight.value,\n overflow: 'hidden',\n } as ViewStyle), []);\n\n const animatedContentStyle = useAnimatedStyle(() => ({\n opacity: animatedOpacity.value,\n }), []);\n\n const onPress = () => {\n setIsExpanded(prev => !prev);\n };\n\n const onLayout = (event: LayoutChangeEvent) => {\n const height = event.nativeEvent.layout.height + CONTENT_MARGIN_HEIGHT;\n setContentHeight(height);\n\n if (shouldInitialExpandedRef.current) {\n shouldInitialExpandedRef.current = false;\n setTimeout(() => setIsExpanded(true), INITIAL_EXPANDED_DELAY_MILLIS);\n }\n };\n\n useEffect(() => {\n rotate.value = withTiming(isExpanded ? ROTATE_SHOW_DEGREE : ROTATE_HIDE_DEGREE, ANIMATION_CONFIG);\n\n animatedHeight.value = withTiming(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);\n\n animatedOpacity.value = isExpanded\n ? withDelay(CONTENT_OPACITY_DELAY_MILLIS, withTiming(1, ANIMATION_CONFIG))\n : withTiming(0, ANIMATION_CONFIG);\n }, [isExpanded, contentHeight]);\n\n const rootStyle = css([\n styles.root,\n containerStyle,\n ]);\n\n return (\n <Column style={rootStyle}>\n <ButtonBase onPress={onPress}>\n <Row style={titleStyle}>\n <Column flexShrink={1}>\n <Row alignItems={'center'}>\n {LeftComponent ? (\n <React.Fragment>\n <View style={iconContainerStyle}>\n {LeftComponent}\n </View>\n\n <Spacer size={1.5}/>\n </React.Fragment>\n ) : null}\n\n <Text\n allowFontScaling={false}\n children={title}\n numberOfLines={1}\n style={titleFontStyle}\n />\n </Row>\n\n {subTitle && variant === 'solid' ? (\n <React.Fragment>\n <Spacer size={1.5}/>\n\n {typeof subTitle === 'string' ? (\n <Text\n allowFontScaling={false}\n children={subTitle}\n numberOfLines={1}\n style={subTitleFontStyle}\n />\n ) : (subTitle)}\n </React.Fragment>\n ) : null}\n </Column>\n\n <Spacer flex={1}/>\n\n <Spacer size={3}/>\n\n <Animated.View style={animatedChevronDownStyles}>\n <View style={styles.rightIcon}>\n {RightIcon ? RightIcon : (\n <ChevronDown\n width={16}\n height={16}\n color={'base'}\n />\n )}\n </View>\n </Animated.View>\n </Row>\n </ButtonBase>\n\n <Animated.View style={animatedContentBackgroundStyles}>\n <View\n onLayout={onLayout}\n style={contentStyle}\n >\n <Animated.View style={animatedContentStyle}>\n {typeof content === 'string' ? (\n <Text\n allowFontScaling={false}\n children={content}\n style={contentFontStyle}\n />\n ) : (content)}\n </Animated.View>\n </View>\n </Animated.View>\n </Column>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;;;;;;;AAIA,MAAMA,kBAAkB,GAAG,CAA3B;AACA,MAAMC,kBAAkB,GAAG,GAA3B;AACA,MAAMC,gBAA4C,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAArD;AACA,MAAMC,6BAA6B,GAAG,GAAtC;AACA,MAAMC,4BAA4B,GAAG,GAArC;;AAEA,MAAMC,SAAqC,GAAG,YAA6B;EACvE,MAAMC,KAAK,GAAG,IAAAC,iBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MAAEC,YAAY,EAAEH,KAAK,CAACI,OAAN,CAAc,CAAd;IAAhB,CADH;IAEHC,SAAS,EAAE;MACPC,UAAU,EAAE,QADL;MAEPC,MAAM,EAAE,EAFD;MAGPC,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AS,GAAGA,SAAH,gBACN,6BAAC,kBAAD;IACI,KAAK,EAAE,EADX;IAEI,MAAM,EAAE,EAFZ;IAGI,KAAK,EAAE;EAHX,EAFR,CADJ,CAzCJ,CADJ,CADJ,eAyDI,6BAAC,8BAAD,CAAU,IAAV;IAAe,KAAK,EAAEkC;EAAtB,gBACI,6BAAC,iBAAD;IACI,QAAQ,EAAEM,QADd;IAEI,KAAK,EAAE3B;EAFX,gBAII,6BAAC,8BAAD,CAAU,IAAV;IAAe,KAAK,EAAEuB;EAAtB,GACK,OAAOrC,OAAP,KAAmB,QAAnB,gBACG,6BAAC,iBAAD;IACI,gBAAgB,EAAE,KADtB;IAEI,QAAQ,EAAEA,OAFd;IAGI,KAAK,EAAEgB;EAHX,EADH,GAMIhB,OAPT,CAJJ,CADJ,CAzDJ,CADJ;AA4EH"}
|
|
1
|
+
{"version":3,"names":["ROTATE_HIDE_DEGREE","ROTATE_SHOW_DEGREE","ANIMATION_CONFIG","duration","INITIAL_EXPANDED_DELAY_MILLIS","CONTENT_OPACITY_DELAY_MILLIS","useStyles","theme","useTheme","root","marginBottom","spacing","rightIcon","alignItems","height","justifyContent","width","Accordion","props","title","subTitle","content","RightIcon","LeftComponent","isInitialExpanded","style","styleProp","variant","otherProps","styles","CONTENT_MARGIN_HEIGHT","isExpanded","setIsExpanded","useState","shouldInitialExpandedRef","useRef","container","containerStyle","contentStyle","contentFont","contentFontStyle","iconContainer","iconContainerStyle","subTitleFont","subTitleFontStyle","titleStyle","titleFont","titleFontStyle","useVariantStyleMap","rotate","useSharedValue","animatedOpacity","animatedHeight","contentHeight","setContentHeight","animatedChevronDownStyles","useAnimatedStyle","transform","value","animatedContentBackgroundStyles","overflow","animatedContentStyle","opacity","onPress","prev","onLayout","event","nativeEvent","layout","current","setTimeout","useEffect","withTiming","withDelay","rootStyle","css"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { LayoutChangeEvent, Text, View, ViewStyle } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n WithTimingConfig,\n} from 'react-native-reanimated';\nimport { css, NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport { ChevronDown } from '../internal/icons';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Row from '../Row';\nimport Spacer from '../Spacer';\nimport type AccordionProps from './AccordionProps';\nimport type { AccordionVariant } from './AccordionProps';\nimport useVariantStyleMap from './useVariantStyleMap';\n\ntype AccordionStyles = NamedStylesStringUnion<'root' | 'rightIcon'>;\n\nconst ROTATE_HIDE_DEGREE = 0;\nconst ROTATE_SHOW_DEGREE = 180;\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 200 };\nconst INITIAL_EXPANDED_DELAY_MILLIS = 100;\nconst CONTENT_OPACITY_DELAY_MILLIS = 200;\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: { marginBottom: theme.spacing(3) },\n rightIcon: {\n alignItems: 'center',\n height: 32,\n justifyContent: 'center',\n width: 32,\n },\n };\n};\n\nexport default function Accordion(props: AccordionProps) {\n const {\n title,\n subTitle,\n content,\n RightIcon,\n LeftComponent,\n isInitialExpanded = false,\n style: styleProp,\n variant = 'solid' as AccordionVariant,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n const theme = useTheme();\n const CONTENT_MARGIN_HEIGHT = theme.spacing(2);\n\n const [isExpanded, setIsExpanded] = useState<boolean>(false);\n const shouldInitialExpandedRef = useRef<boolean>(isInitialExpanded);\n\n const {\n container: containerStyle,\n content: contentStyle,\n contentFont: contentFontStyle,\n iconContainer: iconContainerStyle,\n subTitleFont: subTitleFontStyle,\n title: titleStyle,\n titleFont: titleFontStyle,\n } = useVariantStyleMap(variant);\n\n const rotate = useSharedValue(ROTATE_HIDE_DEGREE);\n const animatedOpacity = useSharedValue(0);\n\n const animatedHeight = useSharedValue(0);\n const [contentHeight, setContentHeight] = useState(0);\n\n const animatedChevronDownStyles = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }), []);\n\n const animatedContentBackgroundStyles = useAnimatedStyle(() => ({\n height: animatedHeight.value,\n overflow: 'hidden',\n } as ViewStyle), []);\n\n const animatedContentStyle = useAnimatedStyle(() => ({\n opacity: animatedOpacity.value,\n }), []);\n\n const onPress = () => {\n setIsExpanded(prev => !prev);\n };\n\n const onLayout = (event: LayoutChangeEvent) => {\n const height = event.nativeEvent.layout.height + CONTENT_MARGIN_HEIGHT;\n setContentHeight(height);\n\n if (shouldInitialExpandedRef.current) {\n shouldInitialExpandedRef.current = false;\n setTimeout(() => setIsExpanded(true), INITIAL_EXPANDED_DELAY_MILLIS);\n }\n };\n\n useEffect(() => {\n rotate.value = withTiming(isExpanded ? ROTATE_SHOW_DEGREE : ROTATE_HIDE_DEGREE, ANIMATION_CONFIG);\n\n animatedHeight.value = withTiming(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);\n\n animatedOpacity.value = isExpanded\n ? withDelay(CONTENT_OPACITY_DELAY_MILLIS, withTiming(1, ANIMATION_CONFIG))\n : withTiming(0, ANIMATION_CONFIG);\n }, [isExpanded, contentHeight]);\n\n const rootStyle = css([\n styles.root,\n containerStyle,\n styleProp,\n ]);\n\n return (\n <Column\n style={rootStyle}\n {...otherProps}\n >\n <ButtonBase onPress={onPress}>\n <Row style={titleStyle}>\n <Column flexShrink={1}>\n <Row alignItems={'center'}>\n {LeftComponent ? (\n <React.Fragment>\n <View style={iconContainerStyle}>\n {LeftComponent}\n </View>\n\n <Spacer size={1.5}/>\n </React.Fragment>\n ) : null}\n\n <Text\n allowFontScaling={false}\n children={title}\n numberOfLines={1}\n style={titleFontStyle}\n />\n </Row>\n\n {subTitle && variant === 'solid' ? (\n <React.Fragment>\n <Spacer size={1.5}/>\n\n {typeof subTitle === 'string' ? (\n <Text\n allowFontScaling={false}\n children={subTitle}\n numberOfLines={1}\n style={subTitleFontStyle}\n />\n ) : (subTitle)}\n </React.Fragment>\n ) : null}\n </Column>\n\n <Spacer flex={1}/>\n\n <Spacer size={3}/>\n\n <Animated.View style={animatedChevronDownStyles}>\n <View style={styles.rightIcon}>\n {RightIcon ? RightIcon : (\n <ChevronDown\n width={16}\n height={16}\n color={'base'}\n />\n )}\n </View>\n </Animated.View>\n </Row>\n </ButtonBase>\n\n <Animated.View style={animatedContentBackgroundStyles}>\n <View\n onLayout={onLayout}\n style={contentStyle}\n >\n <Animated.View style={animatedContentStyle}>\n {typeof content === 'string' ? (\n <Text\n allowFontScaling={false}\n children={content}\n style={contentFontStyle}\n />\n ) : (content)}\n </Animated.View>\n </View>\n </Animated.View>\n </Column>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;;;;;;;;;AAIA,MAAMA,kBAAkB,GAAG,CAA3B;AACA,MAAMC,kBAAkB,GAAG,GAA3B;AACA,MAAMC,gBAA4C,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAArD;AACA,MAAMC,6BAA6B,GAAG,GAAtC;AACA,MAAMC,4BAA4B,GAAG,GAArC;;AAEA,MAAMC,SAAqC,GAAG,YAA6B;EACvE,MAAMC,KAAK,GAAG,IAAAC,iBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MAAEC,YAAY,EAAEH,KAAK,CAACI,OAAN,CAAc,CAAd;IAAhB,CADH;IAEHC,SAAS,EAAE;MACPC,UAAU,EAAE,QADL;MAEPC,MAAM,EAAE,EAFD;MAGPC,cAAc,EAAE,QAHT;MAIPC,KAAK,EAAE;IAJA;EAFR,CAAP;AASH,CAZD;;AAce,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,KADE;IAEFC,QAFE;IAGFC,OAHE;IAIFC,SAJE;IAKFC,aALE;IAMFC,iBAAiB,GAAG,KANlB;IAOFC,KAAK,EAAEC,SAPL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CAAU,IAAV;IAAe,KAAK,EAAEqC;EAAtB,gBACI,6BAAC,iBAAD;IACI,QAAQ,EAAEM,QADd;IAEI,KAAK,EAAE3B;EAFX,gBAII,6BAAC,8BAAD,CAAU,IAAV;IAAe,KAAK,EAAEuB;EAAtB,GACK,OAAOxC,OAAP,KAAmB,QAAnB,gBACG,6BAAC,iBAAD;IACI,gBAAgB,EAAE,KADtB;IAEI,QAAQ,EAAEA,OAFd;IAGI,KAAK,EAAEmB;EAHX,EADH,GAMInB,OAPT,CAJJ,CADJ,CA5DJ,CADJ;AA+EH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["accordionVariants"],"sources":["AccordionProps.ts"],"sourcesContent":["import React from 'react';\n\nexport const accordionVariants = ['solid', 'line', 'underline'] as const;\nexport type AccordionVariant = typeof accordionVariants[number];\n\nexport default interface AccordionProps {\n /**\n * The title of the component.\n */\n title: string | React.ReactNode;\n\n /**\n * The subtitle of the component. (Only for solid variant)\n */\n subTitle?: string | React.ReactNode;\n\n /**\n * The component to the left of the title.\n */\n LeftComponent?: React.ReactNode;\n\n /**\n * The icon to the right of the title.\n */\n RightIcon?: React.ReactElement;\n\n /**\n * The content of the component.\n */\n content: string | React.ReactNode;\n\n /**\n * The initial state of expanding\n * @default false\n */\n isInitialExpanded?: boolean;\n\n /**\n * Determines design variations of the component.\n * @default 'solid'\n */\n variant: AccordionVariant;\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["accordionVariants"],"sources":["AccordionProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ColumnProps } from '../Column';\nimport type { OverridableComponentProps } from '../types';\n\nexport const accordionVariants = ['solid', 'line', 'underline'] as const;\nexport type AccordionVariant = typeof accordionVariants[number];\n\nexport default interface AccordionProps extends OverridableComponentProps<Omit<ColumnProps, 'children'>, {\n /**\n * The title of the component.\n */\n title: string | React.ReactNode;\n\n /**\n * The subtitle of the component. (Only for solid variant)\n */\n subTitle?: string | React.ReactNode;\n\n /**\n * The component to the left of the title.\n */\n LeftComponent?: React.ReactNode;\n\n /**\n * The icon to the right of the title.\n */\n RightIcon?: React.ReactElement;\n\n /**\n * The content of the component.\n */\n content: string | React.ReactNode;\n\n /**\n * The initial state of expanding\n * @default false\n */\n isInitialExpanded?: boolean;\n\n /**\n * Determines design variations of the component.\n * @default 'solid'\n */\n variant: AccordionVariant;\n}> {}\n"],"mappings":";;;;;;AAIO,MAAMA,iBAAiB,GAAG,CAAC,OAAD,EAAU,MAAV,EAAkB,WAAlB,CAA1B"}
|
|
@@ -39,7 +39,7 @@ const AppBar = /*#__PURE__*/_react.default.forwardRef(function AppBar(props, ref
|
|
|
39
39
|
const isDesktop = (0, _hooks.useBreakpointUp)('md', true, false);
|
|
40
40
|
const styles = useStyles();
|
|
41
41
|
const backgroundColorMap = {
|
|
42
|
-
default: theme.palette.background.
|
|
42
|
+
default: theme.palette.background.base,
|
|
43
43
|
alt: theme.palette.background.alt
|
|
44
44
|
};
|
|
45
45
|
const paperStyle = (0, _styles.css)([styles.root, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useStyles","theme","useTheme","root","flexDirection","flexShrink","width","zIndex","appBar","AppBar","React","forwardRef","props","ref","color","style","otherProps","isDesktop","useBreakpointUp","styles","backgroundColorMap","default","palette","background","alt","paperStyle","css","backgroundColor","paddingHorizontal","undefined"],"sources":["AppBar.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useBreakpointUp } from '../hooks';\nimport { css, useTheme } from '../styles';\nimport type AppBarProps from './AppBarProps';\nimport type { AppBarColor } from './AppBarProps';\n\ntype AppBarStyleKeys = 'root';\n\ntype AppBarStyles = NamedStylesStringUnion<AppBarStyleKeys>;\n\nconst useStyles: UseStyles<AppBarStyles> = function (): AppBarStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'column',\n flexShrink: 0,\n width: '100%',\n zIndex: theme.zIndex.appBar,\n },\n };\n};\n\nconst AppBar = React.forwardRef<View, AppBarProps>(function AppBar(props, ref) {\n const {\n color = 'default',\n style,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const isDesktop = useBreakpointUp('md', true, false);\n\n const styles = useStyles();\n\n const backgroundColorMap: Record<AppBarColor, string> = {\n default: theme.palette.background.
|
|
1
|
+
{"version":3,"names":["useStyles","theme","useTheme","root","flexDirection","flexShrink","width","zIndex","appBar","AppBar","React","forwardRef","props","ref","color","style","otherProps","isDesktop","useBreakpointUp","styles","backgroundColorMap","default","palette","background","base","alt","paperStyle","css","backgroundColor","paddingHorizontal","undefined"],"sources":["AppBar.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useBreakpointUp } from '../hooks';\nimport { css, useTheme } from '../styles';\nimport type AppBarProps from './AppBarProps';\nimport type { AppBarColor } from './AppBarProps';\n\ntype AppBarStyleKeys = 'root';\n\ntype AppBarStyles = NamedStylesStringUnion<AppBarStyleKeys>;\n\nconst useStyles: UseStyles<AppBarStyles> = function (): AppBarStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'column',\n flexShrink: 0,\n width: '100%',\n zIndex: theme.zIndex.appBar,\n },\n };\n};\n\nconst AppBar = React.forwardRef<View, AppBarProps>(function AppBar(props, ref) {\n const {\n color = 'default',\n style,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const isDesktop = useBreakpointUp('md', true, false);\n\n const styles = useStyles();\n\n const backgroundColorMap: Record<AppBarColor, string> = {\n default: theme.palette.background.base,\n alt: theme.palette.background.alt,\n };\n\n const paperStyle = css([\n styles.root,\n { backgroundColor: backgroundColorMap[color] },\n isDesktop ? { paddingHorizontal: 8 } : undefined,\n style,\n ]);\n\n return (\n <View\n ref={ref}\n style={paperStyle}\n {...otherProps}\n />\n );\n});\n\nexport default AppBar;\n"],"mappings":";;;;;;;AAAA;;AACA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26
26
|
exports.ORIGINAL_OPACITY = ORIGINAL_OPACITY;
|
|
27
27
|
const ACTIVE_OPACITY = .65;
|
|
28
28
|
const ORIGINAL_SCALE = 1;
|
|
29
|
-
const MINIFIED_SCALE = .
|
|
29
|
+
const MINIFIED_SCALE = .98; // at "node_modules/react-native/Libraries/Pressability.js"
|
|
30
30
|
// const DEFAULT_MIN_PRESS_DURATION = 130;
|
|
31
31
|
|
|
32
32
|
const SCALE_EFFECT_PRESS_IN_DELAY = 130;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ORIGINAL_OPACITY","ACTIVE_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","SCALE_EFFECT_PRESS_IN_DELAY","OPACITY_EFFECT_PRESS_IN_DELAY","startTimingAnimationWithDefaults","value","toValue","Animated","timing","duration","useNativeDriver","isNotAndroid12","start","ButtonBase","props","children","disabled","disableThrottle","onPress","_onPress","onPressOut","pressEffect","pressDelay","pressDelayOrNil","style","styleProp","throttleMillis","otherProps","useCallback","handlePress","useThrottle","periodMillis","callback","opacity","useAnimatedValue","scale","startScaleAnimation","pressIn","isHover","startOpacityAnimation","setValue","startPressAnimation","handlePressIn","handlePressOut","animatedStyle","transform","defaultPressDelay","hovered","undefined"],"sources":["ButtonBase.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\nimport { Animated } from 'react-native';\nimport { useAnimatedValue, useThrottle } from '../hooks';\nimport { isNotAndroid12 } from '../utils';\nimport { AnimatedPressable } from '../animated';\nimport type ButtonBaseProps from './ButtonBaseProps';\n\ninterface StartPressAnimation {\n (pressIn: boolean, isHover: boolean): void;\n}\n\nexport const ORIGINAL_OPACITY = 1;\nconst ACTIVE_OPACITY = .65;\n\nconst ORIGINAL_SCALE = 1;\nconst MINIFIED_SCALE = .
|
|
1
|
+
{"version":3,"names":["ORIGINAL_OPACITY","ACTIVE_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","SCALE_EFFECT_PRESS_IN_DELAY","OPACITY_EFFECT_PRESS_IN_DELAY","startTimingAnimationWithDefaults","value","toValue","Animated","timing","duration","useNativeDriver","isNotAndroid12","start","ButtonBase","props","children","disabled","disableThrottle","onPress","_onPress","onPressOut","pressEffect","pressDelay","pressDelayOrNil","style","styleProp","throttleMillis","otherProps","useCallback","handlePress","useThrottle","periodMillis","callback","opacity","useAnimatedValue","scale","startScaleAnimation","pressIn","isHover","startOpacityAnimation","setValue","startPressAnimation","handlePressIn","handlePressOut","animatedStyle","transform","defaultPressDelay","hovered","undefined"],"sources":["ButtonBase.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\nimport { Animated } from 'react-native';\nimport { useAnimatedValue, useThrottle } from '../hooks';\nimport { isNotAndroid12 } from '../utils';\nimport { AnimatedPressable } from '../animated';\nimport type ButtonBaseProps from './ButtonBaseProps';\n\ninterface StartPressAnimation {\n (pressIn: boolean, isHover: boolean): void;\n}\n\nexport const ORIGINAL_OPACITY = 1;\nconst ACTIVE_OPACITY = .65;\n\nconst ORIGINAL_SCALE = 1;\nconst MINIFIED_SCALE = .98;\n\n// at \"node_modules/react-native/Libraries/Pressability.js\"\n// const DEFAULT_MIN_PRESS_DURATION = 130;\nconst SCALE_EFFECT_PRESS_IN_DELAY = 130;\nconst OPACITY_EFFECT_PRESS_IN_DELAY = 0;\n\ntype TimingAnimationValue = Animated.Value | Animated.ValueXY;\ntype TimingAnimationToValue = Animated.TimingAnimationConfig['toValue'];\n\nconst startTimingAnimationWithDefaults = (\n value: TimingAnimationValue,\n toValue: TimingAnimationToValue,\n) => {\n Animated.timing(value, {\n toValue,\n duration: 150,\n useNativeDriver: isNotAndroid12,\n }).start();\n};\n\nexport default function ButtonBase(props: ButtonBaseProps) {\n const {\n children,\n disabled = false,\n disableThrottle = false,\n onPress: _onPress,\n onPressOut,\n pressEffect = 'opacity',\n pressDelay: pressDelayOrNil,\n style: styleProp,\n throttleMillis = 650,\n ...otherProps\n } = props;\n\n const onPress = useCallback(() => _onPress?.(), [_onPress]);\n const handlePress = useThrottle({\n periodMillis: disableThrottle ? 0 : throttleMillis,\n callback: onPress,\n });\n\n const opacity = useAnimatedValue(ORIGINAL_OPACITY);\n const scale = useAnimatedValue(ORIGINAL_SCALE);\n\n const startScaleAnimation = useCallback<StartPressAnimation>((pressIn, isHover) => {\n if (!isHover) {\n startTimingAnimationWithDefaults(\n scale,\n pressIn ? MINIFIED_SCALE : ORIGINAL_SCALE,\n );\n }\n }, []);\n\n const startOpacityAnimation = useCallback<StartPressAnimation>((pressIn) => {\n if (pressIn) {\n opacity.setValue(ACTIVE_OPACITY);\n } else {\n startTimingAnimationWithDefaults(opacity, ORIGINAL_OPACITY);\n }\n }, []);\n\n const startPressAnimation = useCallback<StartPressAnimation>((pressIn, isHover = false) => {\n if (pressEffect === 'scale') {\n startScaleAnimation(pressIn, isHover);\n } else if (pressEffect === 'opacity') {\n startOpacityAnimation(pressIn, isHover);\n }\n }, [pressEffect]);\n\n const handlePressIn = useCallback(() => {\n startPressAnimation(true, false);\n }, [startPressAnimation]);\n\n const handlePressOut = useCallback(() => {\n onPressOut && onPressOut();\n\n startPressAnimation(false, false);\n }, [startPressAnimation, onPressOut]);\n\n const animatedStyle = {\n opacity,\n transform: [{ scale }],\n };\n\n const defaultPressDelay = pressEffect === 'scale'\n ? SCALE_EFFECT_PRESS_IN_DELAY\n : OPACITY_EFFECT_PRESS_IN_DELAY;\n const pressDelay = pressDelayOrNil ?? defaultPressDelay;\n\n return (\n <AnimatedPressable\n disabled={disabled}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n style={[\n animatedStyle,\n styleProp,\n ]}\n unstable_pressDelay={pressDelay}\n {...otherProps}\n >\n {typeof children !== 'function' ? (\n ({ hovered }) => {\n if (hovered !== undefined && !disabled) {\n startPressAnimation(hovered, true);\n }\n\n return children;\n }\n ) : children}\n </AnimatedPressable>\n );\n};\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAOO,MAAMA,gB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AAe,IAAIuB,iBAAtC;EAEA,oBACI,6BAAC,2BAAD;IACI,QAAQ,EAAE9B,QADd;IAEI,OAAO,EAAEa,WAFb;IAGI,SAAS,EAAEa,aAHf;IAII,UAAU,EAAEC,cAJhB;IAKI,KAAK,EAAE,CACHC,aADG,EAEHnB,SAFG,CALX;IASI,mBAAmB,EAAEH;EATzB,GAUQK,UAVR,GAYK,OAAOZ,QAAP,KAAoB,UAApB,GACG,QAAiB;IAAA,IAAhB;MAAEgC;IAAF,CAAgB;;IACb,IAAIA,OAAO,KAAKC,SAAZ,IAAyB,CAAChC,QAA9B,EAAwC;MACpCyB,mBAAmB,CAACM,OAAD,EAAU,IAAV,CAAnB;IACH;;IAED,OAAOhC,QAAP;EACH,CAPJ,GAQGA,QApBR,CADJ;AAwBH;;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useStyles","theme","useTheme","root","rounded","borderRadius","shape","roundness","overflow","placeholder","backgroundColor","palette","paper","grey","outlined","borderWidth","StyleSheet","hairlineWidth","borderStyle","borderColor","error","alignItems","height","justifyContent","width","errorText","color","text","primary","fontFamily","fontSize","letterSpacing","lineHeight","textAlign","determinePlaceholderMode","props","disablePlaceholder","Image","alt","cache","disableDrag","disableLongClick","disableOutline","loading","onError","onErrorProp","onLoad","onLoadProp","overlaidChildren","resizeMode","source","style","square","otherProps","failed","setFailed","useState","styles","placeholderMode","css","undefined","absoluteFill","zIndex","uri"],"sources":["Image.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Text, View } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport type { ImageCoreProps } from '../ImageCore';\nimport ImageCore from '../ImageCore';\nimport { css, StyleSheet, useTheme } from '../styles';\nimport type ImageProps from './ImageProps';\n\ntype PlaceholderMode =\n | 'default'\n | 'custom'\n | 'none';\n\ntype ImageStyleKeys =\n | 'root'\n | 'rounded'\n | 'placeholder'\n | 'outlined'\n | 'error'\n | 'errorText';\n\ntype ImageStyles = NamedStylesStringUnion<ImageStyleKeys>;\n\nconst useStyles: UseStyles<ImageStyles> = function (): ImageStyles {\n const theme = useTheme();\n\n return {\n root: {},\n rounded: {\n borderRadius: theme.shape.roundness,\n overflow: 'hidden',\n },\n placeholder: {\n backgroundColor: theme.palette.paper.grey,\n },\n outlined: {\n borderWidth: StyleSheet.hairlineWidth,\n borderStyle: 'solid',\n borderColor: theme.palette.
|
|
1
|
+
{"version":3,"names":["useStyles","theme","useTheme","root","rounded","borderRadius","shape","roundness","overflow","placeholder","backgroundColor","palette","paper","grey","outlined","borderWidth","StyleSheet","hairlineWidth","borderStyle","borderColor","border","weak","error","alignItems","height","justifyContent","width","errorText","color","text","primary","fontFamily","fontSize","letterSpacing","lineHeight","textAlign","determinePlaceholderMode","props","disablePlaceholder","Image","alt","cache","disableDrag","disableLongClick","disableOutline","loading","onError","onErrorProp","onLoad","onLoadProp","overlaidChildren","resizeMode","source","style","square","otherProps","failed","setFailed","useState","styles","placeholderMode","css","undefined","absoluteFill","zIndex","uri"],"sources":["Image.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Text, View } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport type { ImageCoreProps } from '../ImageCore';\nimport ImageCore from '../ImageCore';\nimport { css, StyleSheet, useTheme } from '../styles';\nimport type ImageProps from './ImageProps';\n\ntype PlaceholderMode =\n | 'default'\n | 'custom'\n | 'none';\n\ntype ImageStyleKeys =\n | 'root'\n | 'rounded'\n | 'placeholder'\n | 'outlined'\n | 'error'\n | 'errorText';\n\ntype ImageStyles = NamedStylesStringUnion<ImageStyleKeys>;\n\nconst useStyles: UseStyles<ImageStyles> = function (): ImageStyles {\n const theme = useTheme();\n\n return {\n root: {},\n rounded: {\n borderRadius: theme.shape.roundness,\n overflow: 'hidden',\n },\n placeholder: {\n backgroundColor: theme.palette.paper.grey,\n },\n outlined: {\n borderWidth: StyleSheet.hairlineWidth,\n borderStyle: 'solid',\n borderColor: theme.palette.border.weak,\n },\n error: {\n alignItems: 'center',\n height: '100%',\n justifyContent: 'center',\n width: '100%',\n },\n errorText: {\n color: theme.palette.text.primary,\n fontFamily: 'Inter-Medium',\n fontSize: 12,\n letterSpacing: 0,\n lineHeight: 18,\n textAlign: 'center',\n },\n };\n};\n\nfunction determinePlaceholderMode(props: ImageProps): PlaceholderMode {\n if (props.disablePlaceholder) {\n return 'none';\n }\n\n return props.placeholder ? 'custom' : 'default';\n}\n\nexport default function Image(props: ImageProps) {\n const {\n alt,\n cache = 'immutable',\n disableDrag,\n disableLongClick,\n disableOutline,\n disablePlaceholder,\n error,\n loading = 'lazy',\n onError: onErrorProp,\n onLoad: onLoadProp,\n overlaidChildren,\n placeholder,\n resizeMode = 'cover',\n source,\n style,\n square = false,\n ...otherProps\n } = props;\n\n const [failed, setFailed] = useState(false);\n\n const styles = useStyles();\n\n const onLoad: ImageCoreProps['onLoad'] = () => {\n setFailed(false);\n\n onLoadProp?.();\n };\n\n const onError: ImageCoreProps['onError'] = () => {\n setFailed(true);\n\n onErrorProp?.();\n };\n\n const placeholderMode = determinePlaceholderMode(props);\n\n return (\n <View\n style={css([\n styles.root,\n !disableOutline ? styles.outlined : undefined,\n !square ? styles.rounded : undefined,\n placeholderMode === 'default' ? styles.placeholder : undefined,\n style,\n ])}\n {...otherProps}\n >\n {placeholderMode === 'custom' ? (\n <View\n style={css([\n StyleSheet.absoluteFill,\n { zIndex: -1 },\n ])}\n >\n {placeholder}\n </View>\n ) : null}\n\n {failed ? (\n <View style={styles.error}>\n {error ?? (\n <Text\n children={alt}\n style={styles.errorText}\n />\n )}\n </View>\n ) : source.uri ? (\n <ImageCore\n alt={alt}\n cache={cache}\n disableDrag={disableDrag}\n disableLongClick={disableLongClick}\n height={'100%'}\n loading={loading}\n onError={onError}\n onLoad={onLoad}\n resizeMode={resizeMode}\n source={source}\n width={'100%'}\n />\n ) : null}\n\n {overlaidChildren ? (\n <View style={StyleSheet.absoluteFill}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C,iBAAD;IAAM,KAAK,EAAEG,MAAM,CAACrC;EAApB,GACKA,KAAK,iBACF,6BAAC,iBAAD;IACI,QAAQ,EAAEkB,GADd;IAEI,KAAK,EAAEmB,MAAM,CAAChC;EAFlB,EAFR,CADG,GASHyB,MAAM,CAACa,GAAP,gBACA,6BAAC,kBAAD;IACI,GAAG,EAAEzB,GADT;IAEI,KAAK,EAAEC,KAFX;IAGI,WAAW,EAAEC,WAHjB;IAII,gBAAgB,EAAEC,gBAJtB;IAKI,MAAM,EAAE,MALZ;IAMI,OAAO,EAAEE,OANb;IAOI,OAAO,EAAEC,OAPb;IAQI,MAAM,EAAEE,MARZ;IASI,UAAU,EAAEG,UAThB;IAUI,MAAM,EAAEC,MAVZ;IAWI,KAAK,EAAE;EAXX,EADA,GAcA,IA5CR,EA8CKF,gBAAgB,gBACb,6BAAC,iBAAD;IAAM,KAAK,EAAElC,kBAAA,CAAW+C;EAAxB,GACKb,gBADL,CADa,GAIb,IAlDR,CADJ;AAsDH;;AAAA"}
|
|
@@ -60,7 +60,9 @@ function NumberPagination(props) {
|
|
|
60
60
|
return /*#__PURE__*/_react.default.createElement(_Row.default, {
|
|
61
61
|
style: styles.root
|
|
62
62
|
}, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
63
|
-
style: currentFontStyle
|
|
63
|
+
style: [currentFontStyle, {
|
|
64
|
+
fontVariant: ['tabular-nums']
|
|
65
|
+
}]
|
|
64
66
|
}, currentPage + 1), /*#__PURE__*/_react.default.createElement(_Divider.default, {
|
|
65
67
|
style: styles.divider,
|
|
66
68
|
vertical: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useStyles","theme","useTheme","root","backgroundColor","commonColors","static","weakOpacity","borderRadius","shape","radius","full","paddingHorizontal","spacing","paddingVertical","divider","alignSelf","borderColor","weakOpacityInverse","height","NumberPagination","props","currentPage","maxPage","styles","typography","typographyOf","fontSize","lineHeight","fontFamily","letterSpacing","currentFontStyle","createFontStyle","selector","_","color","strongInverse","countFontStyle","baseOpacityInverse"],"sources":["NumberPagination.tsx"],"sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { commonColors, typographyOf } from '@fountain-ui/styles';\nimport Divider from '../Divider';\nimport Row from '../Row';\nimport { createFontStyle, useTheme } from '../styles';\nimport type PaginationProps from './PaginationProps';\n\ntype NumberPaginationStyles = NamedStylesStringUnion<'root' | 'divider'>;\n\nconst useStyles: UseStyles<NumberPaginationStyles> = function (): NumberPaginationStyles {\n const theme = useTheme();\n\n return {\n root: {\n backgroundColor: commonColors.static.weakOpacity,\n borderRadius: theme.shape.radius.full,\n paddingHorizontal: theme.spacing(1.25),\n paddingVertical: theme.spacing(0.5),\n },\n divider: {\n alignSelf: 'center',\n borderColor: commonColors.static.weakOpacityInverse,\n height: 6,\n },\n };\n};\n\ninterface NumberPaginationProps {\n currentPage: PaginationProps['page'];\n maxPage: PaginationProps['count'];\n}\n\nexport default function NumberPagination(props: NumberPaginationProps) {\n const {\n currentPage,\n maxPage,\n } = props;\n\n const styles = useStyles();\n\n const theme = useTheme();\n\n const typography = typographyOf({\n fontSize: 9.5,\n lineHeight: 11.4,\n fontFamily: 'PretendardStd-SemiBold',\n letterSpacing: -0.19,\n });\n\n const currentFontStyle = createFontStyle(theme, {\n selector: (_) => typography,\n color: commonColors.static.strongInverse,\n });\n\n const countFontStyle = createFontStyle(theme, {\n selector: (_) => typography,\n color: commonColors.static.baseOpacityInverse,\n });\n\n return (\n <Row style={styles.root}>\n <Text
|
|
1
|
+
{"version":3,"names":["useStyles","theme","useTheme","root","backgroundColor","commonColors","static","weakOpacity","borderRadius","shape","radius","full","paddingHorizontal","spacing","paddingVertical","divider","alignSelf","borderColor","weakOpacityInverse","height","NumberPagination","props","currentPage","maxPage","styles","typography","typographyOf","fontSize","lineHeight","fontFamily","letterSpacing","currentFontStyle","createFontStyle","selector","_","color","strongInverse","countFontStyle","baseOpacityInverse","fontVariant"],"sources":["NumberPagination.tsx"],"sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { commonColors, typographyOf } from '@fountain-ui/styles';\nimport Divider from '../Divider';\nimport Row from '../Row';\nimport { createFontStyle, useTheme } from '../styles';\nimport type PaginationProps from './PaginationProps';\n\ntype NumberPaginationStyles = NamedStylesStringUnion<'root' | 'divider'>;\n\nconst useStyles: UseStyles<NumberPaginationStyles> = function (): NumberPaginationStyles {\n const theme = useTheme();\n\n return {\n root: {\n backgroundColor: commonColors.static.weakOpacity,\n borderRadius: theme.shape.radius.full,\n paddingHorizontal: theme.spacing(1.25),\n paddingVertical: theme.spacing(0.5),\n },\n divider: {\n alignSelf: 'center',\n borderColor: commonColors.static.weakOpacityInverse,\n height: 6,\n },\n };\n};\n\ninterface NumberPaginationProps {\n currentPage: PaginationProps['page'];\n maxPage: PaginationProps['count'];\n}\n\nexport default function NumberPagination(props: NumberPaginationProps) {\n const {\n currentPage,\n maxPage,\n } = props;\n\n const styles = useStyles();\n\n const theme = useTheme();\n\n const typography = typographyOf({\n fontSize: 9.5,\n lineHeight: 11.4,\n fontFamily: 'PretendardStd-SemiBold',\n letterSpacing: -0.19,\n });\n\n const currentFontStyle = createFontStyle(theme, {\n selector: (_) => typography,\n color: commonColors.static.strongInverse,\n });\n\n const countFontStyle = createFontStyle(theme, {\n selector: (_) => typography,\n color: commonColors.static.baseOpacityInverse,\n });\n\n return (\n <Row style={styles.root}>\n <Text\n style={[\n currentFontStyle,\n { fontVariant: ['tabular-nums'] },\n ]}\n >\n {currentPage + 1}\n </Text>\n\n <Divider\n style={styles.divider}\n vertical={true}\n />\n\n <Text style={countFontStyle}>\n {maxPage}\n </Text>\n </Row>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;AAKA,MAAMA,SAA4C,GAAG,YAAoC;EACrF,MAAMC,KAAK,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B;EAAnB,gBACI,6BAAC,iBAAD;IACI,KAAK,EAAE,CACH4B,gBADG,EAEH;MAAEQ,WAAW,EAAE,CAAC,cAAD;IAAf,CAFG;EADX,GAMKjB,WAAW,GAAG,CANnB,CADJ,eAUI,6BAAC,gBAAD;IACI,KAAK,EAAEE,MAAM,CAACT,OADlB;IAEI,QAAQ,EAAE;EAFd,EAVJ,eAeI,6BAAC,iBAAD;IAAM,KAAK,EAAEsB;EAAb,GACKd,OADL,CAfJ,CADJ;AAqBH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useVariantStyleMap","variant","selected","size","theme","useTheme","useMemo","container","paddingHorizontal","spacing","paddingVertical","inner","backgroundColor","palette","fill","base","weaker","borderRadius","shape","radius","full","flexDirection","gap","paddingBottom","paddingTop","label","createFontStyle","selector","_","typographyOf","fontSize","lineHeight","fontFamily","letterSpacing","color","text","strongInverse","surface","borderWidth","undefined","borderColor","border","weak","alignItems","height","justifyContent","
|
|
1
|
+
{"version":3,"names":["useVariantStyleMap","variant","selected","size","theme","useTheme","useMemo","container","paddingHorizontal","spacing","paddingVertical","inner","backgroundColor","palette","fill","base","weaker","borderRadius","shape","radius","full","flexDirection","gap","paddingBottom","paddingTop","label","createFontStyle","selector","_","typographyOf","fontSize","lineHeight","fontFamily","letterSpacing","color","text","strongInverse","surface","borderWidth","undefined","borderColor","border","weak","alignItems","height","justifyContent","maxWidth","iconContainer","padding","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 iconContainer?: 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: 7.5,\n paddingHorizontal: 14,\n paddingTop: 6.5,\n },\n label: createFontStyle(theme, {\n selector: (_) => typographyOf({\n fontSize: 14,\n lineHeight: 18.2,\n fontFamily: 'LexendDeca-Medium',\n letterSpacing: -0.28,\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 maxWidth: 48,\n },\n iconContainer: {\n padding: 0.75,\n },\n inner: {\n flexDirection: 'column',\n gap: 4.75,\n },\n label: createFontStyle(theme, {\n selector: (_) => typographyOf({\n fontSize: 10.5,\n lineHeight: 10.5,\n fontFamily: 'PretendardStd-Medium',\n letterSpacing: -0.105,\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.base,\n }),\n };\n }\n }, [theme, variant, selected, size]);\n}\n"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AAUe,SAASA,kBAAT,CAA4BC,OAA5B,EAAiDC,QAAjD,EAAoEC,IAApE,EAAiG;EAC5G,MAAMC,KAAK,GAAG,IAAAC,iBAAA,GAAd;EAEA,OAAO,IAAAC,cAAA,EAAsB,MAAM;IAC/B,QAAQL,OAAR;MACI,KAAK,UAAL;QACI,OAAO;UACHM,SAAS,EAAE;YACPC,iBAAiB,EAAEJ,KAAK,CAACK,OAAN,CAAc,IAAd,CADZ;YAEPC,eAAe,EAAEN,KAAK,CAACK,OAAN,CAAc,CAAd;UAFV,CADR;UAKHE,KAAK,EAAE;YACHC,eAAe,EAAEV,QAAQ,GACnBE,KAAK,CAACS,OAAN,CAAcC,IAAd,CAAmBC,IADA,GAEnBX,KAAK,CAACS,OAAN,CAAcC,IAAd,CAAmBE,MAHtB;YAIHC,YAAY,EAAEb,KAAK,CAACc,KAAN,CAAYC,MAAZ,CAAmBC,IAJ9B;YAKHC,aAAa,EAAE,KALZ;YAMHC,GAAG,EAAE,CANF;YAOHC,aAAa,EAAE,GAPZ;YAQHf,iBAAiB,EAAE,EARhB;YASHgB,UAAU,EAAE;UATT,CALJ;UAgBHC,KAAK,EAAE,IAAAC,wBAAA,EAAgBtB,KAAhB,EAAuB;YAC1BuB,QAAQ,EAAGC,CAAD,IAAO,IAAAC,oBAAA,EAAa;cAC1BC,QAAQ,EAAE3B,IAAI,KAAK,O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AAU,EAAE5B,IAAI,KAAK,OAAT,GAAmB,KAAnB,GAA2B,EAFb;cAG1B6B,UAAU,EAAE9B,QAAQ,GAAG,wBAAH,GAA8B,sBAHxB;cAI1B+B,aAAa,EAAE;YAJW,CAAb,CADS;YAO1BC,KAAK,EAAEhC,QAAQ,GACTE,KAAK,CAACS,OAAN,CAAcsB,IAAd,CAAmBc,MADV,GAET7C,KAAK,CAACS,OAAN,CAAcsB,IAAd,CAAmBpB;UATC,CAAvB;QAVJ,CAAP;IA3FR;EAkHH,CAnHM,EAmHJ,CAACX,KAAD,EAAQH,OAAR,EAAiBC,QAAjB,EAA2BC,IAA3B,CAnHI,CAAP;AAoHH"}
|
|
@@ -82,8 +82,9 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(function Tabs(props, ref) {
|
|
|
82
82
|
const realInitialIndex = sharedIndex.initialValue;
|
|
83
83
|
const currentIndexRef = (0, _react.useRef)(initialIndex);
|
|
84
84
|
const {
|
|
85
|
-
container: containerStyle
|
|
86
|
-
|
|
85
|
+
container: containerStyle,
|
|
86
|
+
contentContainer: contentContainerStyle
|
|
87
|
+
} = (0, _useTabsStyle.default)(variant, size, scrollable);
|
|
87
88
|
|
|
88
89
|
const setTab = newIndex => {
|
|
89
90
|
const currentIndex = currentIndexRef.current;
|
|
@@ -168,6 +169,8 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(function Tabs(props, ref) {
|
|
|
168
169
|
}; // @ts-ignore
|
|
169
170
|
|
|
170
171
|
|
|
172
|
+
const tabStyle = child.props.style; // @ts-ignore
|
|
173
|
+
|
|
171
174
|
const tabElement = /*#__PURE__*/(0, _react.cloneElement)(child, {
|
|
172
175
|
enableIndicator: !disableIndicator && !canRenderIndicator,
|
|
173
176
|
onTabInnerLayout,
|
|
@@ -177,7 +180,7 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(function Tabs(props, ref) {
|
|
|
177
180
|
size,
|
|
178
181
|
variant,
|
|
179
182
|
indicatorSize,
|
|
180
|
-
style: scrollable ? undefined : styles.fixedTab
|
|
183
|
+
style: (0, _styles.css)([scrollable ? undefined : styles.fixedTab, tabStyle])
|
|
181
184
|
});
|
|
182
185
|
return /*#__PURE__*/_react.default.createElement(_IndexAwareTab.default, {
|
|
183
186
|
children: tabElement,
|
|
@@ -205,7 +208,7 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)(function Tabs(props, ref) {
|
|
|
205
208
|
}, scrollable ? /*#__PURE__*/_react.default.createElement(_ScrollableTabsView.default, {
|
|
206
209
|
automaticallyAdjustContentInsets: false,
|
|
207
210
|
bounces: false,
|
|
208
|
-
contentContainerStyle: (0, _styles.css)([scrollViewContentContainerStyle]),
|
|
211
|
+
contentContainerStyle: (0, _styles.css)([contentContainerStyle, scrollViewContentContainerStyle]),
|
|
209
212
|
coordinates: coordinates,
|
|
210
213
|
directionalLockEnabled: true,
|
|
211
214
|
horizontal: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useStyles","theme","useTheme","root","fixedRoot","flexDirection","fixedTab","flex","bottomDivider","borderBottomColor","palette","border","base","borderBottomWidth","Tabs","forwardRef","props","ref","children","color","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","showDivider","size","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","useSyncAnimatedValue","initialValue","sharedIndex","realInitialIndex","currentIndexRef","useRef","container","containerStyle","useTabsStyle","setTab","newIndex","currentIndex","current","animatedValue","setValue","useImperativeHandle","styles","outerCoordinates","updateCoordinate","useTabCoordinates","innerContentsWidthList","updateInnerContentsWidth","useTabInnerContentsWidth","canRenderIndicator","isEveryTabCoordinatesDefined","indexStore","useIndexStore","coordinates","useMemo","length","map","innerContentWidth","idx","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","useEffect","subscribe","tabElements","React","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabElement","cloneElement","enableIndicator","undefined","filter","Boolean","tabIndicator","backgroundColorMap","default","background","alt","css","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.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IAA0B,KAAK,EAAE;MAAE3C;IAAF;EAAjC,gBACI,6BAAC,iBAAD;IACI,KAAK,EAAE,IAAA4C,WAAA,EAAI,CACPrD,MAAM,CAAChD,IADA,EAEPuC,cAFO,EAGP;MAAE+D,eAAe,EAAEL,kBAAkB,CAACjF,KAAD;IAArC,CAHO,EAIPS,WAAW,GAAGuB,MAAM,CAAC3C,aAAV,GAA0BwF,SAJ9B,EAKPtE,UAAU,GAAGsE,SAAH,GAAe7C,MAAM,CAAC/C,SALzB,EAMP0B,KANO,CAAJ;EADX,GAUKJ,UAAU,gBACP,6BAAC,2BAAD;IACI,gCAAgC,EAAE,KADtC;IAEI,OAAO,EAAE,KAFb;IAGI,qBAAqB,EAAE,IAAA8E,WAAA,EAAI,CACvB7E,+BADuB,CAAJ,CAH3B;IAMI,WAAW,EAAEmC,WANjB;IAOI,sBAAsB,EAAE,IAP5B;IAQI,UAAU,EAAE,IARhB;IASI,YAAY,EAAExB,gBATlB;IAUI,YAAY,EAAE,KAVlB;IAWI,8BAA8B,EAAE,KAXpC;IAYI,4BAA4B,EAAE,KAZlC;IAaI,mBAAmB,EAAEf,mBAbzB;IAcI,yBAAyB,EAAEC;EAd/B,GAgBKqD,WAhBL,EAiBKsB,YAjBL,CADO,gBAqBP,6BAAC,cAAD,CAAO,QAAP,QACKtB,WADL,EAEKsB,YAFL,CA/BR,CADJ,CADJ;AAyCH,CAnMY,CAAb;eAqMerF,I"}
|
|
1
|
+
{"version":3,"names":["useStyles","theme","useTheme","root","fixedRoot","flexDirection","fixedTab","flex","bottomDivider","borderBottomColor","palette","border","base","borderBottomWidth","Tabs","forwardRef","props","ref","children","color","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","showDivider","size","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","useSyncAnimatedValue","initialValue","sharedIndex","realInitialIndex","currentIndexRef","useRef","container","containerStyle","contentContainer","contentContainerStyle","useTabsStyle","setTab","newIndex","currentIndex","current","animatedValue","setValue","useImperativeHandle","styles","outerCoordinates","updateCoordinate","useTabCoordinates","innerContentsWidthList","updateInnerContentsWidth","useTabInnerContentsWidth","canRenderIndicator","isEveryTabCoordinatesDefined","indexStore","useIndexStore","coordinates","useMemo","length","map","innerContentWidth","idx","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","useEffect","subscribe","tabElements","React","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabStyle","tabElement","cloneElement","enableIndicator","css","undefined","filter","Boolean","tabIndicator","backgroundColorMap","default","background","alt","backgroundColor"],"sources":["Tabs.tsx"],"sourcesContent":["import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { css, useTheme } from '../styles';\nimport { useSyncAnimatedValue } from '../hooks';\nimport type { TabSize, TabVariant } from '../Tab';\nimport type TabsProps from './TabsProps';\nimport type { TabsColor } from './TabsProps';\nimport type { TabsInstance } from './types';\nimport TabIndicator from './TabIndicator';\nimport ScrollableTabsView from './ScrollableTabsView';\nimport IndexAwareTab from './IndexAwareTab';\nimport useTabCoordinates from './useTabCoordinates';\nimport useTabInnerContentsWidth from './useTabInnerContentsWidth';\nimport useIndexStore from './useIndexStore';\nimport InternalContext from './InternalContext';\nimport { isEveryTabCoordinatesDefined } from './utils';\nimport useTabsStyle from './useTabsStyle';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'bottomDivider';\n\ntype TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;\n\nconst useStyles: UseStyles<TabsStyles> = function (): TabsStyles {\n const theme = useTheme();\n\n return {\n root: {},\n fixedRoot: {\n flexDirection: 'row',\n },\n fixedTab: {\n flex: 1,\n },\n bottomDivider: {\n borderBottomColor: theme.palette.border.base,\n borderBottomWidth: 0.5,\n },\n };\n};\n\nconst Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {\n const {\n children,\n color = 'default',\n initialIndex = 0,\n disableIndicator = false,\n indicatorSize = 'fit-content',\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollViewContentContainerStyle,\n showDivider = false,\n size = 'medium' as TabSize,\n style,\n variant = 'default' as TabVariant,\n UNSTABLE_sharedIndex,\n onTabSelected,\n } = props;\n\n const fallbackSharedIndex = useSyncAnimatedValue({ initialValue: initialIndex });\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n const realInitialIndex = sharedIndex.initialValue;\n\n const currentIndexRef = useRef(initialIndex);\n\n const {\n container: containerStyle,\n contentContainer: contentContainerStyle,\n } = useTabsStyle(variant, size, scrollable);\n\n const setTab = (newIndex: number) => {\n const currentIndex = currentIndexRef.current;\n onTabSelected?.(newIndex, currentIndex);\n\n sharedIndex.animatedValue.setValue(newIndex);\n };\n\n useImperativeHandle(\n ref,\n () => ({\n setTab,\n }),\n [sharedIndex],\n );\n\n const styles = useStyles();\n\n const theme = useTheme();\n\n const [outerCoordinates, updateCoordinate] = useTabCoordinates(children);\n const [innerContentsWidthList, updateInnerContentsWidth] = useTabInnerContentsWidth(children);\n\n const canRenderIndicator = indicatorSize === 'fit-content'\n ? isEveryTabCoordinatesDefined(innerContentsWidthList, children)\n : isEveryTabCoordinatesDefined(outerCoordinates, children);\n\n const indexStore = useIndexStore(sharedIndex);\n\n const coordinates = useMemo(() => {\n if (outerCoordinates.length === 0) {\n return [];\n }\n\n if (indicatorSize !== 'fit-content') {\n return outerCoordinates;\n }\n\n return innerContentsWidthList.map((innerContentWidth, idx) => {\n const { 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 tabStyle = child.props.style;\n\n // @ts-ignore\n const tabElement = cloneElement(child, {\n enableIndicator: !disableIndicator && !canRenderIndicator,\n onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n size,\n variant,\n indicatorSize,\n style: css([\n scrollable ? undefined : styles.fixedTab,\n tabStyle,\n ]),\n });\n\n return (\n <IndexAwareTab\n children={tabElement}\n index={index}\n initialIndex={realInitialIndex}\n />\n );\n })?.filter(Boolean);\n\n const tabIndicator = canRenderIndicator ? (\n <TabIndicator\n coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={realInitialIndex}\n />\n ) : null;\n\n const backgroundColorMap: Record<TabsColor, string> = {\n default: theme.palette.background.base,\n alt: theme.palette.background.alt,\n };\n\n return (\n <InternalContext.Provider value={{ indexStore }}>\n <View\n style={css([\n styles.root,\n containerStyle,\n { backgroundColor: backgroundColorMap[color] },\n showDivider ? styles.bottomDivider : undefined,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n >\n {scrollable ? (\n <ScrollableTabsView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={css([\n contentContainerStyle,\n scrollViewContentContainerStyle,\n ])}\n coordinates={coordinates}\n directionalLockEnabled={true}\n horizontal={true}\n initialIndex={realInitialIndex}\n scrollsToTop={false}\n showsHorizontalScrollIndicator={false}\n showsVerticalScrollIndicator={false}\n keyboardDismissMode={keyboardDismissMode}\n keyboardShouldPersistTaps={keyboardShouldPersistTaps}\n >\n {tabElements}\n {tabIndicator}\n </ScrollableTabsView>\n ) : (\n <React.Fragment>\n {tabElements}\n {tabIndicator}\n </React.Fragment>\n )}\n </View>\n </InternalContext.Provider>\n );\n});\n\nexport default Tabs;\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAUA,MAAMA,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE,EADH;IAEHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAFR;IAKHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CALP;IAQHC,aAAa,EAAE;MACXC,iBAAiB,EAAER,KAAK,CAACS,OAAN,CAAcC,MAAd,CAAqBC,IAD7B;MAEXC,iBAAiB,EAAE;IAFR;EARZ,CAAP;AAaH,CAhBD;;AAkBA,MAAMC,IAAI,gBAAG,IAAAC,iBAAA,EAAoC,SAASD,IAAT,CAAcE,KAAd,EAAqBC,GAArB,EAA0B;EAAA;;EACvE,MAAM;IACFC,QADE;IAEFC,KAAK,GAAG,SAFN;IAGFC,YAAY,GAAG,CAHb;IAIFC,gBAAgB,GAAG,KAJjB;IAKFC,aAAa,GAAG,aALd;IAMFC,mBAAmB,GAAG,MANpB;IAOFC,yBAAyB,GAAG,OAP1B;IAQFC,QARE;IASFC,UAAU,GAAG,KATX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,EAAE,KAXlB;IAYI,8BAA8B,EAAE,KAZpC;IAaI,4BAA4B,EAAE,KAblC;IAcI,mBAAmB,EAAEf,mBAdzB;IAeI,yBAAyB,EAAEC;EAf/B,GAiBKuD,WAjBL,EAkBKwB,YAlBL,CADO,gBAsBP,6BAAC,cAAD,CAAO,QAAP,QACKxB,WADL,EAEKwB,YAFL,CAhCR,CADJ,CADJ;AA0CH,CA7MY,CAAb;eA+MezF,I"}
|
|
@@ -11,44 +11,69 @@ var _hooks = require("../hooks");
|
|
|
11
11
|
|
|
12
12
|
var _styles = require("../styles");
|
|
13
13
|
|
|
14
|
-
function useTabsStyle(variant, size) {
|
|
14
|
+
function useTabsStyle(variant, size, scrollable) {
|
|
15
15
|
const theme = (0, _styles.useTheme)();
|
|
16
16
|
const isTablet = (0, _hooks.useBreakpointUp)('md', true, false);
|
|
17
17
|
return (0, _react.useMemo)(() => {
|
|
18
18
|
switch (variant) {
|
|
19
19
|
case 'circular':
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
{
|
|
21
|
+
const paddingHorizontal = isTablet ? 20 : size === 'small' ? 8 : 12;
|
|
22
|
+
return {
|
|
23
|
+
container: {
|
|
24
|
+
paddingBottom: 8,
|
|
25
|
+
paddingHorizontal: scrollable ? 0 : paddingHorizontal
|
|
26
|
+
},
|
|
27
|
+
contentContainer: {
|
|
28
|
+
paddingHorizontal: scrollable ? paddingHorizontal : 0
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
26
32
|
|
|
27
33
|
case 'circular-home':
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
{
|
|
35
|
+
const paddingHorizontal = isTablet ? 20 : 8;
|
|
36
|
+
return {
|
|
37
|
+
container: {
|
|
38
|
+
paddingBottom: 8,
|
|
39
|
+
paddingHorizontal: scrollable ? 0 : paddingHorizontal
|
|
40
|
+
},
|
|
41
|
+
contentContainer: {
|
|
42
|
+
paddingHorizontal: scrollable ? paddingHorizontal : 0
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
34
46
|
|
|
35
47
|
case 'bottom-navigation':
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
{
|
|
49
|
+
const paddingHorizontal = 24;
|
|
50
|
+
return {
|
|
51
|
+
container: {
|
|
52
|
+
borderTopColor: theme.palette.border.base,
|
|
53
|
+
borderTopWidth: 0.5,
|
|
54
|
+
justifyContent: 'space-between',
|
|
55
|
+
paddingHorizontal: scrollable ? 0 : paddingHorizontal
|
|
56
|
+
},
|
|
57
|
+
contentContainer: {
|
|
58
|
+
paddingHorizontal: scrollable ? paddingHorizontal : 0
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
43
62
|
|
|
44
63
|
case 'default':
|
|
45
64
|
default:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
{
|
|
66
|
+
const paddingHorizontal = isTablet ? 14 : 6;
|
|
67
|
+
return {
|
|
68
|
+
container: {
|
|
69
|
+
paddingHorizontal: scrollable ? 0 : paddingHorizontal
|
|
70
|
+
},
|
|
71
|
+
contentContainer: {
|
|
72
|
+
paddingHorizontal: scrollable ? paddingHorizontal : 0
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
51
76
|
}
|
|
52
|
-
}, [theme, variant, isTablet, size]);
|
|
77
|
+
}, [theme, variant, isTablet, size, scrollable]);
|
|
53
78
|
}
|
|
54
79
|
//# sourceMappingURL=useTabsStyle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useTabsStyle","variant","size","theme","useTheme","isTablet","useBreakpointUp","useMemo","container","paddingBottom","
|
|
1
|
+
{"version":3,"names":["useTabsStyle","variant","size","scrollable","theme","useTheme","isTablet","useBreakpointUp","useMemo","paddingHorizontal","container","paddingBottom","contentContainer","borderTopColor","palette","border","base","borderTopWidth","justifyContent"],"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 contentContainer?: FountainUiStyle;\n}\n\nexport default function useTabsStyle(variant: TabVariant, size: TabSize, scrollable: boolean) {\n const theme = useTheme();\n\n const isTablet = useBreakpointUp('md', true, false);\n\n return useMemo<TabsStyle>(() => {\n switch (variant) {\n case 'circular': {\n const paddingHorizontal = isTablet ? 20 : (size === 'small' ? 8 : 12);\n\n return {\n container: {\n paddingBottom: 8,\n paddingHorizontal: scrollable ? 0 : paddingHorizontal,\n },\n contentContainer: {\n paddingHorizontal: scrollable ? paddingHorizontal : 0,\n },\n };\n }\n case 'circular-home': {\n const paddingHorizontal = isTablet ? 20 : 8;\n\n return {\n container: {\n paddingBottom: 8,\n paddingHorizontal: scrollable ? 0 : paddingHorizontal,\n },\n contentContainer: {\n paddingHorizontal: scrollable ? paddingHorizontal : 0,\n },\n };\n }\n case 'bottom-navigation': {\n const paddingHorizontal = 24;\n\n return {\n container: {\n borderTopColor: theme.palette.border.base,\n borderTopWidth: 0.5,\n justifyContent: 'space-between',\n paddingHorizontal: scrollable ? 0 : paddingHorizontal,\n },\n contentContainer: {\n paddingHorizontal: scrollable ? paddingHorizontal : 0,\n },\n };\n }\n case 'default':\n default: {\n const paddingHorizontal = isTablet ? 14 : 6;\n\n return {\n container: {\n paddingHorizontal: scrollable ? 0 : paddingHorizontal,\n },\n contentContainer: {\n paddingHorizontal: scrollable ? paddingHorizontal : 0,\n },\n };\n }\n }\n }, [theme, variant, isTablet, size, scrollable]);\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAQe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