@oxyhq/bloom 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/lib/commonjs/dialog/CenteredDialog.js +2 -0
  2. package/lib/commonjs/dialog/CenteredDialog.js.map +1 -1
  3. package/lib/commonjs/dialog/CenteredDialog.web.js +2 -0
  4. package/lib/commonjs/dialog/CenteredDialog.web.js.map +1 -1
  5. package/lib/commonjs/dialog/Dialog.js +337 -43
  6. package/lib/commonjs/dialog/Dialog.js.map +1 -1
  7. package/lib/commonjs/dialog/Dialog.web.js +414 -63
  8. package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
  9. package/lib/commonjs/dialog/index.js +6 -0
  10. package/lib/commonjs/dialog/index.js.map +1 -1
  11. package/lib/commonjs/dialog/index.web.js +6 -0
  12. package/lib/commonjs/dialog/index.web.js.map +1 -1
  13. package/lib/commonjs/dialog/placement.js +104 -0
  14. package/lib/commonjs/dialog/placement.js.map +1 -0
  15. package/lib/commonjs/index.js +22 -0
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/index.web.js +28 -6
  18. package/lib/commonjs/index.web.js.map +1 -1
  19. package/lib/commonjs/responsive-sheet/ResponsiveSheet.js +97 -0
  20. package/lib/commonjs/responsive-sheet/ResponsiveSheet.js.map +1 -0
  21. package/lib/commonjs/responsive-sheet/ResponsiveSheet.web.js +84 -0
  22. package/lib/commonjs/responsive-sheet/ResponsiveSheet.web.js.map +1 -0
  23. package/lib/commonjs/responsive-sheet/index.js +19 -0
  24. package/lib/commonjs/responsive-sheet/index.js.map +1 -0
  25. package/lib/commonjs/responsive-sheet/index.web.js +19 -0
  26. package/lib/commonjs/responsive-sheet/index.web.js.map +1 -0
  27. package/lib/commonjs/responsive-sheet/types.js +6 -0
  28. package/lib/commonjs/responsive-sheet/types.js.map +1 -0
  29. package/lib/module/dialog/CenteredDialog.js +2 -0
  30. package/lib/module/dialog/CenteredDialog.js.map +1 -1
  31. package/lib/module/dialog/CenteredDialog.web.js +2 -0
  32. package/lib/module/dialog/CenteredDialog.web.js.map +1 -1
  33. package/lib/module/dialog/Dialog.js +336 -46
  34. package/lib/module/dialog/Dialog.js.map +1 -1
  35. package/lib/module/dialog/Dialog.web.js +412 -65
  36. package/lib/module/dialog/Dialog.web.js.map +1 -1
  37. package/lib/module/dialog/index.js +1 -1
  38. package/lib/module/dialog/index.js.map +1 -1
  39. package/lib/module/dialog/index.web.js +1 -1
  40. package/lib/module/dialog/index.web.js.map +1 -1
  41. package/lib/module/dialog/placement.js +100 -0
  42. package/lib/module/dialog/placement.js.map +1 -0
  43. package/lib/module/index.js +3 -1
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/index.web.js +3 -1
  46. package/lib/module/index.web.js.map +1 -1
  47. package/lib/module/responsive-sheet/ResponsiveSheet.js +90 -0
  48. package/lib/module/responsive-sheet/ResponsiveSheet.js.map +1 -0
  49. package/lib/module/responsive-sheet/ResponsiveSheet.web.js +77 -0
  50. package/lib/module/responsive-sheet/ResponsiveSheet.web.js.map +1 -0
  51. package/lib/module/responsive-sheet/index.js +4 -0
  52. package/lib/module/responsive-sheet/index.js.map +1 -0
  53. package/lib/module/responsive-sheet/index.web.js +12 -0
  54. package/lib/module/responsive-sheet/index.web.js.map +1 -0
  55. package/lib/module/responsive-sheet/types.js +4 -0
  56. package/lib/module/responsive-sheet/types.js.map +1 -0
  57. package/lib/typescript/commonjs/dialog/CenteredDialog.d.ts +2 -0
  58. package/lib/typescript/commonjs/dialog/CenteredDialog.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/dialog/CenteredDialog.web.d.ts +2 -0
  60. package/lib/typescript/commonjs/dialog/CenteredDialog.web.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/dialog/Dialog.d.ts +18 -15
  62. package/lib/typescript/commonjs/dialog/Dialog.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/dialog/Dialog.web.d.ts +18 -5
  64. package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/dialog/centered-dialog-types.d.ts +4 -0
  66. package/lib/typescript/commonjs/dialog/centered-dialog-types.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/dialog/index.d.ts +2 -2
  68. package/lib/typescript/commonjs/dialog/index.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/dialog/index.web.d.ts +2 -2
  70. package/lib/typescript/commonjs/dialog/index.web.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/dialog/placement.d.ts +71 -0
  72. package/lib/typescript/commonjs/dialog/placement.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/dialog/types.d.ts +66 -3
  74. package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/index.d.ts +4 -2
  76. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/index.web.d.ts +4 -2
  78. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts +22 -0
  80. package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.web.d.ts +16 -0
  82. package/lib/typescript/commonjs/responsive-sheet/ResponsiveSheet.web.d.ts.map +1 -0
  83. package/lib/typescript/commonjs/responsive-sheet/index.d.ts +3 -0
  84. package/lib/typescript/commonjs/responsive-sheet/index.d.ts.map +1 -0
  85. package/lib/typescript/commonjs/responsive-sheet/index.web.d.ts +3 -0
  86. package/lib/typescript/commonjs/responsive-sheet/index.web.d.ts.map +1 -0
  87. package/lib/typescript/commonjs/responsive-sheet/types.d.ts +58 -0
  88. package/lib/typescript/commonjs/responsive-sheet/types.d.ts.map +1 -0
  89. package/lib/typescript/module/dialog/CenteredDialog.d.ts +2 -0
  90. package/lib/typescript/module/dialog/CenteredDialog.d.ts.map +1 -1
  91. package/lib/typescript/module/dialog/CenteredDialog.web.d.ts +2 -0
  92. package/lib/typescript/module/dialog/CenteredDialog.web.d.ts.map +1 -1
  93. package/lib/typescript/module/dialog/Dialog.d.ts +18 -15
  94. package/lib/typescript/module/dialog/Dialog.d.ts.map +1 -1
  95. package/lib/typescript/module/dialog/Dialog.web.d.ts +18 -5
  96. package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
  97. package/lib/typescript/module/dialog/centered-dialog-types.d.ts +4 -0
  98. package/lib/typescript/module/dialog/centered-dialog-types.d.ts.map +1 -1
  99. package/lib/typescript/module/dialog/index.d.ts +2 -2
  100. package/lib/typescript/module/dialog/index.d.ts.map +1 -1
  101. package/lib/typescript/module/dialog/index.web.d.ts +2 -2
  102. package/lib/typescript/module/dialog/index.web.d.ts.map +1 -1
  103. package/lib/typescript/module/dialog/placement.d.ts +71 -0
  104. package/lib/typescript/module/dialog/placement.d.ts.map +1 -0
  105. package/lib/typescript/module/dialog/types.d.ts +66 -3
  106. package/lib/typescript/module/dialog/types.d.ts.map +1 -1
  107. package/lib/typescript/module/index.d.ts +4 -2
  108. package/lib/typescript/module/index.d.ts.map +1 -1
  109. package/lib/typescript/module/index.web.d.ts +4 -2
  110. package/lib/typescript/module/index.web.d.ts.map +1 -1
  111. package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts +22 -0
  112. package/lib/typescript/module/responsive-sheet/ResponsiveSheet.d.ts.map +1 -0
  113. package/lib/typescript/module/responsive-sheet/ResponsiveSheet.web.d.ts +16 -0
  114. package/lib/typescript/module/responsive-sheet/ResponsiveSheet.web.d.ts.map +1 -0
  115. package/lib/typescript/module/responsive-sheet/index.d.ts +3 -0
  116. package/lib/typescript/module/responsive-sheet/index.d.ts.map +1 -0
  117. package/lib/typescript/module/responsive-sheet/index.web.d.ts +3 -0
  118. package/lib/typescript/module/responsive-sheet/index.web.d.ts.map +1 -0
  119. package/lib/typescript/module/responsive-sheet/types.d.ts +58 -0
  120. package/lib/typescript/module/responsive-sheet/types.d.ts.map +1 -0
  121. package/package.json +18 -1
  122. package/src/__tests__/DialogPlacement.test.tsx +144 -0
  123. package/src/__tests__/ResponsiveSheet.test.tsx +88 -0
  124. package/src/dialog/CenteredDialog.tsx +2 -0
  125. package/src/dialog/CenteredDialog.web.tsx +2 -0
  126. package/src/dialog/Dialog.tsx +407 -50
  127. package/src/dialog/Dialog.web.tsx +490 -75
  128. package/src/dialog/centered-dialog-types.ts +4 -0
  129. package/src/dialog/index.ts +4 -1
  130. package/src/dialog/index.web.ts +4 -1
  131. package/src/dialog/placement.ts +113 -0
  132. package/src/dialog/types.ts +69 -3
  133. package/src/index.ts +12 -0
  134. package/src/index.web.ts +12 -0
  135. package/src/responsive-sheet/ResponsiveSheet.stories.tsx +54 -0
  136. package/src/responsive-sheet/ResponsiveSheet.tsx +88 -0
  137. package/src/responsive-sheet/ResponsiveSheet.web.tsx +76 -0
  138. package/src/responsive-sheet/index.ts +6 -0
  139. package/src/responsive-sheet/index.web.ts +14 -0
  140. package/src/responsive-sheet/types.ts +60 -0
@@ -2,6 +2,10 @@ import type { ReactNode } from 'react';
2
2
  import type { StyleProp, ViewStyle } from 'react-native';
3
3
 
4
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
+ *
5
9
  * Props for the declarative `<CenteredDialog>` primitive.
6
10
  *
7
11
  * This is the simple, controlled centered-modal surface — distinct from the
@@ -1,4 +1,4 @@
1
- export { Dialog } from './Dialog';
1
+ export { Dialog, DIALOG_SHEET_BACKDROP_TESTID } from './Dialog';
2
2
  export { CenteredDialog, CENTERED_DIALOG_BACKDROP_TESTID } from './CenteredDialog';
3
3
  export { BloomDialogProvider } from './BloomDialogProvider';
4
4
  export { alert } from './alert';
@@ -12,6 +12,9 @@ export type {
12
12
  DialogActionColor,
13
13
  DialogContextProps,
14
14
  DialogControlProps,
15
+ DialogInset,
16
+ DialogPlacement,
15
17
  DialogProps,
18
+ ResponsiveDialogPlacement,
16
19
  } from './types';
17
20
  export type { CenteredDialogProps } from './centered-dialog-types';
@@ -8,7 +8,7 @@
8
8
  // Web bundlers select this file via the `"browser"` export condition in
9
9
  // `package.json`'s `exports['./dialog']`; native bundlers fall through to
10
10
  // the React Native build above.
11
- export { Dialog, BLOOM_DIALOG_CSS } from './Dialog.web';
11
+ export { Dialog, BLOOM_DIALOG_CSS, DIALOG_SHEET_BACKDROP_TESTID } from './Dialog.web';
12
12
  export {
13
13
  CenteredDialog,
14
14
  BLOOM_CENTERED_DIALOG_CSS,
@@ -26,6 +26,9 @@ export type {
26
26
  DialogActionColor,
27
27
  DialogContextProps,
28
28
  DialogControlProps,
29
+ DialogInset,
30
+ DialogPlacement,
29
31
  DialogProps,
32
+ ResponsiveDialogPlacement,
30
33
  } from './types';
31
34
  export type { CenteredDialogProps } from './centered-dialog-types';
@@ -0,0 +1,113 @@
1
+ import { useMemo } from 'react';
2
+ import { useWindowDimensions } from 'react-native';
3
+
4
+ /**
5
+ * Anchor a `<Dialog>` can render against.
6
+ *
7
+ * - `'center'` — the default centered modal card (current behavior).
8
+ * - `'left'` / `'right'` — an anchored side-sheet / drawer.
9
+ * - `'bottom'` — a bottom-sheet (drag handle, slide-up).
10
+ */
11
+ export type DialogPlacement = 'center' | 'left' | 'right' | 'bottom';
12
+
13
+ /**
14
+ * A `<Dialog>` placement that may vary by viewport width.
15
+ *
16
+ * Either a single `DialogPlacement` (applied at every width) or a responsive
17
+ * map whose `base` applies below the first breakpoint and whose `sm`/`md`/`lg`/
18
+ * `xl` keys override it at and above the matching Tailwind breakpoint.
19
+ *
20
+ * The common store-drawer case is `{ base: 'bottom', md: 'left' }`; the common
21
+ * dialog-to-sheet case is `{ base: 'bottom', md: 'center' }`.
22
+ */
23
+ export type ResponsiveDialogPlacement =
24
+ | DialogPlacement
25
+ | {
26
+ base: DialogPlacement;
27
+ sm?: DialogPlacement;
28
+ md?: DialogPlacement;
29
+ lg?: DialogPlacement;
30
+ xl?: DialogPlacement;
31
+ };
32
+
33
+ /**
34
+ * Tailwind-default breakpoints (px). A responsive `placement` map resolves to
35
+ * the value for the largest key whose min-width is `<=` the current viewport
36
+ * width, falling back to `base`.
37
+ */
38
+ export const BREAKPOINT_SM = 640;
39
+ export const BREAKPOINT_MD = 768;
40
+ export const BREAKPOINT_LG = 1024;
41
+ export const BREAKPOINT_XL = 1280;
42
+
43
+ /** Ordered breakpoint table, widest first, so the first match wins. */
44
+ const RESPONSIVE_KEYS = [
45
+ ['xl', BREAKPOINT_XL],
46
+ ['lg', BREAKPOINT_LG],
47
+ ['md', BREAKPOINT_MD],
48
+ ['sm', BREAKPOINT_SM],
49
+ ] as const;
50
+
51
+ /** Default side-sheet width (px) on wide screens. */
52
+ export const DEFAULT_SIDE_WIDTH = 460;
53
+
54
+ /** Default centered-card max width (px). Matches the legacy `maxWidth: 480`. */
55
+ export const DEFAULT_CENTER_MAX_WIDTH = 480;
56
+
57
+ /** Default bottom-sheet max height as a fraction of the viewport height. */
58
+ export const DEFAULT_MAX_HEIGHT_RATIO = 0.9;
59
+
60
+ /** Corner radius shared by the side-sheet panel and the bottom-sheet top. */
61
+ export const PANEL_RADIUS = 20;
62
+
63
+ /** Open/close transition duration (ms). ~280ms ease-out reads smooth. */
64
+ export const ANIMATION_DURATION = 280;
65
+
66
+ /** Centered-card fade-out duration (ms) — preserves the legacy timing. */
67
+ export const CENTER_FADE_OUT_DURATION = 150;
68
+
69
+ /** CSS approximation of reanimated's `Easing.out(Easing.cubic)`. */
70
+ export const EASE_OUT = 'cubic-bezier(0.33, 1, 0.68, 1)';
71
+
72
+ /** Backdrop dim opacity once fully shown (matches `bg-black/40`). */
73
+ export const SHEET_BACKDROP_OPACITY = 0.4;
74
+
75
+ /** Stable testID for the dimmed backdrop of a side/bottom placement dialog. */
76
+ export const DIALOG_SHEET_BACKDROP_TESTID = 'bloom-dialog-sheet-backdrop';
77
+
78
+ /** Drag-handle pill geometry for the bottom-sheet. */
79
+ export const HANDLE_WIDTH = 36;
80
+ export const HANDLE_HEIGHT = 5;
81
+ export const HANDLE_RADIUS = 3;
82
+
83
+ /**
84
+ * Minimum gutter kept between a wide side-sheet and the opposite viewport edge
85
+ * when capping its width, so the panel never spans the full screen.
86
+ */
87
+ export const SIDE_SHEET_MIN_GUTTER = 24;
88
+
89
+ /**
90
+ * Resolve a (possibly responsive) `placement` to a concrete `DialogPlacement`
91
+ * for the current viewport width.
92
+ *
93
+ * A plain string placement resolves to itself. A responsive map picks the
94
+ * value for the largest breakpoint key whose min-width is `<=` the viewport
95
+ * width, falling back to `base` below the first breakpoint.
96
+ */
97
+ export function useResolvedPlacement(
98
+ placement: ResponsiveDialogPlacement | undefined,
99
+ ): DialogPlacement {
100
+ const { width } = useWindowDimensions();
101
+
102
+ return useMemo<DialogPlacement>(() => {
103
+ if (placement === undefined) return 'center';
104
+ if (typeof placement === 'string') return placement;
105
+ for (const [key, minWidth] of RESPONSIVE_KEYS) {
106
+ if (width >= minWidth) {
107
+ const value = placement[key];
108
+ if (value !== undefined) return value;
109
+ }
110
+ }
111
+ return placement.base;
112
+ }, [placement, width]);
113
+ }
@@ -1,5 +1,21 @@
1
1
  import type { GestureResponderEvent, StyleProp, ViewStyle } from 'react-native';
2
2
 
3
+ import type { ResponsiveDialogPlacement } from './placement';
4
+
5
+ export type { DialogPlacement, ResponsiveDialogPlacement } from './placement';
6
+
7
+ /**
8
+ * Side-sheet inset (px) from the root overlay's edges. Lets a host place a
9
+ * `left`/`right` placement "inside its own shell" — e.g. offset from the top
10
+ * by a header, or from the anchored edge by a nav rail.
11
+ */
12
+ export type DialogInset = {
13
+ top?: number;
14
+ bottom?: number;
15
+ left?: number;
16
+ right?: number;
17
+ };
18
+
3
19
  /**
4
20
  * Imperative open/close handle returned by `useDialogControl`.
5
21
  *
@@ -51,7 +67,14 @@ export type DialogAction = {
51
67
  /**
52
68
  * Props accepted by the unified `<Dialog>` component.
53
69
  *
54
- * Three usage modes pick whichever fits the call site:
70
+ * Open/close is driven by EITHER of two mutually-exclusive modes:
71
+ *
72
+ * - **Imperative `control`** (`useDialogControl()` + `control.open()` /
73
+ * `control.close()`). The legacy default; unchanged.
74
+ * - **Controlled `open`** (an `open` boolean + `onClose`). When `open` is
75
+ * provided it wins and `control` is ignored.
76
+ *
77
+ * Rendering modes (orthogonal to open/close mode) — pick whichever fits:
55
78
  *
56
79
  * 1. **Declarative (`title` / `description` / `actions`).** Most common
57
80
  * confirm/cancel surface. Bloom renders the title, description and
@@ -63,10 +86,26 @@ export type DialogAction = {
63
86
  *
64
87
  * 3. **Imperative `alert()`.** Bypass the JSX layer entirely — see the
65
88
  * module-level `alert()` helper.
89
+ *
90
+ * `placement` controls the surface anchor — centered modal (default), an
91
+ * anchored side-sheet (`left`/`right`), or a bottom-sheet (`bottom`) — and may
92
+ * be a responsive map that collapses to a bottom-sheet on narrow viewports.
66
93
  */
67
94
  export type DialogProps = React.PropsWithChildren<{
68
- control: DialogControlProps;
69
- /** Fires after the dialog has finished closing. */
95
+ /**
96
+ * Imperative open/close handle from `useDialogControl()`. Optional omit it
97
+ * when driving the dialog with the controlled `open` prop instead.
98
+ */
99
+ control?: DialogControlProps;
100
+ /**
101
+ * Controlled open state (opt-in). When provided, the dialog is driven by
102
+ * this boolean and `onClose`, and `control` is ignored.
103
+ */
104
+ open?: boolean;
105
+ /**
106
+ * Fires after the dialog has finished closing. In controlled mode it is the
107
+ * close request the host must answer by flipping `open` to `false`.
108
+ */
70
109
  onClose?: () => void;
71
110
  testID?: string;
72
111
  /** Optional dialog header text. Rendered above `description` / `children`. */
@@ -78,11 +117,38 @@ export type DialogProps = React.PropsWithChildren<{
78
117
  * confirm/cancel/destructive buttons for you. Order is preserved.
79
118
  */
80
119
  actions?: DialogAction[];
120
+ /**
121
+ * Surface anchor. Defaults to `'center'` (the centered modal — current
122
+ * behavior). `'left'`/`'right'` render an anchored side-sheet, `'bottom'` a
123
+ * bottom-sheet. A responsive map resolves by viewport width, e.g.
124
+ * `{ base: 'bottom', md: 'left' }` (drawer on wide, sheet on narrow).
125
+ */
126
+ placement?: ResponsiveDialogPlacement;
127
+ /** Side-sheet width (px) on wide screens. Defaults to `460`. */
128
+ width?: number;
129
+ /** Centered-card max width (px). Defaults to `480`. */
130
+ maxWidth?: number;
131
+ /** Bottom-sheet max height as a fraction of the viewport height. Defaults to `0.9`. */
132
+ maxHeightRatio?: number;
133
+ /** Side-sheet inset (px) from the root overlay's edges. */
134
+ inset?: DialogInset;
135
+ /** Whether to render the drag handle in bottom-sheet mode. Defaults to `true`. */
136
+ showHandle?: boolean;
137
+ /** Whether tapping the backdrop dismisses the dialog. Defaults to `true`. */
138
+ dismissOnBackdrop?: boolean;
81
139
  /**
82
140
  * Style overrides applied to the inner content container on native (the
83
141
  * floating bottom-sheet card) and to the modal panel on web.
84
142
  */
85
143
  style?: StyleProp<ViewStyle>;
144
+ /** Style overrides for the side/bottom placement panel surface. */
145
+ panelStyle?: StyleProp<ViewStyle>;
146
+ /** NativeWind classes for the side/bottom placement panel surface. */
147
+ panelClassName?: string;
148
+ /** Style for the root overlay (theme-var scope, rail offset, etc.). */
149
+ containerStyle?: StyleProp<ViewStyle>;
150
+ /** NativeWind classes for the root overlay (e.g. `"md:left-[4.75rem]"`). */
151
+ containerClassName?: string;
86
152
  /** Accessibility label, applied to the dialog role on web. */
87
153
  label?: string;
88
154
  }>;
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export { type Props as IconProps, sizes as iconSizes, useCommonSVGProps } from '
20
20
  export * from './portal';
21
21
  export {
22
22
  Dialog,
23
+ DIALOG_SHEET_BACKDROP_TESTID,
23
24
  CenteredDialog,
24
25
  CENTERED_DIALOG_BACKDROP_TESTID,
25
26
  BloomDialogProvider,
@@ -35,7 +36,10 @@ export type {
35
36
  DialogActionColor,
36
37
  DialogContextProps,
37
38
  DialogControlProps,
39
+ DialogInset,
40
+ DialogPlacement,
38
41
  DialogProps,
42
+ ResponsiveDialogPlacement,
39
43
  } from './dialog';
40
44
  export * from './button';
41
45
  export { Fab } from './fab';
@@ -88,6 +92,14 @@ export type { ComboboxProps, ComboboxOption } from './combobox';
88
92
  export { BottomSheet } from './bottom-sheet';
89
93
  export type { BottomSheetRef, BottomSheetProps } from './bottom-sheet';
90
94
 
95
+ // Responsive sheet — side-sheet on wide screens, bottom-sheet on narrow.
96
+ export { ResponsiveSheet, RESPONSIVE_SHEET_BACKDROP_TESTID } from './responsive-sheet';
97
+ export type {
98
+ ResponsiveSheetProps,
99
+ ResponsiveSheetSide,
100
+ ResponsiveSheetInset,
101
+ } from './responsive-sheet';
102
+
91
103
  // Data display
92
104
  export * from './card';
93
105
  export * from './badge';
package/src/index.web.ts CHANGED
@@ -25,6 +25,7 @@ export { type Props as IconProps, sizes as iconSizes, useCommonSVGProps } from '
25
25
  export * from './portal/index.web';
26
26
  export {
27
27
  Dialog,
28
+ DIALOG_SHEET_BACKDROP_TESTID,
28
29
  CenteredDialog,
29
30
  CENTERED_DIALOG_BACKDROP_TESTID,
30
31
  BloomDialogProvider,
@@ -40,7 +41,10 @@ export type {
40
41
  DialogActionColor,
41
42
  DialogContextProps,
42
43
  DialogControlProps,
44
+ DialogInset,
45
+ DialogPlacement,
43
46
  DialogProps,
47
+ ResponsiveDialogPlacement,
44
48
  } from './dialog/index.web';
45
49
  export * from './button/index.web';
46
50
  export { Fab } from './fab/index.web';
@@ -93,6 +97,14 @@ export type { ComboboxProps, ComboboxOption } from './combobox/index.web';
93
97
  export { BottomSheet } from './bottom-sheet';
94
98
  export type { BottomSheetRef, BottomSheetProps } from './bottom-sheet';
95
99
 
100
+ // Responsive sheet — side-sheet on wide screens, bottom-sheet on narrow.
101
+ export { ResponsiveSheet, RESPONSIVE_SHEET_BACKDROP_TESTID } from './responsive-sheet/index.web';
102
+ export type {
103
+ ResponsiveSheetProps,
104
+ ResponsiveSheetSide,
105
+ ResponsiveSheetInset,
106
+ } from './responsive-sheet/index.web';
107
+
96
108
  // Data display
97
109
  export * from './card';
98
110
  export * from './badge';
@@ -0,0 +1,54 @@
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
+ };
@@ -0,0 +1,88 @@
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;
@@ -0,0 +1,76 @@
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;
@@ -0,0 +1,6 @@
1
+ export { ResponsiveSheet, RESPONSIVE_SHEET_BACKDROP_TESTID } from './ResponsiveSheet';
2
+ export type {
3
+ ResponsiveSheetProps,
4
+ ResponsiveSheetSide,
5
+ ResponsiveSheetInset,
6
+ } from './types';
@@ -0,0 +1,14 @@
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';
@@ -0,0 +1,60 @@
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
+ }