@multiplatform.one/components 9.1.0 → 9.2.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 (203) hide show
  1. package/dist/cjs/SheetModal/SheetBodyRegion.cjs +44 -0
  2. package/dist/cjs/SheetModal/SheetBodyRegion.native.js +48 -0
  3. package/dist/cjs/SheetModal/SheetBodyRegion.native.js.map +1 -0
  4. package/dist/cjs/SheetModal/SheetHeader.cjs +11 -14
  5. package/dist/cjs/SheetModal/SheetHeader.native.js +11 -14
  6. package/dist/cjs/SheetModal/SheetHeader.native.js.map +1 -1
  7. package/dist/cjs/SheetModal/index.cjs +57 -18
  8. package/dist/cjs/SheetModal/index.native.js +87 -65
  9. package/dist/cjs/SheetModal/index.native.js.map +1 -1
  10. package/dist/cjs/actions/StandardAction.cjs +62 -1
  11. package/dist/cjs/actions/StandardAction.native.js +63 -1
  12. package/dist/cjs/actions/StandardAction.native.js.map +1 -1
  13. package/dist/cjs/appShell/TabHost.native.js +24 -3
  14. package/dist/cjs/appShell/TabHost.native.js.map +1 -1
  15. package/dist/cjs/appShell/bottomChrome.cjs +3 -0
  16. package/dist/cjs/appShell/bottomChrome.native.js +3 -0
  17. package/dist/cjs/appShell/bottomChrome.native.js.map +1 -1
  18. package/dist/cjs/appShell/index.cjs +2 -1
  19. package/dist/cjs/appShell/index.native.js +2 -1
  20. package/dist/cjs/appShell/index.native.js.map +1 -1
  21. package/dist/cjs/charts/ChartDataView.cjs +0 -1
  22. package/dist/cjs/charts/ChartDataView.native.js +0 -1
  23. package/dist/cjs/charts/ChartDataView.native.js.map +1 -1
  24. package/dist/cjs/icons/lucide.cjs +16 -8
  25. package/dist/cjs/icons/lucide.native.js +16 -8
  26. package/dist/cjs/icons/lucide.native.js.map +1 -1
  27. package/dist/cjs/icons/themed.cjs +4 -1
  28. package/dist/cjs/icons/themed.native.js +4 -1
  29. package/dist/cjs/icons/themed.native.js.map +1 -1
  30. package/dist/cjs/layouts/page.cjs +25 -2
  31. package/dist/cjs/layouts/page.native.js +27 -2
  32. package/dist/cjs/layouts/page.native.js.map +1 -1
  33. package/dist/cjs/layouts/timeline.cjs +4 -3
  34. package/dist/cjs/layouts/timeline.native.js +4 -3
  35. package/dist/cjs/layouts/timeline.native.js.map +1 -1
  36. package/dist/cjs/surfaces.cjs +1 -1
  37. package/dist/cjs/surfaces.native.js +1 -1
  38. package/dist/cjs/surfaces.native.js.map +1 -1
  39. package/dist/cjs/views/FilePreview.cjs +1 -1
  40. package/dist/cjs/views/FilePreview.native.js +1 -1
  41. package/dist/cjs/views/FilePreview.native.js.map +1 -1
  42. package/dist/esm/SheetModal/SheetBodyRegion.mjs +19 -0
  43. package/dist/esm/SheetModal/SheetBodyRegion.mjs.map +1 -0
  44. package/dist/esm/SheetModal/SheetBodyRegion.native.js +20 -0
  45. package/dist/esm/SheetModal/SheetBodyRegion.native.js.map +1 -0
  46. package/dist/esm/SheetModal/SheetHeader.mjs +11 -14
  47. package/dist/esm/SheetModal/SheetHeader.mjs.map +1 -1
  48. package/dist/esm/SheetModal/SheetHeader.native.js +11 -14
  49. package/dist/esm/SheetModal/SheetHeader.native.js.map +1 -1
  50. package/dist/esm/SheetModal/index.mjs +61 -22
  51. package/dist/esm/SheetModal/index.mjs.map +1 -1
  52. package/dist/esm/SheetModal/index.native.js +89 -67
  53. package/dist/esm/SheetModal/index.native.js.map +1 -1
  54. package/dist/esm/actions/StandardAction.mjs +63 -2
  55. package/dist/esm/actions/StandardAction.mjs.map +1 -1
  56. package/dist/esm/actions/StandardAction.native.js +64 -2
  57. package/dist/esm/actions/StandardAction.native.js.map +1 -1
  58. package/dist/esm/appShell/TabHost.native.js +26 -5
  59. package/dist/esm/appShell/TabHost.native.js.map +1 -1
  60. package/dist/esm/appShell/bottomChrome.mjs +2 -1
  61. package/dist/esm/appShell/bottomChrome.mjs.map +1 -1
  62. package/dist/esm/appShell/bottomChrome.native.js +2 -1
  63. package/dist/esm/appShell/bottomChrome.native.js.map +1 -1
  64. package/dist/esm/appShell/index.mjs +2 -2
  65. package/dist/esm/appShell/index.mjs.map +1 -1
  66. package/dist/esm/appShell/index.native.js +2 -2
  67. package/dist/esm/appShell/index.native.js.map +1 -1
  68. package/dist/esm/charts/ChartDataView.mjs +0 -1
  69. package/dist/esm/charts/ChartDataView.mjs.map +1 -1
  70. package/dist/esm/charts/ChartDataView.native.js +0 -1
  71. package/dist/esm/charts/ChartDataView.native.js.map +1 -1
  72. package/dist/esm/icons/lucide.mjs +11 -3
  73. package/dist/esm/icons/lucide.mjs.map +1 -1
  74. package/dist/esm/icons/lucide.native.js +11 -3
  75. package/dist/esm/icons/lucide.native.js.map +1 -1
  76. package/dist/esm/icons/themed.mjs +4 -1
  77. package/dist/esm/icons/themed.mjs.map +1 -1
  78. package/dist/esm/icons/themed.native.js +4 -1
  79. package/dist/esm/icons/themed.native.js.map +1 -1
  80. package/dist/esm/layouts/page.mjs +26 -3
  81. package/dist/esm/layouts/page.mjs.map +1 -1
  82. package/dist/esm/layouts/page.native.js +28 -3
  83. package/dist/esm/layouts/page.native.js.map +1 -1
  84. package/dist/esm/layouts/timeline.mjs +2 -1
  85. package/dist/esm/layouts/timeline.mjs.map +1 -1
  86. package/dist/esm/layouts/timeline.native.js +2 -1
  87. package/dist/esm/layouts/timeline.native.js.map +1 -1
  88. package/dist/esm/surfaces.mjs +1 -1
  89. package/dist/esm/surfaces.mjs.map +1 -1
  90. package/dist/esm/surfaces.native.js +1 -1
  91. package/dist/esm/surfaces.native.js.map +1 -1
  92. package/dist/esm/views/FilePreview.mjs +1 -1
  93. package/dist/esm/views/FilePreview.mjs.map +1 -1
  94. package/dist/esm/views/FilePreview.native.js +1 -1
  95. package/dist/esm/views/FilePreview.native.js.map +1 -1
  96. package/dist/jsx/SheetModal/SheetBodyRegion.mjs +19 -0
  97. package/dist/jsx/SheetModal/SheetBodyRegion.mjs.map +1 -0
  98. package/dist/jsx/SheetModal/SheetBodyRegion.native.js +48 -0
  99. package/dist/jsx/SheetModal/SheetBodyRegion.native.js.map +1 -0
  100. package/dist/jsx/SheetModal/SheetHeader.mjs +11 -14
  101. package/dist/jsx/SheetModal/SheetHeader.mjs.map +1 -1
  102. package/dist/jsx/SheetModal/SheetHeader.native.js +11 -14
  103. package/dist/jsx/SheetModal/SheetHeader.native.js.map +1 -1
  104. package/dist/jsx/SheetModal/index.mjs +61 -22
  105. package/dist/jsx/SheetModal/index.mjs.map +1 -1
  106. package/dist/jsx/SheetModal/index.native.js +87 -65
  107. package/dist/jsx/SheetModal/index.native.js.map +1 -1
  108. package/dist/jsx/actions/StandardAction.mjs +63 -2
  109. package/dist/jsx/actions/StandardAction.mjs.map +1 -1
  110. package/dist/jsx/actions/StandardAction.native.js +63 -1
  111. package/dist/jsx/actions/StandardAction.native.js.map +1 -1
  112. package/dist/jsx/appShell/TabHost.native.js +24 -3
  113. package/dist/jsx/appShell/TabHost.native.js.map +1 -1
  114. package/dist/jsx/appShell/bottomChrome.mjs +2 -1
  115. package/dist/jsx/appShell/bottomChrome.mjs.map +1 -1
  116. package/dist/jsx/appShell/bottomChrome.native.js +3 -0
  117. package/dist/jsx/appShell/bottomChrome.native.js.map +1 -1
  118. package/dist/jsx/appShell/index.mjs +2 -2
  119. package/dist/jsx/appShell/index.mjs.map +1 -1
  120. package/dist/jsx/appShell/index.native.js +2 -1
  121. package/dist/jsx/charts/ChartDataView.mjs +0 -1
  122. package/dist/jsx/charts/ChartDataView.mjs.map +1 -1
  123. package/dist/jsx/charts/ChartDataView.native.js +0 -1
  124. package/dist/jsx/charts/ChartDataView.native.js.map +1 -1
  125. package/dist/jsx/icons/lucide.mjs +11 -3
  126. package/dist/jsx/icons/lucide.mjs.map +1 -1
  127. package/dist/jsx/icons/lucide.native.js +16 -8
  128. package/dist/jsx/icons/lucide.native.js.map +1 -1
  129. package/dist/jsx/icons/themed.mjs +4 -1
  130. package/dist/jsx/icons/themed.mjs.map +1 -1
  131. package/dist/jsx/icons/themed.native.js +4 -1
  132. package/dist/jsx/icons/themed.native.js.map +1 -1
  133. package/dist/jsx/layouts/page.mjs +26 -3
  134. package/dist/jsx/layouts/page.mjs.map +1 -1
  135. package/dist/jsx/layouts/page.native.js +27 -2
  136. package/dist/jsx/layouts/page.native.js.map +1 -1
  137. package/dist/jsx/layouts/timeline.mjs +2 -1
  138. package/dist/jsx/layouts/timeline.mjs.map +1 -1
  139. package/dist/jsx/layouts/timeline.native.js +4 -3
  140. package/dist/jsx/layouts/timeline.native.js.map +1 -1
  141. package/dist/jsx/surfaces.mjs +1 -1
  142. package/dist/jsx/surfaces.mjs.map +1 -1
  143. package/dist/jsx/surfaces.native.js +1 -1
  144. package/dist/jsx/views/FilePreview.mjs +1 -1
  145. package/dist/jsx/views/FilePreview.mjs.map +1 -1
  146. package/dist/jsx/views/FilePreview.native.js +1 -1
  147. package/dist/jsx/views/FilePreview.native.js.map +1 -1
  148. package/package.json +7 -7
  149. package/src/SheetFrame.stories.tsx +2 -2
  150. package/src/SheetModal/SheetBodyRegion.tsx +19 -0
  151. package/src/SheetModal/SheetHeader.tsx +23 -27
  152. package/src/SheetModal/SheetModal.grabber.spec.tsx +52 -10
  153. package/src/SheetModal/SheetModal.native.spec.tsx +90 -6
  154. package/src/SheetModal/SheetModal.noHeaderBar.spec.tsx +103 -0
  155. package/src/SheetModal/SheetModal.onDismiss.spec.tsx +35 -0
  156. package/src/SheetModal/SheetModal.stories.spec.tsx +11 -13
  157. package/src/SheetModal/SheetModal.stories.tsx +2 -6
  158. package/src/SheetModal/SheetModal.titleRow.spec.tsx +203 -0
  159. package/src/SheetModal/index.native.tsx +83 -54
  160. package/src/SheetModal/index.tsx +99 -25
  161. package/src/SheetScrollView/SheetScrollView.stories.tsx +2 -2
  162. package/src/actions/StandardAction.tsx +72 -4
  163. package/src/appShell/TabHost.native.tsx +50 -5
  164. package/src/appShell/TabHost.nestedScroll.spec.tsx +177 -0
  165. package/src/appShell/bottomChrome.ts +2 -0
  166. package/src/appShell/index.ts +1 -1
  167. package/src/charts/ChartDataView.tsx +0 -1
  168. package/src/charts/Charts.stories.tsx +20 -0
  169. package/src/icons/lucide.glyphGrid.spec.tsx +41 -0
  170. package/src/icons/lucide.ts +21 -2
  171. package/src/icons/themed.tsx +6 -2
  172. package/src/layouts/page.tsx +35 -2
  173. package/src/layouts/severityShape.spec.tsx +31 -0
  174. package/src/layouts/timeline.tsx +1 -1
  175. package/src/surfaces.spec.tsx +6 -2
  176. package/src/surfaces.tsx +1 -1
  177. package/src/views/FilePreview.tsx +1 -8
  178. package/src/views/filePreview.spec.tsx +3 -4
  179. package/types/Chip/index.d.ts +1 -1
  180. package/types/Collapsible.d.ts +1 -1
  181. package/types/Dialog.d.ts +3 -3
  182. package/types/SheetModal/SheetBodyRegion.d.ts +9 -0
  183. package/types/SheetModal/SheetBodyRegion.d.ts.map +1 -0
  184. package/types/SheetModal/SheetHeader.d.ts +4 -4
  185. package/types/SheetModal/SheetHeader.d.ts.map +1 -1
  186. package/types/SheetModal/index.d.ts +12 -4
  187. package/types/SheetModal/index.d.ts.map +1 -1
  188. package/types/SheetModal/index.native.d.ts +1 -1
  189. package/types/SheetModal/index.native.d.ts.map +1 -1
  190. package/types/actions/StandardAction.d.ts +4 -3
  191. package/types/actions/StandardAction.d.ts.map +1 -1
  192. package/types/appShell/TabHost.native.d.ts.map +1 -1
  193. package/types/appShell/bottomChrome.d.ts +1 -0
  194. package/types/appShell/bottomChrome.d.ts.map +1 -1
  195. package/types/appShell/index.d.ts +1 -1
  196. package/types/appShell/index.d.ts.map +1 -1
  197. package/types/charts/ChartDataView.d.ts.map +1 -1
  198. package/types/icons/lucide.d.ts +7 -3
  199. package/types/icons/lucide.d.ts.map +1 -1
  200. package/types/icons/themed.d.ts.map +1 -1
  201. package/types/layouts/page.d.ts.map +1 -1
  202. package/types/layouts/timeline.d.ts.map +1 -1
  203. package/types/views/FilePreview.d.ts.map +1 -1
@@ -0,0 +1,203 @@
1
+ /**
2
+ * FZ-11418: a sheet's title is content, not a bar. The house Dialog's phone
3
+ * face and SheetModal draw no header bar and no ✕; the title row paints no
4
+ * background, border, fixed height or sticky chrome; it scrolls with a
5
+ * scrolling body; and only a sheet that commits an edit carries the ✓.
6
+ */
7
+ import { renderWithProviders } from "@multiplatform.one/test-utils";
8
+ import { cleanup, screen, waitFor } from "@testing-library/react";
9
+ import { afterEach, describe, expect, it, vi } from "vitest";
10
+ import { Text } from "tamagui";
11
+ import { OverlayHeader } from "../actions/StandardAction";
12
+ import { Dialog } from "../Dialog";
13
+ import { DialogContent, DialogOverlay } from "../surfaces";
14
+ import { SheetModal as NativeSheetModal } from "./index.native";
15
+ import { SheetModal } from "./index";
16
+
17
+ vi.mock("react-native-web", async (importOriginal) => ({
18
+ ...(await importOriginal<typeof import("react-native")>()),
19
+ ActionSheetIOS: undefined,
20
+ Modal: ({ children }: { children: import("react").ReactNode }) => children,
21
+ }));
22
+
23
+ const originalInnerWidth = window.innerWidth;
24
+
25
+ function setViewportWidth(width: number) {
26
+ Object.defineProperty(window, "innerWidth", { configurable: true, writable: true, value: width });
27
+ window.dispatchEvent(new Event("resize"));
28
+ }
29
+
30
+ afterEach(() => {
31
+ cleanup();
32
+ setViewportWidth(originalInnerWidth);
33
+ });
34
+
35
+ const barAtom = /^_(bg|bc|btc|bbc|bw|btw|bbw|blw|brw|h|minHeight|mih|pos|bxsh|bs)-/;
36
+ const barStyle = /background|border|height|sticky|box-shadow/;
37
+
38
+ /** The row and every wrapper that holds only it, up to the box shared with the body. */
39
+ function expectContentNotBar(row: Element, body: string) {
40
+ for (
41
+ let node: Element | null = row;
42
+ node && !node.textContent?.includes(body);
43
+ node = node.parentElement
44
+ ) {
45
+ const atoms = String(node.className).split(/\s+/).filter(Boolean);
46
+ expect(atoms.filter((atom) => barAtom.test(atom))).toEqual([]);
47
+ expect(node.getAttribute("style") ?? "").not.toMatch(barStyle);
48
+ }
49
+ }
50
+
51
+ const rowIn = (root: ParentNode) => root.querySelector("[data-mp-overlay-header]");
52
+
53
+ function PhoneDialog({ confirm }: { confirm?: boolean }) {
54
+ return (
55
+ <Dialog modal open onOpenChange={() => {}}>
56
+ <Dialog.Portal>
57
+ <DialogOverlay key="overlay" />
58
+ <DialogContent key="content">
59
+ <OverlayHeader
60
+ title="About"
61
+ onClose={() => {}}
62
+ {...(confirm ? { onConfirm: () => {}, confirmKind: "save" as const } : null)}
63
+ />
64
+ <Text>Dialog body</Text>
65
+ </DialogContent>
66
+ </Dialog.Portal>
67
+ </Dialog>
68
+ );
69
+ }
70
+
71
+ describe("the Dialog's phone sheet draws no header bar and no ✕ (FZ-11418)", () => {
72
+ it("at 390 the title is a content row with no button", async () => {
73
+ setViewportWidth(390);
74
+ renderWithProviders(<PhoneDialog />);
75
+ const face = await waitFor(() => {
76
+ const node = document.querySelector("[data-mp-dialog-face='sheet']");
77
+ expect(node).not.toBeNull();
78
+ return node!;
79
+ });
80
+ const row = rowIn(face)!;
81
+ expect(row.getAttribute("data-mp-overlay-face")).toBe("sheet");
82
+ expect(row.textContent).toBe("About");
83
+ expect(face.querySelectorAll("[role='button']")).toHaveLength(0);
84
+ expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
85
+ expectContentNotBar(row, "Dialog body");
86
+ });
87
+
88
+ it("a phone dialog that saves keeps only the ✓", async () => {
89
+ setViewportWidth(390);
90
+ renderWithProviders(<PhoneDialog confirm />);
91
+ const face = await waitFor(() => {
92
+ const node = document.querySelector("[data-mp-dialog-face='sheet']");
93
+ expect(node).not.toBeNull();
94
+ return node!;
95
+ });
96
+ const names = Array.from(face.querySelectorAll("[role='button']")).map((b) =>
97
+ b.getAttribute("aria-label"),
98
+ );
99
+ expect(names).toEqual(["Save"]);
100
+ });
101
+ });
102
+
103
+ describe("SheetModal's title row is content (FZ-11418)", () => {
104
+ it("web: no bar background, border, height or sticky chrome", async () => {
105
+ renderWithProviders(
106
+ <SheetModal open onOpenChange={() => {}} header={<OverlayHeader title="Move" />}>
107
+ <Text>Body</Text>
108
+ </SheetModal>,
109
+ );
110
+ const frame = (await screen.findAllByRole("dialog"))[0]!;
111
+ expectContentNotBar(rowIn(frame)!, "Body");
112
+ expect(frame.querySelectorAll("[role='button']")).toHaveLength(0);
113
+ });
114
+
115
+ it("native: no bar background, border, height or sticky chrome, and no ✕", () => {
116
+ renderWithProviders(
117
+ <NativeSheetModal open onOpenChange={() => {}} header={<OverlayHeader title="Move" />}>
118
+ <Text>Body</Text>
119
+ </NativeSheetModal>,
120
+ );
121
+ const surface = screen.getByTestId("sheet-modal-surface");
122
+ expectContentNotBar(rowIn(surface)!, "Body");
123
+ expect(surface.querySelectorAll("[role='button']")).toHaveLength(0);
124
+ });
125
+
126
+ it("web: scrolls with a scrolling body", async () => {
127
+ renderWithProviders(
128
+ <SheetModal open onOpenChange={() => {}} scrollable header={<OverlayHeader title="Move" />}>
129
+ <Text>Body</Text>
130
+ </SheetModal>,
131
+ );
132
+ const scroll = await screen.findByTestId("sheet-modal-scroll");
133
+ expect(scroll.contains(rowIn(document)!)).toBe(true);
134
+ });
135
+
136
+ it("web: a filled scrolling body carries it too", async () => {
137
+ renderWithProviders(
138
+ <SheetModal
139
+ open
140
+ onOpenChange={() => {}}
141
+ scrollable
142
+ fill
143
+ header={<OverlayHeader title="Move" />}
144
+ >
145
+ <Text>Body</Text>
146
+ </SheetModal>,
147
+ );
148
+ const scroll = await screen.findByTestId("sheet-modal-scroll");
149
+ expect(scroll.contains(rowIn(document)!)).toBe(true);
150
+ });
151
+
152
+ it("native: scrolls with a scrolling body, filled or not", () => {
153
+ for (const fill of [false, true]) {
154
+ renderWithProviders(
155
+ <NativeSheetModal
156
+ open
157
+ onOpenChange={() => {}}
158
+ scrollable
159
+ fill={fill}
160
+ header={<OverlayHeader title="Move" />}
161
+ >
162
+ <Text>Body</Text>
163
+ </NativeSheetModal>,
164
+ );
165
+ expect(screen.getByTestId("sheet-modal-scroll").contains(rowIn(document)!)).toBe(true);
166
+ cleanup();
167
+ }
168
+ });
169
+
170
+ it("a header that is not a title row stays above the scroll", async () => {
171
+ renderWithProviders(
172
+ <SheetModal open onOpenChange={() => {}} scrollable header={<Text>Toolbar</Text>}>
173
+ <Text>Body</Text>
174
+ </SheetModal>,
175
+ );
176
+ const scroll = await screen.findByTestId("sheet-modal-scroll");
177
+ expect(scroll.textContent).not.toContain("Toolbar");
178
+ });
179
+
180
+ it("a sheet that only shows content draws no ✓", async () => {
181
+ renderWithProviders(
182
+ <SheetModal open onOpenChange={() => {}} header={<OverlayHeader title="Details" />}>
183
+ <Text>Body</Text>
184
+ </SheetModal>,
185
+ );
186
+ const frame = (await screen.findAllByRole("dialog"))[0]!;
187
+ expect(rowIn(frame)!.getAttribute("data-mp-overlay-header")).toBe("dismiss");
188
+ expect(screen.queryByRole("button", { name: "Done" })).toBeNull();
189
+ });
190
+
191
+ it("a sheet that commits an edit keeps the ✓", async () => {
192
+ renderWithProviders(
193
+ <SheetModal
194
+ open
195
+ onOpenChange={() => {}}
196
+ header={<OverlayHeader title="Move" onConfirm={() => {}} />}
197
+ >
198
+ <Text>Body</Text>
199
+ </SheetModal>,
200
+ );
201
+ expect(await screen.findByRole("button", { name: "Done" })).toBeTruthy();
202
+ });
203
+ });
@@ -29,8 +29,9 @@ import {
29
29
  type MotionStop,
30
30
  nativeAnimationConfig as animationConfig,
31
31
  overlayScrim,
32
- sheetGrabber,
33
- sheetGrabberZone,
32
+ sheetHandle,
33
+ sheetHandleTone,
34
+ sheetHandleZone,
34
35
  } from "@multiplatform.one/theme";
35
36
  import {
36
37
  useCallback,
@@ -65,17 +66,16 @@ import {
65
66
  import { useTranslation } from "../shared/i18n";
66
67
  import { useKeyboardInset } from "../shared/useKeyboardInset";
67
68
  import { View, YStack } from "tamagui";
68
- import { DialogRegionContext } from "../surfaces";
69
69
 
70
70
  import type { SheetModalProps } from "./index";
71
- import { SheetHeader } from "./SheetHeader";
71
+ import { SheetBodyRegion } from "./SheetBodyRegion";
72
+ import { isOverlayHeader, SheetHeader } from "./SheetHeader";
72
73
  import { SheetNavigation } from "./SheetNavigation";
73
74
  export type { SheetModalProps } from "./index";
74
75
 
75
76
  const bottomInset = Platform.OS === "ios" ? 24 : 16;
76
77
  // Backdrop left visible above the sheet, so the scrim stays tappable.
77
78
  const backdropStrip = 48;
78
- const IN_DIALOG_REGION = { inDialogRegion: true } as const;
79
79
  /*
80
80
  * MPO-299 fill: an owned viewport bootstraps from zero unless EVERY link
81
81
  * between the capped frame and the body gives way at once — frame height,
@@ -103,6 +103,7 @@ export function SheetModal({
103
103
  scrollable,
104
104
  fill = false,
105
105
  flush = false,
106
+ onDismiss,
106
107
  }: SheetModalProps) {
107
108
  const { t } = useTranslation();
108
109
  const { knobProps } = useResolvedKnobs();
@@ -116,6 +117,7 @@ export function SheetModal({
116
117
  ) : (
117
118
  sheetHeader
118
119
  );
120
+ const titleScrolls = isOverlayHeader(headerContent) && scrollable === true;
119
121
  const windowZIndex = useOverlayZIndex("sheet");
120
122
  const slideTransition = knobProps.motion.slide.transition;
121
123
  const slideDuration = motionDurationMs(slideTransition);
@@ -130,15 +132,13 @@ export function SheetModal({
130
132
  const regular = overlaySizeClass(windowWidth) === "regular";
131
133
  const keyboardInset = useKeyboardInset();
132
134
  const topInset = useContext(SafeAreaInsetsContext)?.top ?? initialWindowMetrics?.insets.top ?? 0;
133
- const [backdropArmed, setBackdropArmed] = useState(false);
134
- const armTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
135
+ const scrimOpacity = useRef(new Animated.Value(0)).current;
136
+ const onDismissRef = useRef(onDismiss);
137
+ onDismissRef.current = onDismiss;
138
+ const shownRef = useRef(false);
135
139
 
136
140
  const close = useCallback(() => onOpenChange(false), [onOpenChange]);
137
141
 
138
- const handleBackdropPress = useCallback(() => {
139
- if (backdropArmed) close();
140
- }, [backdropArmed, close]);
141
-
142
142
  // MPO-64: the sheet ends above the keyboard rather than running under it,
143
143
  // and below the status bar with a strip of backdrop still showing.
144
144
  const available = Math.max(0, windowHeight - keyboardInset);
@@ -196,6 +196,12 @@ export function SheetModal({
196
196
  const presentationRef = useRef(0);
197
197
  const activeRef = useRef(false);
198
198
 
199
+ const handleDismiss = useCallback(() => {
200
+ if (activeRef.current || !shownRef.current) return;
201
+ shownRef.current = false;
202
+ onDismissRef.current?.();
203
+ }, []);
204
+
199
205
  /*
200
206
  * MPO-68 / MPO-299: a sheet at rest below full height is LAID OUT at that
201
207
  * height. Translating a full-height frame down pushed its bottom off the
@@ -353,24 +359,27 @@ export function SheetModal({
353
359
  const presentation = presentationRef.current;
354
360
  const { slideDuration, scrimDuration } = entryTiming.current;
355
361
  enteredRef.current = true;
356
- if (armTimerRef.current) clearTimeout(armTimerRef.current);
362
+ if (scrimDuration) {
363
+ scrimOpacity.setValue(0);
364
+ Animated.timing(scrimOpacity, {
365
+ toValue: 1,
366
+ duration: scrimDuration,
367
+ easing: Easing.bezier(0.25, 0.1, 0.25, 1),
368
+ useNativeDriver: false,
369
+ }).start();
370
+ } else {
371
+ scrimOpacity.setValue(1);
372
+ }
357
373
  if (!slideDuration) {
358
374
  translateY.setValue(0);
359
375
  restRef.current = 0;
360
- setBackdropArmed(true);
361
376
  return;
362
377
  }
363
- armTimerRef.current = setTimeout(() => {
364
- if (activeRef.current && presentation === presentationRef.current) {
365
- armTimerRef.current = null;
366
- setBackdropArmed(true);
367
- }
368
- }, scrimDuration);
369
- // MPO-62: the modal fades (backdrop dims IN PLACE); only the panel slides.
378
+ // MPO-62: the scrim dims IN PLACE; only the panel slides.
370
379
  // MPO-71: the sheet is already parked off-screen before the present, so
371
380
  // this setValue only normalises the start to exactly `travel` once the
372
381
  // sheet has measured. Priming it here ALONE is the open-close-open bug:
373
- // by the time onShow runs the dissolve has already shown the sheet.
382
+ // by the time onShow runs the present has already shown the sheet.
374
383
  translateY.setValue(travelRef.current);
375
384
  restRef.current = 0;
376
385
  Animated.timing(translateY, {
@@ -382,7 +391,7 @@ export function SheetModal({
382
391
  if (finished && activeRef.current && presentation === presentationRef.current)
383
392
  translateY.setValue(0);
384
393
  });
385
- }, [translateY]);
394
+ }, [scrimOpacity, translateY]);
386
395
 
387
396
  useEffect(() => {
388
397
  presentationRef.current += 1;
@@ -390,9 +399,11 @@ export function SheetModal({
390
399
  restHeightRef.current = null;
391
400
  frameCap.setValue(maxHeightRef.current);
392
401
  if (open) {
402
+ shownRef.current = true;
393
403
  enter();
394
404
  } else {
395
- setBackdropArmed(false);
405
+ scrimOpacity.setValue(0);
406
+ if (Platform.OS !== "ios") handleDismiss();
396
407
  const parked = travelRef.current || 10000;
397
408
  translateY.setValue(parked);
398
409
  restRef.current = parked;
@@ -402,22 +413,20 @@ export function SheetModal({
402
413
  activeRef.current = false;
403
414
  presentationRef.current += 1;
404
415
  enteredRef.current = false;
405
- if (armTimerRef.current) {
406
- clearTimeout(armTimerRef.current);
407
- armTimerRef.current = null;
408
- }
416
+ scrimOpacity.stopAnimation();
409
417
  translateY.stopAnimation();
410
418
  };
411
- }, [open, enter, frameCap, translateY]);
419
+ }, [open, enter, frameCap, handleDismiss, scrimOpacity, translateY]);
412
420
 
413
421
  return (
414
422
  <Modal
415
423
  visible={open}
416
424
  transparent
417
- animationType={scrimDuration ? "fade" : "none"}
425
+ animationType="none"
418
426
  statusBarTranslucent
419
427
  onRequestClose={close}
420
428
  onShow={enter}
429
+ onDismiss={handleDismiss}
421
430
  >
422
431
  <OverlayWindow zIndex={windowZIndex}>
423
432
  <RNView
@@ -434,11 +443,13 @@ export function SheetModal({
434
443
  >
435
444
  <Pressable
436
445
  style={StyleSheet.absoluteFill}
437
- onPress={handleBackdropPress}
446
+ onPress={close}
438
447
  accessibilityRole="button"
439
448
  accessibilityLabel={t("Close")}
440
449
  >
441
- <View flex={1} backgroundColor={overlayScrim} />
450
+ <Animated.View testID="sheet-modal-scrim" style={{ flex: 1, opacity: scrimOpacity }}>
451
+ <View flex={1} backgroundColor={overlayScrim} />
452
+ </Animated.View>
442
453
  </Pressable>
443
454
  <Animated.View
444
455
  onLayout={(e) => {
@@ -463,6 +474,21 @@ export function SheetModal({
463
474
  transform: [{ translateY }],
464
475
  }}
465
476
  >
477
+ {/*
478
+ The grabber is the grab ZONE, not the 10pt pill inside it. LC-71
479
+ says the frame is not a control; the grabber is the one part of
480
+ it that is, so it is the only thing that takes the gesture, and
481
+ it never fights the ScrollView below.
482
+ */}
483
+ <RNView
484
+ {...panResponder.panHandlers}
485
+ accessibilityRole="adjustable"
486
+ accessibilityLabel={t("Drag to resize")}
487
+ testID="sheet-modal-grabber"
488
+ style={{ ...sheetHandleZone, ...(fill ? nonShrinking : null) }}
489
+ >
490
+ <View {...sheetHandle} {...sheetHandleTone(knobProps.scheme)} accessible={false} />
491
+ </RNView>
466
492
  <YStack
467
493
  testID="sheet-modal-surface"
468
494
  data-sheet-form={regular ? "panel" : "bottom"}
@@ -473,6 +499,8 @@ export function SheetModal({
473
499
  backgroundColor: knobProps.elevatedSurface.backgroundColor,
474
500
  })}
475
501
  {...knobProps.borderRadius}
502
+ borderTopLeftRadius={knobProps.sheetRadius.borderRadius}
503
+ borderTopRightRadius={knobProps.sheetRadius.borderRadius}
476
504
  borderBottomLeftRadius={0}
477
505
  borderBottomRightRadius={0}
478
506
  // A compact sheet spans the screen: only its top edge meets the page.
@@ -495,31 +523,16 @@ export function SheetModal({
495
523
  accessibilityViewIsModal
496
524
  onAccessibilityEscape={close}
497
525
  >
498
- {/*
499
- The grabber is the grab ZONE, not the 5pt pill inside it. LC-71
500
- says the frame is not a control; the grabber is the one part of
501
- it that is, so it is the only thing that takes the gesture, and
502
- it never fights the ScrollView below.
503
- */}
504
526
  <YStack
505
527
  testID="sheet-modal-clip"
506
528
  overflow="hidden"
507
- borderTopLeftRadius={knobProps.borderRadius.borderRadius}
508
- borderTopRightRadius={knobProps.borderRadius.borderRadius}
529
+ borderTopLeftRadius={knobProps.sheetRadius.borderRadius}
530
+ borderTopRightRadius={knobProps.sheetRadius.borderRadius}
509
531
  flexShrink={1}
510
532
  minHeight={0}
511
533
  {...(fill ? fillSlot : null)}
512
534
  >
513
- <RNView
514
- {...panResponder.panHandlers}
515
- accessibilityRole="adjustable"
516
- accessibilityLabel={t("Drag to resize")}
517
- testID="sheet-modal-grabber"
518
- style={{ ...sheetGrabberZone, ...(fill ? nonShrinking : null) }}
519
- >
520
- <View {...sheetGrabber} accessible={false} />
521
- </RNView>
522
- <DialogRegionContext.Provider value={IN_DIALOG_REGION}>
535
+ <SheetBodyRegion>
523
536
  <Surface elevated>
524
537
  <YStack
525
538
  testID="sheet-modal-content"
@@ -536,7 +549,9 @@ export function SheetModal({
536
549
  root={
537
550
  fill ? (
538
551
  <>
539
- {header ? <RNView style={nonShrinking}>{header}</RNView> : null}
552
+ {header && !titleScrolls ? (
553
+ <RNView style={nonShrinking}>{header}</RNView>
554
+ ) : null}
540
555
  <RNView testID="sheet-modal-body" style={fillSlot}>
541
556
  {scrollable ? (
542
557
  <RNScrollView
@@ -544,7 +559,14 @@ export function SheetModal({
544
559
  style={fillSlot}
545
560
  keyboardShouldPersistTaps="handled"
546
561
  >
547
- {children}
562
+ {titleScrolls ? (
563
+ <YStack gap={knobProps.gap.gap}>
564
+ {header}
565
+ {children}
566
+ </YStack>
567
+ ) : (
568
+ children
569
+ )}
548
570
  </RNScrollView>
549
571
  ) : (
550
572
  children
@@ -553,14 +575,21 @@ export function SheetModal({
553
575
  </>
554
576
  ) : (
555
577
  <>
556
- {header}
578
+ {titleScrolls ? null : header}
557
579
  {scrollable ? (
558
580
  <RNScrollView
559
581
  testID="sheet-modal-scroll"
560
582
  style={{ flexGrow: 0 }}
561
583
  keyboardShouldPersistTaps="handled"
562
584
  >
563
- {children}
585
+ {titleScrolls ? (
586
+ <YStack gap={knobProps.gap.gap}>
587
+ {header}
588
+ {children}
589
+ </YStack>
590
+ ) : (
591
+ children
592
+ )}
564
593
  </RNScrollView>
565
594
  ) : (
566
595
  children
@@ -571,7 +600,7 @@ export function SheetModal({
571
600
  />
572
601
  </YStack>
573
602
  </Surface>
574
- </DialogRegionContext.Provider>
603
+ </SheetBodyRegion>
575
604
  </YStack>
576
605
  </YStack>
577
606
  </Animated.View>