@oxyhq/bloom 0.46.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/bottom-sheet/BottomSheetBase.js +36 -12
- package/lib/commonjs/bottom-sheet/BottomSheetBase.js.map +1 -1
- package/lib/commonjs/combobox/Combobox.js +3 -3
- package/lib/commonjs/combobox/Combobox.js.map +1 -1
- package/lib/commonjs/command/Command.js +3 -3
- package/lib/commonjs/command/Command.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.js +103 -8
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +189 -12
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/DialogBottomSheet.js +111 -31
- package/lib/commonjs/dialog/DialogBottomSheet.js.map +1 -1
- package/lib/commonjs/dialog/DialogHeader.js +371 -0
- package/lib/commonjs/dialog/DialogHeader.js.map +1 -0
- package/lib/commonjs/dialog/DialogMorph.js +458 -0
- package/lib/commonjs/dialog/DialogMorph.js.map +1 -0
- package/lib/commonjs/dialog/index.js +14 -0
- package/lib/commonjs/dialog/index.js.map +1 -1
- package/lib/commonjs/dialog/index.web.js +14 -0
- package/lib/commonjs/dialog/index.web.js.map +1 -1
- package/lib/commonjs/index.js +11 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +11 -4
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/react-native-className.d.js +6 -0
- package/lib/commonjs/react-native-className.d.js.map +1 -0
- package/lib/commonjs/{search-input → search}/index.js +5 -3
- package/lib/commonjs/search/index.js.map +1 -0
- package/lib/commonjs/settings-list/SettingsList.js +6 -2
- package/lib/commonjs/settings-list/SettingsList.js.map +1 -1
- package/lib/commonjs/surfaces/SurfaceHost.js +23 -9
- package/lib/commonjs/surfaces/SurfaceHost.js.map +1 -1
- package/lib/commonjs/text-field/index.js +22 -6
- package/lib/commonjs/text-field/index.js.map +1 -1
- package/lib/module/bottom-sheet/BottomSheetBase.js +36 -12
- package/lib/module/bottom-sheet/BottomSheetBase.js.map +1 -1
- package/lib/module/combobox/Combobox.js +3 -3
- package/lib/module/combobox/Combobox.js.map +1 -1
- package/lib/module/command/Command.js +3 -3
- package/lib/module/command/Command.js.map +1 -1
- package/lib/module/dialog/Dialog.js +104 -9
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +192 -16
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/DialogBottomSheet.js +113 -33
- package/lib/module/dialog/DialogBottomSheet.js.map +1 -1
- package/lib/module/dialog/DialogHeader.js +362 -0
- package/lib/module/dialog/DialogHeader.js.map +1 -0
- package/lib/module/dialog/DialogMorph.js +451 -0
- package/lib/module/dialog/DialogMorph.js.map +1 -0
- package/lib/module/dialog/index.js +2 -0
- package/lib/module/dialog/index.js.map +1 -1
- package/lib/module/dialog/index.web.js +2 -0
- package/lib/module/dialog/index.web.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +2 -2
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/react-native-className.d.js +20 -0
- package/lib/module/react-native-className.d.js.map +1 -0
- package/lib/module/{search-input → search}/index.js +6 -2
- package/lib/module/search/index.js.map +1 -0
- package/lib/module/settings-list/SettingsList.js +6 -2
- package/lib/module/settings-list/SettingsList.js.map +1 -1
- package/lib/module/surfaces/SurfaceHost.js +23 -9
- package/lib/module/surfaces/SurfaceHost.js.map +1 -1
- package/lib/module/text-field/index.js +22 -6
- package/lib/module/text-field/index.js.map +1 -1
- package/lib/typescript/commonjs/bottom-sheet/BottomSheetBase.d.ts +31 -1
- package/lib/typescript/commonjs/bottom-sheet/BottomSheetBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/combobox/Combobox.d.ts +1 -1
- package/lib/typescript/commonjs/command/Command.d.ts +1 -1
- package/lib/typescript/commonjs/dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/DialogBottomSheet.d.ts +2 -2
- package/lib/typescript/commonjs/dialog/DialogBottomSheet.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/DialogHeader.d.ts +86 -0
- package/lib/typescript/commonjs/dialog/DialogHeader.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/DialogMorph.d.ts +150 -0
- package/lib/typescript/commonjs/dialog/DialogMorph.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/index.d.ts +4 -1
- package/lib/typescript/commonjs/dialog/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/index.web.d.ts +4 -1
- package/lib/typescript/commonjs/dialog/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/types.d.ts +105 -0
- package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/icons/common.d.ts +1 -0
- package/lib/typescript/commonjs/icons/common.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +3 -3
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +3 -3
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/input-group/types.d.ts +1 -1
- package/lib/typescript/commonjs/{search-input → search}/index.d.ts +1 -1
- package/lib/typescript/commonjs/search/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/surfaces/SurfaceHost.d.ts.map +1 -1
- package/lib/typescript/commonjs/surfaces/types.d.ts +26 -1
- package/lib/typescript/commonjs/surfaces/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/text-field/index.d.ts +2 -1
- package/lib/typescript/commonjs/text-field/index.d.ts.map +1 -1
- package/lib/typescript/module/bottom-sheet/BottomSheetBase.d.ts +31 -1
- package/lib/typescript/module/bottom-sheet/BottomSheetBase.d.ts.map +1 -1
- package/lib/typescript/module/combobox/Combobox.d.ts +1 -1
- package/lib/typescript/module/command/Command.d.ts +1 -1
- package/lib/typescript/module/dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/DialogBottomSheet.d.ts +2 -2
- package/lib/typescript/module/dialog/DialogBottomSheet.d.ts.map +1 -1
- package/lib/typescript/module/dialog/DialogHeader.d.ts +86 -0
- package/lib/typescript/module/dialog/DialogHeader.d.ts.map +1 -0
- package/lib/typescript/module/dialog/DialogMorph.d.ts +150 -0
- package/lib/typescript/module/dialog/DialogMorph.d.ts.map +1 -0
- package/lib/typescript/module/dialog/index.d.ts +4 -1
- package/lib/typescript/module/dialog/index.d.ts.map +1 -1
- package/lib/typescript/module/dialog/index.web.d.ts +4 -1
- package/lib/typescript/module/dialog/index.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/types.d.ts +105 -0
- package/lib/typescript/module/dialog/types.d.ts.map +1 -1
- package/lib/typescript/module/icons/common.d.ts +1 -0
- package/lib/typescript/module/icons/common.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +3 -3
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +3 -3
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/input-group/types.d.ts +1 -1
- package/lib/typescript/module/{search-input → search}/index.d.ts +1 -1
- package/lib/typescript/module/search/index.d.ts.map +1 -0
- package/lib/typescript/module/surfaces/SurfaceHost.d.ts.map +1 -1
- package/lib/typescript/module/surfaces/types.d.ts +26 -1
- package/lib/typescript/module/surfaces/types.d.ts.map +1 -1
- package/lib/typescript/module/text-field/index.d.ts +2 -1
- package/lib/typescript/module/text-field/index.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/__tests__/BottomSheet.test.tsx +47 -0
- package/src/__tests__/DialogBottomSheet.test.tsx +30 -5
- package/src/__tests__/DialogMorph.test.tsx +230 -0
- package/src/bottom-sheet/BottomSheetBase.tsx +72 -11
- package/src/combobox/Combobox.tsx +3 -3
- package/src/command/Command.tsx +3 -3
- package/src/dialog/Dialog.tsx +111 -14
- package/src/dialog/Dialog.web.tsx +186 -25
- package/src/dialog/DialogBottomSheet.tsx +122 -30
- package/src/dialog/DialogHeader.tsx +429 -0
- package/src/dialog/DialogMorph.tsx +576 -0
- package/src/dialog/index.ts +4 -0
- package/src/dialog/index.web.ts +4 -0
- package/src/dialog/types.ts +106 -0
- package/src/index.ts +3 -1
- package/src/index.web.ts +3 -1
- package/src/input-group/types.ts +1 -1
- package/src/react-native-className.d.ts +38 -0
- package/src/{search-input → search}/index.tsx +8 -5
- package/src/settings-list/SettingsList.tsx +6 -2
- package/src/surfaces/SurfaceHost.tsx +17 -1
- package/src/surfaces/types.ts +26 -1
- package/src/text-field/index.tsx +24 -5
- package/lib/commonjs/search-input/index.js.map +0 -1
- package/lib/module/search-input/index.js.map +0 -1
- package/lib/typescript/commonjs/search-input/index.d.ts.map +0 -1
- package/lib/typescript/module/search-input/index.d.ts.map +0 -1
|
@@ -10,6 +10,8 @@ var _bottomSheet = require("../bottom-sheet");
|
|
|
10
10
|
var _useTheme = require("../theme/use-theme.js");
|
|
11
11
|
var _context = require("./context.js");
|
|
12
12
|
var _DialogContent = require("./DialogContent.js");
|
|
13
|
+
var _DialogHeader = require("./DialogHeader.js");
|
|
14
|
+
var _DialogMorph = require("./DialogMorph.js");
|
|
13
15
|
var _placement = require("./placement.js");
|
|
14
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -36,15 +38,19 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
36
38
|
function DialogBottomSheet({
|
|
37
39
|
control,
|
|
38
40
|
open: controlledOpen,
|
|
41
|
+
startOpen,
|
|
39
42
|
onClose,
|
|
40
43
|
testID,
|
|
41
44
|
title,
|
|
42
45
|
description,
|
|
43
46
|
actions,
|
|
47
|
+
header,
|
|
44
48
|
maxHeightRatio = _placement.DEFAULT_MAX_HEIGHT_RATIO,
|
|
45
49
|
showHandle = true,
|
|
46
50
|
dismissOnBackdrop = true,
|
|
47
51
|
contentPadding = _placement.DEFAULT_DIALOG_CONTENT_PADDING,
|
|
52
|
+
scrollable,
|
|
53
|
+
morph,
|
|
48
54
|
style,
|
|
49
55
|
panelStyle,
|
|
50
56
|
panelClassName,
|
|
@@ -55,10 +61,14 @@ function DialogBottomSheet({
|
|
|
55
61
|
}) {
|
|
56
62
|
const isControlled = controlledOpen !== undefined;
|
|
57
63
|
const theme = (0, _useTheme.useTheme)();
|
|
64
|
+
const {
|
|
65
|
+
height: viewportHeight
|
|
66
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
58
67
|
const ref = (0, _react.useRef)(null);
|
|
59
68
|
const closeCallbacks = (0, _react.useRef)([]);
|
|
60
69
|
const titleId = (0, _react.useId)();
|
|
61
70
|
const descriptionId = (0, _react.useId)();
|
|
71
|
+
const headerController = (0, _DialogHeader.useDialogHeaderController)();
|
|
62
72
|
|
|
63
73
|
// Read the latest controlled flag / `onClose` inside stable callbacks without
|
|
64
74
|
// re-binding them (the context + imperative handle depend on `close` staying
|
|
@@ -136,6 +146,18 @@ function DialogBottomSheet({
|
|
|
136
146
|
// from `onDismissAttempt` blocks the BottomSheet's own backdrop/pan dismissal,
|
|
137
147
|
// which is how `dismissOnBackdrop: false` maps onto the single sheet API.
|
|
138
148
|
const onDismissAttempt = (0, _react.useCallback)(() => dismissOnBackdrop, [dismissOnBackdrop]);
|
|
149
|
+
const scrollableResolved = scrollable ?? true;
|
|
150
|
+
|
|
151
|
+
// Size morphing across an in-place content swap. The sheet is anchored at the
|
|
152
|
+
// bottom, so animating its height makes it grow/shrink from that edge; its
|
|
153
|
+
// width is fixed by the placement. The sheet's own `maxHeight` (the ratio
|
|
154
|
+
// percentage + the safe-area clamp inside `BottomSheet`) does the exact
|
|
155
|
+
// capping — the viewport is just the bound the reshape may not exceed.
|
|
156
|
+
const morphState = (0, _DialogMorph.useDialogMorph)({
|
|
157
|
+
enabled: morph !== false,
|
|
158
|
+
measurable: scrollableResolved,
|
|
159
|
+
maxHeight: viewportHeight
|
|
160
|
+
});
|
|
139
161
|
|
|
140
162
|
// `panelStyle` paints the sheet surface (e.g. a brand background). It composes
|
|
141
163
|
// AFTER the BottomSheet's internal background so a host palette wins; the
|
|
@@ -147,46 +169,105 @@ function DialogBottomSheet({
|
|
|
147
169
|
borderTopLeftRadius: _placement.PANEL_RADIUS + 4,
|
|
148
170
|
borderTopRightRadius: _placement.PANEL_RADIUS + 4,
|
|
149
171
|
maxHeight: maxHeightPercent
|
|
150
|
-
}, panelStyle
|
|
151
|
-
|
|
172
|
+
}, panelStyle,
|
|
173
|
+
// Drives the card's `height` only while a morph is in flight; at rest it
|
|
174
|
+
// resolves to `height: 'auto'` — the sheet's normal content sizing.
|
|
175
|
+
morphState.panelStyle];
|
|
176
|
+
}, [theme.colors.background, maxHeightRatio, panelStyle, morphState.panelStyle]);
|
|
152
177
|
|
|
153
178
|
// Does this dialog render bloom's declarative chrome (title / description /
|
|
154
|
-
// actions)
|
|
155
|
-
//
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
// viewports. This only changes what `DialogBottomSheet` passes to
|
|
161
|
-
// `BottomSheet`; the standalone `BottomSheet` API and its `scrollable` default
|
|
162
|
-
// are unchanged for direct consumers.
|
|
179
|
+
// actions)? This no longer gates the SCROLL decision (that is now the explicit
|
|
180
|
+
// `scrollable` prop below) — it only opts declarative dialogs into the
|
|
181
|
+
// gorhom-style pan coordination for their internal ScrollView. A declarative
|
|
182
|
+
// dialog overflowing on a small viewport needs the coordinated pan so the body
|
|
183
|
+
// scrolls instead of the drag stealing every vertical gesture; pure-custom
|
|
184
|
+
// children keep the legacy always-active pan.
|
|
163
185
|
const hasDeclarativeChrome = title !== undefined || description !== undefined || actions !== undefined && actions.length > 0;
|
|
186
|
+
const dialogBody = /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogContent.DialogBody, {
|
|
187
|
+
titleId: titleId,
|
|
188
|
+
descriptionId: descriptionId,
|
|
189
|
+
title: title,
|
|
190
|
+
description: description,
|
|
191
|
+
actions: actions,
|
|
192
|
+
children: children
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Nav-header mode: the Dialog OWNS a sticky gradient nav bar + a large
|
|
196
|
+
// collapsing title over the sheet's OWN scroll content. The bar floats via the
|
|
197
|
+
// BottomSheet `headerOverlay` slot; the sheet's scroll offset feeds the shared
|
|
198
|
+
// controller (`scrollY`) that drives the small-title cross-fade. `contentPadding`
|
|
199
|
+
// is dropped (the large title + screens own their padding).
|
|
200
|
+
const headerBody = header ? scrollableResolved ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
201
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogHeader.DialogLargeTitle, {
|
|
202
|
+
controller: headerController,
|
|
203
|
+
header: header
|
|
204
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogHeader.DialogHeaderProvider, {
|
|
205
|
+
controller: headerController,
|
|
206
|
+
children: dialogBody
|
|
207
|
+
})]
|
|
208
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
209
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
210
|
+
style: {
|
|
211
|
+
height: _DialogHeader.DIALOG_NAV_BAR_HEIGHT
|
|
212
|
+
}
|
|
213
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogHeader.DialogHeaderProvider, {
|
|
214
|
+
controller: headerController,
|
|
215
|
+
children: dialogBody
|
|
216
|
+
})]
|
|
217
|
+
}) : null;
|
|
164
218
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_bottomSheet.BottomSheet, {
|
|
165
|
-
ref: ref
|
|
219
|
+
ref: ref
|
|
220
|
+
// Seed the sheet's open state so a fresh mount that should be open renders
|
|
221
|
+
// visible on its FIRST commit instead of relying on a present()-in-effect
|
|
222
|
+
// that races the mount and flashes blank. In controlled mode that seed is
|
|
223
|
+
// `controlledOpen`; in imperative mode it is the surface's `startOpen`
|
|
224
|
+
// intent — which is what lets a responsive Dialog survive a resize
|
|
225
|
+
// placement swap (centered card → bottom sheet) STILL OPEN.
|
|
226
|
+
,
|
|
227
|
+
open: isControlled ? controlledOpen : startOpen,
|
|
166
228
|
onDismiss: handleDismiss,
|
|
167
229
|
onDismissAttempt: onDismissAttempt,
|
|
168
|
-
enablePanDownToClose: true
|
|
169
|
-
|
|
170
|
-
//
|
|
171
|
-
|
|
230
|
+
enablePanDownToClose: true
|
|
231
|
+
// Nav-header mode hides the drag handle (the nav bar sits at the very top);
|
|
232
|
+
// drag-to-dismiss still works via the coordinated body pan.
|
|
233
|
+
,
|
|
234
|
+
showHandle: header ? false : showHandle
|
|
235
|
+
// Content scrolls inside the sheet's internal ScrollView by default; the
|
|
236
|
+
// Dialog owns the scroll boundary. A surface whose content owns its own
|
|
237
|
+
// scroller (a FlatList / VirtualizedList) passes `scrollable={false}` to
|
|
238
|
+
// opt OUT so there is exactly ONE scroll container (no scroll-in-scroll,
|
|
239
|
+
// no "VirtualizedList inside a plain ScrollView" warning).
|
|
172
240
|
,
|
|
173
|
-
scrollable:
|
|
174
|
-
// Declarative dialogs (title/description/actions) that overflow
|
|
175
|
-
//
|
|
241
|
+
scrollable: scrollableResolved
|
|
242
|
+
// Declarative dialogs (title/description/actions) that overflow — AND every
|
|
243
|
+
// nav-header page (its scroll content overflows by design) — need
|
|
176
244
|
// gorhom-style pan coordination: the drag-to-dismiss pan only activates
|
|
177
245
|
// when the ScrollView is at the top AND the finger moves down >8dp —
|
|
178
246
|
// otherwise the ScrollView owns the touch. Without this the always-active
|
|
179
247
|
// legacy body-pan steals vertical drags and a tall body cannot scroll
|
|
180
248
|
// (dragging up dismisses the sheet / bleeds into the parent instead). The
|
|
181
249
|
// standalone `BottomSheet` API keeps its legacy `manualActivation={false}`
|
|
182
|
-
// default, so direct consumers are unaffected.
|
|
183
|
-
|
|
250
|
+
// default, so direct consumers are unaffected.
|
|
251
|
+
,
|
|
252
|
+
manualActivation: header ? scrollableResolved : hasDeclarativeChrome
|
|
253
|
+
// Feed the sheet's scroll offset into the nav header's collapse controller.
|
|
184
254
|
,
|
|
185
|
-
|
|
255
|
+
scrollY: header ? headerController.scrollY : undefined
|
|
256
|
+
// Float the sticky nav bar over the scroll body (clipped to the sheet top).
|
|
257
|
+
,
|
|
258
|
+
headerOverlay: header ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogHeader.DialogNavHeader, {
|
|
259
|
+
controller: headerController,
|
|
260
|
+
header: header,
|
|
261
|
+
onDismiss: close,
|
|
262
|
+
collapse: scrollableResolved
|
|
263
|
+
}) : undefined
|
|
186
264
|
// Stronger dim than a lone sheet so an underlying sheet's handle/content
|
|
187
265
|
// doesn't bleed through when a Dialog is stacked over one.
|
|
188
266
|
,
|
|
189
|
-
backdropOpacity: _placement.SHEET_BACKDROP_OPACITY + 0.3
|
|
267
|
+
backdropOpacity: _placement.SHEET_BACKDROP_OPACITY + 0.3
|
|
268
|
+
// Measures the sheet card — the size a morph starts from.
|
|
269
|
+
,
|
|
270
|
+
onLayout: morphState.onPanelLayout,
|
|
190
271
|
style: sheetStyle,
|
|
191
272
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.Context.Provider, {
|
|
192
273
|
value: context,
|
|
@@ -201,19 +282,18 @@ function DialogBottomSheet({
|
|
|
201
282
|
...(panelClassName ? {
|
|
202
283
|
className: panelClassName
|
|
203
284
|
} : {}),
|
|
204
|
-
style: [
|
|
285
|
+
style: [
|
|
286
|
+
// Nav-header mode: the large title + screens own their padding, so the
|
|
287
|
+
// wrapper adds none. Otherwise the Dialog's uniform content padding.
|
|
288
|
+
header ? null : {
|
|
205
289
|
padding: contentPadding
|
|
206
290
|
},
|
|
207
291
|
// `containerStyle` carries the host's CSS-var theme scope; it wraps
|
|
208
292
|
// the content subtree so descendants read the scoped palette.
|
|
209
293
|
containerStyle, style, panelStyle],
|
|
210
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
title: title,
|
|
214
|
-
description: description,
|
|
215
|
-
actions: actions,
|
|
216
|
-
children: children
|
|
294
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogMorph.DialogMorphContent, {
|
|
295
|
+
morph: morphState,
|
|
296
|
+
children: header ? headerBody : dialogBody
|
|
217
297
|
})
|
|
218
298
|
})
|
|
219
299
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bottomSheet","_useTheme","_context","_DialogContent","_placement","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DialogBottomSheet","control","open","controlledOpen","onClose","testID","title","description","actions","maxHeightRatio","DEFAULT_MAX_HEIGHT_RATIO","showHandle","dismissOnBackdrop","contentPadding","DEFAULT_DIALOG_CONTENT_PADDING","style","panelStyle","panelClassName","containerStyle","containerClassName","label","children","isControlled","undefined","theme","useTheme","ref","useRef","closeCallbacks","titleId","useId","descriptionId","isControlledRef","current","onCloseRef","callQueuedCallbacks","useCallback","queued","cb","console","error","present","close","push","dismiss","handleDismiss","useEffect","useImperativeHandle","context","useMemo","isWithinDialog","onDismissAttempt","sheetStyle","maxHeightPercent","Math","round","backgroundColor","colors","background","borderTopLeftRadius","PANEL_RADIUS","borderTopRightRadius","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_bottomSheet","_useTheme","_context","_DialogContent","_DialogHeader","_DialogMorph","_placement","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DialogBottomSheet","control","open","controlledOpen","startOpen","onClose","testID","title","description","actions","header","maxHeightRatio","DEFAULT_MAX_HEIGHT_RATIO","showHandle","dismissOnBackdrop","contentPadding","DEFAULT_DIALOG_CONTENT_PADDING","scrollable","morph","style","panelStyle","panelClassName","containerStyle","containerClassName","label","children","isControlled","undefined","theme","useTheme","height","viewportHeight","useWindowDimensions","ref","useRef","closeCallbacks","titleId","useId","descriptionId","headerController","useDialogHeaderController","isControlledRef","current","onCloseRef","callQueuedCallbacks","useCallback","queued","cb","console","error","present","close","push","dismiss","handleDismiss","useEffect","useImperativeHandle","context","useMemo","isWithinDialog","onDismissAttempt","scrollableResolved","morphState","useDialogMorph","enabled","measurable","maxHeight","sheetStyle","maxHeightPercent","Math","round","backgroundColor","colors","background","borderTopLeftRadius","PANEL_RADIUS","borderTopRightRadius","hasDeclarativeChrome","length","dialogBody","jsx","DialogBody","headerBody","jsxs","Fragment","DialogLargeTitle","controller","DialogHeaderProvider","View","DIALOG_NAV_BAR_HEIGHT","BottomSheet","onDismiss","enablePanDownToClose","manualActivation","scrollY","headerOverlay","DialogNavHeader","collapse","backdropOpacity","SHEET_BACKDROP_OPACITY","onLayout","onPanelLayout","Context","Provider","value","accessibilityLabel","className","padding","DialogMorphContent"],"sourceRoot":"../../../src","sources":["dialog/DialogBottomSheet.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAA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M,EAAEA,MAAO;QACfmG,kBAAkB,EAAEjF,KAAM;QAC1B,mBAAiBjB,KAAK,GAAG6B,OAAO,GAAGT,SAAU;QAC7C,oBAAkBnB,WAAW,GAAG8B,aAAa,GAAGX,SAAU;QAAA,IACrDJ,kBAAkB,GAAI;UAAEmF,SAAS,EAAEnF;QAAmB,CAAC,GAA8B,CAAC,CAAC;QAAA,IACvFF,cAAc,GAAI;UAAEqF,SAAS,EAAErF;QAAe,CAAC,GAA8B,CAAC,CAAC;QACpFF,KAAK,EAAE;QACL;QACA;QACAT,MAAM,GAAG,IAAI,GAAG;UAAEiG,OAAO,EAAE5F;QAAe,CAAC;QAC3C;QACA;QACAO,cAAc,EACdH,KAAK,EACLC,UAAU,CACV;QAAAK,QAAA,eAKF,IAAA7C,WAAA,CAAAoG,GAAA,EAACtG,YAAA,CAAAkI,kBAAkB;UAAC1F,KAAK,EAAE4C,UAAW;UAAArC,QAAA,EACnCf,MAAM,GAAGwE,UAAU,GAAGH;QAAU,CACf;MAAC,CACjB;IAAC,CACS;EAAC,CACR,CAAC;AAElB;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DIALOG_NAV_BAR_HEIGHT = exports.DIALOG_HEADER_OVERLAY_HEIGHT = exports.DIALOG_HEADER_CONTENT_TOP = void 0;
|
|
7
|
+
exports.DialogHeaderProvider = DialogHeaderProvider;
|
|
8
|
+
exports.DialogNavHeader = exports.DialogLargeTitle = void 0;
|
|
9
|
+
exports.useDialogHeader = useDialogHeader;
|
|
10
|
+
exports.useDialogHeaderController = useDialogHeaderController;
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _reactNative = require("react-native");
|
|
13
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
14
|
+
var _index = require("../icons/index.js");
|
|
15
|
+
var _frostedIconButton = require("../frosted-icon-button");
|
|
16
|
+
var _useTheme = require("../theme/use-theme.js");
|
|
17
|
+
var _index2 = require("../typography/index.js");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Dialog-owned navigation header (iOS large-title collapse).
|
|
22
|
+
//
|
|
23
|
+
// This is a DISTINCT surface mode from the declarative
|
|
24
|
+
// `title`/`description`/`actions` centered-heading path: it turns the Dialog
|
|
25
|
+
// into a scrolling page with a sticky, gradient top bar (left + right slots)
|
|
26
|
+
// and a large collapsing title that lives in the Dialog's OWN scroll content.
|
|
27
|
+
// As the large title scrolls under the bar, a small title cross-fades into the
|
|
28
|
+
// bar center.
|
|
29
|
+
//
|
|
30
|
+
// Screens render NO header of their own — they declare their title/subtitle
|
|
31
|
+
// (via the surface registry) or contribute runtime slots (a Save action, a
|
|
32
|
+
// dynamic title) through {@link useDialogHeader}.
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
/** Interactive nav-bar row height (px). Buttons + collapsed title live here. */
|
|
36
|
+
const DIALOG_NAV_BAR_HEIGHT = exports.DIALOG_NAV_BAR_HEIGHT = 52;
|
|
37
|
+
|
|
38
|
+
/** Extra gradient tail (px) below the bar, over which scrolled content fades. */
|
|
39
|
+
const GRADIENT_FADE = 20;
|
|
40
|
+
|
|
41
|
+
/** Total gradient overlay height (bar + fade tail). */
|
|
42
|
+
const DIALOG_HEADER_OVERLAY_HEIGHT = exports.DIALOG_HEADER_OVERLAY_HEIGHT = DIALOG_NAV_BAR_HEIGHT + GRADIENT_FADE;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Top inset applied to the Dialog's scroll content so the large title starts
|
|
46
|
+
* BELOW the whole gradient overlay (fully clear at rest, then scrolls under it).
|
|
47
|
+
*/
|
|
48
|
+
const DIALOG_HEADER_CONTENT_TOP = exports.DIALOG_HEADER_CONTENT_TOP = DIALOG_HEADER_OVERLAY_HEIGHT;
|
|
49
|
+
|
|
50
|
+
/** Horizontal gutter — matches the `screen-margin` (20px) SDK screens use. */
|
|
51
|
+
const HEADER_H_PADDING = 20;
|
|
52
|
+
|
|
53
|
+
/** Circular icon-button diameter for the default back / close affordances. */
|
|
54
|
+
const NAV_BUTTON_SIZE = 36;
|
|
55
|
+
|
|
56
|
+
// --- Runtime override store (child screen → nav bar / large title) ----------
|
|
57
|
+
//
|
|
58
|
+
// The nav bar overlay and the in-content large title live in DIFFERENT subtrees
|
|
59
|
+
// (the bar is a sibling ABOVE the scroller; the large title + the screen are
|
|
60
|
+
// inside it), so a plain React ancestor context cannot bridge a screen's runtime
|
|
61
|
+
// contribution up to the bar. We use a tiny external store instead: the screen
|
|
62
|
+
// writes its override through {@link useDialogHeader}; the bar and large title
|
|
63
|
+
// read it via `useSyncExternalStore`. Only those two re-render — never the
|
|
64
|
+
// screen subtree — and there is no shared-ancestor constraint.
|
|
65
|
+
|
|
66
|
+
function configsEqual(a, b) {
|
|
67
|
+
if (a === b) return true;
|
|
68
|
+
if (!a || !b) return false;
|
|
69
|
+
return a.title === b.title && a.titleContent === b.titleContent && a.subtitle === b.subtitle && a.largeTitle === b.largeTitle && a.left === b.left && a.right === b.right && a.onBack === b.onBack && a.showClose === b.showClose;
|
|
70
|
+
}
|
|
71
|
+
function createHeaderStore() {
|
|
72
|
+
let override = null;
|
|
73
|
+
const listeners = new Set();
|
|
74
|
+
return {
|
|
75
|
+
getSnapshot: () => override,
|
|
76
|
+
setOverride: next => {
|
|
77
|
+
if (configsEqual(override, next)) return;
|
|
78
|
+
override = next;
|
|
79
|
+
for (const l of listeners) l();
|
|
80
|
+
},
|
|
81
|
+
subscribe: listener => {
|
|
82
|
+
listeners.add(listener);
|
|
83
|
+
return () => listeners.delete(listener);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The per-surface header controller — the scroll offset + measured large-title
|
|
90
|
+
* height shared values plus the runtime-override store. Created once per Dialog
|
|
91
|
+
* (via {@link useDialogHeaderController}) and threaded into the scroller (writes
|
|
92
|
+
* `scrollY`), the nav bar, the large title, and the child provider.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/** Create the header controller for one Dialog. Stable for the Dialog's life. */
|
|
96
|
+
function useDialogHeaderController() {
|
|
97
|
+
const scrollY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
98
|
+
const largeTitleHeight = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
99
|
+
const store = (0, _react.useMemo)(() => createHeaderStore(), []);
|
|
100
|
+
return (0, _react.useMemo)(() => ({
|
|
101
|
+
scrollY,
|
|
102
|
+
largeTitleHeight,
|
|
103
|
+
store
|
|
104
|
+
}), [scrollY, largeTitleHeight, store]);
|
|
105
|
+
}
|
|
106
|
+
const DialogHeaderContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Wraps the Dialog's scroll content so a mounted screen can contribute header
|
|
110
|
+
* slots via {@link useDialogHeader}. Only the child subtree needs this — the nav
|
|
111
|
+
* bar and large title read the same controller directly.
|
|
112
|
+
*/
|
|
113
|
+
function DialogHeaderProvider({
|
|
114
|
+
controller,
|
|
115
|
+
children
|
|
116
|
+
}) {
|
|
117
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DialogHeaderContext.Provider, {
|
|
118
|
+
value: controller,
|
|
119
|
+
children: children
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Contribute header content from within a Dialog surface — a dynamic title, a
|
|
125
|
+
* Save action, custom slots. Merges over the surface's static (registry) header
|
|
126
|
+
* config; unmounting clears the contribution. Slot nodes (`left`/`right`) MUST
|
|
127
|
+
* be referentially stable (memoize them) so the effect does not thrash.
|
|
128
|
+
*
|
|
129
|
+
* No-op outside a header-mode Dialog (e.g. a confirm dialog), so a screen can
|
|
130
|
+
* call it unconditionally.
|
|
131
|
+
*/
|
|
132
|
+
function useDialogHeader(config) {
|
|
133
|
+
const controller = (0, _react.useContext)(DialogHeaderContext);
|
|
134
|
+
const store = controller?.store;
|
|
135
|
+
// Set synchronously in the commit's layout phase so the bar/title fill in
|
|
136
|
+
// BEFORE the browser paints — no first-frame flash of an empty bar.
|
|
137
|
+
(0, _react.useLayoutEffect)(() => {
|
|
138
|
+
if (!store) return;
|
|
139
|
+
store.setOverride(config ?? null);
|
|
140
|
+
return () => store.setOverride(null);
|
|
141
|
+
// Slot nodes are compared by identity; callers memoize them.
|
|
142
|
+
}, [store, config?.title, config?.titleContent, config?.subtitle, config?.largeTitle, config?.left, config?.right, config?.onBack, config?.showClose]);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Read the merged (base + runtime-override) header config, reactively. */
|
|
146
|
+
function useMergedHeaderConfig(base, store) {
|
|
147
|
+
const override = (0, _react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
148
|
+
return (0, _react.useMemo)(() => override ? {
|
|
149
|
+
...base,
|
|
150
|
+
...override
|
|
151
|
+
} : base, [base, override]);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// --- Nav bar overlay --------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The sticky nav bar: gradient background + left / center (collapsing title) /
|
|
158
|
+
* right slots. Absolutely positioned at the top of the Dialog surface, painted
|
|
159
|
+
* ABOVE the scroll content. Reads the scroll offset to cross-fade the small
|
|
160
|
+
* title in as the large title scrolls under it.
|
|
161
|
+
*
|
|
162
|
+
* `onDismiss` is the Dialog's own close (the default right-slot close button
|
|
163
|
+
* calls it) — passed explicitly rather than read from the dialog context because
|
|
164
|
+
* the bar is rendered as a sibling of the scroller, outside that context on the
|
|
165
|
+
* bottom-sheet path.
|
|
166
|
+
*/
|
|
167
|
+
const DialogNavHeader = exports.DialogNavHeader = /*#__PURE__*/(0, _react.memo)(function DialogNavHeader({
|
|
168
|
+
controller,
|
|
169
|
+
header,
|
|
170
|
+
onDismiss,
|
|
171
|
+
collapse = true,
|
|
172
|
+
style
|
|
173
|
+
}) {
|
|
174
|
+
const theme = (0, _useTheme.useTheme)();
|
|
175
|
+
const config = useMergedHeaderConfig(header, controller.store);
|
|
176
|
+
const {
|
|
177
|
+
scrollY,
|
|
178
|
+
largeTitleHeight
|
|
179
|
+
} = controller;
|
|
180
|
+
|
|
181
|
+
// A branded `titleContent` owns the bar centre outright: it is always visible,
|
|
182
|
+
// so there is nothing to collapse and no large in-content title to collapse under.
|
|
183
|
+
const hasLargeTitle = collapse && !config.titleContent && (config.largeTitle ?? true) && !!config.title;
|
|
184
|
+
const titleStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
185
|
+
// When there is no large title to collapse under, the bar title is always
|
|
186
|
+
// shown (a plain, non-collapsing nav bar). Otherwise it cross-fades in as the
|
|
187
|
+
// large title scrolls up under the bar.
|
|
188
|
+
if (!hasLargeTitle) return {
|
|
189
|
+
opacity: 1,
|
|
190
|
+
transform: [{
|
|
191
|
+
translateY: 0
|
|
192
|
+
}]
|
|
193
|
+
};
|
|
194
|
+
const threshold = largeTitleHeight.value > 0 ? largeTitleHeight.value : 44;
|
|
195
|
+
const start = threshold * 0.35;
|
|
196
|
+
const end = threshold * 0.9;
|
|
197
|
+
return {
|
|
198
|
+
opacity: (0, _reactNativeReanimated.interpolate)(scrollY.value, [start, end], [0, 1], _reactNativeReanimated.Extrapolation.CLAMP),
|
|
199
|
+
transform: [{
|
|
200
|
+
translateY: (0, _reactNativeReanimated.interpolate)(scrollY.value, [start, end], [10, 0], _reactNativeReanimated.Extrapolation.CLAMP)
|
|
201
|
+
}]
|
|
202
|
+
};
|
|
203
|
+
// Reanimated on RN-Web has no worklets plugin: every shared value the mapper
|
|
204
|
+
// reads MUST be in the deps array or it freezes on the first frame.
|
|
205
|
+
}, [scrollY, largeTitleHeight, hasLargeTitle]);
|
|
206
|
+
const left = config.left ?? (config.onBack ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_frostedIconButton.FrostedIconButton, {
|
|
207
|
+
onPress: config.onBack,
|
|
208
|
+
accessibilityLabel: "Go back",
|
|
209
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ChevronLeft_Stroke2_Corner0_Rounded, {
|
|
210
|
+
size: "md"
|
|
211
|
+
})
|
|
212
|
+
}) : null);
|
|
213
|
+
const right = config.right ?? (config.showClose !== false ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_frostedIconButton.FrostedIconButton, {
|
|
214
|
+
onPress: onDismiss,
|
|
215
|
+
accessibilityLabel: "Close",
|
|
216
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TimesLarge_Stroke2_Corner0_Rounded, {
|
|
217
|
+
size: "md"
|
|
218
|
+
})
|
|
219
|
+
}) : null);
|
|
220
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
221
|
+
pointerEvents: "box-none",
|
|
222
|
+
style: [styles.overlay, style],
|
|
223
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
224
|
+
pointerEvents: "none",
|
|
225
|
+
className: "bg-gradient-to-b from-bg to-transparent",
|
|
226
|
+
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
227
|
+
height: DIALOG_HEADER_OVERLAY_HEIGHT
|
|
228
|
+
}]
|
|
229
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
230
|
+
pointerEvents: "box-none",
|
|
231
|
+
style: styles.navRow,
|
|
232
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
233
|
+
style: styles.side,
|
|
234
|
+
children: left
|
|
235
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
|
|
236
|
+
pointerEvents: "none",
|
|
237
|
+
testID: "dialog-nav-title",
|
|
238
|
+
style: [styles.centerTitle, titleStyle],
|
|
239
|
+
children: [config.titleContent ?? null, !config.titleContent && config.title ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Text, {
|
|
240
|
+
numberOfLines: 1,
|
|
241
|
+
style: [styles.smallTitle, {
|
|
242
|
+
color: theme.colors.text
|
|
243
|
+
}],
|
|
244
|
+
children: config.title
|
|
245
|
+
}) : null, !hasLargeTitle && !config.titleContent && config.subtitle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Text, {
|
|
246
|
+
numberOfLines: 1,
|
|
247
|
+
style: [styles.smallSubtitle, {
|
|
248
|
+
color: theme.colors.textSecondary
|
|
249
|
+
}],
|
|
250
|
+
children: config.subtitle
|
|
251
|
+
}) : null]
|
|
252
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
253
|
+
style: [styles.side, styles.sideRight],
|
|
254
|
+
children: right
|
|
255
|
+
})]
|
|
256
|
+
})]
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// --- In-content large title -------------------------------------------------
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The large collapsing title, rendered at the TOP of the Dialog's scroll content
|
|
264
|
+
* (before the screen body). Owns the content top inset (so the title starts
|
|
265
|
+
* below the gradient overlay) and measures its own text height into the
|
|
266
|
+
* controller so the nav bar knows when to cross-fade the small title in.
|
|
267
|
+
*/
|
|
268
|
+
const DialogLargeTitle = exports.DialogLargeTitle = /*#__PURE__*/(0, _react.memo)(function DialogLargeTitle({
|
|
269
|
+
controller,
|
|
270
|
+
header
|
|
271
|
+
}) {
|
|
272
|
+
const theme = (0, _useTheme.useTheme)();
|
|
273
|
+
const config = useMergedHeaderConfig(header, controller.store);
|
|
274
|
+
const {
|
|
275
|
+
largeTitleHeight
|
|
276
|
+
} = controller;
|
|
277
|
+
|
|
278
|
+
// A branded `titleContent` lives in the bar and never collapses, so the
|
|
279
|
+
// surface starts flush under the bar with no large title above it.
|
|
280
|
+
const hasLargeTitle = !config.titleContent && (config.largeTitle ?? true) && !!config.title;
|
|
281
|
+
const onLayout = e => {
|
|
282
|
+
largeTitleHeight.value = e.nativeEvent.layout.height;
|
|
283
|
+
};
|
|
284
|
+
if (!hasLargeTitle) {
|
|
285
|
+
// No large title: just inset the content below the nav bar.
|
|
286
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
287
|
+
style: {
|
|
288
|
+
height: DIALOG_NAV_BAR_HEIGHT
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
293
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
294
|
+
style: {
|
|
295
|
+
height: DIALOG_HEADER_CONTENT_TOP
|
|
296
|
+
}
|
|
297
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
298
|
+
onLayout: onLayout,
|
|
299
|
+
testID: "dialog-large-title",
|
|
300
|
+
style: styles.largeTitleBlock,
|
|
301
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.H1, {
|
|
302
|
+
style: [styles.largeTitle, {
|
|
303
|
+
color: theme.colors.text
|
|
304
|
+
}],
|
|
305
|
+
children: config.title
|
|
306
|
+
}), config.subtitle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Text, {
|
|
307
|
+
style: [styles.largeSubtitle, {
|
|
308
|
+
color: theme.colors.textSecondary
|
|
309
|
+
}],
|
|
310
|
+
children: config.subtitle
|
|
311
|
+
}) : null]
|
|
312
|
+
})]
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
const styles = _reactNative.StyleSheet.create({
|
|
316
|
+
overlay: {
|
|
317
|
+
position: 'absolute',
|
|
318
|
+
top: 0,
|
|
319
|
+
left: 0,
|
|
320
|
+
right: 0,
|
|
321
|
+
height: DIALOG_HEADER_OVERLAY_HEIGHT,
|
|
322
|
+
zIndex: 10
|
|
323
|
+
},
|
|
324
|
+
navRow: {
|
|
325
|
+
height: DIALOG_NAV_BAR_HEIGHT,
|
|
326
|
+
flexDirection: 'row',
|
|
327
|
+
alignItems: 'center',
|
|
328
|
+
paddingHorizontal: HEADER_H_PADDING - 4
|
|
329
|
+
},
|
|
330
|
+
side: {
|
|
331
|
+
minWidth: NAV_BUTTON_SIZE,
|
|
332
|
+
flexDirection: 'row',
|
|
333
|
+
alignItems: 'center'
|
|
334
|
+
},
|
|
335
|
+
sideRight: {
|
|
336
|
+
justifyContent: 'flex-end'
|
|
337
|
+
},
|
|
338
|
+
centerTitle: {
|
|
339
|
+
flex: 1,
|
|
340
|
+
alignItems: 'center',
|
|
341
|
+
justifyContent: 'center',
|
|
342
|
+
paddingHorizontal: 8
|
|
343
|
+
},
|
|
344
|
+
smallTitle: {
|
|
345
|
+
fontSize: 16,
|
|
346
|
+
fontWeight: '600',
|
|
347
|
+
letterSpacing: -0.2,
|
|
348
|
+
lineHeight: 20
|
|
349
|
+
},
|
|
350
|
+
smallSubtitle: {
|
|
351
|
+
fontSize: 12,
|
|
352
|
+
fontWeight: '400',
|
|
353
|
+
lineHeight: 14
|
|
354
|
+
},
|
|
355
|
+
largeTitleBlock: {
|
|
356
|
+
paddingHorizontal: HEADER_H_PADDING,
|
|
357
|
+
paddingBottom: 4
|
|
358
|
+
},
|
|
359
|
+
largeTitle: {
|
|
360
|
+
fontSize: 32,
|
|
361
|
+
lineHeight: 38,
|
|
362
|
+
letterSpacing: -0.5,
|
|
363
|
+
fontWeight: '700'
|
|
364
|
+
},
|
|
365
|
+
largeSubtitle: {
|
|
366
|
+
fontSize: 16,
|
|
367
|
+
lineHeight: 22,
|
|
368
|
+
marginTop: 4
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
//# sourceMappingURL=DialogHeader.js.map
|