@oxy.so/bloom 7.20.0 → 7.21.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/docs/adoption-matrix.mdx +6 -6
- package/docs/bottom-sheet.mdx +15 -0
- package/docs/dialog.mdx +49 -0
- package/docs/overlay.mdx +18 -0
- package/lib/commonjs/bottom-sheet/BottomSheetBase.js +27 -10
- package/lib/commonjs/bottom-sheet/BottomSheetBase.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.js +16 -5
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +32 -15
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/DialogBottomSheet.js +4 -0
- package/lib/commonjs/dialog/DialogBottomSheet.js.map +1 -1
- package/lib/commonjs/motion/surface-transition.js +18 -0
- package/lib/commonjs/motion/surface-transition.js.map +1 -0
- package/lib/commonjs/motion/use-surface-transition.js +24 -0
- package/lib/commonjs/motion/use-surface-transition.js.map +1 -0
- package/lib/commonjs/overlay/Overlay.js +11 -11
- package/lib/commonjs/overlay/Overlay.js.map +1 -1
- package/lib/commonjs/overlay/backdrop-paint.js +34 -0
- package/lib/commonjs/overlay/backdrop-paint.js.map +1 -0
- package/lib/module/bottom-sheet/BottomSheetBase.js +27 -10
- package/lib/module/bottom-sheet/BottomSheetBase.js.map +1 -1
- package/lib/module/dialog/Dialog.js +16 -5
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +32 -15
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/DialogBottomSheet.js +4 -0
- package/lib/module/dialog/DialogBottomSheet.js.map +1 -1
- package/lib/module/motion/surface-transition.js +14 -0
- package/lib/module/motion/surface-transition.js.map +1 -0
- package/lib/module/motion/use-surface-transition.js +20 -0
- package/lib/module/motion/use-surface-transition.js.map +1 -0
- package/lib/module/overlay/Overlay.js +11 -11
- package/lib/module/overlay/Overlay.js.map +1 -1
- package/lib/module/overlay/backdrop-paint.js +29 -0
- package/lib/module/overlay/backdrop-paint.js.map +1 -0
- package/lib/typescript/commonjs/bottom-sheet/BottomSheetBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/bottom-sheet/types.d.ts +6 -0
- package/lib/typescript/commonjs/bottom-sheet/types.d.ts.map +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/types.d.ts +6 -0
- package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/motion/index.d.ts +1 -1
- package/lib/typescript/commonjs/motion/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/motion/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/motion/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/motion/surface-transition.d.ts +8 -0
- package/lib/typescript/commonjs/motion/surface-transition.d.ts.map +1 -0
- package/lib/typescript/commonjs/motion/types.d.ts +7 -0
- package/lib/typescript/commonjs/motion/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/motion/use-surface-transition.d.ts +9 -0
- package/lib/typescript/commonjs/motion/use-surface-transition.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/Overlay.d.ts.map +1 -1
- package/lib/typescript/commonjs/overlay/backdrop-paint.d.ts +7 -0
- package/lib/typescript/commonjs/overlay/backdrop-paint.d.ts.map +1 -0
- package/lib/typescript/commonjs/overlay/index.d.ts +1 -1
- package/lib/typescript/commonjs/overlay/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/overlay/types.d.ts +23 -9
- package/lib/typescript/commonjs/overlay/types.d.ts.map +1 -1
- package/lib/typescript/module/bottom-sheet/BottomSheetBase.d.ts.map +1 -1
- package/lib/typescript/module/bottom-sheet/types.d.ts +6 -0
- package/lib/typescript/module/bottom-sheet/types.d.ts.map +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/types.d.ts +6 -0
- package/lib/typescript/module/dialog/types.d.ts.map +1 -1
- package/lib/typescript/module/motion/index.d.ts +1 -1
- package/lib/typescript/module/motion/index.d.ts.map +1 -1
- package/lib/typescript/module/motion/index.web.d.ts +1 -1
- package/lib/typescript/module/motion/index.web.d.ts.map +1 -1
- package/lib/typescript/module/motion/surface-transition.d.ts +8 -0
- package/lib/typescript/module/motion/surface-transition.d.ts.map +1 -0
- package/lib/typescript/module/motion/types.d.ts +7 -0
- package/lib/typescript/module/motion/types.d.ts.map +1 -1
- package/lib/typescript/module/motion/use-surface-transition.d.ts +9 -0
- package/lib/typescript/module/motion/use-surface-transition.d.ts.map +1 -0
- package/lib/typescript/module/overlay/Overlay.d.ts.map +1 -1
- package/lib/typescript/module/overlay/backdrop-paint.d.ts +7 -0
- package/lib/typescript/module/overlay/backdrop-paint.d.ts.map +1 -0
- package/lib/typescript/module/overlay/index.d.ts +1 -1
- package/lib/typescript/module/overlay/index.d.ts.map +1 -1
- package/lib/typescript/module/overlay/types.d.ts +23 -9
- package/lib/typescript/module/overlay/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bottom-sheet/BottomSheetBase.tsx +18 -8
- package/src/bottom-sheet/types.ts +6 -0
- package/src/dialog/Dialog.tsx +17 -4
- package/src/dialog/Dialog.web.tsx +33 -12
- package/src/dialog/DialogBottomSheet.tsx +6 -0
- package/src/dialog/types.ts +6 -0
- package/src/motion/index.ts +1 -1
- package/src/motion/index.web.ts +1 -1
- package/src/motion/surface-transition.ts +15 -0
- package/src/motion/types.ts +8 -0
- package/src/motion/use-surface-transition.ts +14 -0
- package/src/overlay/Overlay.tsx +12 -8
- package/src/overlay/backdrop-paint.ts +25 -0
- package/src/overlay/index.ts +1 -1
- package/src/overlay/types.ts +22 -9
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useSurfaceTransition } from '../motion/use-surface-transition';
|
|
1
2
|
import { MOTION_RECIPES } from '../motion/recipes';
|
|
2
3
|
import { surfaceStyle } from '../shapes/surface-style';
|
|
3
4
|
import { SURFACE_SHAPES } from '../design-tokens/shapes';
|
|
@@ -176,6 +177,8 @@ export function Dialog({ placement, ...rest }: DialogProps) {
|
|
|
176
177
|
*/
|
|
177
178
|
function CenterOrSideDialog({
|
|
178
179
|
material: surfaceMaterial = 'surface',
|
|
180
|
+
backdrop,
|
|
181
|
+
transition,
|
|
179
182
|
control,
|
|
180
183
|
open: controlledOpen,
|
|
181
184
|
startOpen,
|
|
@@ -213,6 +216,7 @@ function CenterOrSideDialog({
|
|
|
213
216
|
const dialogMessages = useMessages(DIALOG_MESSAGES).messages;
|
|
214
217
|
// Controlled mode is opt-in: when `open` is a boolean the host owns the
|
|
215
218
|
// visible state; otherwise the legacy imperative `control` path drives it.
|
|
219
|
+
const motion = useSurfaceTransition(transition);
|
|
216
220
|
const isControlled = controlledOpen !== undefined;
|
|
217
221
|
const resolvedPlacement = placement;
|
|
218
222
|
|
|
@@ -271,7 +275,7 @@ function CenterOrSideDialog({
|
|
|
271
275
|
}, [isControlled, controlledOpen]);
|
|
272
276
|
|
|
273
277
|
const exitDuration =
|
|
274
|
-
presentation === 'custom' ? customExitDuration ?? 0 : resolvedPlacement === 'center' ? FADE_OUT_DURATION : ANIMATION_DURATION;
|
|
278
|
+
presentation === 'custom' ? customExitDuration ?? 0 : motion.duration ?? (resolvedPlacement === 'center' ? FADE_OUT_DURATION : ANIMATION_DURATION);
|
|
275
279
|
|
|
276
280
|
useEffect(() => {
|
|
277
281
|
if (!isClosing) return;
|
|
@@ -316,9 +320,9 @@ function CenterOrSideDialog({
|
|
|
316
320
|
return;
|
|
317
321
|
}
|
|
318
322
|
backdropFade.value = isClosing
|
|
319
|
-
? withTiming(0, { ...MOTION_RECIPES.dismiss, duration: FADE_OUT_DURATION, easing: Easing.in(Easing.ease) })
|
|
320
|
-
: withTiming(1, { ...MOTION_RECIPES.present, duration: BACKDROP_FADE_IN_DURATION, easing: Easing.out(Easing.ease) });
|
|
321
|
-
}, [backdropFade, isOpen, isClosing]);
|
|
323
|
+
? withTiming(0, { ...MOTION_RECIPES.dismiss, duration: motion.duration ?? FADE_OUT_DURATION, easing: transition ? motion.easing : Easing.in(Easing.ease) })
|
|
324
|
+
: withTiming(1, { ...MOTION_RECIPES.present, duration: motion.duration ?? BACKDROP_FADE_IN_DURATION, easing: transition ? motion.easing : Easing.out(Easing.ease) });
|
|
325
|
+
}, [backdropFade, isOpen, isClosing, motion.duration, motion.easing, !!transition]);
|
|
322
326
|
|
|
323
327
|
useImperativeHandle(
|
|
324
328
|
control?.ref,
|
|
@@ -366,8 +370,9 @@ function CenterOrSideDialog({
|
|
|
366
370
|
// opacity animation on the blur's ancestor composites the group in
|
|
367
371
|
// isolation and leaves `backdrop-filter` nothing to sample.
|
|
368
372
|
progress={backdropFade}
|
|
369
|
-
|
|
370
|
-
|
|
373
|
+
{...backdrop}
|
|
374
|
+
dimOpacity={presentation === 'custom' ? 0 : backdrop?.dimOpacity}
|
|
375
|
+
blurIntensity={presentation === 'custom' ? 0 : backdrop?.blurIntensity}
|
|
371
376
|
style={[{
|
|
372
377
|
position: WEB_POSITION_FIXED,
|
|
373
378
|
alignItems: 'center',
|
|
@@ -376,6 +381,7 @@ function CenterOrSideDialog({
|
|
|
376
381
|
}, containerStyle]}
|
|
377
382
|
>
|
|
378
383
|
<DialogPanel
|
|
384
|
+
transition={transition}
|
|
379
385
|
material={surfaceMaterial}
|
|
380
386
|
presentation={presentation}
|
|
381
387
|
panelRef={panelRef}
|
|
@@ -409,6 +415,8 @@ function CenterOrSideDialog({
|
|
|
409
415
|
<ClosingContext.Provider value={isClosing}>
|
|
410
416
|
<RemoveScrollBar />
|
|
411
417
|
<SheetSurface
|
|
418
|
+
backdrop={backdrop}
|
|
419
|
+
transition={transition}
|
|
412
420
|
material={surfaceMaterial}
|
|
413
421
|
panelRef={panelRef}
|
|
414
422
|
testID={testID}
|
|
@@ -442,6 +450,7 @@ function CenterOrSideDialog({
|
|
|
442
450
|
|
|
443
451
|
function DialogPanel({
|
|
444
452
|
material: surfaceMaterial = 'surface',
|
|
453
|
+
transition,
|
|
445
454
|
presentation,
|
|
446
455
|
panelRef,
|
|
447
456
|
testID,
|
|
@@ -460,6 +469,7 @@ function DialogPanel({
|
|
|
460
469
|
children,
|
|
461
470
|
}: {
|
|
462
471
|
material?: DialogProps['material'];
|
|
472
|
+
transition?: DialogProps['transition'];
|
|
463
473
|
presentation?: DialogProps['presentation'];
|
|
464
474
|
panelRef: React.RefObject<View | null>;
|
|
465
475
|
testID?: string;
|
|
@@ -477,6 +487,10 @@ function DialogPanel({
|
|
|
477
487
|
isClosing: boolean;
|
|
478
488
|
children?: React.ReactNode;
|
|
479
489
|
}) {
|
|
490
|
+
const motion = useSurfaceTransition(transition);
|
|
491
|
+
const panelMotion: WebCssStyle | undefined = motion.duration === undefined ? undefined : {
|
|
492
|
+
animation: `${isClosing ? 'bloomDialogZoomFadeOut' : 'bloomDialogZoomFadeIn'} ${motion.cssEasing} ${motion.duration}ms${isClosing ? ' forwards' : ''}`,
|
|
493
|
+
};
|
|
480
494
|
const theme = useTheme();
|
|
481
495
|
const { close } = useDialogContext();
|
|
482
496
|
const titleId = useId();
|
|
@@ -560,6 +574,7 @@ function DialogPanel({
|
|
|
560
574
|
zIndex: Z_INDEX.raised,
|
|
561
575
|
},
|
|
562
576
|
presentation === 'custom' ? undefined : isClosing ? ZOOM_FADE_OUT : ZOOM_FADE_IN,
|
|
577
|
+
presentation === 'custom' ? undefined : panelMotion,
|
|
563
578
|
// Drives `height` (and `maxWidth`) only while a morph is in flight; at
|
|
564
579
|
// rest it resolves to `height: 'auto'` — the natural sizing above. Placed
|
|
565
580
|
// before `style` so a consumer's explicit size still wins.
|
|
@@ -643,6 +658,8 @@ function DialogPanel({
|
|
|
643
658
|
*/
|
|
644
659
|
function SheetSurface({
|
|
645
660
|
material: surfaceMaterial = 'surface',
|
|
661
|
+
backdrop,
|
|
662
|
+
transition,
|
|
646
663
|
panelRef,
|
|
647
664
|
testID,
|
|
648
665
|
label,
|
|
@@ -667,6 +684,8 @@ function SheetSurface({
|
|
|
667
684
|
children,
|
|
668
685
|
}: {
|
|
669
686
|
material?: DialogProps['material'];
|
|
687
|
+
backdrop?: DialogProps['backdrop'];
|
|
688
|
+
transition?: DialogProps['transition'];
|
|
670
689
|
panelRef: React.RefObject<View | null>;
|
|
671
690
|
testID?: string;
|
|
672
691
|
label?: string;
|
|
@@ -690,6 +709,7 @@ function SheetSurface({
|
|
|
690
709
|
style?: StyleProp<ViewStyle>;
|
|
691
710
|
children?: React.ReactNode;
|
|
692
711
|
}) {
|
|
712
|
+
const motion = useSurfaceTransition(transition);
|
|
693
713
|
const dialogMessages = useMessages(DIALOG_MESSAGES).messages;
|
|
694
714
|
const theme = useTheme();
|
|
695
715
|
const titleId = useId();
|
|
@@ -718,19 +738,19 @@ function SheetSurface({
|
|
|
718
738
|
const panelTransition = useMemo<WebCssStyle>(
|
|
719
739
|
() => ({
|
|
720
740
|
transitionProperty: 'transform, opacity',
|
|
721
|
-
transitionDuration: `${ANIMATION_DURATION}ms`,
|
|
722
|
-
transitionTimingFunction: EASE_OUT,
|
|
741
|
+
transitionDuration: `${motion.duration ?? ANIMATION_DURATION}ms`,
|
|
742
|
+
transitionTimingFunction: transition ? motion.cssEasing : EASE_OUT,
|
|
723
743
|
}),
|
|
724
|
-
[],
|
|
744
|
+
[motion.duration, motion.cssEasing, !!transition],
|
|
725
745
|
);
|
|
726
746
|
|
|
727
747
|
const backdropTransition = useMemo<WebCssStyle>(
|
|
728
748
|
() => ({
|
|
729
749
|
transitionProperty: 'opacity',
|
|
730
|
-
transitionDuration: `${ANIMATION_DURATION}ms`,
|
|
731
|
-
transitionTimingFunction: EASE_OUT,
|
|
750
|
+
transitionDuration: `${motion.duration ?? ANIMATION_DURATION}ms`,
|
|
751
|
+
transitionTimingFunction: transition ? motion.cssEasing : EASE_OUT,
|
|
732
752
|
}),
|
|
733
|
-
[],
|
|
753
|
+
[motion.duration, motion.cssEasing, !!transition],
|
|
734
754
|
);
|
|
735
755
|
|
|
736
756
|
const panelGeometry = useMemo<ViewStyle>(() => {
|
|
@@ -776,6 +796,7 @@ function SheetSurface({
|
|
|
776
796
|
<OverlayRoot style={[sheetStyles.root, containerStyle]} className={containerClassName} modal>
|
|
777
797
|
<ModalKeyboard panelRef={panelRef} closing={!shown} dismissible={dismissOnBackdrop} dismiss={onDismiss} />
|
|
778
798
|
<Backdrop
|
|
799
|
+
{...backdrop}
|
|
779
800
|
testID={testID ? `${testID}-backdrop` : DIALOG_SHEET_BACKDROP_TESTID}
|
|
780
801
|
accessibilityLabel={label ? dialogMessages.dismissNamed(label) : dialogMessages.dismissDialog}
|
|
781
802
|
onPress={handleBackdropPress}
|
|
@@ -59,6 +59,8 @@ import type { DialogControlProps, DialogProps } from './types';
|
|
|
59
59
|
* - `title` / `description` / `actions` / `children` → declarative body
|
|
60
60
|
*/
|
|
61
61
|
export function DialogBottomSheet({
|
|
62
|
+
backdrop,
|
|
63
|
+
transition,
|
|
62
64
|
control,
|
|
63
65
|
open: controlledOpen,
|
|
64
66
|
startOpen,
|
|
@@ -255,6 +257,8 @@ export function DialogBottomSheet({
|
|
|
255
257
|
|
|
256
258
|
return (
|
|
257
259
|
<BottomSheet
|
|
260
|
+
backdrop={backdrop}
|
|
261
|
+
transition={transition}
|
|
258
262
|
material={surfaceMaterial}
|
|
259
263
|
accessibilityLabel={label ?? header?.title}
|
|
260
264
|
aria-labelledby={!header && title ? titleId : undefined}
|
|
@@ -386,6 +390,8 @@ const FILL_BOUNDED = { flex: 1, minHeight: 0 } as const;
|
|
|
386
390
|
*/
|
|
387
391
|
export type DialogBottomSheetProps = Pick<
|
|
388
392
|
DialogProps,
|
|
393
|
+
| 'backdrop'
|
|
394
|
+
| 'transition'
|
|
389
395
|
| 'control'
|
|
390
396
|
| 'open'
|
|
391
397
|
| 'startOpen'
|
package/src/dialog/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BackdropAppearance } from '../overlay/types';
|
|
2
|
+
import type { SurfaceTransition } from '../motion/types';
|
|
1
3
|
import type { ReactNode } from 'react';
|
|
2
4
|
import type { ButtonIconComponent } from '../button/types';
|
|
3
5
|
import type { GestureResponderEvent, StyleProp, ViewStyle } from 'react-native';
|
|
@@ -233,6 +235,10 @@ export type DialogAction = {
|
|
|
233
235
|
export type DialogProps = React.PropsWithChildren<{
|
|
234
236
|
/** Standard optical surface, or a plain fill without refraction/sheen. Default surface. */
|
|
235
237
|
material?: 'surface' | 'flat';
|
|
238
|
+
/** Backdrop paint; the surface continues to own dismissal and layering. */
|
|
239
|
+
backdrop?: BackdropAppearance;
|
|
240
|
+
/** Opt-in timing for panel and backdrop. Live reduced motion settles immediately. */
|
|
241
|
+
transition?: SurfaceTransition;
|
|
236
242
|
/** Content owns paint and motion; shared overlay, focus and dismissal remain. */
|
|
237
243
|
presentation?: 'default' | 'custom';
|
|
238
244
|
/** Custom presentation exit lifetime, in milliseconds. */
|
package/src/motion/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ScaleAndFadeIn, ScaleAndFadeOut, ShrinkAndPop } from './motion';
|
|
2
2
|
export { ScreenTransition } from './ScreenTransition';
|
|
3
|
-
export type { ScreenTransitionProps, ScreenTransitionDirection } from './types';
|
|
3
|
+
export type { ScreenTransitionProps, ScreenTransitionDirection, SurfaceTransition } from './types';
|
|
4
4
|
export { MOTION_RECIPES, animateMotion } from './recipes';
|
|
5
5
|
export type { MotionIntent } from './recipes';
|
package/src/motion/index.web.ts
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
export { ScaleAndFadeIn, ScaleAndFadeOut, ShrinkAndPop } from './motion.web';
|
|
7
7
|
export { ScreenTransition } from './ScreenTransition';
|
|
8
|
-
export type { ScreenTransitionProps, ScreenTransitionDirection } from './types';
|
|
8
|
+
export type { ScreenTransitionProps, ScreenTransitionDirection, SurfaceTransition } from './types';
|
|
9
9
|
export { MOTION_RECIPES, animateMotion } from './recipes';
|
|
10
10
|
export type { MotionIntent } from './recipes';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SurfaceTransition } from './types';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_EASING = [0.25, 0.1, 0.25, 1] as const;
|
|
4
|
+
/** Keeps identical CSS/Reanimated timing; invalid values preserve safe defaults. */
|
|
5
|
+
export function resolveSurfaceTransition(transition: SurfaceTransition | undefined) {
|
|
6
|
+
const candidate = transition?.easing;
|
|
7
|
+
const easing = candidate?.length === 4 && candidate.every(Number.isFinite)
|
|
8
|
+
&& candidate[0] >= 0 && candidate[0] <= 1 && candidate[2] >= 0 && candidate[2] <= 1
|
|
9
|
+
? candidate : DEFAULT_EASING;
|
|
10
|
+
return {
|
|
11
|
+
duration: Number.isFinite(transition?.duration) ? Math.max(0, transition!.duration) : 300,
|
|
12
|
+
easing,
|
|
13
|
+
cssEasing: `cubic-bezier(${easing.join(', ')})`,
|
|
14
|
+
};
|
|
15
|
+
}
|
package/src/motion/types.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
+
/** Opt-in timing for a surface's panel and backdrop. Defaults remain owner-specific when omitted. */
|
|
5
|
+
export interface SurfaceTransition {
|
|
6
|
+
/** Milliseconds, clamped to zero. Non-finite values fall back to 300. */
|
|
7
|
+
duration: number;
|
|
8
|
+
/** CSS cubic-bezier coordinates. Invalid curves fall back to ease. */
|
|
9
|
+
easing?: readonly [number, number, number, number];
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
/** Direction the incoming screen travels. */
|
|
5
13
|
export type ScreenTransitionDirection = 'forward' | 'backward';
|
|
6
14
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { Easing } from 'react-native-reanimated';
|
|
3
|
+
import { usePrefersReducedMotion } from '../hooks/use-prefers-reduced-motion';
|
|
4
|
+
import { resolveSurfaceTransition } from './surface-transition';
|
|
5
|
+
import type { SurfaceTransition } from './types';
|
|
6
|
+
|
|
7
|
+
/** Stable timing values keep unrelated surface renders from restarting motion. */
|
|
8
|
+
export function useSurfaceTransition(transition: SurfaceTransition | undefined) {
|
|
9
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
10
|
+
const resolved = resolveSurfaceTransition(transition);
|
|
11
|
+
const [x1, y1, x2, y2] = resolved.easing;
|
|
12
|
+
const easing = useMemo(() => Easing.bezier(x1, y1, x2, y2), [x1, y1, x2, y2]);
|
|
13
|
+
return { ...resolved, easing, reducedMotion, duration: reducedMotion ? 0 : transition ? resolved.duration : undefined };
|
|
14
|
+
}
|
package/src/overlay/Overlay.tsx
CHANGED
|
@@ -43,6 +43,8 @@ import { ScreenScope } from '../layout/screen-scope';
|
|
|
43
43
|
import { createContext, memo, useContext, useMemo } from 'react';
|
|
44
44
|
import { BlurView } from 'expo-blur';
|
|
45
45
|
|
|
46
|
+
import { useIsRtl } from '../hooks/use-is-rtl';
|
|
47
|
+
import { backdropDimStyle, clampBackdropNumber } from './backdrop-paint';
|
|
46
48
|
import { useWindowedBlurTarget } from '../glass/blur-target';
|
|
47
49
|
import {
|
|
48
50
|
Platform,
|
|
@@ -247,7 +249,7 @@ interface BackdropLayerProps {
|
|
|
247
249
|
blurTarget?: ReturnType<typeof useWindowedBlurTarget>;
|
|
248
250
|
blurIntensity: number;
|
|
249
251
|
blurTint: 'light' | 'dark' | 'default';
|
|
250
|
-
|
|
252
|
+
dimStyle: ViewStyle;
|
|
251
253
|
dimOpacity: number;
|
|
252
254
|
/** Opacity the caller asked for, already lifted off the press target. */
|
|
253
255
|
staticOpacity: number;
|
|
@@ -264,7 +266,7 @@ function AnimatedBackdropLayers({
|
|
|
264
266
|
progress,
|
|
265
267
|
blurIntensity,
|
|
266
268
|
blurTint,
|
|
267
|
-
|
|
269
|
+
dimStyle,
|
|
268
270
|
dimOpacity,
|
|
269
271
|
staticOpacity,
|
|
270
272
|
layerStyle,
|
|
@@ -299,7 +301,7 @@ function AnimatedBackdropLayers({
|
|
|
299
301
|
) : null}
|
|
300
302
|
<Animated.View
|
|
301
303
|
pointerEvents="none"
|
|
302
|
-
style={[StyleSheet.absoluteFill,
|
|
304
|
+
style={[StyleSheet.absoluteFill, dimStyle, layerStyle, dimFade]}
|
|
303
305
|
/>
|
|
304
306
|
</>
|
|
305
307
|
);
|
|
@@ -325,7 +327,7 @@ function StaticBackdropLayers({
|
|
|
325
327
|
blurTarget,
|
|
326
328
|
blurIntensity,
|
|
327
329
|
blurTint,
|
|
328
|
-
|
|
330
|
+
dimStyle,
|
|
329
331
|
dimOpacity,
|
|
330
332
|
staticOpacity,
|
|
331
333
|
layerStyle,
|
|
@@ -350,7 +352,7 @@ function StaticBackdropLayers({
|
|
|
350
352
|
pointerEvents="none"
|
|
351
353
|
style={[
|
|
352
354
|
StyleSheet.absoluteFill,
|
|
353
|
-
|
|
355
|
+
dimStyle,
|
|
354
356
|
layerStyle,
|
|
355
357
|
{ opacity: staticOpacity * dimOpacity },
|
|
356
358
|
]}
|
|
@@ -383,6 +385,7 @@ export const Backdrop = memo(function Backdrop({
|
|
|
383
385
|
blurIntensity = BACKDROP_BLUR_INTENSITY,
|
|
384
386
|
blurTint = 'dark',
|
|
385
387
|
dimColor = '#000',
|
|
388
|
+
dimGradient,
|
|
386
389
|
dimOpacity = BACKDROP_DIM_OPACITY,
|
|
387
390
|
style,
|
|
388
391
|
layerStyle,
|
|
@@ -390,6 +393,7 @@ export const Backdrop = memo(function Backdrop({
|
|
|
390
393
|
accessibilityLabel: accessibilityLabelProp,
|
|
391
394
|
testID,
|
|
392
395
|
}: BackdropProps) {
|
|
396
|
+
const rtl = useIsRtl();
|
|
393
397
|
const common = useCommonMessages();
|
|
394
398
|
const accessibilityLabel = accessibilityLabelProp ?? common.dismiss;
|
|
395
399
|
const inert = disabled || !onPress;
|
|
@@ -412,10 +416,10 @@ export const Backdrop = memo(function Backdrop({
|
|
|
412
416
|
|
|
413
417
|
const layerProps: BackdropLayerProps = {
|
|
414
418
|
blurTarget,
|
|
415
|
-
blurIntensity,
|
|
419
|
+
blurIntensity: clampBackdropNumber(blurIntensity, BACKDROP_BLUR_INTENSITY, 100),
|
|
416
420
|
blurTint,
|
|
417
|
-
|
|
418
|
-
dimOpacity,
|
|
421
|
+
dimStyle: backdropDimStyle(resolvedDimColor, dimGradient, rtl),
|
|
422
|
+
dimOpacity: clampBackdropNumber(dimOpacity, BACKDROP_DIM_OPACITY, 1),
|
|
419
423
|
staticOpacity,
|
|
420
424
|
layerStyle,
|
|
421
425
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import type { WebCssStyle } from '../styles/web-view-style';
|
|
3
|
+
import type { BackdropGradient } from './types';
|
|
4
|
+
|
|
5
|
+
/** Invalid/non-finite numbers preserve the owner's default; valid numbers clamp. */
|
|
6
|
+
export function clampBackdropNumber(value: number, fallback: number, max: number): number {
|
|
7
|
+
return Number.isFinite(value) ? Math.max(0, Math.min(max, value)) : fallback;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** The gradient lives on the dim layer, never the interactive backdrop host. */
|
|
11
|
+
export function backdropDimStyle(color: string, gradient: BackdropGradient | undefined, rtl: boolean): WebCssStyle {
|
|
12
|
+
if (!gradient || !['start-to-end', 'end-to-start', 'top-to-bottom', 'bottom-to-top'].includes(gradient.direction) || !Array.isArray(gradient.stops) || gradient.stops.length < 2 || gradient.stops.some(stop => !Number.isFinite(stop.offset) || typeof stop.color !== 'string' || !stop.color.trim())) {
|
|
13
|
+
return { backgroundColor: color };
|
|
14
|
+
}
|
|
15
|
+
const angle = gradient.direction === 'top-to-bottom' ? 180
|
|
16
|
+
: gradient.direction === 'bottom-to-top' ? 0
|
|
17
|
+
: (gradient.direction === 'start-to-end') !== rtl ? 90 : 270;
|
|
18
|
+
let previous = 0;
|
|
19
|
+
const stops = gradient.stops.map(stop => {
|
|
20
|
+
previous = Math.max(previous, Math.min(1, Math.max(0, stop.offset)));
|
|
21
|
+
return `${stop.color} ${previous * 100}%`;
|
|
22
|
+
}).join(', ');
|
|
23
|
+
const image = `linear-gradient(${angle}deg, ${stops})`;
|
|
24
|
+
return Platform.OS === 'web' ? { backgroundImage: image } : { experimental_backgroundImage: image };
|
|
25
|
+
}
|
package/src/overlay/index.ts
CHANGED
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
OverlayRoot,
|
|
17
17
|
Backdrop,
|
|
18
18
|
} from './Overlay';
|
|
19
|
-
export type { OverlayRootProps, BackdropProps, OverlayInertBoundaryProps } from './types';
|
|
19
|
+
export type { OverlayRootProps, BackdropProps, BackdropAppearance, BackdropGradient, OverlayInertBoundaryProps } from './types';
|
package/src/overlay/types.ts
CHANGED
|
@@ -62,7 +62,28 @@ export interface OverlayInertBoundaryProps {
|
|
|
62
62
|
testID?: string;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
/** A logical linear gradient replacing the uniform dim fill. */
|
|
66
|
+
export interface BackdropGradient {
|
|
67
|
+
direction: 'start-to-end' | 'end-to-start' | 'top-to-bottom' | 'bottom-to-top';
|
|
68
|
+
/** At least two stops. Offsets clamp to 0..1 and cannot precede the previous stop. */
|
|
69
|
+
stops: readonly { offset: number; color: string }[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Paint only; the owning surface retains hit testing, layering and animation. */
|
|
73
|
+
export interface BackdropAppearance {
|
|
74
|
+
/** Blur radius behind the dim. `0` renders the dim alone. */
|
|
75
|
+
blurIntensity?: number;
|
|
76
|
+
/** Blur tint. Backdrops dim the app, so `dark` is the default on every theme. */
|
|
77
|
+
blurTint?: 'light' | 'dark' | 'default';
|
|
78
|
+
/** Dim colour over the blur. */
|
|
79
|
+
dimColor?: string;
|
|
80
|
+
/** Dim opacity, 0–1. */
|
|
81
|
+
dimOpacity?: number;
|
|
82
|
+
/** Replaces dimColor; dimOpacity still multiplies the gradient. Invalid stops fall back to dimColor. */
|
|
83
|
+
dimGradient?: BackdropGradient;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface BackdropProps extends BackdropAppearance {
|
|
66
87
|
/** Dismiss handler. Omit (or pass `disabled`) for a backdrop that only dims. */
|
|
67
88
|
onPress?: () => void;
|
|
68
89
|
/**
|
|
@@ -73,14 +94,6 @@ export interface BackdropProps {
|
|
|
73
94
|
progress?: SharedValue<number>;
|
|
74
95
|
/** `true` keeps the dim but makes it inert — a blocking dialog, a busy state. */
|
|
75
96
|
disabled?: boolean;
|
|
76
|
-
/** Blur radius behind the dim. `0` renders the dim alone. */
|
|
77
|
-
blurIntensity?: number;
|
|
78
|
-
/** Blur tint. Backdrops dim the app, so `dark` is the default on every theme. */
|
|
79
|
-
blurTint?: 'light' | 'dark' | 'default';
|
|
80
|
-
/** Dim colour over the blur. */
|
|
81
|
-
dimColor?: string;
|
|
82
|
-
/** Dim opacity, 0–1. */
|
|
83
|
-
dimOpacity?: number;
|
|
84
97
|
/**
|
|
85
98
|
* Geometry for the press target: insets, layout. NOT a z-index — where this
|
|
86
99
|
* surface sits relative to others is `OverlayRoot`'s call (see `./stack.ts`),
|