@fountain-ui/core 2.0.0-beta.80 → 2.0.0-beta.81

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.
@@ -7,82 +7,169 @@ exports.default = Accordion;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _reactNative = require("react-native");
11
+
10
12
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
13
 
14
+ var _styles = require("../styles");
15
+
12
16
  var _icons = require("../internal/icons");
13
17
 
14
18
  var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
15
19
 
16
20
  var _Column = _interopRequireDefault(require("../Column"));
17
21
 
18
- var _Divider = _interopRequireDefault(require("../Divider"));
22
+ var _Row = _interopRequireDefault(require("../Row"));
19
23
 
20
24
  var _Spacer = _interopRequireDefault(require("../Spacer"));
21
25
 
22
26
  var _Typography = _interopRequireDefault(require("../Typography"));
23
27
 
24
- var _styles = require("../styles");
25
-
26
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
29
 
28
30
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
31
 
30
32
  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; }
31
33
 
34
+ const CONTENT_Y_START = 30;
35
+ const CONTENT_Y_END = 0;
36
+ const ROTATE_HIDE_DEGREE = 0;
37
+ const ROTATE_SHOW_DEGREE = 180;
32
38
  const ANIMATION_CONFIG = {
33
- duration: 250
39
+ duration: 300
34
40
  };
35
41
 
36
42
  const useStyles = function () {
37
43
  const theme = (0, _styles.useTheme)();
38
44
  return {
39
45
  root: {
40
- flexDirection: 'row',
41
- paddingVertical: theme.spacing(3)
46
+ marginBottom: theme.spacing(2)
47
+ },
48
+ title: {
49
+ borderRadius: theme.spacing(4),
50
+ backgroundColor: theme.palette.paper.grey,
51
+ paddingHorizontal: theme.spacing(4),
52
+ paddingVertical: theme.spacing(3.5),
53
+ alignItems: 'center'
54
+ },
55
+ titleColumn: {
56
+ flexShrink: 1
57
+ },
58
+ subtitle: {
59
+ fontSize: 11,
60
+ lineHeight: 12,
61
+ fontFamily: 'Inter-Regular'
62
+ },
63
+ contentView: {
64
+ position: 'absolute',
65
+ width: '100%',
66
+ borderRadius: theme.spacing(4),
67
+ backgroundColor: theme.palette.paper.grey,
68
+ paddingHorizontal: theme.spacing(4),
69
+ paddingVertical: theme.spacing(6),
70
+ marginTop: theme.spacing(2)
42
71
  }
43
72
  };
44
73
  };
45
74
 
46
75
  function Accordion(props) {
47
76
  const {
77
+ title,
78
+ subTitle,
48
79
  content,
49
- LeftIcon,
50
80
  RightIcon,
51
- title,
52
- titleVariant = 'subtitle2'
81
+ LeftComponent,
82
+ isInitialExpanded = false
53
83
  } = props;
54
84
  const styles = useStyles();
85
+ const theme = (0, _styles.useTheme)();
86
+ const CONTENT_MARGIN_HEIGHT = theme.spacing(2);
55
87
  const [isExpanded, setIsExpanded] = (0, _react.useState)(false);
56
- const rotate = (0, _reactNativeReanimated.useSharedValue)(0);
88
+ const shouldInitialExpandedRef = (0, _react.useRef)(isInitialExpanded);
89
+ const rotate = (0, _reactNativeReanimated.useSharedValue)(ROTATE_HIDE_DEGREE);
90
+ const animatedOpacity = (0, _reactNativeReanimated.useSharedValue)(0);
91
+ const animatedContentY = (0, _reactNativeReanimated.useSharedValue)(CONTENT_Y_START);
92
+ const animatedHeight = (0, _reactNativeReanimated.useSharedValue)(0);
93
+ const [contentHeight, setContentHeight] = (0, _react.useState)(0);
57
94
  const animatedChevronDownStyles = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
58
95
  transform: [{
59
96
  rotate: `${rotate.value}deg`
60
97
  }]
61
98
  }), []);
99
+ const animatedContentBackgroundStyles = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
100
+ height: animatedHeight.value,
101
+ opacity: animatedOpacity.value,
102
+ overflow: 'hidden'
103
+ }), []);
104
+ const animatedContentStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
105
+ transform: [{
106
+ translateY: animatedContentY.value
107
+ }],
108
+ opacity: animatedOpacity.value
109
+ }), []);
62
110
 
63
111
  const onPress = () => {
64
112
  setIsExpanded(prev => !prev);
65
- rotate.value = (0, _reactNativeReanimated.withTiming)(!isExpanded ? 180 : 0, ANIMATION_CONFIG);
66
113
  };
67
114
 
68
- return /*#__PURE__*/_react.default.createElement(_Column.default, null, /*#__PURE__*/_react.default.createElement(_ButtonBase.default, {
69
- onPress: onPress,
115
+ const onLayout = event => {
116
+ const height = event.nativeEvent.layout.height + CONTENT_MARGIN_HEIGHT;
117
+ setContentHeight(height);
118
+
119
+ if (shouldInitialExpandedRef.current) {
120
+ shouldInitialExpandedRef.current = false;
121
+ setIsExpanded(true);
122
+ }
123
+ };
124
+
125
+ (0, _react.useEffect)(() => {
126
+ rotate.value = (0, _reactNativeReanimated.withTiming)(isExpanded ? ROTATE_SHOW_DEGREE : ROTATE_HIDE_DEGREE, ANIMATION_CONFIG);
127
+ animatedHeight.value = (0, _reactNativeReanimated.withTiming)(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);
128
+ animatedOpacity.value = (0, _reactNativeReanimated.withTiming)(isExpanded ? 1 : 0, ANIMATION_CONFIG);
129
+ animatedContentY.value = isExpanded ? (0, _reactNativeReanimated.withTiming)(CONTENT_Y_END, ANIMATION_CONFIG) : (0, _reactNativeReanimated.withDelay)(ANIMATION_CONFIG.duration, (0, _reactNativeReanimated.withTiming)(CONTENT_Y_START, {
130
+ duration: 0
131
+ }));
132
+ }, [isExpanded, contentHeight]);
133
+ return /*#__PURE__*/_react.default.createElement(_Column.default, {
70
134
  style: styles.root
71
- }, LeftIcon ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, LeftIcon, /*#__PURE__*/_react.default.createElement(_Spacer.default, {
72
- size: 2
73
- })) : null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
135
+ }, /*#__PURE__*/_react.default.createElement(_ButtonBase.default, {
136
+ onPress: onPress
137
+ }, /*#__PURE__*/_react.default.createElement(_Row.default, {
138
+ style: styles.title
139
+ }, LeftComponent ? LeftComponent : null, /*#__PURE__*/_react.default.createElement(_Column.default, {
140
+ style: styles.titleColumn
141
+ }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
142
+ variant: 'subtitle2',
74
143
  children: title,
75
- variant: titleVariant
76
- }), /*#__PURE__*/_react.default.createElement(_Spacer.default, {
144
+ color: 'textPrimary',
145
+ numberOfLines: 1
146
+ }), subTitle ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Spacer.default, {
147
+ size: 0.5
148
+ }), /*#__PURE__*/_react.default.createElement(_Typography.default, {
149
+ style: styles.subtitle,
150
+ color: 'tertiary',
151
+ children: subTitle
152
+ })) : null), /*#__PURE__*/_react.default.createElement(_Spacer.default, {
77
153
  flex: 1
78
154
  }), /*#__PURE__*/_react.default.createElement(_Spacer.default, {
79
- size: 2
80
- }), /*#__PURE__*/_react.default.createElement(_Column.default, null, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
155
+ size: 3
156
+ }), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
81
157
  style: animatedChevronDownStyles
82
- }, RightIcon ? RightIcon : /*#__PURE__*/_react.default.createElement(_icons.ChevronDown, null)))), isExpanded ? /*#__PURE__*/_react.default.isValidElement(content) ? content : /*#__PURE__*/_react.default.createElement(_Typography.default, {
83
- children: content,
84
- color: 'textSecondary',
85
- variant: 'body2'
86
- }) : null, /*#__PURE__*/_react.default.createElement(_Divider.default, null));
158
+ }, RightIcon ? RightIcon : /*#__PURE__*/_react.default.createElement(_icons.ChevronDown, {
159
+ width: 20,
160
+ height: 20,
161
+ color: 'tertiary'
162
+ })))), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
163
+ style: animatedContentBackgroundStyles
164
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
165
+ onLayout: onLayout,
166
+ style: styles.contentView
167
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
168
+ style: animatedContentStyle
169
+ }, typeof content === 'string' ? /*#__PURE__*/_react.default.createElement(_Typography.default, {
170
+ variant: 'subtitle2',
171
+ color: 'tertiary',
172
+ children: content
173
+ }) : content))));
87
174
  }
88
175
  //# sourceMappingURL=Accordion.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ANIMATION_CONFIG","duration","useStyles","theme","useTheme","root","flexDirection","paddingVertical","spacing","Accordion","props","content","LeftIcon","RightIcon","title","titleVariant","styles","isExpanded","setIsExpanded","useState","rotate","useSharedValue","animatedChevronDownStyles","useAnimatedStyle","transform","value","onPress","prev","withTiming","React","isValidElement"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { ChevronDown as ChevronDownIcon } from '../internal/icons';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Divider from '../Divider';\nimport Spacer from '../Spacer';\nimport Typography from '../Typography';\nimport { useTheme } from '../styles';\n\nimport AccordionProps from './AccordionProps';\n\ntype AccordionStyles = NamedStylesStringUnion<'root'>;\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 250 };\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'row',\n paddingVertical: theme.spacing(3),\n },\n };\n};\n\nexport default function Accordion(props: AccordionProps) {\n const {\n content,\n LeftIcon,\n RightIcon,\n title,\n titleVariant = 'subtitle2',\n } = props;\n\n const styles = useStyles();\n\n const [isExpanded, setIsExpanded] = useState(false);\n\n const rotate = useSharedValue(0);\n\n const animatedChevronDownStyles = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }), []);\n\n const onPress = () => {\n setIsExpanded(prev => !prev);\n rotate.value = withTiming(!isExpanded ? 180 : 0, ANIMATION_CONFIG);\n };\n\n return (\n <Column>\n <ButtonBase\n onPress={onPress}\n style={styles.root}\n >\n {LeftIcon ? (\n <React.Fragment>\n {LeftIcon}\n <Spacer size={2}/>\n </React.Fragment>\n ) : null}\n\n <Typography\n children={title}\n variant={titleVariant}\n />\n\n <Spacer flex={1}/>\n\n <Spacer size={2}/>\n\n <Column>\n <Animated.View style={animatedChevronDownStyles}>\n {RightIcon ? RightIcon : <ChevronDownIcon/>}\n </Animated.View>\n </Column>\n </ButtonBase>\n\n {isExpanded ? (\n React.isValidElement(content) ? (content) : (\n <Typography\n children={content}\n color={'textSecondary'}\n variant={'body2'}\n />\n )\n ) : null}\n\n <Divider/>\n </Column>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAMA,MAAMA,gBAA4C,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAArD;;AAEA,MAAMC,SAAqC,GAAG,YAA6B;EACvE,MAAMC,KAAK,GAAG,IA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eAAD;IAAQ,IAAI,EAAE;EAAd,EAlBJ,eAoBI,6BAAC,eAAD,qBACI,6BAAC,8BAAD,CAAU,IAAV;IAAe,KAAK,EAAEO;EAAtB,GACKT,SAAS,GAAGA,SAAH,gBAAe,6BAAC,kBAAD,OAD7B,CADJ,CApBJ,CADJ,EA4BKI,UAAU,GACP,aAAAY,cAAA,CAAMC,cAAN,CAAqBnB,OAArB,IAAiCA,OAAjC,gBACI,6BAAC,mBAAD;IACI,QAAQ,EAAEA,OADd;IAEI,KAAK,EAAE,eAFX;IAGI,OAAO,EAAE;EAHb,EAFG,GAQP,IApCR,eAsCI,6BAAC,gBAAD,OAtCJ,CADJ;AA0CH"}
1
+ {"version":3,"names":["CONTENT_Y_START","CONTENT_Y_END","ROTATE_HIDE_DEGREE","ROTATE_SHOW_DEGREE","ANIMATION_CONFIG","duration","useStyles","theme","useTheme","root","marginBottom","spacing","title","borderRadius","backgroundColor","palette","paper","grey","paddingHorizontal","paddingVertical","alignItems","titleColumn","flexShrink","subtitle","fontSize","lineHeight","fontFamily","contentView","position","width","marginTop","Accordion","props","subTitle","content","RightIcon","LeftComponent","isInitialExpanded","styles","CONTENT_MARGIN_HEIGHT","isExpanded","setIsExpanded","useState","shouldInitialExpandedRef","useRef","rotate","useSharedValue","animatedOpacity","animatedContentY","animatedHeight","contentHeight","setContentHeight","animatedChevronDownStyles","useAnimatedStyle","transform","value","animatedContentBackgroundStyles","height","opacity","overflow","animatedContentStyle","translateY","onPress","prev","onLayout","event","nativeEvent","layout","current","useEffect","withTiming","withDelay"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { LayoutChangeEvent, View } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n WithTimingConfig,\n} from 'react-native-reanimated';\nimport { 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 Typography from '../Typography';\n\nimport AccordionProps from './AccordionProps';\n\ntype AccordionStyles = NamedStylesStringUnion<\n 'root'\n | 'title'\n | 'titleColumn'\n | 'subtitle'\n | 'contentView'\n>;\n\nconst CONTENT_Y_START = 30;\nconst CONTENT_Y_END = 0;\n\nconst ROTATE_HIDE_DEGREE = 0;\nconst ROTATE_SHOW_DEGREE = 180;\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 300 };\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: { marginBottom: theme.spacing(2) },\n title: {\n borderRadius: theme.spacing(4),\n backgroundColor: theme.palette.paper.grey,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3.5),\n alignItems: 'center',\n },\n titleColumn: { flexShrink: 1 },\n subtitle: {\n fontSize: 11,\n lineHeight: 12,\n fontFamily: 'Inter-Regular',\n },\n contentView: {\n position: 'absolute',\n width: '100%',\n borderRadius: theme.spacing(4),\n backgroundColor: theme.palette.paper.grey,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(6),\n marginTop: theme.spacing(2),\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 } = props;\n\n const styles = useStyles();\n const theme = useTheme();\n const CONTENT_MARGIN_HEIGHT = theme.spacing(2);\n\n const [isExpanded, setIsExpanded] = useState(false);\n const shouldInitialExpandedRef = useRef<boolean>(isInitialExpanded);\n\n const rotate = useSharedValue(ROTATE_HIDE_DEGREE);\n const animatedOpacity = useSharedValue(0);\n const animatedContentY = useSharedValue(CONTENT_Y_START);\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 opacity: animatedOpacity.value,\n overflow: 'hidden',\n }), []);\n\n const animatedContentStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: animatedContentY.value }],\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 setIsExpanded(true);\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 animatedOpacity.value = withTiming(isExpanded ? 1 : 0, ANIMATION_CONFIG);\n\n animatedContentY.value = isExpanded\n ? withTiming(CONTENT_Y_END, ANIMATION_CONFIG)\n : withDelay(ANIMATION_CONFIG.duration as number, withTiming(CONTENT_Y_START, { duration: 0 }));\n }, [isExpanded, contentHeight]);\n\n return (\n <Column style={styles.root}>\n <ButtonBase onPress={onPress}>\n <Row style={styles.title}>\n {LeftComponent ? LeftComponent : null}\n\n <Column style={styles.titleColumn}>\n <Typography\n variant={'subtitle2'}\n children={title}\n color={'textPrimary'}\n numberOfLines={1}\n />\n\n {subTitle ? (\n <React.Fragment>\n <Spacer size={0.5}/>\n\n <Typography\n style={styles.subtitle}\n color={'tertiary'}\n children={subTitle}\n />\n </React.Fragment>\n ) : null}\n </Column>\n\n <Spacer flex={1}/>\n\n <Spacer size={3}/>\n\n <Animated.View style={animatedChevronDownStyles}>\n {RightIcon ? RightIcon : (\n <ChevronDown\n width={20}\n height={20}\n color={'tertiary'}\n />\n )}\n </Animated.View>\n </Row>\n </ButtonBase>\n\n <Animated.View style={animatedContentBackgroundStyles}>\n <View\n onLayout={onLayout}\n style={styles.contentView}\n >\n <Animated.View style={animatedContentStyle}>\n {typeof content === 'string' ? (\n <Typography\n variant={'subtitle2'}\n color={'tertiary'}\n children={content}\n />\n ) : (content)}\n </Animated.View>\n </View>\n </Animated.View>\n </Column>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAYA,MAAMA,eAAe,GAAG,EAAxB;AACA,MAAMC,aAAa,GAAG,CAAtB;AAEA,MAAMC,kBAAkB,GAAG,CAA3B;AACA,MAAMC,kBAAkB,GAAG,GAA3B;AACA,MAAMC,gBAA4C,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAArD;;AAEA,MAAMC,SAAqC,GAAG,YAA6B;EACvE,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MAAEC,YAAY,EAAEH,KAAK,CAACI,OAAN,CAAc,CAAd;IAAhB,CADH;IAEHC,KAAK,EAAE;MACHC,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAc,CAAd,CADX;MAEHG,eAAe,EAAEP,KAAK,CAACQ,OAAN,CAAcC,KAAd,CAAoBC,IAFlC;MAGHC,iBAAiB,EAAEX,KAAK,CAACI,OAAN,CAAc,CAAd,CAHhB;MAIHQ,eAAe,EAAEZ,KAAK,CAACI,OAAN,CAAc,GAAd,CAJd;MAKHS,UAAU,EAAE;IALT,CAFJ;IASHC,WAAW,EAAE;MAAEC,UAAU,EAAE;IAAd,CATV;IAUHC,QAAQ,EAAE;MACNC,QAAQ,EAAE,EADJ;MAENC,UAAU,EAAE,EAFN;MAGNC,UAAU,EAAE;IAHN,CAVP;IAeHC,WAAW,EAAE;MACTC,QAAQ,EAAE,UADD;MAETC,KAAK,EAAE,MAFE;MAGThB,YAAY,EAAEN,KAAK,CAACI,OAAN,CAAc,CAAd,CAHL;MAITG,eAAe,EAAEP,KAAK,CAACQ,O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gBACI,6BAAC,iBAAD;IACI,QAAQ,EAAEQ,QADd;IAEI,KAAK,EAAE1B,MAAM,CAACX;EAFlB,gBAII,6BAAC,8BAAD,CAAU,IAAV;IAAe,KAAK,EAAEiC;EAAtB,GACK,OAAO1B,OAAP,KAAmB,QAAnB,gBACG,6BAAC,mBAAD;IACI,OAAO,EAAE,WADb;IAEI,KAAK,EAAE,UAFX;IAGI,QAAQ,EAAEA;EAHd,EADH,GAMIA,OAPT,CAJJ,CADJ,CA1CJ,CADJ;AA6DH"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["AccordionProps.ts"],"sourcesContent":["import React from 'react';\nimport type { TypographyProps } from '../Typography';\n\nexport default interface AccordionProps {\n /**\n * The content of the component.\n */\n content: string | React.ReactNode;\n\n /**\n * The icon to the left of the component.\n */\n LeftIcon?: React.ReactElement;\n\n /**\n * The icon to the right of the component.\n */\n RightIcon?: React.ReactElement;\n\n /**\n * The title of the component.\n */\n title: string;\n\n /**\n * The variant of the component title.\n * @default 'subtitle2'\n */\n titleVariant?: TypographyProps['variant'];\n}"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["AccordionProps.ts"],"sourcesContent":["import React from 'react';\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.\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}"],"mappings":""}
@@ -57,11 +57,20 @@ function Tab(props) {
57
57
  } = props;
58
58
  const theme = (0, _styles.useTheme)();
59
59
  const vertical = variant === 'bottom-navigation';
60
- const color = selected ? theme.palette.text.primary : theme.palette.text.hint;
61
- const tabBaseStyle = (0, _styles.css)([styles.root, variant === 'bottom-navigation' && styles.bottomNavigation, style]);
60
+ const color = selected ? theme.palette.text.primary : variant === 'contained' ? theme.palette.text.secondary : theme.palette.text.hint;
61
+ const containedStyle = {
62
+ borderColor: selected ? theme.palette.primary.main : theme.palette.border,
63
+ borderRadius: theme.shape.roundnessExtra,
64
+ borderWidth: selected ? 1.5 : 1,
65
+ paddingHorizontal: theme.spacing(3),
66
+ paddingVertical: theme.spacing(1.5)
67
+ };
68
+ const tabBaseStyle = (0, _styles.css)([styles.root, variant === 'bottom-navigation' && styles.bottomNavigation, variant === 'contained' && containedStyle, style]);
62
69
  const tabInnerStyle = (0, _styles.css)([styles.root, styles.filledInner]);
63
70
  const fontStyle = (0, _styles.createFontStyle)(theme, {
64
- selector: typo => variant === 'primary' ? typo.h2 : variant === 'secondary' ? typo.button2 : typo.flag,
71
+ selector: typo => variant === 'primary' ? typo.h2 : variant === 'secondary' ? typo.button2 : variant === 'contained' ? selected ? { ...typo.subtitle2,
72
+ fontWeight: typo.fontWeight.medium
73
+ } : typo.body2 : typo.flag,
65
74
  color
66
75
  });
67
76
  const pressEffect = selected ? 'none' : 'opacity';
@@ -1 +1 @@
1
- {"version":3,"names":["styles","StyleSheet","create","root","Platform","OS","minWidth","minHeight","bottomNavigation","filledInner","justifyContent","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","indicatorColor","indicatorSize","selected","selectedIcon","variant","style","onTabInnerLayout","otherProps","theme","useTheme","vertical","color","palette","text","primary","hint","tabBaseStyle","css","tabInnerStyle","fontStyle","createFontStyle","selector","typo","h2","button2","flag","pressEffect","iconElement","cloneElement","fill","tabElement","React","tabIndicator"],"sources":["Tab.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { Platform, Text, View } from 'react-native';\nimport Badge from '../Badge';\nimport TabBase from '../TabBase';\nimport type TabProps from './TabProps';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport TabIndicator from './TabIndicator';\n\nconst styles = StyleSheet.create({\n root: {\n // TODO: Remove redundant platform checking\n ...(Platform.OS === 'web' ? { minWidth: 'auto' } : {}),\n minHeight: 40,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n filledInner: {\n justifyContent: 'center',\n }\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator = false,\n icon: defaultIcon,\n indicatorColor = 'primary',\n indicatorSize = 'full',\n selected = false,\n selectedIcon,\n variant = 'primary',\n style,\n onTabInnerLayout,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const vertical = variant === 'bottom-navigation';\n\n const color = selected ? theme.palette.text.primary : theme.palette.text.hint;\n\n const tabBaseStyle = css([\n styles.root,\n variant === 'bottom-navigation' && styles.bottomNavigation,\n style,\n ]);\n\n const tabInnerStyle = css([\n styles.root,\n styles.filledInner,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => variant === 'primary'\n ? typo.h2\n : (variant === 'secondary' ? typo.button2 : typo.flag),\n color,\n });\n\n const pressEffect = selected ? 'none' : 'opacity';\n\n const icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? cloneElement(icon, { fill: color }) : null;\n\n const tabElement = typeof children !== 'string' ? (\n React.cloneElement(children, {\n selected,\n })\n ) : (\n <React.Fragment>\n <Badge\n children={iconElement}\n invisible={!badgeVisible}\n />\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n </React.Fragment>\n );\n const tabIndicator = (enableIndicator && selected)\n ? <TabIndicator indicatorSize={indicatorSize} color={indicatorColor}/>\n : null;\n\n return (\n <TabBase\n pressEffect={pressEffect}\n style={tabBaseStyle}\n vertical={vertical}\n {...otherProps}\n >\n {indicatorSize === 'fit-content' ? (\n <View onLayout={onTabInnerLayout} style={tabInnerStyle}>\n {tabElement}\n\n {tabIndicator}\n </View>\n ) : (\n <React.Fragment>\n {tabElement}\n\n {tabIndicator}\n </React.Fragment>\n )}\n </TabBase>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;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,QACKF,UADL,EAGKE,YAHL,CAbR,CADJ;AAsBH;;AAAA"}
1
+ {"version":3,"names":["styles","StyleSheet","create","root","Platform","OS","minWidth","minHeight","bottomNavigation","filledInner","justifyContent","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","indicatorColor","indicatorSize","selected","selectedIcon","variant","style","onTabInnerLayout","otherProps","theme","useTheme","vertical","color","palette","text","primary","secondary","hint","containedStyle","borderColor","main","border","borderRadius","shape","roundnessExtra","borderWidth","paddingHorizontal","spacing","paddingVertical","tabBaseStyle","css","tabInnerStyle","fontStyle","createFontStyle","selector","typo","h2","button2","subtitle2","fontWeight","medium","body2","flag","pressEffect","iconElement","cloneElement","fill","tabElement","React","tabIndicator"],"sources":["Tab.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { Platform, Text, View } from 'react-native';\nimport Badge from '../Badge';\nimport TabBase from '../TabBase';\nimport type TabProps from './TabProps';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport TabIndicator from './TabIndicator';\n\nconst styles = StyleSheet.create({\n root: {\n // TODO: Remove redundant platform checking\n ...(Platform.OS === 'web' ? { minWidth: 'auto' } : {}),\n minHeight: 40,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n filledInner: {\n justifyContent: 'center',\n },\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator = false,\n icon: defaultIcon,\n indicatorColor = 'primary',\n indicatorSize = 'full',\n selected = false,\n selectedIcon,\n variant = 'primary',\n style,\n onTabInnerLayout,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const vertical = variant === 'bottom-navigation';\n\n const color = selected\n ? theme.palette.text.primary\n : variant === 'contained'\n ? theme.palette.text.secondary\n : theme.palette.text.hint;\n\n const containedStyle = {\n borderColor: selected ? theme.palette.primary.main : theme.palette.border,\n borderRadius: theme.shape.roundnessExtra,\n borderWidth: selected ? 1.5 : 1,\n paddingHorizontal: theme.spacing(3),\n paddingVertical: theme.spacing(1.5),\n };\n\n const tabBaseStyle = css([\n styles.root,\n variant === 'bottom-navigation' && styles.bottomNavigation,\n variant === 'contained' && containedStyle,\n style,\n ]);\n\n const tabInnerStyle = css([\n styles.root,\n styles.filledInner,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => variant === 'primary'\n ? typo.h2\n : variant === 'secondary'\n ? typo.button2\n : variant === 'contained'\n ? (selected ? { ...typo.subtitle2, fontWeight: typo.fontWeight.medium } : typo.body2)\n : typo.flag,\n color,\n });\n\n const pressEffect = selected ? 'none' : 'opacity';\n\n const icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? cloneElement(icon, { fill: color }) : null;\n\n const tabElement = typeof children !== 'string' ? (\n React.cloneElement(children, {\n selected,\n })\n ) : (\n <React.Fragment>\n <Badge\n children={iconElement}\n invisible={!badgeVisible}\n />\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n </React.Fragment>\n );\n const tabIndicator = (enableIndicator && selected)\n ? <TabIndicator indicatorSize={indicatorSize} color={indicatorColor}/>\n : null;\n\n return (\n <TabBase\n pressEffect={pressEffect}\n style={tabBaseStyle}\n vertical={vertical}\n {...otherProps}\n >\n {indicatorSize === 'fit-content' ? (\n <View onLayout={onTabInnerLayout} style={tabInnerStyle}>\n {tabElement}\n\n {tabIndicator}\n </View>\n ) : (\n <React.Fragment>\n {tabElement}\n\n {tabIndicator}\n </React.Fragment>\n )}\n </TabBase>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,MAAMA,MAAM,GAAGC,kBAAA,CAAWC,MAAX,CAAkB;EAC7BC,IAAI,EAAE,EACF;IACA,IAAIC,qBAAA,CAASC,EAAT,KAAgB,KAAhB,GAAwB;MAAEC,QAAQ,EAAE;IAAZ,CAAxB,GAA+C,EAAnD,CAFE;IAGFC,SAAS,EAAE;EAHT,CADuB;EAM7BC,gBAAgB,EAAE;IACdD,SA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MAAMiB,YAAY,GAAInD,eAAe,IAAIK,QAApB,gBACf,6BAAC,qBAAD;IAAc,aAAa,EAAED,aAA7B;IAA4C,KAAK,EAAED;EAAnD,EADe,GAEf,IAFN;EAIA,oBACI,6BAAC,gBAAD;IACI,WAAW,EAAE0C,WADjB;IAEI,KAAK,EAAEd,YAFX;IAGI,QAAQ,EAAElB;EAHd,GAIQH,UAJR,GAMKN,aAAa,KAAK,aAAlB,gBACG,6BAAC,iBAAD;IAAM,QAAQ,EAAEK,gBAAhB;IAAkC,KAAK,EAAEwB;EAAzC,GACKgB,UADL,EAGKE,YAHL,CADH,gBAOG,6BAAC,cAAD,CAAO,QAAP,QACKF,UADL,EAGKE,YAHL,CAbR,CADJ;AAsBH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TabProps.ts"],"sourcesContent":["import React from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport type { TabBaseProps } from '../TabBase';\nimport type { OverridableComponentProps } from '../types';\n\nexport type TabVariant = 'primary' | 'secondary' | 'bottom-navigation';\nexport type TabIndicatorColor = 'primary' | 'secondary'\nexport type TabIndicatorSize = 'full' | 'fit-content';\n\nexport default interface TabProps extends OverridableComponentProps<TabBaseProps, {\n /**\n * If `true`, the badge is visible.\n * @default false\n */\n badgeVisible?: boolean;\n\n /**\n * The label of the Tab.\n */\n children: string | React.ReactElement;\n\n /**\n * If `true`, the indicator is enabled.\n * @default false\n */\n enableIndicator?: boolean;\n\n /**\n * If `true`, the component is selected.\n * @default false\n */\n selected?: boolean;\n\n /**\n * Element placed before the children.\n */\n icon?: React.ReactElement;\n\n /**\n * Tab indicator color\n * @default 'primary'\n */\n indicatorColor?: TabIndicatorColor;\n\n /**\n * The size of tab indicator.\n * 'full' adjusts the indicator to the size of the Tab,\n * while 'fit-content' adjusts the indicator to the size of the content inside the Tab.\n * @default 'full'\n */\n indicatorSize?: TabIndicatorSize;\n\n /**\n * If supplied, use this icon on selected state.\n */\n selectedIcon?: React.ReactElement;\n\n /**\n * The variant to use.\n * @default 'primary'\n */\n variant?: TabVariant;\n\n /**\n * Function to be passed to the child component's onLayout prop.\n */\n onTabInnerLayout?: (event: LayoutChangeEvent) => void;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["TabProps.ts"],"sourcesContent":["import React from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport type { TabBaseProps } from '../TabBase';\nimport type { OverridableComponentProps } from '../types';\n\nexport type TabVariant = 'primary' | 'secondary' | 'bottom-navigation' | 'contained';\nexport type TabIndicatorColor = 'primary' | 'secondary'\nexport type TabIndicatorSize = 'full' | 'fit-content';\n\nexport default interface TabProps extends OverridableComponentProps<TabBaseProps, {\n /**\n * If `true`, the badge is visible.\n * @default false\n */\n badgeVisible?: boolean;\n\n /**\n * The label of the Tab.\n */\n children: string | React.ReactElement;\n\n /**\n * If `true`, the indicator is enabled.\n * @default false\n */\n enableIndicator?: boolean;\n\n /**\n * If `true`, the component is selected.\n * @default false\n */\n selected?: boolean;\n\n /**\n * Element placed before the children.\n */\n icon?: React.ReactElement;\n\n /**\n * Tab indicator color\n * @default 'primary'\n */\n indicatorColor?: TabIndicatorColor;\n\n /**\n * The size of tab indicator.\n * 'full' adjusts the indicator to the size of the Tab,\n * while 'fit-content' adjusts the indicator to the size of the content inside the Tab.\n * @default 'full'\n */\n indicatorSize?: TabIndicatorSize;\n\n /**\n * If supplied, use this icon on selected state.\n */\n selectedIcon?: React.ReactElement;\n\n /**\n * The variant to use.\n * @default 'primary'\n */\n variant?: TabVariant;\n\n /**\n * Function to be passed to the child component's onLayout prop.\n */\n onTabInnerLayout?: (event: LayoutChangeEvent) => void;\n}> {}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TypographyProps.ts"],"sourcesContent":["import React from 'react';\nimport type { AccessibilityProps, TextProps } from 'react-native';\nimport type { ComponentProps } from '../types';\n\nexport type TypographyAlign = 'inherit' | 'left' | 'center' | 'right' | 'justify';\n\nexport type TypographyColor =\n | 'inherit'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'warning'\n | 'error'\n | 'accent'\n | 'textPrimary'\n | 'textSecondary'\n | 'textAccent'\n | 'textHint';\n\nexport type TypographyVariant =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'subtitle1'\n | 'subtitle2'\n | 'body1'\n | 'body2'\n | 'caption1'\n | 'caption2'\n | 'flag';\n\nexport interface Accessibility {\n accessibilityRole: AccessibilityProps['accessibilityRole'];\n 'area-level'?: number;\n}\n\nexport interface AccessibilityMap extends Partial<{\n [key: string]: Accessibility;\n}> {}\n\nexport default interface TypographyProps extends ComponentProps<{\n /**\n * Applies HTML tag at web and communicates purpose of component at app\n */\n accessibilityRole?: AccessibilityProps['accessibilityRole'];\n\n /**\n * Set the text-align on the component.\n * The value 'justify' is not supported on Android and fallbacks to left.\n * @default 'inherit'\n */\n align?: TypographyAlign;\n\n /**\n * Applies HTML heading level\n */\n ariaLevel?: number;\n\n /**\n * Specifies whether fonts should scale to respect Text Size accessibility settings.\n * @default false\n */\n disableFontScaling?: boolean;\n\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The color of the component. It supports those theme colors that make sense for this component.\n * @default 'inherit'\n */\n color?: TypographyColor;\n\n /**\n * The text ellipsis mode.\n * @default 'tail'\n */\n ellipsizeMode?: TextProps['ellipsizeMode'];\n\n /**\n * Internal use only. The hyperlink of the text.\n */\n href?: string;\n\n /**\n * Used to truncate the text with an ellipsis after computing the text\n * layout, including line wrapping, such that the total number of lines\n * does not exceed this number.\n */\n numberOfLines?: TextProps['numberOfLines'];\n\n /**\n * Lets the user select text, to use the native copy and paste functionality.\n */\n onPress?: TextProps['onPress'];\n\n /**\n * Lets the user select text, to use the native copy and paste functionality.\n */\n selectable?: boolean;\n\n /**\n * Applies the theme typography styles.\n * @default 'body1'\n */\n variant?: TypographyVariant;\n\n\n /**\n * Callback that is called when the text layout has been calculated.\n */\n onTextLayout?: TextProps['onTextLayout'];\n\n /**\n * Callback that is called when the layout of the Text component changes.\n */\n onLayout?: TextProps['onLayout'];\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["TypographyProps.ts"],"sourcesContent":["import React from 'react';\nimport type { AccessibilityProps, TextProps } from 'react-native';\nimport type { ComponentProps } from '../types';\n\nexport type TypographyAlign = 'inherit' | 'left' | 'center' | 'right' | 'justify';\n\nexport type TypographyColor =\n | 'inherit'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'warning'\n | 'error'\n | 'accent'\n | 'textPrimary'\n | 'textSecondary'\n | 'textAccent'\n | 'textHint';\n\nexport type TypographyVariant =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'subtitle1'\n | 'subtitle2'\n | 'body1'\n | 'body2'\n | 'caption1'\n | 'caption2'\n | 'flag'\n | 'button1'\n | 'button2';\n\nexport interface Accessibility {\n accessibilityRole: AccessibilityProps['accessibilityRole'];\n 'area-level'?: number;\n}\n\nexport interface AccessibilityMap extends Partial<{\n [key: string]: Accessibility;\n}> {}\n\nexport default interface TypographyProps extends ComponentProps<{\n /**\n * Applies HTML tag at web and communicates purpose of component at app\n */\n accessibilityRole?: AccessibilityProps['accessibilityRole'];\n\n /**\n * Set the text-align on the component.\n * The value 'justify' is not supported on Android and fallbacks to left.\n * @default 'inherit'\n */\n align?: TypographyAlign;\n\n /**\n * Applies HTML heading level\n */\n ariaLevel?: number;\n\n /**\n * Specifies whether fonts should scale to respect Text Size accessibility settings.\n * @default false\n */\n disableFontScaling?: boolean;\n\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The color of the component. It supports those theme colors that make sense for this component.\n * @default 'inherit'\n */\n color?: TypographyColor;\n\n /**\n * The text ellipsis mode.\n * @default 'tail'\n */\n ellipsizeMode?: TextProps['ellipsizeMode'];\n\n /**\n * Internal use only. The hyperlink of the text.\n */\n href?: string;\n\n /**\n * Used to truncate the text with an ellipsis after computing the text\n * layout, including line wrapping, such that the total number of lines\n * does not exceed this number.\n */\n numberOfLines?: TextProps['numberOfLines'];\n\n /**\n * Lets the user select text, to use the native copy and paste functionality.\n */\n onPress?: TextProps['onPress'];\n\n /**\n * Lets the user select text, to use the native copy and paste functionality.\n */\n selectable?: boolean;\n\n /**\n * Applies the theme typography styles.\n * @default 'body1'\n */\n variant?: TypographyVariant;\n\n\n /**\n * Callback that is called when the text layout has been calculated.\n */\n onTextLayout?: TextProps['onTextLayout'];\n\n /**\n * Callback that is called when the layout of the Text component changes.\n */\n onLayout?: TextProps['onLayout'];\n}> {}\n"],"mappings":""}
@@ -1,66 +1,152 @@
1
- import React, { useState } from 'react';
2
- import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
3
- import { ChevronDown as ChevronDownIcon } from '../internal/icons';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import Animated, { useAnimatedStyle, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
4
+ import { useTheme } from '../styles';
5
+ import { ChevronDown } from '../internal/icons';
4
6
  import ButtonBase from '../ButtonBase';
5
7
  import Column from '../Column';
6
- import Divider from '../Divider';
8
+ import Row from '../Row';
7
9
  import Spacer from '../Spacer';
8
10
  import Typography from '../Typography';
9
- import { useTheme } from '../styles';
11
+ const CONTENT_Y_START = 30;
12
+ const CONTENT_Y_END = 0;
13
+ const ROTATE_HIDE_DEGREE = 0;
14
+ const ROTATE_SHOW_DEGREE = 180;
10
15
  const ANIMATION_CONFIG = {
11
- duration: 250
16
+ duration: 300
12
17
  };
13
18
 
14
19
  const useStyles = function () {
15
20
  const theme = useTheme();
16
21
  return {
17
22
  root: {
18
- flexDirection: 'row',
19
- paddingVertical: theme.spacing(3)
23
+ marginBottom: theme.spacing(2)
24
+ },
25
+ title: {
26
+ borderRadius: theme.spacing(4),
27
+ backgroundColor: theme.palette.paper.grey,
28
+ paddingHorizontal: theme.spacing(4),
29
+ paddingVertical: theme.spacing(3.5),
30
+ alignItems: 'center'
31
+ },
32
+ titleColumn: {
33
+ flexShrink: 1
34
+ },
35
+ subtitle: {
36
+ fontSize: 11,
37
+ lineHeight: 12,
38
+ fontFamily: 'Inter-Regular'
39
+ },
40
+ contentView: {
41
+ position: 'absolute',
42
+ width: '100%',
43
+ borderRadius: theme.spacing(4),
44
+ backgroundColor: theme.palette.paper.grey,
45
+ paddingHorizontal: theme.spacing(4),
46
+ paddingVertical: theme.spacing(6),
47
+ marginTop: theme.spacing(2)
20
48
  }
21
49
  };
22
50
  };
23
51
 
24
52
  export default function Accordion(props) {
25
53
  const {
54
+ title,
55
+ subTitle,
26
56
  content,
27
- LeftIcon,
28
57
  RightIcon,
29
- title,
30
- titleVariant = 'subtitle2'
58
+ LeftComponent,
59
+ isInitialExpanded = false
31
60
  } = props;
32
61
  const styles = useStyles();
62
+ const theme = useTheme();
63
+ const CONTENT_MARGIN_HEIGHT = theme.spacing(2);
33
64
  const [isExpanded, setIsExpanded] = useState(false);
34
- const rotate = useSharedValue(0);
65
+ const shouldInitialExpandedRef = useRef(isInitialExpanded);
66
+ const rotate = useSharedValue(ROTATE_HIDE_DEGREE);
67
+ const animatedOpacity = useSharedValue(0);
68
+ const animatedContentY = useSharedValue(CONTENT_Y_START);
69
+ const animatedHeight = useSharedValue(0);
70
+ const [contentHeight, setContentHeight] = useState(0);
35
71
  const animatedChevronDownStyles = useAnimatedStyle(() => ({
36
72
  transform: [{
37
73
  rotate: `${rotate.value}deg`
38
74
  }]
39
75
  }), []);
76
+ const animatedContentBackgroundStyles = useAnimatedStyle(() => ({
77
+ height: animatedHeight.value,
78
+ opacity: animatedOpacity.value,
79
+ overflow: 'hidden'
80
+ }), []);
81
+ const animatedContentStyle = useAnimatedStyle(() => ({
82
+ transform: [{
83
+ translateY: animatedContentY.value
84
+ }],
85
+ opacity: animatedOpacity.value
86
+ }), []);
40
87
 
41
88
  const onPress = () => {
42
89
  setIsExpanded(prev => !prev);
43
- rotate.value = withTiming(!isExpanded ? 180 : 0, ANIMATION_CONFIG);
44
90
  };
45
91
 
46
- return /*#__PURE__*/React.createElement(Column, null, /*#__PURE__*/React.createElement(ButtonBase, {
47
- onPress: onPress,
92
+ const onLayout = event => {
93
+ const height = event.nativeEvent.layout.height + CONTENT_MARGIN_HEIGHT;
94
+ setContentHeight(height);
95
+
96
+ if (shouldInitialExpandedRef.current) {
97
+ shouldInitialExpandedRef.current = false;
98
+ setIsExpanded(true);
99
+ }
100
+ };
101
+
102
+ useEffect(() => {
103
+ rotate.value = withTiming(isExpanded ? ROTATE_SHOW_DEGREE : ROTATE_HIDE_DEGREE, ANIMATION_CONFIG);
104
+ animatedHeight.value = withTiming(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);
105
+ animatedOpacity.value = withTiming(isExpanded ? 1 : 0, ANIMATION_CONFIG);
106
+ animatedContentY.value = isExpanded ? withTiming(CONTENT_Y_END, ANIMATION_CONFIG) : withDelay(ANIMATION_CONFIG.duration, withTiming(CONTENT_Y_START, {
107
+ duration: 0
108
+ }));
109
+ }, [isExpanded, contentHeight]);
110
+ return /*#__PURE__*/React.createElement(Column, {
48
111
  style: styles.root
49
- }, LeftIcon ? /*#__PURE__*/React.createElement(React.Fragment, null, LeftIcon, /*#__PURE__*/React.createElement(Spacer, {
50
- size: 2
51
- })) : null, /*#__PURE__*/React.createElement(Typography, {
112
+ }, /*#__PURE__*/React.createElement(ButtonBase, {
113
+ onPress: onPress
114
+ }, /*#__PURE__*/React.createElement(Row, {
115
+ style: styles.title
116
+ }, LeftComponent ? LeftComponent : null, /*#__PURE__*/React.createElement(Column, {
117
+ style: styles.titleColumn
118
+ }, /*#__PURE__*/React.createElement(Typography, {
119
+ variant: 'subtitle2',
52
120
  children: title,
53
- variant: titleVariant
54
- }), /*#__PURE__*/React.createElement(Spacer, {
121
+ color: 'textPrimary',
122
+ numberOfLines: 1
123
+ }), subTitle ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Spacer, {
124
+ size: 0.5
125
+ }), /*#__PURE__*/React.createElement(Typography, {
126
+ style: styles.subtitle,
127
+ color: 'tertiary',
128
+ children: subTitle
129
+ })) : null), /*#__PURE__*/React.createElement(Spacer, {
55
130
  flex: 1
56
131
  }), /*#__PURE__*/React.createElement(Spacer, {
57
- size: 2
58
- }), /*#__PURE__*/React.createElement(Column, null, /*#__PURE__*/React.createElement(Animated.View, {
132
+ size: 3
133
+ }), /*#__PURE__*/React.createElement(Animated.View, {
59
134
  style: animatedChevronDownStyles
60
- }, RightIcon ? RightIcon : /*#__PURE__*/React.createElement(ChevronDownIcon, null)))), isExpanded ? /*#__PURE__*/React.isValidElement(content) ? content : /*#__PURE__*/React.createElement(Typography, {
61
- children: content,
62
- color: 'textSecondary',
63
- variant: 'body2'
64
- }) : null, /*#__PURE__*/React.createElement(Divider, null));
135
+ }, RightIcon ? RightIcon : /*#__PURE__*/React.createElement(ChevronDown, {
136
+ width: 20,
137
+ height: 20,
138
+ color: 'tertiary'
139
+ })))), /*#__PURE__*/React.createElement(Animated.View, {
140
+ style: animatedContentBackgroundStyles
141
+ }, /*#__PURE__*/React.createElement(View, {
142
+ onLayout: onLayout,
143
+ style: styles.contentView
144
+ }, /*#__PURE__*/React.createElement(Animated.View, {
145
+ style: animatedContentStyle
146
+ }, typeof content === 'string' ? /*#__PURE__*/React.createElement(Typography, {
147
+ variant: 'subtitle2',
148
+ color: 'tertiary',
149
+ children: content
150
+ }) : content))));
65
151
  }
66
152
  //# sourceMappingURL=Accordion.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useState","Animated","useAnimatedStyle","useSharedValue","withTiming","ChevronDown","ChevronDownIcon","ButtonBase","Column","Divider","Spacer","Typography","useTheme","ANIMATION_CONFIG","duration","useStyles","theme","root","flexDirection","paddingVertical","spacing","Accordion","props","content","LeftIcon","RightIcon","title","titleVariant","styles","isExpanded","setIsExpanded","rotate","animatedChevronDownStyles","transform","value","onPress","prev","isValidElement"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { ChevronDown as ChevronDownIcon } from '../internal/icons';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Divider from '../Divider';\nimport Spacer from '../Spacer';\nimport Typography from '../Typography';\nimport { useTheme } from '../styles';\n\nimport AccordionProps from './AccordionProps';\n\ntype AccordionStyles = NamedStylesStringUnion<'root'>;\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 250 };\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'row',\n paddingVertical: theme.spacing(3),\n },\n };\n};\n\nexport default function Accordion(props: AccordionProps) {\n const {\n content,\n LeftIcon,\n RightIcon,\n title,\n titleVariant = 'subtitle2',\n } = props;\n\n const styles = useStyles();\n\n const [isExpanded, setIsExpanded] = useState(false);\n\n const rotate = useSharedValue(0);\n\n const animatedChevronDownStyles = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }), []);\n\n const onPress = () => {\n setIsExpanded(prev => !prev);\n rotate.value = withTiming(!isExpanded ? 180 : 0, ANIMATION_CONFIG);\n };\n\n return (\n <Column>\n <ButtonBase\n onPress={onPress}\n style={styles.root}\n >\n {LeftIcon ? (\n <React.Fragment>\n {LeftIcon}\n <Spacer size={2}/>\n </React.Fragment>\n ) : null}\n\n <Typography\n children={title}\n variant={titleVariant}\n />\n\n <Spacer flex={1}/>\n\n <Spacer size={2}/>\n\n <Column>\n <Animated.View style={animatedChevronDownStyles}>\n {RightIcon ? RightIcon : <ChevronDownIcon/>}\n </Animated.View>\n </Column>\n </ButtonBase>\n\n {isExpanded ? (\n React.isValidElement(content) ? (content) : (\n <Typography\n children={content}\n color={'textSecondary'}\n variant={'body2'}\n />\n )\n ) : null}\n\n <Divider/>\n </Column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b;IACAL,MAAM,CAACG,KAAP,GAAe9B,UAAU,CAAC,CAACyB,UAAD,GAAc,GAAd,GAAoB,CAArB,EAAwBhB,gBAAxB,CAAzB;EACH,CAHD;;EAKA,oBACI,oBAAC,MAAD,qBACI,oBAAC,UAAD;IACI,OAAO,EAAEsB,OADb;IAEI,KAAK,EAAEP,MAAM,CAACX;EAFlB,GAIKO,QAAQ,gBACL,oBAAC,KAAD,CAAO,QAAP,QACKA,QADL,eAEI,oBAAC,MAAD;IAAQ,IAAI,EAAE;EAAd,EAFJ,CADK,GAKL,IATR,eAWI,oBAAC,UAAD;IACI,QAAQ,EAAEE,KADd;IAEI,OAAO,EAAEC;EAFb,EAXJ,eAgBI,oBAAC,MAAD;IAAQ,IAAI,EAAE;EAAd,EAhBJ,eAkBI,oBAAC,MAAD;IAAQ,IAAI,EAAE;EAAd,EAlBJ,eAoBI,oBAAC,MAAD,qBACI,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAEK;EAAtB,GACKP,SAAS,GAAGA,SAAH,gBAAe,oBAAC,eAAD,OAD7B,CADJ,CApBJ,CADJ,EA4BKI,UAAU,GACP,aAAA9B,KAAK,CAACsC,cAAN,CAAqBd,OAArB,IAAiCA,OAAjC,gBACI,oBAAC,UAAD;IACI,QAAQ,EAAEA,OADd;IAEI,KAAK,EAAE,eAFX;IAGI,OAAO,EAAE;EAHb,EAFG,GAQP,IApCR,eAsCI,oBAAC,OAAD,OAtCJ,CADJ;AA0CH"}
1
+ {"version":3,"names":["React","useEffect","useRef","useState","View","Animated","useAnimatedStyle","useSharedValue","withDelay","withTiming","useTheme","ChevronDown","ButtonBase","Column","Row","Spacer","Typography","CONTENT_Y_START","CONTENT_Y_END","ROTATE_HIDE_DEGREE","ROTATE_SHOW_DEGREE","ANIMATION_CONFIG","duration","useStyles","theme","root","marginBottom","spacing","title","borderRadius","backgroundColor","palette","paper","grey","paddingHorizontal","paddingVertical","alignItems","titleColumn","flexShrink","subtitle","fontSize","lineHeight","fontFamily","contentView","position","width","marginTop","Accordion","props","subTitle","content","RightIcon","LeftComponent","isInitialExpanded","styles","CONTENT_MARGIN_HEIGHT","isExpanded","setIsExpanded","shouldInitialExpandedRef","rotate","animatedOpacity","animatedContentY","animatedHeight","contentHeight","setContentHeight","animatedChevronDownStyles","transform","value","animatedContentBackgroundStyles","height","opacity","overflow","animatedContentStyle","translateY","onPress","prev","onLayout","event","nativeEvent","layout","current"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { LayoutChangeEvent, View } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n WithTimingConfig,\n} from 'react-native-reanimated';\nimport { 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 Typography from '../Typography';\n\nimport AccordionProps from './AccordionProps';\n\ntype AccordionStyles = NamedStylesStringUnion<\n 'root'\n | 'title'\n | 'titleColumn'\n | 'subtitle'\n | 'contentView'\n>;\n\nconst CONTENT_Y_START = 30;\nconst CONTENT_Y_END = 0;\n\nconst ROTATE_HIDE_DEGREE = 0;\nconst ROTATE_SHOW_DEGREE = 180;\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 300 };\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: { marginBottom: theme.spacing(2) },\n title: {\n borderRadius: theme.spacing(4),\n backgroundColor: theme.palette.paper.grey,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3.5),\n alignItems: 'center',\n },\n titleColumn: { flexShrink: 1 },\n subtitle: {\n fontSize: 11,\n lineHeight: 12,\n fontFamily: 'Inter-Regular',\n },\n contentView: {\n position: 'absolute',\n width: '100%',\n borderRadius: theme.spacing(4),\n backgroundColor: theme.palette.paper.grey,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(6),\n marginTop: theme.spacing(2),\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 } = props;\n\n const styles = useStyles();\n const theme = useTheme();\n const CONTENT_MARGIN_HEIGHT = theme.spacing(2);\n\n const [isExpanded, setIsExpanded] = useState(false);\n const shouldInitialExpandedRef = useRef<boolean>(isInitialExpanded);\n\n const rotate = useSharedValue(ROTATE_HIDE_DEGREE);\n const animatedOpacity = useSharedValue(0);\n const animatedContentY = useSharedValue(CONTENT_Y_START);\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 opacity: animatedOpacity.value,\n overflow: 'hidden',\n }), []);\n\n const animatedContentStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: animatedContentY.value }],\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 setIsExpanded(true);\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 animatedOpacity.value = withTiming(isExpanded ? 1 : 0, ANIMATION_CONFIG);\n\n animatedContentY.value = isExpanded\n ? withTiming(CONTENT_Y_END, ANIMATION_CONFIG)\n : withDelay(ANIMATION_CONFIG.duration as number, withTiming(CONTENT_Y_START, { duration: 0 }));\n }, [isExpanded, contentHeight]);\n\n return (\n <Column style={styles.root}>\n <ButtonBase onPress={onPress}>\n <Row style={styles.title}>\n {LeftComponent ? LeftComponent : null}\n\n <Column style={styles.titleColumn}>\n <Typography\n variant={'subtitle2'}\n children={title}\n color={'textPrimary'}\n numberOfLines={1}\n />\n\n {subTitle ? (\n <React.Fragment>\n <Spacer size={0.5}/>\n\n <Typography\n style={styles.subtitle}\n color={'tertiary'}\n children={subTitle}\n />\n </React.Fragment>\n ) : null}\n </Column>\n\n <Spacer flex={1}/>\n\n <Spacer size={3}/>\n\n <Animated.View style={animatedChevronDownStyles}>\n {RightIcon ? RightIcon : (\n <ChevronDown\n width={20}\n height={20}\n color={'tertiary'}\n />\n )}\n </Animated.View>\n </Row>\n </ButtonBase>\n\n <Animated.View style={animatedContentBackgroundStyles}>\n <View\n onLayout={onLayout}\n style={styles.contentView}\n >\n <Animated.View style={animatedContentStyle}>\n {typeof content === 'string' ? (\n <Typography\n variant={'subtitle2'}\n color={'tertiary'}\n children={content}\n />\n ) : (content)}\n </Animated.View>\n </View>\n </Animated.View>\n </Column>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AACA,SAA4BC,IAA5B,QAAwC,cAAxC;AACA,OAAOC,QAAP,IACIC,gBADJ,EAEIC,cAFJ,EAGIC,SAHJ,EAIIC,UAJJ,QAMO,yBANP;AAQA,SAASC,QAAT,QAAyB,WAAzB;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,GAAP,MAAgB,QAAhB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AAYA,MAAMC,eAAe,GAAG,EAAxB;AACA,MAAMC,aAAa,GAAG,CAAtB;AAEA,MAAM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AAC,MAAD;IAAQ,KAAK,EAAEE,MAAM,CAACjB;EAAtB,gBACI,oBAAC,UAAD;IACI,OAAO,EAAE,WADb;IAEI,QAAQ,EAAET,KAFd;IAGI,KAAK,EAAE,aAHX;IAII,aAAa,EAAE;EAJnB,EADJ,EAQKqB,QAAQ,gBACL,oBAAC,KAAD,CAAO,QAAP,qBACI,oBAAC,MAAD;IAAQ,IAAI,EAAE;EAAd,EADJ,eAGI,oBAAC,UAAD;IACI,KAAK,EAAEK,MAAM,CAACf,QADlB;IAEI,KAAK,EAAE,UAFX;IAGI,QAAQ,EAAEU;EAHd,EAHJ,CADK,GAUL,IAlBR,CAHJ,eAwBI,oBAAC,MAAD;IAAQ,IAAI,EAAE;EAAd,EAxBJ,eA0BI,oBAAC,MAAD;IAAQ,IAAI,EAAE;EAAd,EA1BJ,eA4BI,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAEgB;EAAtB,GACKd,SAAS,GAAGA,SAAH,gBACN,oBAAC,WAAD;IACI,KAAK,EAAE,EADX;IAEI,MAAM,EAAE,EAFZ;IAGI,KAAK,EAAE;EAHX,EAFR,CA5BJ,CADJ,CADJ,eA0CI,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAEiB;EAAtB,gBACI,oBAAC,IAAD;IACI,QAAQ,EAAEQ,QADd;IAEI,KAAK,EAAEtB,MAAM,CAACX;EAFlB,gBAII,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAE6B;EAAtB,GACK,OAAOtB,OAAP,KAAmB,QAAnB,gBACG,oBAAC,UAAD;IACI,OAAO,EAAE,WADb;IAEI,KAAK,EAAE,UAFX;IAGI,QAAQ,EAAEA;EAHd,EADH,GAMIA,OAPT,CAJJ,CADJ,CA1CJ,CADJ;AA6DH"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["AccordionProps.ts"],"sourcesContent":["import React from 'react';\nimport type { TypographyProps } from '../Typography';\n\nexport default interface AccordionProps {\n /**\n * The content of the component.\n */\n content: string | React.ReactNode;\n\n /**\n * The icon to the left of the component.\n */\n LeftIcon?: React.ReactElement;\n\n /**\n * The icon to the right of the component.\n */\n RightIcon?: React.ReactElement;\n\n /**\n * The title of the component.\n */\n title: string;\n\n /**\n * The variant of the component title.\n * @default 'subtitle2'\n */\n titleVariant?: TypographyProps['variant'];\n}"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["AccordionProps.ts"],"sourcesContent":["import React from 'react';\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.\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}"],"mappings":""}
@@ -37,11 +37,20 @@ export default function Tab(props) {
37
37
  } = props;
38
38
  const theme = useTheme();
39
39
  const vertical = variant === 'bottom-navigation';
40
- const color = selected ? theme.palette.text.primary : theme.palette.text.hint;
41
- const tabBaseStyle = css([styles.root, variant === 'bottom-navigation' && styles.bottomNavigation, style]);
40
+ const color = selected ? theme.palette.text.primary : variant === 'contained' ? theme.palette.text.secondary : theme.palette.text.hint;
41
+ const containedStyle = {
42
+ borderColor: selected ? theme.palette.primary.main : theme.palette.border,
43
+ borderRadius: theme.shape.roundnessExtra,
44
+ borderWidth: selected ? 1.5 : 1,
45
+ paddingHorizontal: theme.spacing(3),
46
+ paddingVertical: theme.spacing(1.5)
47
+ };
48
+ const tabBaseStyle = css([styles.root, variant === 'bottom-navigation' && styles.bottomNavigation, variant === 'contained' && containedStyle, style]);
42
49
  const tabInnerStyle = css([styles.root, styles.filledInner]);
43
50
  const fontStyle = createFontStyle(theme, {
44
- selector: typo => variant === 'primary' ? typo.h2 : variant === 'secondary' ? typo.button2 : typo.flag,
51
+ selector: typo => variant === 'primary' ? typo.h2 : variant === 'secondary' ? typo.button2 : variant === 'contained' ? selected ? { ...typo.subtitle2,
52
+ fontWeight: typo.fontWeight.medium
53
+ } : typo.body2 : typo.flag,
45
54
  color
46
55
  });
47
56
  const pressEffect = selected ? 'none' : 'opacity';
@@ -1 +1 @@
1
- {"version":3,"names":["React","cloneElement","Platform","Text","View","Badge","TabBase","createFontStyle","css","StyleSheet","useTheme","TabIndicator","styles","create","root","OS","minWidth","minHeight","bottomNavigation","filledInner","justifyContent","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","indicatorColor","indicatorSize","selected","selectedIcon","variant","style","onTabInnerLayout","otherProps","theme","vertical","color","palette","text","primary","hint","tabBaseStyle","tabInnerStyle","fontStyle","selector","typo","h2","button2","flag","pressEffect","iconElement","fill","tabElement","tabIndicator"],"sources":["Tab.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { Platform, Text, View } from 'react-native';\nimport Badge from '../Badge';\nimport TabBase from '../TabBase';\nimport type TabProps from './TabProps';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport TabIndicator from './TabIndicator';\n\nconst styles = StyleSheet.create({\n root: {\n // TODO: Remove redundant platform checking\n ...(Platform.OS === 'web' ? { minWidth: 'auto' } : {}),\n minHeight: 40,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n filledInner: {\n justifyContent: 'center',\n }\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator = false,\n icon: defaultIcon,\n indicatorColor = 'primary',\n indicatorSize = 'full',\n selected = false,\n selectedIcon,\n variant = 'primary',\n style,\n onTabInnerLayout,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const vertical = variant === 'bottom-navigation';\n\n const color = selected ? theme.palette.text.primary : theme.palette.text.hint;\n\n const tabBaseStyle = css([\n styles.root,\n variant === 'bottom-navigation' && styles.bottomNavigation,\n style,\n ]);\n\n const tabInnerStyle = css([\n styles.root,\n styles.filledInner,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => variant === 'primary'\n ? typo.h2\n : (variant === 'secondary' ? typo.button2 : typo.flag),\n color,\n });\n\n const pressEffect = selected ? 'none' : 'opacity';\n\n const icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? cloneElement(icon, { fill: color }) : null;\n\n const tabElement = typeof children !== 'string' ? (\n React.cloneElement(children, {\n selected,\n })\n ) : (\n <React.Fragment>\n <Badge\n children={iconElement}\n invisible={!badgeVisible}\n />\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n </React.Fragment>\n );\n const tabIndicator = (enableIndicator && selected)\n ? <TabIndicator indicatorSize={indicatorSize} color={indicatorColor}/>\n : null;\n\n return (\n <TabBase\n pressEffect={pressEffect}\n style={tabBaseStyle}\n vertical={vertical}\n {...otherProps}\n >\n {indicatorSize === 'fit-content' ? (\n <View onLayout={onTabInnerLayout} style={tabInnerStyle}>\n {tabElement}\n\n {tabIndicator}\n </View>\n ) : (\n <React.Fragment>\n {tabElement}\n\n {tabIndicator}\n </React.Fragment>\n )}\n </TabBase>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,YAAhB,QAAoC,OAApC;AACA,SAASC,QAAT,EAAmBC,IAAnB,EAAyBC,IAAzB,QAAqC,cAArC;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,OAAOC,OAAP,MAAoB,YAApB;AAEA,SAASC,eAAT,EAA0BC,GAA1B,EAA+BC,UAA/B,EAA2CC,QAA3C,QAA2D,WAA3D;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA,MAAMC,MAAM,GAAGH,UAAU,CAACI,MAAX,CAAkB;EAC7BC,IAAI,EAAE,EACF;IACA,IAAIZ,QAAQ,CAACa,EAAT,KAAgB,KAAhB,GAAwB;MAAEC,QAAQ,EAAE;IAAZ,CAAxB,GAA+C,EAAnD,CAFE;IAGFC,SAAS,EAAE;EAHT,CADuB;EAM7BC,gBAAgB,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AGI,QAAQ,GAAIC,YAAY,IAAIJ,WAApB,GAAmCA,WAAxD;EACA,MAAMyB,WAAW,GAAG1B,IAAI,gBAAGzB,YAAY,CAACyB,IAAD,EAAO;IAAE2B,IAAI,EAAEf;EAAR,CAAP,CAAf,GAAyC,IAAjE;EAEA,MAAMgB,UAAU,GAAG,OAAO9B,QAAP,KAAoB,QAApB,gBACfxB,KAAK,CAACC,YAAN,CAAmBuB,QAAnB,EAA6B;IACzBM;EADyB,CAA7B,CADe,gBAKf,oBAAC,KAAD,CAAO,QAAP,qBACI,oBAAC,KAAD;IACI,QAAQ,EAAEsB,WADd;IAEI,SAAS,EAAE,CAAC7B;EAFhB,EADJ,eAMI,oBAAC,IAAD;IACI,QAAQ,EAAEC,QADd;IAEI,KAAK,EAAEhB,GAAG,CAACqC,SAAD;EAFd,EANJ,CALJ;EAiBA,MAAMU,YAAY,GAAI9B,eAAe,IAAIK,QAApB,gBACf,oBAAC,YAAD;IAAc,aAAa,EAAED,aAA7B;IAA4C,KAAK,EAAED;EAAnD,EADe,GAEf,IAFN;EAIA,oBACI,oBAAC,OAAD;IACI,WAAW,EAAEuB,WADjB;IAEI,KAAK,EAAER,YAFX;IAGI,QAAQ,EAAEN;EAHd,GAIQF,UAJR,GAMKN,aAAa,KAAK,aAAlB,gBACG,oBAAC,IAAD;IAAM,QAAQ,EAAEK,gBAAhB;IAAkC,KAAK,EAAEU;EAAzC,GACKU,UADL,EAGKC,YAHL,CADH,gBAOG,oBAAC,KAAD,CAAO,QAAP,QACKD,UADL,EAGKC,YAHL,CAbR,CADJ;AAsBH;AAAA"}
1
+ {"version":3,"names":["React","cloneElement","Platform","Text","View","Badge","TabBase","createFontStyle","css","StyleSheet","useTheme","TabIndicator","styles","create","root","OS","minWidth","minHeight","bottomNavigation","filledInner","justifyContent","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","indicatorColor","indicatorSize","selected","selectedIcon","variant","style","onTabInnerLayout","otherProps","theme","vertical","color","palette","text","primary","secondary","hint","containedStyle","borderColor","main","border","borderRadius","shape","roundnessExtra","borderWidth","paddingHorizontal","spacing","paddingVertical","tabBaseStyle","tabInnerStyle","fontStyle","selector","typo","h2","button2","subtitle2","fontWeight","medium","body2","flag","pressEffect","iconElement","fill","tabElement","tabIndicator"],"sources":["Tab.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { Platform, Text, View } from 'react-native';\nimport Badge from '../Badge';\nimport TabBase from '../TabBase';\nimport type TabProps from './TabProps';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport TabIndicator from './TabIndicator';\n\nconst styles = StyleSheet.create({\n root: {\n // TODO: Remove redundant platform checking\n ...(Platform.OS === 'web' ? { minWidth: 'auto' } : {}),\n minHeight: 40,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n filledInner: {\n justifyContent: 'center',\n },\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator = false,\n icon: defaultIcon,\n indicatorColor = 'primary',\n indicatorSize = 'full',\n selected = false,\n selectedIcon,\n variant = 'primary',\n style,\n onTabInnerLayout,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const vertical = variant === 'bottom-navigation';\n\n const color = selected\n ? theme.palette.text.primary\n : variant === 'contained'\n ? theme.palette.text.secondary\n : theme.palette.text.hint;\n\n const containedStyle = {\n borderColor: selected ? theme.palette.primary.main : theme.palette.border,\n borderRadius: theme.shape.roundnessExtra,\n borderWidth: selected ? 1.5 : 1,\n paddingHorizontal: theme.spacing(3),\n paddingVertical: theme.spacing(1.5),\n };\n\n const tabBaseStyle = css([\n styles.root,\n variant === 'bottom-navigation' && styles.bottomNavigation,\n variant === 'contained' && containedStyle,\n style,\n ]);\n\n const tabInnerStyle = css([\n styles.root,\n styles.filledInner,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => variant === 'primary'\n ? typo.h2\n : variant === 'secondary'\n ? typo.button2\n : variant === 'contained'\n ? (selected ? { ...typo.subtitle2, fontWeight: typo.fontWeight.medium } : typo.body2)\n : typo.flag,\n color,\n });\n\n const pressEffect = selected ? 'none' : 'opacity';\n\n const icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? cloneElement(icon, { fill: color }) : null;\n\n const tabElement = typeof children !== 'string' ? (\n React.cloneElement(children, {\n selected,\n })\n ) : (\n <React.Fragment>\n <Badge\n children={iconElement}\n invisible={!badgeVisible}\n />\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n </React.Fragment>\n );\n const tabIndicator = (enableIndicator && selected)\n ? <TabIndicator indicatorSize={indicatorSize} color={indicatorColor}/>\n : null;\n\n return (\n <TabBase\n pressEffect={pressEffect}\n style={tabBaseStyle}\n vertical={vertical}\n {...otherProps}\n >\n {indicatorSize === 'fit-content' ? (\n <View onLayout={onTabInnerLayout} style={tabInnerStyle}>\n {tabElement}\n\n {tabIndicator}\n </View>\n ) : (\n <React.Fragment>\n {tabElement}\n\n {tabIndicator}\n </React.Fragment>\n )}\n </TabBase>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,YAAhB,QAAoC,OAApC;AACA,SAASC,QAAT,EAAmBC,IAAnB,EAAyBC,IAAzB,QAAqC,cAArC;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,OAAOC,OAAP,MAAoB,YAApB;AAEA,SAASC,eAAT,EAA0BC,GAA1B,EAA+BC,UAA/B,EAA2CC,QAA3C,QAA2D,WAA3D;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA,MAAMC,MAAM,GAAGH,UAAU,CAACI,MAAX,CAAkB;EAC7BC,IAAI,EAAE,EACF;IACA,IAAIZ,QAAQ,CAACa,EAAT,KAAgB,KAAhB,GAAwB;MAAEC,QAAQ,EAAE;IAAZ,CAAxB,GAA+C,EAAnD,CAFE;IAGFC,SAAS,EAAE;EAHT,CADuB;EAM7BC,gBAAgB,EAAE;IACdD,SAAS,EAAE;EADG,CANW;EAS7BE,WAAW,EAAE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7B;IAA4C,KAAK,EAAED;EAAnD,EADe,GAEf,IAFN;EAIA,oBACI,oBAAC,OAAD;IACI,WAAW,EAAEuC,WADjB;IAEI,KAAK,EAAEZ,YAFX;IAGI,QAAQ,EAAElB;EAHd,GAIQF,UAJR,GAMKN,aAAa,KAAK,aAAlB,gBACG,oBAAC,IAAD;IAAM,QAAQ,EAAEK,gBAAhB;IAAkC,KAAK,EAAEsB;EAAzC,GACKc,UADL,EAGKC,YAHL,CADH,gBAOG,oBAAC,KAAD,CAAO,QAAP,QACKD,UADL,EAGKC,YAHL,CAbR,CADJ;AAsBH;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TabProps.ts"],"sourcesContent":["import React from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport type { TabBaseProps } from '../TabBase';\nimport type { OverridableComponentProps } from '../types';\n\nexport type TabVariant = 'primary' | 'secondary' | 'bottom-navigation';\nexport type TabIndicatorColor = 'primary' | 'secondary'\nexport type TabIndicatorSize = 'full' | 'fit-content';\n\nexport default interface TabProps extends OverridableComponentProps<TabBaseProps, {\n /**\n * If `true`, the badge is visible.\n * @default false\n */\n badgeVisible?: boolean;\n\n /**\n * The label of the Tab.\n */\n children: string | React.ReactElement;\n\n /**\n * If `true`, the indicator is enabled.\n * @default false\n */\n enableIndicator?: boolean;\n\n /**\n * If `true`, the component is selected.\n * @default false\n */\n selected?: boolean;\n\n /**\n * Element placed before the children.\n */\n icon?: React.ReactElement;\n\n /**\n * Tab indicator color\n * @default 'primary'\n */\n indicatorColor?: TabIndicatorColor;\n\n /**\n * The size of tab indicator.\n * 'full' adjusts the indicator to the size of the Tab,\n * while 'fit-content' adjusts the indicator to the size of the content inside the Tab.\n * @default 'full'\n */\n indicatorSize?: TabIndicatorSize;\n\n /**\n * If supplied, use this icon on selected state.\n */\n selectedIcon?: React.ReactElement;\n\n /**\n * The variant to use.\n * @default 'primary'\n */\n variant?: TabVariant;\n\n /**\n * Function to be passed to the child component's onLayout prop.\n */\n onTabInnerLayout?: (event: LayoutChangeEvent) => void;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["TabProps.ts"],"sourcesContent":["import React from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport type { TabBaseProps } from '../TabBase';\nimport type { OverridableComponentProps } from '../types';\n\nexport type TabVariant = 'primary' | 'secondary' | 'bottom-navigation' | 'contained';\nexport type TabIndicatorColor = 'primary' | 'secondary'\nexport type TabIndicatorSize = 'full' | 'fit-content';\n\nexport default interface TabProps extends OverridableComponentProps<TabBaseProps, {\n /**\n * If `true`, the badge is visible.\n * @default false\n */\n badgeVisible?: boolean;\n\n /**\n * The label of the Tab.\n */\n children: string | React.ReactElement;\n\n /**\n * If `true`, the indicator is enabled.\n * @default false\n */\n enableIndicator?: boolean;\n\n /**\n * If `true`, the component is selected.\n * @default false\n */\n selected?: boolean;\n\n /**\n * Element placed before the children.\n */\n icon?: React.ReactElement;\n\n /**\n * Tab indicator color\n * @default 'primary'\n */\n indicatorColor?: TabIndicatorColor;\n\n /**\n * The size of tab indicator.\n * 'full' adjusts the indicator to the size of the Tab,\n * while 'fit-content' adjusts the indicator to the size of the content inside the Tab.\n * @default 'full'\n */\n indicatorSize?: TabIndicatorSize;\n\n /**\n * If supplied, use this icon on selected state.\n */\n selectedIcon?: React.ReactElement;\n\n /**\n * The variant to use.\n * @default 'primary'\n */\n variant?: TabVariant;\n\n /**\n * Function to be passed to the child component's onLayout prop.\n */\n onTabInnerLayout?: (event: LayoutChangeEvent) => void;\n}> {}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TypographyProps.ts"],"sourcesContent":["import React from 'react';\nimport type { AccessibilityProps, TextProps } from 'react-native';\nimport type { ComponentProps } from '../types';\n\nexport type TypographyAlign = 'inherit' | 'left' | 'center' | 'right' | 'justify';\n\nexport type TypographyColor =\n | 'inherit'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'warning'\n | 'error'\n | 'accent'\n | 'textPrimary'\n | 'textSecondary'\n | 'textAccent'\n | 'textHint';\n\nexport type TypographyVariant =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'subtitle1'\n | 'subtitle2'\n | 'body1'\n | 'body2'\n | 'caption1'\n | 'caption2'\n | 'flag';\n\nexport interface Accessibility {\n accessibilityRole: AccessibilityProps['accessibilityRole'];\n 'area-level'?: number;\n}\n\nexport interface AccessibilityMap extends Partial<{\n [key: string]: Accessibility;\n}> {}\n\nexport default interface TypographyProps extends ComponentProps<{\n /**\n * Applies HTML tag at web and communicates purpose of component at app\n */\n accessibilityRole?: AccessibilityProps['accessibilityRole'];\n\n /**\n * Set the text-align on the component.\n * The value 'justify' is not supported on Android and fallbacks to left.\n * @default 'inherit'\n */\n align?: TypographyAlign;\n\n /**\n * Applies HTML heading level\n */\n ariaLevel?: number;\n\n /**\n * Specifies whether fonts should scale to respect Text Size accessibility settings.\n * @default false\n */\n disableFontScaling?: boolean;\n\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The color of the component. It supports those theme colors that make sense for this component.\n * @default 'inherit'\n */\n color?: TypographyColor;\n\n /**\n * The text ellipsis mode.\n * @default 'tail'\n */\n ellipsizeMode?: TextProps['ellipsizeMode'];\n\n /**\n * Internal use only. The hyperlink of the text.\n */\n href?: string;\n\n /**\n * Used to truncate the text with an ellipsis after computing the text\n * layout, including line wrapping, such that the total number of lines\n * does not exceed this number.\n */\n numberOfLines?: TextProps['numberOfLines'];\n\n /**\n * Lets the user select text, to use the native copy and paste functionality.\n */\n onPress?: TextProps['onPress'];\n\n /**\n * Lets the user select text, to use the native copy and paste functionality.\n */\n selectable?: boolean;\n\n /**\n * Applies the theme typography styles.\n * @default 'body1'\n */\n variant?: TypographyVariant;\n\n\n /**\n * Callback that is called when the text layout has been calculated.\n */\n onTextLayout?: TextProps['onTextLayout'];\n\n /**\n * Callback that is called when the layout of the Text component changes.\n */\n onLayout?: TextProps['onLayout'];\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["TypographyProps.ts"],"sourcesContent":["import React from 'react';\nimport type { AccessibilityProps, TextProps } from 'react-native';\nimport type { ComponentProps } from '../types';\n\nexport type TypographyAlign = 'inherit' | 'left' | 'center' | 'right' | 'justify';\n\nexport type TypographyColor =\n | 'inherit'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'warning'\n | 'error'\n | 'accent'\n | 'textPrimary'\n | 'textSecondary'\n | 'textAccent'\n | 'textHint';\n\nexport type TypographyVariant =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'subtitle1'\n | 'subtitle2'\n | 'body1'\n | 'body2'\n | 'caption1'\n | 'caption2'\n | 'flag'\n | 'button1'\n | 'button2';\n\nexport interface Accessibility {\n accessibilityRole: AccessibilityProps['accessibilityRole'];\n 'area-level'?: number;\n}\n\nexport interface AccessibilityMap extends Partial<{\n [key: string]: Accessibility;\n}> {}\n\nexport default interface TypographyProps extends ComponentProps<{\n /**\n * Applies HTML tag at web and communicates purpose of component at app\n */\n accessibilityRole?: AccessibilityProps['accessibilityRole'];\n\n /**\n * Set the text-align on the component.\n * The value 'justify' is not supported on Android and fallbacks to left.\n * @default 'inherit'\n */\n align?: TypographyAlign;\n\n /**\n * Applies HTML heading level\n */\n ariaLevel?: number;\n\n /**\n * Specifies whether fonts should scale to respect Text Size accessibility settings.\n * @default false\n */\n disableFontScaling?: boolean;\n\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The color of the component. It supports those theme colors that make sense for this component.\n * @default 'inherit'\n */\n color?: TypographyColor;\n\n /**\n * The text ellipsis mode.\n * @default 'tail'\n */\n ellipsizeMode?: TextProps['ellipsizeMode'];\n\n /**\n * Internal use only. The hyperlink of the text.\n */\n href?: string;\n\n /**\n * Used to truncate the text with an ellipsis after computing the text\n * layout, including line wrapping, such that the total number of lines\n * does not exceed this number.\n */\n numberOfLines?: TextProps['numberOfLines'];\n\n /**\n * Lets the user select text, to use the native copy and paste functionality.\n */\n onPress?: TextProps['onPress'];\n\n /**\n * Lets the user select text, to use the native copy and paste functionality.\n */\n selectable?: boolean;\n\n /**\n * Applies the theme typography styles.\n * @default 'body1'\n */\n variant?: TypographyVariant;\n\n\n /**\n * Callback that is called when the text layout has been calculated.\n */\n onTextLayout?: TextProps['onTextLayout'];\n\n /**\n * Callback that is called when the layout of the Text component changes.\n */\n onLayout?: TextProps['onLayout'];\n}> {}\n"],"mappings":""}
@@ -1,25 +1,28 @@
1
1
  import React from 'react';
2
- import type { TypographyProps } from '../Typography';
3
2
  export default interface AccordionProps {
4
3
  /**
5
- * The content of the component.
4
+ * The title of the component.
6
5
  */
7
- content: string | React.ReactNode;
6
+ title: string | React.ReactNode;
7
+ /**
8
+ * The subtitle of the component.
9
+ */
10
+ subTitle?: string | React.ReactNode;
8
11
  /**
9
- * The icon to the left of the component.
12
+ * The component to the left of the title.
10
13
  */
11
- LeftIcon?: React.ReactElement;
14
+ LeftComponent?: React.ReactNode;
12
15
  /**
13
- * The icon to the right of the component.
16
+ * The icon to the right of the title.
14
17
  */
15
18
  RightIcon?: React.ReactElement;
16
19
  /**
17
- * The title of the component.
20
+ * The content of the component.
18
21
  */
19
- title: string;
22
+ content: string | React.ReactNode;
20
23
  /**
21
- * The variant of the component title.
22
- * @default 'subtitle2'
24
+ * The initial state of expanding
25
+ * @default false
23
26
  */
24
- titleVariant?: TypographyProps['variant'];
27
+ isInitialExpanded?: boolean;
25
28
  }
@@ -2,7 +2,7 @@ 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 type TabVariant = 'primary' | 'secondary' | 'bottom-navigation';
5
+ export declare type TabVariant = 'primary' | 'secondary' | 'bottom-navigation' | 'contained';
6
6
  export declare type TabIndicatorColor = 'primary' | 'secondary';
7
7
  export declare type TabIndicatorSize = 'full' | 'fit-content';
8
8
  export default interface TabProps extends OverridableComponentProps<TabBaseProps, {
@@ -3,7 +3,7 @@ import type { AccessibilityProps, TextProps } from 'react-native';
3
3
  import type { ComponentProps } from '../types';
4
4
  export declare type TypographyAlign = 'inherit' | 'left' | 'center' | 'right' | 'justify';
5
5
  export declare type TypographyColor = 'inherit' | 'primary' | 'secondary' | 'tertiary' | 'warning' | 'error' | 'accent' | 'textPrimary' | 'textSecondary' | 'textAccent' | 'textHint';
6
- export declare type TypographyVariant = 'h1' | 'h2' | 'h3' | 'subtitle1' | 'subtitle2' | 'body1' | 'body2' | 'caption1' | 'caption2' | 'flag';
6
+ export declare type TypographyVariant = 'h1' | 'h2' | 'h3' | 'subtitle1' | 'subtitle2' | 'body1' | 'body2' | 'caption1' | 'caption2' | 'flag' | 'button1' | 'button2';
7
7
  export interface Accessibility {
8
8
  accessibilityRole: AccessibilityProps['accessibilityRole'];
9
9
  'area-level'?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fountain-ui/core",
3
- "version": "2.0.0-beta.80",
3
+ "version": "2.0.0-beta.81",
4
4
  "author": "Fountain-UI Team",
5
5
  "description": "React components that implement Tappytoon's Fountain Design.",
6
6
  "license": "MIT",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "37ce762e5307ea990f832f2413d8c1248be3919e"
70
+ "gitHead": "6a28f31a6f19409b3b2249968f40a0085e3836ec"
71
71
  }
@@ -1,96 +1,191 @@
1
- import React, { useState } from 'react';
2
- import type { WithTimingConfig } from 'react-native-reanimated';
3
- import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { LayoutChangeEvent, View } from 'react-native';
3
+ import Animated, {
4
+ useAnimatedStyle,
5
+ useSharedValue,
6
+ withDelay,
7
+ withTiming,
8
+ WithTimingConfig,
9
+ } from 'react-native-reanimated';
4
10
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
5
- import { ChevronDown as ChevronDownIcon } from '../internal/icons';
11
+ import { useTheme } from '../styles';
12
+ import { ChevronDown } from '../internal/icons';
6
13
  import ButtonBase from '../ButtonBase';
7
14
  import Column from '../Column';
8
- import Divider from '../Divider';
15
+ import Row from '../Row';
9
16
  import Spacer from '../Spacer';
10
17
  import Typography from '../Typography';
11
- import { useTheme } from '../styles';
12
18
 
13
19
  import AccordionProps from './AccordionProps';
14
20
 
15
- type AccordionStyles = NamedStylesStringUnion<'root'>;
21
+ type AccordionStyles = NamedStylesStringUnion<
22
+ 'root'
23
+ | 'title'
24
+ | 'titleColumn'
25
+ | 'subtitle'
26
+ | 'contentView'
27
+ >;
28
+
29
+ const CONTENT_Y_START = 30;
30
+ const CONTENT_Y_END = 0;
16
31
 
17
- const ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 250 };
32
+ const ROTATE_HIDE_DEGREE = 0;
33
+ const ROTATE_SHOW_DEGREE = 180;
34
+ const ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 300 };
18
35
 
19
36
  const useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {
20
37
  const theme = useTheme();
21
38
 
22
39
  return {
23
- root: {
24
- flexDirection: 'row',
25
- paddingVertical: theme.spacing(3),
40
+ root: { marginBottom: theme.spacing(2) },
41
+ title: {
42
+ borderRadius: theme.spacing(4),
43
+ backgroundColor: theme.palette.paper.grey,
44
+ paddingHorizontal: theme.spacing(4),
45
+ paddingVertical: theme.spacing(3.5),
46
+ alignItems: 'center',
47
+ },
48
+ titleColumn: { flexShrink: 1 },
49
+ subtitle: {
50
+ fontSize: 11,
51
+ lineHeight: 12,
52
+ fontFamily: 'Inter-Regular',
53
+ },
54
+ contentView: {
55
+ position: 'absolute',
56
+ width: '100%',
57
+ borderRadius: theme.spacing(4),
58
+ backgroundColor: theme.palette.paper.grey,
59
+ paddingHorizontal: theme.spacing(4),
60
+ paddingVertical: theme.spacing(6),
61
+ marginTop: theme.spacing(2),
26
62
  },
27
63
  };
28
64
  };
29
65
 
30
66
  export default function Accordion(props: AccordionProps) {
31
67
  const {
68
+ title,
69
+ subTitle,
32
70
  content,
33
- LeftIcon,
34
71
  RightIcon,
35
- title,
36
- titleVariant = 'subtitle2',
72
+ LeftComponent,
73
+ isInitialExpanded = false,
37
74
  } = props;
38
75
 
39
76
  const styles = useStyles();
77
+ const theme = useTheme();
78
+ const CONTENT_MARGIN_HEIGHT = theme.spacing(2);
40
79
 
41
80
  const [isExpanded, setIsExpanded] = useState(false);
81
+ const shouldInitialExpandedRef = useRef<boolean>(isInitialExpanded);
82
+
83
+ const rotate = useSharedValue(ROTATE_HIDE_DEGREE);
84
+ const animatedOpacity = useSharedValue(0);
85
+ const animatedContentY = useSharedValue(CONTENT_Y_START);
42
86
 
43
- const rotate = useSharedValue(0);
87
+ const animatedHeight = useSharedValue(0);
88
+ const [contentHeight, setContentHeight] = useState(0);
44
89
 
45
90
  const animatedChevronDownStyles = useAnimatedStyle(() => ({
46
91
  transform: [{ rotate: `${rotate.value}deg` }],
47
92
  }), []);
48
93
 
94
+ const animatedContentBackgroundStyles = useAnimatedStyle(() => ({
95
+ height: animatedHeight.value,
96
+ opacity: animatedOpacity.value,
97
+ overflow: 'hidden',
98
+ }), []);
99
+
100
+ const animatedContentStyle = useAnimatedStyle(() => ({
101
+ transform: [{ translateY: animatedContentY.value }],
102
+ opacity: animatedOpacity.value,
103
+ }), []);
104
+
49
105
  const onPress = () => {
50
106
  setIsExpanded(prev => !prev);
51
- rotate.value = withTiming(!isExpanded ? 180 : 0, ANIMATION_CONFIG);
52
107
  };
53
108
 
109
+ const onLayout = (event: LayoutChangeEvent) => {
110
+ const height = event.nativeEvent.layout.height + CONTENT_MARGIN_HEIGHT;
111
+ setContentHeight(height);
112
+
113
+ if (shouldInitialExpandedRef.current) {
114
+ shouldInitialExpandedRef.current = false;
115
+ setIsExpanded(true);
116
+ }
117
+ };
118
+
119
+ useEffect(() => {
120
+ rotate.value = withTiming(isExpanded ? ROTATE_SHOW_DEGREE : ROTATE_HIDE_DEGREE, ANIMATION_CONFIG);
121
+
122
+ animatedHeight.value = withTiming(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);
123
+ animatedOpacity.value = withTiming(isExpanded ? 1 : 0, ANIMATION_CONFIG);
124
+
125
+ animatedContentY.value = isExpanded
126
+ ? withTiming(CONTENT_Y_END, ANIMATION_CONFIG)
127
+ : withDelay(ANIMATION_CONFIG.duration as number, withTiming(CONTENT_Y_START, { duration: 0 }));
128
+ }, [isExpanded, contentHeight]);
129
+
54
130
  return (
55
- <Column>
56
- <ButtonBase
57
- onPress={onPress}
58
- style={styles.root}
59
- >
60
- {LeftIcon ? (
61
- <React.Fragment>
62
- {LeftIcon}
63
- <Spacer size={2}/>
64
- </React.Fragment>
65
- ) : null}
66
-
67
- <Typography
68
- children={title}
69
- variant={titleVariant}
70
- />
71
-
72
- <Spacer flex={1}/>
73
-
74
- <Spacer size={2}/>
75
-
76
- <Column>
131
+ <Column style={styles.root}>
132
+ <ButtonBase onPress={onPress}>
133
+ <Row style={styles.title}>
134
+ {LeftComponent ? LeftComponent : null}
135
+
136
+ <Column style={styles.titleColumn}>
137
+ <Typography
138
+ variant={'subtitle2'}
139
+ children={title}
140
+ color={'textPrimary'}
141
+ numberOfLines={1}
142
+ />
143
+
144
+ {subTitle ? (
145
+ <React.Fragment>
146
+ <Spacer size={0.5}/>
147
+
148
+ <Typography
149
+ style={styles.subtitle}
150
+ color={'tertiary'}
151
+ children={subTitle}
152
+ />
153
+ </React.Fragment>
154
+ ) : null}
155
+ </Column>
156
+
157
+ <Spacer flex={1}/>
158
+
159
+ <Spacer size={3}/>
160
+
77
161
  <Animated.View style={animatedChevronDownStyles}>
78
- {RightIcon ? RightIcon : <ChevronDownIcon/>}
162
+ {RightIcon ? RightIcon : (
163
+ <ChevronDown
164
+ width={20}
165
+ height={20}
166
+ color={'tertiary'}
167
+ />
168
+ )}
79
169
  </Animated.View>
80
- </Column>
170
+ </Row>
81
171
  </ButtonBase>
82
172
 
83
- {isExpanded ? (
84
- React.isValidElement(content) ? (content) : (
85
- <Typography
86
- children={content}
87
- color={'textSecondary'}
88
- variant={'body2'}
89
- />
90
- )
91
- ) : null}
92
-
93
- <Divider/>
173
+ <Animated.View style={animatedContentBackgroundStyles}>
174
+ <View
175
+ onLayout={onLayout}
176
+ style={styles.contentView}
177
+ >
178
+ <Animated.View style={animatedContentStyle}>
179
+ {typeof content === 'string' ? (
180
+ <Typography
181
+ variant={'subtitle2'}
182
+ color={'tertiary'}
183
+ children={content}
184
+ />
185
+ ) : (content)}
186
+ </Animated.View>
187
+ </View>
188
+ </Animated.View>
94
189
  </Column>
95
190
  );
96
191
  }
@@ -1,30 +1,34 @@
1
1
  import React from 'react';
2
- import type { TypographyProps } from '../Typography';
3
2
 
4
3
  export default interface AccordionProps {
5
4
  /**
6
- * The content of the component.
5
+ * The title of the component.
7
6
  */
8
- content: string | React.ReactNode;
7
+ title: string | React.ReactNode;
9
8
 
10
9
  /**
11
- * The icon to the left of the component.
10
+ * The subtitle of the component.
12
11
  */
13
- LeftIcon?: React.ReactElement;
12
+ subTitle?: string | React.ReactNode;
14
13
 
15
14
  /**
16
- * The icon to the right of the component.
15
+ * The component to the left of the title.
16
+ */
17
+ LeftComponent?: React.ReactNode;
18
+
19
+ /**
20
+ * The icon to the right of the title.
17
21
  */
18
22
  RightIcon?: React.ReactElement;
19
23
 
20
24
  /**
21
- * The title of the component.
25
+ * The content of the component.
22
26
  */
23
- title: string;
27
+ content: string | React.ReactNode;
24
28
 
25
29
  /**
26
- * The variant of the component title.
27
- * @default 'subtitle2'
30
+ * The initial state of expanding
31
+ * @default false
28
32
  */
29
- titleVariant?: TypographyProps['variant'];
33
+ isInitialExpanded?: boolean;
30
34
  }
package/src/Tab/Tab.tsx CHANGED
@@ -17,7 +17,7 @@ const styles = StyleSheet.create({
17
17
  },
18
18
  filledInner: {
19
19
  justifyContent: 'center',
20
- }
20
+ },
21
21
  });
22
22
 
23
23
  export default function Tab(props: TabProps) {
@@ -40,11 +40,24 @@ export default function Tab(props: TabProps) {
40
40
 
41
41
  const vertical = variant === 'bottom-navigation';
42
42
 
43
- const color = selected ? theme.palette.text.primary : theme.palette.text.hint;
43
+ const color = selected
44
+ ? theme.palette.text.primary
45
+ : variant === 'contained'
46
+ ? theme.palette.text.secondary
47
+ : theme.palette.text.hint;
48
+
49
+ const containedStyle = {
50
+ borderColor: selected ? theme.palette.primary.main : theme.palette.border,
51
+ borderRadius: theme.shape.roundnessExtra,
52
+ borderWidth: selected ? 1.5 : 1,
53
+ paddingHorizontal: theme.spacing(3),
54
+ paddingVertical: theme.spacing(1.5),
55
+ };
44
56
 
45
57
  const tabBaseStyle = css([
46
58
  styles.root,
47
59
  variant === 'bottom-navigation' && styles.bottomNavigation,
60
+ variant === 'contained' && containedStyle,
48
61
  style,
49
62
  ]);
50
63
 
@@ -56,7 +69,11 @@ export default function Tab(props: TabProps) {
56
69
  const fontStyle = createFontStyle(theme, {
57
70
  selector: (typo) => variant === 'primary'
58
71
  ? typo.h2
59
- : (variant === 'secondary' ? typo.button2 : typo.flag),
72
+ : variant === 'secondary'
73
+ ? typo.button2
74
+ : variant === 'contained'
75
+ ? (selected ? { ...typo.subtitle2, fontWeight: typo.fontWeight.medium } : typo.body2)
76
+ : typo.flag,
60
77
  color,
61
78
  });
62
79
 
@@ -3,7 +3,7 @@ import type { LayoutChangeEvent } from 'react-native';
3
3
  import type { TabBaseProps } from '../TabBase';
4
4
  import type { OverridableComponentProps } from '../types';
5
5
 
6
- export type TabVariant = 'primary' | 'secondary' | 'bottom-navigation';
6
+ export type TabVariant = 'primary' | 'secondary' | 'bottom-navigation' | 'contained';
7
7
  export type TabIndicatorColor = 'primary' | 'secondary'
8
8
  export type TabIndicatorSize = 'full' | 'fit-content';
9
9
 
@@ -27,7 +27,9 @@ export type TypographyVariant =
27
27
  | 'body2'
28
28
  | 'caption1'
29
29
  | 'caption2'
30
- | 'flag';
30
+ | 'flag'
31
+ | 'button1'
32
+ | 'button2';
31
33
 
32
34
  export interface Accessibility {
33
35
  accessibilityRole: AccessibilityProps['accessibilityRole'];