@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,68 +0,0 @@
|
|
|
1
|
-
import { borderRadius, space } from '../styles/tokens';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Shared layout constants for `<CenteredDialog>`, kept in one module so the
|
|
5
|
-
* native and web forks render identically. All values are Bloom theme tokens
|
|
6
|
-
* (`styles/tokens`) — no ad-hoc magic numbers.
|
|
7
|
-
*
|
|
8
|
-
* COMPACT is the priority: the `compact` spacing set is the default and is
|
|
9
|
-
* deliberately tight (≈`space.md`), so the card reads snug out of the box.
|
|
10
|
-
* The `cozy` set is the opt-out (`compact={false}`) for roomier dialogs.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/** Default max card width — comfortable for a compact dialog. */
|
|
14
|
-
export const DEFAULT_MAX_WIDTH = 440;
|
|
15
|
-
|
|
16
|
-
/** Card height is capped at this fraction of the viewport; body scrolls. */
|
|
17
|
-
export const MAX_HEIGHT_FRACTION = 0.8;
|
|
18
|
-
|
|
19
|
-
/** Card corner radius (token: `borderRadius.lg` = 16). */
|
|
20
|
-
export const CARD_RADIUS = borderRadius.lg;
|
|
21
|
-
|
|
22
|
-
/** Outer gutter between the card edge and the viewport edge (token `space.lg`). */
|
|
23
|
-
export const VIEWPORT_GUTTER = space.lg;
|
|
24
|
-
|
|
25
|
-
export type DialogSpacing = {
|
|
26
|
-
/** Card inner padding (horizontal + vertical). */
|
|
27
|
-
pad: number;
|
|
28
|
-
/** Gap between the header title row and the body. */
|
|
29
|
-
headerGap: number;
|
|
30
|
-
/** Gap between the body and the footer. */
|
|
31
|
-
footerGap: number;
|
|
32
|
-
/** Vertical gap between stacked body items (the content container `gap`). */
|
|
33
|
-
contentGap: number;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Compact (default) — tight, snug spacing built on `space.md` (12).
|
|
38
|
-
*
|
|
39
|
-
* pad = space.md (12)
|
|
40
|
-
* headerGap = space.sm (8)
|
|
41
|
-
* footerGap = space.md (12)
|
|
42
|
-
* contentGap = space.sm (8)
|
|
43
|
-
*/
|
|
44
|
-
export const COMPACT_SPACING: DialogSpacing = {
|
|
45
|
-
pad: space.md,
|
|
46
|
-
headerGap: space.sm,
|
|
47
|
-
footerGap: space.md,
|
|
48
|
-
contentGap: space.sm,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Cozy (`compact={false}`) — roomier spacing built on `space.xl` (20).
|
|
53
|
-
*
|
|
54
|
-
* pad = space.xl (20)
|
|
55
|
-
* headerGap = space.md (12)
|
|
56
|
-
* footerGap = space.lg (16)
|
|
57
|
-
* contentGap = space.md (12)
|
|
58
|
-
*/
|
|
59
|
-
export const COZY_SPACING: DialogSpacing = {
|
|
60
|
-
pad: space.xl,
|
|
61
|
-
headerGap: space.md,
|
|
62
|
-
footerGap: space.lg,
|
|
63
|
-
contentGap: space.md,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export function resolveSpacing(compact: boolean): DialogSpacing {
|
|
67
|
-
return compact ? COMPACT_SPACING : COZY_SPACING;
|
|
68
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use `<Dialog placement="center">` instead. `CenteredDialog` is
|
|
6
|
-
* superseded by the centered placement of the canonical `<Dialog>` and is
|
|
7
|
-
* slated for removal in a future major.
|
|
8
|
-
*
|
|
9
|
-
* Props for the declarative `<CenteredDialog>` primitive.
|
|
10
|
-
*
|
|
11
|
-
* This is the simple, controlled centered-modal surface — distinct from the
|
|
12
|
-
* imperative `useDialogControl()` + `<Dialog control={…}>` API in the same
|
|
13
|
-
* module. Reach for `<CenteredDialog>` when you already own the open/closed
|
|
14
|
-
* boolean (a `useState`, a query flag, a route param) and just want Bloom to
|
|
15
|
-
* render the dimmed backdrop + a snug, theme-styled centered card.
|
|
16
|
-
*
|
|
17
|
-
* All spacing/colour/radius come from Bloom theme tokens — the card reads
|
|
18
|
-
* compact out of the box (`compact` defaults to `true`).
|
|
19
|
-
*/
|
|
20
|
-
export type CenteredDialogProps = {
|
|
21
|
-
/** Whether the dialog is mounted + visible. */
|
|
22
|
-
visible: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Close request — fired on backdrop tap (when `dismissible`), the close
|
|
25
|
-
* button, the hardware back button (Android), and `Escape` (web). The
|
|
26
|
-
* caller owns the visible state, so it must flip `visible` to `false` here.
|
|
27
|
-
*/
|
|
28
|
-
onClose: () => void;
|
|
29
|
-
/**
|
|
30
|
-
* Optional header title. When set (or when `showClose` is `true`) Bloom
|
|
31
|
-
* renders a tight header row above the content.
|
|
32
|
-
*/
|
|
33
|
-
title?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Tap-outside / back-button / Escape dismisses the dialog. Defaults to
|
|
36
|
-
* `true`. Set `false` for blocking flows (e.g. a destructive confirm that
|
|
37
|
-
* must be answered via an explicit action).
|
|
38
|
-
*/
|
|
39
|
-
dismissible?: boolean;
|
|
40
|
-
/** Max card width in px. Defaults to {@link DEFAULT_MAX_WIDTH} (440). */
|
|
41
|
-
maxWidth?: number;
|
|
42
|
-
/**
|
|
43
|
-
* Tight, snug spacing (the Bloom default). Set `false` for a roomier card
|
|
44
|
-
* with larger padding and header/footer gaps. Defaults to `true`.
|
|
45
|
-
*/
|
|
46
|
-
compact?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Render a close (✕) icon button in the header. Defaults to `true` when a
|
|
49
|
-
* `title` is provided, otherwise `false` (a chromeless card owns its own
|
|
50
|
-
* dismissal affordances).
|
|
51
|
-
*/
|
|
52
|
-
showClose?: boolean;
|
|
53
|
-
/** Card body. Scrolls within the height cap when it overflows. */
|
|
54
|
-
children?: ReactNode;
|
|
55
|
-
/**
|
|
56
|
-
* Optional footer slot for actions (e.g. a Bloom `<Button>` row). Rendered
|
|
57
|
-
* below the scrollable body with a hairline separator.
|
|
58
|
-
*/
|
|
59
|
-
footer?: ReactNode;
|
|
60
|
-
/**
|
|
61
|
-
* Accessibility label for the dialog surface. Falls back to `title` when
|
|
62
|
-
* omitted.
|
|
63
|
-
*/
|
|
64
|
-
accessibilityLabel?: string;
|
|
65
|
-
/** Accessibility label for the header close (✕) button. */
|
|
66
|
-
closeAccessibilityLabel?: string;
|
|
67
|
-
/** Accessibility label for the dimmed backdrop's tap-to-dismiss affordance. */
|
|
68
|
-
backdropAccessibilityLabel?: string;
|
|
69
|
-
/** Style overrides merged onto the centered card container. */
|
|
70
|
-
cardStyle?: StyleProp<ViewStyle>;
|
|
71
|
-
/** Style overrides merged onto the scrollable content container. */
|
|
72
|
-
contentStyle?: StyleProp<ViewStyle>;
|
|
73
|
-
testID?: string;
|
|
74
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
|
-
|
|
5
|
-
import { ResponsiveSheet } from './index';
|
|
6
|
-
import type { ResponsiveSheetSide } from './types';
|
|
7
|
-
import { Button } from '../button';
|
|
8
|
-
import { Text } from '../typography';
|
|
9
|
-
|
|
10
|
-
const meta: Meta = {
|
|
11
|
-
title: 'Overlays/ResponsiveSheet',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default meta;
|
|
15
|
-
|
|
16
|
-
type Story = StoryObj;
|
|
17
|
-
|
|
18
|
-
function Demo({ side }: { side: ResponsiveSheetSide }) {
|
|
19
|
-
const [open, setOpen] = useState(false);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<View style={{ padding: 24, minHeight: 480 }}>
|
|
23
|
-
<Button onPress={() => setOpen(true)}>Open sheet ({side})</Button>
|
|
24
|
-
<ResponsiveSheet
|
|
25
|
-
open={open}
|
|
26
|
-
onClose={() => setOpen(false)}
|
|
27
|
-
side={side}
|
|
28
|
-
width={420}
|
|
29
|
-
inset={{ top: 16, bottom: 16, left: 16 }}
|
|
30
|
-
label="Demo sheet"
|
|
31
|
-
>
|
|
32
|
-
<View style={{ padding: 20, gap: 12 }}>
|
|
33
|
-
<Text style={{ fontSize: 20, fontWeight: '700' }}>Responsive sheet</Text>
|
|
34
|
-
<Text>
|
|
35
|
-
On a wide viewport this is an anchored side-sheet; below the
|
|
36
|
-
breakpoint it becomes a bottom-sheet with a drag handle. Resize the
|
|
37
|
-
preview to switch modes.
|
|
38
|
-
</Text>
|
|
39
|
-
<Button variant="secondary" onPress={() => setOpen(false)}>
|
|
40
|
-
Close
|
|
41
|
-
</Button>
|
|
42
|
-
</View>
|
|
43
|
-
</ResponsiveSheet>
|
|
44
|
-
</View>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const SideLeft: Story = {
|
|
49
|
-
render: () => <Demo side="left" />,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const SideRight: Story = {
|
|
53
|
-
render: () => <Demo side="right" />,
|
|
54
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Dialog } from '../dialog';
|
|
4
|
-
import {
|
|
5
|
-
BREAKPOINT_LG,
|
|
6
|
-
BREAKPOINT_MD,
|
|
7
|
-
BREAKPOINT_SM,
|
|
8
|
-
BREAKPOINT_XL,
|
|
9
|
-
DIALOG_SHEET_BACKDROP_TESTID,
|
|
10
|
-
type ResponsiveDialogPlacement,
|
|
11
|
-
} from '../dialog/placement';
|
|
12
|
-
import type { ResponsiveSheetProps } from './types';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use `<Dialog placement={{ base: 'bottom', md: 'left' }}>` instead.
|
|
16
|
-
*
|
|
17
|
-
* `ResponsiveSheet` is now a thin wrapper that configures the canonical
|
|
18
|
-
* `<Dialog>` — an anchored side-sheet on wide screens collapsing to a
|
|
19
|
-
* bottom-sheet below the breakpoint. It holds ZERO motion/layout logic of its
|
|
20
|
-
* own; it maps its props onto a responsive `Dialog` `placement`. The
|
|
21
|
-
* `@oxyhq/bloom/responsive-sheet` subpath is retained for the migration window.
|
|
22
|
-
*
|
|
23
|
-
* This file is BOTH the package default entry (resolved by downstream `tsc`
|
|
24
|
-
* and non-Metro web bundlers via the `browser` condition through `index.web`)
|
|
25
|
-
* AND a clean delegation, so it carries no platform-specific imports.
|
|
26
|
-
*/
|
|
27
|
-
export function ResponsiveSheet({
|
|
28
|
-
open,
|
|
29
|
-
onClose,
|
|
30
|
-
side = 'left',
|
|
31
|
-
breakpoint = BREAKPOINT_MD,
|
|
32
|
-
width,
|
|
33
|
-
maxHeightRatio,
|
|
34
|
-
inset,
|
|
35
|
-
showHandle,
|
|
36
|
-
dismissOnBackdrop,
|
|
37
|
-
panelStyle,
|
|
38
|
-
panelClassName,
|
|
39
|
-
containerStyle,
|
|
40
|
-
containerClassName,
|
|
41
|
-
label,
|
|
42
|
-
children,
|
|
43
|
-
}: ResponsiveSheetProps) {
|
|
44
|
-
return (
|
|
45
|
-
<Dialog
|
|
46
|
-
open={open}
|
|
47
|
-
onClose={onClose}
|
|
48
|
-
placement={placementForSide(side, breakpoint)}
|
|
49
|
-
width={width}
|
|
50
|
-
maxHeightRatio={maxHeightRatio}
|
|
51
|
-
inset={inset}
|
|
52
|
-
showHandle={showHandle}
|
|
53
|
-
dismissOnBackdrop={dismissOnBackdrop}
|
|
54
|
-
panelStyle={panelStyle}
|
|
55
|
-
panelClassName={panelClassName}
|
|
56
|
-
containerStyle={containerStyle}
|
|
57
|
-
containerClassName={containerClassName}
|
|
58
|
-
label={label}
|
|
59
|
-
>
|
|
60
|
-
{children}
|
|
61
|
-
</Dialog>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Build the `Dialog` `placement` map for a `ResponsiveSheet`: a bottom-sheet
|
|
67
|
-
* below `breakpoint`, the anchored `side` at and above it. The `breakpoint`
|
|
68
|
-
* (px) is bucketed to the nearest Tailwind key so the side-sheet engages at the
|
|
69
|
-
* matching width.
|
|
70
|
-
*/
|
|
71
|
-
function placementForSide(
|
|
72
|
-
side: 'left' | 'right',
|
|
73
|
-
breakpoint: number,
|
|
74
|
-
): ResponsiveDialogPlacement {
|
|
75
|
-
if (breakpoint <= BREAKPOINT_SM) return { base: 'bottom', sm: side };
|
|
76
|
-
if (breakpoint <= BREAKPOINT_MD) return { base: 'bottom', md: side };
|
|
77
|
-
if (breakpoint <= BREAKPOINT_LG) return { base: 'bottom', lg: side };
|
|
78
|
-
if (breakpoint <= BREAKPOINT_XL) return { base: 'bottom', xl: side };
|
|
79
|
-
return { base: 'bottom', xl: side };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Stable testID for the dimmed backdrop dismiss button — now
|
|
84
|
-
* provided by the underlying `<Dialog>`'s side/bottom backdrop.
|
|
85
|
-
*/
|
|
86
|
-
export const RESPONSIVE_SHEET_BACKDROP_TESTID = DIALOG_SHEET_BACKDROP_TESTID;
|
|
87
|
-
|
|
88
|
-
export default ResponsiveSheet;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Dialog } from '../dialog/index.web';
|
|
4
|
-
import {
|
|
5
|
-
BREAKPOINT_LG,
|
|
6
|
-
BREAKPOINT_MD,
|
|
7
|
-
BREAKPOINT_SM,
|
|
8
|
-
BREAKPOINT_XL,
|
|
9
|
-
DIALOG_SHEET_BACKDROP_TESTID,
|
|
10
|
-
type ResponsiveDialogPlacement,
|
|
11
|
-
} from '../dialog/placement';
|
|
12
|
-
import type { ResponsiveSheetProps } from './types';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use `<Dialog placement={{ base: 'bottom', md: 'left' }}>` instead.
|
|
16
|
-
*
|
|
17
|
-
* Web fork of the deprecated `ResponsiveSheet` wrapper. Identical delegation to
|
|
18
|
-
* the default fork, but imports the web `Dialog` explicitly so non-Metro web
|
|
19
|
-
* bundlers never follow the native (reanimated) `Dialog` sibling.
|
|
20
|
-
*/
|
|
21
|
-
export function ResponsiveSheet({
|
|
22
|
-
open,
|
|
23
|
-
onClose,
|
|
24
|
-
side = 'left',
|
|
25
|
-
breakpoint = BREAKPOINT_MD,
|
|
26
|
-
width,
|
|
27
|
-
maxHeightRatio,
|
|
28
|
-
inset,
|
|
29
|
-
showHandle,
|
|
30
|
-
dismissOnBackdrop,
|
|
31
|
-
panelStyle,
|
|
32
|
-
panelClassName,
|
|
33
|
-
containerStyle,
|
|
34
|
-
containerClassName,
|
|
35
|
-
label,
|
|
36
|
-
children,
|
|
37
|
-
}: ResponsiveSheetProps) {
|
|
38
|
-
return (
|
|
39
|
-
<Dialog
|
|
40
|
-
open={open}
|
|
41
|
-
onClose={onClose}
|
|
42
|
-
placement={placementForSide(side, breakpoint)}
|
|
43
|
-
width={width}
|
|
44
|
-
maxHeightRatio={maxHeightRatio}
|
|
45
|
-
inset={inset}
|
|
46
|
-
showHandle={showHandle}
|
|
47
|
-
dismissOnBackdrop={dismissOnBackdrop}
|
|
48
|
-
panelStyle={panelStyle}
|
|
49
|
-
panelClassName={panelClassName}
|
|
50
|
-
containerStyle={containerStyle}
|
|
51
|
-
containerClassName={containerClassName}
|
|
52
|
-
label={label}
|
|
53
|
-
>
|
|
54
|
-
{children}
|
|
55
|
-
</Dialog>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function placementForSide(
|
|
60
|
-
side: 'left' | 'right',
|
|
61
|
-
breakpoint: number,
|
|
62
|
-
): ResponsiveDialogPlacement {
|
|
63
|
-
if (breakpoint <= BREAKPOINT_SM) return { base: 'bottom', sm: side };
|
|
64
|
-
if (breakpoint <= BREAKPOINT_MD) return { base: 'bottom', md: side };
|
|
65
|
-
if (breakpoint <= BREAKPOINT_LG) return { base: 'bottom', lg: side };
|
|
66
|
-
if (breakpoint <= BREAKPOINT_XL) return { base: 'bottom', xl: side };
|
|
67
|
-
return { base: 'bottom', xl: side };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated Stable testID for the dimmed backdrop dismiss button — now
|
|
72
|
-
* provided by the underlying `<Dialog>`'s side/bottom backdrop.
|
|
73
|
-
*/
|
|
74
|
-
export const RESPONSIVE_SHEET_BACKDROP_TESTID = DIALOG_SHEET_BACKDROP_TESTID;
|
|
75
|
-
|
|
76
|
-
export default ResponsiveSheet;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Web variant of the `./responsive-sheet` barrel.
|
|
2
|
-
//
|
|
3
|
-
// `ResponsiveSheet` is now a deprecated thin wrapper over `<Dialog>`. The
|
|
4
|
-
// default barrel (`./index.ts`) imports the default `Dialog`; THIS web barrel
|
|
5
|
-
// re-exports from `./ResponsiveSheet.web`, which imports the web `Dialog`
|
|
6
|
-
// explicitly so a non-Metro bundler never follows the native (reanimated)
|
|
7
|
-
// `Dialog` sibling. Web bundlers select this file via the `"browser"` export
|
|
8
|
-
// condition in `package.json`'s `exports['./responsive-sheet']`.
|
|
9
|
-
export { ResponsiveSheet, RESPONSIVE_SHEET_BACKDROP_TESTID } from './ResponsiveSheet.web';
|
|
10
|
-
export type {
|
|
11
|
-
ResponsiveSheetProps,
|
|
12
|
-
ResponsiveSheetSide,
|
|
13
|
-
ResponsiveSheetInset,
|
|
14
|
-
} from './types';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
|
|
4
|
-
/** Edge a wide-screen side-sheet anchors to. */
|
|
5
|
-
export type ResponsiveSheetSide = 'left' | 'right';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Inset (px) of the wide-screen side-sheet from its container edges. Lets a
|
|
9
|
-
* host place the sheet "inside its own shell" — e.g. offset from the top by a
|
|
10
|
-
* header, or from the left by a nav rail — with margins on every side.
|
|
11
|
-
*/
|
|
12
|
-
export interface ResponsiveSheetInset {
|
|
13
|
-
top?: number;
|
|
14
|
-
bottom?: number;
|
|
15
|
-
left?: number;
|
|
16
|
-
right?: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated Use `<Dialog placement={{ base: 'bottom', md: 'left' }}>` from
|
|
21
|
-
* `@oxyhq/bloom/dialog` instead. `ResponsiveSheet` is now a thin wrapper over
|
|
22
|
-
* `<Dialog>` retained for the migration window.
|
|
23
|
-
*
|
|
24
|
-
* A responsive overlay sheet: an anchored side-sheet on wide screens and a
|
|
25
|
-
* bottom-sheet (with drag handle) on small screens, switching by viewport
|
|
26
|
-
* width. It is a plain controlled component — the host drives `open`/`onClose`
|
|
27
|
-
* from its own state.
|
|
28
|
-
*/
|
|
29
|
-
export interface ResponsiveSheetProps {
|
|
30
|
-
/** Whether the sheet is open. Controlled by the host. */
|
|
31
|
-
open: boolean;
|
|
32
|
-
/** Fired when the sheet requests to close (backdrop tap, Escape on web). */
|
|
33
|
-
onClose: () => void;
|
|
34
|
-
/** Anchor edge on wide screens. Defaults to `'left'`. */
|
|
35
|
-
side?: ResponsiveSheetSide;
|
|
36
|
-
/** Viewport width (px) below which the sheet renders as a bottom-sheet. Defaults to `768`. */
|
|
37
|
-
breakpoint?: number;
|
|
38
|
-
/** Side-sheet width (px) on wide screens. Capped to fit. Defaults to `460`. */
|
|
39
|
-
width?: number;
|
|
40
|
-
/** Bottom-sheet max height as a fraction of the viewport height. Defaults to `0.9`. */
|
|
41
|
-
maxHeightRatio?: number;
|
|
42
|
-
/** Side-sheet inset (px) from the container edges. Defaults to `0` on all sides. */
|
|
43
|
-
inset?: ResponsiveSheetInset;
|
|
44
|
-
/** Whether to render the drag handle in bottom-sheet mode. Defaults to `true`. */
|
|
45
|
-
showHandle?: boolean;
|
|
46
|
-
/** Whether tapping the backdrop closes the sheet. Defaults to `true`. */
|
|
47
|
-
dismissOnBackdrop?: boolean;
|
|
48
|
-
/** Style for the panel surface (e.g. brand color). Composed after defaults. */
|
|
49
|
-
panelStyle?: StyleProp<ViewStyle>;
|
|
50
|
-
/** NativeWind classes for the panel surface. */
|
|
51
|
-
panelClassName?: string;
|
|
52
|
-
/** Style for the root overlay (theme-var scope, rail offset, etc.). */
|
|
53
|
-
containerStyle?: StyleProp<ViewStyle>;
|
|
54
|
-
/** NativeWind classes for the root overlay (e.g. `"md:left-[4.75rem]"`). */
|
|
55
|
-
containerClassName?: string;
|
|
56
|
-
/** Accessibility label for the sheet panel and the backdrop dismiss button. */
|
|
57
|
-
label?: string;
|
|
58
|
-
/** Sheet content. */
|
|
59
|
-
children: ReactNode;
|
|
60
|
-
}
|