@fountain-ui/core 2.0.0-beta.82 → 2.0.0-beta.83

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 (38) hide show
  1. package/build/commonjs/Accordion/Accordion.js +9 -15
  2. package/build/commonjs/Accordion/Accordion.js.map +1 -1
  3. package/build/commonjs/Dialog/Dialog.js +59 -31
  4. package/build/commonjs/Dialog/Dialog.js.map +1 -1
  5. package/build/commonjs/Dialog/DialogProps.js.map +1 -1
  6. package/build/commonjs/Modal/AnimatedContainer/index.js +153 -0
  7. package/build/commonjs/Modal/AnimatedContainer/index.js.map +1 -0
  8. package/build/commonjs/Modal/Modal.js +41 -15
  9. package/build/commonjs/Modal/Modal.js.map +1 -1
  10. package/build/commonjs/Modal/ModalProps.js +12 -0
  11. package/build/commonjs/Modal/ModalProps.js.map +1 -1
  12. package/build/commonjs/Modal/index.js +8 -0
  13. package/build/commonjs/Modal/index.js.map +1 -1
  14. package/build/module/Accordion/Accordion.js +9 -15
  15. package/build/module/Accordion/Accordion.js.map +1 -1
  16. package/build/module/Dialog/Dialog.js +61 -31
  17. package/build/module/Dialog/Dialog.js.map +1 -1
  18. package/build/module/Dialog/DialogProps.js.map +1 -1
  19. package/build/module/Modal/AnimatedContainer/index.js +131 -0
  20. package/build/module/Modal/AnimatedContainer/index.js.map +1 -0
  21. package/build/module/Modal/Modal.js +41 -14
  22. package/build/module/Modal/Modal.js.map +1 -1
  23. package/build/module/Modal/ModalProps.js +5 -0
  24. package/build/module/Modal/ModalProps.js.map +1 -1
  25. package/build/module/Modal/index.js +1 -0
  26. package/build/module/Modal/index.js.map +1 -1
  27. package/build/typescript/Dialog/DialogProps.d.ts +6 -0
  28. package/build/typescript/Modal/AnimatedContainer/index.d.ts +5 -0
  29. package/build/typescript/Modal/ModalProps.d.ts +41 -8
  30. package/build/typescript/Modal/index.d.ts +2 -1
  31. package/package.json +2 -2
  32. package/src/Accordion/Accordion.tsx +6 -11
  33. package/src/Dialog/Dialog.tsx +70 -32
  34. package/src/Dialog/DialogProps.ts +7 -0
  35. package/src/Modal/AnimatedContainer/index.tsx +156 -0
  36. package/src/Modal/Modal.tsx +42 -18
  37. package/src/Modal/ModalProps.ts +51 -10
  38. package/src/Modal/index.ts +2 -1
@@ -1,2 +1,14 @@
1
1
  "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ANIMATION_TYPE = void 0;
7
+ let ANIMATION_TYPE;
8
+ exports.ANIMATION_TYPE = ANIMATION_TYPE;
9
+
10
+ (function (ANIMATION_TYPE) {
11
+ ANIMATION_TYPE["SLIDE"] = "slide";
12
+ ANIMATION_TYPE["FADE"] = "fade";
13
+ })(ANIMATION_TYPE || (exports.ANIMATION_TYPE = ANIMATION_TYPE = {}));
2
14
  //# sourceMappingURL=ModalProps.js.map
@@ -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 * 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":""}
1
+ {"version":3,"names":["ANIMATION_TYPE"],"sources":["ModalProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport type { ComponentProps, OverridableComponentProps } from '../types';\nimport { ModalCloseEvent } from './Modal';\n\nexport const enum ANIMATION_TYPE {\n SLIDE = 'slide',\n FADE = 'fade',\n}\n\nexport type AnimationUnit = Omit<Animated.TimingAnimationConfig, 'useNativeDriver'> & {\n /**\n * Type of animation used when the dialog opens and closes.\n */\n type: ANIMATION_TYPE;\n}\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 * Animation used when the modal closes.\n */\n closeAnimation?: AnimationUnit[] | undefined;\n\n /**\n * If `true`, the backdrop is not rendered.\n * @default false\n */\n hideBackdrop?: boolean;\n\n /**\n * Set the initial value of opacity for animating.\n */\n initialOpacity?: number | undefined;\n\n /**\n * Set the initial value of transition y for animating.\n */\n initialTranslateY?: number | undefined;\n\n /**\n * Callback fired when the component requests to be closed.\n */\n onClose?: (event?: ModalCloseEvent) => void;\n\n /**\n * Callback fired when the enter animation will start.\n */\n onEnter?: () => void | undefined;\n\n /**\n * Callback fired when the enter animation is completed.\n */\n onEntered?: () => void | undefined;\n\n /**\n * Callback fired when the exit animation will start.\n */\n onExit?: () => void | undefined;\n\n /**\n * Callback fired when the exit animation is completed.\n */\n onExited?: () => void | undefined;\n\n /**\n * Animation used when the modal opens.\n */\n openAnimation?: AnimationUnit[] | undefined;\n\n /**\n * If `true`, the modal is visible.\n */\n visible: boolean;\n}> {}\n"],"mappings":";;;;;;IAMkBA,c;;;WAAAA,c;EAAAA,c;EAAAA,c;GAAAA,c,8BAAAA,c"}
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "ANIMATION_TYPE", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ModalProps.ANIMATION_TYPE;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "createModalCloseEvent", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -18,6 +24,8 @@ Object.defineProperty(exports, "default", {
18
24
 
19
25
  var _Modal = _interopRequireWildcard(require("./Modal"));
20
26
 
27
+ var _ModalProps = require("./ModalProps");
28
+
21
29
  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); }
22
30
 
23
31
  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; }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default, createModalCloseEvent } from './Modal';\nexport type { ModalCloseEvent } from './Modal';\nexport type { default as ModalProps } from './ModalProps';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default, createModalCloseEvent } from './Modal';\nexport type { ModalCloseEvent } from './Modal';\nexport type { default as ModalProps, AnimationUnit } from './ModalProps';\nexport { ANIMATION_TYPE } from './ModalProps';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAGA"}
@@ -8,15 +8,12 @@ import Column from '../Column';
8
8
  import Row from '../Row';
9
9
  import Spacer from '../Spacer';
10
10
  import Typography from '../Typography';
11
- const CONTENT_Y_START = 10;
12
- const CONTENT_Y_END = 0;
13
11
  const ROTATE_HIDE_DEGREE = 0;
14
12
  const ROTATE_SHOW_DEGREE = 180;
15
13
  const ANIMATION_CONFIG = {
16
- duration: 300
14
+ duration: 200
17
15
  };
18
- const INITIAL_EXPANDED_DELAY_MILLIS = 400;
19
- const CONTENT_TRANSLATEY_DELAY_MILLIS = 300;
16
+ const INITIAL_EXPANDED_DELAY_MILLIS = 100;
20
17
  const CONTENT_OPACITY_DELAY_MILLIS = 200;
21
18
 
22
19
  const useStyles = function () {
@@ -30,7 +27,8 @@ const useStyles = function () {
30
27
  backgroundColor: theme.palette.paper.grey,
31
28
  paddingHorizontal: theme.spacing(4),
32
29
  paddingVertical: theme.spacing(3.5),
33
- alignItems: 'center'
30
+ alignItems: 'center',
31
+ height: 64
34
32
  },
35
33
  titleColumn: {
36
34
  flexShrink: 1
@@ -68,7 +66,6 @@ export default function Accordion(props) {
68
66
  const shouldInitialExpandedRef = useRef(isInitialExpanded);
69
67
  const rotate = useSharedValue(ROTATE_HIDE_DEGREE);
70
68
  const animatedOpacity = useSharedValue(0);
71
- const animatedContentY = useSharedValue(CONTENT_Y_START);
72
69
  const animatedHeight = useSharedValue(0);
73
70
  const [contentHeight, setContentHeight] = useState(0);
74
71
  const animatedChevronDownStyles = useAnimatedStyle(() => ({
@@ -81,9 +78,6 @@ export default function Accordion(props) {
81
78
  overflow: 'hidden'
82
79
  }), []);
83
80
  const animatedContentStyle = useAnimatedStyle(() => ({
84
- transform: [{
85
- translateY: animatedContentY.value
86
- }],
87
81
  opacity: animatedOpacity.value
88
82
  }), []);
89
83
 
@@ -105,9 +99,6 @@ export default function Accordion(props) {
105
99
  rotate.value = withTiming(isExpanded ? ROTATE_SHOW_DEGREE : ROTATE_HIDE_DEGREE, ANIMATION_CONFIG);
106
100
  animatedHeight.value = withTiming(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);
107
101
  animatedOpacity.value = isExpanded ? withDelay(CONTENT_OPACITY_DELAY_MILLIS, withTiming(1, ANIMATION_CONFIG)) : withTiming(0, ANIMATION_CONFIG);
108
- animatedContentY.value = isExpanded ? withDelay(CONTENT_TRANSLATEY_DELAY_MILLIS, withTiming(CONTENT_Y_END, ANIMATION_CONFIG)) : withDelay(ANIMATION_CONFIG.duration, withTiming(CONTENT_Y_START, {
109
- duration: 0
110
- }));
111
102
  }, [isExpanded, contentHeight]);
112
103
  return /*#__PURE__*/React.createElement(Column, {
113
104
  style: styles.root
@@ -121,13 +112,16 @@ export default function Accordion(props) {
121
112
  variant: 'subtitle2',
122
113
  children: title,
123
114
  color: 'textPrimary',
124
- numberOfLines: 1
115
+ numberOfLines: 1,
116
+ disableFontScaling: true
125
117
  }), subTitle ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Spacer, {
126
118
  size: 0.5
127
119
  }), /*#__PURE__*/React.createElement(Typography, {
128
120
  style: styles.subtitle,
129
121
  color: 'tertiary',
130
- children: subTitle
122
+ children: subTitle,
123
+ numberOfLines: 1,
124
+ disableFontScaling: true
131
125
  })) : null), /*#__PURE__*/React.createElement(Spacer, {
132
126
  flex: 1
133
127
  }), /*#__PURE__*/React.createElement(Spacer, {
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useRef","useState","View","Animated","useAnimatedStyle","useSharedValue","withDelay","withTiming","useTheme","ChevronDown","ButtonBase","Column","Row","Spacer","Typography","CONTENT_Y_START","CONTENT_Y_END","ROTATE_HIDE_DEGREE","ROTATE_SHOW_DEGREE","ANIMATION_CONFIG","duration","INITIAL_EXPANDED_DELAY_MILLIS","CONTENT_TRANSLATEY_DELAY_MILLIS","CONTENT_OPACITY_DELAY_MILLIS","useStyles","theme","root","marginBottom","spacing","title","borderRadius","backgroundColor","palette","paper","grey","paddingHorizontal","paddingVertical","alignItems","titleColumn","flexShrink","subtitle","fontSize","lineHeight","fontFamily","contentView","position","width","marginTop","Accordion","props","subTitle","content","RightIcon","LeftComponent","isInitialExpanded","styles","CONTENT_MARGIN_HEIGHT","isExpanded","setIsExpanded","shouldInitialExpandedRef","rotate","animatedOpacity","animatedContentY","animatedHeight","contentHeight","setContentHeight","animatedChevronDownStyles","transform","value","animatedContentBackgroundStyles","height","overflow","animatedContentStyle","translateY","opacity","onPress","prev","onLayout","event","nativeEvent","layout","current","setTimeout"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { LayoutChangeEvent, View } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n WithTimingConfig,\n} from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport { ChevronDown } from '../internal/icons';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Row from '../Row';\nimport Spacer from '../Spacer';\nimport Typography from '../Typography';\n\nimport AccordionProps from './AccordionProps';\n\ntype AccordionStyles = NamedStylesStringUnion<\n 'root'\n | 'title'\n | 'titleColumn'\n | 'subtitle'\n | 'contentView'\n>;\n\nconst CONTENT_Y_START = 10;\nconst CONTENT_Y_END = 0;\n\nconst ROTATE_HIDE_DEGREE = 0;\nconst ROTATE_SHOW_DEGREE = 180;\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 300 };\nconst INITIAL_EXPANDED_DELAY_MILLIS = 400;\nconst CONTENT_TRANSLATEY_DELAY_MILLIS = 300;\nconst CONTENT_OPACITY_DELAY_MILLIS = 200;\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: { marginBottom: theme.spacing(3) },\n title: {\n borderRadius: theme.spacing(4),\n backgroundColor: theme.palette.paper.grey,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3.5),\n alignItems: 'center',\n },\n titleColumn: { flexShrink: 1 },\n subtitle: {\n fontSize: 11,\n lineHeight: 12,\n fontFamily: 'Inter-Regular',\n },\n contentView: {\n position: 'absolute',\n width: '100%',\n borderRadius: theme.spacing(4),\n backgroundColor: theme.palette.paper.grey,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(6),\n marginTop: theme.spacing(1),\n },\n };\n};\n\nexport default function Accordion(props: AccordionProps) {\n const {\n title,\n subTitle,\n content,\n RightIcon,\n LeftComponent,\n isInitialExpanded = false,\n } = props;\n\n const styles = useStyles();\n const theme = useTheme();\n const CONTENT_MARGIN_HEIGHT = theme.spacing(2);\n\n const [isExpanded, setIsExpanded] = useState(false);\n const shouldInitialExpandedRef = useRef<boolean>(isInitialExpanded);\n\n const rotate = useSharedValue(ROTATE_HIDE_DEGREE);\n const animatedOpacity = useSharedValue(0);\n const animatedContentY = useSharedValue(CONTENT_Y_START);\n\n const animatedHeight = useSharedValue(0);\n const [contentHeight, setContentHeight] = useState(0);\n\n const animatedChevronDownStyles = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }), []);\n\n const animatedContentBackgroundStyles = useAnimatedStyle(() => ({\n height: animatedHeight.value,\n overflow: 'hidden',\n }), []);\n\n const animatedContentStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: animatedContentY.value }],\n opacity: animatedOpacity.value,\n }), []);\n\n const onPress = () => {\n setIsExpanded(prev => !prev);\n };\n\n const onLayout = (event: LayoutChangeEvent) => {\n const height = event.nativeEvent.layout.height + CONTENT_MARGIN_HEIGHT;\n setContentHeight(height);\n\n if (shouldInitialExpandedRef.current) {\n shouldInitialExpandedRef.current = false;\n setTimeout(() => setIsExpanded(true), INITIAL_EXPANDED_DELAY_MILLIS);\n }\n };\n\n useEffect(() => {\n rotate.value = withTiming(isExpanded ? ROTATE_SHOW_DEGREE : ROTATE_HIDE_DEGREE, ANIMATION_CONFIG);\n\n animatedHeight.value = withTiming(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);\n\n animatedOpacity.value = isExpanded\n ? withDelay(CONTENT_OPACITY_DELAY_MILLIS, withTiming(1, ANIMATION_CONFIG))\n : withTiming(0, ANIMATION_CONFIG);\n animatedContentY.value = isExpanded\n ? withDelay(CONTENT_TRANSLATEY_DELAY_MILLIS, withTiming(CONTENT_Y_END, ANIMATION_CONFIG))\n : withDelay(ANIMATION_CONFIG.duration as number, withTiming(CONTENT_Y_START, { duration: 0 }));\n }, [isExpanded, contentHeight]);\n\n return (\n <Column style={styles.root}>\n <ButtonBase onPress={onPress}>\n <Row style={styles.title}>\n {LeftComponent ? LeftComponent : null}\n\n <Column style={styles.titleColumn}>\n <Typography\n variant={'subtitle2'}\n children={title}\n color={'textPrimary'}\n numberOfLines={1}\n />\n\n {subTitle ? (\n <React.Fragment>\n <Spacer size={0.5}/>\n\n <Typography\n style={styles.subtitle}\n color={'tertiary'}\n children={subTitle}\n />\n </React.Fragment>\n ) : null}\n </Column>\n\n <Spacer flex={1}/>\n\n <Spacer size={3}/>\n\n <Animated.View style={animatedChevronDownStyles}>\n {RightIcon ? RightIcon : (\n <ChevronDown\n width={20}\n height={20}\n color={'tertiary'}\n />\n )}\n </Animated.View>\n </Row>\n </ButtonBase>\n\n <Animated.View style={animatedContentBackgroundStyles}>\n <View\n onLayout={onLayout}\n style={styles.contentView}\n >\n <Animated.View style={animatedContentStyle}>\n {typeof content === 'string' ? (\n <Typography\n variant={'subtitle2'}\n color={'tertiary'}\n children={content}\n />\n ) : (content)}\n </Animated.View>\n </View>\n </Animated.View>\n </Column>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AACA,SAA4BC,IAA5B,QAAwC,cAAxC;AAC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,EAAE,EADX;IAEI,MAAM,EAAE,EAFZ;IAGI,KAAK,EAAE;EAHX,EAFR,CA5BJ,CADJ,CADJ,eA0CI,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAEiB;EAAtB,gBACI,oBAAC,IAAD;IACI,QAAQ,EAAEQ,QADd;IAEI,KAAK,EAAEtB,MAAM,CAACX;EAFlB,gBAII,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAE4B;EAAtB,GACK,OAAOrB,OAAP,KAAmB,QAAnB,gBACG,oBAAC,UAAD;IACI,OAAO,EAAE,WADb;IAEI,KAAK,EAAE,UAFX;IAGI,QAAQ,EAAEA;EAHd,EADH,GAMIA,OAPT,CAJJ,CADJ,CA1CJ,CADJ;AA6DH"}
1
+ {"version":3,"names":["React","useEffect","useRef","useState","View","Animated","useAnimatedStyle","useSharedValue","withDelay","withTiming","useTheme","ChevronDown","ButtonBase","Column","Row","Spacer","Typography","ROTATE_HIDE_DEGREE","ROTATE_SHOW_DEGREE","ANIMATION_CONFIG","duration","INITIAL_EXPANDED_DELAY_MILLIS","CONTENT_OPACITY_DELAY_MILLIS","useStyles","theme","root","marginBottom","spacing","title","borderRadius","backgroundColor","palette","paper","grey","paddingHorizontal","paddingVertical","alignItems","height","titleColumn","flexShrink","subtitle","fontSize","lineHeight","fontFamily","contentView","position","width","marginTop","Accordion","props","subTitle","content","RightIcon","LeftComponent","isInitialExpanded","styles","CONTENT_MARGIN_HEIGHT","isExpanded","setIsExpanded","shouldInitialExpandedRef","rotate","animatedOpacity","animatedHeight","contentHeight","setContentHeight","animatedChevronDownStyles","transform","value","animatedContentBackgroundStyles","overflow","animatedContentStyle","opacity","onPress","prev","onLayout","event","nativeEvent","layout","current","setTimeout"],"sources":["Accordion.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { LayoutChangeEvent, View } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n useSharedValue,\n withDelay,\n withTiming,\n WithTimingConfig,\n} from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport { ChevronDown } from '../internal/icons';\nimport ButtonBase from '../ButtonBase';\nimport Column from '../Column';\nimport Row from '../Row';\nimport Spacer from '../Spacer';\nimport Typography from '../Typography';\n\nimport AccordionProps from './AccordionProps';\n\ntype AccordionStyles = NamedStylesStringUnion<\n 'root'\n | 'title'\n | 'titleColumn'\n | 'subtitle'\n | 'contentView'\n>;\n\nconst ROTATE_HIDE_DEGREE = 0;\nconst ROTATE_SHOW_DEGREE = 180;\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 200 };\nconst INITIAL_EXPANDED_DELAY_MILLIS = 100;\nconst CONTENT_OPACITY_DELAY_MILLIS = 200;\n\nconst useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {\n const theme = useTheme();\n\n return {\n root: { marginBottom: theme.spacing(3) },\n title: {\n borderRadius: theme.spacing(4),\n backgroundColor: theme.palette.paper.grey,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3.5),\n alignItems: 'center',\n height: 64,\n },\n titleColumn: { flexShrink: 1 },\n subtitle: {\n fontSize: 11,\n lineHeight: 12,\n fontFamily: 'Inter-Regular',\n },\n contentView: {\n position: 'absolute',\n width: '100%',\n borderRadius: theme.spacing(4),\n backgroundColor: theme.palette.paper.grey,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(6),\n marginTop: theme.spacing(1),\n },\n };\n};\n\nexport default function Accordion(props: AccordionProps) {\n const {\n title,\n subTitle,\n content,\n RightIcon,\n LeftComponent,\n isInitialExpanded = false,\n } = props;\n\n const styles = useStyles();\n const theme = useTheme();\n const CONTENT_MARGIN_HEIGHT = theme.spacing(2);\n\n const [isExpanded, setIsExpanded] = useState(false);\n const shouldInitialExpandedRef = useRef<boolean>(isInitialExpanded);\n\n const rotate = useSharedValue(ROTATE_HIDE_DEGREE);\n const animatedOpacity = useSharedValue(0);\n\n const animatedHeight = useSharedValue(0);\n const [contentHeight, setContentHeight] = useState(0);\n\n const animatedChevronDownStyles = useAnimatedStyle(() => ({\n transform: [{ rotate: `${rotate.value}deg` }],\n }), []);\n\n const animatedContentBackgroundStyles = useAnimatedStyle(() => ({\n height: animatedHeight.value,\n overflow: 'hidden',\n }), []);\n\n const animatedContentStyle = useAnimatedStyle(() => ({\n opacity: animatedOpacity.value,\n }), []);\n\n const onPress = () => {\n setIsExpanded(prev => !prev);\n };\n\n const onLayout = (event: LayoutChangeEvent) => {\n const height = event.nativeEvent.layout.height + CONTENT_MARGIN_HEIGHT;\n setContentHeight(height);\n\n if (shouldInitialExpandedRef.current) {\n shouldInitialExpandedRef.current = false;\n setTimeout(() => setIsExpanded(true), INITIAL_EXPANDED_DELAY_MILLIS);\n }\n };\n\n useEffect(() => {\n rotate.value = withTiming(isExpanded ? ROTATE_SHOW_DEGREE : ROTATE_HIDE_DEGREE, ANIMATION_CONFIG);\n\n animatedHeight.value = withTiming(isExpanded ? contentHeight : 0, ANIMATION_CONFIG);\n\n animatedOpacity.value = isExpanded\n ? withDelay(CONTENT_OPACITY_DELAY_MILLIS, withTiming(1, ANIMATION_CONFIG))\n : withTiming(0, ANIMATION_CONFIG);\n }, [isExpanded, contentHeight]);\n\n return (\n <Column style={styles.root}>\n <ButtonBase onPress={onPress}>\n <Row style={styles.title}>\n {LeftComponent ? LeftComponent : null}\n\n <Column style={styles.titleColumn}>\n <Typography\n variant={'subtitle2'}\n children={title}\n color={'textPrimary'}\n numberOfLines={1}\n disableFontScaling={true}\n />\n\n {subTitle ? (\n <React.Fragment>\n <Spacer size={0.5}/>\n\n <Typography\n style={styles.subtitle}\n color={'tertiary'}\n children={subTitle}\n numberOfLines={1}\n disableFontScaling={true}\n />\n </React.Fragment>\n ) : null}\n </Column>\n\n <Spacer flex={1}/>\n\n <Spacer size={3}/>\n\n <Animated.View style={animatedChevronDownStyles}>\n {RightIcon ? RightIcon : (\n <ChevronDown\n width={20}\n height={20}\n color={'tertiary'}\n />\n )}\n </Animated.View>\n </Row>\n </ButtonBase>\n\n <Animated.View style={animatedContentBackgroundStyles}>\n <View\n onLayout={onLayout}\n style={styles.contentView}\n >\n <Animated.View style={animatedContentStyle}>\n {typeof content === 'string' ? (\n <Typography\n variant={'subtitle2'}\n color={'tertiary'}\n children={content}\n />\n ) : (content)}\n </Animated.View>\n </View>\n </Animated.View>\n </Column>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,QAAmD,OAAnD;AACA,SAA4BC,IAA5B,QAAwC,cAAxC;AACA,OAAOC,QAAP,IACIC,gBADJ,EAEIC,cAFJ,EAGIC,SAHJ,EAIIC,UAJJ,QAMO,yBANP;AAQA,SAASC,QAAT,QAAyB,WAAzB;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,GAAP,MAAgB,QAAhB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AAYA,MAAMC,kBAAkB,GAAG,CAA3B;AACA,MAAMC,kBAAkB,GAAG,GAA3B;AACA,MAAMC,gBAA4C,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAArD;AACA,MAAMC,6BAA6B,GAAG,GAAtC;AACA,MAAMC,4BAA4B,GAAG,GAArC;;AAEA,MAAMC,SAAqC,GAAG,YAA6B;EACvE,MAAMC,KAAK,GAAGd,QAAQ,EAAtB;EAEA,OAAO;IACHe,IAAI,EAAE;MAAEC,YAAY,EAAEF,KAAK,CAACG,OAAN,CAAc,CAAd;IAAhB,CADH;IAEHC,KAAK,EAAE;MACHC,YAAY,EAAEL,KAAK,CAACG,OAAN,CAAc,CAAd,CADX;MAEHG,eAAe,EAAEN,KAAK,CAACO,OAAN,CAAcC,KAAd,CAAoBC,IAFlC;MAGHC,iBAAiB,EAA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AAK,EAAE,EADX;IAEI,MAAM,EAAE,EAFZ;IAGI,KAAK,EAAE;EAHX,EAFR,CA/BJ,CADJ,CADJ,eA6CI,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAEgB;EAAtB,gBACI,oBAAC,IAAD;IACI,QAAQ,EAAEM,QADd;IAEI,KAAK,EAAEnB,MAAM,CAACX;EAFlB,gBAII,oBAAC,QAAD,CAAU,IAAV;IAAe,KAAK,EAAE0B;EAAtB,GACK,OAAOnB,OAAP,KAAmB,QAAnB,gBACG,oBAAC,UAAD;IACI,OAAO,EAAE,WADb;IAEI,KAAK,EAAE,UAFX;IAGI,QAAQ,EAAEA;EAHd,EADH,GAMIA,OAPT,CAJJ,CADJ,CA7CJ,CADJ;AAgEH"}
@@ -1,17 +1,13 @@
1
1
  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); }
2
2
 
3
- import React, { useEffect } from 'react';
4
- import { useWindowDimensions, Animated, Easing } from 'react-native';
3
+ import React, { useMemo } from 'react';
4
+ import { useWindowDimensions } from 'react-native';
5
5
  import { css } from '@fountain-ui/styles';
6
6
  import Column from '../Column';
7
- import Modal from '../Modal';
7
+ import Modal, { ANIMATION_TYPE } from '../Modal';
8
8
  import Paper from '../Paper';
9
- import { useAnimatedValue } from '../hooks';
10
- import { isNotAndroid12 } from '../utils';
11
9
  import { useTheme } from '../styles';
12
10
  const DIALOG_MAX_WIDTH = 328;
13
- const fadeDuration = 300;
14
- const fadeAnimationDelay = 50;
15
11
 
16
12
  const useStyles = function () {
17
13
  const theme = useTheme();
@@ -27,6 +23,7 @@ const useStyles = function () {
27
23
  zIndex: theme.zIndex.dialog
28
24
  },
29
25
  paper: {
26
+ borderRadius: theme.shape.roundnessExtra,
30
27
  margin,
31
28
  maxWidth: DIALOG_MAX_WIDTH,
32
29
  overflow: 'hidden',
@@ -55,6 +52,7 @@ const useStyles = function () {
55
52
 
56
53
  export default function Dialog(props) {
57
54
  const {
55
+ animationType = ANIMATION_TYPE.SLIDE,
58
56
  children,
59
57
  fullScreen = false,
60
58
  onClose,
@@ -64,42 +62,74 @@ export default function Dialog(props) {
64
62
  ...otherProps
65
63
  } = props;
66
64
  const styles = useStyles();
67
- const theme = useTheme();
68
- const animatedOpacity = useAnimatedValue(0);
69
- useEffect(() => {
70
- if (!fullScreen) {
71
- Animated.timing(animatedOpacity, {
72
- toValue: visible ? 1 : 0,
73
- duration: fadeDuration,
74
- delay: visible ? fadeAnimationDelay : 0,
75
- easing: Easing.out(Easing.exp),
76
- useNativeDriver: isNotAndroid12
77
- }).start();
65
+ const {
66
+ height: screenHeight
67
+ } = useWindowDimensions();
68
+ const closeAnimation = useMemo(() => {
69
+ if (animationType === ANIMATION_TYPE.FADE) {
70
+ return [{
71
+ toValue: 0,
72
+ type: ANIMATION_TYPE.FADE
73
+ }];
74
+ } else if (animationType === ANIMATION_TYPE.SLIDE && !fullScreen) {
75
+ return [{
76
+ toValue: screenHeight,
77
+ type: ANIMATION_TYPE.SLIDE
78
+ }, {
79
+ duration: 150,
80
+ toValue: 0,
81
+ type: ANIMATION_TYPE.FADE
82
+ }];
78
83
  }
79
- }, [fullScreen, visible]);
84
+
85
+ return [{
86
+ duration: 150,
87
+ toValue: screenHeight,
88
+ type: ANIMATION_TYPE.SLIDE
89
+ }];
90
+ }, [animationType, fullScreen, screenHeight]);
91
+ const openAnimation = useMemo(() => {
92
+ if (animationType === ANIMATION_TYPE.FADE) {
93
+ return [{
94
+ toValue: 1,
95
+ type: ANIMATION_TYPE.FADE
96
+ }];
97
+ } else if (animationType === ANIMATION_TYPE.SLIDE && !fullScreen) {
98
+ return [{
99
+ toValue: 0,
100
+ type: ANIMATION_TYPE.SLIDE
101
+ }, {
102
+ delay: 50,
103
+ duration: 150,
104
+ toValue: 1,
105
+ type: ANIMATION_TYPE.FADE
106
+ }];
107
+ }
108
+
109
+ return [{
110
+ toValue: 0,
111
+ type: ANIMATION_TYPE.SLIDE
112
+ }];
113
+ }, [animationType, fullScreen]);
114
+ const initialOpacity = animationType === ANIMATION_TYPE.SLIDE && fullScreen ? 1 : undefined;
115
+ const initialTranslateY = animationType === ANIMATION_TYPE.FADE ? 0 : undefined;
80
116
  return /*#__PURE__*/React.createElement(Modal, _extends({
81
117
  animationStyle: fullScreen ? styles.animationFullScreen : styles.animation,
118
+ closeAnimation: closeAnimation,
119
+ initialOpacity: initialOpacity,
120
+ initialTranslateY: initialTranslateY,
82
121
  onClose: onClose,
83
- exitDuration: fullScreen ? 150 : 300,
122
+ openAnimation: openAnimation,
84
123
  visible: visible,
85
124
  style: styles.root
86
- }, otherProps), /*#__PURE__*/React.createElement(Animated.View, {
87
- needsOffscreenAlphaCompositing: true,
88
- style: {
89
- height: fullScreen ? '100%' : 'auto',
90
- width: fullScreen ? '100%' : 'auto',
91
- opacity: fullScreen ? 1 : animatedOpacity
92
- }
93
- }, topElement ? /*#__PURE__*/React.createElement(Column, {
125
+ }, otherProps), /*#__PURE__*/React.createElement(React.Fragment, null, topElement ? /*#__PURE__*/React.createElement(Column, {
94
126
  style: fullScreen ? undefined : styles.topElementSize
95
127
  }, /*#__PURE__*/React.createElement(Column, {
96
128
  style: styles.topElementPosition
97
129
  }, topElement)) : null, /*#__PURE__*/React.createElement(Paper, {
98
130
  elevation: 6,
99
131
  square: fullScreen,
100
- style: css([{
101
- borderRadius: fullScreen ? undefined : theme.shape.roundnessExtra
102
- }, fullScreen ? styles.paperFullScreen : styles.paper, style])
132
+ style: css([fullScreen ? styles.paperFullScreen : styles.paper, style])
103
133
  }, children)));
104
134
  }
105
135
  ;
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useWindowDimensions","Animated","Easing","css","Column","Modal","Paper","useAnimatedValue","isNotAndroid12","useTheme","DIALOG_MAX_WIDTH","fadeDuration","fadeAnimationDelay","useStyles","theme","width","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","timing","toValue","duration","delay","easing","out","exp","useNativeDriver","start","opacity","undefined","borderRadius","shape","roundnessExtra"],"sources":["Dialog.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useWindowDimensions, Animated, Easing } 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 fadeDuration = 300;\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(0);\n\n useEffect(() => {\n if(!fullScreen){\n Animated.timing(animatedOpacity, {\n toValue: visible ? 1 : 0,\n duration: fadeDuration,\n delay: visible ? fadeAnimationDelay : 0,\n easing: Easing.out(Easing.exp),\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={{\n height: fullScreen ? '100%' : 'auto',\n width: fullScreen ? '100%' : 'auto',\n opacity: fullScreen ? 1 : animatedOpacity,\n }}\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={6}\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,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,mBAAT,EAA8BC,QAA9B,EAAwCC,MAAxC,QAAsD,cAAtD;AACA,SAASC,GAAT,QAAuD,qBAAvD;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,SAASC,gBAAT,QAAiC,UAAjC;AACA,SAASC,cAAT,QAA+B,UAA/B;AACA,SAASC,QAAT,QAAyB,WAAzB;AAcA,MAAMC,gBAAgB,GAAG,GAAzB;AAEA,MAAMC,YAAY,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I,oBAAC,KAAD;IACI,SAAS,EAAE,CADf;IAEI,MAAM,EAAEJ,UAFZ;IAGI,KAAK,EAAErC,GAAG,CAAC,CACP;MAAEwD,YAAY,EAAEnB,UAAU,GAAGkB,SAAH,GAAe5C,KAAK,CAAC8C,KAAN,CAAYC;IAArD,CADO,EAEPrB,UAAU,GAAGM,MAAM,CAACnB,eAAV,GAA4BmB,MAAM,CAACtB,KAFtC,EAGPkB,KAHO,CAAD;EAHd,GASKH,QATL,CAhBJ,CARJ,CADJ;AAuCH;AAAA"}
1
+ {"version":3,"names":["React","useMemo","useWindowDimensions","css","Column","Modal","ANIMATION_TYPE","Paper","useTheme","DIALOG_MAX_WIDTH","useStyles","theme","width","margin","spacing","dialogWidth","root","alignItems","justifyContent","zIndex","dialog","paper","borderRadius","shape","roundnessExtra","maxWidth","overflow","paperFullScreen","flexGrow","animation","animationFullScreen","height","topElementSize","marginHorizontal","topElementPosition","position","bottom","Dialog","props","animationType","SLIDE","children","fullScreen","onClose","style","visible","topElement","otherProps","styles","screenHeight","closeAnimation","FADE","toValue","type","duration","openAnimation","delay","initialOpacity","undefined","initialTranslateY"],"sources":["Dialog.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useWindowDimensions } from 'react-native';\nimport { css, NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport Column from '../Column';\nimport Modal, { ANIMATION_TYPE, AnimationUnit } 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 borderRadius: theme.shape.roundnessExtra,\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 animationType = ANIMATION_TYPE.SLIDE,\n children,\n fullScreen = false,\n onClose,\n style = {},\n visible,\n topElement,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const { height: screenHeight } = useWindowDimensions();\n\n const closeAnimation = useMemo<AnimationUnit[]>(() => {\n if (animationType === ANIMATION_TYPE.FADE) {\n return [{\n toValue: 0,\n type: ANIMATION_TYPE.FADE,\n }];\n } else if (animationType === ANIMATION_TYPE.SLIDE && !fullScreen) {\n return [\n {\n toValue: screenHeight,\n type: ANIMATION_TYPE.SLIDE,\n },\n {\n duration: 150,\n toValue: 0,\n type: ANIMATION_TYPE.FADE,\n },\n ];\n }\n\n return [{\n duration: 150,\n toValue: screenHeight,\n type: ANIMATION_TYPE.SLIDE,\n }];\n }, [animationType, fullScreen, screenHeight]);\n\n const openAnimation = useMemo<AnimationUnit[]>(() => {\n if (animationType === ANIMATION_TYPE.FADE) {\n return [{\n toValue: 1,\n type: ANIMATION_TYPE.FADE,\n }];\n } else if (animationType === ANIMATION_TYPE.SLIDE && !fullScreen) {\n return [\n {\n toValue: 0,\n type: ANIMATION_TYPE.SLIDE,\n },\n {\n delay: 50,\n duration: 150,\n toValue: 1,\n type: ANIMATION_TYPE.FADE,\n },\n ];\n }\n\n return [{\n toValue: 0,\n type: ANIMATION_TYPE.SLIDE,\n }];\n }, [animationType, fullScreen]);\n\n const initialOpacity = animationType === ANIMATION_TYPE.SLIDE && fullScreen ? 1 : undefined;\n\n const initialTranslateY = animationType === ANIMATION_TYPE.FADE ? 0 : undefined;\n\n return (\n <Modal\n animationStyle={fullScreen ? styles.animationFullScreen : styles.animation}\n closeAnimation={closeAnimation}\n initialOpacity={initialOpacity}\n initialTranslateY={initialTranslateY}\n onClose={onClose}\n openAnimation={openAnimation}\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={6}\n square={fullScreen}\n style={css([\n fullScreen ? styles.paperFullScreen : styles.paper,\n style,\n ])}\n >\n {children}\n </Paper>\n </React.Fragment>\n </Modal>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,OAAhB,QAA+B,OAA/B;AACA,SAASC,mBAAT,QAAoC,cAApC;AACA,SAASC,GAAT,QAAuD,qBAAvD;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,KAAP,IAAgBC,cAAhB,QAAqD,UAArD;AACA,OAAOC,KAAP,MAAkB,UAAlB;AACA,SAASC,QAAT,QAAyB,WAAzB;AAcA,MAAMC,gBAAgB,GAAG,GAAzB;;AAEA,MAAMC,SAAkC,GAAG,YAA0B;EACjE,MAAMC,KAAK,GAAGH,QAAQ,EAAtB;EAEA,MAAM;IAAEI;EAAF,IAAYV,mBAAmB,EAArC;EAEA,MAAMW,MAAM,GAAGF,KAAK,CAACG,OAAN,CAAc,CAAd,CAAf;EACA,MAAMC,WAAW,GAAGH,KAAK,GAAGC,MAAM,GAAG,CAArC;EAEA,OAAO;IACHG,IAAI,EAAE;MACFC,UAAU,EAAE,QADV;MAEFC,cAAc,EAAE,QAFd;MAGFC,MAAM,EAAER,KAAK,CAACQ,MAAN,CAAaC;IAHnB,CADH;IAMH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iBAAiB,GAAGpB,aAAa,KAAKjC,cAAc,CAAC6C,IAAjC,GAAwC,CAAxC,GAA4CO,SAAtE;EAEA,oBACI,oBAAC,KAAD;IACI,cAAc,EAAEhB,UAAU,GAAGM,MAAM,CAAClB,mBAAV,GAAgCkB,MAAM,CAACnB,SADrE;IAEI,cAAc,EAAEqB,cAFpB;IAGI,cAAc,EAAEO,cAHpB;IAII,iBAAiB,EAAEE,iBAJvB;IAKI,OAAO,EAAEhB,OALb;IAMI,aAAa,EAAEY,aANnB;IAOI,OAAO,EAAEV,OAPb;IAQI,KAAK,EAAEG,MAAM,CAAChC;EARlB,GASQ+B,UATR,gBAWI,oBAAC,KAAD,CAAO,QAAP,QACKD,UAAU,gBACP,oBAAC,MAAD;IAAQ,KAAK,EAAEJ,UAAU,GAAGgB,SAAH,GAAeV,MAAM,CAAChB;EAA/C,gBACI,oBAAC,MAAD;IAAQ,KAAK,EAAEgB,MAAM,CAACd;EAAtB,GACKY,UADL,CADJ,CADO,GAMP,IAPR,eASI,oBAAC,KAAD;IACI,SAAS,EAAE,CADf;IAEI,MAAM,EAAEJ,UAFZ;IAGI,KAAK,EAAEvC,GAAG,CAAC,CACPuC,UAAU,GAAGM,MAAM,CAACrB,eAAV,GAA4BqB,MAAM,CAAC3B,KADtC,EAEPuB,KAFO,CAAD;EAHd,GAQKH,QARL,CATJ,CAXJ,CADJ;AAkCH;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["DialogProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ModalProps } from '../Modal';\nimport type { OverridableComponentProps } from '../types';\n\nexport default interface DialogProps extends OverridableComponentProps<ModalProps, {\n /**\n * Dialog children, usually the included sub-components.\n */\n children?: React.ReactNode;\n\n /**\n * If `true`, the dialog is full-screen.\n * @default false\n */\n fullScreen?: boolean;\n\n /**\n * Top element for displaying additional information on the dialog.\n */\n topElement?: React.ReactNode;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["DialogProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ModalProps } from '../Modal';\nimport type { OverridableComponentProps } from '../types';\nimport { ANIMATION_TYPE } from '../Modal';\n\nexport default interface DialogProps extends OverridableComponentProps<ModalProps, {\n /**\n * Type of animation used when the dialog opens and closes.\n * @default 'slide'\n */\n animationType?: ANIMATION_TYPE;\n\n /**\n * Dialog children, usually the included sub-components.\n */\n children?: React.ReactNode;\n\n /**\n * If `true`, the dialog is full-screen.\n * @default false\n */\n fullScreen?: boolean;\n\n /**\n * Top element for displaying additional information on the dialog.\n */\n topElement?: React.ReactNode;\n}> {}\n"],"mappings":""}
@@ -0,0 +1,131 @@
1
+ import React, { useCallback, useEffect } from 'react';
2
+ import { Animated, Easing, Platform, useWindowDimensions } from 'react-native';
3
+ import * as R from 'ramda';
4
+ import { useAnimatedValue } from '../../hooks';
5
+ import { isNotAndroid12 } from '../../utils';
6
+ import { ANIMATION_TYPE } from '../ModalProps';
7
+ const DEFAULT_ANIMATION_CONFIG = {
8
+ duration: 300,
9
+ useNativeDriver: isNotAndroid12
10
+ };
11
+ export default function AnimatedContainer(props) {
12
+ const {
13
+ children,
14
+ closeAnimation,
15
+ initialOpacity,
16
+ initialTranslateY,
17
+ onEnter,
18
+ onEntered,
19
+ onExit,
20
+ onExited,
21
+ openAnimation,
22
+ style,
23
+ visible
24
+ } = props;
25
+ const {
26
+ height: screenHeight
27
+ } = useWindowDimensions();
28
+ const opacity = useAnimatedValue(initialOpacity ?? 0);
29
+ const translateY = useAnimatedValue(initialTranslateY ?? screenHeight);
30
+ const convertToCompositeAnimation = useCallback(animationUnit => {
31
+ const {
32
+ type,
33
+ ...others
34
+ } = animationUnit;
35
+
36
+ switch (type) {
37
+ case ANIMATION_TYPE.FADE:
38
+ return Animated.timing(opacity, { ...others,
39
+ useNativeDriver: isNotAndroid12
40
+ });
41
+
42
+ case ANIMATION_TYPE.SLIDE:
43
+ default:
44
+ const easing = others.toValue === screenHeight ? Easing.in(Easing.ease) : Platform.OS === 'web' ? Easing.bezier(0.16, 1, 0.3, 1) : Easing.out(Easing.exp);
45
+ return Animated.timing(translateY, { ...others,
46
+ easing,
47
+ useNativeDriver: isNotAndroid12
48
+ });
49
+ }
50
+ }, [screenHeight]);
51
+ useEffect(() => {
52
+ if (visible) {
53
+ onEnter === null || onEnter === void 0 ? void 0 : onEnter();
54
+
55
+ if (R.isNil(openAnimation)) {
56
+ opacity.setValue(1);
57
+ Animated.timing(translateY, { ...DEFAULT_ANIMATION_CONFIG,
58
+ easing: Platform.OS === 'web' ? Easing.bezier(0.16, 1, 0.3, 1) : Easing.out(Easing.exp),
59
+ toValue: 0
60
+ }).start(_ref => {
61
+ let {
62
+ finished
63
+ } = _ref;
64
+
65
+ if (finished) {
66
+ onEntered === null || onEntered === void 0 ? void 0 : onEntered();
67
+ }
68
+ });
69
+ } else {
70
+ const convertedAnimation = openAnimation.map(animationUnit => {
71
+ return convertToCompositeAnimation({ ...DEFAULT_ANIMATION_CONFIG,
72
+ ...animationUnit
73
+ });
74
+ });
75
+ Animated.parallel(convertedAnimation).start(_ref2 => {
76
+ let {
77
+ finished
78
+ } = _ref2;
79
+
80
+ if (finished) {
81
+ onEntered === null || onEntered === void 0 ? void 0 : onEntered();
82
+ }
83
+ });
84
+ }
85
+ } else {
86
+ onExit === null || onExit === void 0 ? void 0 : onExit();
87
+
88
+ if (R.isNil(closeAnimation)) {
89
+ opacity.setValue(1);
90
+ Animated.timing(translateY, { ...DEFAULT_ANIMATION_CONFIG,
91
+ easing: Easing.in(Easing.ease),
92
+ toValue: screenHeight
93
+ }).start(_ref3 => {
94
+ let {
95
+ finished
96
+ } = _ref3;
97
+
98
+ if (finished) {
99
+ onExited === null || onExited === void 0 ? void 0 : onExited();
100
+ }
101
+ });
102
+ } else {
103
+ const convertedAnimation = closeAnimation.map(animationUnit => {
104
+ return convertToCompositeAnimation({ ...DEFAULT_ANIMATION_CONFIG,
105
+ ...animationUnit
106
+ });
107
+ });
108
+ Animated.parallel(convertedAnimation).start(_ref4 => {
109
+ let {
110
+ finished
111
+ } = _ref4;
112
+
113
+ if (finished) {
114
+ onExited === null || onExited === void 0 ? void 0 : onExited();
115
+ }
116
+ });
117
+ }
118
+ }
119
+ }, [convertToCompositeAnimation, visible]);
120
+ const animatedStyle = {
121
+ opacity,
122
+ transform: [{
123
+ translateY
124
+ }]
125
+ };
126
+ return /*#__PURE__*/React.createElement(Animated.View, {
127
+ pointerEvents: 'box-none',
128
+ style: [animatedStyle, style]
129
+ }, children);
130
+ }
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useEffect","Animated","Easing","Platform","useWindowDimensions","R","useAnimatedValue","isNotAndroid12","ANIMATION_TYPE","DEFAULT_ANIMATION_CONFIG","duration","useNativeDriver","AnimatedContainer","props","children","closeAnimation","initialOpacity","initialTranslateY","onEnter","onEntered","onExit","onExited","openAnimation","style","visible","height","screenHeight","opacity","translateY","convertToCompositeAnimation","animationUnit","type","others","FADE","timing","SLIDE","easing","toValue","in","ease","OS","bezier","out","exp","isNil","setValue","start","finished","convertedAnimation","map","parallel","animatedStyle","transform"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from 'react';\nimport { Animated, Easing, Platform, useWindowDimensions } from 'react-native';\nimport * as R from 'ramda';\nimport { useAnimatedValue } from '../../hooks';\nimport { isNotAndroid12 } from '../../utils';\nimport type ModalProps from '../ModalProps';\nimport { ANIMATION_TYPE, AnimationUnit } from '../ModalProps';\n\ntype AnimatedContainerProps = Pick<ModalProps,\n | 'children'\n | 'closeAnimation'\n | 'initialOpacity'\n | 'initialTranslateY'\n | 'onEnter'\n | 'onEntered'\n | 'onExit'\n | 'onExited'\n | 'openAnimation'\n | 'style'\n | 'visible'>\n\nconst DEFAULT_ANIMATION_CONFIG = {\n duration: 300,\n useNativeDriver: isNotAndroid12,\n};\n\nexport default function AnimatedContainer(props: AnimatedContainerProps) {\n const {\n children,\n closeAnimation,\n initialOpacity,\n initialTranslateY,\n onEnter,\n onEntered,\n onExit,\n onExited,\n openAnimation,\n style,\n visible,\n } = props;\n\n const { height: screenHeight } = useWindowDimensions();\n\n const opacity = useAnimatedValue(initialOpacity ?? 0);\n\n const translateY = useAnimatedValue(initialTranslateY ?? screenHeight);\n\n const convertToCompositeAnimation = useCallback((animationUnit: AnimationUnit) => {\n const {\n type,\n ...others\n } = animationUnit;\n\n switch (type) {\n case ANIMATION_TYPE.FADE:\n return Animated.timing(opacity, {\n ...others,\n useNativeDriver: isNotAndroid12,\n });\n case ANIMATION_TYPE.SLIDE:\n default:\n const easing = others.toValue === screenHeight\n ? Easing.in(Easing.ease)\n : Platform.OS === 'web'\n ? Easing.bezier(0.16, 1, 0.3, 1)\n : Easing.out(Easing.exp);\n\n return Animated.timing(translateY, {\n ...others,\n easing,\n useNativeDriver: isNotAndroid12,\n });\n }\n }, [screenHeight]);\n\n useEffect(() => {\n if (visible) {\n onEnter?.();\n\n if (R.isNil(openAnimation)) {\n opacity.setValue(1);\n\n Animated.timing(translateY, {\n ...DEFAULT_ANIMATION_CONFIG,\n easing: Platform.OS === 'web'\n ? Easing.bezier(0.16, 1, 0.3, 1)\n : Easing.out(Easing.exp),\n toValue: 0,\n }).start(({ finished }) => {\n if (finished) {\n onEntered?.();\n }\n });\n } else {\n const convertedAnimation = openAnimation.map((animationUnit) => {\n return convertToCompositeAnimation({\n ...DEFAULT_ANIMATION_CONFIG,\n ...animationUnit,\n });\n });\n\n Animated.parallel(convertedAnimation).start(({ finished }) => {\n if (finished) {\n onEntered?.();\n }\n });\n }\n } else {\n onExit?.();\n\n if (R.isNil(closeAnimation)) {\n opacity.setValue(1);\n\n Animated.timing(translateY, {\n ...DEFAULT_ANIMATION_CONFIG,\n easing: Easing.in(Easing.ease),\n toValue: screenHeight,\n }).start(({ finished }) => {\n if (finished) {\n onExited?.();\n }\n });\n } else {\n const convertedAnimation = closeAnimation.map((animationUnit) => {\n return convertToCompositeAnimation({\n ...DEFAULT_ANIMATION_CONFIG,\n ...animationUnit,\n });\n });\n\n Animated.parallel(convertedAnimation).start(({ finished }) => {\n if (finished) {\n onExited?.();\n }\n });\n }\n }\n }, [convertToCompositeAnimation, visible]);\n\n const animatedStyle = {\n opacity,\n transform: [{ translateY }],\n };\n\n return (\n <Animated.View\n pointerEvents={'box-none'}\n style={[\n animatedStyle,\n style,\n ]}\n >\n {children}\n </Animated.View>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,QAA8C,OAA9C;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,QAA3B,EAAqCC,mBAArC,QAAgE,cAAhE;AACA,OAAO,KAAKC,CAAZ,MAAmB,OAAnB;AACA,SAASC,gBAAT,QAAiC,aAAjC;AACA,SAASC,cAAT,QAA+B,aAA/B;AAEA,SAASC,cAAT,QAA8C,eAA9C;AAeA,MAAMC,wBAAwB,GAAG;EAC7BC,QAAQ,EAAE,GADmB;EAE7BC,eAAe,EAAEJ;AAFY,CAAjC;AAKA,eAAe,SAASK,iBAAT,CAA2BC,KAA3B,EAA0D;EACrE,MAAM;IACFC,QADE;IAEFC,cAFE;IAGFC,cAHE;IAIFC,iBAJE;IAKFC,OALE;IAMFC,SANE;IAOFC,MAPE;IAQFC,QARE;IASFC,aATE;IAUFC,KAVE;IAWFC;EAXE,IAYFX,KAZJ;EAcA,MAAM;IAAEY,MAAM,EAAEC;EAAV,IAA2BtB,mBAAmB,EAApD;EAEA,MAAMuB,OAAO,GAAGrB,gBAAgB,CAACU,cAAc,IAAI,CAAnB,CAAhC;EAEA,MAAMY,UAAU,GAAGtB,gBAAgB,CAACW,iBAAiB,IAAIS,YAAtB,CAAnC;EAEA,MAAMG,2BAA2B,GAAG9B,WAAW,CAAE+B,aAAD,IAAkC;IAC9E,MAAM;MACFC,IADE;MAEF,GAAGC;IAFD,IAGFF,aAHJ;;IAKA,QAAQC,IAAR;MACI,KAAKvB,cAAc,CAACyB,IAApB;QACI,OAAO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,CAA3B;QAOA7B,QAAQ,CAACiD,QAAT,CAAkBF,kBAAlB,EAAsCF,KAAtC,CAA4C,SAAkB;UAAA,IAAjB;YAAEC;UAAF,CAAiB;;UAC1D,IAAIA,QAAJ,EAAc;YACV1B,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ;UACX;QACJ,CAJD;MAKH;IACJ;EACJ,CA9DQ,EA8DN,CAACQ,2BAAD,EAA8BL,OAA9B,CA9DM,CAAT;EAgEA,MAAM2B,aAAa,GAAG;IAClBxB,OADkB;IAElByB,SAAS,EAAE,CAAC;MAAExB;IAAF,CAAD;EAFO,CAAtB;EAKA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,aAAa,EAAE,UADnB;IAEI,KAAK,EAAE,CACHuB,aADG,EAEH5B,KAFG;EAFX,GAOKT,QAPL,CADJ;AAWH"}
@@ -4,10 +4,8 @@ import React from 'react';
4
4
  import { View } from 'react-native';
5
5
  import { css, StyleSheet } from '../styles';
6
6
  import { useElevationStyle } from '../hooks';
7
- import Slide from '../Slide';
7
+ import AnimatedContainer from './AnimatedContainer';
8
8
  import SimpleBackdrop from './SimpleBackdrop';
9
- const defaultEnterDuration = 300;
10
- const defaultExitDuration = 150;
11
9
  export const createModalCloseEvent = reason => ({
12
10
  metadata: {
13
11
  reason
@@ -18,11 +16,17 @@ export default function Modal(props) {
18
16
  animationStyle,
19
17
  backdropOpacity = 0.5,
20
18
  children,
19
+ closeAnimation,
21
20
  disableAnimation = false,
22
- enterDuration = defaultEnterDuration,
23
- exitDuration = defaultExitDuration,
24
21
  hideBackdrop = false,
22
+ initialOpacity,
23
+ initialTranslateY,
25
24
  onClose,
25
+ onEnter: onEnterProp,
26
+ onEntered: onEnteredProp,
27
+ onExit: onExitProp,
28
+ onExited: onExitedProp,
29
+ openAnimation,
26
30
  style,
27
31
  visible,
28
32
  ...otherProps
@@ -37,6 +41,24 @@ export default function Modal(props) {
37
41
  const [exited, setExited] = React.useState(true);
38
42
  const elevationStyle = useElevationStyle(6);
39
43
 
44
+ const onEnter = () => {
45
+ setExited(false);
46
+ onEnterProp === null || onEnterProp === void 0 ? void 0 : onEnterProp();
47
+ };
48
+
49
+ const onEntered = () => {
50
+ onEnteredProp === null || onEnteredProp === void 0 ? void 0 : onEnteredProp();
51
+ };
52
+
53
+ const onExit = () => {
54
+ onExitProp === null || onExitProp === void 0 ? void 0 : onExitProp();
55
+ };
56
+
57
+ const onExited = () => {
58
+ setExited(true);
59
+ onExitedProp === null || onExitedProp === void 0 ? void 0 : onExitedProp();
60
+ };
61
+
40
62
  if (!visible) {
41
63
  if (disableAnimation || exited) {
42
64
  return null;
@@ -45,17 +67,22 @@ export default function Modal(props) {
45
67
 
46
68
  return /*#__PURE__*/React.createElement(View, _extends({
47
69
  style: css([StyleSheet.absoluteFill, elevationStyle, style])
48
- }, otherProps), hideBackdrop || !visible ? null : /*#__PURE__*/React.createElement(SimpleBackdrop, {
70
+ }, otherProps), !hideBackdrop && visible ? /*#__PURE__*/React.createElement(SimpleBackdrop, {
49
71
  onPress: handleBackdropPress,
50
72
  opacity: backdropOpacity
51
- }), !disableAnimation ? /*#__PURE__*/React.createElement(Slide, {
52
- appear: visible,
53
- enterDuration: enterDuration,
54
- exitDuration: exitDuration,
55
- onEnter: () => setExited(false),
56
- onExited: () => setExited(true),
57
- style: animationStyle
58
- }, children) : children);
73
+ }) : null, !disableAnimation ? /*#__PURE__*/React.createElement(AnimatedContainer, {
74
+ children: children,
75
+ closeAnimation: closeAnimation,
76
+ initialOpacity: initialOpacity,
77
+ initialTranslateY: initialTranslateY,
78
+ onEnter: onEnter,
79
+ onEntered: onEntered,
80
+ onExit: onExit,
81
+ onExited: onExited,
82
+ openAnimation: openAnimation,
83
+ style: animationStyle,
84
+ visible: visible
85
+ }) : children);
59
86
  }
60
87
  ;
61
88
  //# sourceMappingURL=Modal.js.map