@fountain-ui/core 2.0.0-beta.74 → 2.0.0-beta.76

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 (67) hide show
  1. package/build/commonjs/Button/Button.js +1 -1
  2. package/build/commonjs/Button/Button.js.map +1 -1
  3. package/build/commonjs/Dialog/Dialog.js +30 -2
  4. package/build/commonjs/Dialog/Dialog.js.map +1 -1
  5. package/build/commonjs/Modal/Modal.js +7 -1
  6. package/build/commonjs/Modal/Modal.js.map +1 -1
  7. package/build/commonjs/Modal/ModalProps.js.map +1 -1
  8. package/build/commonjs/Snackbar/Snackbar.js +34 -7
  9. package/build/commonjs/Snackbar/Snackbar.js.map +1 -1
  10. package/build/commonjs/Snackbar/SnackbarProps.js.map +1 -1
  11. package/build/commonjs/SnackbarContent/SnackbarContent.js +32 -14
  12. package/build/commonjs/SnackbarContent/SnackbarContent.js.map +1 -1
  13. package/build/commonjs/SnackbarContent/SnackbarContentProps.js.map +1 -1
  14. package/build/commonjs/Tab/Tab.js +23 -14
  15. package/build/commonjs/Tab/Tab.js.map +1 -1
  16. package/build/commonjs/Tab/TabIndicator.js +5 -4
  17. package/build/commonjs/Tab/TabIndicator.js.map +1 -1
  18. package/build/commonjs/Tab/TabProps.js.map +1 -1
  19. package/build/commonjs/Tab/index.js.map +1 -1
  20. package/build/commonjs/Tabs/Tabs.js +46 -6
  21. package/build/commonjs/Tabs/Tabs.js.map +1 -1
  22. package/build/commonjs/Tabs/TabsProps.js.map +1 -1
  23. package/build/module/Button/Button.js +1 -1
  24. package/build/module/Button/Button.js.map +1 -1
  25. package/build/module/Dialog/Dialog.js +25 -3
  26. package/build/module/Dialog/Dialog.js.map +1 -1
  27. package/build/module/Modal/Modal.js +6 -1
  28. package/build/module/Modal/Modal.js.map +1 -1
  29. package/build/module/Modal/ModalProps.js.map +1 -1
  30. package/build/module/Snackbar/Snackbar.js +25 -5
  31. package/build/module/Snackbar/Snackbar.js.map +1 -1
  32. package/build/module/Snackbar/SnackbarProps.js.map +1 -1
  33. package/build/module/SnackbarContent/SnackbarContent.js +21 -6
  34. package/build/module/SnackbarContent/SnackbarContent.js.map +1 -1
  35. package/build/module/SnackbarContent/SnackbarContentProps.js.map +1 -1
  36. package/build/module/Tab/Tab.js +24 -15
  37. package/build/module/Tab/Tab.js.map +1 -1
  38. package/build/module/Tab/TabIndicator.js +5 -4
  39. package/build/module/Tab/TabIndicator.js.map +1 -1
  40. package/build/module/Tab/TabProps.js.map +1 -1
  41. package/build/module/Tab/index.js.map +1 -1
  42. package/build/module/Tabs/Tabs.js +48 -6
  43. package/build/module/Tabs/Tabs.js.map +1 -1
  44. package/build/module/Tabs/TabsProps.js.map +1 -1
  45. package/build/typescript/Modal/ModalProps.d.ts +10 -0
  46. package/build/typescript/Snackbar/SnackbarProps.d.ts +8 -0
  47. package/build/typescript/SnackbarContent/SnackbarContentProps.d.ts +9 -0
  48. package/build/typescript/Tab/TabIndicator.d.ts +3 -2
  49. package/build/typescript/Tab/TabProps.d.ts +14 -1
  50. package/build/typescript/Tab/index.d.ts +1 -1
  51. package/build/typescript/Tabs/Tabs.d.ts +1 -1
  52. package/build/typescript/Tabs/TabsProps.d.ts +14 -1
  53. package/package.json +2 -2
  54. package/src/Button/Button.tsx +1 -1
  55. package/src/Dialog/Dialog.tsx +26 -4
  56. package/src/Modal/Modal.tsx +7 -1
  57. package/src/Modal/ModalProps.ts +12 -0
  58. package/src/Snackbar/Snackbar.tsx +33 -7
  59. package/src/Snackbar/SnackbarProps.ts +16 -6
  60. package/src/SnackbarContent/SnackbarContent.tsx +42 -10
  61. package/src/SnackbarContent/SnackbarContentProps.ts +14 -3
  62. package/src/Tab/Tab.tsx +43 -17
  63. package/src/Tab/TabIndicator.tsx +7 -7
  64. package/src/Tab/TabProps.ts +16 -1
  65. package/src/Tab/index.ts +1 -1
  66. package/src/Tabs/Tabs.tsx +42 -4
  67. package/src/Tabs/TabsProps.ts +16 -1
@@ -84,7 +84,7 @@ function Button(props) {
84
84
  };
85
85
  const startIcon = (0, _utils.cloneElementSafely)(startIconProp, iconProps);
86
86
  const endIcon = (0, _utils.cloneElementSafely)(endIconProp, iconProps);
87
- const paddingSize = size === 'small' ? theme.spacing(2) : theme.spacing(4);
87
+ const paddingSize = size === 'small' ? theme.spacing(3) : theme.spacing(4);
88
88
  const paddingLeft = startIcon ? paddingSize - theme.spacing(1) : paddingSize;
89
89
  const paddingRight = endIcon ? paddingSize - theme.spacing(1) : paddingSize;
90
90
  const borderRadius = theme.shape.roundnessLarge;
@@ -1 +1 @@
1
- {"version":3,"names":["iconSizes","small","medium","styles","StyleSheet","create","root","flexDirection","justifyContent","alignItems","fullWidth","width","minWidth","height","Button","props","children","clipHorizontalSpacing","color","disabled","endIcon","endIconProp","href","onPress","pressEffect","size","startIcon","startIconProp","style","styleProp","variant","otherProps","theme","useTheme","mainColor","palette","main","fontColor","contrastTextColor","variantStyleMap","contained","backgroundColor","outlined","borderColor","borderStyle","borderWidth","text","iconProps","fill","cloneElementSafely","paddingSize","spacing","paddingLeft","paddingRight","borderRadius","shape","roundnessLarge","buttonBaseStyle","css","undefined","fontStyle","createFontStyle","selector","typo","button2","button1","textMarginSize","textMarginStyle","marginLeft","marginRight","textStyle","textAlign","modifiedPressEffect","handlePress","Linking","canOpenURL","openURL"],"sources":["Button.tsx"],"sourcesContent":["import React from 'react';\nimport { Linking, Text } from 'react-native';\nimport ButtonBase from '../ButtonBase';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport type ButtonProps from './ButtonProps';\nimport type { ButtonSize } from './ButtonProps';\n\ntype IconSizes = { [n in ButtonSize]: number };\n\nconst iconSizes: IconSizes = {\n small: 20,\n medium: 24,\n};\n\nconst styles = StyleSheet.create({\n root: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n },\n fullWidth: {\n width: '100%',\n },\n medium: {\n minWidth: 104,\n height: 48,\n },\n small: {\n minWidth: 56,\n height: 32,\n },\n});\n\nexport default function Button(props: ButtonProps) {\n const {\n children,\n clipHorizontalSpacing = false,\n color = 'primary',\n disabled = false,\n endIcon: endIconProp,\n fullWidth = false,\n href,\n onPress,\n pressEffect,\n size = 'medium',\n startIcon: startIconProp,\n style: styleProp,\n variant = 'contained',\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const mainColor = theme.palette[color].main;\n\n const fontColor = variant === 'contained'\n ? theme.palette[color].contrastTextColor\n : theme.palette[color].main;\n\n const variantStyleMap = {\n contained: {\n backgroundColor: mainColor,\n },\n outlined: {\n backgroundColor: 'transparent',\n borderColor: mainColor,\n borderStyle: 'solid',\n borderWidth: 1,\n },\n text: {\n backgroundColor: 'transparent',\n },\n };\n\n const iconProps = {\n width: iconSizes[size],\n height: iconSizes[size],\n fill: fontColor,\n };\n\n const startIcon = cloneElementSafely(startIconProp, iconProps);\n const endIcon = cloneElementSafely(endIconProp, iconProps);\n\n const paddingSize = size === 'small' ? theme.spacing(2) : theme.spacing(4);\n const paddingLeft = startIcon ? paddingSize - theme.spacing(1) : paddingSize;\n const paddingRight = endIcon ? paddingSize - theme.spacing(1) : paddingSize;\n\n const borderRadius = theme.shape.roundnessLarge;\n const buttonBaseStyle = css([\n styles.root,\n variantStyleMap[variant],\n size === 'medium' ? styles.medium : styles.small,\n fullWidth ? styles.fullWidth : undefined,\n { borderRadius, color: fontColor },\n (variant === 'text' && clipHorizontalSpacing)\n ? { minWidth: 0 }\n : { paddingLeft, paddingRight },\n styleProp,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => size === 'small' ? typo.button2 : typo.button1,\n color: fontColor,\n });\n\n const textMarginSize = size === 'small' ? theme.spacing(1) : theme.spacing(2);\n const textMarginStyle = startIcon\n ? { marginLeft: textMarginSize }\n : endIcon\n ? { marginRight: textMarginSize }\n : undefined;\n\n const textStyle = css([\n fontStyle,\n textMarginStyle,\n { textAlign: 'center' },\n ]);\n\n const modifiedPressEffect = variant !== 'text' && !pressEffect\n ? 'scale'\n : pressEffect;\n\n const handlePress = async () => {\n if (disabled) {\n return;\n }\n if (onPress) {\n onPress();\n return;\n }\n if (href) {\n if (await Linking.canOpenURL(href)) {\n await Linking.openURL(href);\n }\n }\n };\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={buttonBaseStyle}\n pressEffect={modifiedPressEffect}\n {...otherProps}\n >\n {startIcon}\n\n <Text\n children={children}\n style={textStyle}\n />\n\n {endIcon}\n </ButtonBase>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMA,MAAMA,SAAoB,GAAG;EACzBC,KAAK,EAAE,EADkB;EAEzBC,MAAM,EAAE;AAFiB,CAA7B;;AAKA,MAAMC,MAAM,GAAGC,kBAAA,CAAWC,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,aAAa,EAAE,KADb;IAEFC,cAAc,EAAE,QAFd;IAGFC,UAAU,EAAE;EAHV,CADuB;EAM7BC,SAAS,EAAE;IACPC,KAAK,EAAE;EADA,CANkB;EAS7BT,MAAM,EAAE;IACJU,QAAQ,EAAE,GADN;IAEJC,MAAM,EAAE;EAFJ,CATqB;EAa7BZ,KAAK,EAAE;IACHW,QAAQ,EAAE,EADP;IAEHC,MAAM,EAAE;EAFL;AAbsB,CAAlB,CAAf;;AAmBe,SAASC,MAAT,CAAgBC,KAAhB,EAAoC;EAC/C,MAAM;IACFC,QADE;IAEFC,qBAAqB,GAAG,KAFtB;IAGFC,KAAK,GAAG,SAHN;IAIFC,QAAQ,GAAG,KAJT;IAKFC,OAAO,EAAEC,WALP;IAMFX,SAAS,GAAG,KANV;IAOFY,IAPE;IAQFC,OARE;IASFC,WATE;IAUFC,IAAI,GAAG,QAVL;IAWFC,SAAS,EAAEC,aAXT;IAYFC,KAAK,EAAEC,SAZL;IAaFC,OAAO,GAAG,WAbR;IAcF,GAAGC;EAdD,IAeFhB,KAfJ;EAiBA,MAAMiB,KAAK,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B,IAAItD,QAAJ,EAAc;MACV;IACH;;IACD,IAAII,OAAJ,EAAa;MACTA,OAAO;MACP;IACH;;IACD,IAAID,IAAJ,EAAU;MACN,IAAI,MAAMoD,oBAAA,CAAQC,UAAR,CAAmBrD,IAAnB,CAAV,EAAoC;QAChC,MAAMoD,oBAAA,CAAQE,OAAR,CAAgBtD,IAAhB,CAAN;MACH;IACJ;EACJ,CAbD;;EAeA,oBACI,6BAAC,mBAAD;IACI,QAAQ,EAAEH,QADd;IAEI,OAAO,EAAEsD,WAFb;IAGI,KAAK,EAAEhB,eAHX;IAII,WAAW,EAAEe;EAJjB,GAKQzC,UALR,GAOKL,SAPL,eASI,6BAAC,iBAAD;IACI,QAAQ,EAAEV,QADd;IAEI,KAAK,EAAEsD;EAFX,EATJ,EAcKlD,OAdL,CADJ;AAkBH;;AAAA"}
1
+ {"version":3,"names":["iconSizes","small","medium","styles","StyleSheet","create","root","flexDirection","justifyContent","alignItems","fullWidth","width","minWidth","height","Button","props","children","clipHorizontalSpacing","color","disabled","endIcon","endIconProp","href","onPress","pressEffect","size","startIcon","startIconProp","style","styleProp","variant","otherProps","theme","useTheme","mainColor","palette","main","fontColor","contrastTextColor","variantStyleMap","contained","backgroundColor","outlined","borderColor","borderStyle","borderWidth","text","iconProps","fill","cloneElementSafely","paddingSize","spacing","paddingLeft","paddingRight","borderRadius","shape","roundnessLarge","buttonBaseStyle","css","undefined","fontStyle","createFontStyle","selector","typo","button2","button1","textMarginSize","textMarginStyle","marginLeft","marginRight","textStyle","textAlign","modifiedPressEffect","handlePress","Linking","canOpenURL","openURL"],"sources":["Button.tsx"],"sourcesContent":["import React from 'react';\nimport { Linking, Text } from 'react-native';\nimport ButtonBase from '../ButtonBase';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport type ButtonProps from './ButtonProps';\nimport type { ButtonSize } from './ButtonProps';\n\ntype IconSizes = { [n in ButtonSize]: number };\n\nconst iconSizes: IconSizes = {\n small: 20,\n medium: 24,\n};\n\nconst styles = StyleSheet.create({\n root: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n },\n fullWidth: {\n width: '100%',\n },\n medium: {\n minWidth: 104,\n height: 48,\n },\n small: {\n minWidth: 56,\n height: 32,\n },\n});\n\nexport default function Button(props: ButtonProps) {\n const {\n children,\n clipHorizontalSpacing = false,\n color = 'primary',\n disabled = false,\n endIcon: endIconProp,\n fullWidth = false,\n href,\n onPress,\n pressEffect,\n size = 'medium',\n startIcon: startIconProp,\n style: styleProp,\n variant = 'contained',\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const mainColor = theme.palette[color].main;\n\n const fontColor = variant === 'contained'\n ? theme.palette[color].contrastTextColor\n : theme.palette[color].main;\n\n const variantStyleMap = {\n contained: {\n backgroundColor: mainColor,\n },\n outlined: {\n backgroundColor: 'transparent',\n borderColor: mainColor,\n borderStyle: 'solid',\n borderWidth: 1,\n },\n text: {\n backgroundColor: 'transparent',\n },\n };\n\n const iconProps = {\n width: iconSizes[size],\n height: iconSizes[size],\n fill: fontColor,\n };\n\n const startIcon = cloneElementSafely(startIconProp, iconProps);\n const endIcon = cloneElementSafely(endIconProp, iconProps);\n\n const paddingSize = size === 'small' ? theme.spacing(3) : theme.spacing(4);\n const paddingLeft = startIcon ? paddingSize - theme.spacing(1) : paddingSize;\n const paddingRight = endIcon ? paddingSize - theme.spacing(1) : paddingSize;\n\n const borderRadius = theme.shape.roundnessLarge;\n const buttonBaseStyle = css([\n styles.root,\n variantStyleMap[variant],\n size === 'medium' ? styles.medium : styles.small,\n fullWidth ? styles.fullWidth : undefined,\n { borderRadius, color: fontColor },\n (variant === 'text' && clipHorizontalSpacing)\n ? { minWidth: 0 }\n : { paddingLeft, paddingRight },\n styleProp,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => size === 'small' ? typo.button2 : typo.button1,\n color: fontColor,\n });\n\n const textMarginSize = size === 'small' ? theme.spacing(1) : theme.spacing(2);\n const textMarginStyle = startIcon\n ? { marginLeft: textMarginSize }\n : endIcon\n ? { marginRight: textMarginSize }\n : undefined;\n\n const textStyle = css([\n fontStyle,\n textMarginStyle,\n { textAlign: 'center' },\n ]);\n\n const modifiedPressEffect = variant !== 'text' && !pressEffect\n ? 'scale'\n : pressEffect;\n\n const handlePress = async () => {\n if (disabled) {\n return;\n }\n if (onPress) {\n onPress();\n return;\n }\n if (href) {\n if (await Linking.canOpenURL(href)) {\n await Linking.openURL(href);\n }\n }\n };\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={buttonBaseStyle}\n pressEffect={modifiedPressEffect}\n {...otherProps}\n >\n {startIcon}\n\n <Text\n children={children}\n style={textStyle}\n />\n\n {endIcon}\n </ButtonBase>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMA,MAAMA,SAAoB,GAAG;EACzBC,KAAK,EAAE,EADkB;EAEzBC,MAAM,EAAE;AAFiB,CAA7B;;AAKA,MAAMC,MAAM,GAAGC,kBAAA,CAAWC,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,aAAa,EAAE,KADb;IAEFC,cAAc,EAAE,QAFd;IAGFC,UAAU,EAAE;EAHV,CADuB;EAM7BC,SAAS,EAAE;IACPC,KAAK,EAAE;EADA,CANkB;EAS7BT,MAAM,EAAE;IACJU,QAAQ,EAAE,GADN;IAEJC,MAAM,EAAE;EAFJ,CATqB;EAa7BZ,KAAK,EAAE;IACHW,QAAQ,EAAE,EADP;IAEHC,MAAM,EAAE;EAFL;AAbsB,CAAlB,CAAf;;AAmBe,SAASC,MAAT,CAAgBC,KAAhB,EAAoC;EAC/C,MAAM;IACFC,QADE;IAEFC,qBAAqB,GAAG,KAFtB;IAGFC,KAAK,GAAG,SAHN;IAIFC,QAAQ,GAAG,KAJT;IAKFC,OAAO,EAAEC,WALP;IAMFX,SAAS,GAAG,KANV;IAOFY,IAPE;IAQFC,OARE;IASFC,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E;EAAb,CAHkB,CAAJ,CAAlB;EAMA,MAAMC,mBAAmB,GAAG1C,OAAO,KAAK,MAAZ,IAAsB,CAACN,WAAvB,GACtB,OADsB,GAEtBA,WAFN;;EAIA,MAAMiD,WAAW,GAAG,YAAY;IAC5B,IAAItD,QAAJ,EAAc;MACV;IACH;;IACD,IAAII,OAAJ,EAAa;MACTA,OAAO;MACP;IACH;;IACD,IAAID,IAAJ,EAAU;MACN,IAAI,MAAMoD,oBAAA,CAAQC,UAAR,CAAmBrD,IAAnB,CAAV,EAAoC;QAChC,MAAMoD,oBAAA,CAAQE,OAAR,CAAgBtD,IAAhB,CAAN;MACH;IACJ;EACJ,CAbD;;EAeA,oBACI,6BAAC,mBAAD;IACI,QAAQ,EAAEH,QADd;IAEI,OAAO,EAAEsD,WAFb;IAGI,KAAK,EAAEhB,eAHX;IAII,WAAW,EAAEe;EAJjB,GAKQzC,UALR,GAOKL,SAPL,eASI,6BAAC,iBAAD;IACI,QAAQ,EAAEV,QADd;IAEI,KAAK,EAAEsD;EAFX,EATJ,EAcKlD,OAdL,CADJ;AAkBH;;AAAA"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = Dialog;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
@@ -17,13 +17,24 @@ var _Modal = _interopRequireDefault(require("../Modal"));
17
17
 
18
18
  var _Paper = _interopRequireDefault(require("../Paper"));
19
19
 
20
+ var _hooks = require("../hooks");
21
+
22
+ var _utils = require("../utils");
23
+
20
24
  var _styles2 = require("../styles");
21
25
 
22
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
27
 
28
+ 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
+
30
+ 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
+
24
32
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
25
33
 
26
34
  const DIALOG_MAX_WIDTH = 328;
35
+ const fadeInDuration = 300;
36
+ const fadeOutDuration = 100;
37
+ const fadeAnimationDelay = 50;
27
38
 
28
39
  const useStyles = function () {
29
40
  const theme = (0, _styles2.useTheme)();
@@ -77,12 +88,29 @@ function Dialog(props) {
77
88
  } = props;
78
89
  const styles = useStyles();
79
90
  const theme = (0, _styles2.useTheme)();
91
+ const animatedOpacity = (0, _hooks.useAnimatedValue)(fullScreen ? 1 : 0);
92
+ (0, _react.useEffect)(() => {
93
+ if (!fullScreen) {
94
+ _reactNative.Animated.timing(animatedOpacity, {
95
+ toValue: visible ? 1 : 0,
96
+ duration: visible ? fadeInDuration : fadeOutDuration,
97
+ delay: visible ? fadeAnimationDelay : 0,
98
+ useNativeDriver: _utils.isNotAndroid12
99
+ }).start();
100
+ }
101
+ }, [fullScreen, visible]);
80
102
  return /*#__PURE__*/_react.default.createElement(_Modal.default, _extends({
81
103
  animationStyle: fullScreen ? styles.animationFullScreen : styles.animation,
82
104
  onClose: onClose,
105
+ exitDuration: fullScreen ? 150 : 300,
83
106
  visible: visible,
84
107
  style: styles.root
85
- }, otherProps), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, topElement ? /*#__PURE__*/_react.default.createElement(_Column.default, {
108
+ }, otherProps), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
109
+ needsOffscreenAlphaCompositing: true,
110
+ style: {
111
+ opacity: animatedOpacity
112
+ }
113
+ }, topElement ? /*#__PURE__*/_react.default.createElement(_Column.default, {
86
114
  style: fullScreen ? undefined : styles.topElementSize
87
115
  }, /*#__PURE__*/_react.default.createElement(_Column.default, {
88
116
  style: styles.topElementPosition
@@ -1 +1 @@
1
- {"version":3,"names":["DIALOG_MAX_WIDTH","useStyles","theme","useTheme","width","useWindowDimensions","margin","spacing","dialogWidth","root","alignItems","justifyContent","zIndex","dialog","paper","maxWidth","overflow","paperFullScreen","flexGrow","animation","animationFullScreen","height","topElementSize","marginHorizontal","topElementPosition","position","bottom","Dialog","props","children","fullScreen","onClose","style","visible","topElement","otherProps","styles","undefined","css","borderRadius","shape","roundnessExtra"],"sources":["Dialog.tsx"],"sourcesContent":["import React from 'react';\nimport { useWindowDimensions } from 'react-native';\nimport { css, NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport Column from '../Column';\nimport Modal from '../Modal';\nimport Paper from '../Paper';\nimport { useTheme } from '../styles';\nimport type DialogProps from './DialogProps';\n\ntype DialogStyleKeys =\n | 'root'\n | 'paper'\n | 'paperFullScreen'\n | 'animation'\n | 'animationFullScreen'\n | 'topElementSize'\n | 'topElementPosition';\n\ntype DialogStyles = NamedStylesStringUnion<DialogStyleKeys>;\n\nconst DIALOG_MAX_WIDTH = 328;\n\nconst useStyles: UseStyles<DialogStyles> = function (): DialogStyles {\n const theme = useTheme();\n\n const { width } = useWindowDimensions();\n\n const margin = theme.spacing(4);\n const dialogWidth = width - margin * 2;\n\n return {\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n zIndex: theme.zIndex.dialog,\n },\n paper: {\n margin,\n maxWidth: DIALOG_MAX_WIDTH,\n overflow: 'hidden',\n width: dialogWidth,\n },\n paperFullScreen: {\n flexGrow: 1,\n },\n animation: {},\n animationFullScreen: {\n width: '100%',\n height: '100%',\n },\n topElementSize: {\n marginHorizontal: margin,\n maxWidth: DIALOG_MAX_WIDTH,\n width: dialogWidth,\n },\n topElementPosition: {\n position: 'absolute',\n bottom: -1 * theme.spacing(4),\n width: '100%',\n },\n };\n};\n\nexport default function Dialog(props: DialogProps) {\n const {\n children,\n fullScreen = false,\n onClose,\n style = {},\n visible,\n topElement,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n const theme = useTheme();\n\n return (\n <Modal\n animationStyle={fullScreen ? styles.animationFullScreen : styles.animation}\n onClose={onClose}\n visible={visible}\n style={styles.root}\n {...otherProps}\n >\n <React.Fragment>\n {topElement ? (\n <Column style={fullScreen ? undefined : styles.topElementSize}>\n <Column style={styles.topElementPosition}>\n {topElement}\n </Column>\n </Column>\n ) : null}\n\n <Paper\n elevation={24}\n square={fullScreen}\n style={css([\n { borderRadius: fullScreen ? undefined : theme.shape.roundnessExtra },\n fullScreen ? styles.paperFullScreen : styles.paper,\n style,\n ])}\n >\n {children}\n </Paper>\n </React.Fragment>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAcA,MAAMA,gBAAgB,GAAG,GAAzB;;AAEA,MAAMC,SAAkC,GAAG,YAA0B;EACjE,MAAMC,KAAK,GAAG,IAAAC,iBAAA,GAAd;EAEA,MAAM;IAAEC;EAAF,IAAY,IAAAC,gCAAA,GAAlB;EAEA,MAAMC,MAAM,GAAGJ,KAAK,CAACK,OAAN,CAAc,CAAd,CAAf;EACA,MAAMC,WAAW,GAAGJ,KAAK,GAAGE,MAAM,GAAG,CAArC;EAEA,OAAO;IAC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BAAC,eAAD;IAAQ,KAAK,EAAEJ,UAAU,GAAGO,SAAH,GAAeD,MAAM,CAACd;EAA/C,gBACI,6BAAC,eAAD;IAAQ,KAAK,EAAEc,MAAM,CAACZ;EAAtB,GACKU,UADL,CADJ,CADO,GAMP,IAPR,eASI,6BAAC,cAAD;IACI,SAAS,EAAE,EADf;IAEI,MAAM,EAAEJ,UAFZ;IAGI,KAAK,EAAE,IAAAQ,WAAA,EAAI,CACP;MAAEC,YAAY,EAAET,UAAU,GAAGO,SAAH,GAAenC,KAAK,CAACsC,KAAN,CAAYC;IAArD,CADO,EAEPX,UAAU,GAAGM,MAAM,CAACnB,eAAV,GAA4BmB,MAAM,CAACtB,KAFtC,EAGPkB,KAHO,CAAJ;EAHX,GASKH,QATL,CATJ,CAPJ,CADJ;AA+BH;;AAAA"}
1
+ {"version":3,"names":["DIALOG_MAX_WIDTH","fadeInDuration","fadeOutDuration","fadeAnimationDelay","useStyles","theme","useTheme","width","useWindowDimensions","margin","spacing","dialogWidth","root","alignItems","justifyContent","zIndex","dialog","paper","maxWidth","overflow","paperFullScreen","flexGrow","animation","animationFullScreen","height","topElementSize","marginHorizontal","topElementPosition","position","bottom","Dialog","props","children","fullScreen","onClose","style","visible","topElement","otherProps","styles","animatedOpacity","useAnimatedValue","useEffect","Animated","timing","toValue","duration","delay","useNativeDriver","isNotAndroid12","start","opacity","undefined","css","borderRadius","shape","roundnessExtra"],"sources":["Dialog.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useWindowDimensions, Animated } from 'react-native';\nimport { css, NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport Column from '../Column';\nimport Modal from '../Modal';\nimport Paper from '../Paper';\nimport { useAnimatedValue } from '../hooks';\nimport { isNotAndroid12 } from '../utils';\nimport { useTheme } from '../styles';\nimport type DialogProps from './DialogProps';\n\ntype DialogStyleKeys =\n | 'root'\n | 'paper'\n | 'paperFullScreen'\n | 'animation'\n | 'animationFullScreen'\n | 'topElementSize'\n | 'topElementPosition';\n\ntype DialogStyles = NamedStylesStringUnion<DialogStyleKeys>;\n\nconst DIALOG_MAX_WIDTH = 328;\n\nconst fadeInDuration = 300;\nconst fadeOutDuration = 100;\nconst fadeAnimationDelay = 50;\n\nconst useStyles: UseStyles<DialogStyles> = function (): DialogStyles {\n const theme = useTheme();\n\n const { width } = useWindowDimensions();\n\n const margin = theme.spacing(4);\n const dialogWidth = width - margin * 2;\n\n return {\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n zIndex: theme.zIndex.dialog,\n },\n paper: {\n margin,\n maxWidth: DIALOG_MAX_WIDTH,\n overflow: 'hidden',\n width: dialogWidth,\n },\n paperFullScreen: {\n flexGrow: 1,\n },\n animation: {},\n animationFullScreen: {\n width: '100%',\n height: '100%',\n },\n topElementSize: {\n marginHorizontal: margin,\n maxWidth: DIALOG_MAX_WIDTH,\n width: dialogWidth,\n },\n topElementPosition: {\n position: 'absolute',\n bottom: -1 * theme.spacing(4),\n width: '100%',\n },\n };\n};\n\nexport default function Dialog(props: DialogProps) {\n const {\n children,\n fullScreen = false,\n onClose,\n style = {},\n visible,\n topElement,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n const theme = useTheme();\n const animatedOpacity = useAnimatedValue(fullScreen ? 1 : 0);\n\n useEffect(() => {\n if(!fullScreen){\n Animated.timing(animatedOpacity, {\n toValue: visible ? 1 : 0,\n duration: visible ? fadeInDuration: fadeOutDuration,\n delay: visible ? fadeAnimationDelay : 0,\n useNativeDriver: isNotAndroid12,\n }).start();\n }\n }, [fullScreen, visible]);\n\n return (\n <Modal\n animationStyle={fullScreen ? styles.animationFullScreen : styles.animation}\n onClose={onClose}\n exitDuration={fullScreen ? 150 : 300}\n visible={visible}\n style={styles.root}\n {...otherProps}\n >\n <Animated.View\n needsOffscreenAlphaCompositing={true}\n style={{ opacity: animatedOpacity }}\n >\n {topElement ? (\n <Column style={fullScreen ? undefined : styles.topElementSize}>\n <Column style={styles.topElementPosition}>\n {topElement}\n </Column>\n </Column>\n ) : null}\n\n <Paper\n elevation={24}\n square={fullScreen}\n style={css([\n { borderRadius: fullScreen ? undefined : theme.shape.roundnessExtra },\n fullScreen ? styles.paperFullScreen : styles.paper,\n style,\n ])}\n >\n {children}\n </Paper>\n </Animated.View>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAcA,MAAMA,gBAAgB,GAAG,GAAzB;AAEA,MAAMC,cAAc,GAAG,GAAvB;AACA,MAAMC,eAAe,GAAG,GAAxB;AACA,MAAMC,kBAAkB,GAAG,EAA3B;;AAEA,MAAMC,SAAkC,GAAG,YAA0B;EACjE,MAAMC,KAAK,GAAG,IAAAC,iBAAA,GAAd;EAEA,MAAM;IAAEC;EAAF,IAAY,IAAAC,gCAAA,GAAlB;EAEA,MAAMC,MAAM,GAAGJ,KAAK,CAACK,OAAN,CAAc,CAAd,CAAf;EACA,MAAMC,WAAW,GAAGJ,KAAK,GAAGE,MAAM,GAAG,CAArC;EAEA,OAAO;IACHG,IAAI,EAAE;MACFC,UAAU,EAAE,QADV;MAEFC,cAAc,EAAE,QAFd;MAGFC,MAAM,EAAEV,KAAK,CAACU,MAAN,CAAaC;IAHnB,CADH;IAMHC,KAAK,EAAE;MACHR,MADG;MAEHS,QAAQ,EAAElB,gBAFP;MAGHmB,QAAQ,EAAE,QAHP;MAIHZ,KAAK,EAAEI;IAJJ,CANJ;IAYHS,eAAe,EAAE;MACbC,QAAQ,EAAE;IADG,CAZd;IAeHC,SAAS,EAAE,EAfR;IAgBHC,mBAAmB,EAAE;MACjBhB,KAAK,EAAE,MADU;MAEjBiB,MAAM,EAAE;IAFS,CAhBlB;IAoBHC,cAAc,EAAE;MACZC,gBAAgB,EAAEjB,MADN;MAEZS,QAAQ,EAAElB,gBAFE;MAGZO,KAAK,EAAEI;IAHK,CApBb;IAyBHgB,kBAAkB,EAAE;MAChBC,QAAQ,EAAE,UADM;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AX;EAFX,GAIKH,UAAU,gBACP,6BAAC,eAAD;IAAQ,KAAK,EAAEJ,UAAU,GAAGmB,SAAH,GAAeb,MAAM,CAACd;EAA/C,gBACI,6BAAC,eAAD;IAAQ,KAAK,EAAEc,MAAM,CAACZ;EAAtB,GACKU,UADL,CADJ,CADO,GAMP,IAVR,eAYI,6BAAC,cAAD;IACI,SAAS,EAAE,EADf;IAEI,MAAM,EAAEJ,UAFZ;IAGI,KAAK,EAAE,IAAAoB,WAAA,EAAI,CACP;MAAEC,YAAY,EAAErB,UAAU,GAAGmB,SAAH,GAAe/C,KAAK,CAACkD,KAAN,CAAYC;IAArD,CADO,EAEPvB,UAAU,GAAGM,MAAM,CAACnB,eAAV,GAA4BmB,MAAM,CAACtB,KAFtC,EAGPkB,KAHO,CAAJ;EAHX,GASKH,QATL,CAZJ,CARJ,CADJ;AAmCH;;AAAA"}
@@ -22,6 +22,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
22
 
23
23
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
24
24
 
25
+ const defaultEnterDuration = 300;
26
+ const defaultExitDuration = 150;
27
+
25
28
  const createModalCloseEvent = reason => ({
26
29
  metadata: {
27
30
  reason
@@ -36,6 +39,8 @@ function Modal(props) {
36
39
  backdropOpacity = 0.5,
37
40
  children,
38
41
  disableAnimation = false,
42
+ enterDuration = defaultEnterDuration,
43
+ exitDuration = defaultExitDuration,
39
44
  hideBackdrop = false,
40
45
  onClose,
41
46
  style,
@@ -66,7 +71,8 @@ function Modal(props) {
66
71
  opacity: backdropOpacity
67
72
  }), !disableAnimation ? /*#__PURE__*/_react.default.createElement(_Slide.default, {
68
73
  appear: visible,
69
- exitDuration: 150,
74
+ enterDuration: enterDuration,
75
+ exitDuration: exitDuration,
70
76
  onEnter: () => setExited(false),
71
77
  onExited: () => setExited(true),
72
78
  style: animationStyle
@@ -1 +1 @@
1
- {"version":3,"names":["createModalCloseEvent","reason","metadata","Modal","props","animationStyle","backdropOpacity","children","disableAnimation","hideBackdrop","onClose","style","visible","otherProps","handleBackdropPress","exited","setExited","React","useState","elevationStyle","useElevationStyle","css","StyleSheet","absoluteFill"],"sources":["Modal.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { css, StyleSheet } from '../styles';\nimport { useElevationStyle } from '../hooks';\nimport Slide from '../Slide';\nimport SimpleBackdrop from './SimpleBackdrop';\nimport type ModalProps from './ModalProps';\n\nexport type ModalCloseReasonType = 'OUTSIDE_PRESS' | 'HARDWARE_BACK_PRESS' | 'CLOSE_BUTTON_PRESS' | 'UNKNOWN';\n\nexport interface ModalCloseEvent {\n metadata: {\n reason: ModalCloseReasonType\n };\n}\n\nexport const createModalCloseEvent = (reason: ModalCloseReasonType) => ({\n metadata: {\n reason,\n },\n});\n\nexport default function Modal(props: ModalProps) {\n const {\n animationStyle,\n backdropOpacity = 0.5,\n children,\n disableAnimation = false,\n hideBackdrop = false,\n onClose,\n style,\n visible,\n ...otherProps\n } = props;\n\n const handleBackdropPress = () => {\n if (onClose) {\n onClose(createModalCloseEvent('OUTSIDE_PRESS'));\n }\n };\n\n const [exited, setExited] = React.useState(true);\n\n const elevationStyle = useElevationStyle(6);\n\n if (!visible) {\n if (disableAnimation || exited) {\n return null;\n }\n }\n\n return (\n <View\n style={css([\n StyleSheet.absoluteFill,\n elevationStyle,\n style,\n ])}\n {...otherProps}\n >\n {(hideBackdrop || !visible) ? null : (\n <SimpleBackdrop\n onPress={handleBackdropPress}\n opacity={backdropOpacity}\n />\n )}\n\n {!disableAnimation ? (\n <Slide\n appear={visible}\n exitDuration={150}\n onEnter={() => setExited(false)}\n onExited={() => setExited(true)}\n style={animationStyle}\n >\n {children}\n </Slide>\n ) : children}\n </View>\n );\n};\n"],"mappings":";;;;;;;;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QAPL,CADH,GAUGA,QAzBR,CADJ;AA6BH;;AAAA"}
1
+ {"version":3,"names":["defaultEnterDuration","defaultExitDuration","createModalCloseEvent","reason","metadata","Modal","props","animationStyle","backdropOpacity","children","disableAnimation","enterDuration","exitDuration","hideBackdrop","onClose","style","visible","otherProps","handleBackdropPress","exited","setExited","React","useState","elevationStyle","useElevationStyle","css","StyleSheet","absoluteFill"],"sources":["Modal.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { css, StyleSheet } from '../styles';\nimport { useElevationStyle } from '../hooks';\nimport Slide from '../Slide';\nimport SimpleBackdrop from './SimpleBackdrop';\nimport type ModalProps from './ModalProps';\n\nexport type ModalCloseReasonType = 'OUTSIDE_PRESS' | 'HARDWARE_BACK_PRESS' | 'CLOSE_BUTTON_PRESS' | 'UNKNOWN';\n\nexport interface ModalCloseEvent {\n metadata: {\n reason: ModalCloseReasonType\n };\n}\n\nconst defaultEnterDuration = 300;\nconst defaultExitDuration = 150;\n\nexport const createModalCloseEvent = (reason: ModalCloseReasonType) => ({\n metadata: {\n reason,\n },\n});\n\nexport default function Modal(props: ModalProps) {\n const {\n animationStyle,\n backdropOpacity = 0.5,\n children,\n disableAnimation = false,\n enterDuration = defaultEnterDuration,\n exitDuration = defaultExitDuration,\n hideBackdrop = false,\n onClose,\n style,\n visible,\n ...otherProps\n } = props;\n\n const handleBackdropPress = () => {\n if (onClose) {\n onClose(createModalCloseEvent('OUTSIDE_PRESS'));\n }\n };\n\n const [exited, setExited] = React.useState(true);\n\n const elevationStyle = useElevationStyle(6);\n\n if (!visible) {\n if (disableAnimation || exited) {\n return null;\n }\n }\n\n return (\n <View\n style={css([\n StyleSheet.absoluteFill,\n elevationStyle,\n style,\n ])}\n {...otherProps}\n >\n {(hideBackdrop || !visible) ? null : (\n <SimpleBackdrop\n onPress={handleBackdropPress}\n opacity={backdropOpacity}\n />\n )}\n\n {!disableAnimation ? (\n <Slide\n appear={visible}\n enterDuration={enterDuration}\n exitDuration={exitDuration}\n onEnter={() => setExited(false)}\n onExited={() => setExited(true)}\n style={animationStyle}\n >\n {children}\n </Slide>\n ) : children}\n </View>\n );\n};\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAWA,MAAMA,oBAAoB,GAAG,GAA7B;AACA,MAAMC,mBAAmB,GAAG,GAA5B;;AAEO,MAAMC,qBAAqB,GAAIC,MAAD,KAAmC;EACpEC,QAAQ,EAAE;IACND;EADM;AAD0D,CAAnC,CAA9B;;;;AAMQ,SAASE,KAAT,CAAeC,KAAf,EAAkC;EAC7C,MAAM;IACFC,cADE;IAEFC,eAAe,GAAG,GAFhB;IAGFC,QAHE;IAIFC,gBAAgB,GAAG,KAJjB;IAKFC,aAAa,GAAGX,oBALd;IAMFY,YAAY,GAAGX,mBANb;IAOFY,YAAY,GAAG,KAPb;IAQFC,OARE;IASFC,KATE;IAUFC,OAVE;IAWF,GAAGC;EAXD,IAYFX,KAZJ;;EAcA,MAAMY,mBAAmB,GAAG,MAAM;IAC9B,IAAIJ,OAAJ,EAAa;MACTA,OAAO,CAACZ,qBAAqB,CAAC,eAAD,CAAtB,CAAP;IACH;EACJ,CAJD;;EAMA,MAAM,CAACiB,MAAD,EAASC,SAAT,IAAsBC,cAAA,CAAMC,QAAN,CAAe,IAAf,CAA5B;;EAEA,MAAMC,cAAc,GAAG,IAAAC,wBAAA,EAAkB,CAAlB,CAAvB;;EAEA,IAAI,CAACR,OAAL,EAAc;IACV,IAAIN,gBAAgB,IAAIS,MAAxB,EAAgC;MAC5B,OAAO,IAAP;IACH;EACJ;;EAED,oBACI,6BAAC,iBAAD;IACI,KAAK,EAAE,IAAAM,WAAA,EAAI,CACPC,kBAAA,CAAWC,YADJ,EAEPJ,cAFO,EAGPR,KAHO,CAAJ;EADX,GAMQE,UANR,GAQMJ,YAAY,IAAI,CAACG,OAAlB,GAA6B,IAA7B,gBACG,6BAAC,uBAAD;IACI,OAAO,EAAEE,mBADb;IAEI,OAAO,EAAEV;EAFb,EATR,EAeK,CAACE,gBAAD,gBACG,6BAAC,cAAD;IACI,MAAM,EAAEM,OADZ;IAEI,aAAa,EAAEL,aAFnB;IAGI,YAAY,EAAEC,YAHlB;IAII,OAAO,EAAE,MAAMQ,SAAS,CAAC,KAAD,CAJ5B;IAKI,QAAQ,EAAE,MAAMA,SAAS,CAAC,IAAD,CAL7B;IAMI,KAAK,EAAEb;EANX,GAQKE,QARL,CADH,GAWGA,QA1BR,CADJ;AA8BH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ModalProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { ComponentProps, OverridableComponentProps } from '../types';\nimport { ModalCloseEvent } from './Modal';\n\nexport default interface ModalProps extends OverridableComponentProps<ViewProps, {\n /**\n * Style object provided to animation component.\n */\n animationStyle?: ComponentProps['style'];\n\n /**\n * Opacity for backdrop.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * A single child content element.\n */\n children: React.ReactElement;\n\n /**\n * If `true`, the animation is disabled.\n * @default false\n */\n disableAnimation?: boolean;\n\n /**\n * If `true`, the backdrop is not rendered.\n * @default false\n */\n hideBackdrop?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n */\n onClose?: (event?: ModalCloseEvent) => void,\n\n /**\n * If `true`, the modal is visible.\n */\n visible: boolean;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["ModalProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { ComponentProps, OverridableComponentProps } from '../types';\nimport { ModalCloseEvent } from './Modal';\n\nexport default interface ModalProps extends OverridableComponentProps<ViewProps, {\n /**\n * Style object provided to animation component.\n */\n animationStyle?: ComponentProps['style'];\n\n /**\n * Opacity for backdrop.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * A single child content element.\n */\n children: React.ReactElement;\n\n /**\n * If `true`, the animation is disabled.\n * @default false\n */\n disableAnimation?: boolean;\n\n /**\n * The number of milliseconds to enter animation.\n * @default 300\n */\n enterDuration?: number;\n\n /**\n * The number of milliseconds to exit animation.\n * @default 150\n */\n exitDuration?: number;\n\n /**\n * If `true`, the backdrop is not rendered.\n * @default false\n */\n hideBackdrop?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n */\n onClose?: (event?: ModalCloseEvent) => void,\n\n /**\n * If `true`, the modal is visible.\n */\n visible: boolean;\n}> {}\n"],"mappings":""}
@@ -5,26 +5,36 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = Snackbar;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
12
  var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
13
13
 
14
- var _styles = require("@fountain-ui/styles");
15
-
16
14
  var _Slide = _interopRequireDefault(require("../Slide"));
17
15
 
18
16
  var _SnackbarContent = _interopRequireDefault(require("../SnackbarContent"));
19
17
 
20
- var _styles2 = require("../styles");
18
+ var _hooks = require("../hooks");
19
+
20
+ var _styles = require("../styles");
21
+
22
+ var _utils = require("../utils");
21
23
 
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
26
+ 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); }
27
+
28
+ 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; }
29
+
24
30
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
25
31
 
32
+ const fadeInDuration = 300;
33
+ const fadeOutDuration = 110;
34
+ const fadeAnimationDelay = 100;
35
+
26
36
  const useStyles = function () {
27
- const theme = (0, _styles2.useTheme)();
37
+ const theme = (0, _styles.useTheme)();
28
38
  const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
29
39
  return {
30
40
  root: {
@@ -48,6 +58,8 @@ function Snackbar(props) {
48
58
  autoHideDuration = null,
49
59
  children,
50
60
  message,
61
+ title,
62
+ startIcon,
51
63
  onActionPress,
52
64
  onClose,
53
65
  style,
@@ -85,18 +97,33 @@ function Snackbar(props) {
85
97
 
86
98
  const [exited, setExited] = _react.default.useState(true);
87
99
 
100
+ const animatedOpacity = (0, _hooks.useAnimatedValue)(0);
101
+ const animatedStyle = {
102
+ opacity: animatedOpacity
103
+ };
104
+ (0, _react.useEffect)(() => {
105
+ _reactNative.Animated.timing(animatedOpacity, {
106
+ toValue: visible ? 1 : 0,
107
+ duration: visible ? fadeInDuration : fadeOutDuration,
108
+ delay: visible ? fadeAnimationDelay : 0,
109
+ useNativeDriver: _utils.isNotAndroid12
110
+ }).start();
111
+ }, [visible]);
112
+
88
113
  if (!visible && exited) {
89
114
  return null;
90
115
  }
91
116
 
92
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
93
- style: (0, _styles.css)([styles.root, style])
117
+ return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, _extends({
118
+ style: [animatedStyle, styles.root, style]
94
119
  }, otherProps), /*#__PURE__*/_react.default.createElement(_Slide.default, {
95
120
  animatedY: animatedY,
96
121
  appear: visible,
97
122
  onEnter: () => setExited(false),
98
123
  onExited: () => setExited(true)
99
124
  }, children ? children : /*#__PURE__*/_react.default.createElement(_SnackbarContent.default, {
125
+ title: title,
126
+ startIcon: startIcon,
100
127
  actionLabel: actionLabel,
101
128
  message: message,
102
129
  onActionPress: onActionPress
@@ -1 +1 @@
1
- {"version":3,"names":["useStyles","theme","useTheme","insets","useSafeAreaInsets","root","alignSelf","bottom","spacing","maxWidth","paddingBottom","paddingHorizontal","position","width","zIndex","Snackbar","props","actionLabel","animatedY","autoHideDuration","children","message","onActionPress","onClose","style","visible","otherProps","autoHideTimer","React","useRef","clearAutoHideTimeout","current","clearTimeout","useEffect","setTimeout","styles","exited","setExited","useState","css"],"sources":["Snackbar.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { css, NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport Slide from '../Slide';\nimport SnackbarContent from '../SnackbarContent';\nimport { useTheme } from '../styles';\nimport type SnackbarProps from './SnackbarProps';\n\ntype SnackBarStyles = NamedStylesStringUnion<'root'>;\n\nconst useStyles: UseStyles<SnackBarStyles> = function (): SnackBarStyles {\n const theme = useTheme();\n const insets = useSafeAreaInsets();\n\n return {\n root: {\n alignSelf: 'center',\n bottom: theme.spacing(2),\n maxWidth: 480,\n paddingBottom: insets.bottom,\n paddingHorizontal: theme.spacing(2),\n position: 'absolute',\n width: '100%',\n // TODO: Need to remove zIndex.\n zIndex: 32,\n },\n };\n};\n\nexport default function Snackbar(props: SnackbarProps) {\n const {\n actionLabel,\n animatedY,\n autoHideDuration = null,\n children,\n message,\n onActionPress,\n onClose,\n style,\n visible = false,\n ...otherProps\n } = props;\n\n const autoHideTimer = React.useRef<number | null>(null);\n\n const clearAutoHideTimeout = () => {\n if (autoHideTimer.current !== null) {\n clearTimeout(autoHideTimer.current);\n }\n };\n\n React.useEffect(() => {\n return () => {\n clearAutoHideTimeout();\n };\n }, []);\n\n React.useEffect(() => {\n if (visible && autoHideDuration !== null) {\n clearAutoHideTimeout();\n\n // @ts-ignore\n autoHideTimer.current = setTimeout(() => {\n if (onClose) {\n onClose();\n }\n }, autoHideDuration);\n }\n }, [visible, autoHideDuration, onClose]);\n\n const styles = useStyles();\n\n const [exited, setExited] = React.useState(true);\n\n if (!visible && exited) {\n return null;\n }\n\n return (\n <View\n style={css([\n styles.root,\n style,\n ])}\n {...otherProps}\n >\n <Slide\n animatedY={animatedY}\n appear={visible}\n onEnter={() => setExited(false)}\n onExited={() => setExited(true)}\n >\n {children ? children : (\n <SnackbarContent\n actionLabel={actionLabel}\n message={message}\n onActionPress={onActionPress}\n />\n )}\n </Slide>\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAKA,MAAMA,SAAoC,GAAG,YAA4B;EACrE,MAAMC,KAAK,GAAG,IAAAC,iBAAA,GAAd;EACA,MAAMC,MAAM,GAAG,IAAAC,6CAAA,GAAf;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,SAAS,EAAE,QADT;MAEFC,MAAM,EAAEN,KAAK,CAACO,OAAN,CAAc,CAAd,CAFN;MAGFC,QAAQ,EAAE,GAHR;MAIFC,aAAa,EAAEP,MAAM,CAACI,MAJpB;MAKFI,iBAAiB,EAAEV,KAAK,CAACO,OAAN,CAAc,CAAd,CALjB;MAMFI,QAAQ,EAAE,UANR;MAOFC,KAAK,EAAE,MAPL;MAQF;MACAC,MAAM,EAAE;IATN;EADH,CAAP;AAaH,CAjBD;;AAmBe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;EACnD,MAAM;IACFC,WADE;IAEFC,SAFE;IAGFC,gBAAgB,GAAG,IAHjB;IAIFC,QAJE;IAKFC,OAL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AAC,IAAD;EAJ7B,GAMKjB,QAAQ,GAAGA,QAAH,gBACL,6BAAC,wBAAD;IACI,WAAW,EAAEH,WADjB;IAEI,OAAO,EAAEI,OAFb;IAGI,aAAa,EAAEC;EAHnB,EAPR,CAPJ,CADJ;AAwBH;;AAAA"}
1
+ {"version":3,"names":["fadeInDuration","fadeOutDuration","fadeAnimationDelay","useStyles","theme","useTheme","insets","useSafeAreaInsets","root","alignSelf","bottom","spacing","maxWidth","paddingBottom","paddingHorizontal","position","width","zIndex","Snackbar","props","actionLabel","animatedY","autoHideDuration","children","message","title","startIcon","onActionPress","onClose","style","visible","otherProps","autoHideTimer","React","useRef","clearAutoHideTimeout","current","clearTimeout","useEffect","setTimeout","styles","exited","setExited","useState","animatedOpacity","useAnimatedValue","animatedStyle","opacity","Animated","timing","toValue","duration","delay","useNativeDriver","isNotAndroid12","start"],"sources":["Snackbar.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { Animated } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport Slide from '../Slide';\nimport SnackbarContent from '../SnackbarContent';\nimport { useAnimatedValue } from '../hooks';\nimport { useTheme } from '../styles';\nimport { isNotAndroid12 } from '../utils';\nimport type SnackbarProps from './SnackbarProps';\n\ntype SnackBarStyles = NamedStylesStringUnion<'root'>;\n\nconst fadeInDuration = 300;\nconst fadeOutDuration = 110;\nconst fadeAnimationDelay = 100;\n\nconst useStyles: UseStyles<SnackBarStyles> = function (): SnackBarStyles {\n const theme = useTheme();\n const insets = useSafeAreaInsets();\n\n return {\n root: {\n alignSelf: 'center',\n bottom: theme.spacing(2),\n maxWidth: 480,\n paddingBottom: insets.bottom,\n paddingHorizontal: theme.spacing(2),\n position: 'absolute',\n width: '100%',\n // TODO: Need to remove zIndex.\n zIndex: 32,\n },\n };\n};\n\nexport default function Snackbar(props: SnackbarProps) {\n const {\n actionLabel,\n animatedY,\n autoHideDuration = null,\n children,\n message,\n title,\n startIcon,\n onActionPress,\n onClose,\n style,\n visible = false,\n ...otherProps\n } = props;\n\n const autoHideTimer = React.useRef<number | null>(null);\n\n const clearAutoHideTimeout = () => {\n if (autoHideTimer.current !== null) {\n clearTimeout(autoHideTimer.current);\n }\n };\n\n React.useEffect(() => {\n return () => {\n clearAutoHideTimeout();\n };\n }, []);\n\n React.useEffect(() => {\n if (visible && autoHideDuration !== null) {\n clearAutoHideTimeout();\n\n // @ts-ignore\n autoHideTimer.current = setTimeout(() => {\n if (onClose) {\n onClose();\n }\n }, autoHideDuration);\n }\n }, [visible, autoHideDuration, onClose]);\n\n const styles = useStyles();\n\n const [exited, setExited] = React.useState(true);\n\n const animatedOpacity = useAnimatedValue(0);\n\n const animatedStyle = {\n opacity: animatedOpacity,\n };\n\n useEffect(() => {\n Animated.timing(animatedOpacity, {\n toValue: visible ? 1 : 0,\n duration: visible ? fadeInDuration : fadeOutDuration,\n delay: visible ? fadeAnimationDelay : 0,\n useNativeDriver: isNotAndroid12,\n }).start();\n }, [visible]);\n\n if (!visible && exited) {\n return null;\n }\n\n return (\n <Animated.View\n style={[\n animatedStyle,\n styles.root,\n style,\n ]}\n {...otherProps}\n >\n <Slide\n animatedY={animatedY}\n appear={visible}\n onEnter={() => setExited(false)}\n onExited={() => setExited(true)}\n >\n {children ? children : (\n <SnackbarContent\n title={title}\n startIcon={startIcon}\n actionLabel={actionLabel}\n message={message}\n onActionPress={onActionPress}\n />\n )}\n </Slide>\n </Animated.View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAKA,MAAMA,cAAc,GAAG,GAAvB;AACA,MAAMC,eAAe,GAAG,GAAxB;AACA,MAAMC,kBAAkB,GAAG,GAA3B;;AAEA,MAAMC,SAAoC,GAAG,YAA4B;EACrE,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EACA,MAAMC,MAAM,GAAG,IAAA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ackbarProps.ts"],"sourcesContent":["import React from 'react';\n\nimport type { Animated, ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\n\nexport default interface SnackbarProps extends OverridableComponentProps<ViewProps, {\n /**\n * The text to use for the action component.\n */\n actionLabel?: string,\n\n /**\n * y value for animating.\n */\n animatedY?: Animated.Value;\n\n /**\n * The number of milliseconds to wait before automatically calling the\n * `onDismiss` function. `onDismiss` should then set the state of the `visible`\n * prop to hide the `Snackbar`. This behavior is disabled by default with\n * the `null` value.\n * @default null\n */\n autoHideDuration?: number | null,\n\n /**\n * Replace the `SnackbarContent` component.\n */\n children?: React.ReactNode;\n\n /**\n * The message to display.\n */\n message?: string,\n\n /**\n * Callback fired when the action component pressed.\n */\n onActionPress?: () => void\n\n /**\n * Callback fired when the component requests to be closed.\n */\n onClose?: () => void,\n\n /**\n * If `true`, `Snackbar` is shown.\n * @default false\n */\n visible?: boolean,\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["SnackbarProps.ts"],"sourcesContent":["import React from 'react';\n\nimport type { Animated, ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\n\nexport default interface SnackbarProps extends OverridableComponentProps<ViewProps, {\n /**\n * The text to use for the action component.\n */\n actionLabel?: string;\n\n /**\n * y value for animating.\n */\n animatedY?: Animated.Value;\n\n /**\n * The number of milliseconds to wait before automatically calling the\n * `onDismiss` function. `onDismiss` should then set the state of the `visible`\n * prop to hide the `Snackbar`. This behavior is disabled by default with\n * the `null` value.\n * @default null\n */\n autoHideDuration?: number | null;\n\n /**\n * Replace the `SnackbarContent` component.\n */\n children?: React.ReactNode;\n\n /**\n * The message to display.\n */\n message?: string;\n\n /**\n * Callback fired when the action component pressed.\n */\n onActionPress?: () => void;\n\n /**\n * Callback fired when the component requests to be closed.\n */\n onClose?: () => void;\n\n /**\n * Element placed before the title and message.\n */\n startIcon?: React.ReactElement;\n\n /**\n * The title to display.\n */\n title?: string;\n\n /**\n * If `true`, `Snackbar` is shown.\n * @default false\n */\n visible?: boolean;\n}> {}\n"],"mappings":""}
@@ -9,37 +9,42 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
+ var _styles = require("@fountain-ui/styles");
13
+
12
14
  var _utils = require("@fountain-ui/utils");
13
15
 
14
- var _styles = require("../styles");
16
+ var _styles2 = require("../styles");
15
17
 
16
18
  var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
17
19
 
20
+ var _Column = _interopRequireDefault(require("../Column"));
21
+
18
22
  var _Paper = _interopRequireDefault(require("../Paper"));
19
23
 
20
24
  var _Spacer = _interopRequireDefault(require("../Spacer"));
21
25
 
26
+ var _Typography = _interopRequireDefault(require("../Typography"));
27
+
22
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
29
 
24
30
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
25
31
 
26
32
  const useStyles = function () {
27
- const theme = (0, _styles.useTheme)();
33
+ const theme = (0, _styles2.useTheme)();
28
34
  const backgroundColor = theme.palette.primary.main;
29
35
 
30
36
  const [r, g, b] = _react.default.useMemo(() => (0, _utils.rgb)(backgroundColor), [backgroundColor]);
31
37
 
32
38
  return {
33
39
  root: {
40
+ flexDirection: 'row',
41
+ alignItems: 'center',
34
42
  backgroundColor: `rgba(${r}, ${g}, ${b}, .9)`,
35
43
  borderRadius: theme.shape.roundness,
36
44
  paddingHorizontal: theme.spacing(4),
37
45
  paddingVertical: theme.spacing(3)
38
46
  },
39
47
  action: {
40
- alignItems: 'center',
41
- flexDirection: 'row',
42
- justifyContent: 'space-between',
43
48
  paddingVertical: theme.spacing(2)
44
49
  }
45
50
  };
@@ -49,30 +54,43 @@ function SnackbarContent(props) {
49
54
  const {
50
55
  actionLabel,
51
56
  message,
57
+ title,
52
58
  onActionPress,
53
59
  style,
60
+ startIcon,
54
61
  ...otherProps
55
62
  } = props;
56
63
  const styles = useStyles();
57
- const theme = (0, _styles.useTheme)();
58
- const messageFontStyle = (0, _styles.createFontStyle)(theme, {
64
+ const theme = (0, _styles2.useTheme)();
65
+ const titleFontStyle = (0, _styles2.createFontStyle)(theme, {
66
+ selector: typo => typo.subtitle2,
67
+ color: theme.mode === 'light' ? _styles.lightTheme.palette.primary.contrastTextColor : _styles.lightTheme.palette.primary.main
68
+ });
69
+ const messageFontStyle = (0, _styles2.createFontStyle)(theme, {
59
70
  selector: typo => typo.body2,
60
- color: theme.palette.primary.contrastTextColor
71
+ color: title ? theme.mode === 'light' ? _styles.darkTheme.palette.text.secondary : _styles.lightTheme.palette.text.secondary : theme.palette.primary.contrastTextColor
61
72
  });
62
- const labelFontStyle = (0, _styles.createFontStyle)(theme, {
73
+ const labelFontStyle = (0, _styles2.createFontStyle)(theme, {
63
74
  selector: typo => typo.button2,
64
75
  color: theme.palette.primary.contrastTextColor
65
76
  });
66
- const labelStyle = (0, _styles.css)([labelFontStyle, {
77
+ const labelStyle = (0, _styles2.css)([labelFontStyle, {
67
78
  padding: theme.spacing(2)
68
79
  }]);
69
80
  return /*#__PURE__*/_react.default.createElement(_Paper.default, _extends({
70
81
  elevation: 0,
71
- style: (0, _styles.css)([styles.root, actionLabel ? styles.action : undefined, style])
72
- }, otherProps), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
82
+ style: (0, _styles2.css)([styles.root, actionLabel ? styles.action : undefined, style])
83
+ }, otherProps), startIcon ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, startIcon, /*#__PURE__*/_react.default.createElement(_Spacer.default, {
84
+ size: 3
85
+ })) : null, /*#__PURE__*/_react.default.createElement(_Column.default, null, title ? /*#__PURE__*/_react.default.createElement(_Typography.default, {
86
+ children: title,
87
+ style: (0, _styles2.css)([titleFontStyle])
88
+ }) : null, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
73
89
  children: message,
74
- style: (0, _styles.css)([messageFontStyle])
75
- }), actionLabel ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Spacer.default, {
90
+ style: (0, _styles2.css)([messageFontStyle])
91
+ })), actionLabel ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Spacer.default, {
92
+ flex: 1
93
+ }), /*#__PURE__*/_react.default.createElement(_Spacer.default, {
76
94
  size: 1
77
95
  }), /*#__PURE__*/_react.default.createElement(_ButtonBase.default, {
78
96
  onPress: onActionPress,
@@ -1 +1 @@
1
- {"version":3,"names":["useStyles","theme","useTheme","backgroundColor","palette","primary","main","r","g","b","React","useMemo","rgb","root","borderRadius","shape","roundness","paddingHorizontal","spacing","paddingVertical","action","alignItems","flexDirection","justifyContent","SnackbarContent","props","actionLabel","message","onActionPress","style","otherProps","styles","messageFontStyle","createFontStyle","selector","typo","body2","color","contrastTextColor","labelFontStyle","button2","labelStyle","css","padding","undefined"],"sources":["SnackbarContent.tsx"],"sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { rgb } from '@fountain-ui/utils';\nimport { createFontStyle, css, useTheme } from '../styles';\nimport ButtonBase from '../ButtonBase';\nimport Paper from '../Paper';\nimport Spacer from '../Spacer';\nimport type SnackbarContentProps from './SnackbarContentProps';\n\ntype SnackBarContentStyles = NamedStylesStringUnion<'root' | 'action'>;\n\nconst useStyles: UseStyles<SnackBarContentStyles> = function (): SnackBarContentStyles {\n const theme = useTheme();\n\n const backgroundColor = theme.palette.primary.main;\n const [r, g, b] = React.useMemo(() => rgb(backgroundColor), [backgroundColor]);\n\n return {\n root: {\n backgroundColor: `rgba(${r}, ${g}, ${b}, .9)`,\n borderRadius: theme.shape.roundness,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n action: {\n alignItems: 'center',\n flexDirection: 'row',\n justifyContent: 'space-between',\n paddingVertical: theme.spacing(2),\n },\n };\n};\n\nexport default function SnackbarContent(props: SnackbarContentProps) {\n const {\n actionLabel,\n message,\n onActionPress,\n style,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const theme = useTheme();\n\n const messageFontStyle = createFontStyle(theme, {\n selector: (typo) => typo.body2,\n color: theme.palette.primary.contrastTextColor,\n });\n\n const labelFontStyle = createFontStyle(theme, {\n selector: (typo) => typo.button2,\n color: theme.palette.primary.contrastTextColor,\n });\n\n const labelStyle = css([\n labelFontStyle,\n { padding: theme.spacing(2) },\n ]);\n\n return (\n <Paper\n elevation={0}\n style={css([\n styles.root,\n actionLabel ? styles.action : undefined,\n style,\n ])}\n {...otherProps}\n >\n <Text\n children={message}\n style={css([\n messageFontStyle,\n ])}\n />\n\n {actionLabel ? (\n <React.Fragment>\n <Spacer size={1}/>\n\n <ButtonBase\n onPress={onActionPress}\n pressEffect={'none'}\n >\n <Text\n children={actionLabel}\n style={labelStyle}\n />\n </ButtonBase>\n </React.Fragment>\n ) : null}\n </Paper>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAKA,MAAMA,SAA2C,GAAG,YAAmC;EACnF,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,MAAMC,eAAe,GAAGF,KAAK,CAACG,OAAN,CAAcC,OAAd,CAAsBC,IAA9C;;EACA,MAAM,CAACC,CAAD,EAAIC,CAAJ,EAAOC,CAAP,IAAYC,cAAA,CAAMC,OAAN,CAAc,MAAM,IAAAC,UAAA,EAAIT,eAAJ,CAApB,EAA0C,CAACA,eAAD,CAA1C,CAAlB;;EAEA,OAAO;IACHU,IAAI,EAAE;MACFV,eAAe,EAAG,QAAOI,CAAE,KAAIC,CAAE,KAAIC,CAAE,OADrC;MAEFK,YAAY,EAAEb,KAAK,CAACc,KAAN,CAAYC,SAFxB;MAGFC,iBA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vB,EAGPf,KAHO,CAAJ;EAFX,GAOQC,UAPR,gBASI,6BAAC,iBAAD;IACI,QAAQ,EAAEH,OADd;IAEI,KAAK,EAAE,IAAAe,WAAA,EAAI,CACPV,gBADO,CAAJ;EAFX,EATJ,EAgBKN,WAAW,gBACR,6BAAC,cAAD,CAAO,QAAP,qBACI,6BAAC,eAAD;IAAQ,IAAI,EAAE;EAAd,EADJ,eAGI,6BAAC,mBAAD;IACI,OAAO,EAAEE,aADb;IAEI,WAAW,EAAE;EAFjB,gBAII,6BAAC,iBAAD;IACI,QAAQ,EAAEF,WADd;IAEI,KAAK,EAAEe;EAFX,EAJJ,CAHJ,CADQ,GAcR,IA9BR,CADJ;AAkCH;;AAAA"}
1
+ {"version":3,"names":["useStyles","theme","useTheme","backgroundColor","palette","primary","main","r","g","b","React","useMemo","rgb","root","flexDirection","alignItems","borderRadius","shape","roundness","paddingHorizontal","spacing","paddingVertical","action","SnackbarContent","props","actionLabel","message","title","onActionPress","style","startIcon","otherProps","styles","titleFontStyle","createFontStyle","selector","typo","subtitle2","color","mode","lightTheme","contrastTextColor","messageFontStyle","body2","darkTheme","text","secondary","labelFontStyle","button2","labelStyle","css","padding","undefined"],"sources":["SnackbarContent.tsx"],"sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport { lightTheme, darkTheme } from '@fountain-ui/styles';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { rgb } from '@fountain-ui/utils';\nimport { createFontStyle, css, useTheme } from '../styles';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Paper from '../Paper';\nimport Spacer from '../Spacer';\nimport Typography from '../Typography';\nimport type SnackbarContentProps from './SnackbarContentProps';\n\ntype SnackBarContentStyles = NamedStylesStringUnion<'root' | 'action'>;\n\nconst useStyles: UseStyles<SnackBarContentStyles> = function (): SnackBarContentStyles {\n const theme = useTheme();\n\n const backgroundColor = theme.palette.primary.main;\n const [r, g, b] = React.useMemo(() => rgb(backgroundColor), [backgroundColor]);\n\n return {\n root: {\n flexDirection: 'row',\n alignItems: 'center',\n backgroundColor: `rgba(${r}, ${g}, ${b}, .9)`,\n borderRadius: theme.shape.roundness,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n action: {\n paddingVertical: theme.spacing(2),\n },\n };\n};\n\nexport default function SnackbarContent(props: SnackbarContentProps) {\n const {\n actionLabel,\n message,\n title,\n onActionPress,\n style,\n startIcon,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const theme = useTheme();\n\n const titleFontStyle = createFontStyle(theme, {\n selector: (typo) => typo.subtitle2,\n color: theme.mode === 'light'\n ? lightTheme.palette.primary.contrastTextColor\n : lightTheme.palette.primary.main,\n });\n\n const messageFontStyle = createFontStyle(theme, {\n selector: (typo) => typo.body2,\n color: title\n ? theme.mode === 'light'\n ? darkTheme.palette.text.secondary\n : lightTheme.palette.text.secondary\n : theme.palette.primary.contrastTextColor,\n });\n\n const labelFontStyle = createFontStyle(theme, {\n selector: (typo) => typo.button2,\n color: theme.palette.primary.contrastTextColor,\n });\n\n const labelStyle = css([\n labelFontStyle,\n { padding: theme.spacing(2) },\n ]);\n\n return (\n <Paper\n elevation={0}\n style={css([\n styles.root,\n actionLabel ? styles.action : undefined,\n style,\n ])}\n {...otherProps}\n >\n {startIcon ? (\n <React.Fragment>\n {startIcon}\n\n <Spacer size={3}/>\n </React.Fragment>\n ) : null}\n\n <Column>\n {title ? (\n <Typography\n children={title}\n style={css([titleFontStyle])}\n />\n ) : null}\n\n <Text\n children={message}\n style={css([messageFontStyle])}\n />\n </Column>\n\n {actionLabel ? (\n <React.Fragment>\n <Spacer flex={1}/>\n\n <Spacer size={1}/>\n\n <ButtonBase\n onPress={onActionPress}\n pressEffect={'none'}\n >\n <Text\n children={actionLabel}\n style={labelStyle}\n />\n </ButtonBase>\n </React.Fragment>\n ) : null}\n </Paper>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA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,KAAK,EAAE,IAAAuB,YAAA,EAAI,CAACjB,cAAD,CAAJ;EAFX,EADE,GAKF,IANR,eAQI,6BAAC,iBAAD;IACI,QAAQ,EAAEP,OADd;IAEI,KAAK,EAAE,IAAAwB,YAAA,EAAI,CAACR,gBAAD,CAAJ;EAFX,EARJ,CAjBJ,EA+BKjB,WAAW,gBACR,6BAAC,cAAD,CAAO,QAAP,qBACI,6BAAC,eAAD;IAAQ,IAAI,EAAE;EAAd,EADJ,eAGI,6BAAC,eAAD;IAAQ,IAAI,EAAE;EAAd,EAHJ,eAKI,6BAAC,mBAAD;IACI,OAAO,EAAEG,aADb;IAEI,WAAW,EAAE;EAFjB,gBAII,6BAAC,iBAAD;IACI,QAAQ,EAAEH,WADd;IAEI,KAAK,EAAEwB;EAFX,EAJJ,CALJ,CADQ,GAgBR,IA/CR,CADJ;AAmDH;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["SnackbarContentProps.ts"],"sourcesContent":["import type { OverridableComponentProps } from '../types';\nimport type { PaperProps } from '../Paper';\n\nexport default interface SnackbarContentProps extends OverridableComponentProps<PaperProps, {\n /**\n * The text to use for the action component.\n */\n actionLabel?: string,\n\n /**\n * The message to display.\n */\n message?: string,\n\n /**\n * Callback fired when the action component pressed.\n */\n onActionPress?: () => void\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["SnackbarContentProps.ts"],"sourcesContent":["import React from 'react';\nimport type { OverridableComponentProps } from '../types';\nimport type { PaperProps } from '../Paper';\n\nexport default interface SnackbarContentProps extends OverridableComponentProps<PaperProps, {\n /**\n * The text to use for the action component.\n */\n actionLabel?: string;\n\n /**\n * The message to display.\n */\n message?: string;\n\n /**\n * Callback fired when the action component pressed.\n */\n onActionPress?: () => void;\n\n /**\n * Element placed before the title and message.\n */\n startIcon?: React.ReactElement;\n\n /**\n * The title to display.\n */\n title?: string;\n}> {}\n"],"mappings":""}
@@ -29,16 +29,14 @@ const styles = _styles.StyleSheet.create({
29
29
  root: { // TODO: Remove redundant platform checking
30
30
  ...(_reactNative.Platform.OS === 'web' ? {
31
31
  minWidth: 'auto'
32
- } : {})
33
- },
34
- primary: {
35
- minHeight: 40
36
- },
37
- secondary: {
32
+ } : {}),
38
33
  minHeight: 40
39
34
  },
40
35
  bottomNavigation: {
41
36
  minHeight: 56
37
+ },
38
+ filledInner: {
39
+ justifyContent: 'center'
42
40
  }
43
41
  });
44
42
 
@@ -49,16 +47,19 @@ function Tab(props) {
49
47
  enableIndicator = false,
50
48
  icon: defaultIcon,
51
49
  indicatorColor = 'primary',
50
+ indicatorSize = 'full',
52
51
  selected = false,
53
52
  selectedIcon,
54
53
  variant = 'primary',
55
54
  style,
55
+ onTabInnerLayout,
56
56
  ...otherProps
57
57
  } = props;
58
58
  const theme = (0, _styles.useTheme)();
59
59
  const vertical = variant === 'bottom-navigation';
60
60
  const color = selected ? theme.palette.text.primary : theme.palette.text.hint;
61
- const tabBaseStyle = (0, _styles.css)([styles.root, variant === 'primary' ? styles.primary : variant === 'secondary' ? styles.secondary : styles.bottomNavigation, style]);
61
+ const tabBaseStyle = (0, _styles.css)([styles.root, variant === 'bottom-navigation' && styles.bottomNavigation, style]);
62
+ const tabInnerStyle = (0, _styles.css)([styles.root, styles.filledInner]);
62
63
  const fontStyle = (0, _styles.createFontStyle)(theme, {
63
64
  selector: typo => variant === 'primary' ? typo.h2 : variant === 'secondary' ? typo.button2 : typo.flag,
64
65
  color
@@ -68,19 +69,27 @@ function Tab(props) {
68
69
  const iconElement = icon ? /*#__PURE__*/(0, _react.cloneElement)(icon, {
69
70
  fill: color
70
71
  }) : null;
71
- return /*#__PURE__*/_react.default.createElement(_TabBase.default, _extends({
72
- pressEffect: pressEffect,
73
- style: tabBaseStyle,
74
- vertical: vertical
75
- }, otherProps), /*#__PURE__*/_react.default.createElement(_Badge.default, {
72
+ const tabElement = typeof children !== 'string' ? /*#__PURE__*/_react.default.cloneElement(children, {
73
+ selected
74
+ }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Badge.default, {
76
75
  children: iconElement,
77
76
  invisible: !badgeVisible
78
77
  }), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
79
78
  children: children,
80
79
  style: (0, _styles.css)(fontStyle)
81
- }), enableIndicator && selected ? /*#__PURE__*/_react.default.createElement(_TabIndicator.default, {
80
+ }));
81
+ const tabIndicator = enableIndicator && selected ? /*#__PURE__*/_react.default.createElement(_TabIndicator.default, {
82
+ indicatorSize: indicatorSize,
82
83
  color: indicatorColor
83
- }) : null);
84
+ }) : null;
85
+ return /*#__PURE__*/_react.default.createElement(_TabBase.default, _extends({
86
+ pressEffect: pressEffect,
87
+ style: tabBaseStyle,
88
+ vertical: vertical
89
+ }, otherProps), indicatorSize === 'fit-content' ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
90
+ onLayout: onTabInnerLayout,
91
+ style: tabInnerStyle
92
+ }, tabElement, tabIndicator) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tabElement, tabIndicator));
84
93
  }
85
94
 
86
95
  ;