@oxy.so/bloom 7.17.0 → 7.19.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 +12 -12
- package/docs/carousel.mdx +28 -2
- package/docs/checkbox.mdx +21 -0
- package/docs/dialog.mdx +16 -0
- package/docs/media-header.mdx +21 -0
- package/docs/popover.mdx +8 -0
- package/docs/radio.mdx +35 -0
- package/docs/search.mdx +19 -0
- package/lib/commonjs/bottom-sheet/BottomSheetBase.js +4 -3
- package/lib/commonjs/bottom-sheet/BottomSheetBase.js.map +1 -1
- package/lib/commonjs/carousel/Carousel.js +52 -15
- package/lib/commonjs/carousel/Carousel.js.map +1 -1
- package/lib/commonjs/checkbox/Checkbox.js +15 -9
- package/lib/commonjs/checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.js +11 -3
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +15 -6
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/DialogBottomSheet.js +3 -0
- package/lib/commonjs/dialog/DialogBottomSheet.js.map +1 -1
- package/lib/commonjs/dialog/DialogHeader.js +9 -1
- package/lib/commonjs/dialog/DialogHeader.js.map +1 -1
- package/lib/commonjs/dialog/SheetShell.js +3 -0
- package/lib/commonjs/dialog/SheetShell.js.map +1 -1
- package/lib/commonjs/floating/FloatingPanel.js +5 -3
- package/lib/commonjs/floating/FloatingPanel.js.map +1 -1
- package/lib/commonjs/hooks/use-choice-space-key.js +37 -0
- package/lib/commonjs/hooks/use-choice-space-key.js.map +1 -0
- package/lib/commonjs/media-header/FollowLabel.js +46 -0
- package/lib/commonjs/media-header/FollowLabel.js.map +1 -0
- package/lib/commonjs/media-header/MediaActionBar.js +19 -13
- package/lib/commonjs/media-header/MediaActionBar.js.map +1 -1
- package/lib/commonjs/popover/Popover.js +2 -0
- package/lib/commonjs/popover/Popover.js.map +1 -1
- package/lib/commonjs/popover/Popover.web.js +2 -0
- package/lib/commonjs/popover/Popover.web.js.map +1 -1
- package/lib/commonjs/radio/Radio.js +83 -34
- package/lib/commonjs/radio/Radio.js.map +1 -1
- package/lib/commonjs/radio/RadioCard.js +3 -0
- package/lib/commonjs/radio/RadioCard.js.map +1 -1
- package/lib/commonjs/radio/context.js +9 -0
- package/lib/commonjs/radio/context.js.map +1 -0
- package/lib/commonjs/radio/use-radio-group-item.js +29 -0
- package/lib/commonjs/radio/use-radio-group-item.js.map +1 -0
- package/lib/commonjs/search/Search.js +29 -23
- package/lib/commonjs/search/Search.js.map +1 -1
- package/lib/commonjs/surface/use-surface-material.web.js +4 -4
- package/lib/commonjs/surface/use-surface-material.web.js.map +1 -1
- package/lib/commonjs/text-field/TextField.js +6 -4
- package/lib/commonjs/text-field/TextField.js.map +1 -1
- package/lib/module/bottom-sheet/BottomSheetBase.js +4 -3
- package/lib/module/bottom-sheet/BottomSheetBase.js.map +1 -1
- package/lib/module/carousel/Carousel.js +52 -15
- package/lib/module/carousel/Carousel.js.map +1 -1
- package/lib/module/checkbox/Checkbox.js +15 -9
- package/lib/module/checkbox/Checkbox.js.map +1 -1
- package/lib/module/dialog/Dialog.js +11 -3
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +15 -6
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/DialogBottomSheet.js +3 -0
- package/lib/module/dialog/DialogBottomSheet.js.map +1 -1
- package/lib/module/dialog/DialogHeader.js +9 -1
- package/lib/module/dialog/DialogHeader.js.map +1 -1
- package/lib/module/dialog/SheetShell.js +3 -0
- package/lib/module/dialog/SheetShell.js.map +1 -1
- package/lib/module/floating/FloatingPanel.js +5 -3
- package/lib/module/floating/FloatingPanel.js.map +1 -1
- package/lib/module/hooks/use-choice-space-key.js +34 -0
- package/lib/module/hooks/use-choice-space-key.js.map +1 -0
- package/lib/module/media-header/FollowLabel.js +42 -0
- package/lib/module/media-header/FollowLabel.js.map +1 -0
- package/lib/module/media-header/MediaActionBar.js +19 -13
- package/lib/module/media-header/MediaActionBar.js.map +1 -1
- package/lib/module/popover/Popover.js +2 -0
- package/lib/module/popover/Popover.js.map +1 -1
- package/lib/module/popover/Popover.web.js +2 -0
- package/lib/module/popover/Popover.web.js.map +1 -1
- package/lib/module/radio/Radio.js +84 -35
- package/lib/module/radio/Radio.js.map +1 -1
- package/lib/module/radio/RadioCard.js +3 -0
- package/lib/module/radio/RadioCard.js.map +1 -1
- package/lib/module/radio/context.js +5 -0
- package/lib/module/radio/context.js.map +1 -0
- package/lib/module/radio/use-radio-group-item.js +26 -0
- package/lib/module/radio/use-radio-group-item.js.map +1 -0
- package/lib/module/search/Search.js +32 -26
- package/lib/module/search/Search.js.map +1 -1
- package/lib/module/surface/use-surface-material.web.js +4 -4
- package/lib/module/surface/use-surface-material.web.js.map +1 -1
- package/lib/module/text-field/TextField.js +6 -4
- package/lib/module/text-field/TextField.js.map +1 -1
- package/lib/typescript/commonjs/bottom-sheet/BottomSheetBase.d.ts.map +1 -1
- package/lib/typescript/commonjs/bottom-sheet/types.d.ts +2 -0
- package/lib/typescript/commonjs/bottom-sheet/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/carousel/Carousel.d.ts +1 -1
- package/lib/typescript/commonjs/carousel/Carousel.d.ts.map +1 -1
- package/lib/typescript/commonjs/carousel/types.d.ts +11 -2
- package/lib/typescript/commonjs/carousel/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/commonjs/checkbox/types.d.ts +4 -0
- package/lib/typescript/commonjs/checkbox/types.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 +2 -0
- package/lib/typescript/commonjs/dialog/DialogHeader.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/SheetShell.d.ts +2 -1
- package/lib/typescript/commonjs/dialog/SheetShell.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/types.d.ts +2 -0
- package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/FloatingPanel.d.ts +1 -1
- package/lib/typescript/commonjs/floating/FloatingPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/types.d.ts +1 -0
- package/lib/typescript/commonjs/floating/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-choice-space-key.d.ts +14 -0
- package/lib/typescript/commonjs/hooks/use-choice-space-key.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-header/FollowLabel.d.ts +11 -0
- package/lib/typescript/commonjs/media-header/FollowLabel.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-header/MediaActionBar.d.ts +1 -1
- package/lib/typescript/commonjs/media-header/MediaActionBar.d.ts.map +1 -1
- package/lib/typescript/commonjs/media-header/types.d.ts +10 -0
- package/lib/typescript/commonjs/media-header/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/Popover.d.ts +1 -1
- package/lib/typescript/commonjs/popover/Popover.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/Popover.web.d.ts +1 -1
- package/lib/typescript/commonjs/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/types.d.ts +4 -1
- package/lib/typescript/commonjs/popover/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/Radio.d.ts +1 -1
- package/lib/typescript/commonjs/radio/Radio.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/RadioCard.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/context.d.ts +9 -0
- package/lib/typescript/commonjs/radio/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/radio/types.d.ts +6 -0
- package/lib/typescript/commonjs/radio/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/use-radio-group-item.d.ts +3 -0
- package/lib/typescript/commonjs/radio/use-radio-group-item.d.ts.map +1 -0
- package/lib/typescript/commonjs/search/Search.d.ts +2 -0
- package/lib/typescript/commonjs/search/Search.d.ts.map +1 -1
- package/lib/typescript/commonjs/search/types.d.ts +5 -0
- package/lib/typescript/commonjs/search/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/surface/use-surface-material.web.d.ts +1 -1
- package/lib/typescript/commonjs/surface/use-surface-material.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/text-field/TextField.d.ts +1 -1
- package/lib/typescript/commonjs/text-field/TextField.d.ts.map +1 -1
- package/lib/typescript/commonjs/text-field/types.d.ts +3 -1
- package/lib/typescript/commonjs/text-field/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 +2 -0
- package/lib/typescript/module/bottom-sheet/types.d.ts.map +1 -1
- package/lib/typescript/module/carousel/Carousel.d.ts +1 -1
- package/lib/typescript/module/carousel/Carousel.d.ts.map +1 -1
- package/lib/typescript/module/carousel/types.d.ts +11 -2
- package/lib/typescript/module/carousel/types.d.ts.map +1 -1
- package/lib/typescript/module/checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/module/checkbox/types.d.ts +4 -0
- package/lib/typescript/module/checkbox/types.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 +2 -0
- package/lib/typescript/module/dialog/DialogHeader.d.ts.map +1 -1
- package/lib/typescript/module/dialog/SheetShell.d.ts +2 -1
- package/lib/typescript/module/dialog/SheetShell.d.ts.map +1 -1
- package/lib/typescript/module/dialog/types.d.ts +2 -0
- package/lib/typescript/module/dialog/types.d.ts.map +1 -1
- package/lib/typescript/module/floating/FloatingPanel.d.ts +1 -1
- package/lib/typescript/module/floating/FloatingPanel.d.ts.map +1 -1
- package/lib/typescript/module/floating/types.d.ts +1 -0
- package/lib/typescript/module/floating/types.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-choice-space-key.d.ts +14 -0
- package/lib/typescript/module/hooks/use-choice-space-key.d.ts.map +1 -0
- package/lib/typescript/module/media-header/FollowLabel.d.ts +11 -0
- package/lib/typescript/module/media-header/FollowLabel.d.ts.map +1 -0
- package/lib/typescript/module/media-header/MediaActionBar.d.ts +1 -1
- package/lib/typescript/module/media-header/MediaActionBar.d.ts.map +1 -1
- package/lib/typescript/module/media-header/types.d.ts +10 -0
- package/lib/typescript/module/media-header/types.d.ts.map +1 -1
- package/lib/typescript/module/popover/Popover.d.ts +1 -1
- package/lib/typescript/module/popover/Popover.d.ts.map +1 -1
- package/lib/typescript/module/popover/Popover.web.d.ts +1 -1
- package/lib/typescript/module/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/types.d.ts +4 -1
- package/lib/typescript/module/popover/types.d.ts.map +1 -1
- package/lib/typescript/module/radio/Radio.d.ts +1 -1
- package/lib/typescript/module/radio/Radio.d.ts.map +1 -1
- package/lib/typescript/module/radio/RadioCard.d.ts.map +1 -1
- package/lib/typescript/module/radio/context.d.ts +9 -0
- package/lib/typescript/module/radio/context.d.ts.map +1 -0
- package/lib/typescript/module/radio/types.d.ts +6 -0
- package/lib/typescript/module/radio/types.d.ts.map +1 -1
- package/lib/typescript/module/radio/use-radio-group-item.d.ts +3 -0
- package/lib/typescript/module/radio/use-radio-group-item.d.ts.map +1 -0
- package/lib/typescript/module/search/Search.d.ts +2 -0
- package/lib/typescript/module/search/Search.d.ts.map +1 -1
- package/lib/typescript/module/search/types.d.ts +5 -0
- package/lib/typescript/module/search/types.d.ts.map +1 -1
- package/lib/typescript/module/surface/use-surface-material.web.d.ts +1 -1
- package/lib/typescript/module/surface/use-surface-material.web.d.ts.map +1 -1
- package/lib/typescript/module/text-field/TextField.d.ts +1 -1
- package/lib/typescript/module/text-field/TextField.d.ts.map +1 -1
- package/lib/typescript/module/text-field/types.d.ts +3 -1
- package/lib/typescript/module/text-field/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bottom-sheet/BottomSheetBase.tsx +4 -3
- package/src/bottom-sheet/types.ts +2 -0
- package/src/carousel/Carousel.tsx +46 -20
- package/src/carousel/types.ts +8 -2
- package/src/checkbox/Checkbox.tsx +13 -3
- package/src/checkbox/types.ts +4 -0
- package/src/dialog/Dialog.tsx +11 -3
- package/src/dialog/Dialog.web.tsx +15 -6
- package/src/dialog/DialogBottomSheet.tsx +4 -0
- package/src/dialog/DialogHeader.tsx +7 -1
- package/src/dialog/SheetShell.tsx +4 -0
- package/src/dialog/types.ts +2 -0
- package/src/floating/FloatingPanel.tsx +4 -3
- package/src/floating/types.ts +1 -0
- package/src/hooks/use-choice-space-key.ts +29 -0
- package/src/media-header/FollowLabel.tsx +23 -0
- package/src/media-header/MediaActionBar.tsx +11 -6
- package/src/media-header/types.ts +10 -0
- package/src/popover/Popover.tsx +2 -0
- package/src/popover/Popover.web.tsx +2 -0
- package/src/popover/types.ts +4 -1
- package/src/radio/Radio.tsx +77 -34
- package/src/radio/RadioCard.tsx +4 -0
- package/src/radio/context.ts +9 -0
- package/src/radio/types.ts +6 -0
- package/src/radio/use-radio-group-item.ts +20 -0
- package/src/search/Search.tsx +24 -31
- package/src/search/types.ts +5 -0
- package/src/surface/use-surface-material.web.ts +4 -4
- package/src/text-field/TextField.tsx +5 -4
- package/src/text-field/types.ts +3 -1
|
@@ -12,6 +12,8 @@ export interface BottomSheetRef {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface BottomSheetProps {
|
|
15
|
+
/** Standard optical surface, or the unmodified backing fill. Default surface. */
|
|
16
|
+
material?: 'surface' | 'flat';
|
|
15
17
|
children: React.ReactNode;
|
|
16
18
|
/** Accessible name for the modal sheet panel on web. */
|
|
17
19
|
accessibilityLabel?: string;
|
|
@@ -327,8 +327,11 @@ const CarouselComponent = function Carousel({
|
|
|
327
327
|
children,
|
|
328
328
|
accessibilityLabel,
|
|
329
329
|
header,
|
|
330
|
+
footer,
|
|
331
|
+
loop = false,
|
|
330
332
|
showArrows = true,
|
|
331
333
|
arrowsPlacement = 'header',
|
|
334
|
+
arrowsInset = 8,
|
|
332
335
|
arrowsVisibility = 'always',
|
|
333
336
|
arrowButtonProps,
|
|
334
337
|
hideUnavailableArrows = false,
|
|
@@ -560,14 +563,23 @@ const CarouselComponent = function Carousel({
|
|
|
560
563
|
node.addEventListener('pointerdown', beginDrag);
|
|
561
564
|
window.addEventListener('pointerup', endDrag);
|
|
562
565
|
window.addEventListener('pointercancel', endDrag);
|
|
563
|
-
|
|
566
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
567
|
+
// Owned loop navigation must retain its pending destination so rapid
|
|
568
|
+
// key presses advance from the requested stop, not an animation frame.
|
|
569
|
+
if (loop && event.target === node && !event.altKey && !event.ctrlKey && !event.metaKey
|
|
570
|
+
&& (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) return;
|
|
571
|
+
interruptControlledScroll();
|
|
572
|
+
};
|
|
573
|
+
node.addEventListener('wheel', interruptControlledScroll);
|
|
574
|
+
node.addEventListener('keydown', onKeyDown);
|
|
564
575
|
return () => {
|
|
565
576
|
node.removeEventListener('pointerdown', beginDrag);
|
|
566
577
|
window.removeEventListener('pointerup', endDrag);
|
|
567
578
|
window.removeEventListener('pointercancel', endDrag);
|
|
568
|
-
|
|
579
|
+
node.removeEventListener('wheel', interruptControlledScroll);
|
|
580
|
+
node.removeEventListener('keydown', onKeyDown);
|
|
569
581
|
};
|
|
570
|
-
}, [controlledIndex !== undefined, interruptControlledScroll, beginDrag, endDrag]);
|
|
582
|
+
}, [controlledIndex !== undefined, interruptControlledScroll, beginDrag, endDrag, loop]);
|
|
571
583
|
|
|
572
584
|
const scrollToStop = (stop: Stop | undefined) => {
|
|
573
585
|
if (!stop) return;
|
|
@@ -588,11 +600,10 @@ const CarouselComponent = function Carousel({
|
|
|
588
600
|
const all = computeStops();
|
|
589
601
|
if (!all) return;
|
|
590
602
|
const x = pendingTarget.current ?? scroll.current.x;
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
);
|
|
603
|
+
const target = direction === 1
|
|
604
|
+
? all.find((stop) => stop.offset > x + 1)
|
|
605
|
+
: [...all].reverse().find((stop) => stop.offset < x - 1);
|
|
606
|
+
scrollToStop(target ?? (loop && all.length > 1 ? all[direction === 1 ? 0 : all.length - 1] : undefined));
|
|
596
607
|
};
|
|
597
608
|
|
|
598
609
|
const onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
@@ -635,6 +646,9 @@ const CarouselComponent = function Carousel({
|
|
|
635
646
|
};
|
|
636
647
|
|
|
637
648
|
const overlay = arrowsPlacement === 'overlay';
|
|
649
|
+
const canWrap = loop && stops.length > 1;
|
|
650
|
+
const previousUnavailable = atStart && !canWrap;
|
|
651
|
+
const nextUnavailable = atEnd && !canWrap;
|
|
638
652
|
const arrowsVisible = showArrows && count > 0;
|
|
639
653
|
// Slots stay mounted at the same edges even when their controls are hidden.
|
|
640
654
|
// Hover opacity belongs to the slot, leaving the button's recipe authoritative.
|
|
@@ -652,7 +666,7 @@ const CarouselComponent = function Carousel({
|
|
|
652
666
|
useLayoutEffect(() => {
|
|
653
667
|
if (!IS_WEB || !hideUnavailableArrows || typeof HTMLElement === 'undefined') return;
|
|
654
668
|
const activeElement = document.activeElement;
|
|
655
|
-
for (const [unavailable, ref] of [[
|
|
669
|
+
for (const [unavailable, ref] of [[previousUnavailable, previousArrowRef], [nextUnavailable, nextArrowRef]] as const) {
|
|
656
670
|
const slot: unknown = ref.current;
|
|
657
671
|
if (unavailable && slot instanceof HTMLElement && slot.contains(activeElement)) {
|
|
658
672
|
const trackNode: unknown = scrollRef.current?.getScrollableNode();
|
|
@@ -660,16 +674,16 @@ const CarouselComponent = function Carousel({
|
|
|
660
674
|
break;
|
|
661
675
|
}
|
|
662
676
|
}
|
|
663
|
-
}, [
|
|
677
|
+
}, [previousUnavailable, nextUnavailable, hideUnavailableArrows]);
|
|
664
678
|
const arrowButtons = <>
|
|
665
679
|
{arrow(<Button size={overlay ? 'lg' : 'sm'} appearance="subtle" tone="neutral" {...arrowButtonProps}
|
|
666
680
|
icon={rtl ? RiArrowRightSLine : RiArrowLeftSLine}
|
|
667
|
-
accessibilityLabel={previousLabel} disabled={
|
|
668
|
-
|
|
681
|
+
accessibilityLabel={previousLabel} disabled={previousUnavailable} onPress={() => step(-1)} />,
|
|
682
|
+
previousUnavailable, previousArrowRef)}
|
|
669
683
|
{arrow(<Button size={overlay ? 'lg' : 'sm'} appearance="subtle" tone="neutral" {...arrowButtonProps}
|
|
670
684
|
icon={rtl ? RiArrowLeftSLine : RiArrowRightSLine}
|
|
671
|
-
accessibilityLabel={nextLabel} disabled={
|
|
672
|
-
|
|
685
|
+
accessibilityLabel={nextLabel} disabled={nextUnavailable} onPress={() => step(1)} />,
|
|
686
|
+
nextUnavailable, nextArrowRef)}
|
|
673
687
|
</>;
|
|
674
688
|
// iOS snapping reads physical offsets even though its imperative command and
|
|
675
689
|
// scroll events use logical offsets. Android converts snap offsets internally.
|
|
@@ -682,9 +696,14 @@ const CarouselComponent = function Carousel({
|
|
|
682
696
|
<ScrollView
|
|
683
697
|
ref={scrollRef}
|
|
684
698
|
{...webDataSet({ bloomCarouselTrack: align })}
|
|
685
|
-
//
|
|
686
|
-
//
|
|
687
|
-
{...(IS_WEB ? { tabIndex: 0
|
|
699
|
+
// The browser scrolls a focused track by default; wrapping opts into
|
|
700
|
+
// stop-based Left/Right navigation without intercepting slide controls.
|
|
701
|
+
{...(IS_WEB ? { tabIndex: 0, onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => {
|
|
702
|
+
if (!loop || event.target !== event.currentTarget || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
703
|
+
if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return;
|
|
704
|
+
event.preventDefault(); event.stopPropagation();
|
|
705
|
+
step((event.key === 'ArrowRight') !== rtl ? 1 : -1);
|
|
706
|
+
} } : {})}
|
|
688
707
|
horizontal
|
|
689
708
|
showsHorizontalScrollIndicator={false}
|
|
690
709
|
scrollEventThrottle={16}
|
|
@@ -718,10 +737,10 @@ const CarouselComponent = function Carousel({
|
|
|
718
737
|
style={[{ width: '100%', flexDirection: 'column', gap: 16 }, style]}
|
|
719
738
|
testID={testID}
|
|
720
739
|
>
|
|
721
|
-
{header != null || (arrowsVisible &&
|
|
740
|
+
{header != null || (arrowsVisible && arrowsPlacement === 'header') ? (
|
|
722
741
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 8, paddingHorizontal: inset }}>
|
|
723
742
|
<View style={{ flex: 1, minWidth: 0 }}>{header}</View>
|
|
724
|
-
{arrowsVisible &&
|
|
743
|
+
{arrowsVisible && arrowsPlacement === 'header' ? arrowButtons : null}
|
|
725
744
|
</View>
|
|
726
745
|
) : null}
|
|
727
746
|
|
|
@@ -729,7 +748,8 @@ const CarouselComponent = function Carousel({
|
|
|
729
748
|
{track}
|
|
730
749
|
{arrowsVisible && overlay ? <View pointerEvents="box-none"
|
|
731
750
|
testID={testID ? `${testID}-overlay-arrows` : undefined}
|
|
732
|
-
style={{ position: 'absolute', top: 0, bottom: 0, insetInlineStart:
|
|
751
|
+
style={{ position: 'absolute', top: 0, bottom: 0, insetInlineStart: typeof arrowsInset === 'number' ? arrowsInset : arrowsInset.start ?? 8,
|
|
752
|
+
insetInlineEnd: typeof arrowsInset === 'number' ? arrowsInset : arrowsInset.end ?? 8,
|
|
733
753
|
flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
|
734
754
|
{arrowButtons}
|
|
735
755
|
</View> : null}
|
|
@@ -755,6 +775,12 @@ const CarouselComponent = function Carousel({
|
|
|
755
775
|
})}
|
|
756
776
|
</View>
|
|
757
777
|
) : null}
|
|
778
|
+
{footer != null || (arrowsVisible && arrowsPlacement === 'footer') ? (
|
|
779
|
+
<View testID={testID ? `${testID}-footer` : undefined} style={{ flexDirection:'row', alignItems:'center', gap:8, paddingHorizontal:inset }}>
|
|
780
|
+
<View style={{ flex:1, minWidth:0 }}>{footer}</View>
|
|
781
|
+
{arrowsVisible && arrowsPlacement === 'footer' ? arrowButtons : null}
|
|
782
|
+
</View>
|
|
783
|
+
) : null}
|
|
758
784
|
</View>
|
|
759
785
|
);
|
|
760
786
|
};
|
package/src/carousel/types.ts
CHANGED
|
@@ -20,10 +20,16 @@ export interface CarouselProps {
|
|
|
20
20
|
* start, arrows at the end). With overlay arrows this row contains only the header.
|
|
21
21
|
*/
|
|
22
22
|
header?: ReactNode;
|
|
23
|
+
/** Leading content in an optional row below the track and dots. */
|
|
24
|
+
footer?: ReactNode;
|
|
25
|
+
/** Controls and track arrow keys wrap to the other end; no cloned slides. Default false. */
|
|
26
|
+
loop?: boolean;
|
|
23
27
|
/** Previous / next buttons. Defaults to `true`; callers may hide them at their mobile breakpoint. */
|
|
24
28
|
showArrows?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
|
|
29
|
+
/** Overlay control offsets from logical track edges. Negative values extend outside. Default 8. */
|
|
30
|
+
arrowsInset?: number | { start?: number; end?: number };
|
|
31
|
+
/** Controls share a header/footer row or overlay the track. Default header. */
|
|
32
|
+
arrowsPlacement?: 'header' | 'overlay' | 'footer';
|
|
27
33
|
/**
|
|
28
34
|
* Defaults to 'always'. 'hover' reveals arrows on hover or focus within the
|
|
29
35
|
* carousel on web with a fine, hover-capable pointer. Touch and native keep
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useChoiceSpaceKey } from '../hooks/use-choice-space-key';
|
|
1
2
|
import { useControllableState } from '../hooks/use-controllable-state';
|
|
2
3
|
import { useBloomAppearance } from '../appearance';
|
|
3
4
|
import { resolveBloomColors } from '../appearance/colors';
|
|
@@ -87,6 +88,7 @@ const CheckboxComponent: React.FC<CheckboxProps> = (props) => {
|
|
|
87
88
|
defaultChecked = false,
|
|
88
89
|
onCheckedChange,
|
|
89
90
|
label,
|
|
91
|
+
labelContent,
|
|
90
92
|
description,
|
|
91
93
|
size: sizeProp,
|
|
92
94
|
disabled = false,
|
|
@@ -130,7 +132,8 @@ const CheckboxComponent: React.FC<CheckboxProps> = (props) => {
|
|
|
130
132
|
}
|
|
131
133
|
}, [checked, isDisabled, setChecked]);
|
|
132
134
|
|
|
133
|
-
const
|
|
135
|
+
const hasLabel = labelContent != null || Boolean(label);
|
|
136
|
+
const hasText = hasLabel || Boolean(description);
|
|
134
137
|
|
|
135
138
|
const rowStyle = useMemo(
|
|
136
139
|
(): WebCssStyle => ({
|
|
@@ -146,8 +149,11 @@ const CheckboxComponent: React.FC<CheckboxProps> = (props) => {
|
|
|
146
149
|
|
|
147
150
|
const slop = Math.max(8, Math.ceil((MIN_TOUCH_TARGET - sizeConfig.box) / 2));
|
|
148
151
|
|
|
152
|
+
const spaceKey = useChoiceSpaceKey(isDisabled, handlePress);
|
|
153
|
+
|
|
149
154
|
return (
|
|
150
155
|
<Pressable
|
|
156
|
+
{...spaceKey}
|
|
151
157
|
// The DOM hooks the adopted sheets hang off. Through `dataSet`, because
|
|
152
158
|
// react-native-web drops any prop outside its own fixed list — a literal
|
|
153
159
|
// `'data-bloom-checkbox'` prop never reaches the DOM. See the longer note
|
|
@@ -191,7 +197,11 @@ const CheckboxComponent: React.FC<CheckboxProps> = (props) => {
|
|
|
191
197
|
|
|
192
198
|
{hasText && (
|
|
193
199
|
<View style={{ flex: 1 }}>
|
|
194
|
-
{
|
|
200
|
+
{labelContent != null ? (
|
|
201
|
+
<View pointerEvents="none" aria-hidden accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
|
|
202
|
+
{labelContent}
|
|
203
|
+
</View>
|
|
204
|
+
) : label && (
|
|
195
205
|
<Text variant={sizeConfig.label} style={[{ color: paint.text }, labelStyle]}>
|
|
196
206
|
{label}
|
|
197
207
|
</Text>
|
|
@@ -199,7 +209,7 @@ const CheckboxComponent: React.FC<CheckboxProps> = (props) => {
|
|
|
199
209
|
{description && (
|
|
200
210
|
<Text
|
|
201
211
|
variant={sizeConfig.description}
|
|
202
|
-
style={{ color: paint.description, marginTop:
|
|
212
|
+
style={{ color: paint.description, marginTop: hasLabel ? DESCRIPTION_GAP : 0 }}
|
|
203
213
|
>
|
|
204
214
|
{description}
|
|
205
215
|
</Text>
|
package/src/checkbox/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { BloomSize } from '../appearance';
|
|
2
3
|
import type { BloomTone } from '../appearance';
|
|
3
4
|
import type { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
@@ -12,6 +13,9 @@ export interface CheckboxProps {
|
|
|
12
13
|
onCheckedChange?: (checked: boolean) => void;
|
|
13
14
|
/** Optional label text. */
|
|
14
15
|
label?: string;
|
|
16
|
+
/** Decorative label layout, rendered in a View instead of Text. Supply
|
|
17
|
+
* `label` or `accessibilityLabel` for its accessible name. Do not nest controls. */
|
|
18
|
+
labelContent?: ReactNode;
|
|
15
19
|
/** Optional description shown below the label. */
|
|
16
20
|
description?: string;
|
|
17
21
|
/** Size preset. */
|
package/src/dialog/Dialog.tsx
CHANGED
|
@@ -112,6 +112,7 @@ export function Dialog({
|
|
|
112
112
|
* placement is handled separately by `DialogBottomSheet`.
|
|
113
113
|
*/
|
|
114
114
|
function CenteredOrSideDialog({
|
|
115
|
+
material: surfaceMaterial = 'surface',
|
|
115
116
|
control,
|
|
116
117
|
open: controlledOpen,
|
|
117
118
|
startOpen,
|
|
@@ -302,6 +303,7 @@ function CenteredOrSideDialog({
|
|
|
302
303
|
return (
|
|
303
304
|
<Context.Provider value={context}>
|
|
304
305
|
<SideSheet
|
|
306
|
+
material={surfaceMaterial}
|
|
305
307
|
presentation={presentation}
|
|
306
308
|
exitDuration={exitDuration}
|
|
307
309
|
scrollable={scrollableResolved}
|
|
@@ -335,6 +337,8 @@ function CenteredOrSideDialog({
|
|
|
335
337
|
|
|
336
338
|
return (
|
|
337
339
|
<BottomSheet
|
|
340
|
+
material={surfaceMaterial}
|
|
341
|
+
backgroundFill={surfaceMaterial === 'flat' ? String(StyleSheet.flatten([style, panelStyle])?.backgroundColor ?? theme.colors.background) : undefined}
|
|
338
342
|
ref={ref}
|
|
339
343
|
onDismiss={handleDismiss}
|
|
340
344
|
enablePanDownToClose
|
|
@@ -348,6 +352,7 @@ function CenteredOrSideDialog({
|
|
|
348
352
|
headerOverlay={
|
|
349
353
|
header ? (
|
|
350
354
|
<DialogNavHeader
|
|
355
|
+
flatSurface={surfaceMaterial === 'flat'}
|
|
351
356
|
controller={headerController}
|
|
352
357
|
header={header}
|
|
353
358
|
onDismiss={close}
|
|
@@ -402,6 +407,7 @@ function CenteredOrSideDialog({
|
|
|
402
407
|
* exit animations are safe (the web `removeChild` crash does not apply).
|
|
403
408
|
*/
|
|
404
409
|
function SideSheet({
|
|
410
|
+
material: surfaceMaterial = 'surface',
|
|
405
411
|
scrollable,
|
|
406
412
|
presentation,
|
|
407
413
|
exitDuration,
|
|
@@ -428,6 +434,7 @@ function SideSheet({
|
|
|
428
434
|
style,
|
|
429
435
|
children,
|
|
430
436
|
}: {
|
|
437
|
+
material?: DialogProps['material'];
|
|
431
438
|
scrollable: boolean;
|
|
432
439
|
presentation?: DialogProps['presentation'];
|
|
433
440
|
exitDuration?: number;
|
|
@@ -541,7 +548,7 @@ function SideSheet({
|
|
|
541
548
|
);
|
|
542
549
|
|
|
543
550
|
const panelRadius = StyleSheet.flatten([panelStyle, style])?.borderRadius ?? SURFACE_SHAPES.panel.radius;
|
|
544
|
-
const material = resolveSurfaceMaterial({ fill: String(StyleSheet.flatten([panelStyle, style])?.backgroundColor ?? theme.colors.background), parentFill: theme.colors.background, level: 0 });
|
|
551
|
+
const material = resolveSurfaceMaterial({ fill: String(StyleSheet.flatten([panelStyle, style])?.backgroundColor ?? theme.colors.background), parentFill: theme.colors.background, level: 0, paint: surfaceMaterial !== 'flat' });
|
|
545
552
|
const { paintFill, publishedFill: surfaceFill } = material;
|
|
546
553
|
if (!mounted) return null;
|
|
547
554
|
|
|
@@ -593,10 +600,10 @@ function SideSheet({
|
|
|
593
600
|
panelAnimatedStyle,
|
|
594
601
|
panelStyle,
|
|
595
602
|
style,
|
|
596
|
-
{ backgroundColor: 'transparent' },
|
|
603
|
+
{ backgroundColor: surfaceMaterial === 'flat' ? paintFill : 'transparent' },
|
|
597
604
|
]}
|
|
598
605
|
>
|
|
599
|
-
{presentation !== 'custom' && <SurfacePaint fill={paintFill} shape={{ curve: SURFACE_SHAPES.panel.curve }} radius={panelRadius} />}
|
|
606
|
+
{presentation !== 'custom' && surfaceMaterial !== 'flat' && <SurfacePaint fill={paintFill} shape={{ curve: SURFACE_SHAPES.panel.curve }} radius={panelRadius} />}
|
|
600
607
|
<SurfaceLevelProvider level={material.level} fill={surfaceFill}>
|
|
601
608
|
{header ? (
|
|
602
609
|
// Nav-header mode on a side drawer: a static titled bar (the drawer body
|
|
@@ -604,6 +611,7 @@ function SideSheet({
|
|
|
604
611
|
// below the bar.
|
|
605
612
|
<View style={{ flex: 1, minHeight: 0, borderRadius: panelRadius, overflow: 'hidden' }}>
|
|
606
613
|
<DialogNavHeader
|
|
614
|
+
flatSurface={surfaceMaterial === 'flat'}
|
|
607
615
|
controller={headerController}
|
|
608
616
|
header={header}
|
|
609
617
|
onDismiss={onHeaderDismiss}
|
|
@@ -175,6 +175,7 @@ export function Dialog({ placement, ...rest }: DialogProps) {
|
|
|
175
175
|
* `BottomSheet`).
|
|
176
176
|
*/
|
|
177
177
|
function CenterOrSideDialog({
|
|
178
|
+
material: surfaceMaterial = 'surface',
|
|
178
179
|
control,
|
|
179
180
|
open: controlledOpen,
|
|
180
181
|
startOpen,
|
|
@@ -374,6 +375,7 @@ function CenterOrSideDialog({
|
|
|
374
375
|
}, containerStyle]}
|
|
375
376
|
>
|
|
376
377
|
<DialogPanel
|
|
378
|
+
material={surfaceMaterial}
|
|
377
379
|
presentation={presentation}
|
|
378
380
|
panelRef={panelRef}
|
|
379
381
|
testID={testID}
|
|
@@ -406,6 +408,7 @@ function CenterOrSideDialog({
|
|
|
406
408
|
<ClosingContext.Provider value={isClosing}>
|
|
407
409
|
<RemoveScrollBar />
|
|
408
410
|
<SheetSurface
|
|
411
|
+
material={surfaceMaterial}
|
|
409
412
|
panelRef={panelRef}
|
|
410
413
|
testID={testID}
|
|
411
414
|
label={label}
|
|
@@ -436,6 +439,7 @@ function CenterOrSideDialog({
|
|
|
436
439
|
}
|
|
437
440
|
|
|
438
441
|
function DialogPanel({
|
|
442
|
+
material: surfaceMaterial = 'surface',
|
|
439
443
|
presentation,
|
|
440
444
|
panelRef,
|
|
441
445
|
testID,
|
|
@@ -453,6 +457,7 @@ function DialogPanel({
|
|
|
453
457
|
isClosing,
|
|
454
458
|
children,
|
|
455
459
|
}: {
|
|
460
|
+
material?: DialogProps['material'];
|
|
456
461
|
presentation?: DialogProps['presentation'];
|
|
457
462
|
panelRef: React.RefObject<View | null>;
|
|
458
463
|
testID?: string;
|
|
@@ -477,7 +482,7 @@ function DialogPanel({
|
|
|
477
482
|
const headerController = useDialogHeaderController();
|
|
478
483
|
const { height: viewportHeight } = useWindowDimensions();
|
|
479
484
|
const heightRatio = maxHeightRatio ?? DEFAULT_MAX_HEIGHT_RATIO;
|
|
480
|
-
const material = resolveSurfaceMaterial({ fill: String(StyleSheet.flatten(style)?.backgroundColor ?? theme.colors.background), parentFill: theme.colors.background, level: 0 });
|
|
485
|
+
const material = resolveSurfaceMaterial({ fill: String(StyleSheet.flatten(style)?.backgroundColor ?? theme.colors.background), parentFill: theme.colors.background, level: 0, paint: surfaceMaterial !== 'flat' });
|
|
481
486
|
const { paintFill, publishedFill: surfaceFill } = material;
|
|
482
487
|
|
|
483
488
|
// Size morphing across an in-place content swap. The centered card is the one
|
|
@@ -558,10 +563,10 @@ function DialogPanel({
|
|
|
558
563
|
// before `style` so a consumer's explicit size still wins.
|
|
559
564
|
morphState.panelStyle,
|
|
560
565
|
style,
|
|
561
|
-
{ backgroundColor: 'transparent' },
|
|
566
|
+
{ backgroundColor: surfaceMaterial === 'flat' ? paintFill : 'transparent' },
|
|
562
567
|
]}
|
|
563
568
|
>
|
|
564
|
-
{presentation !== 'custom' && <SurfacePaint fill={paintFill} shape={{ curve: SURFACE_SHAPES.panel.curve }} radius={StyleSheet.flatten(style)?.borderRadius ?? 20} />}
|
|
569
|
+
{presentation !== 'custom' && surfaceMaterial !== 'flat' && <SurfacePaint fill={paintFill} shape={{ curve: SURFACE_SHAPES.panel.curve }} radius={StyleSheet.flatten(style)?.borderRadius ?? 20} />}
|
|
565
570
|
<SurfaceLevelProvider level={material.level} fill={surfaceFill}>
|
|
566
571
|
{header ? (
|
|
567
572
|
// Nav-header mode: the Dialog OWNS a sticky gradient nav bar + a large
|
|
@@ -570,6 +575,7 @@ function DialogPanel({
|
|
|
570
575
|
// the shared scroll offset that drives the small-title cross-fade.
|
|
571
576
|
<>
|
|
572
577
|
<DialogNavHeader
|
|
578
|
+
flatSurface={surfaceMaterial === 'flat'}
|
|
573
579
|
controller={headerController}
|
|
574
580
|
header={header}
|
|
575
581
|
onDismiss={close}
|
|
@@ -634,6 +640,7 @@ function DialogPanel({
|
|
|
634
640
|
* implementation with native and supports drag-to-dismiss on web.
|
|
635
641
|
*/
|
|
636
642
|
function SheetSurface({
|
|
643
|
+
material: surfaceMaterial = 'surface',
|
|
637
644
|
panelRef,
|
|
638
645
|
testID,
|
|
639
646
|
label,
|
|
@@ -656,6 +663,7 @@ function SheetSurface({
|
|
|
656
663
|
style,
|
|
657
664
|
children,
|
|
658
665
|
}: {
|
|
666
|
+
material?: DialogProps['material'];
|
|
659
667
|
panelRef: React.RefObject<View | null>;
|
|
660
668
|
testID?: string;
|
|
661
669
|
label?: string;
|
|
@@ -751,7 +759,7 @@ function SheetSurface({
|
|
|
751
759
|
if (dismissOnBackdrop) onDismiss();
|
|
752
760
|
}, [dismissOnBackdrop, onDismiss]);
|
|
753
761
|
|
|
754
|
-
const material = resolveSurfaceMaterial({ fill: String(StyleSheet.flatten([panelStyle, style])?.backgroundColor ?? theme.colors.background), parentFill: theme.colors.background, level: 0 });
|
|
762
|
+
const material = resolveSurfaceMaterial({ fill: String(StyleSheet.flatten([panelStyle, style])?.backgroundColor ?? theme.colors.background), parentFill: theme.colors.background, level: 0, paint: surfaceMaterial !== 'flat' });
|
|
755
763
|
const { paintFill, publishedFill: surfaceFill } = material;
|
|
756
764
|
|
|
757
765
|
// The drawer uses the PAGE token as its tint and nominal surface for its
|
|
@@ -809,10 +817,10 @@ function SheetSurface({
|
|
|
809
817
|
panelTransition,
|
|
810
818
|
panelStyle,
|
|
811
819
|
style,
|
|
812
|
-
{ backgroundColor: 'transparent' },
|
|
820
|
+
{ backgroundColor: surfaceMaterial === 'flat' ? paintFill : 'transparent' },
|
|
813
821
|
]}
|
|
814
822
|
>
|
|
815
|
-
<SurfacePaint fill={paintFill} shape={{ curve: SURFACE_SHAPES.panel.curve }} radius={StyleSheet.flatten([panelStyle, style])?.borderRadius ?? SURFACE_SHAPES.panel.radius} />
|
|
823
|
+
{surfaceMaterial !== 'flat' && <SurfacePaint fill={paintFill} shape={{ curve: SURFACE_SHAPES.panel.curve }} radius={StyleSheet.flatten([panelStyle, style])?.borderRadius ?? SURFACE_SHAPES.panel.radius} />}
|
|
816
824
|
<SurfaceLevelProvider level={material.level} fill={surfaceFill}>
|
|
817
825
|
{header ? (
|
|
818
826
|
// Nav-header mode on a side drawer: a static titled bar (the drawer
|
|
@@ -820,6 +828,7 @@ function SheetSurface({
|
|
|
820
828
|
// the content, which is inset below the bar.
|
|
821
829
|
<View style={{ flex: 1, minHeight: 0 }}>
|
|
822
830
|
<DialogNavHeader
|
|
831
|
+
flatSurface={surfaceMaterial === 'flat'}
|
|
823
832
|
controller={headerController}
|
|
824
833
|
header={header}
|
|
825
834
|
onDismiss={onDismiss}
|
|
@@ -68,6 +68,7 @@ export function DialogBottomSheet({
|
|
|
68
68
|
description,
|
|
69
69
|
actions,
|
|
70
70
|
header,
|
|
71
|
+
material: surfaceMaterial = 'surface',
|
|
71
72
|
maxHeightRatio = DEFAULT_MAX_HEIGHT_RATIO,
|
|
72
73
|
showHandle = true,
|
|
73
74
|
dismissOnBackdrop = true,
|
|
@@ -254,6 +255,7 @@ export function DialogBottomSheet({
|
|
|
254
255
|
|
|
255
256
|
return (
|
|
256
257
|
<BottomSheet
|
|
258
|
+
material={surfaceMaterial}
|
|
257
259
|
accessibilityLabel={label ?? header?.title}
|
|
258
260
|
aria-labelledby={!header && title ? titleId : undefined}
|
|
259
261
|
aria-describedby={!header && description ? descriptionId : undefined}
|
|
@@ -293,6 +295,7 @@ export function DialogBottomSheet({
|
|
|
293
295
|
headerOverlay={
|
|
294
296
|
header ? (
|
|
295
297
|
<DialogNavHeader
|
|
298
|
+
flatSurface={surfaceMaterial === 'flat'}
|
|
296
299
|
controller={headerController}
|
|
297
300
|
header={header}
|
|
298
301
|
onDismiss={close}
|
|
@@ -392,6 +395,7 @@ export type DialogBottomSheetProps = Pick<
|
|
|
392
395
|
| 'description'
|
|
393
396
|
| 'actions'
|
|
394
397
|
| 'header'
|
|
398
|
+
| 'material'
|
|
395
399
|
| 'maxHeightRatio'
|
|
396
400
|
| 'showHandle'
|
|
397
401
|
| 'dismissOnBackdrop'
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
44
44
|
import { Item } from '../item';
|
|
45
45
|
import { useDialogControl } from './context';
|
|
46
|
+
import { useSurfaceFill } from '../styles/surface-levels';
|
|
46
47
|
import { useTheme } from '../theme/use-theme';
|
|
47
48
|
import { H1, Text } from '../typography';
|
|
48
49
|
import type { DialogHeaderConfig } from './types';
|
|
@@ -554,6 +555,7 @@ export const DialogNavHeader = memo(function DialogNavHeader({
|
|
|
554
555
|
header,
|
|
555
556
|
onDismiss,
|
|
556
557
|
collapse = true,
|
|
558
|
+
flatSurface = false,
|
|
557
559
|
style,
|
|
558
560
|
}: {
|
|
559
561
|
controller: DialogHeaderController;
|
|
@@ -566,9 +568,12 @@ export const DialogNavHeader = memo(function DialogNavHeader({
|
|
|
566
568
|
* collapse): the small title is then always visible — a plain titled nav bar.
|
|
567
569
|
*/
|
|
568
570
|
collapse?: boolean;
|
|
571
|
+
/** Internal propagation of the owning panel material. */
|
|
572
|
+
flatSurface?: boolean;
|
|
569
573
|
style?: StyleProp<ViewStyle>;
|
|
570
574
|
}) {
|
|
571
575
|
const theme = useTheme();
|
|
576
|
+
const surfaceFill = useSurfaceFill();
|
|
572
577
|
const common = useCommonMessages();
|
|
573
578
|
const config = useMergedHeaderConfig(header, controller.store);
|
|
574
579
|
const { scrollY, largeTitleHeight } = controller;
|
|
@@ -672,7 +677,8 @@ export const DialogNavHeader = memo(function DialogNavHeader({
|
|
|
672
677
|
scrimStyle,
|
|
673
678
|
]}
|
|
674
679
|
>
|
|
675
|
-
<
|
|
680
|
+
{flatSurface && !onImage ? <View style={{ height: DIALOG_NAV_BAR_HEIGHT, backgroundColor: surfaceFill }} />
|
|
681
|
+
: <NavScrim onImage={onImage} surface={theme.colors.background} />}
|
|
676
682
|
</Animated.View>
|
|
677
683
|
<View pointerEvents="box-none" style={styles.navRow}>
|
|
678
684
|
<View style={styles.side}>{left}</View>
|
|
@@ -25,6 +25,7 @@ import type { DialogControlProps } from './types';
|
|
|
25
25
|
import { useCommonMessages } from '../locale/common-messages';
|
|
26
26
|
|
|
27
27
|
export interface SheetShellProps {
|
|
28
|
+
material?: 'surface' | 'flat';
|
|
28
29
|
control: DialogControlProps;
|
|
29
30
|
label?: string;
|
|
30
31
|
header?: React.ReactNode;
|
|
@@ -43,6 +44,7 @@ export interface SheetShellProps {
|
|
|
43
44
|
* etc. rely on it to dismiss the sheet after selection.
|
|
44
45
|
*/
|
|
45
46
|
export function SheetShell({
|
|
47
|
+
material = 'surface',
|
|
46
48
|
control,
|
|
47
49
|
label,
|
|
48
50
|
header,
|
|
@@ -113,6 +115,8 @@ export function SheetShell({
|
|
|
113
115
|
|
|
114
116
|
return (
|
|
115
117
|
<BottomSheet
|
|
118
|
+
material={material}
|
|
119
|
+
backgroundFill={material === 'flat' ? String(StyleSheet.flatten(contentStyle)?.backgroundColor ?? theme.colors.background) : undefined}
|
|
116
120
|
ref={ref}
|
|
117
121
|
onDismiss={handleDismiss}
|
|
118
122
|
enablePanDownToClose
|
package/src/dialog/types.ts
CHANGED
|
@@ -231,6 +231,8 @@ export type DialogAction = {
|
|
|
231
231
|
* be a responsive map that collapses to a bottom-sheet on narrow viewports.
|
|
232
232
|
*/
|
|
233
233
|
export type DialogProps = React.PropsWithChildren<{
|
|
234
|
+
/** Standard optical surface, or a plain fill without refraction/sheen. Default surface. */
|
|
235
|
+
material?: 'surface' | 'flat';
|
|
234
236
|
/** Content owns paint and motion; shared overlay, focus and dismissal remain. */
|
|
235
237
|
presentation?: 'default' | 'custom';
|
|
236
238
|
/** Custom presentation exit lifetime, in milliseconds. */
|
|
@@ -190,6 +190,7 @@ function transformOriginFor(side: FloatingSide, align: string): string {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
export function FloatingPanel({
|
|
193
|
+
material: surfaceMaterial = 'surface',
|
|
193
194
|
open,
|
|
194
195
|
anchor,
|
|
195
196
|
side = 'bottom',
|
|
@@ -217,8 +218,8 @@ export function FloatingPanel({
|
|
|
217
218
|
const palette = useMenuPalette();
|
|
218
219
|
const ownFill = StyleSheet.flatten(style)?.backgroundColor ?? palette.surface;
|
|
219
220
|
const parsedFill = typeof ownFill === 'string' ? parseRgba(ownFill) : null;
|
|
220
|
-
const publishedFill = typeof ownFill === 'string' ? resolveSurfaceMaterial({ fill: ownFill, parentFill: parentFill }).publishedFill : undefined;
|
|
221
|
-
const materialStyle = useSurfaceMaterial('.bloom-floating-surface', 'bloom-floating-surface-css', typeof ownFill === 'string' ? ownFill : 'transparent');
|
|
221
|
+
const publishedFill = typeof ownFill === 'string' ? resolveSurfaceMaterial({ fill: ownFill, parentFill: parentFill, paint: surfaceMaterial !== 'flat' }).publishedFill : undefined;
|
|
222
|
+
const materialStyle = useSurfaceMaterial('.bloom-floating-surface', 'bloom-floating-surface-css', typeof ownFill === 'string' ? ownFill : 'transparent', surfaceMaterial !== 'flat');
|
|
222
223
|
const transparentFill = ownFill === 'transparent' || parsedFill?.a === 0;
|
|
223
224
|
// The mounted panel as STATE, not a bare ref: placement has to measure it,
|
|
224
225
|
// and `Portal` renders null on its first pass (it resolves its host in its own
|
|
@@ -517,7 +518,7 @@ export function FloatingPanel({
|
|
|
517
518
|
role={role}
|
|
518
519
|
aria-label={label}
|
|
519
520
|
testID={testID}
|
|
520
|
-
className={cx('bloom-floating-surface', chrome.className, className)}
|
|
521
|
+
className={cx(surfaceMaterial !== 'flat' && 'bloom-floating-surface', chrome.className, className)}
|
|
521
522
|
style={[
|
|
522
523
|
styles.panel,
|
|
523
524
|
PANEL_CURVE,
|
package/src/floating/types.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef, type KeyboardEvent } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/** RNW Pressable activates Enter for every role, but Space only for buttons.
|
|
5
|
+
* Checkbox/radio rows own the missing Space gesture. Native keeps Pressable's
|
|
6
|
+
* platform handling. Activation waits for keyup and is cancelled by blur. */
|
|
7
|
+
export function useChoiceSpaceKey(disabled: boolean, activate: () => void) {
|
|
8
|
+
const armed = useRef(false);
|
|
9
|
+
if (Platform.OS !== 'web') return {};
|
|
10
|
+
return {
|
|
11
|
+
onKeyDown(event: KeyboardEvent<HTMLElement>) {
|
|
12
|
+
if (event.key !== ' ' && event.key !== 'Spacebar') return;
|
|
13
|
+
if (event.target !== event.currentTarget || disabled) return;
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
if (!event.repeat) armed.current = true;
|
|
17
|
+
},
|
|
18
|
+
onKeyUp(event: KeyboardEvent<HTMLElement>) {
|
|
19
|
+
if (event.key !== ' ' && event.key !== 'Spacebar') return;
|
|
20
|
+
const wasArmed = armed.current;
|
|
21
|
+
armed.current = false;
|
|
22
|
+
if (event.target !== event.currentTarget || disabled || !wasArmed) return;
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
activate();
|
|
26
|
+
},
|
|
27
|
+
onBlur() { armed.current = false; },
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform, type StyleProp, type TextStyle } from 'react-native';
|
|
3
|
+
import { Text } from '../typography';
|
|
4
|
+
import { resolveNativeWebStyle } from '../styles/resolve-native-web-style';
|
|
5
|
+
|
|
6
|
+
/** The animated label and its measuring copy share one typography owner.
|
|
7
|
+
* RNW's unlayered Text reset would outrank a caller's layered recipe, so the
|
|
8
|
+
* web class slot uses a span. Native delegates class interop to Bloom Text. */
|
|
9
|
+
export function FollowLabel({ children, className, style, numberOfLines }: {
|
|
10
|
+
children: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: StyleProp<TextStyle>;
|
|
13
|
+
numberOfLines?: number;
|
|
14
|
+
}) {
|
|
15
|
+
if (Platform.OS === 'web' && className?.trim()) {
|
|
16
|
+
return <span className={className} style={{
|
|
17
|
+
display: 'block', fontFamily: 'var(--bloom-font-sans)',
|
|
18
|
+
...(numberOfLines === 1 && { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }),
|
|
19
|
+
...resolveNativeWebStyle(style),
|
|
20
|
+
}}>{children}</span>;
|
|
21
|
+
}
|
|
22
|
+
return <Text variant="body-semibold" className={className} style={style} numberOfLines={numberOfLines}>{children}</Text>;
|
|
23
|
+
}
|