@oxyhq/bloom 0.14.0 → 0.15.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/dialog/CenteredDialog.js +2 -0
- package/lib/commonjs/dialog/CenteredDialog.js.map +1 -1
- package/lib/commonjs/dialog/CenteredDialog.web.js +2 -0
- package/lib/commonjs/dialog/CenteredDialog.web.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.js +337 -43
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +414 -63
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/index.js +6 -0
- package/lib/commonjs/dialog/index.js.map +1 -1
- package/lib/commonjs/dialog/index.web.js +6 -0
- package/lib/commonjs/dialog/index.web.js.map +1 -1
- package/lib/commonjs/dialog/placement.js +104 -0
- package/lib/commonjs/dialog/placement.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +7 -0
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.js +63 -266
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.js.map +1 -1
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.web.js +84 -0
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.web.js.map +1 -0
- package/lib/commonjs/responsive-sheet/index.web.js +3 -3
- package/lib/commonjs/responsive-sheet/index.web.js.map +1 -1
- package/lib/module/dialog/CenteredDialog.js +2 -0
- package/lib/module/dialog/CenteredDialog.js.map +1 -1
- package/lib/module/dialog/CenteredDialog.web.js +2 -0
- package/lib/module/dialog/CenteredDialog.web.js.map +1 -1
- package/lib/module/dialog/Dialog.js +336 -46
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +412 -65
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/index.js +1 -1
- package/lib/module/dialog/index.js.map +1 -1
- package/lib/module/dialog/index.web.js +1 -1
- package/lib/module/dialog/index.web.js.map +1 -1
- package/lib/module/dialog/placement.js +100 -0
- package/lib/module/dialog/placement.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/responsive-sheet/ResponsiveSheet.js +63 -266
- package/lib/module/responsive-sheet/ResponsiveSheet.js.map +1 -1
- package/lib/module/responsive-sheet/ResponsiveSheet.web.js +77 -0
- package/lib/module/responsive-sheet/ResponsiveSheet.web.js.map +1 -0
- package/lib/module/responsive-sheet/index.web.js +7 -9
- package/lib/module/responsive-sheet/index.web.js.map +1 -1
- package/lib/typescript/commonjs/dialog/CenteredDialog.d.ts +2 -0
- package/lib/typescript/commonjs/dialog/CenteredDialog.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/CenteredDialog.web.d.ts +2 -0
- package/lib/typescript/commonjs/dialog/CenteredDialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/Dialog.d.ts +18 -15
- package/lib/typescript/commonjs/dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts +18 -5
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/centered-dialog-types.d.ts +4 -0
- package/lib/typescript/commonjs/dialog/centered-dialog-types.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/index.d.ts +2 -2
- package/lib/typescript/commonjs/dialog/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/index.web.d.ts +2 -2
- package/lib/typescript/commonjs/dialog/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/placement.d.ts +71 -0
- package/lib/typescript/commonjs/dialog/placement.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/types.d.ts +66 -3
- package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +2 -2
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +2 -2
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts +15 -19
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts.map +1 -1
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.web.d.ts +16 -0
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/responsive-sheet/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/responsive-sheet/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/responsive-sheet/types.d.ts +5 -2
- package/lib/typescript/commonjs/responsive-sheet/types.d.ts.map +1 -1
- package/lib/typescript/module/dialog/CenteredDialog.d.ts +2 -0
- package/lib/typescript/module/dialog/CenteredDialog.d.ts.map +1 -1
- package/lib/typescript/module/dialog/CenteredDialog.web.d.ts +2 -0
- package/lib/typescript/module/dialog/CenteredDialog.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/Dialog.d.ts +18 -15
- package/lib/typescript/module/dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/module/dialog/Dialog.web.d.ts +18 -5
- package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/centered-dialog-types.d.ts +4 -0
- package/lib/typescript/module/dialog/centered-dialog-types.d.ts.map +1 -1
- package/lib/typescript/module/dialog/index.d.ts +2 -2
- package/lib/typescript/module/dialog/index.d.ts.map +1 -1
- package/lib/typescript/module/dialog/index.web.d.ts +2 -2
- package/lib/typescript/module/dialog/index.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/placement.d.ts +71 -0
- package/lib/typescript/module/dialog/placement.d.ts.map +1 -0
- package/lib/typescript/module/dialog/types.d.ts +66 -3
- package/lib/typescript/module/dialog/types.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +2 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +2 -2
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts +15 -19
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts.map +1 -1
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.web.d.ts +16 -0
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.web.d.ts.map +1 -0
- package/lib/typescript/module/responsive-sheet/index.web.d.ts +1 -1
- package/lib/typescript/module/responsive-sheet/index.web.d.ts.map +1 -1
- package/lib/typescript/module/responsive-sheet/types.d.ts +5 -2
- package/lib/typescript/module/responsive-sheet/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/DialogPlacement.test.tsx +144 -0
- package/src/__tests__/ResponsiveSheet.test.tsx +36 -52
- package/src/dialog/CenteredDialog.tsx +2 -0
- package/src/dialog/CenteredDialog.web.tsx +2 -0
- package/src/dialog/Dialog.tsx +407 -50
- package/src/dialog/Dialog.web.tsx +490 -75
- package/src/dialog/centered-dialog-types.ts +4 -0
- package/src/dialog/index.ts +4 -1
- package/src/dialog/index.web.ts +4 -1
- package/src/dialog/placement.ts +113 -0
- package/src/dialog/types.ts +69 -3
- package/src/index.ts +4 -0
- package/src/index.web.ts +4 -0
- package/src/responsive-sheet/ResponsiveSheet.tsx +58 -297
- package/src/responsive-sheet/ResponsiveSheet.web.tsx +76 -0
- package/src/responsive-sheet/index.web.ts +7 -9
- package/src/responsive-sheet/types.ts +5 -2
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.native.js +0 -226
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.native.js.map +0 -1
- package/lib/commonjs/responsive-sheet/const.js +0 -60
- package/lib/commonjs/responsive-sheet/const.js.map +0 -1
- package/lib/module/responsive-sheet/ResponsiveSheet.native.js +0 -219
- package/lib/module/responsive-sheet/ResponsiveSheet.native.js.map +0 -1
- package/lib/module/responsive-sheet/const.js +0 -56
- package/lib/module/responsive-sheet/const.js.map +0 -1
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.native.d.ts +0 -20
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.native.d.ts.map +0 -1
- package/lib/typescript/commonjs/responsive-sheet/const.d.ts +0 -43
- package/lib/typescript/commonjs/responsive-sheet/const.d.ts.map +0 -1
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.native.d.ts +0 -20
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.native.d.ts.map +0 -1
- package/lib/typescript/module/responsive-sheet/const.d.ts +0 -43
- package/lib/typescript/module/responsive-sheet/const.d.ts.map +0 -1
- package/src/responsive-sheet/ResponsiveSheet.native.tsx +0 -257
- package/src/responsive-sheet/const.ts +0 -53
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared default constants for `ResponsiveSheet`.
|
|
3
|
-
*
|
|
4
|
-
* Platform-agnostic — imported by both the default/web CSS implementation
|
|
5
|
-
* (`ResponsiveSheet.tsx`) and the native reanimated implementation
|
|
6
|
-
* (`ResponsiveSheet.native.tsx`) so the two variants stay in lockstep.
|
|
7
|
-
*/
|
|
8
|
-
/** Below this viewport width the sheet renders as a bottom-sheet. */
|
|
9
|
-
export declare const DEFAULT_BREAKPOINT = 768;
|
|
10
|
-
/** Side-sheet width (px) on wide screens. Capped to fit the viewport. */
|
|
11
|
-
export declare const DEFAULT_WIDTH = 460;
|
|
12
|
-
/** Bottom-sheet maximum height as a fraction of the viewport height. */
|
|
13
|
-
export declare const DEFAULT_MAX_HEIGHT_RATIO = 0.9;
|
|
14
|
-
/** Anchored edge of the side-sheet on wide screens. */
|
|
15
|
-
export declare const DEFAULT_SIDE: "left";
|
|
16
|
-
/**
|
|
17
|
-
* Open/close transition duration (ms). ~280–300ms ease-out reads as smooth
|
|
18
|
-
* without feeling sluggish; shared by the CSS transition and the native
|
|
19
|
-
* reanimated timing so both platforms match.
|
|
20
|
-
*/
|
|
21
|
-
export declare const ANIMATION_DURATION = 280;
|
|
22
|
-
/**
|
|
23
|
-
* Standard CSS approximation of reanimated's `Easing.out(Easing.cubic)` so the
|
|
24
|
-
* web transition curve matches the native one.
|
|
25
|
-
*/
|
|
26
|
-
export declare const EASE_OUT = "cubic-bezier(0.33, 1, 0.68, 1)";
|
|
27
|
-
/** Corner radius for the side-sheet panel and the top of the bottom-sheet. */
|
|
28
|
-
export declare const PANEL_RADIUS = 20;
|
|
29
|
-
/** Backdrop dim opacity once fully shown (matches `bg-black/40`). */
|
|
30
|
-
export declare const BACKDROP_OPACITY = 0.4;
|
|
31
|
-
/** Drag-handle pill geometry for the bottom-sheet. */
|
|
32
|
-
export declare const HANDLE_WIDTH = 36;
|
|
33
|
-
export declare const HANDLE_HEIGHT = 5;
|
|
34
|
-
export declare const HANDLE_RADIUS = 3;
|
|
35
|
-
/**
|
|
36
|
-
* Minimum gutter kept between a wide side-sheet and the opposite viewport edge
|
|
37
|
-
* when capping its width, so the panel never spans the full screen on a narrow
|
|
38
|
-
* desktop window that is still above the breakpoint.
|
|
39
|
-
*/
|
|
40
|
-
export declare const SIDE_SHEET_MIN_GUTTER = 24;
|
|
41
|
-
/** A11y label fallback when the host does not provide one. */
|
|
42
|
-
export declare const DEFAULT_LABEL = "Sheet";
|
|
43
|
-
//# sourceMappingURL=const.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/const.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,yEAAyE;AACzE,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,uDAAuD;AACvD,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,QAAQ,mCAAmC,CAAC;AAEzD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,sDAAsD;AACtD,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,8DAA8D;AAC9D,eAAO,MAAM,aAAa,UAAU,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ResponsiveSheetProps } from './types';
|
|
2
|
-
/** Stable testID for the dimmed backdrop dismiss button. */
|
|
3
|
-
export declare const RESPONSIVE_SHEET_BACKDROP_TESTID = "bloom-responsive-sheet-backdrop";
|
|
4
|
-
/**
|
|
5
|
-
* Native variant of `<ResponsiveSheet>` (selected only by Metro).
|
|
6
|
-
*
|
|
7
|
-
* Uses `react-native-reanimated` to drive the same motion as the web/CSS
|
|
8
|
-
* default fork: a shared `progress` value times 0 -> 1 on open and 1 -> 0 on
|
|
9
|
-
* close, mapped to the panel translate/opacity and the backdrop opacity.
|
|
10
|
-
* Native exit animations are safe here — the web-only `removeChild` crash does
|
|
11
|
-
* not apply — so we keep the node mounted through the close timing and unmount
|
|
12
|
-
* from the animation completion callback.
|
|
13
|
-
*
|
|
14
|
-
* The panel itself is measured (not percentage-translated): we offset by the
|
|
15
|
-
* panel's own width/height so the hidden state sits fully off its side, which
|
|
16
|
-
* is the reanimated-friendly equivalent of the web `translate(±100%)`.
|
|
17
|
-
*/
|
|
18
|
-
export declare function ResponsiveSheet({ open, onClose, side, breakpoint, width, maxHeightRatio, inset, showHandle, dismissOnBackdrop, panelStyle, panelClassName, containerStyle, containerClassName, label, children, }: ResponsiveSheetProps): import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
-
export default ResponsiveSheet;
|
|
20
|
-
//# sourceMappingURL=ResponsiveSheet.native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsiveSheet.native.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/ResponsiveSheet.native.tsx"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,4DAA4D;AAC5D,eAAO,MAAM,gCAAgC,oCAAoC,CAAC;AAElF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,IAAmB,EACnB,UAA+B,EAC/B,KAAqB,EACrB,cAAyC,EACzC,KAAK,EACL,UAAiB,EACjB,iBAAwB,EACxB,UAAU,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,KAAqB,EACrB,QAAQ,GACT,EAAE,oBAAoB,kDAqJtB;AAiCD,eAAe,eAAe,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared default constants for `ResponsiveSheet`.
|
|
3
|
-
*
|
|
4
|
-
* Platform-agnostic — imported by both the default/web CSS implementation
|
|
5
|
-
* (`ResponsiveSheet.tsx`) and the native reanimated implementation
|
|
6
|
-
* (`ResponsiveSheet.native.tsx`) so the two variants stay in lockstep.
|
|
7
|
-
*/
|
|
8
|
-
/** Below this viewport width the sheet renders as a bottom-sheet. */
|
|
9
|
-
export declare const DEFAULT_BREAKPOINT = 768;
|
|
10
|
-
/** Side-sheet width (px) on wide screens. Capped to fit the viewport. */
|
|
11
|
-
export declare const DEFAULT_WIDTH = 460;
|
|
12
|
-
/** Bottom-sheet maximum height as a fraction of the viewport height. */
|
|
13
|
-
export declare const DEFAULT_MAX_HEIGHT_RATIO = 0.9;
|
|
14
|
-
/** Anchored edge of the side-sheet on wide screens. */
|
|
15
|
-
export declare const DEFAULT_SIDE: "left";
|
|
16
|
-
/**
|
|
17
|
-
* Open/close transition duration (ms). ~280–300ms ease-out reads as smooth
|
|
18
|
-
* without feeling sluggish; shared by the CSS transition and the native
|
|
19
|
-
* reanimated timing so both platforms match.
|
|
20
|
-
*/
|
|
21
|
-
export declare const ANIMATION_DURATION = 280;
|
|
22
|
-
/**
|
|
23
|
-
* Standard CSS approximation of reanimated's `Easing.out(Easing.cubic)` so the
|
|
24
|
-
* web transition curve matches the native one.
|
|
25
|
-
*/
|
|
26
|
-
export declare const EASE_OUT = "cubic-bezier(0.33, 1, 0.68, 1)";
|
|
27
|
-
/** Corner radius for the side-sheet panel and the top of the bottom-sheet. */
|
|
28
|
-
export declare const PANEL_RADIUS = 20;
|
|
29
|
-
/** Backdrop dim opacity once fully shown (matches `bg-black/40`). */
|
|
30
|
-
export declare const BACKDROP_OPACITY = 0.4;
|
|
31
|
-
/** Drag-handle pill geometry for the bottom-sheet. */
|
|
32
|
-
export declare const HANDLE_WIDTH = 36;
|
|
33
|
-
export declare const HANDLE_HEIGHT = 5;
|
|
34
|
-
export declare const HANDLE_RADIUS = 3;
|
|
35
|
-
/**
|
|
36
|
-
* Minimum gutter kept between a wide side-sheet and the opposite viewport edge
|
|
37
|
-
* when capping its width, so the panel never spans the full screen on a narrow
|
|
38
|
-
* desktop window that is still above the breakpoint.
|
|
39
|
-
*/
|
|
40
|
-
export declare const SIDE_SHEET_MIN_GUTTER = 24;
|
|
41
|
-
/** A11y label fallback when the host does not provide one. */
|
|
42
|
-
export declare const DEFAULT_LABEL = "Sheet";
|
|
43
|
-
//# sourceMappingURL=const.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/const.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,yEAAyE;AACzE,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,uDAAuD;AACvD,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,QAAQ,mCAAmC,CAAC;AAEzD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,sDAAsD;AACtD,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,8DAA8D;AAC9D,eAAO,MAAM,aAAa,UAAU,CAAC"}
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useCallback,
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import {
|
|
9
|
-
Pressable,
|
|
10
|
-
StyleSheet,
|
|
11
|
-
useWindowDimensions,
|
|
12
|
-
View,
|
|
13
|
-
type ViewStyle,
|
|
14
|
-
} from 'react-native';
|
|
15
|
-
import Animated, {
|
|
16
|
-
cancelAnimation,
|
|
17
|
-
Easing,
|
|
18
|
-
runOnJS,
|
|
19
|
-
useAnimatedStyle,
|
|
20
|
-
useSharedValue,
|
|
21
|
-
withTiming,
|
|
22
|
-
} from 'react-native-reanimated';
|
|
23
|
-
|
|
24
|
-
import { Z_INDEX } from '../styles/z-index';
|
|
25
|
-
import { useTheme } from '../theme/use-theme';
|
|
26
|
-
import {
|
|
27
|
-
ANIMATION_DURATION,
|
|
28
|
-
BACKDROP_OPACITY,
|
|
29
|
-
DEFAULT_BREAKPOINT,
|
|
30
|
-
DEFAULT_LABEL,
|
|
31
|
-
DEFAULT_MAX_HEIGHT_RATIO,
|
|
32
|
-
DEFAULT_SIDE,
|
|
33
|
-
DEFAULT_WIDTH,
|
|
34
|
-
HANDLE_HEIGHT,
|
|
35
|
-
HANDLE_RADIUS,
|
|
36
|
-
HANDLE_WIDTH,
|
|
37
|
-
PANEL_RADIUS,
|
|
38
|
-
SIDE_SHEET_MIN_GUTTER,
|
|
39
|
-
} from './const';
|
|
40
|
-
import type { ResponsiveSheetProps } from './types';
|
|
41
|
-
|
|
42
|
-
/** Stable testID for the dimmed backdrop dismiss button. */
|
|
43
|
-
export const RESPONSIVE_SHEET_BACKDROP_TESTID = 'bloom-responsive-sheet-backdrop';
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Native variant of `<ResponsiveSheet>` (selected only by Metro).
|
|
47
|
-
*
|
|
48
|
-
* Uses `react-native-reanimated` to drive the same motion as the web/CSS
|
|
49
|
-
* default fork: a shared `progress` value times 0 -> 1 on open and 1 -> 0 on
|
|
50
|
-
* close, mapped to the panel translate/opacity and the backdrop opacity.
|
|
51
|
-
* Native exit animations are safe here — the web-only `removeChild` crash does
|
|
52
|
-
* not apply — so we keep the node mounted through the close timing and unmount
|
|
53
|
-
* from the animation completion callback.
|
|
54
|
-
*
|
|
55
|
-
* The panel itself is measured (not percentage-translated): we offset by the
|
|
56
|
-
* panel's own width/height so the hidden state sits fully off its side, which
|
|
57
|
-
* is the reanimated-friendly equivalent of the web `translate(±100%)`.
|
|
58
|
-
*/
|
|
59
|
-
export function ResponsiveSheet({
|
|
60
|
-
open,
|
|
61
|
-
onClose,
|
|
62
|
-
side = DEFAULT_SIDE,
|
|
63
|
-
breakpoint = DEFAULT_BREAKPOINT,
|
|
64
|
-
width = DEFAULT_WIDTH,
|
|
65
|
-
maxHeightRatio = DEFAULT_MAX_HEIGHT_RATIO,
|
|
66
|
-
inset,
|
|
67
|
-
showHandle = true,
|
|
68
|
-
dismissOnBackdrop = true,
|
|
69
|
-
panelStyle,
|
|
70
|
-
panelClassName,
|
|
71
|
-
containerStyle,
|
|
72
|
-
containerClassName,
|
|
73
|
-
label = DEFAULT_LABEL,
|
|
74
|
-
children,
|
|
75
|
-
}: ResponsiveSheetProps) {
|
|
76
|
-
const theme = useTheme();
|
|
77
|
-
const { width: viewportWidth, height: viewportHeight } = useWindowDimensions();
|
|
78
|
-
|
|
79
|
-
// Keep the tree mounted through the exit timing; unmount once it settles.
|
|
80
|
-
const [mounted, setMounted] = useState(open);
|
|
81
|
-
// `progress`: 0 = fully hidden, 1 = fully shown. Drives both transform and
|
|
82
|
-
// opacity so a single timing controls the whole transition.
|
|
83
|
-
const progress = useSharedValue(open ? 1 : 0);
|
|
84
|
-
|
|
85
|
-
const isBottom = viewportWidth < breakpoint;
|
|
86
|
-
|
|
87
|
-
// Measured panel extent along the travel axis. Falls back to the geometry
|
|
88
|
-
// target so the very first frame is already off-screen before layout lands.
|
|
89
|
-
const insetTop = inset?.top ?? 0;
|
|
90
|
-
const insetBottom = inset?.bottom ?? 0;
|
|
91
|
-
const insetLeft = inset?.left ?? 0;
|
|
92
|
-
const insetRight = inset?.right ?? 0;
|
|
93
|
-
const anchorInset = side === 'left' ? insetLeft : insetRight;
|
|
94
|
-
const oppositeInset = side === 'left' ? insetRight : insetLeft;
|
|
95
|
-
|
|
96
|
-
const sideWidth = useMemo(() => {
|
|
97
|
-
const available = viewportWidth - anchorInset - oppositeInset - SIDE_SHEET_MIN_GUTTER;
|
|
98
|
-
return Math.max(0, Math.min(width, available));
|
|
99
|
-
}, [viewportWidth, anchorInset, oppositeInset, width]);
|
|
100
|
-
|
|
101
|
-
const bottomMaxHeight = useMemo(
|
|
102
|
-
() => Math.round(viewportHeight * maxHeightRatio),
|
|
103
|
-
[viewportHeight, maxHeightRatio],
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
// Travel distance for the hidden state: the panel's measured extent (height
|
|
107
|
-
// for the bottom-sheet, width for the side-sheet), with the geometry target
|
|
108
|
-
// as the pre-measurement fallback.
|
|
109
|
-
const travel = useSharedValue(isBottom ? bottomMaxHeight : sideWidth);
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
travel.value = isBottom ? bottomMaxHeight : sideWidth;
|
|
112
|
-
}, [isBottom, bottomMaxHeight, sideWidth, travel]);
|
|
113
|
-
|
|
114
|
-
const finishClose = useCallback(() => {
|
|
115
|
-
setMounted(false);
|
|
116
|
-
}, []);
|
|
117
|
-
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
cancelAnimation(progress);
|
|
120
|
-
const timing = { duration: ANIMATION_DURATION, easing: Easing.out(Easing.cubic) };
|
|
121
|
-
if (open) {
|
|
122
|
-
setMounted(true);
|
|
123
|
-
progress.value = withTiming(1, timing);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (!mounted) return;
|
|
127
|
-
progress.value = withTiming(0, timing, (finished) => {
|
|
128
|
-
if (finished) runOnJS(finishClose)();
|
|
129
|
-
});
|
|
130
|
-
}, [open, mounted, progress, finishClose]);
|
|
131
|
-
|
|
132
|
-
const handleBackdropPress = useCallback(() => {
|
|
133
|
-
if (dismissOnBackdrop) onClose();
|
|
134
|
-
}, [dismissOnBackdrop, onClose]);
|
|
135
|
-
|
|
136
|
-
const backdropAnimatedStyle = useAnimatedStyle(() => ({
|
|
137
|
-
opacity: progress.value * BACKDROP_OPACITY,
|
|
138
|
-
}));
|
|
139
|
-
|
|
140
|
-
const hiddenSign = side === 'left' ? -1 : 1;
|
|
141
|
-
const panelAnimatedStyle = useAnimatedStyle(() => {
|
|
142
|
-
const hidden = 1 - progress.value;
|
|
143
|
-
if (isBottom) {
|
|
144
|
-
return {
|
|
145
|
-
opacity: progress.value,
|
|
146
|
-
transform: [{ translateY: hidden * travel.value }],
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
opacity: progress.value,
|
|
151
|
-
transform: [{ translateX: hidden * travel.value * hiddenSign }],
|
|
152
|
-
};
|
|
153
|
-
}, [isBottom, hiddenSign]);
|
|
154
|
-
|
|
155
|
-
const measurePanel = useCallback(
|
|
156
|
-
(e: { nativeEvent: { layout: { width: number; height: number } } }) => {
|
|
157
|
-
const measured = isBottom ? e.nativeEvent.layout.height : e.nativeEvent.layout.width;
|
|
158
|
-
if (measured > 0) travel.value = measured;
|
|
159
|
-
},
|
|
160
|
-
[isBottom, travel],
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
const panelGeometry = useMemo<ViewStyle>(() => {
|
|
164
|
-
if (isBottom) {
|
|
165
|
-
return {
|
|
166
|
-
left: 0,
|
|
167
|
-
right: 0,
|
|
168
|
-
bottom: 0,
|
|
169
|
-
maxHeight: bottomMaxHeight,
|
|
170
|
-
borderTopLeftRadius: PANEL_RADIUS,
|
|
171
|
-
borderTopRightRadius: PANEL_RADIUS,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
return {
|
|
175
|
-
top: insetTop,
|
|
176
|
-
bottom: insetBottom,
|
|
177
|
-
[side]: anchorInset,
|
|
178
|
-
width: sideWidth,
|
|
179
|
-
borderRadius: PANEL_RADIUS,
|
|
180
|
-
} as ViewStyle;
|
|
181
|
-
}, [isBottom, bottomMaxHeight, insetTop, insetBottom, side, anchorInset, sideWidth]);
|
|
182
|
-
|
|
183
|
-
if (!mounted) return null;
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<View
|
|
187
|
-
style={[styles.root, containerStyle]}
|
|
188
|
-
{...(containerClassName ? ({ className: containerClassName } as Record<string, string>) : {})}
|
|
189
|
-
pointerEvents="box-none"
|
|
190
|
-
>
|
|
191
|
-
<Animated.View style={[styles.backdrop, backdropAnimatedStyle]} pointerEvents="auto">
|
|
192
|
-
<Pressable
|
|
193
|
-
testID={RESPONSIVE_SHEET_BACKDROP_TESTID}
|
|
194
|
-
accessibilityRole="button"
|
|
195
|
-
accessibilityLabel={`Dismiss ${label}`}
|
|
196
|
-
onPress={handleBackdropPress}
|
|
197
|
-
disabled={!dismissOnBackdrop}
|
|
198
|
-
style={StyleSheet.absoluteFill}
|
|
199
|
-
/>
|
|
200
|
-
</Animated.View>
|
|
201
|
-
|
|
202
|
-
<Animated.View
|
|
203
|
-
accessibilityViewIsModal
|
|
204
|
-
{...(panelClassName ? ({ className: panelClassName } as Record<string, string>) : {})}
|
|
205
|
-
onLayout={measurePanel}
|
|
206
|
-
style={[
|
|
207
|
-
styles.panel,
|
|
208
|
-
{ backgroundColor: theme.colors.background, shadowColor: theme.colors.shadow },
|
|
209
|
-
panelGeometry,
|
|
210
|
-
panelAnimatedStyle,
|
|
211
|
-
panelStyle,
|
|
212
|
-
]}
|
|
213
|
-
pointerEvents="auto"
|
|
214
|
-
>
|
|
215
|
-
{isBottom && showHandle ? (
|
|
216
|
-
<View style={styles.handleRow} pointerEvents="none">
|
|
217
|
-
<View style={[styles.handle, { backgroundColor: theme.colors.border }]} />
|
|
218
|
-
</View>
|
|
219
|
-
) : null}
|
|
220
|
-
{children}
|
|
221
|
-
</Animated.View>
|
|
222
|
-
</View>
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const styles = StyleSheet.create({
|
|
227
|
-
root: {
|
|
228
|
-
...StyleSheet.absoluteFill,
|
|
229
|
-
zIndex: Z_INDEX.fullscreen,
|
|
230
|
-
},
|
|
231
|
-
backdrop: {
|
|
232
|
-
...StyleSheet.absoluteFill,
|
|
233
|
-
backgroundColor: '#000',
|
|
234
|
-
},
|
|
235
|
-
panel: {
|
|
236
|
-
position: 'absolute',
|
|
237
|
-
overflow: 'hidden',
|
|
238
|
-
shadowOpacity: 0.18,
|
|
239
|
-
shadowRadius: 24,
|
|
240
|
-
shadowOffset: { width: 0, height: 8 },
|
|
241
|
-
elevation: 12,
|
|
242
|
-
},
|
|
243
|
-
handleRow: {
|
|
244
|
-
width: '100%',
|
|
245
|
-
alignItems: 'center',
|
|
246
|
-
paddingTop: 8,
|
|
247
|
-
paddingBottom: 4,
|
|
248
|
-
},
|
|
249
|
-
handle: {
|
|
250
|
-
width: HANDLE_WIDTH,
|
|
251
|
-
height: HANDLE_HEIGHT,
|
|
252
|
-
borderRadius: HANDLE_RADIUS,
|
|
253
|
-
opacity: 0.5,
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
export default ResponsiveSheet;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared default constants for `ResponsiveSheet`.
|
|
3
|
-
*
|
|
4
|
-
* Platform-agnostic — imported by both the default/web CSS implementation
|
|
5
|
-
* (`ResponsiveSheet.tsx`) and the native reanimated implementation
|
|
6
|
-
* (`ResponsiveSheet.native.tsx`) so the two variants stay in lockstep.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/** Below this viewport width the sheet renders as a bottom-sheet. */
|
|
10
|
-
export const DEFAULT_BREAKPOINT = 768;
|
|
11
|
-
|
|
12
|
-
/** Side-sheet width (px) on wide screens. Capped to fit the viewport. */
|
|
13
|
-
export const DEFAULT_WIDTH = 460;
|
|
14
|
-
|
|
15
|
-
/** Bottom-sheet maximum height as a fraction of the viewport height. */
|
|
16
|
-
export const DEFAULT_MAX_HEIGHT_RATIO = 0.9;
|
|
17
|
-
|
|
18
|
-
/** Anchored edge of the side-sheet on wide screens. */
|
|
19
|
-
export const DEFAULT_SIDE = 'left' as const;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Open/close transition duration (ms). ~280–300ms ease-out reads as smooth
|
|
23
|
-
* without feeling sluggish; shared by the CSS transition and the native
|
|
24
|
-
* reanimated timing so both platforms match.
|
|
25
|
-
*/
|
|
26
|
-
export const ANIMATION_DURATION = 280;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Standard CSS approximation of reanimated's `Easing.out(Easing.cubic)` so the
|
|
30
|
-
* web transition curve matches the native one.
|
|
31
|
-
*/
|
|
32
|
-
export const EASE_OUT = 'cubic-bezier(0.33, 1, 0.68, 1)';
|
|
33
|
-
|
|
34
|
-
/** Corner radius for the side-sheet panel and the top of the bottom-sheet. */
|
|
35
|
-
export const PANEL_RADIUS = 20;
|
|
36
|
-
|
|
37
|
-
/** Backdrop dim opacity once fully shown (matches `bg-black/40`). */
|
|
38
|
-
export const BACKDROP_OPACITY = 0.4;
|
|
39
|
-
|
|
40
|
-
/** Drag-handle pill geometry for the bottom-sheet. */
|
|
41
|
-
export const HANDLE_WIDTH = 36;
|
|
42
|
-
export const HANDLE_HEIGHT = 5;
|
|
43
|
-
export const HANDLE_RADIUS = 3;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Minimum gutter kept between a wide side-sheet and the opposite viewport edge
|
|
47
|
-
* when capping its width, so the panel never spans the full screen on a narrow
|
|
48
|
-
* desktop window that is still above the breakpoint.
|
|
49
|
-
*/
|
|
50
|
-
export const SIDE_SHEET_MIN_GUTTER = 24;
|
|
51
|
-
|
|
52
|
-
/** A11y label fallback when the host does not provide one. */
|
|
53
|
-
export const DEFAULT_LABEL = 'Sheet';
|