@oxy.so/bloom 7.18.0 → 7.19.1
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 +8 -8
- package/docs/button.mdx +8 -0
- package/docs/carousel.mdx +28 -2
- package/docs/dialog.mdx +16 -0
- package/docs/popover.mdx +8 -0
- package/docs/radio.mdx +15 -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/button/Button.js +7 -2
- package/lib/commonjs/button/Button.js.map +1 -1
- package/lib/commonjs/button/Button.web.js +5 -1
- package/lib/commonjs/button/Button.web.js.map +1 -1
- package/lib/commonjs/carousel/Carousel.js +52 -15
- package/lib/commonjs/carousel/Carousel.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/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 +71 -33
- 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/button/Button.js +7 -2
- package/lib/module/button/Button.js.map +1 -1
- package/lib/module/button/Button.web.js +5 -1
- package/lib/module/button/Button.web.js.map +1 -1
- package/lib/module/carousel/Carousel.js +52 -15
- package/lib/module/carousel/Carousel.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/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 +72 -34
- 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/button/Button.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/Button.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/types.d.ts +7 -1
- package/lib/typescript/commonjs/button/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/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/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.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 +2 -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/button/Button.d.ts.map +1 -1
- package/lib/typescript/module/button/Button.web.d.ts.map +1 -1
- package/lib/typescript/module/button/types.d.ts +7 -1
- package/lib/typescript/module/button/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/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/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.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 +2 -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/button/Button.tsx +6 -2
- package/src/button/Button.web.tsx +5 -0
- package/src/button/types.ts +7 -1
- package/src/carousel/Carousel.tsx +46 -20
- package/src/carousel/types.ts +8 -2
- 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/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 +66 -33
- package/src/radio/RadioCard.tsx +4 -0
- package/src/radio/context.ts +9 -0
- package/src/radio/types.ts +2 -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
|
@@ -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
package/src/popover/Popover.tsx
CHANGED
|
@@ -73,6 +73,7 @@ export function PopoverTrigger({
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export function PopoverContent({
|
|
76
|
+
material,
|
|
76
77
|
children,
|
|
77
78
|
label: labelProp,
|
|
78
79
|
className,
|
|
@@ -86,6 +87,7 @@ export function PopoverContent({
|
|
|
86
87
|
|
|
87
88
|
return (
|
|
88
89
|
<SheetShell
|
|
90
|
+
material={material}
|
|
89
91
|
control={control}
|
|
90
92
|
label={label}
|
|
91
93
|
onClose={onSheetClose}
|
|
@@ -71,6 +71,7 @@ export function PopoverTrigger({
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export function PopoverContent({
|
|
74
|
+
material,
|
|
74
75
|
children,
|
|
75
76
|
label: labelProp,
|
|
76
77
|
side,
|
|
@@ -104,6 +105,7 @@ export function PopoverContent({
|
|
|
104
105
|
|
|
105
106
|
return (
|
|
106
107
|
<FloatingPanel
|
|
108
|
+
material={material}
|
|
107
109
|
open={popover.open}
|
|
108
110
|
anchor={anchor}
|
|
109
111
|
role="dialog"
|
package/src/popover/types.ts
CHANGED
|
@@ -8,7 +8,10 @@ import type {
|
|
|
8
8
|
|
|
9
9
|
export type PopoverProps = React.PropsWithChildren<OverlayOpenProps>;
|
|
10
10
|
export type PopoverTriggerProps = OverlayTriggerProps;
|
|
11
|
-
export type PopoverContentProps = OverlaySurfaceProps
|
|
11
|
+
export type PopoverContentProps = OverlaySurfaceProps & {
|
|
12
|
+
/** Standard optical surface or plain fill. Default surface. */
|
|
13
|
+
material?: 'surface' | 'flat';
|
|
14
|
+
};
|
|
12
15
|
|
|
13
16
|
/** Shared by the panel's layout parts. */
|
|
14
17
|
interface PopoverPartProps {
|
package/src/radio/Radio.tsx
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRadioGroupItem } from './use-radio-group-item';
|
|
2
|
+
import { RadioGroupContext } from './context';
|
|
3
|
+
import { useIsRtl } from '../hooks/use-is-rtl';
|
|
2
4
|
import { useControllableState } from '../hooks/use-controllable-state';
|
|
3
5
|
import { useBloomAppearance } from '../appearance';
|
|
4
6
|
import { resolveBloomColors } from '../appearance/colors';
|
|
5
|
-
import React, { memo, useCallback, useMemo } from 'react';
|
|
7
|
+
import React, { memo, useCallback, useMemo, useRef, type KeyboardEvent } from 'react';
|
|
6
8
|
import { View, Platform, Pressable } from 'react-native';
|
|
7
9
|
|
|
8
10
|
import { useTheme } from '../theme/use-theme';
|
|
@@ -147,7 +149,7 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
147
149
|
...ringOffset,
|
|
148
150
|
};
|
|
149
151
|
|
|
150
|
-
const spaceKey =
|
|
152
|
+
const spaceKey = useRadioGroupItem(value, isDisabled, handlePress);
|
|
151
153
|
|
|
152
154
|
return (
|
|
153
155
|
<Pressable
|
|
@@ -227,6 +229,7 @@ const RadioGroupComponent = function RadioGroup<Value extends string = string>(p
|
|
|
227
229
|
tone: toneProp,
|
|
228
230
|
style,
|
|
229
231
|
labelStyle,
|
|
232
|
+
optionStyle,
|
|
230
233
|
variant = 'default',
|
|
231
234
|
testID,
|
|
232
235
|
} = props;
|
|
@@ -241,46 +244,76 @@ const RadioGroupComponent = function RadioGroup<Value extends string = string>(p
|
|
|
241
244
|
const isDisabled = field.disabled;
|
|
242
245
|
const { size: scopedSize, tone } = useBloomAppearance({size: sizeProp, tone: toneProp}, {size: 'md', tone: 'accent'});
|
|
243
246
|
const size = scopedSize;
|
|
247
|
+
const rtl = useIsRtl();
|
|
248
|
+
const nodes = useRef(new Map<string, View>());
|
|
249
|
+
const enabledValues = options.filter(option => !isDisabled && !option.disabled).map(option => option.value);
|
|
250
|
+
const tabValue = value !== undefined && enabledValues.includes(value) ? value : enabledValues[0];
|
|
251
|
+
const register = useCallback((option: string, node: View | null) => {
|
|
252
|
+
if (node) nodes.current.set(option, node); else nodes.current.delete(option);
|
|
253
|
+
}, []);
|
|
254
|
+
const onKeyDown = (current: string, event: KeyboardEvent<HTMLElement>) => {
|
|
255
|
+
if (event.target !== event.currentTarget || event.altKey || event.ctrlKey || event.metaKey || !enabledValues.length) return;
|
|
256
|
+
const position = enabledValues.findIndex(option => option === current);
|
|
257
|
+
if (position < 0) return;
|
|
258
|
+
let target: Value | undefined;
|
|
259
|
+
if (event.key === 'Home') target = enabledValues[0];
|
|
260
|
+
else if (event.key === 'End') target = enabledValues[enabledValues.length - 1];
|
|
261
|
+
else {
|
|
262
|
+
const delta = event.key === 'ArrowDown' ? 1 : event.key === 'ArrowUp' ? -1
|
|
263
|
+
: event.key === 'ArrowRight' ? (rtl ? -1 : 1) : event.key === 'ArrowLeft' ? (rtl ? 1 : -1) : 0;
|
|
264
|
+
if (!delta) return;
|
|
265
|
+
target = enabledValues[(position + delta + enabledValues.length) % enabledValues.length];
|
|
266
|
+
}
|
|
267
|
+
if (target === undefined) return;
|
|
268
|
+
event.preventDefault(); event.stopPropagation();
|
|
269
|
+
const node: unknown = nodes.current.get(target);
|
|
270
|
+
if (typeof HTMLElement !== 'undefined' && node instanceof HTMLElement) node.focus({ preventScroll: true });
|
|
271
|
+
if (target !== value) onValueChange(target);
|
|
272
|
+
};
|
|
244
273
|
return (
|
|
245
|
-
<
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
274
|
+
<RadioGroupContext.Provider value={{ tabValue, register, onKeyDown }}>
|
|
275
|
+
<View
|
|
276
|
+
style={[{ gap: space.sm }, style]}
|
|
277
|
+
accessibilityRole="radiogroup"
|
|
278
|
+
accessibilityLabel={field.accessibilityLabel}
|
|
279
|
+
aria-label={field.accessibilityLabel}
|
|
280
|
+
aria-describedby={field.describedBy}
|
|
281
|
+
aria-invalid={field.invalid || undefined}
|
|
282
|
+
testID={testID}
|
|
283
|
+
>
|
|
284
|
+
{options.map((option) =>
|
|
285
|
+
variant === 'card' ? (
|
|
286
|
+
<RadioCard
|
|
287
|
+
key={option.value}
|
|
288
|
+
value={option.value}
|
|
289
|
+
checked={option.value === value}
|
|
290
|
+
onValueChange={onValueChange}
|
|
291
|
+
title={option.label ?? option.value}
|
|
292
|
+
description={option.description}
|
|
293
|
+
disabled={isDisabled || option.disabled === true}
|
|
294
|
+
tone={tone}
|
|
295
|
+
style={optionStyle}
|
|
296
|
+
testID={option.testID}
|
|
297
|
+
/>
|
|
298
|
+
) : (
|
|
299
|
+
<Radio
|
|
257
300
|
key={option.value}
|
|
258
301
|
value={option.value}
|
|
259
302
|
checked={option.value === value}
|
|
260
303
|
onValueChange={onValueChange}
|
|
261
|
-
|
|
304
|
+
label={option.label}
|
|
262
305
|
description={option.description}
|
|
306
|
+
size={size}
|
|
263
307
|
disabled={isDisabled || option.disabled === true}
|
|
264
308
|
tone={tone}
|
|
309
|
+
labelStyle={labelStyle}
|
|
310
|
+
style={optionStyle}
|
|
265
311
|
testID={option.testID}
|
|
266
312
|
/>
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
checked={option.value === value}
|
|
272
|
-
onValueChange={onValueChange}
|
|
273
|
-
label={option.label}
|
|
274
|
-
description={option.description}
|
|
275
|
-
size={size}
|
|
276
|
-
disabled={isDisabled || option.disabled === true}
|
|
277
|
-
tone={tone}
|
|
278
|
-
labelStyle={labelStyle}
|
|
279
|
-
testID={option.testID}
|
|
280
|
-
/>
|
|
281
|
-
),
|
|
282
|
-
)}
|
|
283
|
-
</View>
|
|
313
|
+
),
|
|
314
|
+
)}
|
|
315
|
+
</View>
|
|
316
|
+
</RadioGroupContext.Provider>
|
|
284
317
|
);
|
|
285
318
|
};
|
|
286
319
|
|
package/src/radio/RadioCard.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useRadioGroupItem } from './use-radio-group-item';
|
|
1
2
|
import { useFieldMembership } from '../field/membership';
|
|
2
3
|
import { useRingOffsetStyle } from '../styles/surface-levels';
|
|
3
4
|
import { useBloomAppearance } from '../appearance';
|
|
@@ -129,8 +130,11 @@ const RadioCardComponent = function RadioCard<Value extends string = string>({
|
|
|
129
130
|
: null),
|
|
130
131
|
};
|
|
131
132
|
|
|
133
|
+
const groupItem = useRadioGroupItem(value, disabled, handlePress);
|
|
134
|
+
|
|
132
135
|
return (
|
|
133
136
|
<Pressable
|
|
137
|
+
{...groupItem}
|
|
134
138
|
{...webDataSet({ bloomRadioCard: '' })}
|
|
135
139
|
style={[cardStyle, style]}
|
|
136
140
|
onPress={handlePress}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext, type KeyboardEvent } from 'react';
|
|
2
|
+
import type { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface RadioGroupContextValue {
|
|
5
|
+
tabValue: string | undefined;
|
|
6
|
+
register: (value: string, node: View | null) => void;
|
|
7
|
+
onKeyDown: (value: string, event: KeyboardEvent<HTMLElement>) => void;
|
|
8
|
+
}
|
|
9
|
+
export const RadioGroupContext = createContext<RadioGroupContextValue | null>(null);
|
package/src/radio/types.ts
CHANGED
|
@@ -78,6 +78,8 @@ export interface RadioGroupProps<Value extends string = string> {
|
|
|
78
78
|
tone?: BloomTone;
|
|
79
79
|
style?: StyleProp<ViewStyle>;
|
|
80
80
|
labelStyle?: StyleProp<TextStyle>;
|
|
81
|
+
/** Layout/style on each owned Radio or RadioCard row. */
|
|
82
|
+
optionStyle?: StyleProp<ViewStyle>;
|
|
81
83
|
/**
|
|
82
84
|
* `default` renders each option as a `Radio` row; `card` as a `RadioCard`
|
|
83
85
|
* (title + description left, the dot right, the whole
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback, useContext, type KeyboardEvent } from 'react';
|
|
2
|
+
import { Platform, type View } from 'react-native';
|
|
3
|
+
import { useChoiceSpaceKey } from '../hooks/use-choice-space-key';
|
|
4
|
+
import { RadioGroupContext } from './context';
|
|
5
|
+
|
|
6
|
+
/** One host owns both Space activation and its group's roving keyboard focus. */
|
|
7
|
+
export function useRadioGroupItem(value: string, disabled: boolean, activate: () => void) {
|
|
8
|
+
const group = useContext(RadioGroupContext);
|
|
9
|
+
const space = useChoiceSpaceKey(disabled, activate);
|
|
10
|
+
const ref = useCallback((node: View | null) => group?.register(value, node), [group, value]);
|
|
11
|
+
if (Platform.OS !== 'web') return {};
|
|
12
|
+
return {
|
|
13
|
+
...space,
|
|
14
|
+
...(group ? { ref, tabIndex: !disabled && group.tabValue === value ? 0 : -1 } : {}),
|
|
15
|
+
onKeyDown(event: KeyboardEvent<HTMLElement>) {
|
|
16
|
+
space.onKeyDown?.(event);
|
|
17
|
+
if (!disabled && !event.defaultPrevented) group?.onKeyDown(value, event);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
package/src/search/Search.tsx
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { forwardRef, useCallback, useMemo, useRef } from 'react';
|
|
2
|
-
import { Platform, type TextInput
|
|
1
|
+
import { forwardRef, useCallback, useContext, useMemo, useRef } from 'react';
|
|
2
|
+
import { Platform, type TextInput } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import { useFieldMembership } from '../field/membership';
|
|
5
|
+
import { TextFieldGroupContext } from '../text-field/TextField';
|
|
4
6
|
import { mergeRefs } from '../hooks/merge-refs';
|
|
5
7
|
import { FieldBox } from '../text-field/FieldBox';
|
|
6
8
|
import type { SearchProps } from './types';
|
|
7
|
-
import { useDirectionProps
|
|
9
|
+
import { useDirectionProps } from '../hooks/use-is-rtl';
|
|
8
10
|
import { useCommonMessages } from '../locale/common-messages';
|
|
9
11
|
import { useMessages } from '../locale/messages';
|
|
10
12
|
import { SEARCH_MESSAGES } from './messages';
|
|
@@ -18,10 +20,12 @@ import { RiSearchLine as MagnifyingGlassIcon } from '../icons/remix/RiSearchLine
|
|
|
18
20
|
import { RiCloseLine as X } from '../icons/remix/RiCloseLine';
|
|
19
21
|
|
|
20
22
|
export const Search = forwardRef<TextInput, SearchProps>(
|
|
21
|
-
function Search({ value, label: labelProp, onClearText, onFocus, onPressIn, fieldClassName, fieldChromeClassName, containerClassName, containerStyle, ...rest }, ref) {
|
|
23
|
+
function Search({ value, label: labelProp, onClearText, onFocus, onPressIn, iconSize, clearButtonProps, disabled, style, fieldClassName, fieldChromeClassName, containerClassName, containerStyle, ...rest }, ref) {
|
|
22
24
|
const theme = useTheme();
|
|
23
25
|
const direction = useDirectionProps();
|
|
24
|
-
const
|
|
26
|
+
const field = useFieldMembership({ disabled });
|
|
27
|
+
const group = useContext(TextFieldGroupContext);
|
|
28
|
+
const isDisabled = field.disabled || group?.disabled === true;
|
|
25
29
|
const common = useCommonMessages();
|
|
26
30
|
const { messages } = useMessages(SEARCH_MESSAGES);
|
|
27
31
|
const label = labelProp ?? common.search;
|
|
@@ -64,8 +68,8 @@ export const Search = forwardRef<TextInput, SearchProps>(
|
|
|
64
68
|
|
|
65
69
|
return (
|
|
66
70
|
<FieldBox {...direction} className={containerClassName} style={containerStyle} baseStyle={[a.w_full, a.relative]}>
|
|
67
|
-
<TextField radius={borderRadius.full} className={fieldClassName} chromeClassName={fieldChromeClassName}>
|
|
68
|
-
<TextFieldIcon icon={MagnifyingGlassIcon} />
|
|
71
|
+
<TextField disabled={isDisabled} radius={borderRadius.full} className={fieldClassName} chromeClassName={fieldChromeClassName}>
|
|
72
|
+
<TextFieldIcon icon={MagnifyingGlassIcon} size={iconSize} />
|
|
69
73
|
<TextFieldInput
|
|
70
74
|
inputRef={refs}
|
|
71
75
|
label={label}
|
|
@@ -78,35 +82,24 @@ export const Search = forwardRef<TextInput, SearchProps>(
|
|
|
78
82
|
autoCorrect={false}
|
|
79
83
|
autoComplete="off"
|
|
80
84
|
autoCapitalize="none"
|
|
81
|
-
style={showClear ? (rtl ? { paddingLeft: 24 } : { paddingRight: 24 }) : undefined}
|
|
82
85
|
{...rest}
|
|
86
|
+
disabled={isDisabled}
|
|
87
|
+
style={style}
|
|
83
88
|
onPressIn={handlePressIn}
|
|
84
89
|
onFocus={handleFocus}
|
|
85
90
|
/>
|
|
91
|
+
{showClear && <GlyphButton
|
|
92
|
+
size={28}
|
|
93
|
+
icon={X}
|
|
94
|
+
glyphSize={16}
|
|
95
|
+
{...clearButtonProps}
|
|
96
|
+
testID="searchTextInputClearBtn"
|
|
97
|
+
onPress={onClearText}
|
|
98
|
+
accessibilityLabel={messages.clearQuery}
|
|
99
|
+
disabled={isDisabled}
|
|
100
|
+
style={{ marginInlineStart: 8 }}
|
|
101
|
+
/>}
|
|
86
102
|
</TextField>
|
|
87
|
-
|
|
88
|
-
{showClear && (
|
|
89
|
-
<View
|
|
90
|
-
style={[
|
|
91
|
-
a.absolute,
|
|
92
|
-
a.z_20,
|
|
93
|
-
a.my_auto,
|
|
94
|
-
a.justify_center,
|
|
95
|
-
{ top: 0, bottom: 0, insetInlineEnd: 0, paddingInlineEnd: 8 },
|
|
96
|
-
]}>
|
|
97
|
-
{/* Neutral and transparent. `variant="ghost"` painted an accent
|
|
98
|
-
wash inside the field, which read as a state the field was not
|
|
99
|
-
in. */}
|
|
100
|
-
<GlyphButton
|
|
101
|
-
testID="searchTextInputClearBtn"
|
|
102
|
-
onPress={onClearText}
|
|
103
|
-
accessibilityLabel={messages.clearQuery}
|
|
104
|
-
size={28}
|
|
105
|
-
icon={X}
|
|
106
|
-
glyphSize={16}
|
|
107
|
-
/>
|
|
108
|
-
</View>
|
|
109
|
-
)}
|
|
110
103
|
</FieldBox>
|
|
111
104
|
);
|
|
112
105
|
},
|
package/src/search/types.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import type { GlyphButtonProps } from '../button/types';
|
|
2
3
|
import type { TextFieldInputProps } from '../text-field/types';
|
|
3
4
|
|
|
4
5
|
export type SearchProps = Omit<TextFieldInputProps, 'label'> & {
|
|
5
6
|
label?: TextFieldInputProps['label'];
|
|
7
|
+
/** Leading icon edge in pixels. Default 20. */
|
|
8
|
+
iconSize?: number;
|
|
9
|
+
/** Clear glyph/target geometry. Search owns its name, callback and disabled state. */
|
|
10
|
+
clearButtonProps?: Pick<GlyphButtonProps, 'icon' | 'size' | 'glyphSize'>;
|
|
6
11
|
/** Called when the user presses the clear button. */
|
|
7
12
|
onClearText?: () => void;
|
|
8
13
|
/** Field layout classes (height, width and padding). */
|
|
@@ -7,16 +7,16 @@ import { resolveSurfaceOptics, resolveSurfaceTint } from './shared';
|
|
|
7
7
|
import { surfaceMaterialCss } from './web-material';
|
|
8
8
|
|
|
9
9
|
/** Move a web host fill into the shared body and edge paint; preserve layout and shadow. */
|
|
10
|
-
export function useSurfaceMaterial(selector: string, id: string, fill: string): WebCssStyle {
|
|
11
|
-
useSurfaceRefraction(
|
|
10
|
+
export function useSurfaceMaterial(selector: string, id: string, fill: string, enabled = true): WebCssStyle {
|
|
11
|
+
useSurfaceRefraction(enabled);
|
|
12
12
|
const css = useMemo(() => `${selector} { isolation: isolate; }\n${surfaceMaterialCss(selector, 'var(--bloom-surface-fill)')}`, [selector]);
|
|
13
13
|
useInteractiveWebCss(id, css);
|
|
14
14
|
const theme = useContext(BloomThemeContext)?.theme;
|
|
15
15
|
const optics = resolveSurfaceOptics(theme?.isDark ?? false);
|
|
16
|
-
return useMemo(() => ({
|
|
16
|
+
return useMemo(() => enabled ? ({
|
|
17
17
|
backgroundColor: 'transparent',
|
|
18
18
|
'--bloom-surface-fill': resolveSurfaceTint(fill),
|
|
19
19
|
'--bloom-surface-rim': optics.rim,
|
|
20
20
|
'--bloom-surface-sheen': optics.sheenCss,
|
|
21
|
-
}), [optics, fill]);
|
|
21
|
+
}) : {}, [optics, fill, enabled]);
|
|
22
22
|
}
|
|
@@ -474,7 +474,7 @@ export function TextFieldInput({
|
|
|
474
474
|
// OVERRIDE it — so when the field has a text label the two must be the same
|
|
475
475
|
// string rather than two spellings of it. On native there is no association
|
|
476
476
|
// at all and this prop is the only name the control has.
|
|
477
|
-
const accessibleName = field?.labelText ?? label;
|
|
477
|
+
const accessibleName = rest.accessibilityLabel ?? field?.labelText ?? label;
|
|
478
478
|
const webDisabled = IS_WEB && fieldDisabled ? ({ disabled: true } as Record<string, unknown>) : undefined;
|
|
479
479
|
const reveal = canReveal ? (
|
|
480
480
|
<RevealButton
|
|
@@ -527,7 +527,7 @@ export function TextFieldInput({
|
|
|
527
527
|
fontWeight: TEXT_FIELD_TEXT.fontWeight,
|
|
528
528
|
color: fieldDisabled ? ctx.palette.textDisabled : ctx.palette.text,
|
|
529
529
|
minWidth: 0,
|
|
530
|
-
// Longhands, so
|
|
530
|
+
// Longhands, so caller-authored physical padding wins on
|
|
531
531
|
// web too — `paddingHorizontal` becomes `padding-inline`, which outranks it.
|
|
532
532
|
// Resolve against the field's layout direction, not the input's automatic
|
|
533
533
|
// text direction (an English query may live inside an Arabic interface).
|
|
@@ -918,7 +918,7 @@ export function TextFieldHint({
|
|
|
918
918
|
* disabled, red when it is invalid. The icon does not react to hover or
|
|
919
919
|
* focus; the ring does.
|
|
920
920
|
*/
|
|
921
|
-
export function TextFieldIcon({ icon: Comp, position = 'leading' }: TextFieldIconProps) {
|
|
921
|
+
export function TextFieldIcon({ icon: Comp, position = 'leading', size = 20 }: TextFieldIconProps) {
|
|
922
922
|
const ctx = useTextFieldContext();
|
|
923
923
|
const color = resolveIconColor(ctx.palette, {
|
|
924
924
|
invalid: ctx.invalid,
|
|
@@ -934,7 +934,8 @@ export function TextFieldIcon({ icon: Comp, position = 'leading' }: TextFieldIco
|
|
|
934
934
|
: { marginInlineStart: TEXT_FIELD_TRAILING_GAP },
|
|
935
935
|
]}>
|
|
936
936
|
<Comp
|
|
937
|
-
size
|
|
937
|
+
width={size}
|
|
938
|
+
height={size}
|
|
938
939
|
style={[
|
|
939
940
|
{
|
|
940
941
|
color,
|
package/src/text-field/types.ts
CHANGED
|
@@ -105,8 +105,10 @@ export type TextFieldHintProps = React.PropsWithChildren<
|
|
|
105
105
|
>;
|
|
106
106
|
|
|
107
107
|
export interface TextFieldIconProps {
|
|
108
|
-
/** A Bloom icon component
|
|
108
|
+
/** A Bloom icon component. */
|
|
109
109
|
icon: React.ComponentType<SVGIconProps>;
|
|
110
|
+
/** Icon edge in pixels. Default 20. */
|
|
111
|
+
size?: number;
|
|
110
112
|
/** `leading` (default) sits 2px before the input; `trailing` 8px after it. */
|
|
111
113
|
position?: 'leading' | 'trailing';
|
|
112
114
|
}
|