@fountain-ui/core 1.10.0 → 1.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/build/commonjs/Accordion/Accordion.js +11 -8
  3. package/build/commonjs/Accordion/Accordion.js.map +1 -1
  4. package/build/commonjs/ButtonBase/ButtonBase.js +16 -5
  5. package/build/commonjs/ButtonBase/ButtonBase.js.map +1 -1
  6. package/build/commonjs/Link/Link.js +7 -2
  7. package/build/commonjs/Link/Link.js.map +1 -1
  8. package/build/commonjs/SvgIcon/SvgIcon.js +7 -0
  9. package/build/commonjs/SvgIcon/SvgIcon.js.map +1 -1
  10. package/build/commonjs/Tab/Tab.js +3 -3
  11. package/build/commonjs/Tab/Tab.js.map +1 -1
  12. package/build/commonjs/Typography/Typography.js +1 -1
  13. package/build/commonjs/Typography/Typography.js.map +1 -1
  14. package/build/commonjs/hooks/index.js +16 -0
  15. package/build/commonjs/hooks/index.js.map +1 -1
  16. package/build/commonjs/hooks/useCollapsibleAppBar.js +18 -11
  17. package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
  18. package/build/commonjs/hooks/useContentContainerStyle.js.map +1 -1
  19. package/build/module/Accordion/Accordion.js +12 -10
  20. package/build/module/Accordion/Accordion.js.map +1 -1
  21. package/build/module/ButtonBase/ButtonBase.js +16 -5
  22. package/build/module/ButtonBase/ButtonBase.js.map +1 -1
  23. package/build/module/Link/Link.js +8 -3
  24. package/build/module/Link/Link.js.map +1 -1
  25. package/build/module/SvgIcon/SvgIcon.js +6 -0
  26. package/build/module/SvgIcon/SvgIcon.js.map +1 -1
  27. package/build/module/Tab/Tab.js +3 -3
  28. package/build/module/Tab/Tab.js.map +1 -1
  29. package/build/module/Typography/Typography.js +2 -2
  30. package/build/module/Typography/Typography.js.map +1 -1
  31. package/build/module/hooks/index.js +2 -0
  32. package/build/module/hooks/index.js.map +1 -1
  33. package/build/module/hooks/useCollapsibleAppBar.js +18 -11
  34. package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
  35. package/build/module/hooks/useContentContainerStyle.js.map +1 -1
  36. package/build/typescript/hooks/index.d.ts +2 -0
  37. package/build/typescript/hooks/useCollapsibleAppBar.d.ts +4 -1
  38. package/build/typescript/hooks/useContentContainerStyle.d.ts +1 -1
  39. package/build/typescript/internal/icons/Checkbox.d.ts +2 -2
  40. package/build/typescript/internal/icons/CheckboxChecked.d.ts +2 -2
  41. package/build/typescript/internal/icons/ChevronDown.d.ts +2 -2
  42. package/build/typescript/internal/icons/Close.d.ts +2 -2
  43. package/build/typescript/internal/icons/Radio.d.ts +2 -2
  44. package/build/typescript/internal/icons/RadioChecked.d.ts +2 -2
  45. package/package.json +3 -3
  46. package/src/Accordion/Accordion.tsx +11 -13
  47. package/src/ButtonBase/ButtonBase.tsx +17 -5
  48. package/src/Link/Link.tsx +7 -2
  49. package/src/SvgIcon/SvgIcon.tsx +9 -1
  50. package/src/Tab/Tab.tsx +4 -6
  51. package/src/Typography/Typography.tsx +2 -2
  52. package/src/hooks/index.ts +3 -1
  53. package/src/hooks/useCollapsibleAppBar.ts +18 -10
  54. package/src/hooks/useContentContainerStyle.ts +1 -1
@@ -4,6 +4,7 @@ import React from 'react';
4
4
  import Animated from 'react-native-reanimated';
5
5
  import { useThrottle } from '../hooks';
6
6
  import { AnimatedPressable } from '../animated';
7
+ import { StyleSheet } from '../styles';
7
8
  const ORIGINAL_OPACITY = 1;
8
9
  const ACTIVE_OPACITY = .65;
9
10
  const DISABLED_OPACITY = .3;
@@ -12,6 +13,14 @@ const MINIFIED_SCALE = .96;
12
13
  const animationTimingConfig = {
13
14
  duration: 150
14
15
  };
16
+ const styles = StyleSheet.create({
17
+ disabled: {
18
+ opacity: DISABLED_OPACITY,
19
+ transform: [{
20
+ scale: ORIGINAL_SCALE
21
+ }]
22
+ }
23
+ });
15
24
  export default function ButtonBase(props) {
16
25
  const {
17
26
  children,
@@ -30,12 +39,13 @@ export default function ButtonBase(props) {
30
39
  const opacity = Animated.useSharedValue(ORIGINAL_OPACITY);
31
40
  const scale = Animated.useSharedValue(ORIGINAL_SCALE);
32
41
  const animatedStyle = Animated.useAnimatedStyle(() => ({
33
- opacity: disabled ? DISABLED_OPACITY : opacity.value,
42
+ opacity: opacity.value,
34
43
  transform: [{
35
- scale: disabled ? ORIGINAL_SCALE : scale.value
44
+ scale: scale.value
36
45
  }]
37
46
  }));
38
- const startAnimation = React.useCallback((pressIn, isHovered = false) => {
47
+
48
+ const startAnimation = (pressIn, isHovered = false) => {
39
49
  if (pressEffect === 'none') {
40
50
  return;
41
51
  }
@@ -53,13 +63,14 @@ export default function ButtonBase(props) {
53
63
  scale.value = Animated.withTiming(ORIGINAL_SCALE, animationTimingConfig);
54
64
  }
55
65
  }
56
- }, [pressEffect]);
66
+ };
67
+
57
68
  return /*#__PURE__*/React.createElement(AnimatedPressable, _extends({
58
69
  disabled: disabled,
59
70
  onPress: handlePress,
60
71
  onPressIn: () => startAnimation(true),
61
72
  onPressOut: () => startAnimation(false),
62
- style: [animatedStyle, style]
73
+ style: [animatedStyle, disabled ? styles.disabled : undefined, style]
63
74
  }, otherProps), typeof children !== 'function' ? ({
64
75
  hovered
65
76
  }) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["ButtonBase.tsx"],"names":["React","Animated","useThrottle","AnimatedPressable","ORIGINAL_OPACITY","ACTIVE_OPACITY","DISABLED_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","animationTimingConfig","duration","ButtonBase","props","children","disabled","disableThrottle","onPress","pressEffect","style","throttleMillis","otherProps","handlePress","periodMillis","callback","opacity","useSharedValue","scale","animatedStyle","useAnimatedStyle","value","transform","startAnimation","useCallback","pressIn","isHovered","withTiming","withDelay","hovered","undefined"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,WAAT,QAA4B,UAA5B;AACA,SAASC,iBAA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W,KAAK,MAApB,EAA4B;AACxB;AACH;;AAED,QAAIA,WAAW,KAAK,SAApB,EAA+B;AAC3B,UAAIgB,OAAJ,EAAa;AACTT,QAAAA,OAAO,CAACK,KAAR,GAAgBxB,cAAhB;AACH,OAFD,MAEO;AACHmB,QAAAA,OAAO,CAACK,KAAR,GAAgB5B,QAAQ,CAACkC,UAAT,CAAoB/B,gBAApB,EAAsCK,qBAAtC,CAAhB;AACH;AACJ,KAND,MAMO,IAAI,CAACyB,SAAL,EAAgB;AACnB,UAAID,OAAJ,EAAa;AACTP,QAAAA,KAAK,CAACG,KAAN,GAAc5B,QAAQ,CAACmC,SAAT,CACV,GADU,EAEVnC,QAAQ,CAACkC,UAAT,CAAoB3B,cAApB,EAAoCC,qBAApC,CAFU,CAAd;AAIH,OALD,MAKO;AACHiB,QAAAA,KAAK,CAACG,KAAN,GAAc5B,QAAQ,CAACkC,UAAT,CAAoB5B,cAApB,EAAoCE,qBAApC,CAAd;AACH;AACJ;AACJ,GArBsB,EAqBpB,CAACQ,WAAD,CArBoB,CAAvB;AAuBA,sBACI,oBAAC,iBAAD;AACI,IAAA,QAAQ,EAAEH,QADd;AAEI,IAAA,OAAO,EAAEO,WAFb;AAGI,IAAA,SAAS,EAAE,MAAMU,cAAc,CAAC,IAAD,CAHnC;AAII,IAAA,UAAU,EAAE,MAAMA,cAAc,CAAC,KAAD,CAJpC;AAKI,IAAA,KAAK,EAAE,CAACJ,aAAD,EAAgBT,KAAhB;AALX,KAMQE,UANR,GAQK,OAAOP,QAAP,KAAoB,UAApB,GACG,CAAC;AAAEwB,IAAAA;AAAF,GAAD,KAAiB;AACb,QAAIA,OAAO,KAAKC,SAAhB,EAA2B;AACvBP,MAAAA,cAAc,CAACM,OAAD,EAAU,IAAV,CAAd;AACH;;AAED,WAAOxB,QAAP;AACH,GAPJ,GAQGA,QAhBR,CADJ;AAoBH;AAAA","sourcesContent":["import React from 'react';\nimport Animated from 'react-native-reanimated';\nimport { useThrottle } from '../hooks';\nimport { AnimatedPressable } from '../animated';\nimport type ButtonBaseProps from './ButtonBaseProps';\n\nconst ORIGINAL_OPACITY = 1;\nconst ACTIVE_OPACITY = .65;\nconst DISABLED_OPACITY = .3;\n\nconst ORIGINAL_SCALE = 1;\nconst MINIFIED_SCALE = .96;\n\nconst animationTimingConfig: Animated.WithTimingConfig = { duration: 150 };\n\nexport default function ButtonBase(props: ButtonBaseProps) {\n const {\n children,\n disabled = false,\n disableThrottle = false,\n onPress,\n pressEffect = 'opacity',\n style,\n throttleMillis = 650,\n ...otherProps\n } = props;\n\n const handlePress = useThrottle({\n periodMillis: disableThrottle ? 0 : throttleMillis,\n callback: onPress,\n });\n\n const opacity = Animated.useSharedValue(ORIGINAL_OPACITY);\n const scale = Animated.useSharedValue(ORIGINAL_SCALE);\n\n const animatedStyle = Animated.useAnimatedStyle(() => ({\n opacity: disabled ? DISABLED_OPACITY : opacity.value,\n transform: [{ scale: disabled ? ORIGINAL_SCALE : scale.value }],\n }));\n\n const startAnimation = React.useCallback((pressIn: boolean, isHovered: boolean = false) => {\n if (pressEffect === 'none') {\n return;\n }\n\n if (pressEffect === 'opacity') {\n if (pressIn) {\n opacity.value = ACTIVE_OPACITY;\n } else {\n opacity.value = Animated.withTiming(ORIGINAL_OPACITY, animationTimingConfig);\n }\n } else if (!isHovered) {\n if (pressIn) {\n scale.value = Animated.withDelay(\n 100,\n Animated.withTiming(MINIFIED_SCALE, animationTimingConfig),\n );\n } else {\n scale.value = Animated.withTiming(ORIGINAL_SCALE, animationTimingConfig);\n }\n }\n }, [pressEffect]);\n\n return (\n <AnimatedPressable\n disabled={disabled}\n onPress={handlePress}\n onPressIn={() => startAnimation(true)}\n onPressOut={() => startAnimation(false)}\n style={[animatedStyle, style]}\n {...otherProps}\n >\n {typeof children !== 'function' ? (\n ({ hovered }) => {\n if (hovered !== undefined) {\n startAnimation(hovered, true);\n }\n\n return children;\n }\n ) : children}\n </AnimatedPressable>\n );\n};\n"]}
1
+ {"version":3,"sources":["ButtonBase.tsx"],"names":["React","Animated","useThrottle","AnimatedPressable","StyleSheet","ORIGINAL_OPACITY","ACTIVE_OPACITY","DISABLED_OPACITY","ORIGINAL_SCALE","MINIFIED_SCALE","animationTimingConfig","duration","styles","create","disabled","opacity","transform","scale","ButtonBase","props","children","disableThrottle","onPress","pressEffect","style","throttleMillis","otherProps","handlePress","periodMillis","callback","useSharedValue","animatedStyle","useAnimatedStyle","value","startAnimation","pressIn","isHovered","withTiming","withDelay","undefined","hovered"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,WAAT,QAA4B,UAA5B;AACA,SAASC,iBAAT,QAAkC,aAAlC;AACA,SAASC,UAAT,QAA2B,WAA3B;AAGA,MAAMC,gBAAgB,GAAG,CAAzB;AACA,MAAMC,cAAc,GAAG,GAAvB;AACA,MAAMC,gBAAgB,GAAG,EAAzB;AAEA,MAAMC,cAAc,GAAG,CAAvB;AACA,MAAMC,cAAc,GAAG,GAAvB;AAEA,MAAMC,qBAAgD,GAAG;AAAEC,EAAAA,QAAQ,EAAE;AAAZ,CAAzD;AAEA,MAAMC,MAAM,GAAGR,UAAU,CAACS,MAAX,CAAkB;AAC7BC,EAAAA,QAAQ,EAAE;AACNC,IAAAA,OAAO,EAAER,gBADH;AAENS,IAAAA,SAAS,EAAE,CAAC;AAAEC,MAAAA,KAAK,EAAET;AAAT,KAAD;AAFL;AADmB,CAAlB,CAAf;AAOA,eAAe,SAASU,UAAT,CAAoBC,KAApB,EAA4C;AACvD,QAAM;AACFC,IAAAA,QADE;AAEFN,IAAAA,QAAQ,GAAG,KAFT;AAGFO,IAAAA,eAAe,GAAG,KAHhB;AAIFC,IAAAA,OAJE;AAKFC,IAAAA,WAAW,GAAG,SALZ;AAMFC,IAAAA,KANE;AAOFC,IAAAA,cAAc,GAAG,GAPf;AAQF,OAAGC;AARD,MASFP,KATJ;AAWA,QAAMQ,WAAW,GAAGzB,WAAW,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D;AACI,IAAA,QAAQ,EAAEI,QADd;AAEI,IAAA,OAAO,EAAEa,WAFb;AAGI,IAAA,SAAS,EAAE,MAAMO,cAAc,CAAC,IAAD,CAHnC;AAII,IAAA,UAAU,EAAE,MAAMA,cAAc,CAAC,KAAD,CAJpC;AAKI,IAAA,KAAK,EAAE,CACHH,aADG,EAEHjB,QAAQ,GAAGF,MAAM,CAACE,QAAV,GAAqByB,SAF1B,EAGHf,KAHG;AALX,KAUQE,UAVR,GAYK,OAAON,QAAP,KAAoB,UAApB,GACG,CAAC;AAAEoB,IAAAA;AAAF,GAAD,KAAiB;AACb,QAAIA,OAAO,KAAKD,SAAhB,EAA2B;AACvBL,MAAAA,cAAc,CAACM,OAAD,EAAU,IAAV,CAAd;AACH;;AAED,WAAOpB,QAAP;AACH,GAPJ,GAQGA,QApBR,CADJ;AAwBH;AAAA","sourcesContent":["import React from 'react';\nimport Animated from 'react-native-reanimated';\nimport { useThrottle } from '../hooks';\nimport { AnimatedPressable } from '../animated';\nimport { StyleSheet } from '../styles';\nimport type ButtonBaseProps from './ButtonBaseProps';\n\nconst ORIGINAL_OPACITY = 1;\nconst ACTIVE_OPACITY = .65;\nconst DISABLED_OPACITY = .3;\n\nconst ORIGINAL_SCALE = 1;\nconst MINIFIED_SCALE = .96;\n\nconst animationTimingConfig: Animated.WithTimingConfig = { duration: 150 };\n\nconst styles = StyleSheet.create({\n disabled: {\n opacity: DISABLED_OPACITY,\n transform: [{ scale: ORIGINAL_SCALE }],\n },\n});\n\nexport default function ButtonBase(props: ButtonBaseProps) {\n const {\n children,\n disabled = false,\n disableThrottle = false,\n onPress,\n pressEffect = 'opacity',\n style,\n throttleMillis = 650,\n ...otherProps\n } = props;\n\n const handlePress = useThrottle({\n periodMillis: disableThrottle ? 0 : throttleMillis,\n callback: onPress,\n });\n\n const opacity = Animated.useSharedValue(ORIGINAL_OPACITY);\n const scale = Animated.useSharedValue(ORIGINAL_SCALE);\n\n const animatedStyle = Animated.useAnimatedStyle(() => ({\n opacity: opacity.value,\n transform: [{ scale: scale.value }],\n }));\n\n const startAnimation = (pressIn: boolean, isHovered: boolean = false) => {\n if (pressEffect === 'none') {\n return;\n }\n\n if (pressEffect === 'opacity') {\n if (pressIn) {\n opacity.value = ACTIVE_OPACITY;\n } else {\n opacity.value = Animated.withTiming(ORIGINAL_OPACITY, animationTimingConfig);\n }\n } else if (!isHovered) {\n if (pressIn) {\n scale.value = Animated.withDelay(\n 100,\n Animated.withTiming(MINIFIED_SCALE, animationTimingConfig),\n );\n } else {\n scale.value = Animated.withTiming(ORIGINAL_SCALE, animationTimingConfig);\n }\n }\n };\n\n return (\n <AnimatedPressable\n disabled={disabled}\n onPress={handlePress}\n onPressIn={() => startAnimation(true)}\n onPressOut={() => startAnimation(false)}\n style={[\n animatedStyle,\n disabled ? styles.disabled : undefined,\n style,\n ]}\n {...otherProps}\n >\n {typeof children !== 'function' ? (\n ({ hovered }) => {\n if (hovered !== undefined) {\n startAnimation(hovered, true);\n }\n\n return children;\n }\n ) : children}\n </AnimatedPressable>\n );\n};\n"]}
@@ -1,7 +1,7 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import React from 'react';
4
- import { Linking } from 'react-native';
4
+ import { Linking, Platform } from 'react-native';
5
5
  import Pressable from '../Pressable';
6
6
  import Typography from '../Typography';
7
7
  import { css } from '../styles';
@@ -27,6 +27,10 @@ export default function Link(props) {
27
27
  const styles = useStyles();
28
28
 
29
29
  const handlePress = async event => {
30
+ if (Platform.OS === 'web') {
31
+ event.preventDefault();
32
+ }
33
+
30
34
  if (onPress) {
31
35
  onPress(event);
32
36
  return;
@@ -39,7 +43,7 @@ export default function Link(props) {
39
43
 
40
44
  return /*#__PURE__*/React.createElement(Pressable, {
41
45
  disabled: disabled,
42
- onPress: handlePress,
46
+ onPress: Platform.OS === 'web' ? undefined : handlePress,
43
47
  style: css([styles.root, style])
44
48
  }, ({
45
49
  hovered
@@ -47,7 +51,8 @@ export default function Link(props) {
47
51
  const underlineStyle = underline === 'always' || underline === 'hover' && hovered ? styles.underline : undefined;
48
52
  return /*#__PURE__*/React.createElement(Typography, _extends({
49
53
  href: href,
50
- style: underlineStyle
54
+ style: underlineStyle,
55
+ onPress: Platform.OS === 'web' ? handlePress : undefined
51
56
  }, otherProps));
52
57
  });
53
58
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["Link.tsx"],"names":["React","Linking","Pressable","Typography","css","useStyles","root","underline","textDecorationLine","Link","props","disabled","href","onPress","style","otherProps","styles","handlePress","event","canOpenURL","openURL","hovered","underlineStyle","undefined"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAgCC,OAAhC,QAA+C,cAA/C;AAEA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,SAASC,GAAT,QAAoB,WAApB;;AAKA,MAAMC,SAAgC,GAAG,YAAwB;AAC7D,SAAO;AACHC,IAAAA,IAAI,EAAE,EADH;AAEHC,IAAAA,SAAS,EAAE;AACPC,MAAAA,kBAAkB,EAAE;AADb;AAFR,GAAP;AAMH,CAPD;;AASA,eAAe,SAASC,IAAT,CAAcC,KAAd,EAAgC;AAC3C,QAAM;AACFC,IAAAA,QAAQ,GAAG,KADT;AAEFC,IAAAA,IAFE;AAGFC,IAAAA,OAHE;AAIFC,IAAAA,KAJE;AAKFP,IAAAA,SAAS,GAAG,QALV;AAMF,OAAGQ;AAND,MAOFL,KAPJ;AASA,QAAMM,MAAM,GAAGX,SAAS,EAAxB;;AAEA,QAAMY,WAAW,GAAG,MAAOC,KAAP,IAAwC;AACxD,QAAIL,OAAJ,EAAa;AACTA,MAAAA,OAAO,CAACK,KAAD,CAAP;AACA;AACH;;AAED,QAAI,MAAMjB,OAAO,CAACkB,UAAR,CAAmBP,IAAnB,CAAV,EAAoC;AAChC,YAAMX,OAAO,CAACmB,OAAR,CAAgBR,IAAhB,CAAN;AACH;AACJ,GATD;;AAWA,sBACI,oBAAC,SAAD;AACI,IAAA,QAAQ,EAAED,QADd;AAEI,IAAA,OAAO,EAAEM,WAFb;AAGI,IAAA,KAAK,EAAEb,GAAG,CAAC,CAACY,MAAM,CAACV,IAAR,EAAcQ,KAAd,CAAD;AAHd,KAKK,CAAC;AAAEO,IAAAA;AAAF,GAAD,KAAiB;AACd,UAAMC,cAAc,GAAIf,SAAS,KAAK,QAAd,IAA2BA,SAAS,KAAK,OAAd,IAAyBc,OAArD,GACjBL,MAAM,CAACT,SADU,GAEjBgB,SAFN;AAIA,wBACI,oBAAC,UAAD;AACI,MAAA,IAAI,EAAEX,IADV;AAEI,MAAA,KAAK,EAAEU;AAFX,OAGQP,UAHR,EADJ;AAOH,GAjBL,CADJ;AAqBH;AAAA","sourcesContent":["import React from 'react';\nimport { GestureResponderEvent, Linking } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport Pressable from '../Pressable';\nimport Typography from '../Typography';\nimport { css } from '../styles';\nimport type LinkProps from './LinkProps';\n\ntype LinkStyles = NamedStylesStringUnion<'root' | 'underline'>;\n\nconst useStyles: UseStyles<LinkStyles> = function (): LinkStyles {\n return {\n root: {},\n underline: {\n textDecorationLine: 'underline',\n },\n };\n};\n\nexport default function Link(props: LinkProps) {\n const {\n disabled = false,\n href,\n onPress,\n style,\n underline = 'always',\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const handlePress = async (event: GestureResponderEvent) => {\n if (onPress) {\n onPress(event);\n return;\n }\n\n if (await Linking.canOpenURL(href)) {\n await Linking.openURL(href);\n }\n };\n\n return (\n <Pressable\n disabled={disabled}\n onPress={handlePress}\n style={css([styles.root, style])}\n >\n {({ hovered }) => {\n const underlineStyle = (underline === 'always' || (underline === 'hover' && hovered))\n ? styles.underline\n : undefined;\n\n return (\n <Typography\n href={href}\n style={underlineStyle}\n {...otherProps}\n />\n );\n }}\n </Pressable>\n );\n};\n"]}
1
+ {"version":3,"sources":["Link.tsx"],"names":["React","Linking","Platform","Pressable","Typography","css","useStyles","root","underline","textDecorationLine","Link","props","disabled","href","onPress","style","otherProps","styles","handlePress","event","OS","preventDefault","canOpenURL","openURL","undefined","hovered","underlineStyle"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAgCC,OAAhC,EAAyCC,QAAzC,QAAyD,cAAzD;AAEA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,SAASC,GAAT,QAAoB,WAApB;;AAKA,MAAMC,SAAgC,GAAG,YAAwB;AAC7D,SAAO;AACHC,IAAAA,IAAI,EAAE,EADH;AAEHC,IAAAA,SAAS,EAAE;AACPC,MAAAA,kBAAkB,EAAE;AADb;AAFR,GAAP;AAMH,CAPD;;AASA,eAAe,SAASC,IAAT,CAAcC,KAAd,EAAgC;AAC3C,QAAM;AACFC,IAAAA,QAAQ,GAAG,KADT;AAEFC,IAAAA,IAFE;AAGFC,IAAAA,OAHE;AAIFC,IAAAA,KAJE;AAKFP,IAAAA,SAAS,GAAG,QALV;AAMF,OAAGQ;AAND,MAOFL,KAPJ;AASA,QAAMM,MAAM,GAAGX,SAAS,EAAxB;;AAEA,QAAMY,WAAW,GAAG,MAAOC,KAAP,IAAwC;AACxD,QAAIjB,QAAQ,CAACkB,EAAT,KAAgB,KAApB,EAA2B;AACvBD,MAAAA,KAAK,CAACE,cAAN;AACH;;AAED,QAAIP,OAAJ,EAAa;AACTA,MAAAA,OAAO,CAACK,KAAD,CAAP;AACA;AACH;;AAED,QAAI,MAAMlB,OAAO,CAACqB,UAAR,CAAmBT,IAAnB,CAAV,EAAoC;AAChC,YAAMZ,OAAO,CAACsB,OAAR,CAAgBV,IAAhB,CAAN;AACH;AACJ,GAbD;;AAeA,sBACI,oBAAC,SAAD;AACI,IAAA,QAAQ,EAAED,QADd;AAEI,IAAA,OAAO,EAAEV,QAAQ,CAACkB,EAAT,KAAgB,KAAhB,GAAwBI,SAAxB,GAAoCN,WAFjD;AAGI,IAAA,KAAK,EAAEb,GAAG,CAAC,CAACY,MAAM,CAACV,IAAR,EAAcQ,KAAd,CAAD;AAHd,KAKK,CAAC;AAAEU,IAAAA;AAAF,GAAD,KAAiB;AACd,UAAMC,cAAc,GAAIlB,SAAS,KAAK,QAAd,IAA2BA,SAAS,KAAK,OAAd,IAAyBiB,OAArD,GACjBR,MAAM,CAACT,SADU,GAEjBgB,SAFN;AAIA,wBACI,oBAAC,UAAD;AACI,MAAA,IAAI,EAAEX,IADV;AAEI,MAAA,KAAK,EAAEa,cAFX;AAGI,MAAA,OAAO,EAAExB,QAAQ,CAACkB,EAAT,KAAgB,KAAhB,GAAwBF,WAAxB,GAAsCM;AAHnD,OAIQR,UAJR,EADJ;AAQH,GAlBL,CADJ;AAsBH;AAAA","sourcesContent":["import React from 'react';\nimport { GestureResponderEvent, Linking, Platform } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport Pressable from '../Pressable';\nimport Typography from '../Typography';\nimport { css } from '../styles';\nimport type LinkProps from './LinkProps';\n\ntype LinkStyles = NamedStylesStringUnion<'root' | 'underline'>;\n\nconst useStyles: UseStyles<LinkStyles> = function (): LinkStyles {\n return {\n root: {},\n underline: {\n textDecorationLine: 'underline',\n },\n };\n};\n\nexport default function Link(props: LinkProps) {\n const {\n disabled = false,\n href,\n onPress,\n style,\n underline = 'always',\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const handlePress = async (event: GestureResponderEvent) => {\n if (Platform.OS === 'web') {\n event.preventDefault();\n }\n\n if (onPress) {\n onPress(event);\n return;\n }\n\n if (await Linking.canOpenURL(href)) {\n await Linking.openURL(href);\n }\n };\n\n return (\n <Pressable\n disabled={disabled}\n onPress={Platform.OS === 'web' ? undefined : handlePress}\n style={css([styles.root, style])}\n >\n {({ hovered }) => {\n const underlineStyle = (underline === 'always' || (underline === 'hover' && hovered))\n ? styles.underline\n : undefined;\n\n return (\n <Typography\n href={href}\n style={underlineStyle}\n onPress={Platform.OS === 'web' ? handlePress : undefined}\n {...otherProps}\n />\n );\n }}\n </Pressable>\n );\n};\n"]}
@@ -2,17 +2,23 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React from 'react';
4
4
  import Svg from 'react-native-svg';
5
+ import { css } from '../styles';
5
6
  export default function SvgIcon(props) {
6
7
  const {
7
8
  fill = '#000',
8
9
  height = 24,
10
+ style: styleProp,
9
11
  viewBox = '0 0 20 20',
10
12
  width = 24,
11
13
  ...otherProps
12
14
  } = props;
15
+ const style = css([{
16
+ flexShrink: 0
17
+ }, styleProp]);
13
18
  return /*#__PURE__*/React.createElement(Svg, _extends({
14
19
  fill: fill,
15
20
  height: height,
21
+ style: style,
16
22
  viewBox: viewBox,
17
23
  width: width
18
24
  }, otherProps));
@@ -1 +1 @@
1
- {"version":3,"sources":["SvgIcon.tsx"],"names":["React","Svg","SvgIcon","props","fill","height","viewBox","width","otherProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,GAAP,MAAgB,kBAAhB;AAGA,eAAe,SAASC,OAAT,CAAiBC,KAAjB,EAAsC;AACjD,QAAM;AACFC,IAAAA,IAAI,GAAG,MADL;AAEFC,IAAAA,MAAM,GAAG,EAFP;AAGFC,IAAAA,OAAO,GAAG,WAHR;AAIFC,IAAAA,KAAK,GAAG,EAJN;AAKF,OAAGC;AALD,MAMYL,KANlB;AAQA,sBACI,oBAAC,GAAD;AACI,IAAA,IAAI,EAAEC,IADV;AAEI,IAAA,MAAM,EAAEC,MAFZ;AAGI,IAAA,OAAO,EAAEC,OAHb;AAII,IAAA,KAAK,EAAEC;AAJX,KAKQC,UALR,EADJ;AASH;AAAA","sourcesContent":["import React from 'react';\nimport Svg from 'react-native-svg';\nimport type SvgIconProps from './SvgIconProps';\n\nexport default function SvgIcon(props: SvgIconProps) {\n const {\n fill = '#000',\n height = 24,\n viewBox = '0 0 20 20',\n width = 24,\n ...otherProps\n }: SvgIconProps = props;\n\n return (\n <Svg\n fill={fill}\n height={height}\n viewBox={viewBox}\n width={width}\n {...otherProps}\n />\n );\n};\n"]}
1
+ {"version":3,"sources":["SvgIcon.tsx"],"names":["React","Svg","css","SvgIcon","props","fill","height","style","styleProp","viewBox","width","otherProps","flexShrink"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,GAAP,MAAgB,kBAAhB;AACA,SAASC,GAAT,QAAoB,WAApB;AAGA,eAAe,SAASC,OAAT,CAAiBC,KAAjB,EAAsC;AACjD,QAAM;AACFC,IAAAA,IAAI,GAAG,MADL;AAEFC,IAAAA,MAAM,GAAG,EAFP;AAGFC,IAAAA,KAAK,EAAEC,SAHL;AAIFC,IAAAA,OAAO,GAAG,WAJR;AAKFC,IAAAA,KAAK,GAAG,EALN;AAMF,OAAGC;AAND,MAOYP,KAPlB;AASA,QAAMG,KAAK,GAAGL,GAAG,CAAC,CACd;AAAEU,IAAAA,UAAU,EAAG;AAAf,GADc,EAEdJ,SAFc,CAAD,CAAjB;AAKA,sBACI,oBAAC,GAAD;AACI,IAAA,IAAI,EAAEH,IADV;AAEI,IAAA,MAAM,EAAEC,MAFZ;AAGI,IAAA,KAAK,EAAEC,KAHX;AAII,IAAA,OAAO,EAAEE,OAJb;AAKI,IAAA,KAAK,EAAEC;AALX,KAMQC,UANR,EADJ;AAUH;AAAA","sourcesContent":["import React from 'react';\nimport Svg from 'react-native-svg';\nimport { css } from '../styles';\nimport type SvgIconProps from './SvgIconProps';\n\nexport default function SvgIcon(props: SvgIconProps) {\n const {\n fill = '#000',\n height = 24,\n style: styleProp,\n viewBox = '0 0 20 20',\n width = 24,\n ...otherProps\n }: SvgIconProps = props;\n\n const style = css([\n { flexShrink : 0 },\n styleProp,\n ]);\n\n return (\n <Svg\n fill={fill}\n height={height}\n style={style}\n viewBox={viewBox}\n width={width}\n {...otherProps}\n />\n );\n};"]}
@@ -44,10 +44,10 @@ export default function Tab(props) {
44
44
  return /*#__PURE__*/React.createElement(TabBase, _extends({
45
45
  vertical: vertical,
46
46
  style: tabBaseStyle
47
- }, otherProps), iconElement && badgeVisible ? /*#__PURE__*/React.createElement(Badge, {
47
+ }, otherProps), /*#__PURE__*/React.createElement(Badge, {
48
48
  children: iconElement,
49
- invisible: false
50
- }) : iconElement, /*#__PURE__*/React.createElement(Text, {
49
+ invisible: !badgeVisible
50
+ }), /*#__PURE__*/React.createElement(Text, {
51
51
  children: children,
52
52
  style: css(fontStyle)
53
53
  }), enableIndicator ? /*#__PURE__*/React.createElement(TabIndicator, null) : null);
@@ -1 +1 @@
1
- {"version":3,"sources":["Tab.tsx"],"names":["React","Text","Badge","TabBase","createFontStyle","css","StyleSheet","useTheme","TabIndicator","styles","create","primary","minHeight","secondary","bottomNavigation","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","selected","selectedIcon","variant","style","otherProps","theme","vertical","color","palette","text","hint","tabBaseStyle","fontStyle","selector","typo","h2","button2","flag","iconElement","cloneElement","fill"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAAqB,cAArB;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;AAC7BC,EAAAA,OAAO,EAAE;AACLC,IAAAA,SAAS,EAAE;AADN,GADoB;AAI7BC,EAAAA,SAAS,EAAE;AACPD,IAAAA,SAAS,EAAE;AADJ,GAJkB;AAO7BE,EAAAA,gBAAgB,EAAE;AACdF,IAAAA,SAAS,EAAE;AADG;AAPW,CAAlB,CAAf;AAYA,eA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IAAA,QAAQ,EAAED,QADd;AAEI,IAAA,KAAK,EAAEK;AAFX,KAGQP,UAHR,GAKKc,WAAW,IAAIvB,YAAf,gBACG,oBAAC,KAAD;AACI,IAAA,QAAQ,EAAEuB,WADd;AAEI,IAAA,SAAS,EAAE;AAFf,IADH,GAKGA,WAVR,eAYI,oBAAC,IAAD;AACI,IAAA,QAAQ,EAAEtB,QADd;AAEI,IAAA,KAAK,EAAEb,GAAG,CAAC6B,SAAD;AAFd,IAZJ,EAiBKf,eAAe,gBAAG,oBAAC,YAAD,OAAH,GAAqB,IAjBzC,CADJ;AAqBH;AAAA","sourcesContent":["import React from 'react';\nimport { Text } 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 primary: {\n minHeight: 48,\n },\n secondary: {\n minHeight: 48,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator,\n icon: defaultIcon,\n selected,\n selectedIcon,\n variant = 'primary',\n style,\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 variant === 'primary'\n ? styles.primary\n : (variant === 'secondary' ? styles.secondary : styles.bottomNavigation),\n style,\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 icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? React.cloneElement(icon, { fill: color }) : null;\n\n return (\n <TabBase\n vertical={vertical}\n style={tabBaseStyle}\n {...otherProps}\n >\n {iconElement && badgeVisible ? (\n <Badge\n children={iconElement}\n invisible={false}\n />\n ) : iconElement}\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n\n {enableIndicator ? <TabIndicator/> : null}\n </TabBase>\n );\n};\n"]}
1
+ {"version":3,"sources":["Tab.tsx"],"names":["React","Text","Badge","TabBase","createFontStyle","css","StyleSheet","useTheme","TabIndicator","styles","create","primary","minHeight","secondary","bottomNavigation","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","selected","selectedIcon","variant","style","otherProps","theme","vertical","color","palette","text","hint","tabBaseStyle","fontStyle","selector","typo","h2","button2","flag","iconElement","cloneElement","fill"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAAqB,cAArB;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;AAC7BC,EAAAA,OAAO,EAAE;AACLC,IAAAA,SAAS,EAAE;AADN,GADoB;AAI7BC,EAAAA,SAAS,EAAE;AACPD,IAAAA,SAAS,EAAE;AADJ,GAJkB;AAO7BE,EAAAA,gBAAgB,EAAE;AACdF,IAAAA,SAAS,EAAE;AADG;AAPW,CAAlB,CAAf;AAYA,eAAe,SAASG,GAAT,CAAaC,KAAb,EAA8B;AACzC,QAAM;AACFC,IAAAA,YAAY,GAAG,KADb;AAEFC,IAAAA,QAFE;AAGFC,IAAAA,eAHE;AAIFC,IAAAA,IAAI,EAAEC,WAJJ;AAKFC,IAAAA,QALE;AAMFC,IAAAA,YANE;AAOFC,IAAAA,OAAO,GAAG,SAPR;AAQFC,IAAAA,KARE;AASF,OAAGC;AATD,MAUFV,KAVJ;AAYA,QAAMW,KAAK,GAAGpB,QAAQ,EAAtB;AAEA,QAAMqB,QAAQ,GAAGJ,OAAO,KAAK,mBAA7B;A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Text } 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 primary: {\n minHeight: 48,\n },\n secondary: {\n minHeight: 48,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator,\n icon: defaultIcon,\n selected,\n selectedIcon,\n variant = 'primary',\n style,\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 variant === 'primary'\n ? styles.primary\n : (variant === 'secondary' ? styles.secondary : styles.bottomNavigation),\n style,\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 icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? React.cloneElement(icon, { fill: color }) : null;\n\n return (\n <TabBase\n vertical={vertical}\n style={tabBaseStyle}\n {...otherProps}\n >\n <Badge\n children={iconElement}\n invisible={!badgeVisible}\n />\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n\n {enableIndicator ? <TabIndicator/> : null}\n </TabBase>\n );\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Text } from 'react-native';
2
+ import { Platform, Text } from 'react-native';
3
3
  import { createFontStyle, css, useTheme } from '../styles';
4
4
  const accessibilityMap = {
5
5
  h1: {
@@ -46,7 +46,7 @@ function selectColor(theme, colorProp) {
46
46
 
47
47
  switch (colorProp) {
48
48
  case 'inherit':
49
- return undefined;
49
+ return Platform.OS === 'web' ? 'inherit' : undefined;
50
50
 
51
51
  case 'textPrimary':
52
52
  return palette.primary;
@@ -1 +1 @@
1
- {"version":3,"sources":["Typography.tsx"],"names":["React","Text","createFontStyle","css","useTheme","accessibilityMap","h1","accessibilityRole","h2","h3","subtitle1","subtitle2","body1","body2","caption1","caption2","flag","selectColor","theme","colorProp","palette","text","undefined","primary","secondary","accent","hint","main","Typography","forwardRef","props","ref","align","children","color","ellipsizeMode","href","numberOfLines","onPress","selectable","style","variant","fontStyle","selector","typography","textStyle","textAlign","flexShrink","accessibility","memo"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,SAASC,eAAT,EAA0BC,GAA1B,EAA+BC,QAA/B,QAA+C,WAA/C;AAGA,MAAMC,gBAAkC,GAAG;AACvCC,EAAAA,EAAE,EAAE;AAAEC,IAAAA,iBAAiB,EAAE,QAArB;AAA+B,kBAAc;AAA7C,GADmC;AAEvCC,EAAAA,EAAE,EAAE;AAAED,IAAAA,iBAAiB,EAAE,QAArB;AAA+B,kBAAc;AAA7C,GAFmC;AAGvCE,EAAAA,EAAE,EAAE;AAAEF,IAAAA,iBAAiB,EAAE,QAArB;AAA+B,kBAAc;AAA7C,GAHmC;AAIvCG,EAAAA,SAAS,EAAE;AAAEH,IAAAA,iBAAiB,EAAE,QAArB;AAA+B,kBAAc;AAA7C,GAJ4B;AAKvCI,EAAAA,SAAS,EAAE;AAAEJ,IAAAA,iBAAiB,EAAE,QAArB;AAA+B,kBAAc;AAA7C,GAL4B;AAMvCK,EAAAA,KAAK,EAAE;AAAEL,IAAAA,iBAAiB,EAAE;AAArB,GANgC;AAOvCM,EAAAA,KAAK,EAAE;AAAEN,IAAAA,iBAAiB,EAAE;AAArB,GAPgC;AAQvCO,EAAAA,QAAQ,EAAE;AAAEP,IAAAA,iBAAiB,EAAE;AAArB,GAR6B;AASvCQ,EAAAA,QAAQ,EAAE;AAAER,IAAAA,iBAAiB,EAAE;AAArB,GAT6B;AAUvCS,EAAAA,IAAI,EAAE;AAAET,IAAAA,iBAAiB,EAAE;AAArB;AAViC,CAA3C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,KAD9C;AAEIe,IAAAA,UAAU,EAAE;AAFhB,GAFkB,EAMlBP,KANkB,CAAD,CAArB;AASA,QAAMQ,aAAa,GAAG3C,gBAAgB,CAACoC,OAAD,CAAtC;AACA,QAAMlC,iBAAiB,GAAG6B,IAAI,KAAKd,SAAT,GAAqB,MAArB,GAA8B0B,aAA9B,aAA8BA,aAA9B,uBAA8BA,aAAa,CAAEzC,iBAAvE;AAEA,sBACI,oBAAC,IAAD;AACI,IAAA,GAAG,EAAEwB,GADT;AAEI,IAAA,iBAAiB,EAAExB,iBAFvB;AAGI,kBAAYyC,aAAZ,aAAYA,aAAZ,uBAAYA,aAAa,CAAG,YAAH,CAH7B;AAII,IAAA,QAAQ,EAAEf,QAJd;AAKI,IAAA,aAAa,EAAEE,aALnB,CAMI;AANJ;AAOI,IAAA,IAAI,EAAEC,IAPV;AAQI,IAAA,aAAa,EAAEC,aARnB;AASI,IAAA,OAAO,EAAEC,OATb;AAUI,IAAA,UAAU,EAAEC,UAVhB;AAWI,IAAA,KAAK,EAAEM;AAXX,IADJ;AAeH,CAhDkB,CAAnB;AAkDA,4BAAe7C,KAAK,CAACiD,IAAN,CAAWrB,UAAX,CAAf","sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport type { Theme } from '@fountain-ui/styles';\nimport { createFontStyle, css, useTheme } from '../styles';\nimport TypographyProps, { AccessibilityMap, TypographyColor } from './TypographyProps';\n\nconst accessibilityMap: AccessibilityMap = {\n h1: { accessibilityRole: 'header', 'area-level': 1 },\n h2: { accessibilityRole: 'header', 'area-level': 2 },\n h3: { accessibilityRole: 'header', 'area-level': 3 },\n subtitle1: { accessibilityRole: 'header', 'area-level': 6 },\n subtitle2: { accessibilityRole: 'header', 'area-level': 6 },\n body1: { accessibilityRole: 'text' },\n body2: { accessibilityRole: 'text' },\n caption1: { accessibilityRole: 'text' },\n caption2: { accessibilityRole: 'text' },\n flag: { accessibilityRole: 'text' },\n};\n\nfunction selectColor(theme: Theme, colorProp: TypographyColor): string | undefined {\n const palette = theme.palette.text;\n\n switch (colorProp) {\n case 'inherit':\n return undefined;\n case 'textPrimary':\n return palette.primary;\n case 'textSecondary':\n return palette.secondary;\n case 'textAccent':\n return palette.accent;\n case 'textHint':\n return palette.hint;\n }\n\n return theme.palette[colorProp]?.main;\n}\n\nconst Typography = React.forwardRef<Text, TypographyProps>(function Typography(props, ref) {\n const {\n align = 'inherit',\n children,\n color: colorProp = 'inherit',\n ellipsizeMode = 'tail',\n href,\n numberOfLines,\n onPress,\n selectable,\n style,\n variant = 'body1',\n } = props;\n\n const theme = useTheme();\n\n const fontStyle = createFontStyle(theme, {\n selector: (typography) => typography[variant],\n color: selectColor(theme, colorProp),\n });\n\n const textStyle = css([\n fontStyle,\n {\n textAlign: align === 'inherit' ? 'auto' : align,\n flexShrink: 1,\n },\n style,\n ]);\n\n const accessibility = accessibilityMap[variant];\n const accessibilityRole = href !== undefined ? 'link' : accessibility?.accessibilityRole;\n\n return (\n <Text\n ref={ref}\n accessibilityRole={accessibilityRole}\n aria-level={accessibility?.['area-level']}\n children={children}\n ellipsizeMode={ellipsizeMode}\n // @ts-ignore\n href={href}\n numberOfLines={numberOfLines}\n onPress={onPress}\n selectable={selectable}\n style={textStyle}\n />\n );\n});\n\nexport default React.memo(Typography);\n"]}
1
+ {"version":3,"sources":["Typography.tsx"],"names":["React","Platform","Text","createFontStyle","css","useTheme","accessibilityMap","h1","accessibilityRole","h2","h3","subtitle1","subtitle2","body1","body2","caption1","caption2","flag","selectColor","theme","colorProp","palette","text","OS","undefined","primary","secondary","accent","hint","main","Typography","forwardRef","props","ref","align","children","color","ellipsizeMode","href","numberOfLines","onPress","selectable","style","variant","fontStyle","selector","typography","textStyle","textAlign","flexShrink","accessibility","memo"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,cAA/B;AAEA,SAASC,eAAT,EAA0BC,GAA1B,EAA+BC,QAA/B,QAA+C,WAA/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AAEzB,iBAFvB;AAGI,kBAAY0C,aAAZ,aAAYA,aAAZ,uBAAYA,aAAa,CAAG,YAAH,CAH7B;AAII,IAAA,QAAQ,EAAEf,QAJd;AAKI,IAAA,aAAa,EAAEE,aALnB,CAMI;AANJ;AAOI,IAAA,IAAI,EAAEC,IAPV;AAQI,IAAA,aAAa,EAAEC,aARnB;AASI,IAAA,OAAO,EAAEC,OATb;AAUI,IAAA,UAAU,EAAEC,UAVhB;AAWI,IAAA,KAAK,EAAEM;AAXX,IADJ;AAeH,CAhDkB,CAAnB;AAkDA,4BAAe/C,KAAK,CAACmD,IAAN,CAAWrB,UAAX,CAAf","sourcesContent":["import React from 'react';\nimport { Platform, Text } from 'react-native';\nimport type { Theme } from '@fountain-ui/styles';\nimport { createFontStyle, css, useTheme } from '../styles';\nimport TypographyProps, { AccessibilityMap, TypographyColor } from './TypographyProps';\n\nconst accessibilityMap: AccessibilityMap = {\n h1: { accessibilityRole: 'header', 'area-level': 1 },\n h2: { accessibilityRole: 'header', 'area-level': 2 },\n h3: { accessibilityRole: 'header', 'area-level': 3 },\n subtitle1: { accessibilityRole: 'header', 'area-level': 6 },\n subtitle2: { accessibilityRole: 'header', 'area-level': 6 },\n body1: { accessibilityRole: 'text' },\n body2: { accessibilityRole: 'text' },\n caption1: { accessibilityRole: 'text' },\n caption2: { accessibilityRole: 'text' },\n flag: { accessibilityRole: 'text' },\n};\n\nfunction selectColor(theme: Theme, colorProp: TypographyColor): string | undefined {\n const palette = theme.palette.text;\n\n switch (colorProp) {\n case 'inherit':\n return Platform.OS === 'web' ? 'inherit' : undefined;\n case 'textPrimary':\n return palette.primary;\n case 'textSecondary':\n return palette.secondary;\n case 'textAccent':\n return palette.accent;\n case 'textHint':\n return palette.hint;\n }\n\n return theme.palette[colorProp]?.main;\n}\n\nconst Typography = React.forwardRef<Text, TypographyProps>(function Typography(props, ref) {\n const {\n align = 'inherit',\n children,\n color: colorProp = 'inherit',\n ellipsizeMode = 'tail',\n href,\n numberOfLines,\n onPress,\n selectable,\n style,\n variant = 'body1',\n } = props;\n\n const theme = useTheme();\n\n const fontStyle = createFontStyle(theme, {\n selector: (typography) => typography[variant],\n color: selectColor(theme, colorProp),\n });\n\n const textStyle = css([\n fontStyle,\n {\n textAlign: align === 'inherit' ? 'auto' : align,\n flexShrink: 1,\n },\n style,\n ]);\n\n const accessibility = accessibilityMap[variant];\n const accessibilityRole = href !== undefined ? 'link' : accessibility?.accessibilityRole;\n\n return (\n <Text\n ref={ref}\n accessibilityRole={accessibilityRole}\n aria-level={accessibility?.['area-level']}\n children={children}\n ellipsizeMode={ellipsizeMode}\n // @ts-ignore\n href={href}\n numberOfLines={numberOfLines}\n onPress={onPress}\n selectable={selectable}\n style={textStyle}\n />\n );\n});\n\nexport default React.memo(Typography);\n"]}
@@ -1,4 +1,6 @@
1
+ export { default as useBreakpointUp } from './useBreakpointUp';
1
2
  export { default as useCollapsibleAppBar } from './useCollapsibleAppBar';
3
+ export { default as useContentContainerStyle } from './useContentContainerStyle';
2
4
  export { default as useElevationStyle } from './useElevationStyle';
3
5
  export { default as useFadeInAppBar } from './useFadeInAppBar';
4
6
  export { default as useThrottle } from './useThrottle';
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["default","useCollapsibleAppBar","useElevationStyle","useFadeInAppBar","useThrottle"],"mappings":"AAAA,SAASA,OAAO,IAAIC,oBAApB,QAAgD,wBAAhD;AACA,SAASD,OAAO,IAAIE,iBAApB,QAA6C,qBAA7C;AACA,SAASF,OAAO,IAAIG,eAApB,QAA2C,mBAA3C;AACA,SAASH,OAAO,IAAII,WAApB,QAAuC,eAAvC","sourcesContent":["export { default as useCollapsibleAppBar } from './useCollapsibleAppBar';\nexport { default as useElevationStyle } from './useElevationStyle';\nexport { default as useFadeInAppBar } from './useFadeInAppBar';\nexport { default as useThrottle } from './useThrottle';"]}
1
+ {"version":3,"sources":["index.ts"],"names":["default","useBreakpointUp","useCollapsibleAppBar","useContentContainerStyle","useElevationStyle","useFadeInAppBar","useThrottle"],"mappings":"AAAA,SAASA,OAAO,IAAIC,eAApB,QAA2C,mBAA3C;AACA,SAASD,OAAO,IAAIE,oBAApB,QAAgD,wBAAhD;AACA,SAASF,OAAO,IAAIG,wBAApB,QAAoD,4BAApD;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,qBAA7C;AACA,SAASJ,OAAO,IAAIK,eAApB,QAA2C,mBAA3C;AACA,SAASL,OAAO,IAAIM,WAApB,QAAuC,eAAvC","sourcesContent":["export { default as useBreakpointUp } from './useBreakpointUp';\nexport { default as useCollapsibleAppBar } from './useCollapsibleAppBar';\nexport { default as useContentContainerStyle } from './useContentContainerStyle';\nexport { default as useElevationStyle } from './useElevationStyle';\nexport { default as useFadeInAppBar } from './useFadeInAppBar';\nexport { default as useThrottle } from './useThrottle';\n"]}
@@ -26,17 +26,23 @@ export default function useCollapsibleAppBar(userOptions = defaultOptions) {
26
26
  const lastOffsetY = Animated.useSharedValue(0);
27
27
  const overlapped = Animated.useSharedValue(false);
28
28
  const elevationStyle = useElevationStyle(6);
29
- const animatedStyle = Animated.useAnimatedStyle(() => ({
30
- transform: [{
31
- translateY: translateY.value
32
- }],
33
- boxShadow: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.boxShadow,
34
- elevation: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.elevation : 0,
35
- shadowColor: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowColor,
36
- shadowOffset: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOffset,
37
- shadowRadius: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowRadius,
38
- shadowOpacity: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOpacity : 0
39
- }));
29
+ const animatedStyle = Animated.useAnimatedStyle(() => {
30
+ return Platform.OS === 'web' ? {
31
+ transform: [{
32
+ translateY: translateY.value
33
+ }],
34
+ boxShadow: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.boxShadow : 0
35
+ } : {
36
+ transform: [{
37
+ translateY: translateY.value
38
+ }],
39
+ elevation: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.elevation : 0,
40
+ shadowColor: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowColor,
41
+ shadowOffset: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOffset,
42
+ shadowRadius: elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowRadius,
43
+ shadowOpacity: overlapped.value ? elevationStyle === null || elevationStyle === void 0 ? void 0 : elevationStyle.shadowOpacity : 0
44
+ };
45
+ });
40
46
  const indexRef = React.useRef(0);
41
47
  const offsetsRef = React.useRef([]);
42
48
 
@@ -94,6 +100,7 @@ export default function useCollapsibleAppBar(userOptions = defaultOptions) {
94
100
  }
95
101
  }
96
102
 
103
+ overlapped.value = offsetY > 0;
97
104
  lastOffsetY.value = offsetY;
98
105
  }
99
106
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["useCollapsibleAppBar.ts"],"names":["React","Platform","Animated","useSafeAreaInsets","useElevationStyle","useHeight","useAppbarStyles","defaultOptions","translucent","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","useDerivedValue","translateY","useSharedValue","lastTranslateY","lastOffsetY","overlapped","elevationStyle","animatedStyle","useAnimatedStyle","transform","value","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","useRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","current","savedOffsetY","withTiming","duration","scrollHandler","useAnimatedScrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","dy","Math","min","max","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","undefined","floating","scrollContentInsets"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,SAASC,iBAAT,QAAkC,UAAlC;AACA,SAASC,SAAT,QAA0B,mBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AA4BA,MAAMC,cAAiC,GAAG;AACtCC,EAAAA,WAAW,EAAE;AADyB,CAA1C;AAIA,MAAMC,yBAAyB,GAAG,GAAlC;AAEA,MAAMC,uBAAuB,GAAGT,QAAQ,CAACU,EAAT,KAAgB,KAAhD;AAEA,eAAe,SAASC,oBAAT,CAA8BC,WAAoB,GAAGN,cAArD,EAAwF;AACnG,QAAM;AAAEC,IAAAA;AAAF,MAAqC,EACvC,GAAGD,cADoC;AAEvC,OAAGM;AAFoC,GAA3C;AAKA,QAAMC,MAAM,GAAGR,eAAe,EAA9B;AAEA,QAAMS,cAAc,GAAGZ,iBAAiB,EAAxC;AAEA,QAAM,CAACa,YAAD,EAAeC,cAAf,IAAiCZ,SAAS,EAAhD;AACA,QAAM,CAACa,wBAAD,EAA2BC,0BAA3B,IAAyDd,SAAS,EAAxE;AAEA,QAAMe,aAAa,GAAGlB,QAAQ,CAACmB,eAAT,CAAyB,MAAM,CAACH,wBAAhC,CAAtB;AAEA,QAAMI,UAAU,GAAGpB,QAAQ,CAACqB,cAAT,CAAgC,CAAhC,CAAnB;AACA,QAAMC,cAAc,GAAGtB,QAAQ,CAACqB,cAAT,CAAgC,CAAhC,CAAvB;AACA,QAAME,WAAW,GAAGvB,QAAQ,CAACqB,cAAT,CAAgC,CAAhC,CAApB;AACA,QAAMG,UAAU,GAAGxB,QAAQ,CAACqB,cAAT,CAAiC,KAAjC,CAAnB;AAEA,QAAMI,cAAc,GAAGvB,iBAAiB,CAAC,CA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xE;AAEAhC,MAAAA,UAAU,CAACK,KAAX,GAAmBuB,OAAO,GAAGY,cAAV,GAA2B,CAA9C;AAEA5C,MAAAA,UAAU,CAACS,KAAX,GAAmB7B,QAAQ,CAAC4C,UAAT,CAAoBoB,cAApB,EAAoC;AACnDnB,QAAAA,QAAQ,EAAEtC;AADyC,OAApC,CAAnB;AAGH;AA9DmD,GAAlC,CAAtB;AAiEA,QAAM0D,cAAc,GAAGjD,wBAAwB,GAAG,CAAlD;AAEA,QAAMkD,WAAW,GAAG,CAChBxC,aADgB,EAEhBpB,WAAW,GAAG;AAAE6D,IAAAA,UAAU,EAAEtD,cAAc,CAACuD;AAA7B,GAAH,GAAwCC,SAFnC,EAGhBJ,cAAc,GAAGrD,MAAM,CAAC0D,QAAV,GAAqBD,SAHnB,CAApB;AAMA,SAAO;AACHH,IAAAA,WADG;AAEHnD,IAAAA,cAFG;AAGHE,IAAAA,0BAHG;AAIHiC,IAAAA,QAAQ,EAAEJ,aAJP;AAKHP,IAAAA,mBALG;AAMHgC,IAAAA,mBAAmB,EAAE;AAAEH,MAAAA,GAAG,EAAEH,cAAc,GAAGnD,YAAH,GAAkB;AAAvC;AANlB,GAAP;AAQH;AAAA","sourcesContent":["import React from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { useElevationStyle } from '../hooks';\nimport { useHeight } from '../internal/hooks';\nimport useAppbarStyles from './useAppbarStyles';\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n translucent?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n translucent: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\nexport default function useCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { translucent }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = Animated.useDerivedValue(() => -collapsibleToolbarHeight);\n\n const translateY = Animated.useSharedValue<number>(0);\n const lastTranslateY = Animated.useSharedValue<number>(0);\n const lastOffsetY = Animated.useSharedValue<number>(0);\n const overlapped = Animated.useSharedValue<boolean>(false);\n\n const elevationStyle = useElevationStyle(6);\n const animatedStyle = Animated.useAnimatedStyle(() => ({\n transform: [{ translateY: translateY.value }],\n boxShadow: elevationStyle?.boxShadow,\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n }));\n\n const indexRef = React.useRef<number>(0);\n const offsetsRef = React.useRef<Array<number>>([]);\n\n const onScrollViewChanged = (nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n };\n\n const scrollHandler = Animated.useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = Animated.withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = Animated.withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n });\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n translucent ? { paddingTop: safeAreaInsets.top } : undefined,\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarHeight : 0 },\n };\n};\n"]}
1
+ {"version":3,"sources":["useCollapsibleAppBar.ts"],"names":["React","Platform","Animated","useSafeAreaInsets","useElevationStyle","useHeight","useAppbarStyles","defaultOptions","translucent","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","useDerivedValue","translateY","useSharedValue","lastTranslateY","lastOffsetY","overlapped","elevationStyle","animatedStyle","useAnimatedStyle","transform","value","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","useRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","current","savedOffsetY","withTiming","duration","scrollHandler","useAnimatedScrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","dy","Math","min","max","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","undefined","floating","scrollContentInsets"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,SAASC,iBAAT,QAAkC,UAAlC;AACA,SAASC,SAAT,QAA0B,mBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AA8BA,MAAMC,cAAiC,GAAG;AACtCC,EAAAA,WAAW,EAAE;AADyB,CAA1C;AAIA,MAAMC,yBAAyB,GAAG,GAAlC;AAEA,MAAMC,uBAAuB,GAAGT,QAAQ,CAACU,EAAT,KAAgB,KAAhD;AAEA,eAAe,SAASC,oBAAT,CAA8BC,WAAoB,GAAGN,cAArD,EAAwF;AACnG,QAAM;AAAEC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AAwB,GAAG,CAAlD;AAEA,QAAMkD,WAAW,GAAG,CAChBxC,aADgB,EAEhBpB,WAAW,GAAG;AAAE6D,IAAAA,UAAU,EAAEtD,cAAc,CAACuD;AAA7B,GAAH,GAAwCC,SAFnC,EAGhBJ,cAAc,GAAGrD,MAAM,CAAC0D,QAAV,GAAqBD,SAHnB,CAApB;AAMA,SAAO;AACHH,IAAAA,WADG;AAEHnD,IAAAA,cAFG;AAGHE,IAAAA,0BAHG;AAIHiC,IAAAA,QAAQ,EAAEJ,aAJP;AAKHP,IAAAA,mBALG;AAMHgC,IAAAA,mBAAmB,EAAE;AAAEH,MAAAA,GAAG,EAAEH,cAAc,GAAGnD,YAAH,GAAkB;AAAvC;AANlB,GAAP;AAQH;AAAA","sourcesContent":["import React from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { useElevationStyle } from '../hooks';\nimport { useHeight } from '../internal/hooks';\nimport useAppbarStyles from './useAppbarStyles';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n translucent?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n translucent: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\nexport default function useCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { translucent }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = Animated.useDerivedValue(() => -collapsibleToolbarHeight);\n\n const translateY = Animated.useSharedValue<number>(0);\n const lastTranslateY = Animated.useSharedValue<number>(0);\n const lastOffsetY = Animated.useSharedValue<number>(0);\n const overlapped = Animated.useSharedValue<boolean>(false);\n\n const elevationStyle = useElevationStyle(6);\n const animatedStyle = Animated.useAnimatedStyle(() => {\n return Platform.OS === 'web' ? ({\n transform: [{ translateY: translateY.value }],\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n }) : ({\n transform: [{ translateY: translateY.value }],\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n });\n });\n\n const indexRef = React.useRef<number>(0);\n const offsetsRef = React.useRef<Array<number>>([]);\n\n const onScrollViewChanged = (nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n };\n\n const scrollHandler = Animated.useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = Animated.withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = Animated.withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n });\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n translucent ? { paddingTop: safeAreaInsets.top } : undefined,\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarHeight : 0 },\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["useContentContainerStyle.ts"],"names":["useTheme","useBreakpointUp","defaultConfig","breakpoint","maxWidth","styleProvider","undefined","getMaxWidth","theme","breakpoints","values","useContentContainerStyle","config","additionalStyle","yesStyle","alignSelf","width"],"mappings":"AAEA,SAASA,QAAT,QAAyB,WAAzB;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAYA,MAAMC,aAA+B,GAAG;AACpCC,EAAAA,UAAU,EAAE,IADwB;AAEpCC,EAAAA,QAAQ,EAAE,IAF0B;AAGpCC,EAAAA,aAAa,EAAE,MAAMC;AAHe,CAAxC,C,CAMA;;AACA,SAASC,WAAT,CAAqBC,KAArB,EAAmCL,UAAnC,EAAkF;AAC9E,UAAQA,UAAR;AACI,SAAK,IAAL;AACI,aAAOK,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyB,IAAzB,CAAP;;AACJ,SAAK,IAAL;AACI,aAAOF,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyB,IAAzB,CAAP;;AACJ,SAAK,IAAL;AACI,aAAOF,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyB,IAAzB,CAAP;;AACJ,SAAK,IAAL;AACI,aAAO,MAAP;AARR;AAUH;;AAED,eAAe,SAASC,wBAAT,CAAkCC,MAAM,GAAGV,aAA3C,EAAiF;AAC5F,QAAM;AACFC,IAAAA,UADE;AAEFC,IAAAA,QAFE;AAGFC,IAAAA;AAHE,MAIF,EACA,GAAGH,aADH;AAEA,OAAGU;AAFH,GAJJ;AASA,QAAMJ,KAAK,GAAGR,QAAQ,EAAtB;AAEA,QAAMa,eAAe,GAAGR,aAAH,aAAGA,aAAH,uBAAGA,aAAa,CAAGG,KAAH,CAArC;AAEA,QAAMM,QAA+B,GAAG,CACpC;AACIC,IAAAA,SAAS,EAAE,QADf;AAEIX,IAAAA,QAAQ,EAAEG,WAAW,CAACC,KAAD,EAAQJ,QAAR,CAFzB;AAGIY,IAAAA,KAAK,EAAE;AAHX,GADoC,EAMpCH,eANoC,CAAxC;AASA,SAAOZ,eAAe,CAACE,UAAD,EAAaW,QAAb,EAAuBD,eAAvB,CAAtB;AACH;AAAA","sourcesContent":["import type { ScrollViewProps, ViewStyle } from 'react-native';\nimport type { Theme } from '../types';\nimport { useTheme } from '../styles';\nimport useBreakpointUp from './useBreakpointUp';\n\ntype Breakpoint = keyof Theme['breakpoints']['values'];\n\ntype ContentContainerStyle = ScrollViewProps['contentContainerStyle'];\n\nexport interface Config {\n breakpoint?: Breakpoint;\n maxWidth?: Breakpoint;\n styleProvider?: (theme: Theme) => ContentContainerStyle;\n}\n\nconst defaultConfig: Required<Config> = {\n breakpoint: 'lg',\n maxWidth: 'md',\n styleProvider: () => undefined,\n};\n\n// TODO: Needs to refactor\nfunction getMaxWidth(theme: Theme, breakpoint: Breakpoint): ViewStyle['maxWidth'] {\n switch (breakpoint) {\n case 'xs':\n return theme.breakpoints.values['sm'];\n case 'sm':\n return theme.breakpoints.values['md'];\n case 'md':\n return theme.breakpoints.values['lg'];\n case 'lg':\n return 'none';\n }\n}\n\nexport default function useContentContainerStyle(config = defaultConfig): ContentContainerStyle {\n const {\n breakpoint,\n maxWidth,\n styleProvider,\n } = {\n ...defaultConfig,\n ...config,\n };\n\n const theme = useTheme();\n\n const additionalStyle = styleProvider?.(theme);\n\n const yesStyle: ContentContainerStyle = [\n {\n alignSelf: 'center',\n maxWidth: getMaxWidth(theme, maxWidth),\n width: '100%',\n },\n additionalStyle,\n ];\n\n return useBreakpointUp(breakpoint, yesStyle, additionalStyle);\n};\n"]}
1
+ {"version":3,"sources":["useContentContainerStyle.ts"],"names":["useTheme","useBreakpointUp","defaultConfig","breakpoint","maxWidth","styleProvider","undefined","getMaxWidth","theme","breakpoints","values","useContentContainerStyle","config","additionalStyle","yesStyle","alignSelf","width"],"mappings":"AAEA,SAASA,QAAT,QAAyB,WAAzB;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAYA,MAAMC,aAA+B,GAAG;AACpCC,EAAAA,UAAU,EAAE,IADwB;AAEpCC,EAAAA,QAAQ,EAAE,IAF0B;AAGpCC,EAAAA,aAAa,EAAE,MAAMC;AAHe,CAAxC,C,CAMA;;AACA,SAASC,WAAT,CAAqBC,KAArB,EAAmCL,UAAnC,EAAkF;AAC9E,UAAQA,UAAR;AACI,SAAK,IAAL;AACI,aAAOK,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyB,IAAzB,CAAP;;AACJ,SAAK,IAAL;AACI,aAAOF,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyB,IAAzB,CAAP;;AACJ,SAAK,IAAL;AACI,aAAOF,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyB,IAAzB,CAAP;;AACJ,SAAK,IAAL;AACI,aAAO,MAAP;AARR;AAUH;;AAED,eAAe,SAASC,wBAAT,CAAkCC,MAAc,GAAGV,aAAnD,EAAyF;AACpG,QAAM;AACFC,IAAAA,UADE;AAEFC,IAAAA,QAFE;AAGFC,IAAAA;AAHE,MAIF,EACA,GAAGH,aADH;AAEA,OAAGU;AAFH,GAJJ;AASA,QAAMJ,KAAK,GAAGR,QAAQ,EAAtB;AAEA,QAAMa,eAAe,GAAGR,aAAH,aAAGA,aAAH,uBAAGA,aAAa,CAAGG,KAAH,CAArC;AAEA,QAAMM,QAA+B,GAAG,CACpC;AACIC,IAAAA,SAAS,EAAE,QADf;AAEIX,IAAAA,QAAQ,EAAEG,WAAW,CAACC,KAAD,EAAQJ,QAAR,CAFzB;AAGIY,IAAAA,KAAK,EAAE;AAHX,GADoC,EAMpCH,eANoC,CAAxC;AASA,SAAOZ,eAAe,CAACE,UAAD,EAAaW,QAAb,EAAuBD,eAAvB,CAAtB;AACH;AAAA","sourcesContent":["import type { ScrollViewProps, ViewStyle } from 'react-native';\nimport type { Theme } from '../types';\nimport { useTheme } from '../styles';\nimport useBreakpointUp from './useBreakpointUp';\n\ntype Breakpoint = keyof Theme['breakpoints']['values'];\n\ntype ContentContainerStyle = ScrollViewProps['contentContainerStyle'];\n\nexport interface Config {\n breakpoint?: Breakpoint;\n maxWidth?: Breakpoint;\n styleProvider?: (theme: Theme) => ContentContainerStyle;\n}\n\nconst defaultConfig: Required<Config> = {\n breakpoint: 'lg',\n maxWidth: 'md',\n styleProvider: () => undefined,\n};\n\n// TODO: Needs to refactor\nfunction getMaxWidth(theme: Theme, breakpoint: Breakpoint): ViewStyle['maxWidth'] {\n switch (breakpoint) {\n case 'xs':\n return theme.breakpoints.values['sm'];\n case 'sm':\n return theme.breakpoints.values['md'];\n case 'md':\n return theme.breakpoints.values['lg'];\n case 'lg':\n return 'none';\n }\n}\n\nexport default function useContentContainerStyle(config: Config = defaultConfig): ContentContainerStyle {\n const {\n breakpoint,\n maxWidth,\n styleProvider,\n } = {\n ...defaultConfig,\n ...config,\n };\n\n const theme = useTheme();\n\n const additionalStyle = styleProvider?.(theme);\n\n const yesStyle: ContentContainerStyle = [\n {\n alignSelf: 'center',\n maxWidth: getMaxWidth(theme, maxWidth),\n width: '100%',\n },\n additionalStyle,\n ];\n\n return useBreakpointUp(breakpoint, yesStyle, additionalStyle);\n};\n"]}
@@ -1,4 +1,6 @@
1
+ export { default as useBreakpointUp } from './useBreakpointUp';
1
2
  export { default as useCollapsibleAppBar } from './useCollapsibleAppBar';
3
+ export { default as useContentContainerStyle } from './useContentContainerStyle';
2
4
  export { default as useElevationStyle } from './useElevationStyle';
3
5
  export { default as useFadeInAppBar } from './useFadeInAppBar';
4
6
  export { default as useThrottle } from './useThrottle';
@@ -1,5 +1,8 @@
1
1
  import { Falsy, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';
2
- declare type ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | Falsy>;
2
+ declare type WebOnlyStyle = {
3
+ boxShadow: any;
4
+ };
5
+ declare type ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;
3
6
  declare type OnScroll = ScrollViewProps['onScroll'];
4
7
  declare type OnLayoutCallback = ViewProps['onLayout'];
5
8
  export interface ContentInsets {
@@ -7,5 +7,5 @@ export interface Config {
7
7
  maxWidth?: Breakpoint;
8
8
  styleProvider?: (theme: Theme) => ContentContainerStyle;
9
9
  }
10
- export default function useContentContainerStyle(config?: Required<Config>): ContentContainerStyle;
10
+ export default function useContentContainerStyle(config?: Config): ContentContainerStyle;
11
11
  export {};
@@ -38,8 +38,8 @@ declare const _default: React.MemoExoticComponent<{
38
38
  rotation?: import("react-native-svg").NumberProp | undefined;
39
39
  x?: import("react-native-svg").NumberArray | undefined;
40
40
  y?: import("react-native-svg").NumberArray | undefined;
41
- vectorEffect?: "none" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "inherit" | "uri" | undefined;
42
- pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
41
+ vectorEffect?: "none" | "inherit" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "uri" | undefined;
42
+ pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
43
43
  onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
44
44
  onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
45
45
  onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
@@ -38,8 +38,8 @@ declare const _default: React.MemoExoticComponent<{
38
38
  rotation?: import("react-native-svg").NumberProp | undefined;
39
39
  x?: import("react-native-svg").NumberArray | undefined;
40
40
  y?: import("react-native-svg").NumberArray | undefined;
41
- vectorEffect?: "none" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "inherit" | "uri" | undefined;
42
- pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
41
+ vectorEffect?: "none" | "inherit" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "uri" | undefined;
42
+ pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
43
43
  onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
44
44
  onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
45
45
  onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
@@ -38,8 +38,8 @@ declare const _default: React.MemoExoticComponent<{
38
38
  rotation?: import("react-native-svg").NumberProp | undefined;
39
39
  x?: import("react-native-svg").NumberArray | undefined;
40
40
  y?: import("react-native-svg").NumberArray | undefined;
41
- vectorEffect?: "none" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "inherit" | "uri" | undefined;
42
- pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
41
+ vectorEffect?: "none" | "inherit" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "uri" | undefined;
42
+ pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
43
43
  onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
44
44
  onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
45
45
  onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
@@ -38,8 +38,8 @@ declare const _default: React.MemoExoticComponent<{
38
38
  rotation?: import("react-native-svg").NumberProp | undefined;
39
39
  x?: import("react-native-svg").NumberArray | undefined;
40
40
  y?: import("react-native-svg").NumberArray | undefined;
41
- vectorEffect?: "none" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "inherit" | "uri" | undefined;
42
- pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
41
+ vectorEffect?: "none" | "inherit" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "uri" | undefined;
42
+ pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
43
43
  onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
44
44
  onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
45
45
  onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
@@ -38,8 +38,8 @@ declare const _default: React.MemoExoticComponent<{
38
38
  rotation?: import("react-native-svg").NumberProp | undefined;
39
39
  x?: import("react-native-svg").NumberArray | undefined;
40
40
  y?: import("react-native-svg").NumberArray | undefined;
41
- vectorEffect?: "none" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "inherit" | "uri" | undefined;
42
- pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
41
+ vectorEffect?: "none" | "inherit" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "uri" | undefined;
42
+ pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
43
43
  onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
44
44
  onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
45
45
  onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
@@ -38,8 +38,8 @@ declare const _default: React.MemoExoticComponent<{
38
38
  rotation?: import("react-native-svg").NumberProp | undefined;
39
39
  x?: import("react-native-svg").NumberArray | undefined;
40
40
  y?: import("react-native-svg").NumberArray | undefined;
41
- vectorEffect?: "none" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "inherit" | "uri" | undefined;
42
- pointerEvents?: "none" | "box-none" | "box-only" | "auto" | undefined;
41
+ vectorEffect?: "none" | "inherit" | "non-scaling-stroke" | "nonScalingStroke" | "default" | "uri" | undefined;
42
+ pointerEvents?: "auto" | "none" | "box-none" | "box-only" | undefined;
43
43
  onStartShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
44
44
  onMoveShouldSetResponder?: ((event: import("react-native").GestureResponderEvent) => boolean) | undefined;
45
45
  onResponderEnd?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fountain-ui/core",
3
- "version": "1.10.0",
3
+ "version": "1.11.3",
4
4
  "author": "Fountain-UI Team",
5
5
  "description": "React components that implement Tappytoon's Fountain Design.",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@
14
14
  "prepare": "bob build"
15
15
  },
16
16
  "dependencies": {
17
- "@fountain-ui/styles": "^1.3.0",
17
+ "@fountain-ui/styles": "^1.4.0",
18
18
  "@fountain-ui/utils": "^1.1.0"
19
19
  },
20
20
  "peerDependencies": {
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "38c89201acebdf0642b1547b66af8e7f970f55e2"
70
+ "gitHead": "d0073b2a3cd04c55c88b1225fa46f37013adf63d"
71
71
  }
@@ -2,23 +2,11 @@ import React, { useState } from 'react';
2
2
  import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
3
3
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
4
4
  import { ChevronDown as ChevronDownIcon } from '../internal/icons';
5
- import {
6
- ButtonBase,
7
- Column,
8
- Divider,
9
- Spacer,
10
- Typography,
11
- } from '../index';
5
+ import { ButtonBase, Column, Divider, Spacer, Typography, useTheme } from '../index';
12
6
  import AccordionProps from './AccordionProps';
13
7
 
14
8
  type AccordionStyles = NamedStylesStringUnion<'buttonBase'>;
15
9
 
16
- const useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {
17
- return {
18
- buttonBase: { flexDirection: 'row' },
19
- };
20
- };
21
-
22
10
  const ANIMATION_OPTION = { duration: 250 };
23
11
 
24
12
  export default function Accordion(props: AccordionProps) {
@@ -29,6 +17,16 @@ export default function Accordion(props: AccordionProps) {
29
17
  title,
30
18
  titleVariant = 'subtitle2',
31
19
  } = props;
20
+ const theme = useTheme();
21
+
22
+ const useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {
23
+ return {
24
+ buttonBase: {
25
+ flexDirection: 'row',
26
+ paddingVertical: theme.spacing(3),
27
+ },
28
+ };
29
+ };
32
30
 
33
31
  const styles = useStyles();
34
32
  const [isExpanded, setIsExpanded] = useState(false);