@cleartrip/ct-design-bottomsheet 2.0.0 → 4.0.0-SNAPSHOT-rnfinaltest.0
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/README.md +70 -0
- package/dist/BottomSheet.d.ts +6 -1
- package/dist/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheetHeader/BottomSheetHeader.d.ts +1 -4
- package/dist/BottomSheetHeader/BottomSheetHeader.d.ts.map +1 -1
- package/dist/NativeBottomSheet/BottomSheetNativeComponent/Cross.d.ts +8 -0
- package/dist/NativeBottomSheet/BottomSheetNativeComponent/Cross.d.ts.map +1 -0
- package/dist/NativeBottomSheet/BottomSheetNativeComponent/index.d.ts +30 -0
- package/dist/NativeBottomSheet/BottomSheetNativeComponent/index.d.ts.map +1 -0
- package/dist/NativeBottomSheet/BottomSheetPortal.d.ts +15 -0
- package/dist/NativeBottomSheet/BottomSheetPortal.d.ts.map +1 -0
- package/dist/NativeBottomSheet/Portal.d.ts +9 -0
- package/dist/NativeBottomSheet/Portal.d.ts.map +1 -0
- package/dist/NativeBottomSheet/style.d.ts +27 -0
- package/dist/NativeBottomSheet/style.d.ts.map +1 -0
- package/dist/NativeBottomSheet/useNativeBottomSheetPortal.d.ts +9 -0
- package/dist/NativeBottomSheet/useNativeBottomSheetPortal.d.ts.map +1 -0
- package/dist/ct-design-bottomsheet.browser.cjs.js +1 -1
- package/dist/ct-design-bottomsheet.browser.cjs.js.map +1 -1
- package/dist/ct-design-bottomsheet.browser.esm.js +1 -1
- package/dist/ct-design-bottomsheet.browser.esm.js.map +1 -1
- package/dist/ct-design-bottomsheet.cjs.js +177 -40
- package/dist/ct-design-bottomsheet.cjs.js.map +1 -1
- package/dist/ct-design-bottomsheet.esm.js +178 -42
- package/dist/ct-design-bottomsheet.esm.js.map +1 -1
- package/dist/ct-design-bottomsheet.umd.js +1816 -598
- package/dist/ct-design-bottomsheet.umd.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/type.d.ts +65 -18
- package/dist/type.d.ts.map +1 -1
- package/package.json +34 -17
- package/src/BottomSheet.tsx +269 -0
- package/src/BottomSheetHeader/BottomSheetHeader.tsx +110 -0
- package/src/NativeBottomSheet/BottomSheetNativeComponent/Cross.tsx +8 -0
- package/src/NativeBottomSheet/BottomSheetNativeComponent/index.tsx +338 -0
- package/src/NativeBottomSheet/BottomSheetPortal.tsx +36 -0
- package/src/NativeBottomSheet/Portal.tsx +70 -0
- package/src/NativeBottomSheet/style.ts +29 -0
- package/src/NativeBottomSheet/useNativeBottomSheetPortal.tsx +26 -0
- package/src/index.ts +3 -0
- package/src/type.ts +173 -0
- package/dist/style.d.ts +0 -7
- package/dist/style.d.ts.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tslib = require('tslib');
|
|
4
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
4
|
var ctDesignContainer = require('@cleartrip/ct-design-container');
|
|
6
5
|
var ctDesignOutsideClickHandler = require('@cleartrip/ct-design-outside-click-handler');
|
|
@@ -10,87 +9,225 @@ var ctDesignTransition = require('@cleartrip/ct-design-transition');
|
|
|
10
9
|
var react = require('react');
|
|
11
10
|
var ctDesignIcons = require('@cleartrip/ct-design-icons');
|
|
12
11
|
var ctDesignTheme = require('@cleartrip/ct-design-theme');
|
|
12
|
+
var ctDesignStyleManager = require('@cleartrip/ct-design-style-manager');
|
|
13
|
+
var css = require('@emotion/css');
|
|
14
|
+
var ctDesignBaseDragger = require('@cleartrip/ct-design-base-dragger');
|
|
13
15
|
|
|
16
|
+
exports.BottomSheetSnapPoint = void 0;
|
|
17
|
+
(function (BottomSheetSnapPoint) {
|
|
18
|
+
BottomSheetSnapPoint[BottomSheetSnapPoint["Hidden"] = 0] = "Hidden";
|
|
19
|
+
BottomSheetSnapPoint[BottomSheetSnapPoint["Partial"] = 1] = "Partial";
|
|
20
|
+
BottomSheetSnapPoint[BottomSheetSnapPoint["Full"] = 2] = "Full";
|
|
21
|
+
})(exports.BottomSheetSnapPoint || (exports.BottomSheetSnapPoint = {}));
|
|
14
22
|
exports.DIRECTION = void 0;
|
|
15
23
|
(function (DIRECTION) {
|
|
16
24
|
DIRECTION["DOWN"] = "down";
|
|
17
25
|
DIRECTION["UP"] = "up";
|
|
26
|
+
DIRECTION["LEFT"] = "left";
|
|
27
|
+
DIRECTION["RIGHT"] = "right";
|
|
18
28
|
})(exports.DIRECTION || (exports.DIRECTION = {}));
|
|
19
29
|
|
|
20
|
-
var getCloseButtonStyle = function (_a) {
|
|
21
|
-
var theme = _a.theme, _b = _a.isTop, isTop = _b === void 0 ? true : _b;
|
|
22
|
-
return (tslib.__assign({ position: 'absolute', right: '10px', backgroundColor: 'white', height: theme.size[8], width: theme.size[8], display: 'flex', alignItems: 'center', padding: theme.spacing[1], borderRadius: theme.border.radius['50P'], cursor: 'pointer', justifyContent: 'center' }, (isTop ? { top: '-44px' } : { bottom: '-44px' })));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
30
|
var CLOSE_ICON_TYPE;
|
|
26
31
|
(function (CLOSE_ICON_TYPE) {
|
|
27
32
|
CLOSE_ICON_TYPE["CROSS"] = "CROSS";
|
|
28
33
|
CLOSE_ICON_TYPE["BACK"] = "BACK";
|
|
29
34
|
})(CLOSE_ICON_TYPE || (CLOSE_ICON_TYPE = {}));
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const staticBottomSheetHeaderStyles = ctDesignStyleManager.makeStyles((theme) => {
|
|
36
|
+
return {
|
|
37
|
+
headerContainer: {
|
|
38
|
+
backgroundColor: theme.color.background.neutral,
|
|
39
|
+
zIndex: theme.zIndex.bottomSheet,
|
|
40
|
+
},
|
|
41
|
+
headerContainerWithBorderRadius: {
|
|
42
|
+
backgroundColor: theme.color.background.neutral,
|
|
43
|
+
zIndex: theme.zIndex.bottomSheet,
|
|
44
|
+
borderTopLeftRadius: theme.border.radius[16],
|
|
45
|
+
borderTopRightRadius: theme.border.radius[16],
|
|
46
|
+
},
|
|
47
|
+
closeButton: {
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
right: theme.spacing[2],
|
|
50
|
+
backgroundColor: theme.color.background.neutral,
|
|
51
|
+
height: theme.size[8],
|
|
52
|
+
width: theme.size[8],
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
padding: theme.spacing[1],
|
|
56
|
+
borderRadius: theme.border.radius[32],
|
|
57
|
+
cursor: 'pointer',
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
const BottomSheetHeader = (props) => {
|
|
63
|
+
const { handleClose, styleConfig, isBack, children, showBorderRadius = true, hideHeaderDismissIcon = false, direction = exports.DIRECTION.DOWN, } = props;
|
|
64
|
+
const theme = ctDesignTheme.useTheme();
|
|
65
|
+
const { headerContainer: customHeaderContainerStyles = [], closeButton: customCloseButtonStyles = [] } = styleConfig || {};
|
|
66
|
+
const isTop = direction === exports.DIRECTION.DOWN;
|
|
67
|
+
const dynamicCloseButtonStyles = ctDesignStyleManager.useStyles((theme) => {
|
|
68
|
+
return {
|
|
69
|
+
closeButton: Object.assign({}, (isTop ? { top: -theme.spacing[10] } : { bottom: -theme.spacing[10] })),
|
|
70
|
+
};
|
|
71
|
+
}, [isTop]);
|
|
72
|
+
const getCloseIcon = (isBack = false) => {
|
|
73
|
+
if (hideHeaderDismissIcon) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
37
76
|
if (isBack) {
|
|
38
77
|
return jsxRuntime.jsx(ctDesignIcons.ModalBack, {});
|
|
39
78
|
}
|
|
40
79
|
return jsxRuntime.jsx(ctDesignIcons.Cross, { height: 24, width: 24, crossColor: theme.color.background.primary });
|
|
41
80
|
};
|
|
42
|
-
|
|
43
|
-
return (jsxRuntime.jsxs(ctDesignContainer.Container,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
81
|
+
const CloseIcon = getCloseIcon(isBack);
|
|
82
|
+
return (jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: {
|
|
83
|
+
root: [
|
|
84
|
+
showBorderRadius && direction === exports.DIRECTION.DOWN
|
|
85
|
+
? staticBottomSheetHeaderStyles.headerContainerWithBorderRadius
|
|
86
|
+
: staticBottomSheetHeaderStyles.headerContainer,
|
|
87
|
+
...customHeaderContainerStyles,
|
|
88
|
+
],
|
|
89
|
+
}, children: [jsxRuntime.jsx(ctDesignContainer.Container, { styleConfig: {
|
|
90
|
+
root: [
|
|
91
|
+
staticBottomSheetHeaderStyles.closeButton,
|
|
92
|
+
dynamicCloseButtonStyles.closeButton,
|
|
93
|
+
...customCloseButtonStyles,
|
|
94
|
+
],
|
|
95
|
+
}, onClick: handleClose, children: CloseIcon }), children] }));
|
|
48
96
|
};
|
|
49
|
-
BottomSheetHeader.defaultProps = {};
|
|
50
97
|
|
|
51
|
-
|
|
98
|
+
const slideDirection = {
|
|
52
99
|
up: 'down',
|
|
53
100
|
down: 'up',
|
|
54
101
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
102
|
+
const staticBottomSheetStyles = ctDesignStyleManager.makeStyles((theme) => {
|
|
103
|
+
return {
|
|
104
|
+
bottomSheetContainer: {
|
|
105
|
+
position: 'relative',
|
|
106
|
+
width: '100%',
|
|
107
|
+
display: 'flex',
|
|
108
|
+
flexDirection: 'column',
|
|
109
|
+
maxHeight: 'calc(var(--mvh) * 92)',
|
|
110
|
+
boxShadow: theme.elevation.bottomE2,
|
|
111
|
+
},
|
|
112
|
+
overlayWrapper: {
|
|
113
|
+
top: 0,
|
|
114
|
+
left: 0,
|
|
115
|
+
right: 0,
|
|
116
|
+
bottom: 0,
|
|
117
|
+
display: 'flex',
|
|
118
|
+
flexDirection: 'column',
|
|
119
|
+
justifyContent: 'flex-end',
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
const webStaticBottomSheetStyles = css.css({
|
|
124
|
+
position: 'fixed',
|
|
125
|
+
});
|
|
126
|
+
const handleWindowResize = () => {
|
|
127
|
+
const vh = window.innerHeight * 0.01;
|
|
128
|
+
document.documentElement.style.setProperty('--mvh', `${vh}px`);
|
|
58
129
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var theme = ctDesignTheme.useTheme();
|
|
63
|
-
react.useEffect(function () {
|
|
130
|
+
const BottomSheet = ({ open, onDismiss, backgroundColor: backdropColor, containerSheetBackgroundColor = 'white', cornerRadius = 16, showCloseButton = true, showBackButton = false, showBackdrop = true, children, header, direction = exports.DIRECTION.DOWN, transitionDuration: timeout = 250, allowedBackdropClose = true, styleConfig = {}, disableOutSideClick = false, disablePortal = false, draggableConfig, }) => {
|
|
131
|
+
const [isVisible, setIsVisible] = react.useState(open);
|
|
132
|
+
react.useEffect(() => {
|
|
64
133
|
handleWindowResize();
|
|
65
134
|
window.addEventListener('resize', handleWindowResize);
|
|
66
|
-
return
|
|
135
|
+
return () => {
|
|
67
136
|
window.removeEventListener('resize', handleWindowResize);
|
|
68
137
|
};
|
|
69
138
|
}, []);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var handleCloseBottomSheet = function (event) {
|
|
139
|
+
const { bottomSheetContainer: customBottomSheetContainerStyles = [], overlayWrapper: customOverlayWrapperStyles = [], } = styleConfig || {};
|
|
140
|
+
const handleCloseBottomSheet = (event) => {
|
|
73
141
|
if (disableOutSideClick)
|
|
74
142
|
return;
|
|
75
143
|
event.preventDefault();
|
|
76
|
-
if (allowedBackdropClose &&
|
|
77
|
-
|
|
144
|
+
if (allowedBackdropClose && onDismiss) {
|
|
145
|
+
onDismiss({ isClosedByOutSideClick: true });
|
|
78
146
|
}
|
|
79
147
|
};
|
|
80
|
-
|
|
148
|
+
const handleExited = () => {
|
|
81
149
|
setIsVisible(false);
|
|
82
150
|
};
|
|
83
|
-
|
|
84
|
-
|
|
151
|
+
const handleClose = () => {
|
|
152
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
153
|
+
};
|
|
154
|
+
react.useEffect(() => {
|
|
155
|
+
if (open) {
|
|
85
156
|
setIsVisible(true);
|
|
86
157
|
}
|
|
87
|
-
}, [
|
|
158
|
+
}, [open]);
|
|
159
|
+
const dynamicBottomSheetContainerStyles = ctDesignStyleManager.useStyles(() => {
|
|
160
|
+
return {
|
|
161
|
+
bottomSheetContainer: Object.assign(Object.assign({}, ((draggableConfig === null || draggableConfig === void 0 ? void 0 : draggableConfig.isDraggable) ? { height: undefined } : {})), { backgroundColor: containerSheetBackgroundColor, borderTopLeftRadius: cornerRadius, borderTopRightRadius: cornerRadius }),
|
|
162
|
+
};
|
|
163
|
+
}, [draggableConfig === null || draggableConfig === void 0 ? void 0 : draggableConfig.isDraggable, containerSheetBackgroundColor, cornerRadius]);
|
|
164
|
+
const dynamicOverlayWrapperStyles = ctDesignStyleManager.useStyles((theme) => {
|
|
165
|
+
return {
|
|
166
|
+
overlayWrapper: Object.assign({ zIndex: theme.zIndex.bottomSheet, alignItems: exports.DIRECTION.DOWN ? 'flex-end' : 'flex-start', backgroundColor: backdropColor || (!showBackdrop ? 'transparent' : undefined) }, (!showBackdrop
|
|
167
|
+
? {
|
|
168
|
+
boxShadow: '0px -4px 16px 0px rgba(26, 26, 26, 0.08)',
|
|
169
|
+
}
|
|
170
|
+
: {})),
|
|
171
|
+
};
|
|
172
|
+
}, [showBackdrop, backdropColor, direction]);
|
|
173
|
+
const renderBottomsheetHeader = () => {
|
|
174
|
+
const headerComponent = (jsxRuntime.jsx(BottomSheetHeader, { direction: direction, showBorderRadius: cornerRadius > 0, handleClose: handleClose, isBack: showBackButton, children: header, hideHeaderDismissIcon: !showCloseButton }));
|
|
175
|
+
if (draggableConfig === null || draggableConfig === void 0 ? void 0 : draggableConfig.isDraggable) {
|
|
176
|
+
return jsxRuntime.jsx(ctDesignBaseDragger.BaseDraggerHeader, { children: headerComponent });
|
|
177
|
+
}
|
|
178
|
+
return headerComponent;
|
|
179
|
+
};
|
|
180
|
+
const renderBottomsheetWithTransition = ({ ref, onReactTransitionGroupEnd, }) => {
|
|
181
|
+
return (jsxRuntime.jsx(ctDesignTransition.Transition, { type: 'slide', slideDirection: slideDirection[direction], timeout: timeout, mountOnEnter: true, unmountOnExit: true, appear: true, in: open, onExited: handleExited, onEntered: () => {
|
|
182
|
+
onReactTransitionGroupEnd && onReactTransitionGroupEnd();
|
|
183
|
+
}, children: jsxRuntime.jsx("div", { ref: ref, children: jsxRuntime.jsxs(ctDesignContainer.Container, { styleConfig: {
|
|
184
|
+
root: [
|
|
185
|
+
staticBottomSheetStyles.bottomSheetContainer,
|
|
186
|
+
dynamicBottomSheetContainerStyles.bottomSheetContainer,
|
|
187
|
+
...customBottomSheetContainerStyles,
|
|
188
|
+
],
|
|
189
|
+
}, children: [showCloseButton && renderBottomsheetHeader(), children] }) }) }));
|
|
190
|
+
};
|
|
191
|
+
const renderBottomsheetWithDragger = () => {
|
|
192
|
+
if (draggableConfig === null || draggableConfig === void 0 ? void 0 : draggableConfig.isDraggable) {
|
|
193
|
+
return (jsxRuntime.jsx(ctDesignBaseDragger.BaseDragger, Object.assign({ isWrappedWithTransitionGroup: true }, draggableConfig, { isVisible: open, children: ({ ref, onReactTransitionGroupEnd }) => {
|
|
194
|
+
return renderBottomsheetWithTransition({ ref, onReactTransitionGroupEnd });
|
|
195
|
+
} })));
|
|
196
|
+
}
|
|
197
|
+
return renderBottomsheetWithTransition({});
|
|
198
|
+
};
|
|
199
|
+
const renderBottomsheetWithOutsideClickHandler = () => {
|
|
200
|
+
return (jsxRuntime.jsx(ctDesignOutsideClickHandler.OutsideClickHandler, { disabled: disableOutSideClick, onOutsideClick: handleCloseBottomSheet, wrapperProps: { style: { width: '100%' } }, children: renderBottomsheetWithDragger() }));
|
|
201
|
+
};
|
|
202
|
+
const renderBottomsheetWithOverlay = () => {
|
|
203
|
+
return (jsxRuntime.jsx(ctDesignOverlay.Overlay, { blur: showBackdrop, styleConfig: {
|
|
204
|
+
root: [
|
|
205
|
+
staticBottomSheetStyles.overlayWrapper,
|
|
206
|
+
webStaticBottomSheetStyles,
|
|
207
|
+
dynamicOverlayWrapperStyles.overlayWrapper,
|
|
208
|
+
...customOverlayWrapperStyles,
|
|
209
|
+
],
|
|
210
|
+
}, children: renderBottomsheetWithOutsideClickHandler() }));
|
|
211
|
+
};
|
|
88
212
|
if (isVisible) {
|
|
89
|
-
|
|
213
|
+
if (disablePortal) {
|
|
214
|
+
return renderBottomsheetWithOverlay();
|
|
215
|
+
}
|
|
216
|
+
return jsxRuntime.jsx(ctDesignPortal.Portal, { id: 'bottomsheet', children: renderBottomsheetWithOverlay() });
|
|
90
217
|
}
|
|
91
218
|
return null;
|
|
92
219
|
};
|
|
220
|
+
class BottomSheetComponent extends react.Component {
|
|
221
|
+
dismiss() {
|
|
222
|
+
var _a, _b;
|
|
223
|
+
(_b = (_a = this.props).onDismiss) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
224
|
+
}
|
|
225
|
+
render() {
|
|
226
|
+
return jsxRuntime.jsx(BottomSheet, Object.assign({}, this.props));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
93
229
|
|
|
94
230
|
exports.BottomSheet = BottomSheet;
|
|
231
|
+
exports.BottomSheetComponent = BottomSheetComponent;
|
|
95
232
|
exports.BottomSheetHeader = BottomSheetHeader;
|
|
96
233
|
//# sourceMappingURL=ct-design-bottomsheet.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-design-bottomsheet.cjs.js","sources":["../packages/components/Bottomsheet/src/type.ts","../packages/components/Bottomsheet/src/
|
|
1
|
+
{"version":3,"file":"ct-design-bottomsheet.cjs.js","sources":["../packages/components/Bottomsheet/src/type.ts","../packages/components/Bottomsheet/src/BottomSheetHeader/BottomSheetHeader.tsx","../packages/components/Bottomsheet/src/BottomSheet.tsx"],"sourcesContent":[null,null,null],"names":["BottomSheetSnapPoint","DIRECTION","makeStyles","useTheme","useStyles","_jsx","ModalBack","Cross","_jsxs","Container","css","useState","useEffect","BaseDraggerHeader","Transition","BaseDragger","OutsideClickHandler","Overlay","Portal","Component"],"mappings":";;;;;;;;;;;;;;;AAMYA,sCAIX;AAJD,CAAA,UAAY,oBAAoB,EAAA;AAC9B,IAAA,oBAAA,CAAA,oBAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAM,CAAA;AACN,IAAA,oBAAA,CAAA,oBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAO,CAAA;AACP,IAAA,oBAAA,CAAA,oBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAI,CAAA;AACN,CAAC,EAJWA,4BAAoB,KAApBA,4BAAoB,GAI/B,EAAA,CAAA,CAAA,CAAA;AA6JiBC,2BAKjB;AALD,CAAA,UAAkB,SAAS,EAAA;AACzB,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,SAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;AACT,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACjB,CAAC,EALiBA,iBAAS,KAATA,iBAAS,GAK1B,EAAA,CAAA,CAAA;;ACrKD,IAAkB,eAGjB,CAAA;AAHD,CAAA,UAAkB,eAAe,EAAA;AAC/B,IAAA,eAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,eAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACf,CAAC,EAHiB,eAAe,KAAf,eAAe,GAGhC,EAAA,CAAA,CAAA,CAAA;AAED,MAAM,6BAA6B,GAAGC,+BAAU,CAAC,CAAC,KAAK,KAAI;IACzD,OAAO;AACL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I,EAAE;AACJ,oBAAA,uBAAuB,CAAC,cAAc;oBAEtC,0BAA0B;AAC1B,oBAAA,2BAA2B,CAAC,cAAc;AAC1C,oBAAA,GAAG,0BAA0B;AAC9B,iBAAA;AACF,aAAA,EAAA,QAAA,EAEA,wCAAwC,EAAE,EACnC,CAAA,EACV;AACJ,KAAC,CAAC;IAEF,IAAI,SAAS,EAAE;QACb,IAAI,aAAa,EAAE;YACjB,OAAO,4BAA4B,EAAE,CAAC;SACvC;QACD,OAAOZ,cAAA,CAACa,qBAAM,EAAA,EAAC,EAAE,EAAC,aAAa,EAAE,QAAA,EAAA,4BAA4B,EAAE,EAAA,CAAU,CAAC;KAC3E;AACD,IAAA,OAAO,IAAI,CAAC;AACd,EAAE;AAEI,MAAO,oBAAqB,SAAQC,eAAqC,CAAA;IAC7E,OAAO,GAAA;;AACL,QAAA,CAAA,EAAA,GAAA,MAAA,IAAI,CAAC,KAAK,EAAC,SAAS,kDAAI,CAAC;KAC1B;IACD,MAAM,GAAA;AACJ,QAAA,OAAOd,eAAC,WAAW,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,IAAI,CAAC,KAAK,EAAI,CAAC;KACxC;AACF;;;;;;"}
|
|
@@ -1,93 +1,229 @@
|
|
|
1
|
-
import { __assign } from 'tslib';
|
|
2
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
2
|
import { Container } from '@cleartrip/ct-design-container';
|
|
4
3
|
import { OutsideClickHandler } from '@cleartrip/ct-design-outside-click-handler';
|
|
5
4
|
import { Overlay } from '@cleartrip/ct-design-overlay';
|
|
6
5
|
import { Portal } from '@cleartrip/ct-design-portal';
|
|
7
6
|
import { Transition } from '@cleartrip/ct-design-transition';
|
|
8
|
-
import { useState, useEffect } from 'react';
|
|
7
|
+
import { useState, useEffect, Component } from 'react';
|
|
9
8
|
import { ModalBack, Cross } from '@cleartrip/ct-design-icons';
|
|
10
9
|
import { useTheme } from '@cleartrip/ct-design-theme';
|
|
10
|
+
import { makeStyles, useStyles } from '@cleartrip/ct-design-style-manager';
|
|
11
|
+
import { css } from '@emotion/css';
|
|
12
|
+
import { BaseDragger, BaseDraggerHeader } from '@cleartrip/ct-design-base-dragger';
|
|
11
13
|
|
|
14
|
+
var BottomSheetSnapPoint;
|
|
15
|
+
(function (BottomSheetSnapPoint) {
|
|
16
|
+
BottomSheetSnapPoint[BottomSheetSnapPoint["Hidden"] = 0] = "Hidden";
|
|
17
|
+
BottomSheetSnapPoint[BottomSheetSnapPoint["Partial"] = 1] = "Partial";
|
|
18
|
+
BottomSheetSnapPoint[BottomSheetSnapPoint["Full"] = 2] = "Full";
|
|
19
|
+
})(BottomSheetSnapPoint || (BottomSheetSnapPoint = {}));
|
|
12
20
|
var DIRECTION;
|
|
13
21
|
(function (DIRECTION) {
|
|
14
22
|
DIRECTION["DOWN"] = "down";
|
|
15
23
|
DIRECTION["UP"] = "up";
|
|
24
|
+
DIRECTION["LEFT"] = "left";
|
|
25
|
+
DIRECTION["RIGHT"] = "right";
|
|
16
26
|
})(DIRECTION || (DIRECTION = {}));
|
|
17
27
|
|
|
18
|
-
var getCloseButtonStyle = function (_a) {
|
|
19
|
-
var theme = _a.theme, _b = _a.isTop, isTop = _b === void 0 ? true : _b;
|
|
20
|
-
return (__assign({ position: 'absolute', right: '10px', backgroundColor: 'white', height: theme.size[8], width: theme.size[8], display: 'flex', alignItems: 'center', padding: theme.spacing[1], borderRadius: theme.border.radius['50P'], cursor: 'pointer', justifyContent: 'center' }, (isTop ? { top: '-44px' } : { bottom: '-44px' })));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
28
|
var CLOSE_ICON_TYPE;
|
|
24
29
|
(function (CLOSE_ICON_TYPE) {
|
|
25
30
|
CLOSE_ICON_TYPE["CROSS"] = "CROSS";
|
|
26
31
|
CLOSE_ICON_TYPE["BACK"] = "BACK";
|
|
27
32
|
})(CLOSE_ICON_TYPE || (CLOSE_ICON_TYPE = {}));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const staticBottomSheetHeaderStyles = makeStyles((theme) => {
|
|
34
|
+
return {
|
|
35
|
+
headerContainer: {
|
|
36
|
+
backgroundColor: theme.color.background.neutral,
|
|
37
|
+
zIndex: theme.zIndex.bottomSheet,
|
|
38
|
+
},
|
|
39
|
+
headerContainerWithBorderRadius: {
|
|
40
|
+
backgroundColor: theme.color.background.neutral,
|
|
41
|
+
zIndex: theme.zIndex.bottomSheet,
|
|
42
|
+
borderTopLeftRadius: theme.border.radius[16],
|
|
43
|
+
borderTopRightRadius: theme.border.radius[16],
|
|
44
|
+
},
|
|
45
|
+
closeButton: {
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
right: theme.spacing[2],
|
|
48
|
+
backgroundColor: theme.color.background.neutral,
|
|
49
|
+
height: theme.size[8],
|
|
50
|
+
width: theme.size[8],
|
|
51
|
+
display: 'flex',
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
padding: theme.spacing[1],
|
|
54
|
+
borderRadius: theme.border.radius[32],
|
|
55
|
+
cursor: 'pointer',
|
|
56
|
+
justifyContent: 'center',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
const BottomSheetHeader = (props) => {
|
|
61
|
+
const { handleClose, styleConfig, isBack, children, showBorderRadius = true, hideHeaderDismissIcon = false, direction = DIRECTION.DOWN, } = props;
|
|
62
|
+
const theme = useTheme();
|
|
63
|
+
const { headerContainer: customHeaderContainerStyles = [], closeButton: customCloseButtonStyles = [] } = styleConfig || {};
|
|
64
|
+
const isTop = direction === DIRECTION.DOWN;
|
|
65
|
+
const dynamicCloseButtonStyles = useStyles((theme) => {
|
|
66
|
+
return {
|
|
67
|
+
closeButton: Object.assign({}, (isTop ? { top: -theme.spacing[10] } : { bottom: -theme.spacing[10] })),
|
|
68
|
+
};
|
|
69
|
+
}, [isTop]);
|
|
70
|
+
const getCloseIcon = (isBack = false) => {
|
|
71
|
+
if (hideHeaderDismissIcon) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
35
74
|
if (isBack) {
|
|
36
75
|
return jsx(ModalBack, {});
|
|
37
76
|
}
|
|
38
77
|
return jsx(Cross, { height: 24, width: 24, crossColor: theme.color.background.primary });
|
|
39
78
|
};
|
|
40
|
-
|
|
41
|
-
return (jsxs(Container,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
79
|
+
const CloseIcon = getCloseIcon(isBack);
|
|
80
|
+
return (jsxs(Container, { styleConfig: {
|
|
81
|
+
root: [
|
|
82
|
+
showBorderRadius && direction === DIRECTION.DOWN
|
|
83
|
+
? staticBottomSheetHeaderStyles.headerContainerWithBorderRadius
|
|
84
|
+
: staticBottomSheetHeaderStyles.headerContainer,
|
|
85
|
+
...customHeaderContainerStyles,
|
|
86
|
+
],
|
|
87
|
+
}, children: [jsx(Container, { styleConfig: {
|
|
88
|
+
root: [
|
|
89
|
+
staticBottomSheetHeaderStyles.closeButton,
|
|
90
|
+
dynamicCloseButtonStyles.closeButton,
|
|
91
|
+
...customCloseButtonStyles,
|
|
92
|
+
],
|
|
93
|
+
}, onClick: handleClose, children: CloseIcon }), children] }));
|
|
46
94
|
};
|
|
47
|
-
BottomSheetHeader.defaultProps = {};
|
|
48
95
|
|
|
49
|
-
|
|
96
|
+
const slideDirection = {
|
|
50
97
|
up: 'down',
|
|
51
98
|
down: 'up',
|
|
52
99
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
100
|
+
const staticBottomSheetStyles = makeStyles((theme) => {
|
|
101
|
+
return {
|
|
102
|
+
bottomSheetContainer: {
|
|
103
|
+
position: 'relative',
|
|
104
|
+
width: '100%',
|
|
105
|
+
display: 'flex',
|
|
106
|
+
flexDirection: 'column',
|
|
107
|
+
maxHeight: 'calc(var(--mvh) * 92)',
|
|
108
|
+
boxShadow: theme.elevation.bottomE2,
|
|
109
|
+
},
|
|
110
|
+
overlayWrapper: {
|
|
111
|
+
top: 0,
|
|
112
|
+
left: 0,
|
|
113
|
+
right: 0,
|
|
114
|
+
bottom: 0,
|
|
115
|
+
display: 'flex',
|
|
116
|
+
flexDirection: 'column',
|
|
117
|
+
justifyContent: 'flex-end',
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
const webStaticBottomSheetStyles = css({
|
|
122
|
+
position: 'fixed',
|
|
123
|
+
});
|
|
124
|
+
const handleWindowResize = () => {
|
|
125
|
+
const vh = window.innerHeight * 0.01;
|
|
126
|
+
document.documentElement.style.setProperty('--mvh', `${vh}px`);
|
|
56
127
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var theme = useTheme();
|
|
61
|
-
useEffect(function () {
|
|
128
|
+
const BottomSheet = ({ open, onDismiss, backgroundColor: backdropColor, containerSheetBackgroundColor = 'white', cornerRadius = 16, showCloseButton = true, showBackButton = false, showBackdrop = true, children, header, direction = DIRECTION.DOWN, transitionDuration: timeout = 250, allowedBackdropClose = true, styleConfig = {}, disableOutSideClick = false, disablePortal = false, draggableConfig, }) => {
|
|
129
|
+
const [isVisible, setIsVisible] = useState(open);
|
|
130
|
+
useEffect(() => {
|
|
62
131
|
handleWindowResize();
|
|
63
132
|
window.addEventListener('resize', handleWindowResize);
|
|
64
|
-
return
|
|
133
|
+
return () => {
|
|
65
134
|
window.removeEventListener('resize', handleWindowResize);
|
|
66
135
|
};
|
|
67
136
|
}, []);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var handleCloseBottomSheet = function (event) {
|
|
137
|
+
const { bottomSheetContainer: customBottomSheetContainerStyles = [], overlayWrapper: customOverlayWrapperStyles = [], } = styleConfig || {};
|
|
138
|
+
const handleCloseBottomSheet = (event) => {
|
|
71
139
|
if (disableOutSideClick)
|
|
72
140
|
return;
|
|
73
141
|
event.preventDefault();
|
|
74
|
-
if (allowedBackdropClose &&
|
|
75
|
-
|
|
142
|
+
if (allowedBackdropClose && onDismiss) {
|
|
143
|
+
onDismiss({ isClosedByOutSideClick: true });
|
|
76
144
|
}
|
|
77
145
|
};
|
|
78
|
-
|
|
146
|
+
const handleExited = () => {
|
|
79
147
|
setIsVisible(false);
|
|
80
148
|
};
|
|
81
|
-
|
|
82
|
-
|
|
149
|
+
const handleClose = () => {
|
|
150
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
151
|
+
};
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
if (open) {
|
|
83
154
|
setIsVisible(true);
|
|
84
155
|
}
|
|
85
|
-
}, [
|
|
156
|
+
}, [open]);
|
|
157
|
+
const dynamicBottomSheetContainerStyles = useStyles(() => {
|
|
158
|
+
return {
|
|
159
|
+
bottomSheetContainer: Object.assign(Object.assign({}, ((draggableConfig === null || draggableConfig === void 0 ? void 0 : draggableConfig.isDraggable) ? { height: undefined } : {})), { backgroundColor: containerSheetBackgroundColor, borderTopLeftRadius: cornerRadius, borderTopRightRadius: cornerRadius }),
|
|
160
|
+
};
|
|
161
|
+
}, [draggableConfig === null || draggableConfig === void 0 ? void 0 : draggableConfig.isDraggable, containerSheetBackgroundColor, cornerRadius]);
|
|
162
|
+
const dynamicOverlayWrapperStyles = useStyles((theme) => {
|
|
163
|
+
return {
|
|
164
|
+
overlayWrapper: Object.assign({ zIndex: theme.zIndex.bottomSheet, alignItems: DIRECTION.DOWN ? 'flex-end' : 'flex-start', backgroundColor: backdropColor || (!showBackdrop ? 'transparent' : undefined) }, (!showBackdrop
|
|
165
|
+
? {
|
|
166
|
+
boxShadow: '0px -4px 16px 0px rgba(26, 26, 26, 0.08)',
|
|
167
|
+
}
|
|
168
|
+
: {})),
|
|
169
|
+
};
|
|
170
|
+
}, [showBackdrop, backdropColor, direction]);
|
|
171
|
+
const renderBottomsheetHeader = () => {
|
|
172
|
+
const headerComponent = (jsx(BottomSheetHeader, { direction: direction, showBorderRadius: cornerRadius > 0, handleClose: handleClose, isBack: showBackButton, children: header, hideHeaderDismissIcon: !showCloseButton }));
|
|
173
|
+
if (draggableConfig === null || draggableConfig === void 0 ? void 0 : draggableConfig.isDraggable) {
|
|
174
|
+
return jsx(BaseDraggerHeader, { children: headerComponent });
|
|
175
|
+
}
|
|
176
|
+
return headerComponent;
|
|
177
|
+
};
|
|
178
|
+
const renderBottomsheetWithTransition = ({ ref, onReactTransitionGroupEnd, }) => {
|
|
179
|
+
return (jsx(Transition, { type: 'slide', slideDirection: slideDirection[direction], timeout: timeout, mountOnEnter: true, unmountOnExit: true, appear: true, in: open, onExited: handleExited, onEntered: () => {
|
|
180
|
+
onReactTransitionGroupEnd && onReactTransitionGroupEnd();
|
|
181
|
+
}, children: jsx("div", { ref: ref, children: jsxs(Container, { styleConfig: {
|
|
182
|
+
root: [
|
|
183
|
+
staticBottomSheetStyles.bottomSheetContainer,
|
|
184
|
+
dynamicBottomSheetContainerStyles.bottomSheetContainer,
|
|
185
|
+
...customBottomSheetContainerStyles,
|
|
186
|
+
],
|
|
187
|
+
}, children: [showCloseButton && renderBottomsheetHeader(), children] }) }) }));
|
|
188
|
+
};
|
|
189
|
+
const renderBottomsheetWithDragger = () => {
|
|
190
|
+
if (draggableConfig === null || draggableConfig === void 0 ? void 0 : draggableConfig.isDraggable) {
|
|
191
|
+
return (jsx(BaseDragger, Object.assign({ isWrappedWithTransitionGroup: true }, draggableConfig, { isVisible: open, children: ({ ref, onReactTransitionGroupEnd }) => {
|
|
192
|
+
return renderBottomsheetWithTransition({ ref, onReactTransitionGroupEnd });
|
|
193
|
+
} })));
|
|
194
|
+
}
|
|
195
|
+
return renderBottomsheetWithTransition({});
|
|
196
|
+
};
|
|
197
|
+
const renderBottomsheetWithOutsideClickHandler = () => {
|
|
198
|
+
return (jsx(OutsideClickHandler, { disabled: disableOutSideClick, onOutsideClick: handleCloseBottomSheet, wrapperProps: { style: { width: '100%' } }, children: renderBottomsheetWithDragger() }));
|
|
199
|
+
};
|
|
200
|
+
const renderBottomsheetWithOverlay = () => {
|
|
201
|
+
return (jsx(Overlay, { blur: showBackdrop, styleConfig: {
|
|
202
|
+
root: [
|
|
203
|
+
staticBottomSheetStyles.overlayWrapper,
|
|
204
|
+
webStaticBottomSheetStyles,
|
|
205
|
+
dynamicOverlayWrapperStyles.overlayWrapper,
|
|
206
|
+
...customOverlayWrapperStyles,
|
|
207
|
+
],
|
|
208
|
+
}, children: renderBottomsheetWithOutsideClickHandler() }));
|
|
209
|
+
};
|
|
86
210
|
if (isVisible) {
|
|
87
|
-
|
|
211
|
+
if (disablePortal) {
|
|
212
|
+
return renderBottomsheetWithOverlay();
|
|
213
|
+
}
|
|
214
|
+
return jsx(Portal, { id: 'bottomsheet', children: renderBottomsheetWithOverlay() });
|
|
88
215
|
}
|
|
89
216
|
return null;
|
|
90
217
|
};
|
|
218
|
+
class BottomSheetComponent extends Component {
|
|
219
|
+
dismiss() {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
(_b = (_a = this.props).onDismiss) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
222
|
+
}
|
|
223
|
+
render() {
|
|
224
|
+
return jsx(BottomSheet, Object.assign({}, this.props));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
91
227
|
|
|
92
|
-
export { BottomSheet, BottomSheetHeader, DIRECTION };
|
|
228
|
+
export { BottomSheet, BottomSheetComponent, BottomSheetHeader, BottomSheetSnapPoint, DIRECTION };
|
|
93
229
|
//# sourceMappingURL=ct-design-bottomsheet.esm.js.map
|