@fountain-ui/core 2.0.0-beta.94 → 2.0.0-beta.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/commonjs/Dialog/Dialog.js +26 -50
- package/build/commonjs/Dialog/Dialog.js.map +1 -1
- package/build/commonjs/Dialog/DialogProps.js +7 -0
- package/build/commonjs/Dialog/DialogProps.js.map +1 -1
- package/build/commonjs/Dialog/LegacyDialog.js +181 -0
- package/build/commonjs/Dialog/LegacyDialog.js.map +1 -0
- package/build/commonjs/Dialog/LegacyDialogProps.js +2 -0
- package/build/commonjs/Dialog/LegacyDialogProps.js.map +1 -0
- package/build/commonjs/Dialog/index.js +2 -2
- package/build/commonjs/Dialog/index.js.map +1 -1
- package/build/commonjs/Dialog/useDialogStyle.js +81 -0
- package/build/commonjs/Dialog/useDialogStyle.js.map +1 -0
- package/build/commonjs/DialogActions/DialogActions.js +2 -2
- package/build/commonjs/DialogActions/DialogActions.js.map +1 -1
- package/build/commonjs/DialogActions/LegacyDialogActions.js +30 -0
- package/build/commonjs/DialogActions/LegacyDialogActions.js.map +1 -0
- package/build/commonjs/DialogActions/index.js +2 -2
- package/build/commonjs/DialogActions/index.js.map +1 -1
- package/build/commonjs/DialogContent/DialogContent.js +30 -11
- package/build/commonjs/DialogContent/DialogContent.js.map +1 -1
- package/build/commonjs/DialogContent/DialogContentProps.js.map +1 -1
- package/build/commonjs/DialogContent/LegacyDialogContent.js +36 -0
- package/build/commonjs/DialogContent/LegacyDialogContent.js.map +1 -0
- package/build/commonjs/DialogContent/LegacyDialogContentProps.js +2 -0
- package/build/commonjs/DialogContent/LegacyDialogContentProps.js.map +1 -0
- package/build/commonjs/DialogContent/index.js +2 -2
- package/build/commonjs/DialogContent/index.js.map +1 -1
- package/build/commonjs/DialogMedia/DialogMedia.js +24 -10
- package/build/commonjs/DialogMedia/DialogMedia.js.map +1 -1
- package/build/commonjs/DialogMedia/DialogMediaProps.js +7 -0
- package/build/commonjs/DialogMedia/DialogMediaProps.js.map +1 -1
- package/build/commonjs/DialogMedia/LegacyDialogMedia.js +33 -0
- package/build/commonjs/DialogMedia/LegacyDialogMedia.js.map +1 -0
- package/build/commonjs/DialogMedia/LegacyDialogMediaProps.js +2 -0
- package/build/commonjs/DialogMedia/LegacyDialogMediaProps.js.map +1 -0
- package/build/commonjs/DialogMedia/index.js +2 -2
- package/build/commonjs/DialogMedia/index.js.map +1 -1
- package/build/commonjs/DialogTitle/DialogTitle.js +27 -11
- package/build/commonjs/DialogTitle/DialogTitle.js.map +1 -1
- package/build/commonjs/DialogTitle/DialogTitleProps.js.map +1 -1
- package/build/commonjs/DialogTitle/LegacyDialogTitle.js +36 -0
- package/build/commonjs/DialogTitle/LegacyDialogTitle.js.map +1 -0
- package/build/commonjs/DialogTitle/LegacyDialogTitleProps.js +2 -0
- package/build/commonjs/DialogTitle/LegacyDialogTitleProps.js.map +1 -0
- package/build/commonjs/DialogTitle/index.js +2 -2
- package/build/commonjs/DialogTitle/index.js.map +1 -1
- package/build/module/Dialog/Dialog.js +23 -52
- package/build/module/Dialog/Dialog.js.map +1 -1
- package/build/module/Dialog/DialogProps.js +1 -1
- package/build/module/Dialog/DialogProps.js.map +1 -1
- package/build/module/Dialog/LegacyDialog.js +160 -0
- package/build/module/Dialog/LegacyDialog.js.map +1 -0
- package/build/module/Dialog/LegacyDialogProps.js +2 -0
- package/build/module/Dialog/LegacyDialogProps.js.map +1 -0
- package/build/module/Dialog/index.js +1 -1
- package/build/module/Dialog/index.js.map +1 -1
- package/build/module/Dialog/useDialogStyle.js +71 -0
- package/build/module/Dialog/useDialogStyle.js.map +1 -0
- package/build/module/DialogActions/DialogActions.js +2 -2
- package/build/module/DialogActions/DialogActions.js.map +1 -1
- package/build/module/DialogActions/LegacyDialogActions.js +17 -0
- package/build/module/DialogActions/LegacyDialogActions.js.map +1 -0
- package/build/module/DialogActions/index.js +1 -1
- package/build/module/DialogActions/index.js.map +1 -1
- package/build/module/DialogContent/DialogContent.js +32 -11
- package/build/module/DialogContent/DialogContent.js.map +1 -1
- package/build/module/DialogContent/DialogContentProps.js.map +1 -1
- package/build/module/DialogContent/LegacyDialogContent.js +22 -0
- package/build/module/DialogContent/LegacyDialogContent.js.map +1 -0
- package/build/module/DialogContent/LegacyDialogContentProps.js +2 -0
- package/build/module/DialogContent/LegacyDialogContentProps.js.map +1 -0
- package/build/module/DialogContent/index.js +1 -1
- package/build/module/DialogContent/index.js.map +1 -1
- package/build/module/DialogMedia/DialogMedia.js +24 -10
- package/build/module/DialogMedia/DialogMedia.js.map +1 -1
- package/build/module/DialogMedia/DialogMediaProps.js +1 -1
- package/build/module/DialogMedia/DialogMediaProps.js.map +1 -1
- package/build/module/DialogMedia/LegacyDialogMedia.js +21 -0
- package/build/module/DialogMedia/LegacyDialogMedia.js.map +1 -0
- package/build/module/DialogMedia/LegacyDialogMediaProps.js +2 -0
- package/build/module/DialogMedia/LegacyDialogMediaProps.js.map +1 -0
- package/build/module/DialogMedia/index.js +1 -1
- package/build/module/DialogMedia/index.js.map +1 -1
- package/build/module/DialogTitle/DialogTitle.js +29 -11
- package/build/module/DialogTitle/DialogTitle.js.map +1 -1
- package/build/module/DialogTitle/DialogTitleProps.js.map +1 -1
- package/build/module/DialogTitle/LegacyDialogTitle.js +22 -0
- package/build/module/DialogTitle/LegacyDialogTitle.js.map +1 -0
- package/build/module/DialogTitle/LegacyDialogTitleProps.js +2 -0
- package/build/module/DialogTitle/LegacyDialogTitleProps.js.map +1 -0
- package/build/module/DialogTitle/index.js +1 -1
- package/build/module/DialogTitle/index.js.map +1 -1
- package/build/typescript/Dialog/DialogProps.d.ts +7 -0
- package/build/typescript/Dialog/LegacyDialog.d.ts +3 -0
- package/build/typescript/Dialog/LegacyDialogProps.d.ts +25 -0
- package/build/typescript/Dialog/index.d.ts +2 -2
- package/build/typescript/Dialog/useDialogStyle.d.ts +6 -0
- package/build/typescript/DialogActions/LegacyDialogActions.d.ts +3 -0
- package/build/typescript/DialogActions/index.d.ts +1 -1
- package/build/typescript/DialogContent/DialogContentProps.d.ts +5 -5
- package/build/typescript/DialogContent/LegacyDialogContent.d.ts +3 -0
- package/build/typescript/DialogContent/LegacyDialogContentProps.d.ts +10 -0
- package/build/typescript/DialogContent/index.d.ts +2 -2
- package/build/typescript/DialogMedia/DialogMediaProps.d.ts +7 -10
- package/build/typescript/DialogMedia/LegacyDialogMedia.d.ts +3 -0
- package/build/typescript/DialogMedia/LegacyDialogMediaProps.d.ts +15 -0
- package/build/typescript/DialogMedia/index.d.ts +2 -2
- package/build/typescript/DialogTitle/DialogTitleProps.d.ts +2 -13
- package/build/typescript/DialogTitle/LegacyDialogTitle.d.ts +3 -0
- package/build/typescript/DialogTitle/LegacyDialogTitleProps.d.ts +15 -0
- package/build/typescript/DialogTitle/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/Dialog/Dialog.tsx +27 -69
- package/src/Dialog/DialogProps.ts +9 -0
- package/src/Dialog/LegacyDialog.tsx +198 -0
- package/src/Dialog/LegacyDialogProps.ts +28 -0
- package/src/Dialog/index.ts +2 -2
- package/src/Dialog/useDialogStyle.ts +90 -0
- package/src/DialogActions/DialogActions.tsx +2 -4
- package/src/DialogActions/LegacyDialogActions.tsx +23 -0
- package/src/DialogActions/index.ts +2 -2
- package/src/DialogContent/DialogContent.tsx +47 -16
- package/src/DialogContent/DialogContentProps.ts +5 -5
- package/src/DialogContent/LegacyDialogContent.tsx +30 -0
- package/src/DialogContent/LegacyDialogContentProps.ts +10 -0
- package/src/DialogContent/index.ts +2 -2
- package/src/DialogMedia/DialogMedia.tsx +35 -8
- package/src/DialogMedia/DialogMediaProps.ts +7 -10
- package/src/DialogMedia/LegacyDialogMedia.tsx +21 -0
- package/src/DialogMedia/LegacyDialogMediaProps.ts +16 -0
- package/src/DialogMedia/index.ts +2 -2
- package/src/DialogTitle/DialogTitle.tsx +46 -16
- package/src/DialogTitle/DialogTitleProps.ts +2 -14
- package/src/DialogTitle/LegacyDialogTitle.tsx +30 -0
- package/src/DialogTitle/LegacyDialogTitleProps.ts +16 -0
- package/src/DialogTitle/index.ts +2 -2
|
@@ -13,11 +13,15 @@ var _styles = require("@fountain-ui/styles");
|
|
|
13
13
|
|
|
14
14
|
var _Column = _interopRequireDefault(require("../Column"));
|
|
15
15
|
|
|
16
|
+
var _DialogMedia = _interopRequireDefault(require("../DialogMedia/DialogMedia"));
|
|
17
|
+
|
|
16
18
|
var _Modal = _interopRequireWildcard(require("../Modal"));
|
|
17
19
|
|
|
18
20
|
var _Paper = _interopRequireDefault(require("../Paper"));
|
|
19
21
|
|
|
20
|
-
var
|
|
22
|
+
var _utils = require("../utils");
|
|
23
|
+
|
|
24
|
+
var _useDialogStyle = _interopRequireDefault(require("./useDialogStyle"));
|
|
21
25
|
|
|
22
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
27
|
|
|
@@ -27,50 +31,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
27
31
|
|
|
28
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); }
|
|
29
33
|
|
|
30
|
-
const DIALOG_MAX_WIDTH = 328;
|
|
31
34
|
const TOP_ELEMENT_OFFSET = 20;
|
|
32
35
|
|
|
33
|
-
const useStyles = function () {
|
|
34
|
-
const theme = (0, _styles2.useTheme)();
|
|
35
|
-
const {
|
|
36
|
-
width
|
|
37
|
-
} = (0, _reactNative.useWindowDimensions)();
|
|
38
|
-
const margin = theme.spacing(4);
|
|
39
|
-
const dialogWidth = width - margin * 2;
|
|
40
|
-
return {
|
|
41
|
-
root: {
|
|
42
|
-
alignItems: 'center',
|
|
43
|
-
justifyContent: 'center',
|
|
44
|
-
zIndex: theme.zIndex.dialog
|
|
45
|
-
},
|
|
46
|
-
paper: {
|
|
47
|
-
borderRadius: theme.shape.roundnessExtra,
|
|
48
|
-
margin,
|
|
49
|
-
maxWidth: DIALOG_MAX_WIDTH,
|
|
50
|
-
overflow: 'hidden',
|
|
51
|
-
width: dialogWidth
|
|
52
|
-
},
|
|
53
|
-
paperFullScreen: {
|
|
54
|
-
flexGrow: 1
|
|
55
|
-
},
|
|
56
|
-
animation: {},
|
|
57
|
-
animationFullScreen: {
|
|
58
|
-
width: '100%',
|
|
59
|
-
height: '100%'
|
|
60
|
-
},
|
|
61
|
-
topElementSize: {
|
|
62
|
-
marginHorizontal: margin,
|
|
63
|
-
maxWidth: DIALOG_MAX_WIDTH,
|
|
64
|
-
width: dialogWidth
|
|
65
|
-
},
|
|
66
|
-
topElementPosition: {
|
|
67
|
-
position: 'absolute',
|
|
68
|
-
bottom: -1 * theme.spacing(4),
|
|
69
|
-
width: '100%'
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
36
|
function Dialog(props) {
|
|
75
37
|
const {
|
|
76
38
|
animationType = _Modal.ANIMATION_TYPE.SLIDE,
|
|
@@ -78,12 +40,13 @@ function Dialog(props) {
|
|
|
78
40
|
fullScreen = false,
|
|
79
41
|
hideBackdrop,
|
|
80
42
|
onClose,
|
|
81
|
-
style
|
|
43
|
+
style: styleProp,
|
|
44
|
+
size = 'medium',
|
|
82
45
|
visible,
|
|
83
46
|
topElement,
|
|
84
47
|
...otherProps
|
|
85
48
|
} = props;
|
|
86
|
-
const styles =
|
|
49
|
+
const styles = (0, _useDialogStyle.default)(size, fullScreen);
|
|
87
50
|
const {
|
|
88
51
|
height: screenHeight
|
|
89
52
|
} = (0, _reactNative.useWindowDimensions)();
|
|
@@ -154,8 +117,21 @@ function Dialog(props) {
|
|
|
154
117
|
}, [animationType, fullScreen]);
|
|
155
118
|
const initialOpacity = animationType === _Modal.ANIMATION_TYPE.SLIDE && fullScreen ? 1 : undefined;
|
|
156
119
|
const initialTranslateY = animationType === _Modal.ANIMATION_TYPE.FADE ? 0 : undefined;
|
|
120
|
+
const paperStyle = (0, _styles.css)([styles.paper, styleProp]);
|
|
121
|
+
|
|
122
|
+
const contents = _react.Children.map(children, child => {
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
if (child.type === _DialogMedia.default) {
|
|
125
|
+
return (0, _utils.cloneElementSafely)(child, {
|
|
126
|
+
style: styles.mediaWrapper
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return child;
|
|
131
|
+
});
|
|
132
|
+
|
|
157
133
|
return /*#__PURE__*/_react.default.createElement(_Modal.default, _extends({
|
|
158
|
-
animationStyle:
|
|
134
|
+
animationStyle: styles.container,
|
|
159
135
|
closeAnimation: closeAnimation,
|
|
160
136
|
hideBackdrop: hideBackdrop || animationType === _Modal.ANIMATION_TYPE.FADE,
|
|
161
137
|
initialOpacity: initialOpacity,
|
|
@@ -166,15 +142,15 @@ function Dialog(props) {
|
|
|
166
142
|
visible: visible,
|
|
167
143
|
style: styles.root
|
|
168
144
|
}, otherProps), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, topElement ? /*#__PURE__*/_react.default.createElement(_Column.default, {
|
|
169
|
-
style: fullScreen ? undefined : styles.
|
|
145
|
+
style: fullScreen ? undefined : styles.topElementContainer
|
|
170
146
|
}, /*#__PURE__*/_react.default.createElement(_Column.default, {
|
|
171
|
-
style: styles.
|
|
147
|
+
style: styles.topElementContent,
|
|
172
148
|
onLayout: handleTopElementLayout
|
|
173
149
|
}, topElement)) : null, /*#__PURE__*/_react.default.createElement(_Paper.default, {
|
|
174
150
|
elevation: 6,
|
|
175
151
|
square: fullScreen,
|
|
176
|
-
style:
|
|
177
|
-
},
|
|
152
|
+
style: paperStyle
|
|
153
|
+
}, contents)));
|
|
178
154
|
}
|
|
179
155
|
|
|
180
156
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DIALOG_MAX_WIDTH","TOP_ELEMENT_OFFSET","useStyles","theme","useTheme","width","useWindowDimensions","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","ANIMATION_TYPE","SLIDE","children","fullScreen","hideBackdrop","onClose","style","visible","topElement","otherProps","styles","screenHeight","topElementHeight","setTopElementHeight","useState","handleTopElementLayout","event","nativeEvent","layout","offsetAnimation","useMemo","toValue","type","closeAnimation","FADE","duration","openAnimation","delay","initialOpacity","undefined","initialTranslateY","css"],"sources":["Dialog.tsx"],"sourcesContent":["import React, { useMemo, useState } from 'react';\nimport { LayoutChangeEvent, 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 TOP_ELEMENT_OFFSET = 20;\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 hideBackdrop,\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 [topElementHeight, setTopElementHeight] = useState(0);\n const handleTopElementLayout = (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setTopElementHeight(height);\n };\n\n const offsetAnimation = useMemo<AnimationUnit[]>(() => {\n if (topElementHeight === 0) {\n return [];\n }\n\n return [{\n toValue: (topElementHeight - TOP_ELEMENT_OFFSET) / 2,\n type: ANIMATION_TYPE.SLIDE,\n }]\n }, [topElementHeight]);\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 hideBackdrop={hideBackdrop || animationType === ANIMATION_TYPE.FADE}\n initialOpacity={initialOpacity}\n initialTranslateY={initialTranslateY}\n onClose={onClose}\n openAnimation={openAnimation}\n offsetAnimation={offsetAnimation}\n visible={visible}\n style={styles.root}\n {...otherProps}\n >\n <React.Fragment>\n {topElement ? (\n <Column style={fullScreen ? undefined : styles.topElementSize}>\n <Column\n style={styles.topElementPosition}\n onLayout={handleTopElementLayout}\n >\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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAcA,MAAMA,gBAAgB,GAAG,GAAzB;AAEA,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;MACHC,YAAY,EAAEb,KAAK,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Q,EAAEqB;EAFd,GAIKP,UAJL,CADJ,CADO,GASP,IAVR,eAYI,6BAAC,cAAD;IACI,SAAS,EAAE,CADf;IAEI,MAAM,EAAEL,UAFZ;IAGI,KAAK,EAAE,IAAA4B,WAAA,EAAI,CACP5B,UAAU,GAAGO,MAAM,CAACvB,eAAV,GAA4BuB,MAAM,CAAC7B,KADtC,EAEPyB,KAFO,CAAJ;EAHX,GAQKJ,QARL,CAZJ,CAbJ,CADJ;AAuCH;;AAAA"}
|
|
1
|
+
{"version":3,"names":["TOP_ELEMENT_OFFSET","Dialog","props","animationType","ANIMATION_TYPE","SLIDE","children","fullScreen","hideBackdrop","onClose","style","styleProp","size","visible","topElement","otherProps","styles","useDialogStyle","height","screenHeight","useWindowDimensions","topElementHeight","setTopElementHeight","useState","handleTopElementLayout","event","nativeEvent","layout","offsetAnimation","useMemo","toValue","type","closeAnimation","FADE","duration","openAnimation","delay","initialOpacity","undefined","initialTranslateY","paperStyle","css","paper","contents","Children","map","child","DialogMedia","cloneElementSafely","mediaWrapper","container","root","topElementContainer","topElementContent"],"sources":["Dialog.tsx"],"sourcesContent":["import React, { Children, useMemo, useState } from 'react';\nimport { LayoutChangeEvent, useWindowDimensions } from 'react-native';\nimport { css } from '@fountain-ui/styles';\nimport Column from '../Column';\nimport DialogMedia from '../DialogMedia/DialogMedia';\nimport Modal, { ANIMATION_TYPE, AnimationUnit } from '../Modal';\nimport Paper from '../Paper';\nimport { cloneElementSafely, FalsyReactElement } from '../utils';\nimport type DialogProps from './DialogProps';\nimport useDialogStyle from './useDialogStyle';\n\nconst TOP_ELEMENT_OFFSET = 20;\n\nexport default function Dialog(props: DialogProps) {\n const {\n animationType = ANIMATION_TYPE.SLIDE,\n children,\n fullScreen = false,\n hideBackdrop,\n onClose,\n style: styleProp,\n size = 'medium',\n visible,\n topElement,\n ...otherProps\n } = props;\n\n const styles = useDialogStyle(size, fullScreen);\n\n const { height: screenHeight } = useWindowDimensions();\n\n const [topElementHeight, setTopElementHeight] = useState(0);\n const handleTopElementLayout = (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setTopElementHeight(height);\n };\n\n const offsetAnimation = useMemo<AnimationUnit[]>(() => {\n if (topElementHeight === 0) {\n return [];\n }\n\n return [{\n toValue: (topElementHeight - TOP_ELEMENT_OFFSET) / 2,\n type: ANIMATION_TYPE.SLIDE,\n }];\n }, [topElementHeight]);\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 const paperStyle = css([\n styles.paper,\n styleProp,\n ]);\n\n const contents = Children.map(children, (child) => {\n // @ts-ignore\n if (child.type === DialogMedia) {\n return cloneElementSafely(child as FalsyReactElement, { style: styles.mediaWrapper });\n }\n return child;\n });\n\n return (\n <Modal\n animationStyle={styles.container}\n closeAnimation={closeAnimation}\n hideBackdrop={hideBackdrop || animationType === ANIMATION_TYPE.FADE}\n initialOpacity={initialOpacity}\n initialTranslateY={initialTranslateY}\n onClose={onClose}\n openAnimation={openAnimation}\n offsetAnimation={offsetAnimation}\n visible={visible}\n style={styles.root}\n {...otherProps}\n >\n <React.Fragment>\n {topElement ? (\n <Column style={fullScreen ? undefined : styles.topElementContainer}>\n <Column\n style={styles.topElementContent}\n onLayout={handleTopElementLayout}\n >\n {topElement}\n </Column>\n </Column>\n ) : null}\n\n <Paper\n elevation={6}\n square={fullScreen}\n style={paperStyle}\n >\n {contents}\n </Paper>\n </React.Fragment>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,MAAMA,kBAAkB,GAAG,EAA3B;;AAEe,SAASC,MAAT,CAAgBC,KAAhB,EAAoC;EAC/C,MAAM;IACFC,aAAa,GAAGC,qBAAA,CAAeC,KAD7B;IAEFC,QAFE;IAGFC,UAAU,GAAG,KAHX;IAIFC,YAJE;IAKFC,OALE;IAMFC,KAAK,EAAEC,SANL;IAOFC,IAAI,GAAG,QAPL;IAQFC,OARE;IASFC,UATE;IAUF,GAAGC;EAVD,IAWFb,KAXJ;EAaA,MAAMc,MAAM,GAAG,IAAAC,uBAAA,EAAeL,IAAf,EAAqBL,UAArB,CAAf;EAEA,MAAM;IAAEW,MAAM,EAAEC;EAAV,IAA2B,IAAAC,gCAAA,GAAjC;EAEA,MAAM,CAACC,gBAAD,EAAmBC,mBAAnB,IAA0C,IAAAC,eAAA,EAAS,CAAT,CAAhD;;EACA,MAAMC,sBAAsB,GAAIC,KAAD,IAA8B;IACzD,MAAM;MAAEP;IAAF,IAAaO,KAAK,CAACC,WAAN,CAAkBC,MAArC;IACAL,mBAAmB,CAACJ,MAAD,CAAnB;EACH,CAHD;;EAKA,MAAMU,eAAe,GAAG,IAAAC,cAA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BAAiB,EAAEE,iBALvB;IAMI,OAAO,EAAE9B,OANb;IAOI,aAAa,EAAE0B,aAPnB;IAQI,eAAe,EAAEP,eARrB;IASI,OAAO,EAAEf,OATb;IAUI,KAAK,EAAEG,MAAM,CAACmC;EAVlB,GAWQpC,UAXR,gBAaI,6BAAC,cAAD,CAAO,QAAP,QACKD,UAAU,gBACP,6BAAC,eAAD;IAAQ,KAAK,EAAEP,UAAU,GAAG+B,SAAH,GAAetB,MAAM,CAACoC;EAA/C,gBACI,6BAAC,eAAD;IACI,KAAK,EAAEpC,MAAM,CAACqC,iBADlB;IAEI,QAAQ,EAAE7B;EAFd,GAIKV,UAJL,CADJ,CADO,GASP,IAVR,eAYI,6BAAC,cAAD;IACI,SAAS,EAAE,CADf;IAEI,MAAM,EAAEP,UAFZ;IAGI,KAAK,EAAEiC;EAHX,GAKKG,QALL,CAZJ,CAbJ,CADJ;AAoCH;;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';\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":""}
|
|
1
|
+
{"version":3,"names":["dialogSizes"],"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 const dialogSizes = ['small', 'medium', 'large'] as const;\nexport type DialogSize = typeof dialogSizes[number];\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 * Determines the minWidth of the Dialog.\n * @default 'medium'\n */\n size?: DialogSize;\n\n /**\n * Top element for displaying additional information on the dialog.\n */\n topElement?: React.ReactNode;\n}> {}\n"],"mappings":";;;;;;AAKO,MAAMA,WAAW,GAAG,CAAC,OAAD,EAAU,QAAV,EAAoB,OAApB,CAApB"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Dialog;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _styles = require("@fountain-ui/styles");
|
|
13
|
+
|
|
14
|
+
var _Column = _interopRequireDefault(require("../Column"));
|
|
15
|
+
|
|
16
|
+
var _Modal = _interopRequireWildcard(require("../Modal"));
|
|
17
|
+
|
|
18
|
+
var _Paper = _interopRequireDefault(require("../Paper"));
|
|
19
|
+
|
|
20
|
+
var _styles2 = require("../styles");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
const DIALOG_MAX_WIDTH = 328;
|
|
31
|
+
const TOP_ELEMENT_OFFSET = 20;
|
|
32
|
+
|
|
33
|
+
const useStyles = function () {
|
|
34
|
+
const theme = (0, _styles2.useTheme)();
|
|
35
|
+
const {
|
|
36
|
+
width
|
|
37
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
38
|
+
const margin = theme.spacing(4);
|
|
39
|
+
const dialogWidth = width - margin * 2;
|
|
40
|
+
return {
|
|
41
|
+
root: {
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
zIndex: theme.zIndex.dialog
|
|
45
|
+
},
|
|
46
|
+
paper: {
|
|
47
|
+
borderRadius: theme.shape.roundnessExtra,
|
|
48
|
+
margin,
|
|
49
|
+
maxWidth: DIALOG_MAX_WIDTH,
|
|
50
|
+
overflow: 'hidden',
|
|
51
|
+
width: dialogWidth
|
|
52
|
+
},
|
|
53
|
+
paperFullScreen: {
|
|
54
|
+
flexGrow: 1
|
|
55
|
+
},
|
|
56
|
+
animation: {},
|
|
57
|
+
animationFullScreen: {
|
|
58
|
+
width: '100%',
|
|
59
|
+
height: '100%'
|
|
60
|
+
},
|
|
61
|
+
topElementSize: {
|
|
62
|
+
marginHorizontal: margin,
|
|
63
|
+
maxWidth: DIALOG_MAX_WIDTH,
|
|
64
|
+
width: dialogWidth
|
|
65
|
+
},
|
|
66
|
+
topElementPosition: {
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
bottom: -1 * theme.spacing(4),
|
|
69
|
+
width: '100%'
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function Dialog(props) {
|
|
75
|
+
const {
|
|
76
|
+
animationType = _Modal.ANIMATION_TYPE.SLIDE,
|
|
77
|
+
children,
|
|
78
|
+
fullScreen = false,
|
|
79
|
+
hideBackdrop,
|
|
80
|
+
onClose,
|
|
81
|
+
style = {},
|
|
82
|
+
visible,
|
|
83
|
+
topElement,
|
|
84
|
+
...otherProps
|
|
85
|
+
} = props;
|
|
86
|
+
const styles = useStyles();
|
|
87
|
+
const {
|
|
88
|
+
height: screenHeight
|
|
89
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
90
|
+
const [topElementHeight, setTopElementHeight] = (0, _react.useState)(0);
|
|
91
|
+
|
|
92
|
+
const handleTopElementLayout = event => {
|
|
93
|
+
const {
|
|
94
|
+
height
|
|
95
|
+
} = event.nativeEvent.layout;
|
|
96
|
+
setTopElementHeight(height);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const offsetAnimation = (0, _react.useMemo)(() => {
|
|
100
|
+
if (topElementHeight === 0) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return [{
|
|
105
|
+
toValue: (topElementHeight - TOP_ELEMENT_OFFSET) / 2,
|
|
106
|
+
type: _Modal.ANIMATION_TYPE.SLIDE
|
|
107
|
+
}];
|
|
108
|
+
}, [topElementHeight]);
|
|
109
|
+
const closeAnimation = (0, _react.useMemo)(() => {
|
|
110
|
+
if (animationType === _Modal.ANIMATION_TYPE.FADE) {
|
|
111
|
+
return [{
|
|
112
|
+
toValue: 0,
|
|
113
|
+
type: _Modal.ANIMATION_TYPE.FADE
|
|
114
|
+
}];
|
|
115
|
+
} else if (animationType === _Modal.ANIMATION_TYPE.SLIDE && !fullScreen) {
|
|
116
|
+
return [{
|
|
117
|
+
toValue: screenHeight,
|
|
118
|
+
type: _Modal.ANIMATION_TYPE.SLIDE
|
|
119
|
+
}, {
|
|
120
|
+
duration: 150,
|
|
121
|
+
toValue: 0,
|
|
122
|
+
type: _Modal.ANIMATION_TYPE.FADE
|
|
123
|
+
}];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return [{
|
|
127
|
+
duration: 150,
|
|
128
|
+
toValue: screenHeight,
|
|
129
|
+
type: _Modal.ANIMATION_TYPE.SLIDE
|
|
130
|
+
}];
|
|
131
|
+
}, [animationType, fullScreen, screenHeight]);
|
|
132
|
+
const openAnimation = (0, _react.useMemo)(() => {
|
|
133
|
+
if (animationType === _Modal.ANIMATION_TYPE.FADE) {
|
|
134
|
+
return [{
|
|
135
|
+
toValue: 1,
|
|
136
|
+
type: _Modal.ANIMATION_TYPE.FADE
|
|
137
|
+
}];
|
|
138
|
+
} else if (animationType === _Modal.ANIMATION_TYPE.SLIDE && !fullScreen) {
|
|
139
|
+
return [{
|
|
140
|
+
toValue: 0,
|
|
141
|
+
type: _Modal.ANIMATION_TYPE.SLIDE
|
|
142
|
+
}, {
|
|
143
|
+
delay: 50,
|
|
144
|
+
duration: 150,
|
|
145
|
+
toValue: 1,
|
|
146
|
+
type: _Modal.ANIMATION_TYPE.FADE
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return [{
|
|
151
|
+
toValue: 0,
|
|
152
|
+
type: _Modal.ANIMATION_TYPE.SLIDE
|
|
153
|
+
}];
|
|
154
|
+
}, [animationType, fullScreen]);
|
|
155
|
+
const initialOpacity = animationType === _Modal.ANIMATION_TYPE.SLIDE && fullScreen ? 1 : undefined;
|
|
156
|
+
const initialTranslateY = animationType === _Modal.ANIMATION_TYPE.FADE ? 0 : undefined;
|
|
157
|
+
return /*#__PURE__*/_react.default.createElement(_Modal.default, _extends({
|
|
158
|
+
animationStyle: fullScreen ? styles.animationFullScreen : styles.animation,
|
|
159
|
+
closeAnimation: closeAnimation,
|
|
160
|
+
hideBackdrop: hideBackdrop || animationType === _Modal.ANIMATION_TYPE.FADE,
|
|
161
|
+
initialOpacity: initialOpacity,
|
|
162
|
+
initialTranslateY: initialTranslateY,
|
|
163
|
+
onClose: onClose,
|
|
164
|
+
openAnimation: openAnimation,
|
|
165
|
+
offsetAnimation: offsetAnimation,
|
|
166
|
+
visible: visible,
|
|
167
|
+
style: styles.root
|
|
168
|
+
}, otherProps), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, topElement ? /*#__PURE__*/_react.default.createElement(_Column.default, {
|
|
169
|
+
style: fullScreen ? undefined : styles.topElementSize
|
|
170
|
+
}, /*#__PURE__*/_react.default.createElement(_Column.default, {
|
|
171
|
+
style: styles.topElementPosition,
|
|
172
|
+
onLayout: handleTopElementLayout
|
|
173
|
+
}, topElement)) : null, /*#__PURE__*/_react.default.createElement(_Paper.default, {
|
|
174
|
+
elevation: 6,
|
|
175
|
+
square: fullScreen,
|
|
176
|
+
style: (0, _styles.css)([fullScreen ? styles.paperFullScreen : styles.paper, style])
|
|
177
|
+
}, children)));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
;
|
|
181
|
+
//# sourceMappingURL=LegacyDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DIALOG_MAX_WIDTH","TOP_ELEMENT_OFFSET","useStyles","theme","useTheme","width","useWindowDimensions","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","ANIMATION_TYPE","SLIDE","children","fullScreen","hideBackdrop","onClose","style","visible","topElement","otherProps","styles","screenHeight","topElementHeight","setTopElementHeight","useState","handleTopElementLayout","event","nativeEvent","layout","offsetAnimation","useMemo","toValue","type","closeAnimation","FADE","duration","openAnimation","delay","initialOpacity","undefined","initialTranslateY","css"],"sources":["LegacyDialog.tsx"],"sourcesContent":["import React, { useMemo, useState } from 'react';\nimport { LayoutChangeEvent, 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 './LegacyDialogProps';\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 TOP_ELEMENT_OFFSET = 20;\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 hideBackdrop,\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 [topElementHeight, setTopElementHeight] = useState(0);\n const handleTopElementLayout = (event: LayoutChangeEvent) => {\n const { height } = event.nativeEvent.layout;\n setTopElementHeight(height);\n };\n\n const offsetAnimation = useMemo<AnimationUnit[]>(() => {\n if (topElementHeight === 0) {\n return [];\n }\n\n return [{\n toValue: (topElementHeight - TOP_ELEMENT_OFFSET) / 2,\n type: ANIMATION_TYPE.SLIDE,\n }];\n }, [topElementHeight]);\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 hideBackdrop={hideBackdrop || animationType === ANIMATION_TYPE.FADE}\n initialOpacity={initialOpacity}\n initialTranslateY={initialTranslateY}\n onClose={onClose}\n openAnimation={openAnimation}\n offsetAnimation={offsetAnimation}\n visible={visible}\n style={styles.root}\n {...otherProps}\n >\n <React.Fragment>\n {topElement ? (\n <Column style={fullScreen ? undefined : styles.topElementSize}>\n <Column\n style={styles.topElementPosition}\n onLayout={handleTopElementLayout}\n >\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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAcA,MAAMA,gBAAgB,GAAG,GAAzB;AAEA,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;MACHC,YAAY,EAAEb,KAAK,CAACc,KAAN,CAAYC,cADvB;MAEHX,MAFG;MAGHY,QAAQ,EAAEnB,gBAHP;MAIHoB,QAAQ,EAAE,QAJP;MAKHf,KAAK,EAAEI;IALJ,CANJ;IAaHY,eAAe,EAA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,WAAA,EAAI,CACP5B,UAAU,GAAGO,MAAM,CAACvB,eAAV,GAA4BuB,MAAM,CAAC7B,KADtC,EAEPyB,KAFO,CAAJ;EAHX,GAQKJ,QARL,CAZJ,CAbJ,CADJ;AAuCH;;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["LegacyDialogProps.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":""}
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _LegacyDialog.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _LegacyDialog = _interopRequireDefault(require("./LegacyDialog"));
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './LegacyDialog';\nexport type { default as DialogProps } from './LegacyDialogProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useDialogStyle;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _styles = require("../styles");
|
|
13
|
+
|
|
14
|
+
function useDialogStyle(size, fullScreen) {
|
|
15
|
+
const theme = (0, _styles.useTheme)();
|
|
16
|
+
const {
|
|
17
|
+
height: windowHeight,
|
|
18
|
+
width: windowWidth
|
|
19
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
20
|
+
return (0, _react.useMemo)(() => {
|
|
21
|
+
var _sizeStyleMap$size, _sizeStyleMap$size2;
|
|
22
|
+
|
|
23
|
+
const sizeStyleMap = {
|
|
24
|
+
small: {
|
|
25
|
+
maxWidth: 260,
|
|
26
|
+
paddingHorizontal: theme.spacing(6)
|
|
27
|
+
},
|
|
28
|
+
medium: {
|
|
29
|
+
maxWidth: 400,
|
|
30
|
+
// TODO: need to refactor breakpoints.
|
|
31
|
+
paddingHorizontal: theme.spacing(windowWidth >= 448 ? 8 : 6)
|
|
32
|
+
},
|
|
33
|
+
large: {
|
|
34
|
+
maxWidth: 512,
|
|
35
|
+
minHeight: 360,
|
|
36
|
+
paddingHorizontal: theme.spacing(8),
|
|
37
|
+
width: 512
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const marginVertical = theme.spacing(6);
|
|
41
|
+
const dialogMaxHeight = windowHeight - marginVertical * 2;
|
|
42
|
+
const paddingHorizontal = (_sizeStyleMap$size = sizeStyleMap[size]) === null || _sizeStyleMap$size === void 0 ? void 0 : _sizeStyleMap$size.paddingHorizontal;
|
|
43
|
+
const dialogMaxWidth = (_sizeStyleMap$size2 = sizeStyleMap[size]) === null || _sizeStyleMap$size2 === void 0 ? void 0 : _sizeStyleMap$size2.maxWidth;
|
|
44
|
+
return {
|
|
45
|
+
root: {
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
zIndex: theme.zIndex.dialog
|
|
49
|
+
},
|
|
50
|
+
container: fullScreen ? {
|
|
51
|
+
height: '100%',
|
|
52
|
+
width: '100%'
|
|
53
|
+
} : {
|
|
54
|
+
// TODO: need to refactor breakpoints.
|
|
55
|
+
marginHorizontal: theme.spacing(windowWidth > 320 ? 6 : 4)
|
|
56
|
+
},
|
|
57
|
+
paper: fullScreen ? {
|
|
58
|
+
flexGrow: 1
|
|
59
|
+
} : {
|
|
60
|
+
marginVertical,
|
|
61
|
+
maxHeight: dialogMaxHeight,
|
|
62
|
+
overflow: 'hidden',
|
|
63
|
+
width: '100%',
|
|
64
|
+
...sizeStyleMap[size]
|
|
65
|
+
},
|
|
66
|
+
topElementContainer: {
|
|
67
|
+
maxWidth: dialogMaxWidth,
|
|
68
|
+
width: '100%'
|
|
69
|
+
},
|
|
70
|
+
topElementContent: {
|
|
71
|
+
position: 'absolute',
|
|
72
|
+
bottom: -1 * theme.spacing(4),
|
|
73
|
+
width: '100%'
|
|
74
|
+
},
|
|
75
|
+
mediaWrapper: {
|
|
76
|
+
marginHorizontal: theme.spacing(4) - (paddingHorizontal ?? 0)
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}, [theme, windowHeight, windowWidth, size, fullScreen]);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=useDialogStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useDialogStyle","size","fullScreen","theme","useTheme","height","windowHeight","width","windowWidth","useWindowDimensions","useMemo","sizeStyleMap","small","maxWidth","paddingHorizontal","spacing","medium","large","minHeight","marginVertical","dialogMaxHeight","dialogMaxWidth","root","alignItems","justifyContent","zIndex","dialog","container","marginHorizontal","paper","flexGrow","maxHeight","overflow","topElementContainer","topElementContent","position","bottom","mediaWrapper"],"sources":["useDialogStyle.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { useWindowDimensions } from 'react-native';\nimport type { FountainUiStyle, NamedStylesStringUnion } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport type { DialogSize } from './DialogProps';\n\ntype SizeStyleMap = FountainUiStyle & {\n maxWidth: number;\n paddingHorizontal: number;\n}\n\ntype DialogStyleKeys =\n | 'root'\n | 'container'\n | 'paper'\n | 'topElementContainer'\n | 'topElementContent'\n | 'mediaWrapper';\n\ntype DialogStyles = NamedStylesStringUnion<DialogStyleKeys>;\n\nexport default function useDialogStyle(size: DialogSize, fullScreen: boolean): DialogStyles {\n const theme = useTheme();\n\n const {\n height: windowHeight,\n width: windowWidth,\n } = useWindowDimensions();\n\n return useMemo(() => {\n const sizeStyleMap: Record<DialogSize, SizeStyleMap> = {\n small: {\n maxWidth: 260,\n paddingHorizontal: theme.spacing(6),\n },\n medium: {\n maxWidth: 400,\n // TODO: need to refactor breakpoints.\n paddingHorizontal: theme.spacing(windowWidth >= 448 ? 8 : 6),\n },\n large: {\n maxWidth: 512,\n minHeight: 360,\n paddingHorizontal: theme.spacing(8),\n width: 512,\n },\n };\n\n const marginVertical = theme.spacing(6);\n const dialogMaxHeight = windowHeight - marginVertical * 2;\n const paddingHorizontal = sizeStyleMap[size]?.paddingHorizontal;\n const dialogMaxWidth = sizeStyleMap[size]?.maxWidth;\n\n return {\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n zIndex: theme.zIndex.dialog,\n },\n container: fullScreen ? {\n height: '100%',\n width: '100%',\n } : {\n // TODO: need to refactor breakpoints.\n marginHorizontal: theme.spacing(windowWidth > 320 ? 6 : 4),\n },\n paper: fullScreen ? {\n flexGrow: 1,\n } : {\n marginVertical,\n maxHeight: dialogMaxHeight,\n overflow: 'hidden',\n width: '100%',\n ...sizeStyleMap[size],\n },\n topElementContainer: {\n maxWidth: dialogMaxWidth,\n width: '100%',\n },\n topElementContent: {\n position: 'absolute',\n bottom: -1 * theme.spacing(4),\n width: '100%',\n },\n media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AAN,CAAaC;MAHnB,CADH;MAMHC,SAAS,EAAEzB,UAAU,GAAG;QACpBG,MAAM,EAAE,MADY;QAEpBE,KAAK,EAAE;MAFa,CAAH,GAGjB;QACA;QACAqB,gBAAgB,EAAEzB,KAAK,CAACY,OAAN,CAAcP,WAAW,GAAG,GAAd,GAAoB,CAApB,GAAwB,CAAtC;MAFlB,CATD;MAaHqB,KAAK,EAAE3B,UAAU,GAAG;QAChB4B,QAAQ,EAAE;MADM,CAAH,GAEb;QACAX,cADA;QAEAY,SAAS,EAAEX,eAFX;QAGAY,QAAQ,EAAE,QAHV;QAIAzB,KAAK,EAAE,MAJP;QAKA,GAAGI,YAAY,CAACV,IAAD;MALf,CAfD;MAsBHgC,mBAAmB,EAAE;QACjBpB,QAAQ,EAAEQ,cADO;QAEjBd,KAAK,EAAE;MAFU,CAtBlB;MA0BH2B,iBAAiB,EAAE;QACfC,QAAQ,EAAE,UADK;QAEfC,MAAM,EAAE,CAAC,CAAD,GAAKjC,KAAK,CAACY,OAAN,CAAc,CAAd,CAFE;QAGfR,KAAK,EAAE;MAHQ,CA1BhB;MA+BH8B,YAAY,EAAE;QACVT,gBAAgB,EAAEzB,KAAK,CAACY,OAAN,CAAc,CAAd,KAAoBD,iBAAiB,IAAI,CAAzC;MADR;IA/BX,CAAP;EAmCH,CA3DM,EA2DJ,CAACX,KAAD,EAAQG,YAAR,EAAsBE,WAAtB,EAAmCP,IAAnC,EAAyCC,UAAzC,CA3DI,CAAP;AA4DH"}
|
|
@@ -22,8 +22,8 @@ function DialogActions(props) {
|
|
|
22
22
|
} = props;
|
|
23
23
|
return /*#__PURE__*/_react.default.createElement(_Column.default, _extends({
|
|
24
24
|
alignItems: 'center',
|
|
25
|
-
insets: _styles.EdgeInsets.
|
|
26
|
-
}, otherProps),
|
|
25
|
+
insets: _styles.EdgeInsets.fromLTRB(0, 2, 0, 4)
|
|
26
|
+
}, otherProps), children);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DialogActions","props","children","otherProps","EdgeInsets","
|
|
1
|
+
{"version":3,"names":["DialogActions","props","children","otherProps","EdgeInsets","fromLTRB"],"sources":["DialogActions.tsx"],"sourcesContent":["import React from 'react';\nimport Column from '../Column';\nimport { EdgeInsets } from '../styles';\nimport type DialogActionsProps from './DialogActionsProps';\n\nexport default function DialogActions(props: DialogActionsProps) {\n const {\n children,\n ...otherProps\n } = props;\n\n return (\n <Column\n alignItems={'center'}\n insets={EdgeInsets.fromLTRB(0, 2, 0, 4)}\n {...otherProps}\n >\n {children}\n </Column>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAGe,SAASA,aAAT,CAAuBC,KAAvB,EAAkD;EAC7D,MAAM;IACFC,QADE;IAEF,GAAGC;EAFD,IAGFF,KAHJ;EAKA,oBACI,6BAAC,eAAD;IACI,UAAU,EAAE,QADhB;IAEI,MAAM,EAAEG,kBAAA,CAAWC,QAAX,CAAoB,CAApB,EAAuB,CAAvB,EAA0B,CAA1B,EAA6B,CAA7B;EAFZ,GAGQF,UAHR,GAKKD,QALL,CADJ;AASH;;AAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = DialogActions;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _Column = _interopRequireDefault(require("../Column"));
|
|
11
|
+
|
|
12
|
+
var _styles = require("../styles");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
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); }
|
|
17
|
+
|
|
18
|
+
function DialogActions(props) {
|
|
19
|
+
const {
|
|
20
|
+
children,
|
|
21
|
+
...otherProps
|
|
22
|
+
} = props;
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(_Column.default, _extends({
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
insets: _styles.EdgeInsets.all(6)
|
|
26
|
+
}, otherProps), /*#__PURE__*/_react.default.createElement(_Column.default, null, children));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
;
|
|
30
|
+
//# sourceMappingURL=LegacyDialogActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DialogActions","props","children","otherProps","EdgeInsets","all"],"sources":["LegacyDialogActions.tsx"],"sourcesContent":["import React from 'react';\nimport Column from '../Column';\nimport { EdgeInsets } from '../styles';\nimport type DialogActionsProps from './DialogActionsProps';\n\nexport default function DialogActions(props: DialogActionsProps) {\n const {\n children,\n ...otherProps\n } = props;\n\n return (\n <Column\n alignItems={'center'}\n insets={EdgeInsets.all(6)}\n {...otherProps}\n >\n <Column>\n {children}\n </Column>\n </Column>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAGe,SAASA,aAAT,CAAuBC,KAAvB,EAAkD;EAC7D,MAAM;IACFC,QADE;IAEF,GAAGC;EAFD,IAGFF,KAHJ;EAKA,oBACI,6BAAC,eAAD;IACI,UAAU,EAAE,QADhB;IAEI,MAAM,EAAEG,kBAAA,CAAWC,GAAX,CAAe,CAAf;EAFZ,GAGQF,UAHR,gBAKI,6BAAC,eAAD,QACKD,QADL,CALJ,CADJ;AAWH;;AAAA"}
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _LegacyDialogActions.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _LegacyDialogActions = _interopRequireDefault(require("./LegacyDialogActions"));
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './LegacyDialogActions';\nexport type { default as DialogActionsProps } from './DialogActionsProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|