@oxyhq/bloom 0.15.0 → 0.16.1
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 +39 -152
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +61 -196
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/DialogBottomSheet.js +205 -0
- package/lib/commonjs/dialog/DialogBottomSheet.js.map +1 -0
- package/lib/commonjs/dialog/DialogContent.js +155 -0
- package/lib/commonjs/dialog/DialogContent.js.map +1 -0
- package/lib/commonjs/dialog/index.js +0 -13
- package/lib/commonjs/dialog/index.js.map +1 -1
- package/lib/commonjs/dialog/index.web.js +0 -19
- package/lib/commonjs/dialog/index.web.js.map +1 -1
- package/lib/commonjs/index.js +0 -29
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +6 -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 +42 -155
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +63 -198
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/DialogBottomSheet.js +200 -0
- package/lib/module/dialog/DialogBottomSheet.js.map +1 -0
- package/lib/module/dialog/DialogContent.js +148 -0
- package/lib/module/dialog/DialogContent.js.map +1 -0
- package/lib/module/dialog/index.js +0 -1
- package/lib/module/dialog/index.js.map +1 -1
- package/lib/module/dialog/index.web.js +0 -1
- package/lib/module/dialog/index.web.js.map +1 -1
- 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 +2 -3
- package/lib/typescript/commonjs/dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts +11 -8
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/DialogBottomSheet.d.ts +29 -0
- package/lib/typescript/commonjs/dialog/DialogBottomSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/DialogContent.d.ts +32 -0
- package/lib/typescript/commonjs/dialog/DialogContent.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/index.d.ts +0 -2
- package/lib/typescript/commonjs/dialog/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/index.web.d.ts +0 -2
- package/lib/typescript/commonjs/dialog/index.web.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 +2 -3
- package/lib/typescript/module/dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/module/dialog/Dialog.web.d.ts +11 -8
- package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/DialogBottomSheet.d.ts +29 -0
- package/lib/typescript/module/dialog/DialogBottomSheet.d.ts.map +1 -0
- package/lib/typescript/module/dialog/DialogContent.d.ts +32 -0
- package/lib/typescript/module/dialog/DialogContent.d.ts.map +1 -0
- package/lib/typescript/module/dialog/index.d.ts +0 -2
- package/lib/typescript/module/dialog/index.d.ts.map +1 -1
- package/lib/typescript/module/dialog/index.web.d.ts +0 -2
- package/lib/typescript/module/dialog/index.web.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__/BottomSheetGesture.test.tsx +135 -0
- package/src/__tests__/Command.test.tsx +107 -0
- package/src/__tests__/DialogBottomSheet.test.tsx +130 -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 +35 -168
- package/src/dialog/Dialog.web.tsx +52 -209
- package/src/dialog/DialogBottomSheet.tsx +235 -0
- package/src/dialog/DialogContent.tsx +157 -0
- package/src/dialog/index.ts +0 -2
- package/src/dialog/index.web.ts +0 -6
- package/src/index.ts +0 -11
- package/src/index.web.ts +0 -11
- package/lib/commonjs/dialog/CenteredDialog.js +0 -252
- package/lib/commonjs/dialog/CenteredDialog.js.map +0 -1
- package/lib/commonjs/dialog/CenteredDialog.web.js +0 -330
- 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 -97
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.js.map +0 -1
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.web.js +0 -84
- package/lib/commonjs/responsive-sheet/ResponsiveSheet.web.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 -246
- package/lib/module/dialog/CenteredDialog.js.map +0 -1
- package/lib/module/dialog/CenteredDialog.web.js +0 -324
- 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 -90
- package/lib/module/responsive-sheet/ResponsiveSheet.js.map +0 -1
- package/lib/module/responsive-sheet/ResponsiveSheet.web.js +0 -77
- package/lib/module/responsive-sheet/ResponsiveSheet.web.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 -12
- 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 -22
- package/lib/typescript/commonjs/dialog/CenteredDialog.d.ts.map +0 -1
- package/lib/typescript/commonjs/dialog/CenteredDialog.web.d.ts +0 -31
- 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 -74
- package/lib/typescript/commonjs/dialog/centered-dialog-types.d.ts.map +0 -1
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts +0 -22
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts.map +0 -1
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.web.d.ts +0 -16
- package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.web.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 -58
- package/lib/typescript/commonjs/responsive-sheet/types.d.ts.map +0 -1
- package/lib/typescript/module/dialog/CenteredDialog.d.ts +0 -22
- package/lib/typescript/module/dialog/CenteredDialog.d.ts.map +0 -1
- package/lib/typescript/module/dialog/CenteredDialog.web.d.ts +0 -31
- 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 -74
- package/lib/typescript/module/dialog/centered-dialog-types.d.ts.map +0 -1
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts +0 -22
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts.map +0 -1
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.web.d.ts +0 -16
- package/lib/typescript/module/responsive-sheet/ResponsiveSheet.web.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 -58
- 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 -88
- package/src/dialog/CenteredDialog.stories.tsx +0 -125
- package/src/dialog/CenteredDialog.tsx +0 -305
- package/src/dialog/CenteredDialog.web.tsx +0 -374
- package/src/dialog/centered-dialog-tokens.ts +0 -68
- package/src/dialog/centered-dialog-types.ts +0 -74
- package/src/responsive-sheet/ResponsiveSheet.stories.tsx +0 -54
- package/src/responsive-sheet/ResponsiveSheet.tsx +0 -88
- package/src/responsive-sheet/ResponsiveSheet.web.tsx +0 -76
- package/src/responsive-sheet/index.ts +0 -6
- package/src/responsive-sheet/index.web.ts +0 -14
- package/src/responsive-sheet/types.ts +0 -60
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared layout constants for `<CenteredDialog>`, kept in one module so the
|
|
3
|
-
* native and web forks render identically. All values are Bloom theme tokens
|
|
4
|
-
* (`styles/tokens`) — no ad-hoc magic numbers.
|
|
5
|
-
*
|
|
6
|
-
* COMPACT is the priority: the `compact` spacing set is the default and is
|
|
7
|
-
* deliberately tight (≈`space.md`), so the card reads snug out of the box.
|
|
8
|
-
* The `cozy` set is the opt-out (`compact={false}`) for roomier dialogs.
|
|
9
|
-
*/
|
|
10
|
-
/** Default max card width — comfortable for a compact dialog. */
|
|
11
|
-
export declare const DEFAULT_MAX_WIDTH = 440;
|
|
12
|
-
/** Card height is capped at this fraction of the viewport; body scrolls. */
|
|
13
|
-
export declare const MAX_HEIGHT_FRACTION = 0.8;
|
|
14
|
-
/** Card corner radius (token: `borderRadius.lg` = 16). */
|
|
15
|
-
export declare const CARD_RADIUS: 16;
|
|
16
|
-
/** Outer gutter between the card edge and the viewport edge (token `space.lg`). */
|
|
17
|
-
export declare const VIEWPORT_GUTTER: 16;
|
|
18
|
-
export type DialogSpacing = {
|
|
19
|
-
/** Card inner padding (horizontal + vertical). */
|
|
20
|
-
pad: number;
|
|
21
|
-
/** Gap between the header title row and the body. */
|
|
22
|
-
headerGap: number;
|
|
23
|
-
/** Gap between the body and the footer. */
|
|
24
|
-
footerGap: number;
|
|
25
|
-
/** Vertical gap between stacked body items (the content container `gap`). */
|
|
26
|
-
contentGap: number;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Compact (default) — tight, snug spacing built on `space.md` (12).
|
|
30
|
-
*
|
|
31
|
-
* pad = space.md (12)
|
|
32
|
-
* headerGap = space.sm (8)
|
|
33
|
-
* footerGap = space.md (12)
|
|
34
|
-
* contentGap = space.sm (8)
|
|
35
|
-
*/
|
|
36
|
-
export declare const COMPACT_SPACING: DialogSpacing;
|
|
37
|
-
/**
|
|
38
|
-
* Cozy (`compact={false}`) — roomier spacing built on `space.xl` (20).
|
|
39
|
-
*
|
|
40
|
-
* pad = space.xl (20)
|
|
41
|
-
* headerGap = space.md (12)
|
|
42
|
-
* footerGap = space.lg (16)
|
|
43
|
-
* contentGap = space.md (12)
|
|
44
|
-
*/
|
|
45
|
-
export declare const COZY_SPACING: DialogSpacing;
|
|
46
|
-
export declare function resolveSpacing(compact: boolean): DialogSpacing;
|
|
47
|
-
//# sourceMappingURL=centered-dialog-tokens.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"centered-dialog-tokens.d.ts","sourceRoot":"","sources":["../../../../src/dialog/centered-dialog-tokens.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,0DAA0D;AAC1D,eAAO,MAAM,WAAW,IAAkB,CAAC;AAE3C,mFAAmF;AACnF,eAAO,MAAM,eAAe,IAAW,CAAC;AAExC,MAAM,MAAM,aAAa,GAAG;IAC1B,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,aAK7B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,aAK1B,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAE9D"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Use `<Dialog placement="center">` instead. `CenteredDialog` is
|
|
5
|
-
* superseded by the centered placement of the canonical `<Dialog>` and is
|
|
6
|
-
* slated for removal in a future major.
|
|
7
|
-
*
|
|
8
|
-
* Props for the declarative `<CenteredDialog>` primitive.
|
|
9
|
-
*
|
|
10
|
-
* This is the simple, controlled centered-modal surface — distinct from the
|
|
11
|
-
* imperative `useDialogControl()` + `<Dialog control={…}>` API in the same
|
|
12
|
-
* module. Reach for `<CenteredDialog>` when you already own the open/closed
|
|
13
|
-
* boolean (a `useState`, a query flag, a route param) and just want Bloom to
|
|
14
|
-
* render the dimmed backdrop + a snug, theme-styled centered card.
|
|
15
|
-
*
|
|
16
|
-
* All spacing/colour/radius come from Bloom theme tokens — the card reads
|
|
17
|
-
* compact out of the box (`compact` defaults to `true`).
|
|
18
|
-
*/
|
|
19
|
-
export type CenteredDialogProps = {
|
|
20
|
-
/** Whether the dialog is mounted + visible. */
|
|
21
|
-
visible: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Close request — fired on backdrop tap (when `dismissible`), the close
|
|
24
|
-
* button, the hardware back button (Android), and `Escape` (web). The
|
|
25
|
-
* caller owns the visible state, so it must flip `visible` to `false` here.
|
|
26
|
-
*/
|
|
27
|
-
onClose: () => void;
|
|
28
|
-
/**
|
|
29
|
-
* Optional header title. When set (or when `showClose` is `true`) Bloom
|
|
30
|
-
* renders a tight header row above the content.
|
|
31
|
-
*/
|
|
32
|
-
title?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Tap-outside / back-button / Escape dismisses the dialog. Defaults to
|
|
35
|
-
* `true`. Set `false` for blocking flows (e.g. a destructive confirm that
|
|
36
|
-
* must be answered via an explicit action).
|
|
37
|
-
*/
|
|
38
|
-
dismissible?: boolean;
|
|
39
|
-
/** Max card width in px. Defaults to {@link DEFAULT_MAX_WIDTH} (440). */
|
|
40
|
-
maxWidth?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Tight, snug spacing (the Bloom default). Set `false` for a roomier card
|
|
43
|
-
* with larger padding and header/footer gaps. Defaults to `true`.
|
|
44
|
-
*/
|
|
45
|
-
compact?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Render a close (✕) icon button in the header. Defaults to `true` when a
|
|
48
|
-
* `title` is provided, otherwise `false` (a chromeless card owns its own
|
|
49
|
-
* dismissal affordances).
|
|
50
|
-
*/
|
|
51
|
-
showClose?: boolean;
|
|
52
|
-
/** Card body. Scrolls within the height cap when it overflows. */
|
|
53
|
-
children?: ReactNode;
|
|
54
|
-
/**
|
|
55
|
-
* Optional footer slot for actions (e.g. a Bloom `<Button>` row). Rendered
|
|
56
|
-
* below the scrollable body with a hairline separator.
|
|
57
|
-
*/
|
|
58
|
-
footer?: ReactNode;
|
|
59
|
-
/**
|
|
60
|
-
* Accessibility label for the dialog surface. Falls back to `title` when
|
|
61
|
-
* omitted.
|
|
62
|
-
*/
|
|
63
|
-
accessibilityLabel?: string;
|
|
64
|
-
/** Accessibility label for the header close (✕) button. */
|
|
65
|
-
closeAccessibilityLabel?: string;
|
|
66
|
-
/** Accessibility label for the dimmed backdrop's tap-to-dismiss affordance. */
|
|
67
|
-
backdropAccessibilityLabel?: string;
|
|
68
|
-
/** Style overrides merged onto the centered card container. */
|
|
69
|
-
cardStyle?: StyleProp<ViewStyle>;
|
|
70
|
-
/** Style overrides merged onto the scrollable content container. */
|
|
71
|
-
contentStyle?: StyleProp<ViewStyle>;
|
|
72
|
-
testID?: string;
|
|
73
|
-
};
|
|
74
|
-
//# 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;;;;;;;;;;;;;;;GAeG;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,22 +0,0 @@
|
|
|
1
|
-
import type { ResponsiveSheetProps } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated Use `<Dialog placement={{ base: 'bottom', md: 'left' }}>` instead.
|
|
4
|
-
*
|
|
5
|
-
* `ResponsiveSheet` is now a thin wrapper that configures the canonical
|
|
6
|
-
* `<Dialog>` — an anchored side-sheet on wide screens collapsing to a
|
|
7
|
-
* bottom-sheet below the breakpoint. It holds ZERO motion/layout logic of its
|
|
8
|
-
* own; it maps its props onto a responsive `Dialog` `placement`. The
|
|
9
|
-
* `@oxyhq/bloom/responsive-sheet` subpath is retained for the migration window.
|
|
10
|
-
*
|
|
11
|
-
* This file is BOTH the package default entry (resolved by downstream `tsc`
|
|
12
|
-
* and non-Metro web bundlers via the `browser` condition through `index.web`)
|
|
13
|
-
* AND a clean delegation, so it carries no platform-specific imports.
|
|
14
|
-
*/
|
|
15
|
-
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;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Stable testID for the dimmed backdrop dismiss button — now
|
|
18
|
-
* provided by the underlying `<Dialog>`'s side/bottom backdrop.
|
|
19
|
-
*/
|
|
20
|
-
export declare const RESPONSIVE_SHEET_BACKDROP_TESTID = "bloom-dialog-sheet-backdrop";
|
|
21
|
-
export default ResponsiveSheet;
|
|
22
|
-
//# sourceMappingURL=ResponsiveSheet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsiveSheet.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/ResponsiveSheet.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,IAAa,EACb,UAA0B,EAC1B,KAAK,EACL,cAAc,EACd,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,2CAoBtB;AAmBD;;;GAGG;AACH,eAAO,MAAM,gCAAgC,gCAA+B,CAAC;AAE7E,eAAe,eAAe,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ResponsiveSheetProps } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated Use `<Dialog placement={{ base: 'bottom', md: 'left' }}>` instead.
|
|
4
|
-
*
|
|
5
|
-
* Web fork of the deprecated `ResponsiveSheet` wrapper. Identical delegation to
|
|
6
|
-
* the default fork, but imports the web `Dialog` explicitly so non-Metro web
|
|
7
|
-
* bundlers never follow the native (reanimated) `Dialog` sibling.
|
|
8
|
-
*/
|
|
9
|
-
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;
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Stable testID for the dimmed backdrop dismiss button — now
|
|
12
|
-
* provided by the underlying `<Dialog>`'s side/bottom backdrop.
|
|
13
|
-
*/
|
|
14
|
-
export declare const RESPONSIVE_SHEET_BACKDROP_TESTID = "bloom-dialog-sheet-backdrop";
|
|
15
|
-
export default ResponsiveSheet;
|
|
16
|
-
//# sourceMappingURL=ResponsiveSheet.web.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsiveSheet.web.d.ts","sourceRoot":"","sources":["../../../../src/responsive-sheet/ResponsiveSheet.web.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,IAAa,EACb,UAA0B,EAC1B,KAAK,EACL,cAAc,EACd,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,2CAoBtB;AAaD;;;GAGG;AACH,eAAO,MAAM,gCAAgC,gCAA+B,CAAC;AAE7E,eAAe,eAAe,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":"AAQA,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAC;AAC1F,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -1,58 +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
|
-
* @deprecated Use `<Dialog placement={{ base: 'bottom', md: 'left' }}>` from
|
|
18
|
-
* `@oxyhq/bloom/dialog` instead. `ResponsiveSheet` is now a thin wrapper over
|
|
19
|
-
* `<Dialog>` retained for the migration window.
|
|
20
|
-
*
|
|
21
|
-
* A responsive overlay sheet: an anchored side-sheet on wide screens and a
|
|
22
|
-
* bottom-sheet (with drag handle) on small screens, switching by viewport
|
|
23
|
-
* width. It is a plain controlled component — the host drives `open`/`onClose`
|
|
24
|
-
* from its own state.
|
|
25
|
-
*/
|
|
26
|
-
export interface ResponsiveSheetProps {
|
|
27
|
-
/** Whether the sheet is open. Controlled by the host. */
|
|
28
|
-
open: boolean;
|
|
29
|
-
/** Fired when the sheet requests to close (backdrop tap, Escape on web). */
|
|
30
|
-
onClose: () => void;
|
|
31
|
-
/** Anchor edge on wide screens. Defaults to `'left'`. */
|
|
32
|
-
side?: ResponsiveSheetSide;
|
|
33
|
-
/** Viewport width (px) below which the sheet renders as a bottom-sheet. Defaults to `768`. */
|
|
34
|
-
breakpoint?: number;
|
|
35
|
-
/** Side-sheet width (px) on wide screens. Capped to fit. Defaults to `460`. */
|
|
36
|
-
width?: number;
|
|
37
|
-
/** Bottom-sheet max height as a fraction of the viewport height. Defaults to `0.9`. */
|
|
38
|
-
maxHeightRatio?: number;
|
|
39
|
-
/** Side-sheet inset (px) from the container edges. Defaults to `0` on all sides. */
|
|
40
|
-
inset?: ResponsiveSheetInset;
|
|
41
|
-
/** Whether to render the drag handle in bottom-sheet mode. Defaults to `true`. */
|
|
42
|
-
showHandle?: boolean;
|
|
43
|
-
/** Whether tapping the backdrop closes the sheet. Defaults to `true`. */
|
|
44
|
-
dismissOnBackdrop?: boolean;
|
|
45
|
-
/** Style for the panel surface (e.g. brand color). Composed after defaults. */
|
|
46
|
-
panelStyle?: StyleProp<ViewStyle>;
|
|
47
|
-
/** NativeWind classes for the panel surface. */
|
|
48
|
-
panelClassName?: string;
|
|
49
|
-
/** Style for the root overlay (theme-var scope, rail offset, etc.). */
|
|
50
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
51
|
-
/** NativeWind classes for the root overlay (e.g. `"md:left-[4.75rem]"`). */
|
|
52
|
-
containerClassName?: string;
|
|
53
|
-
/** Accessibility label for the sheet panel and the backdrop dismiss button. */
|
|
54
|
-
label?: string;
|
|
55
|
-
/** Sheet content. */
|
|
56
|
-
children: ReactNode;
|
|
57
|
-
}
|
|
58
|
-
//# 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;;;;;;;;;GASG;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,88 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text } from 'react-native';
|
|
3
|
-
import { act, render } from '@testing-library/react-native';
|
|
4
|
-
|
|
5
|
-
import { ResponsiveSheet } 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
|
-
function rerenderWithTheme(
|
|
17
|
-
rerender: ReturnType<typeof render>['rerender'],
|
|
18
|
-
ui: React.ReactElement,
|
|
19
|
-
) {
|
|
20
|
-
rerender(
|
|
21
|
-
<BloomThemeProvider mode="light" colorPreset="teal">
|
|
22
|
-
{ui}
|
|
23
|
-
</BloomThemeProvider>,
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const LABEL = 'Filters sheet';
|
|
28
|
-
|
|
29
|
-
// `ResponsiveSheet` is now a deprecated thin wrapper over `<Dialog>`. These
|
|
30
|
-
// tests verify the controlled wrapper contract it still owns (open/close
|
|
31
|
-
// presence + delegation). The jest env reports a 375px-wide viewport (below
|
|
32
|
-
// the default `md` breakpoint) so the wrapper resolves to the bottom-sheet
|
|
33
|
-
// placement, which delegates to bloom's `BottomSheet`.
|
|
34
|
-
describe('ResponsiveSheet (deprecated Dialog wrapper)', () => {
|
|
35
|
-
it('renders children when open', () => {
|
|
36
|
-
const { getByText } = renderWithTheme(
|
|
37
|
-
<ResponsiveSheet open onClose={() => {}} label={LABEL}>
|
|
38
|
-
<Text>Sheet body</Text>
|
|
39
|
-
</ResponsiveSheet>,
|
|
40
|
-
);
|
|
41
|
-
expect(getByText('Sheet body')).toBeTruthy();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('renders nothing when closed (never opened)', () => {
|
|
45
|
-
const { queryByText } = renderWithTheme(
|
|
46
|
-
<ResponsiveSheet open={false} onClose={() => {}} label={LABEL}>
|
|
47
|
-
<Text>Sheet body</Text>
|
|
48
|
-
</ResponsiveSheet>,
|
|
49
|
-
);
|
|
50
|
-
expect(queryByText('Sheet body')).toBeNull();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('unmounts the body after a controlled close settles', () => {
|
|
54
|
-
jest.useFakeTimers();
|
|
55
|
-
try {
|
|
56
|
-
const { getByText, queryByText, rerender } = renderWithTheme(
|
|
57
|
-
<ResponsiveSheet open onClose={() => {}} label={LABEL}>
|
|
58
|
-
<Text>Sheet body</Text>
|
|
59
|
-
</ResponsiveSheet>,
|
|
60
|
-
);
|
|
61
|
-
expect(getByText('Sheet body')).toBeTruthy();
|
|
62
|
-
|
|
63
|
-
rerenderWithTheme(
|
|
64
|
-
rerender,
|
|
65
|
-
<ResponsiveSheet open={false} onClose={() => {}} label={LABEL}>
|
|
66
|
-
<Text>Sheet body</Text>
|
|
67
|
-
</ResponsiveSheet>,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
// After the close animation/fallback settles the body is gone.
|
|
71
|
-
act(() => {
|
|
72
|
-
jest.advanceTimersByTime(500);
|
|
73
|
-
});
|
|
74
|
-
expect(queryByText('Sheet body')).toBeNull();
|
|
75
|
-
} finally {
|
|
76
|
-
jest.useRealTimers();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('forwards a custom label to the dialog surface', () => {
|
|
81
|
-
const { getByLabelText } = renderWithTheme(
|
|
82
|
-
<ResponsiveSheet open onClose={() => {}} label={LABEL}>
|
|
83
|
-
<Text>Sheet body</Text>
|
|
84
|
-
</ResponsiveSheet>,
|
|
85
|
-
);
|
|
86
|
-
expect(getByLabelText(LABEL)).toBeTruthy();
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -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
|
-
};
|