@oxyhq/bloom 0.12.1 → 0.14.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/lib/commonjs/fab/Fab.js +25 -6
- package/lib/commonjs/fab/Fab.js.map +1 -1
- package/lib/commonjs/fab/Fab.web.js +26 -7
- package/lib/commonjs/fab/Fab.web.js.map +1 -1
- package/lib/commonjs/index.js +15 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +21 -6
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.js +300 -0
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.js.map +1 -0
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.native.js +226 -0
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.native.js.map +1 -0
- package/lib/commonjs/responsive-sheet/const.js +60 -0
- package/lib/commonjs/responsive-sheet/const.js.map +1 -0
- package/lib/commonjs/responsive-sheet/index.js +19 -0
- package/lib/commonjs/responsive-sheet/index.js.map +1 -0
- package/lib/commonjs/responsive-sheet/index.web.js +19 -0
- package/lib/commonjs/responsive-sheet/index.web.js.map +1 -0
- package/lib/commonjs/responsive-sheet/types.js +6 -0
- package/lib/commonjs/responsive-sheet/types.js.map +1 -0
- package/lib/module/fab/Fab.js +25 -6
- package/lib/module/fab/Fab.js.map +1 -1
- package/lib/module/fab/Fab.web.js +26 -7
- package/lib/module/fab/Fab.web.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +2 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/responsive-sheet/ResponsiveSheet.js +293 -0
- package/lib/module/responsive-sheet/ResponsiveSheet.js.map +1 -0
- package/lib/module/responsive-sheet/ResponsiveSheet.native.js +219 -0
- package/lib/module/responsive-sheet/ResponsiveSheet.native.js.map +1 -0
- package/lib/module/responsive-sheet/const.js +56 -0
- package/lib/module/responsive-sheet/const.js.map +1 -0
- package/lib/module/responsive-sheet/index.js +4 -0
- package/lib/module/responsive-sheet/index.js.map +1 -0
- package/lib/module/responsive-sheet/index.web.js +14 -0
- package/lib/module/responsive-sheet/index.web.js.map +1 -0
- package/lib/module/responsive-sheet/types.js +4 -0
- package/lib/module/responsive-sheet/types.js.map +1 -0
- package/lib/typescript/commonjs/fab/Fab.d.ts.map +1 -1
- package/lib/typescript/commonjs/fab/Fab.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/fab/types.d.ts +12 -2
- package/lib/typescript/commonjs/fab/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +2 -0
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts +26 -0
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.native.d.ts +20 -0
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.native.d.ts.map +1 -0
- package/lib/typescript/commonjs/responsive-sheet/const.d.ts +43 -0
- package/lib/typescript/commonjs/responsive-sheet/const.d.ts.map +1 -0
- package/lib/typescript/commonjs/responsive-sheet/index.d.ts +3 -0
- package/lib/typescript/commonjs/responsive-sheet/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/responsive-sheet/index.web.d.ts +3 -0
- package/lib/typescript/commonjs/responsive-sheet/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/responsive-sheet/types.d.ts +55 -0
- package/lib/typescript/commonjs/responsive-sheet/types.d.ts.map +1 -0
- package/lib/typescript/module/fab/Fab.d.ts.map +1 -1
- package/lib/typescript/module/fab/Fab.web.d.ts.map +1 -1
- package/lib/typescript/module/fab/types.d.ts +12 -2
- package/lib/typescript/module/fab/types.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +2 -0
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts +26 -0
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts.map +1 -0
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.native.d.ts +20 -0
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.native.d.ts.map +1 -0
- package/lib/typescript/module/responsive-sheet/const.d.ts +43 -0
- package/lib/typescript/module/responsive-sheet/const.d.ts.map +1 -0
- package/lib/typescript/module/responsive-sheet/index.d.ts +3 -0
- package/lib/typescript/module/responsive-sheet/index.d.ts.map +1 -0
- package/lib/typescript/module/responsive-sheet/index.web.d.ts +3 -0
- package/lib/typescript/module/responsive-sheet/index.web.d.ts.map +1 -0
- package/lib/typescript/module/responsive-sheet/types.d.ts +55 -0
- package/lib/typescript/module/responsive-sheet/types.d.ts.map +1 -0
- package/package.json +18 -1
- package/src/__tests__/Fab.test.tsx +17 -0
- package/src/__tests__/Fab.web.test.tsx +14 -0
- package/src/__tests__/ResponsiveSheet.test.tsx +104 -0
- package/src/fab/Fab.stories.tsx +9 -0
- package/src/fab/Fab.tsx +33 -7
- package/src/fab/Fab.web.tsx +33 -8
- package/src/fab/types.ts +12 -2
- package/src/index.ts +8 -0
- package/src/index.web.ts +8 -0
- package/src/responsive-sheet/ResponsiveSheet.native.tsx +257 -0
- package/src/responsive-sheet/ResponsiveSheet.stories.tsx +54 -0
- package/src/responsive-sheet/ResponsiveSheet.tsx +327 -0
- package/src/responsive-sheet/const.ts +53 -0
- package/src/responsive-sheet/index.ts +6 -0
- package/src/responsive-sheet/index.web.ts +16 -0
- package/src/responsive-sheet/types.ts +57 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RESPONSIVE_SHEET_BACKDROP_TESTID = void 0;
|
|
7
|
+
exports.ResponsiveSheet = ResponsiveSheet;
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
var _zIndex = require("../styles/z-index.js");
|
|
12
|
+
var _useTheme = require("../theme/use-theme.js");
|
|
13
|
+
var _const = require("./const.js");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
/** Stable testID for the dimmed backdrop dismiss button. */
|
|
17
|
+
const RESPONSIVE_SHEET_BACKDROP_TESTID = exports.RESPONSIVE_SHEET_BACKDROP_TESTID = 'bloom-responsive-sheet-backdrop';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Default / web variant of `<ResponsiveSheet>`.
|
|
21
|
+
*
|
|
22
|
+
* This file is BOTH the package's default entry (`react-native` export
|
|
23
|
+
* condition resolves it for downstream `tsc`, and non-Metro web bundlers pick
|
|
24
|
+
* it via the `browser` condition through `index.web`) AND the canonical web
|
|
25
|
+
* implementation. It MUST NOT import `react-native-reanimated` — reanimated has
|
|
26
|
+
* no web build and its worklets Babel plugin is native-only, so a static import
|
|
27
|
+
* here would break every web bundler and downstream type-check. The native
|
|
28
|
+
* fork (`ResponsiveSheet.native.tsx`, selected only by Metro) drives the same
|
|
29
|
+
* motion with reanimated.
|
|
30
|
+
*
|
|
31
|
+
* Motion is pure CSS transitions: react-native-web emits `transition-*` style
|
|
32
|
+
* props to the DOM, and the panel/backdrop toggle their transform/opacity by a
|
|
33
|
+
* `shown` flag. Presence is handled with a `mounted` + `shown` pair so both the
|
|
34
|
+
* open AND close directions animate while the node stays mounted through the
|
|
35
|
+
* exit. We deliberately do NOT use reanimated `exiting` on web — concurrent
|
|
36
|
+
* React unmounts there throw `Failed to execute 'removeChild' on 'Node'`, the
|
|
37
|
+
* exact bug this component exists to avoid.
|
|
38
|
+
*/
|
|
39
|
+
function ResponsiveSheet({
|
|
40
|
+
open,
|
|
41
|
+
onClose,
|
|
42
|
+
side = _const.DEFAULT_SIDE,
|
|
43
|
+
breakpoint = _const.DEFAULT_BREAKPOINT,
|
|
44
|
+
width = _const.DEFAULT_WIDTH,
|
|
45
|
+
maxHeightRatio = _const.DEFAULT_MAX_HEIGHT_RATIO,
|
|
46
|
+
inset,
|
|
47
|
+
showHandle = true,
|
|
48
|
+
dismissOnBackdrop = true,
|
|
49
|
+
panelStyle,
|
|
50
|
+
panelClassName,
|
|
51
|
+
containerStyle,
|
|
52
|
+
containerClassName,
|
|
53
|
+
label = _const.DEFAULT_LABEL,
|
|
54
|
+
children
|
|
55
|
+
}) {
|
|
56
|
+
const theme = (0, _useTheme.useTheme)();
|
|
57
|
+
const {
|
|
58
|
+
width: viewportWidth,
|
|
59
|
+
height: viewportHeight
|
|
60
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
61
|
+
|
|
62
|
+
// Presence: `mounted` keeps the node in the tree through the exit transition;
|
|
63
|
+
// `shown` drives the enter/exit transform & opacity. On open we mount first,
|
|
64
|
+
// then flip `shown` on the next frame so the browser registers the start
|
|
65
|
+
// state and animates to the end. On close we flip `shown` off, then unmount
|
|
66
|
+
// after the transition duration.
|
|
67
|
+
const [mounted, setMounted] = (0, _react.useState)(open);
|
|
68
|
+
const [shown, setShown] = (0, _react.useState)(false);
|
|
69
|
+
const closeTimerRef = (0, _react.useRef)(null);
|
|
70
|
+
const frameRef = (0, _react.useRef)(null);
|
|
71
|
+
(0, _react.useEffect)(() => {
|
|
72
|
+
if (open) {
|
|
73
|
+
if (closeTimerRef.current) {
|
|
74
|
+
clearTimeout(closeTimerRef.current);
|
|
75
|
+
closeTimerRef.current = null;
|
|
76
|
+
}
|
|
77
|
+
setMounted(true);
|
|
78
|
+
// Defer to the next frame so the entry start state paints before we
|
|
79
|
+
// transition to the shown state. Two frames guarantees the start
|
|
80
|
+
// transform has committed before the toggle (a single frame can be
|
|
81
|
+
// coalesced with the mount paint in some browsers).
|
|
82
|
+
frameRef.current = scheduleFrame(() => {
|
|
83
|
+
frameRef.current = scheduleFrame(() => setShown(true));
|
|
84
|
+
});
|
|
85
|
+
return () => {
|
|
86
|
+
if (frameRef.current !== null) {
|
|
87
|
+
cancelFrame(frameRef.current);
|
|
88
|
+
frameRef.current = null;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Closing: only run the exit if something is currently mounted.
|
|
94
|
+
setShown(false);
|
|
95
|
+
if (!mounted) return;
|
|
96
|
+
closeTimerRef.current = setTimeout(() => {
|
|
97
|
+
setMounted(false);
|
|
98
|
+
closeTimerRef.current = null;
|
|
99
|
+
}, _const.ANIMATION_DURATION);
|
|
100
|
+
return () => {
|
|
101
|
+
if (closeTimerRef.current) {
|
|
102
|
+
clearTimeout(closeTimerRef.current);
|
|
103
|
+
closeTimerRef.current = null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}, [open, mounted]);
|
|
107
|
+
|
|
108
|
+
// Escape-to-close while open (web only; document is undefined elsewhere).
|
|
109
|
+
(0, _react.useEffect)(() => {
|
|
110
|
+
if (!open || typeof document === 'undefined') return;
|
|
111
|
+
const handler = e => {
|
|
112
|
+
if (e.key === 'Escape') {
|
|
113
|
+
e.stopPropagation();
|
|
114
|
+
onClose();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
document.addEventListener('keydown', handler);
|
|
118
|
+
return () => document.removeEventListener('keydown', handler);
|
|
119
|
+
}, [open, onClose]);
|
|
120
|
+
const handleBackdropPress = (0, _react.useCallback)(() => {
|
|
121
|
+
if (dismissOnBackdrop) onClose();
|
|
122
|
+
}, [dismissOnBackdrop, onClose]);
|
|
123
|
+
const isBottom = viewportWidth < breakpoint;
|
|
124
|
+
const panelBackground = theme.colors.background;
|
|
125
|
+
const panelTransition = (0, _react.useMemo)(() => ({
|
|
126
|
+
transitionProperty: 'transform, opacity',
|
|
127
|
+
transitionDuration: `${_const.ANIMATION_DURATION}ms`,
|
|
128
|
+
transitionTimingFunction: _const.EASE_OUT
|
|
129
|
+
}), []);
|
|
130
|
+
const backdropTransition = (0, _react.useMemo)(() => ({
|
|
131
|
+
transitionProperty: 'opacity',
|
|
132
|
+
transitionDuration: `${_const.ANIMATION_DURATION}ms`,
|
|
133
|
+
transitionTimingFunction: _const.EASE_OUT
|
|
134
|
+
}), []);
|
|
135
|
+
const panelGeometry = (0, _react.useMemo)(() => {
|
|
136
|
+
if (isBottom) {
|
|
137
|
+
return {
|
|
138
|
+
left: 0,
|
|
139
|
+
right: 0,
|
|
140
|
+
bottom: 0,
|
|
141
|
+
maxHeight: Math.round(viewportHeight * maxHeightRatio),
|
|
142
|
+
borderTopLeftRadius: _const.PANEL_RADIUS,
|
|
143
|
+
borderTopRightRadius: _const.PANEL_RADIUS,
|
|
144
|
+
transform: [{
|
|
145
|
+
translateY: shown ? 0 : '100%'
|
|
146
|
+
}],
|
|
147
|
+
opacity: shown ? 1 : 0
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Side-sheet: full height minus top/bottom inset, anchored to `side`,
|
|
152
|
+
// offset by the matching horizontal inset. Width is capped so the panel
|
|
153
|
+
// always leaves a gutter on the opposite edge.
|
|
154
|
+
const insetTop = inset?.top ?? 0;
|
|
155
|
+
const insetBottom = inset?.bottom ?? 0;
|
|
156
|
+
const insetLeft = inset?.left ?? 0;
|
|
157
|
+
const insetRight = inset?.right ?? 0;
|
|
158
|
+
const anchorInset = side === 'left' ? insetLeft : insetRight;
|
|
159
|
+
const oppositeInset = side === 'left' ? insetRight : insetLeft;
|
|
160
|
+
const available = viewportWidth - anchorInset - oppositeInset - _const.SIDE_SHEET_MIN_GUTTER;
|
|
161
|
+
const cappedWidth = Math.max(0, Math.min(width, available));
|
|
162
|
+
const hiddenSign = side === 'left' ? '-100%' : '100%';
|
|
163
|
+
return {
|
|
164
|
+
top: insetTop,
|
|
165
|
+
bottom: insetBottom,
|
|
166
|
+
[side]: anchorInset,
|
|
167
|
+
width: cappedWidth,
|
|
168
|
+
borderRadius: _const.PANEL_RADIUS,
|
|
169
|
+
transform: [{
|
|
170
|
+
translateX: shown ? 0 : hiddenSign
|
|
171
|
+
}],
|
|
172
|
+
opacity: shown ? 1 : 0
|
|
173
|
+
};
|
|
174
|
+
}, [isBottom, shown, side, width, inset, viewportWidth, viewportHeight, maxHeightRatio]);
|
|
175
|
+
if (!mounted) return null;
|
|
176
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
177
|
+
style: [styles.root, containerStyle]
|
|
178
|
+
// NativeWind reads `className` at runtime; RN core does not type it on
|
|
179
|
+
// View, so spread it conditionally (matching the Button/Fab pattern).
|
|
180
|
+
,
|
|
181
|
+
...(containerClassName ? {
|
|
182
|
+
className: containerClassName
|
|
183
|
+
} : {}),
|
|
184
|
+
pointerEvents: "box-none",
|
|
185
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
186
|
+
testID: RESPONSIVE_SHEET_BACKDROP_TESTID,
|
|
187
|
+
accessibilityRole: "button",
|
|
188
|
+
accessibilityLabel: `Dismiss ${label}`,
|
|
189
|
+
onPress: handleBackdropPress,
|
|
190
|
+
disabled: !dismissOnBackdrop,
|
|
191
|
+
style: [styles.backdrop, backdropTransition, {
|
|
192
|
+
opacity: shown ? _const.BACKDROP_OPACITY : 0
|
|
193
|
+
}, isWeb ? webBackdropBlur : null]
|
|
194
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
195
|
+
accessibilityViewIsModal: true,
|
|
196
|
+
"aria-label": label,
|
|
197
|
+
...(panelClassName ? {
|
|
198
|
+
className: panelClassName
|
|
199
|
+
} : {}),
|
|
200
|
+
style: [styles.panel, {
|
|
201
|
+
backgroundColor: panelBackground,
|
|
202
|
+
shadowColor: theme.colors.shadow
|
|
203
|
+
}, panelGeometry, panelTransition, panelStyle],
|
|
204
|
+
pointerEvents: "auto",
|
|
205
|
+
children: [isBottom && showHandle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
206
|
+
style: styles.handleRow,
|
|
207
|
+
pointerEvents: "none",
|
|
208
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
209
|
+
style: [styles.handle, {
|
|
210
|
+
backgroundColor: theme.colors.border
|
|
211
|
+
}]
|
|
212
|
+
})
|
|
213
|
+
}) : null, children]
|
|
214
|
+
})]
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// This module is the web/default impl, but it is also the fallback resolved by
|
|
219
|
+
// a downstream consumer's `tsc` for the native target, so guard the web-only
|
|
220
|
+
// `backdrop-blur` style behind a runtime check rather than assuming web.
|
|
221
|
+
const isWeb = typeof document !== 'undefined';
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Opaque token returned by `scheduleFrame`. `requestAnimationFrame` returns a
|
|
225
|
+
* number; the `setTimeout` fallback returns a timer handle — both are kept so
|
|
226
|
+
* `cancelFrame` can route to the matching canceller.
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Schedule a callback for the next paint. Uses `requestAnimationFrame` in the
|
|
231
|
+
* browser; degrades to a 0ms timeout when rAF is unavailable (SSR/hydration,
|
|
232
|
+
* non-DOM test envs) so the enter transition's `shown` flip still fires.
|
|
233
|
+
*/
|
|
234
|
+
function scheduleFrame(cb) {
|
|
235
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
236
|
+
return {
|
|
237
|
+
raf: requestAnimationFrame(cb)
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
timer: setTimeout(cb, 0)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function cancelFrame(token) {
|
|
245
|
+
if ('raf' in token) {
|
|
246
|
+
if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(token.raf);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
clearTimeout(token.timer);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// `backdrop-filter` is web-only; react-native-web passes it through to the DOM.
|
|
253
|
+
const webBackdropBlur = {
|
|
254
|
+
backdropFilter: 'blur(2px)'
|
|
255
|
+
};
|
|
256
|
+
const styles = _reactNative.StyleSheet.create({
|
|
257
|
+
root: {
|
|
258
|
+
// `position: fixed` pins the overlay to the viewport on web; react-native
|
|
259
|
+
// does not type `'fixed'`, so cast to the RN-accepted `'absolute'`. On
|
|
260
|
+
// native the `.native` fork uses `StyleSheet.absoluteFill` instead.
|
|
261
|
+
position: 'fixed',
|
|
262
|
+
top: 0,
|
|
263
|
+
left: 0,
|
|
264
|
+
right: 0,
|
|
265
|
+
bottom: 0,
|
|
266
|
+
zIndex: _zIndex.Z_INDEX.fullscreen
|
|
267
|
+
},
|
|
268
|
+
backdrop: {
|
|
269
|
+
position: 'absolute',
|
|
270
|
+
top: 0,
|
|
271
|
+
left: 0,
|
|
272
|
+
right: 0,
|
|
273
|
+
bottom: 0,
|
|
274
|
+
backgroundColor: '#000'
|
|
275
|
+
},
|
|
276
|
+
panel: {
|
|
277
|
+
position: 'absolute',
|
|
278
|
+
overflow: 'hidden',
|
|
279
|
+
shadowOpacity: 0.18,
|
|
280
|
+
shadowRadius: 24,
|
|
281
|
+
shadowOffset: {
|
|
282
|
+
width: 0,
|
|
283
|
+
height: 8
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
handleRow: {
|
|
287
|
+
width: '100%',
|
|
288
|
+
alignItems: 'center',
|
|
289
|
+
paddingTop: 8,
|
|
290
|
+
paddingBottom: 4
|
|
291
|
+
},
|
|
292
|
+
handle: {
|
|
293
|
+
width: _const.HANDLE_WIDTH,
|
|
294
|
+
height: _const.HANDLE_HEIGHT,
|
|
295
|
+
borderRadius: _const.HANDLE_RADIUS,
|
|
296
|
+
opacity: 0.5
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
var _default = exports.default = ResponsiveSheet;
|
|
300
|
+
//# sourceMappingURL=ResponsiveSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_zIndex","_useTheme","_const","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RESPONSIVE_SHEET_BACKDROP_TESTID","exports","ResponsiveSheet","open","onClose","side","DEFAULT_SIDE","breakpoint","DEFAULT_BREAKPOINT","width","DEFAULT_WIDTH","maxHeightRatio","DEFAULT_MAX_HEIGHT_RATIO","inset","showHandle","dismissOnBackdrop","panelStyle","panelClassName","containerStyle","containerClassName","label","DEFAULT_LABEL","children","theme","useTheme","viewportWidth","height","viewportHeight","useWindowDimensions","mounted","setMounted","useState","shown","setShown","closeTimerRef","useRef","frameRef","useEffect","current","clearTimeout","scheduleFrame","cancelFrame","setTimeout","ANIMATION_DURATION","document","handler","key","stopPropagation","addEventListener","removeEventListener","handleBackdropPress","useCallback","isBottom","panelBackground","colors","background","panelTransition","useMemo","transitionProperty","transitionDuration","transitionTimingFunction","EASE_OUT","backdropTransition","panelGeometry","left","right","bottom","maxHeight","Math","round","borderTopLeftRadius","PANEL_RADIUS","borderTopRightRadius","transform","translateY","opacity","insetTop","top","insetBottom","insetLeft","insetRight","anchorInset","oppositeInset","available","SIDE_SHEET_MIN_GUTTER","cappedWidth","max","min","hiddenSign","borderRadius","translateX","jsxs","View","style","styles","root","className","pointerEvents","jsx","Pressable","testID","accessibilityRole","accessibilityLabel","onPress","disabled","backdrop","BACKDROP_OPACITY","isWeb","webBackdropBlur","accessibilityViewIsModal","panel","backgroundColor","shadowColor","shadow","handleRow","handle","border","cb","requestAnimationFrame","raf","timer","token","cancelAnimationFrame","backdropFilter","StyleSheet","create","position","zIndex","Z_INDEX","fullscreen","overflow","shadowOpacity","shadowRadius","shadowOffset","alignItems","paddingTop","paddingBottom","HANDLE_WIDTH","HANDLE_HEIGHT","HANDLE_RADIUS","_default"],"sourceRoot":"../../../src","sources":["responsive-sheet/ResponsiveSheet.tsx"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAciB,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAA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GAAG8B,uBAAU,CAACC,MAAM,CAAC;EAC/B9B,IAAI,EAAE;IACJ;IACA;IACA;IACA+B,QAAQ,EAAE,OAAqB;IAC/BjD,GAAG,EAAE,CAAC;IACNb,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACT6D,MAAM,EAAEC,eAAO,CAACC;EAClB,CAAC;EACDxB,QAAQ,EAAE;IACRqB,QAAQ,EAAE,UAAU;IACpBjD,GAAG,EAAE,CAAC;IACNb,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE,CAAC;IACT6C,eAAe,EAAE;EACnB,CAAC;EACDD,KAAK,EAAE;IACLgB,QAAQ,EAAE,UAAU;IACpBI,QAAQ,EAAE,QAAQ;IAClBC,aAAa,EAAE,IAAI;IACnBC,YAAY,EAAE,EAAE;IAChBC,YAAY,EAAE;MAAE5H,KAAK,EAAE,CAAC;MAAEiB,MAAM,EAAE;IAAE;EACtC,CAAC;EACDwF,SAAS,EAAE;IACTzG,KAAK,EAAE,MAAM;IACb6H,UAAU,EAAE,QAAQ;IACpBC,UAAU,EAAE,CAAC;IACbC,aAAa,EAAE;EACjB,CAAC;EACDrB,MAAM,EAAE;IACN1G,KAAK,EAAEgI,mBAAY;IACnB/G,MAAM,EAAEgH,oBAAa;IACrBjD,YAAY,EAAEkD,oBAAa;IAC3BhE,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAAC,IAAAiE,QAAA,GAAA3I,OAAA,CAAAV,OAAA,GAEYW,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RESPONSIVE_SHEET_BACKDROP_TESTID = void 0;
|
|
7
|
+
exports.ResponsiveSheet = ResponsiveSheet;
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
12
|
+
var _zIndex = require("../styles/z-index.js");
|
|
13
|
+
var _useTheme = require("../theme/use-theme.js");
|
|
14
|
+
var _const = require("./const.js");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
|
+
/** Stable testID for the dimmed backdrop dismiss button. */
|
|
18
|
+
const RESPONSIVE_SHEET_BACKDROP_TESTID = exports.RESPONSIVE_SHEET_BACKDROP_TESTID = 'bloom-responsive-sheet-backdrop';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Native variant of `<ResponsiveSheet>` (selected only by Metro).
|
|
22
|
+
*
|
|
23
|
+
* Uses `react-native-reanimated` to drive the same motion as the web/CSS
|
|
24
|
+
* default fork: a shared `progress` value times 0 -> 1 on open and 1 -> 0 on
|
|
25
|
+
* close, mapped to the panel translate/opacity and the backdrop opacity.
|
|
26
|
+
* Native exit animations are safe here — the web-only `removeChild` crash does
|
|
27
|
+
* not apply — so we keep the node mounted through the close timing and unmount
|
|
28
|
+
* from the animation completion callback.
|
|
29
|
+
*
|
|
30
|
+
* The panel itself is measured (not percentage-translated): we offset by the
|
|
31
|
+
* panel's own width/height so the hidden state sits fully off its side, which
|
|
32
|
+
* is the reanimated-friendly equivalent of the web `translate(±100%)`.
|
|
33
|
+
*/
|
|
34
|
+
function ResponsiveSheet({
|
|
35
|
+
open,
|
|
36
|
+
onClose,
|
|
37
|
+
side = _const.DEFAULT_SIDE,
|
|
38
|
+
breakpoint = _const.DEFAULT_BREAKPOINT,
|
|
39
|
+
width = _const.DEFAULT_WIDTH,
|
|
40
|
+
maxHeightRatio = _const.DEFAULT_MAX_HEIGHT_RATIO,
|
|
41
|
+
inset,
|
|
42
|
+
showHandle = true,
|
|
43
|
+
dismissOnBackdrop = true,
|
|
44
|
+
panelStyle,
|
|
45
|
+
panelClassName,
|
|
46
|
+
containerStyle,
|
|
47
|
+
containerClassName,
|
|
48
|
+
label = _const.DEFAULT_LABEL,
|
|
49
|
+
children
|
|
50
|
+
}) {
|
|
51
|
+
const theme = (0, _useTheme.useTheme)();
|
|
52
|
+
const {
|
|
53
|
+
width: viewportWidth,
|
|
54
|
+
height: viewportHeight
|
|
55
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
56
|
+
|
|
57
|
+
// Keep the tree mounted through the exit timing; unmount once it settles.
|
|
58
|
+
const [mounted, setMounted] = (0, _react.useState)(open);
|
|
59
|
+
// `progress`: 0 = fully hidden, 1 = fully shown. Drives both transform and
|
|
60
|
+
// opacity so a single timing controls the whole transition.
|
|
61
|
+
const progress = (0, _reactNativeReanimated.useSharedValue)(open ? 1 : 0);
|
|
62
|
+
const isBottom = viewportWidth < breakpoint;
|
|
63
|
+
|
|
64
|
+
// Measured panel extent along the travel axis. Falls back to the geometry
|
|
65
|
+
// target so the very first frame is already off-screen before layout lands.
|
|
66
|
+
const insetTop = inset?.top ?? 0;
|
|
67
|
+
const insetBottom = inset?.bottom ?? 0;
|
|
68
|
+
const insetLeft = inset?.left ?? 0;
|
|
69
|
+
const insetRight = inset?.right ?? 0;
|
|
70
|
+
const anchorInset = side === 'left' ? insetLeft : insetRight;
|
|
71
|
+
const oppositeInset = side === 'left' ? insetRight : insetLeft;
|
|
72
|
+
const sideWidth = (0, _react.useMemo)(() => {
|
|
73
|
+
const available = viewportWidth - anchorInset - oppositeInset - _const.SIDE_SHEET_MIN_GUTTER;
|
|
74
|
+
return Math.max(0, Math.min(width, available));
|
|
75
|
+
}, [viewportWidth, anchorInset, oppositeInset, width]);
|
|
76
|
+
const bottomMaxHeight = (0, _react.useMemo)(() => Math.round(viewportHeight * maxHeightRatio), [viewportHeight, maxHeightRatio]);
|
|
77
|
+
|
|
78
|
+
// Travel distance for the hidden state: the panel's measured extent (height
|
|
79
|
+
// for the bottom-sheet, width for the side-sheet), with the geometry target
|
|
80
|
+
// as the pre-measurement fallback.
|
|
81
|
+
const travel = (0, _reactNativeReanimated.useSharedValue)(isBottom ? bottomMaxHeight : sideWidth);
|
|
82
|
+
(0, _react.useEffect)(() => {
|
|
83
|
+
travel.value = isBottom ? bottomMaxHeight : sideWidth;
|
|
84
|
+
}, [isBottom, bottomMaxHeight, sideWidth, travel]);
|
|
85
|
+
const finishClose = (0, _react.useCallback)(() => {
|
|
86
|
+
setMounted(false);
|
|
87
|
+
}, []);
|
|
88
|
+
(0, _react.useEffect)(() => {
|
|
89
|
+
(0, _reactNativeReanimated.cancelAnimation)(progress);
|
|
90
|
+
const timing = {
|
|
91
|
+
duration: _const.ANIMATION_DURATION,
|
|
92
|
+
easing: _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)
|
|
93
|
+
};
|
|
94
|
+
if (open) {
|
|
95
|
+
setMounted(true);
|
|
96
|
+
progress.value = (0, _reactNativeReanimated.withTiming)(1, timing);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!mounted) return;
|
|
100
|
+
progress.value = (0, _reactNativeReanimated.withTiming)(0, timing, finished => {
|
|
101
|
+
if (finished) (0, _reactNativeReanimated.runOnJS)(finishClose)();
|
|
102
|
+
});
|
|
103
|
+
}, [open, mounted, progress, finishClose]);
|
|
104
|
+
const handleBackdropPress = (0, _react.useCallback)(() => {
|
|
105
|
+
if (dismissOnBackdrop) onClose();
|
|
106
|
+
}, [dismissOnBackdrop, onClose]);
|
|
107
|
+
const backdropAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
108
|
+
opacity: progress.value * _const.BACKDROP_OPACITY
|
|
109
|
+
}));
|
|
110
|
+
const hiddenSign = side === 'left' ? -1 : 1;
|
|
111
|
+
const panelAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
112
|
+
const hidden = 1 - progress.value;
|
|
113
|
+
if (isBottom) {
|
|
114
|
+
return {
|
|
115
|
+
opacity: progress.value,
|
|
116
|
+
transform: [{
|
|
117
|
+
translateY: hidden * travel.value
|
|
118
|
+
}]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
opacity: progress.value,
|
|
123
|
+
transform: [{
|
|
124
|
+
translateX: hidden * travel.value * hiddenSign
|
|
125
|
+
}]
|
|
126
|
+
};
|
|
127
|
+
}, [isBottom, hiddenSign]);
|
|
128
|
+
const measurePanel = (0, _react.useCallback)(e => {
|
|
129
|
+
const measured = isBottom ? e.nativeEvent.layout.height : e.nativeEvent.layout.width;
|
|
130
|
+
if (measured > 0) travel.value = measured;
|
|
131
|
+
}, [isBottom, travel]);
|
|
132
|
+
const panelGeometry = (0, _react.useMemo)(() => {
|
|
133
|
+
if (isBottom) {
|
|
134
|
+
return {
|
|
135
|
+
left: 0,
|
|
136
|
+
right: 0,
|
|
137
|
+
bottom: 0,
|
|
138
|
+
maxHeight: bottomMaxHeight,
|
|
139
|
+
borderTopLeftRadius: _const.PANEL_RADIUS,
|
|
140
|
+
borderTopRightRadius: _const.PANEL_RADIUS
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
top: insetTop,
|
|
145
|
+
bottom: insetBottom,
|
|
146
|
+
[side]: anchorInset,
|
|
147
|
+
width: sideWidth,
|
|
148
|
+
borderRadius: _const.PANEL_RADIUS
|
|
149
|
+
};
|
|
150
|
+
}, [isBottom, bottomMaxHeight, insetTop, insetBottom, side, anchorInset, sideWidth]);
|
|
151
|
+
if (!mounted) return null;
|
|
152
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
153
|
+
style: [styles.root, containerStyle],
|
|
154
|
+
...(containerClassName ? {
|
|
155
|
+
className: containerClassName
|
|
156
|
+
} : {}),
|
|
157
|
+
pointerEvents: "box-none",
|
|
158
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
159
|
+
style: [styles.backdrop, backdropAnimatedStyle],
|
|
160
|
+
pointerEvents: "auto",
|
|
161
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
162
|
+
testID: RESPONSIVE_SHEET_BACKDROP_TESTID,
|
|
163
|
+
accessibilityRole: "button",
|
|
164
|
+
accessibilityLabel: `Dismiss ${label}`,
|
|
165
|
+
onPress: handleBackdropPress,
|
|
166
|
+
disabled: !dismissOnBackdrop,
|
|
167
|
+
style: _reactNative.StyleSheet.absoluteFill
|
|
168
|
+
})
|
|
169
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
|
|
170
|
+
accessibilityViewIsModal: true,
|
|
171
|
+
...(panelClassName ? {
|
|
172
|
+
className: panelClassName
|
|
173
|
+
} : {}),
|
|
174
|
+
onLayout: measurePanel,
|
|
175
|
+
style: [styles.panel, {
|
|
176
|
+
backgroundColor: theme.colors.background,
|
|
177
|
+
shadowColor: theme.colors.shadow
|
|
178
|
+
}, panelGeometry, panelAnimatedStyle, panelStyle],
|
|
179
|
+
pointerEvents: "auto",
|
|
180
|
+
children: [isBottom && showHandle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
181
|
+
style: styles.handleRow,
|
|
182
|
+
pointerEvents: "none",
|
|
183
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
184
|
+
style: [styles.handle, {
|
|
185
|
+
backgroundColor: theme.colors.border
|
|
186
|
+
}]
|
|
187
|
+
})
|
|
188
|
+
}) : null, children]
|
|
189
|
+
})]
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const styles = _reactNative.StyleSheet.create({
|
|
193
|
+
root: {
|
|
194
|
+
..._reactNative.StyleSheet.absoluteFill,
|
|
195
|
+
zIndex: _zIndex.Z_INDEX.fullscreen
|
|
196
|
+
},
|
|
197
|
+
backdrop: {
|
|
198
|
+
..._reactNative.StyleSheet.absoluteFill,
|
|
199
|
+
backgroundColor: '#000'
|
|
200
|
+
},
|
|
201
|
+
panel: {
|
|
202
|
+
position: 'absolute',
|
|
203
|
+
overflow: 'hidden',
|
|
204
|
+
shadowOpacity: 0.18,
|
|
205
|
+
shadowRadius: 24,
|
|
206
|
+
shadowOffset: {
|
|
207
|
+
width: 0,
|
|
208
|
+
height: 8
|
|
209
|
+
},
|
|
210
|
+
elevation: 12
|
|
211
|
+
},
|
|
212
|
+
handleRow: {
|
|
213
|
+
width: '100%',
|
|
214
|
+
alignItems: 'center',
|
|
215
|
+
paddingTop: 8,
|
|
216
|
+
paddingBottom: 4
|
|
217
|
+
},
|
|
218
|
+
handle: {
|
|
219
|
+
width: _const.HANDLE_WIDTH,
|
|
220
|
+
height: _const.HANDLE_HEIGHT,
|
|
221
|
+
borderRadius: _const.HANDLE_RADIUS,
|
|
222
|
+
opacity: 0.5
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
var _default = exports.default = ResponsiveSheet;
|
|
226
|
+
//# sourceMappingURL=ResponsiveSheet.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_zIndex","_useTheme","_const","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RESPONSIVE_SHEET_BACKDROP_TESTID","exports","ResponsiveSheet","open","onClose","side","DEFAULT_SIDE","breakpoint","DEFAULT_BREAKPOINT","width","DEFAULT_WIDTH","maxHeightRatio","DEFAULT_MAX_HEIGHT_RATIO","inset","showHandle","dismissOnBackdrop","panelStyle","panelClassName","containerStyle","containerClassName","label","DEFAULT_LABEL","children","theme","useTheme","viewportWidth","height","viewportHeight","useWindowDimensions","mounted","setMounted","useState","progress","useSharedValue","isBottom","insetTop","top","insetBottom","bottom","insetLeft","left","insetRight","right","anchorInset","oppositeInset","sideWidth","useMemo","available","SIDE_SHEET_MIN_GUTTER","Math","max","min","bottomMaxHeight","round","travel","useEffect","value","finishClose","useCallback","cancelAnimation","timing","duration","ANIMATION_DURATION","easing","Easing","out","cubic","withTiming","finished","runOnJS","handleBackdropPress","backdropAnimatedStyle","useAnimatedStyle","opacity","BACKDROP_OPACITY","hiddenSign","panelAnimatedStyle","hidden","transform","translateY","translateX","measurePanel","measured","nativeEvent","layout","panelGeometry","maxHeight","borderTopLeftRadius","PANEL_RADIUS","borderTopRightRadius","borderRadius","jsxs","View","style","styles","root","className","pointerEvents","jsx","backdrop","Pressable","testID","accessibilityRole","accessibilityLabel","onPress","disabled","StyleSheet","absoluteFill","accessibilityViewIsModal","onLayout","panel","backgroundColor","colors","background","shadowColor","shadow","handleRow","handle","border","create","zIndex","Z_INDEX","fullscreen","position","overflow","shadowOpacity","shadowRadius","shadowOffset","elevation","alignItems","paddingTop","paddingBottom","HANDLE_WIDTH","HANDLE_HEIGHT","HANDLE_RADIUS","_default"],"sourceRoot":"../../../src","sources":["responsive-sheet/ResponsiveSheet.native.tsx"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AASA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAaiB,IAA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eAAO,CAACC;EAClB,CAAC;EACDvB,QAAQ,EAAE;IACR,GAAGO,uBAAU,CAACC,YAAY;IAC1BI,eAAe,EAAE;EACnB,CAAC;EACDD,KAAK,EAAE;IACLa,QAAQ,EAAE,UAAU;IACpBC,QAAQ,EAAE,QAAQ;IAClBC,aAAa,EAAE,IAAI;IACnBC,YAAY,EAAE,EAAE;IAChBC,YAAY,EAAE;MAAEtH,KAAK,EAAE,CAAC;MAAEiB,MAAM,EAAE;IAAE,CAAC;IACrCsG,SAAS,EAAE;EACb,CAAC;EACDZ,SAAS,EAAE;IACT3G,KAAK,EAAE,MAAM;IACbwH,UAAU,EAAE,QAAQ;IACpBC,UAAU,EAAE,CAAC;IACbC,aAAa,EAAE;EACjB,CAAC;EACDd,MAAM,EAAE;IACN5G,KAAK,EAAE2H,mBAAY;IACnB1G,MAAM,EAAE2G,oBAAa;IACrB3C,YAAY,EAAE4C,oBAAa;IAC3B7D,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAAC,IAAA8D,QAAA,GAAAtI,OAAA,CAAAV,OAAA,GAEYW,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SIDE_SHEET_MIN_GUTTER = exports.PANEL_RADIUS = exports.HANDLE_WIDTH = exports.HANDLE_RADIUS = exports.HANDLE_HEIGHT = exports.EASE_OUT = exports.DEFAULT_WIDTH = exports.DEFAULT_SIDE = exports.DEFAULT_MAX_HEIGHT_RATIO = exports.DEFAULT_LABEL = exports.DEFAULT_BREAKPOINT = exports.BACKDROP_OPACITY = exports.ANIMATION_DURATION = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Shared default constants for `ResponsiveSheet`.
|
|
9
|
+
*
|
|
10
|
+
* Platform-agnostic — imported by both the default/web CSS implementation
|
|
11
|
+
* (`ResponsiveSheet.tsx`) and the native reanimated implementation
|
|
12
|
+
* (`ResponsiveSheet.native.tsx`) so the two variants stay in lockstep.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Below this viewport width the sheet renders as a bottom-sheet. */
|
|
16
|
+
const DEFAULT_BREAKPOINT = exports.DEFAULT_BREAKPOINT = 768;
|
|
17
|
+
|
|
18
|
+
/** Side-sheet width (px) on wide screens. Capped to fit the viewport. */
|
|
19
|
+
const DEFAULT_WIDTH = exports.DEFAULT_WIDTH = 460;
|
|
20
|
+
|
|
21
|
+
/** Bottom-sheet maximum height as a fraction of the viewport height. */
|
|
22
|
+
const DEFAULT_MAX_HEIGHT_RATIO = exports.DEFAULT_MAX_HEIGHT_RATIO = 0.9;
|
|
23
|
+
|
|
24
|
+
/** Anchored edge of the side-sheet on wide screens. */
|
|
25
|
+
const DEFAULT_SIDE = exports.DEFAULT_SIDE = 'left';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Open/close transition duration (ms). ~280–300ms ease-out reads as smooth
|
|
29
|
+
* without feeling sluggish; shared by the CSS transition and the native
|
|
30
|
+
* reanimated timing so both platforms match.
|
|
31
|
+
*/
|
|
32
|
+
const ANIMATION_DURATION = exports.ANIMATION_DURATION = 280;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Standard CSS approximation of reanimated's `Easing.out(Easing.cubic)` so the
|
|
36
|
+
* web transition curve matches the native one.
|
|
37
|
+
*/
|
|
38
|
+
const EASE_OUT = exports.EASE_OUT = 'cubic-bezier(0.33, 1, 0.68, 1)';
|
|
39
|
+
|
|
40
|
+
/** Corner radius for the side-sheet panel and the top of the bottom-sheet. */
|
|
41
|
+
const PANEL_RADIUS = exports.PANEL_RADIUS = 20;
|
|
42
|
+
|
|
43
|
+
/** Backdrop dim opacity once fully shown (matches `bg-black/40`). */
|
|
44
|
+
const BACKDROP_OPACITY = exports.BACKDROP_OPACITY = 0.4;
|
|
45
|
+
|
|
46
|
+
/** Drag-handle pill geometry for the bottom-sheet. */
|
|
47
|
+
const HANDLE_WIDTH = exports.HANDLE_WIDTH = 36;
|
|
48
|
+
const HANDLE_HEIGHT = exports.HANDLE_HEIGHT = 5;
|
|
49
|
+
const HANDLE_RADIUS = exports.HANDLE_RADIUS = 3;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Minimum gutter kept between a wide side-sheet and the opposite viewport edge
|
|
53
|
+
* when capping its width, so the panel never spans the full screen on a narrow
|
|
54
|
+
* desktop window that is still above the breakpoint.
|
|
55
|
+
*/
|
|
56
|
+
const SIDE_SHEET_MIN_GUTTER = exports.SIDE_SHEET_MIN_GUTTER = 24;
|
|
57
|
+
|
|
58
|
+
/** A11y label fallback when the host does not provide one. */
|
|
59
|
+
const DEFAULT_LABEL = exports.DEFAULT_LABEL = 'Sheet';
|
|
60
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_BREAKPOINT","exports","DEFAULT_WIDTH","DEFAULT_MAX_HEIGHT_RATIO","DEFAULT_SIDE","ANIMATION_DURATION","EASE_OUT","PANEL_RADIUS","BACKDROP_OPACITY","HANDLE_WIDTH","HANDLE_HEIGHT","HANDLE_RADIUS","SIDE_SHEET_MIN_GUTTER","DEFAULT_LABEL"],"sourceRoot":"../../../src","sources":["responsive-sheet/const.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,GAAG;;AAErC;AACO,MAAME,aAAa,GAAAD,OAAA,CAAAC,aAAA,GAAG,GAAG;;AAEhC;AACO,MAAMC,wBAAwB,GAAAF,OAAA,CAAAE,wBAAA,GAAG,GAAG;;AAE3C;AACO,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,MAAe;;AAE3C;AACA;AACA;AACA;AACA;AACO,MAAMC,kBAAkB,GAAAJ,OAAA,CAAAI,kBAAA,GAAG,GAAG;;AAErC;AACA;AACA;AACA;AACO,MAAMC,QAAQ,GAAAL,OAAA,CAAAK,QAAA,GAAG,gCAAgC;;AAExD;AACO,MAAMC,YAAY,GAAAN,OAAA,CAAAM,YAAA,GAAG,EAAE;;AAE9B;AACO,MAAMC,gBAAgB,GAAAP,OAAA,CAAAO,gBAAA,GAAG,GAAG;;AAEnC;AACO,MAAMC,YAAY,GAAAR,OAAA,CAAAQ,YAAA,GAAG,EAAE;AACvB,MAAMC,aAAa,GAAAT,OAAA,CAAAS,aAAA,GAAG,CAAC;AACvB,MAAMC,aAAa,GAAAV,OAAA,CAAAU,aAAA,GAAG,CAAC;;AAE9B;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAAX,OAAA,CAAAW,qBAAA,GAAG,EAAE;;AAEvC;AACO,MAAMC,aAAa,GAAAZ,OAAA,CAAAY,aAAA,GAAG,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "RESPONSIVE_SHEET_BACKDROP_TESTID", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ResponsiveSheet.RESPONSIVE_SHEET_BACKDROP_TESTID;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ResponsiveSheet", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _ResponsiveSheet.ResponsiveSheet;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _ResponsiveSheet = require("./ResponsiveSheet");
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ResponsiveSheet","require"],"sourceRoot":"../../../src","sources":["responsive-sheet/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA","ignoreList":[]}
|