@oxyhq/bloom 0.14.0 → 0.16.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/alert-dialog/AlertDialog.js +35 -27
- package/lib/commonjs/alert-dialog/AlertDialog.js.map +1 -1
- package/lib/commonjs/alert-dialog/index.js +1 -1
- package/lib/commonjs/alert-dialog/index.js.map +1 -1
- package/lib/commonjs/alert-dialog/index.web.js +1 -1
- package/lib/commonjs/alert-dialog/index.web.js.map +1 -1
- package/lib/commonjs/command/Command.js +27 -16
- package/lib/commonjs/command/Command.js.map +1 -1
- package/lib/commonjs/command/index.js +1 -1
- package/lib/commonjs/command/index.js.map +1 -1
- package/lib/commonjs/command/index.web.js +1 -1
- package/lib/commonjs/command/index.web.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.js +336 -43
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +420 -66
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/index.js +2 -9
- package/lib/commonjs/dialog/index.js.map +1 -1
- package/lib/commonjs/dialog/index.web.js +2 -15
- 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 -29
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +13 -35
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/module/alert-dialog/AlertDialog.js +35 -27
- package/lib/module/alert-dialog/AlertDialog.js.map +1 -1
- package/lib/module/alert-dialog/index.js +2 -2
- package/lib/module/alert-dialog/index.js.map +1 -1
- package/lib/module/alert-dialog/index.web.js +2 -2
- package/lib/module/alert-dialog/index.web.js.map +1 -1
- package/lib/module/command/Command.js +27 -16
- package/lib/module/command/Command.js.map +1 -1
- package/lib/module/command/index.js +2 -2
- package/lib/module/command/index.js.map +1 -1
- package/lib/module/command/index.web.js +2 -2
- package/lib/module/command/index.web.js.map +1 -1
- package/lib/module/dialog/Dialog.js +335 -46
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +418 -68
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/index.js +1 -2
- package/lib/module/dialog/index.js.map +1 -1
- package/lib/module/dialog/index.web.js +1 -2
- 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 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -3
- package/lib/module/index.web.js.map +1 -1
- package/lib/typescript/commonjs/alert-dialog/AlertDialog.d.ts +13 -12
- package/lib/typescript/commonjs/alert-dialog/AlertDialog.d.ts.map +1 -1
- package/lib/typescript/commonjs/alert-dialog/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/alert-dialog/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/command/Command.d.ts +8 -8
- package/lib/typescript/commonjs/command/Command.d.ts.map +1 -1
- package/lib/typescript/commonjs/command/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/command/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/Dialog.d.ts +17 -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/index.d.ts +2 -4
- package/lib/typescript/commonjs/dialog/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/index.web.d.ts +2 -4
- 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 -4
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +2 -4
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/module/alert-dialog/AlertDialog.d.ts +13 -12
- package/lib/typescript/module/alert-dialog/AlertDialog.d.ts.map +1 -1
- package/lib/typescript/module/alert-dialog/index.d.ts.map +1 -1
- package/lib/typescript/module/alert-dialog/index.web.d.ts.map +1 -1
- package/lib/typescript/module/command/Command.d.ts +8 -8
- package/lib/typescript/module/command/Command.d.ts.map +1 -1
- package/lib/typescript/module/command/index.d.ts.map +1 -1
- package/lib/typescript/module/command/index.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/Dialog.d.ts +17 -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/index.d.ts +2 -4
- package/lib/typescript/module/dialog/index.d.ts.map +1 -1
- package/lib/typescript/module/dialog/index.web.d.ts +2 -4
- 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 -4
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +2 -4
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/package.json +1 -18
- package/src/__tests__/AlertDialog.test.tsx +122 -0
- package/src/__tests__/Command.test.tsx +107 -0
- package/src/__tests__/DialogPlacement.test.tsx +144 -0
- package/src/alert-dialog/AlertDialog.tsx +46 -36
- package/src/alert-dialog/index.ts +2 -2
- package/src/alert-dialog/index.web.ts +2 -2
- package/src/command/Command.tsx +30 -19
- package/src/command/index.ts +2 -2
- package/src/command/index.web.ts +2 -2
- package/src/dialog/Dialog.tsx +406 -50
- package/src/dialog/Dialog.web.tsx +496 -78
- package/src/dialog/index.ts +4 -3
- package/src/dialog/index.web.ts +4 -7
- package/src/dialog/placement.ts +113 -0
- package/src/dialog/types.ts +69 -3
- package/src/index.ts +4 -11
- package/src/index.web.ts +4 -11
- package/lib/commonjs/dialog/CenteredDialog.js +0 -250
- package/lib/commonjs/dialog/CenteredDialog.js.map +0 -1
- package/lib/commonjs/dialog/CenteredDialog.web.js +0 -328
- package/lib/commonjs/dialog/CenteredDialog.web.js.map +0 -1
- package/lib/commonjs/dialog/centered-dialog-tokens.js +0 -62
- package/lib/commonjs/dialog/centered-dialog-tokens.js.map +0 -1
- package/lib/commonjs/dialog/centered-dialog-types.js +0 -6
- package/lib/commonjs/dialog/centered-dialog-types.js.map +0 -1
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.js +0 -300
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.js.map +0 -1
- 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/commonjs/responsive-sheet/index.js +0 -19
- package/lib/commonjs/responsive-sheet/index.js.map +0 -1
- package/lib/commonjs/responsive-sheet/index.web.js +0 -19
- package/lib/commonjs/responsive-sheet/index.web.js.map +0 -1
- package/lib/commonjs/responsive-sheet/types.js +0 -6
- package/lib/commonjs/responsive-sheet/types.js.map +0 -1
- package/lib/module/dialog/CenteredDialog.js +0 -244
- package/lib/module/dialog/CenteredDialog.js.map +0 -1
- package/lib/module/dialog/CenteredDialog.web.js +0 -322
- package/lib/module/dialog/CenteredDialog.web.js.map +0 -1
- package/lib/module/dialog/centered-dialog-tokens.js +0 -58
- package/lib/module/dialog/centered-dialog-tokens.js.map +0 -1
- package/lib/module/dialog/centered-dialog-types.js +0 -4
- package/lib/module/dialog/centered-dialog-types.js.map +0 -1
- package/lib/module/responsive-sheet/ResponsiveSheet.js +0 -293
- package/lib/module/responsive-sheet/ResponsiveSheet.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/module/responsive-sheet/index.js +0 -4
- package/lib/module/responsive-sheet/index.js.map +0 -1
- package/lib/module/responsive-sheet/index.web.js +0 -14
- package/lib/module/responsive-sheet/index.web.js.map +0 -1
- package/lib/module/responsive-sheet/types.js +0 -4
- package/lib/module/responsive-sheet/types.js.map +0 -1
- package/lib/typescript/commonjs/dialog/CenteredDialog.d.ts +0 -20
- package/lib/typescript/commonjs/dialog/CenteredDialog.d.ts.map +0 -1
- package/lib/typescript/commonjs/dialog/CenteredDialog.web.d.ts +0 -29
- package/lib/typescript/commonjs/dialog/CenteredDialog.web.d.ts.map +0 -1
- package/lib/typescript/commonjs/dialog/centered-dialog-tokens.d.ts +0 -47
- package/lib/typescript/commonjs/dialog/centered-dialog-tokens.d.ts.map +0 -1
- package/lib/typescript/commonjs/dialog/centered-dialog-types.d.ts +0 -70
- package/lib/typescript/commonjs/dialog/centered-dialog-types.d.ts.map +0 -1
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts +0 -26
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts.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/commonjs/responsive-sheet/index.d.ts +0 -3
- package/lib/typescript/commonjs/responsive-sheet/index.d.ts.map +0 -1
- package/lib/typescript/commonjs/responsive-sheet/index.web.d.ts +0 -3
- package/lib/typescript/commonjs/responsive-sheet/index.web.d.ts.map +0 -1
- package/lib/typescript/commonjs/responsive-sheet/types.d.ts +0 -55
- package/lib/typescript/commonjs/responsive-sheet/types.d.ts.map +0 -1
- package/lib/typescript/module/dialog/CenteredDialog.d.ts +0 -20
- package/lib/typescript/module/dialog/CenteredDialog.d.ts.map +0 -1
- package/lib/typescript/module/dialog/CenteredDialog.web.d.ts +0 -29
- package/lib/typescript/module/dialog/CenteredDialog.web.d.ts.map +0 -1
- package/lib/typescript/module/dialog/centered-dialog-tokens.d.ts +0 -47
- package/lib/typescript/module/dialog/centered-dialog-tokens.d.ts.map +0 -1
- package/lib/typescript/module/dialog/centered-dialog-types.d.ts +0 -70
- package/lib/typescript/module/dialog/centered-dialog-types.d.ts.map +0 -1
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts +0 -26
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.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/lib/typescript/module/responsive-sheet/index.d.ts +0 -3
- package/lib/typescript/module/responsive-sheet/index.d.ts.map +0 -1
- package/lib/typescript/module/responsive-sheet/index.web.d.ts +0 -3
- package/lib/typescript/module/responsive-sheet/index.web.d.ts.map +0 -1
- package/lib/typescript/module/responsive-sheet/types.d.ts +0 -55
- package/lib/typescript/module/responsive-sheet/types.d.ts.map +0 -1
- package/src/__tests__/CenteredDialog.test.tsx +0 -108
- package/src/__tests__/ResponsiveSheet.test.tsx +0 -104
- package/src/dialog/CenteredDialog.stories.tsx +0 -125
- package/src/dialog/CenteredDialog.tsx +0 -303
- package/src/dialog/CenteredDialog.web.tsx +0 -372
- package/src/dialog/centered-dialog-tokens.ts +0 -68
- package/src/dialog/centered-dialog-types.ts +0 -70
- package/src/responsive-sheet/ResponsiveSheet.native.tsx +0 -257
- package/src/responsive-sheet/ResponsiveSheet.stories.tsx +0 -54
- package/src/responsive-sheet/ResponsiveSheet.tsx +0 -327
- package/src/responsive-sheet/const.ts +0 -53
- package/src/responsive-sheet/index.ts +0 -6
- package/src/responsive-sheet/index.web.ts +0 -16
- package/src/responsive-sheet/types.ts +0 -57
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
/**
|
|
4
|
-
* Props for the declarative `<CenteredDialog>` primitive.
|
|
5
|
-
*
|
|
6
|
-
* This is the simple, controlled centered-modal surface — distinct from the
|
|
7
|
-
* imperative `useDialogControl()` + `<Dialog control={…}>` API in the same
|
|
8
|
-
* module. Reach for `<CenteredDialog>` when you already own the open/closed
|
|
9
|
-
* boolean (a `useState`, a query flag, a route param) and just want Bloom to
|
|
10
|
-
* render the dimmed backdrop + a snug, theme-styled centered card.
|
|
11
|
-
*
|
|
12
|
-
* All spacing/colour/radius come from Bloom theme tokens — the card reads
|
|
13
|
-
* compact out of the box (`compact` defaults to `true`).
|
|
14
|
-
*/
|
|
15
|
-
export type CenteredDialogProps = {
|
|
16
|
-
/** Whether the dialog is mounted + visible. */
|
|
17
|
-
visible: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Close request — fired on backdrop tap (when `dismissible`), the close
|
|
20
|
-
* button, the hardware back button (Android), and `Escape` (web). The
|
|
21
|
-
* caller owns the visible state, so it must flip `visible` to `false` here.
|
|
22
|
-
*/
|
|
23
|
-
onClose: () => void;
|
|
24
|
-
/**
|
|
25
|
-
* Optional header title. When set (or when `showClose` is `true`) Bloom
|
|
26
|
-
* renders a tight header row above the content.
|
|
27
|
-
*/
|
|
28
|
-
title?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Tap-outside / back-button / Escape dismisses the dialog. Defaults to
|
|
31
|
-
* `true`. Set `false` for blocking flows (e.g. a destructive confirm that
|
|
32
|
-
* must be answered via an explicit action).
|
|
33
|
-
*/
|
|
34
|
-
dismissible?: boolean;
|
|
35
|
-
/** Max card width in px. Defaults to {@link DEFAULT_MAX_WIDTH} (440). */
|
|
36
|
-
maxWidth?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Tight, snug spacing (the Bloom default). Set `false` for a roomier card
|
|
39
|
-
* with larger padding and header/footer gaps. Defaults to `true`.
|
|
40
|
-
*/
|
|
41
|
-
compact?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Render a close (✕) icon button in the header. Defaults to `true` when a
|
|
44
|
-
* `title` is provided, otherwise `false` (a chromeless card owns its own
|
|
45
|
-
* dismissal affordances).
|
|
46
|
-
*/
|
|
47
|
-
showClose?: boolean;
|
|
48
|
-
/** Card body. Scrolls within the height cap when it overflows. */
|
|
49
|
-
children?: ReactNode;
|
|
50
|
-
/**
|
|
51
|
-
* Optional footer slot for actions (e.g. a Bloom `<Button>` row). Rendered
|
|
52
|
-
* below the scrollable body with a hairline separator.
|
|
53
|
-
*/
|
|
54
|
-
footer?: ReactNode;
|
|
55
|
-
/**
|
|
56
|
-
* Accessibility label for the dialog surface. Falls back to `title` when
|
|
57
|
-
* omitted.
|
|
58
|
-
*/
|
|
59
|
-
accessibilityLabel?: string;
|
|
60
|
-
/** Accessibility label for the header close (✕) button. */
|
|
61
|
-
closeAccessibilityLabel?: string;
|
|
62
|
-
/** Accessibility label for the dimmed backdrop's tap-to-dismiss affordance. */
|
|
63
|
-
backdropAccessibilityLabel?: string;
|
|
64
|
-
/** Style overrides merged onto the centered card container. */
|
|
65
|
-
cardStyle?: StyleProp<ViewStyle>;
|
|
66
|
-
/** Style overrides merged onto the scrollable content container. */
|
|
67
|
-
contentStyle?: StyleProp<ViewStyle>;
|
|
68
|
-
testID?: string;
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=centered-dialog-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"centered-dialog-types.d.ts","sourceRoot":"","sources":["../../../../src/dialog/centered-dialog-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,2DAA2D;IAC3D,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,+EAA+E;IAC/E,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,+DAA+D;IAC/D,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,oEAAoE;IACpE,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -1,26 +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
|
-
* Default / web variant of `<ResponsiveSheet>`.
|
|
6
|
-
*
|
|
7
|
-
* This file is BOTH the package's default entry (`react-native` export
|
|
8
|
-
* condition resolves it for downstream `tsc`, and non-Metro web bundlers pick
|
|
9
|
-
* it via the `browser` condition through `index.web`) AND the canonical web
|
|
10
|
-
* implementation. It MUST NOT import `react-native-reanimated` — reanimated has
|
|
11
|
-
* no web build and its worklets Babel plugin is native-only, so a static import
|
|
12
|
-
* here would break every web bundler and downstream type-check. The native
|
|
13
|
-
* fork (`ResponsiveSheet.native.tsx`, selected only by Metro) drives the same
|
|
14
|
-
* motion with reanimated.
|
|
15
|
-
*
|
|
16
|
-
* Motion is pure CSS transitions: react-native-web emits `transition-*` style
|
|
17
|
-
* props to the DOM, and the panel/backdrop toggle their transform/opacity by a
|
|
18
|
-
* `shown` flag. Presence is handled with a `mounted` + `shown` pair so both the
|
|
19
|
-
* open AND close directions animate while the node stays mounted through the
|
|
20
|
-
* exit. We deliberately do NOT use reanimated `exiting` on web — concurrent
|
|
21
|
-
* React unmounts there throw `Failed to execute 'removeChild' on 'Node'`, the
|
|
22
|
-
* exact bug this component exists to avoid.
|
|
23
|
-
*/
|
|
24
|
-
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;
|
|
25
|
-
export default ResponsiveSheet;
|
|
26
|
-
//# sourceMappingURL=ResponsiveSheet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsiveSheet.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/ResponsiveSheet.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,4DAA4D;AAC5D,eAAO,MAAM,gCAAgC,oCAAoC,CAAC;AAElF;;;;;;;;;;;;;;;;;;;GAmBG;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,kDA+KtB;AA8ED,eAAe,eAAe,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AACtF,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/index.web.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AACtF,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
/** Edge a wide-screen side-sheet anchors to. */
|
|
4
|
-
export type ResponsiveSheetSide = 'left' | 'right';
|
|
5
|
-
/**
|
|
6
|
-
* Inset (px) of the wide-screen side-sheet from its container edges. Lets a
|
|
7
|
-
* host place the sheet "inside its own shell" — e.g. offset from the top by a
|
|
8
|
-
* header, or from the left by a nav rail — with margins on every side.
|
|
9
|
-
*/
|
|
10
|
-
export interface ResponsiveSheetInset {
|
|
11
|
-
top?: number;
|
|
12
|
-
bottom?: number;
|
|
13
|
-
left?: number;
|
|
14
|
-
right?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* A responsive overlay sheet: an anchored side-sheet on wide screens and a
|
|
18
|
-
* bottom-sheet (with drag handle) on small screens, switching by viewport
|
|
19
|
-
* width. It is a plain controlled component — the host drives `open`/`onClose`
|
|
20
|
-
* from its own state. It renders in place (no portal) so the host can scope it
|
|
21
|
-
* inside a themed/positioned subtree.
|
|
22
|
-
*/
|
|
23
|
-
export interface ResponsiveSheetProps {
|
|
24
|
-
/** Whether the sheet is open. Controlled by the host. */
|
|
25
|
-
open: boolean;
|
|
26
|
-
/** Fired when the sheet requests to close (backdrop tap, Escape on web). */
|
|
27
|
-
onClose: () => void;
|
|
28
|
-
/** Anchor edge on wide screens. Defaults to `'left'`. */
|
|
29
|
-
side?: ResponsiveSheetSide;
|
|
30
|
-
/** Viewport width (px) below which the sheet renders as a bottom-sheet. Defaults to `768`. */
|
|
31
|
-
breakpoint?: number;
|
|
32
|
-
/** Side-sheet width (px) on wide screens. Capped to fit. Defaults to `460`. */
|
|
33
|
-
width?: number;
|
|
34
|
-
/** Bottom-sheet max height as a fraction of the viewport height. Defaults to `0.9`. */
|
|
35
|
-
maxHeightRatio?: number;
|
|
36
|
-
/** Side-sheet inset (px) from the container edges. Defaults to `0` on all sides. */
|
|
37
|
-
inset?: ResponsiveSheetInset;
|
|
38
|
-
/** Whether to render the drag handle in bottom-sheet mode. Defaults to `true`. */
|
|
39
|
-
showHandle?: boolean;
|
|
40
|
-
/** Whether tapping the backdrop closes the sheet. Defaults to `true`. */
|
|
41
|
-
dismissOnBackdrop?: boolean;
|
|
42
|
-
/** Style for the panel surface (e.g. brand color). Composed after defaults. */
|
|
43
|
-
panelStyle?: StyleProp<ViewStyle>;
|
|
44
|
-
/** NativeWind classes for the panel surface. */
|
|
45
|
-
panelClassName?: string;
|
|
46
|
-
/** Style for the root overlay (theme-var scope, rail offset, etc.). */
|
|
47
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
48
|
-
/** NativeWind classes for the root overlay (e.g. `"md:left-[4.75rem]"`). */
|
|
49
|
-
containerClassName?: string;
|
|
50
|
-
/** Accessibility label for the sheet panel and the backdrop dismiss button. */
|
|
51
|
-
label?: string;
|
|
52
|
-
/** Sheet content. */
|
|
53
|
-
children: ReactNode;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,gDAAgD;AAChD,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,IAAI,EAAE,OAAO,CAAC;IACd,4EAA4E;IAC5E,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,yDAAyD;IACzD,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uFAAuF;IACvF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,kFAAkF;IAClF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,+EAA+E;IAC/E,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,4EAA4E;IAC5E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Modal, Text } from 'react-native';
|
|
3
|
-
import { fireEvent, render } from '@testing-library/react-native';
|
|
4
|
-
|
|
5
|
-
import { CenteredDialog, CENTERED_DIALOG_BACKDROP_TESTID } from '../dialog';
|
|
6
|
-
import { BloomThemeProvider } from '../theme/BloomThemeProvider';
|
|
7
|
-
|
|
8
|
-
function renderWithTheme(ui: React.ReactElement) {
|
|
9
|
-
return render(
|
|
10
|
-
<BloomThemeProvider mode="light" colorPreset="teal">
|
|
11
|
-
{ui}
|
|
12
|
-
</BloomThemeProvider>,
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const CLOSE_LABEL = 'Close dialog';
|
|
17
|
-
|
|
18
|
-
describe('CenteredDialog', () => {
|
|
19
|
-
it('renders the title, children and footer when visible', () => {
|
|
20
|
-
const { getByText } = renderWithTheme(
|
|
21
|
-
<CenteredDialog
|
|
22
|
-
visible
|
|
23
|
-
onClose={() => {}}
|
|
24
|
-
title="Confirm action"
|
|
25
|
-
footer={<Text>Footer area</Text>}
|
|
26
|
-
>
|
|
27
|
-
<Text>Body content</Text>
|
|
28
|
-
</CenteredDialog>,
|
|
29
|
-
);
|
|
30
|
-
expect(getByText('Confirm action')).toBeTruthy();
|
|
31
|
-
expect(getByText('Body content')).toBeTruthy();
|
|
32
|
-
expect(getByText('Footer area')).toBeTruthy();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('forwards visible=false to the underlying Modal', () => {
|
|
36
|
-
const { UNSAFE_getByType } = renderWithTheme(
|
|
37
|
-
<CenteredDialog visible={false} onClose={() => {}} title="Hidden">
|
|
38
|
-
<Text>Body</Text>
|
|
39
|
-
</CenteredDialog>,
|
|
40
|
-
);
|
|
41
|
-
// The native fork always mounts the RN Modal; the platform hides it via
|
|
42
|
-
// the `visible` prop. Assert the prop is wired through.
|
|
43
|
-
expect(UNSAFE_getByType(Modal).props.visible).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('renders a header close button by default when a title is set and fires onClose', () => {
|
|
47
|
-
const onClose = jest.fn();
|
|
48
|
-
const { getByLabelText } = renderWithTheme(
|
|
49
|
-
<CenteredDialog visible onClose={onClose} title="With close">
|
|
50
|
-
<Text>Body</Text>
|
|
51
|
-
</CenteredDialog>,
|
|
52
|
-
);
|
|
53
|
-
fireEvent.press(getByLabelText(CLOSE_LABEL));
|
|
54
|
-
expect(onClose).toHaveBeenCalledTimes(1);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('omits the header close button when showClose is false even with a title', () => {
|
|
58
|
-
const { queryByLabelText } = renderWithTheme(
|
|
59
|
-
<CenteredDialog visible onClose={() => {}} title="No close" showClose={false}>
|
|
60
|
-
<Text>Body</Text>
|
|
61
|
-
</CenteredDialog>,
|
|
62
|
-
);
|
|
63
|
-
expect(queryByLabelText(CLOSE_LABEL)).toBeNull();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('closes when the backdrop is pressed (dismissible default)', () => {
|
|
67
|
-
const onClose = jest.fn();
|
|
68
|
-
const { getByTestId } = renderWithTheme(
|
|
69
|
-
<CenteredDialog visible onClose={onClose}>
|
|
70
|
-
<Text>Body</Text>
|
|
71
|
-
</CenteredDialog>,
|
|
72
|
-
);
|
|
73
|
-
fireEvent.press(getByTestId(CENTERED_DIALOG_BACKDROP_TESTID));
|
|
74
|
-
expect(onClose).toHaveBeenCalledTimes(1);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('does NOT close on backdrop press when dismissible is false', () => {
|
|
78
|
-
const onClose = jest.fn();
|
|
79
|
-
const { getByTestId } = renderWithTheme(
|
|
80
|
-
<CenteredDialog visible onClose={onClose} dismissible={false}>
|
|
81
|
-
<Text>Body</Text>
|
|
82
|
-
</CenteredDialog>,
|
|
83
|
-
);
|
|
84
|
-
fireEvent.press(getByTestId(CENTERED_DIALOG_BACKDROP_TESTID));
|
|
85
|
-
expect(onClose).not.toHaveBeenCalled();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('derives the backdrop testID from a provided testID', () => {
|
|
89
|
-
const { getByTestId } = renderWithTheme(
|
|
90
|
-
<CenteredDialog visible onClose={() => {}} testID="signout">
|
|
91
|
-
<Text>Body</Text>
|
|
92
|
-
</CenteredDialog>,
|
|
93
|
-
);
|
|
94
|
-
expect(getByTestId('signout-backdrop')).toBeTruthy();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('renders a chromeless card (no header) when no title and showClose unset', () => {
|
|
98
|
-
const { queryByLabelText, getByText, getByTestId } = renderWithTheme(
|
|
99
|
-
<CenteredDialog visible onClose={() => {}}>
|
|
100
|
-
<Text>Chromeless body</Text>
|
|
101
|
-
</CenteredDialog>,
|
|
102
|
-
);
|
|
103
|
-
expect(getByText('Chromeless body')).toBeTruthy();
|
|
104
|
-
// No header close button; only the backdrop is interactive.
|
|
105
|
-
expect(queryByLabelText(CLOSE_LABEL)).toBeNull();
|
|
106
|
-
expect(getByTestId(CENTERED_DIALOG_BACKDROP_TESTID)).toBeTruthy();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text } from 'react-native';
|
|
3
|
-
import { act, fireEvent, render } from '@testing-library/react-native';
|
|
4
|
-
|
|
5
|
-
import { ResponsiveSheet, RESPONSIVE_SHEET_BACKDROP_TESTID } from '../responsive-sheet';
|
|
6
|
-
import { BloomThemeProvider } from '../theme/BloomThemeProvider';
|
|
7
|
-
|
|
8
|
-
function renderWithTheme(ui: React.ReactElement) {
|
|
9
|
-
return render(
|
|
10
|
-
<BloomThemeProvider mode="light" colorPreset="teal">
|
|
11
|
-
{ui}
|
|
12
|
-
</BloomThemeProvider>,
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const LABEL = 'Filters sheet';
|
|
17
|
-
|
|
18
|
-
describe('ResponsiveSheet', () => {
|
|
19
|
-
it('renders children when open', () => {
|
|
20
|
-
const { getByText } = renderWithTheme(
|
|
21
|
-
<ResponsiveSheet open onClose={() => {}} label={LABEL}>
|
|
22
|
-
<Text>Sheet body</Text>
|
|
23
|
-
</ResponsiveSheet>,
|
|
24
|
-
);
|
|
25
|
-
expect(getByText('Sheet body')).toBeTruthy();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('renders nothing when closed (never opened)', () => {
|
|
29
|
-
const { queryByText } = renderWithTheme(
|
|
30
|
-
<ResponsiveSheet open={false} onClose={() => {}} label={LABEL}>
|
|
31
|
-
<Text>Sheet body</Text>
|
|
32
|
-
</ResponsiveSheet>,
|
|
33
|
-
);
|
|
34
|
-
expect(queryByText('Sheet body')).toBeNull();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// The backdrop animates its opacity from 0 -> BACKDROP_OPACITY on enter, so
|
|
38
|
-
// RNTL treats it as accessibility-hidden during the synchronous first frame.
|
|
39
|
-
// `includeHiddenElements` lets us assert its (real, interactive) press
|
|
40
|
-
// behavior without depending on the enter transition having committed.
|
|
41
|
-
const HIDDEN = { includeHiddenElements: true } as const;
|
|
42
|
-
|
|
43
|
-
it('calls onClose when the backdrop is pressed (default dismissOnBackdrop)', () => {
|
|
44
|
-
const onClose = jest.fn();
|
|
45
|
-
const { getByTestId } = renderWithTheme(
|
|
46
|
-
<ResponsiveSheet open onClose={onClose} label={LABEL}>
|
|
47
|
-
<Text>Sheet body</Text>
|
|
48
|
-
</ResponsiveSheet>,
|
|
49
|
-
);
|
|
50
|
-
fireEvent.press(getByTestId(RESPONSIVE_SHEET_BACKDROP_TESTID, HIDDEN));
|
|
51
|
-
expect(onClose).toHaveBeenCalledTimes(1);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('does NOT call onClose on backdrop press when dismissOnBackdrop is false', () => {
|
|
55
|
-
const onClose = jest.fn();
|
|
56
|
-
const { getByTestId } = renderWithTheme(
|
|
57
|
-
<ResponsiveSheet open onClose={onClose} label={LABEL} dismissOnBackdrop={false}>
|
|
58
|
-
<Text>Sheet body</Text>
|
|
59
|
-
</ResponsiveSheet>,
|
|
60
|
-
);
|
|
61
|
-
fireEvent.press(getByTestId(RESPONSIVE_SHEET_BACKDROP_TESTID, HIDDEN));
|
|
62
|
-
expect(onClose).not.toHaveBeenCalled();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('labels the panel and the dismiss backdrop distinctly', () => {
|
|
66
|
-
const { getByLabelText } = renderWithTheme(
|
|
67
|
-
<ResponsiveSheet open onClose={() => {}} label={LABEL}>
|
|
68
|
-
<Text>Sheet body</Text>
|
|
69
|
-
</ResponsiveSheet>,
|
|
70
|
-
);
|
|
71
|
-
expect(getByLabelText(LABEL, HIDDEN)).toBeTruthy();
|
|
72
|
-
expect(getByLabelText(`Dismiss ${LABEL}`, HIDDEN)).toBeTruthy();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('keeps the panel mounted through the exit transition after closing', () => {
|
|
76
|
-
jest.useFakeTimers();
|
|
77
|
-
try {
|
|
78
|
-
const { getByText, queryByText, rerender } = renderWithTheme(
|
|
79
|
-
<ResponsiveSheet open onClose={() => {}} label={LABEL}>
|
|
80
|
-
<Text>Sheet body</Text>
|
|
81
|
-
</ResponsiveSheet>,
|
|
82
|
-
);
|
|
83
|
-
expect(getByText('Sheet body')).toBeTruthy();
|
|
84
|
-
|
|
85
|
-
rerender(
|
|
86
|
-
<BloomThemeProvider mode="light" colorPreset="teal">
|
|
87
|
-
<ResponsiveSheet open={false} onClose={() => {}} label={LABEL}>
|
|
88
|
-
<Text>Sheet body</Text>
|
|
89
|
-
</ResponsiveSheet>
|
|
90
|
-
</BloomThemeProvider>,
|
|
91
|
-
);
|
|
92
|
-
// Still mounted immediately after close (exit transition in flight).
|
|
93
|
-
expect(getByText('Sheet body')).toBeTruthy();
|
|
94
|
-
|
|
95
|
-
// After the transition duration it unmounts.
|
|
96
|
-
act(() => {
|
|
97
|
-
jest.advanceTimersByTime(400);
|
|
98
|
-
});
|
|
99
|
-
expect(queryByText('Sheet body')).toBeNull();
|
|
100
|
-
} finally {
|
|
101
|
-
jest.useRealTimers();
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Text, View } from 'react-native';
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
|
-
|
|
5
|
-
import { Button } from '../button';
|
|
6
|
-
import { CenteredDialog } from './CenteredDialog';
|
|
7
|
-
|
|
8
|
-
const meta: Meta<typeof CenteredDialog> = {
|
|
9
|
-
title: 'Components/CenteredDialog',
|
|
10
|
-
component: CenteredDialog,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
|
|
15
|
-
type Story = StoryObj<typeof CenteredDialog>;
|
|
16
|
-
|
|
17
|
-
function CompactDemo() {
|
|
18
|
-
const [visible, setVisible] = useState(false);
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<Button onPress={() => setVisible(true)}>Open compact dialog</Button>
|
|
22
|
-
<CenteredDialog
|
|
23
|
-
visible={visible}
|
|
24
|
-
onClose={() => setVisible(false)}
|
|
25
|
-
title="Delete project?"
|
|
26
|
-
footer={
|
|
27
|
-
<View style={{ flexDirection: 'row', justifyContent: 'flex-end', gap: 8 }}>
|
|
28
|
-
<Button variant="ghost" size="small" onPress={() => setVisible(false)}>
|
|
29
|
-
Cancel
|
|
30
|
-
</Button>
|
|
31
|
-
<Button variant="primary" size="small" onPress={() => setVisible(false)}>
|
|
32
|
-
Delete
|
|
33
|
-
</Button>
|
|
34
|
-
</View>
|
|
35
|
-
}
|
|
36
|
-
>
|
|
37
|
-
<Text>This action cannot be undone. The project and all its data will be permanently removed.</Text>
|
|
38
|
-
</CenteredDialog>
|
|
39
|
-
</>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function CozyDemo() {
|
|
44
|
-
const [visible, setVisible] = useState(false);
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<Button onPress={() => setVisible(true)}>Open cozy dialog</Button>
|
|
48
|
-
<CenteredDialog
|
|
49
|
-
visible={visible}
|
|
50
|
-
onClose={() => setVisible(false)}
|
|
51
|
-
title="Roomier layout"
|
|
52
|
-
compact={false}
|
|
53
|
-
>
|
|
54
|
-
<Text>compact={'{false}'} relaxes the padding and header/footer gaps for content-heavy dialogs.</Text>
|
|
55
|
-
</CenteredDialog>
|
|
56
|
-
</>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function ChromelessDemo() {
|
|
61
|
-
const [visible, setVisible] = useState(false);
|
|
62
|
-
return (
|
|
63
|
-
<>
|
|
64
|
-
<Button onPress={() => setVisible(true)}>Open chromeless dialog</Button>
|
|
65
|
-
<CenteredDialog visible={visible} onClose={() => setVisible(false)}>
|
|
66
|
-
<View style={{ gap: 12 }}>
|
|
67
|
-
<Text>No title, no close button — the card owns every pixel.</Text>
|
|
68
|
-
<Button variant="secondary" size="small" onPress={() => setVisible(false)}>
|
|
69
|
-
Done
|
|
70
|
-
</Button>
|
|
71
|
-
</View>
|
|
72
|
-
</CenteredDialog>
|
|
73
|
-
</>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function NonDismissibleDemo() {
|
|
78
|
-
const [visible, setVisible] = useState(false);
|
|
79
|
-
return (
|
|
80
|
-
<>
|
|
81
|
-
<Button onPress={() => setVisible(true)}>Open blocking dialog</Button>
|
|
82
|
-
<CenteredDialog
|
|
83
|
-
visible={visible}
|
|
84
|
-
onClose={() => setVisible(false)}
|
|
85
|
-
title="Action required"
|
|
86
|
-
dismissible={false}
|
|
87
|
-
showClose={false}
|
|
88
|
-
footer={
|
|
89
|
-
<Button size="small" onPress={() => setVisible(false)}>
|
|
90
|
-
Acknowledge
|
|
91
|
-
</Button>
|
|
92
|
-
}
|
|
93
|
-
>
|
|
94
|
-
<Text>Backdrop tap and Escape are disabled — the user must choose an action.</Text>
|
|
95
|
-
</CenteredDialog>
|
|
96
|
-
</>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export const Compact: Story = {
|
|
101
|
-
render: () => <CompactDemo />,
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const Cozy: Story = {
|
|
105
|
-
render: () => <CozyDemo />,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const Chromeless: Story = {
|
|
109
|
-
render: () => <ChromelessDemo />,
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const NonDismissible: Story = {
|
|
113
|
-
render: () => <NonDismissibleDemo />,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const Gallery: Story = {
|
|
117
|
-
render: () => (
|
|
118
|
-
<View style={{ gap: 12, alignItems: 'flex-start' }}>
|
|
119
|
-
<CompactDemo />
|
|
120
|
-
<CozyDemo />
|
|
121
|
-
<ChromelessDemo />
|
|
122
|
-
<NonDismissibleDemo />
|
|
123
|
-
</View>
|
|
124
|
-
),
|
|
125
|
-
};
|