@oxy.so/bloom 7.24.2 → 7.26.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/README.md +9 -3
- package/docs/adoption-matrix.mdx +4 -4
- package/docs/overlay.mdx +5 -0
- package/docs/radio.mdx +32 -0
- package/docs/theme.mdx +65 -12
- package/lib/commonjs/ai-chat/AiChatShell.js +2 -0
- package/lib/commonjs/ai-chat/AiChatShell.js.map +1 -1
- package/lib/commonjs/ai-chat/use-panel-interaction.js +6 -1
- package/lib/commonjs/ai-chat/use-panel-interaction.js.map +1 -1
- package/lib/commonjs/overlay/modal-keyboard.js +10 -2
- package/lib/commonjs/overlay/modal-keyboard.js.map +1 -1
- package/lib/commonjs/radio/Radio.js +63 -16
- package/lib/commonjs/radio/Radio.js.map +1 -1
- package/lib/commonjs/radio/RadioCard.js +14 -5
- package/lib/commonjs/radio/RadioCard.js.map +1 -1
- package/lib/commonjs/radio/RadioChip.js +169 -0
- package/lib/commonjs/radio/RadioChip.js.map +1 -0
- package/lib/commonjs/radio/RadioHost.js +153 -0
- package/lib/commonjs/radio/RadioHost.js.map +1 -0
- package/lib/commonjs/radio/index.js +7 -0
- package/lib/commonjs/radio/index.js.map +1 -1
- package/lib/module/ai-chat/AiChatShell.js +2 -0
- package/lib/module/ai-chat/AiChatShell.js.map +1 -1
- package/lib/module/ai-chat/use-panel-interaction.js +6 -1
- package/lib/module/ai-chat/use-panel-interaction.js.map +1 -1
- package/lib/module/overlay/modal-keyboard.js +10 -2
- package/lib/module/overlay/modal-keyboard.js.map +1 -1
- package/lib/module/radio/Radio.js +65 -18
- package/lib/module/radio/Radio.js.map +1 -1
- package/lib/module/radio/RadioCard.js +15 -6
- package/lib/module/radio/RadioCard.js.map +1 -1
- package/lib/module/radio/RadioChip.js +164 -0
- package/lib/module/radio/RadioChip.js.map +1 -0
- package/lib/module/radio/RadioHost.js +147 -0
- package/lib/module/radio/RadioHost.js.map +1 -0
- package/lib/module/radio/index.js +1 -0
- package/lib/module/radio/index.js.map +1 -1
- package/lib/typescript/commonjs/ai-chat/AiChatShell.d.ts.map +1 -1
- package/lib/typescript/commonjs/ai-chat/use-panel-interaction.d.ts.map +1 -1
- package/lib/typescript/commonjs/overlay/modal-keyboard.d.ts +2 -1
- package/lib/typescript/commonjs/overlay/modal-keyboard.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 +1 -1
- package/lib/typescript/commonjs/radio/RadioCard.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/RadioChip.d.ts +5 -0
- package/lib/typescript/commonjs/radio/RadioChip.d.ts.map +1 -0
- package/lib/typescript/commonjs/radio/RadioHost.d.ts +59 -0
- package/lib/typescript/commonjs/radio/RadioHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/radio/index.d.ts +2 -1
- package/lib/typescript/commonjs/radio/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/types.d.ts +22 -4
- package/lib/typescript/commonjs/radio/types.d.ts.map +1 -1
- package/lib/typescript/module/ai-chat/AiChatShell.d.ts.map +1 -1
- package/lib/typescript/module/ai-chat/use-panel-interaction.d.ts.map +1 -1
- package/lib/typescript/module/overlay/modal-keyboard.d.ts +2 -1
- package/lib/typescript/module/overlay/modal-keyboard.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 +1 -1
- package/lib/typescript/module/radio/RadioCard.d.ts.map +1 -1
- package/lib/typescript/module/radio/RadioChip.d.ts +5 -0
- package/lib/typescript/module/radio/RadioChip.d.ts.map +1 -0
- package/lib/typescript/module/radio/RadioHost.d.ts +59 -0
- package/lib/typescript/module/radio/RadioHost.d.ts.map +1 -0
- package/lib/typescript/module/radio/index.d.ts +2 -1
- package/lib/typescript/module/radio/index.d.ts.map +1 -1
- package/lib/typescript/module/radio/types.d.ts +22 -4
- package/lib/typescript/module/radio/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ai-chat/AiChatShell.tsx +2 -0
- package/src/ai-chat/use-panel-interaction.ts +5 -1
- package/src/overlay/modal-keyboard.ts +8 -2
- package/src/radio/Radio.tsx +45 -15
- package/src/radio/RadioCard.tsx +11 -6
- package/src/radio/RadioChip.tsx +84 -0
- package/src/radio/RadioHost.tsx +94 -0
- package/src/radio/index.ts +2 -1
- package/src/radio/types.ts +23 -4
package/src/radio/RadioCard.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { useRingOffsetStyle } from '../styles/surface-levels';
|
|
|
4
4
|
import { useBloomAppearance } from '../appearance';
|
|
5
5
|
import { resolveBloomColors } from '../appearance/colors';
|
|
6
6
|
import React, { memo, useCallback, useMemo } from 'react';
|
|
7
|
-
import { Platform,
|
|
7
|
+
import { Platform, View } from 'react-native';
|
|
8
8
|
|
|
9
9
|
import { useTheme } from '../theme/use-theme';
|
|
10
10
|
import { Text } from '../typography';
|
|
@@ -15,6 +15,7 @@ import type { WebCssStyle } from '../styles/web-view-style';
|
|
|
15
15
|
import { webDataSet } from '../styles/web-data';
|
|
16
16
|
import { RadioIndicator } from '../radio-indicator';
|
|
17
17
|
import type { RadioCardProps } from './types';
|
|
18
|
+
import { RadioHost, RadioLabel } from './RadioHost';
|
|
18
19
|
import { DISABLED_OPACITY } from '../styles/tokens';
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -72,6 +73,9 @@ const RadioCardComponent = function RadioCard<Value extends string = string>({
|
|
|
72
73
|
disabled: disabledProp = false,
|
|
73
74
|
tone: toneProp,
|
|
74
75
|
style,
|
|
76
|
+
className,
|
|
77
|
+
labelClassName,
|
|
78
|
+
labelStyle,
|
|
75
79
|
accessibilityLabel,
|
|
76
80
|
testID,
|
|
77
81
|
}: RadioCardProps<Value>) {
|
|
@@ -134,10 +138,11 @@ const RadioCardComponent = function RadioCard<Value extends string = string>({
|
|
|
134
138
|
const groupItem = useRadioGroupItem(value, disabled, handlePress);
|
|
135
139
|
|
|
136
140
|
return (
|
|
137
|
-
<
|
|
141
|
+
<RadioHost
|
|
142
|
+
className={className}
|
|
138
143
|
{...groupItem}
|
|
139
144
|
{...webDataSet({ bloomRadioCard: '' })}
|
|
140
|
-
style={[cardStyle, style]}
|
|
145
|
+
style={[className ? { '--bloom-radio-ring': paint.ring, ...ringOffset } : cardStyle, style]}
|
|
141
146
|
onPress={handlePress}
|
|
142
147
|
onPressIn={disabled ? undefined : onPressIn}
|
|
143
148
|
onPressOut={disabled ? undefined : onPressOut}
|
|
@@ -155,9 +160,9 @@ const RadioCardComponent = function RadioCard<Value extends string = string>({
|
|
|
155
160
|
testID={testID}
|
|
156
161
|
>
|
|
157
162
|
<View style={{ flexDirection: 'column', gap: 2, minWidth: 0, flexShrink: 1 }}>
|
|
158
|
-
{labelContent != null ? <View pointerEvents="none" aria-hidden accessibilityElementsHidden importantForAccessibility="no-hide-descendants">{labelContent}</View> : <
|
|
163
|
+
{labelContent != null ? <View pointerEvents="none" aria-hidden accessibilityElementsHidden importantForAccessibility="no-hide-descendants">{labelContent}</View> : <RadioLabel className={labelClassName} variant="body-medium" numberOfLines={1} style={[!labelClassName && { color: paint.title }, labelStyle]}>
|
|
159
164
|
{title}
|
|
160
|
-
</
|
|
165
|
+
</RadioLabel>}
|
|
161
166
|
{description != null && (
|
|
162
167
|
<Text variant="body-regular" numberOfLines={1} style={{ color: paint.description }}>
|
|
163
168
|
{description}
|
|
@@ -172,7 +177,7 @@ const RadioCardComponent = function RadioCard<Value extends string = string>({
|
|
|
172
177
|
<RadioIndicator selected={checked} size={DOT_SIZE} selectedColor={color} selectedForeground={foreground} />
|
|
173
178
|
</View>
|
|
174
179
|
</View>
|
|
175
|
-
</
|
|
180
|
+
</RadioHost>
|
|
176
181
|
);
|
|
177
182
|
};
|
|
178
183
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useBloomAppearance } from '../appearance';
|
|
4
|
+
import { resolveBloomColors } from '../appearance/colors';
|
|
5
|
+
import { useFieldMembership } from '../field/membership';
|
|
6
|
+
import { useInteractionState } from '../hooks/use-interaction-state';
|
|
7
|
+
import { interactiveWebCss, useInteractiveWebCss } from '../styles/interactive-web-css';
|
|
8
|
+
import { RadioHost, RadioLabel } from './RadioHost';
|
|
9
|
+
import { useRingOffsetStyle } from '../styles/surface-levels';
|
|
10
|
+
import { DISABLED_OPACITY, borderRadius } from '../styles/tokens';
|
|
11
|
+
import { webDataSet } from '../styles/web-data';
|
|
12
|
+
import type { WebCssStyle } from '../styles/web-view-style';
|
|
13
|
+
import { pressedSurface } from '../theme/press-colors';
|
|
14
|
+
import { useTheme } from '../theme/use-theme';
|
|
15
|
+
import { useRadioGroupItem } from './use-radio-group-item';
|
|
16
|
+
import type { RadioChipProps, RadioSize } from './types';
|
|
17
|
+
|
|
18
|
+
const HEIGHT: Record<RadioSize, number> = { xs: 32, sm: 36, md: 40, lg: 44 };
|
|
19
|
+
const CSS = interactiveWebCss({
|
|
20
|
+
selector: '[data-bloom-radio-chip]', varPrefix: 'bloom-radio-chip', reset: 'none',
|
|
21
|
+
transition: 'background-color 120ms ease, border-color 120ms ease',
|
|
22
|
+
disabled: { opacity: null },
|
|
23
|
+
extraRules: '@media (prefers-reduced-motion: reduce) { [data-bloom-radio-chip] { transition: none !important; } }',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function RadioChipComponent<Value extends string = string>({
|
|
27
|
+
value, checked = false, onValueChange, label, labelContent, description,
|
|
28
|
+
accessibilityLabel, nativeID, disabled: disabledProp = false, size: sizeProp,
|
|
29
|
+
tone: toneProp, appearance = 'outline', className, labelClassName, style,
|
|
30
|
+
labelStyle, testID,
|
|
31
|
+
}: RadioChipProps<Value>) {
|
|
32
|
+
const theme = useTheme();
|
|
33
|
+
const field = useFieldMembership({ accessibilityLabel, label, labelPlacement: 'adjacent', disabled: disabledProp, nativeID });
|
|
34
|
+
const disabled = field.disabled;
|
|
35
|
+
const { size, tone } = useBloomAppearance({ size: sizeProp, tone: toneProp }, { size: 'md', tone: 'neutral' });
|
|
36
|
+
const height = HEIGHT[size];
|
|
37
|
+
const resolved = resolveBloomColors(theme.colors, tone, appearance);
|
|
38
|
+
const selected = tone === 'neutral' && (appearance === 'outline' || appearance === 'plain')
|
|
39
|
+
? { ...resolved, foreground: theme.colors.text, border: appearance === 'outline' ? theme.colors.text : 'transparent' }
|
|
40
|
+
: resolved;
|
|
41
|
+
const foreground = checked ? selected.foreground : theme.colors.text;
|
|
42
|
+
const background = checked ? selected.background : 'transparent';
|
|
43
|
+
const border = appearance === 'plain' ? 'transparent' : checked ? selected.border : theme.colors.borderLight;
|
|
44
|
+
const { state: hovered, onIn: onHoverIn, onOut: onHoverOut } = useInteractionState();
|
|
45
|
+
const { state: pressed, onIn: onPressIn, onOut: onPressOut } = useInteractionState();
|
|
46
|
+
const highlighted = !disabled && (hovered || pressed);
|
|
47
|
+
const ringOffset = useRingOffsetStyle();
|
|
48
|
+
useInteractiveWebCss('bloom-radio-chip-web-css', CSS);
|
|
49
|
+
const activate = useCallback(() => {
|
|
50
|
+
if (!disabled && !checked) onValueChange?.(value);
|
|
51
|
+
}, [checked, disabled, onValueChange, value]);
|
|
52
|
+
const groupItem = useRadioGroupItem(value, disabled, activate);
|
|
53
|
+
const defaultStyle: WebCssStyle = {
|
|
54
|
+
...(!className ? {
|
|
55
|
+
minHeight: height, minWidth: height, borderRadius: borderRadius.full,
|
|
56
|
+
borderWidth: 1, borderColor: border,
|
|
57
|
+
backgroundColor: highlighted ? pressedSurface(theme.colors, background, foreground) : background,
|
|
58
|
+
paddingLeft: size === 'xs' ? 10 : 14, paddingRight: size === 'xs' ? 10 : 14,
|
|
59
|
+
paddingTop: 6, paddingBottom: 6,
|
|
60
|
+
flexDirection: 'row', alignItems: 'center', justifyContent: 'center',
|
|
61
|
+
alignSelf: 'flex-start', flexShrink: 0,
|
|
62
|
+
opacity: disabled ? DISABLED_OPACITY : 1,
|
|
63
|
+
} as const : {}),
|
|
64
|
+
'--bloom-radio-chip-ring': theme.colors.primary,
|
|
65
|
+
...ringOffset,
|
|
66
|
+
};
|
|
67
|
+
return <RadioHost
|
|
68
|
+
{...groupItem} {...webDataSet({ bloomRadioChip: '' })}
|
|
69
|
+
className={className} style={[defaultStyle, style]}
|
|
70
|
+
onPress={activate} onPressIn={onPressIn} onPressOut={onPressOut}
|
|
71
|
+
onHoverIn={onHoverIn} onHoverOut={onHoverOut}
|
|
72
|
+
disabled={disabled} accessibilityRole="radio" aria-checked={checked}
|
|
73
|
+
aria-disabled={disabled || undefined} aria-invalid={field.invalid || undefined}
|
|
74
|
+
accessibilityLabel={field.accessibilityLabel} accessibilityHint={description}
|
|
75
|
+
nativeID={field.nativeID} aria-describedby={field.describedBy} testID={testID}
|
|
76
|
+
hitSlop={Math.max(0, (44 - height) / 2)}
|
|
77
|
+
>
|
|
78
|
+
{labelContent != null ? <View pointerEvents="none" aria-hidden accessibilityElementsHidden importantForAccessibility="no-hide-descendants">{labelContent}</View>
|
|
79
|
+
: <RadioLabel className={labelClassName} variant={size === 'xs' || size === 'sm' ? 'body-2-medium' : 'body-medium'}
|
|
80
|
+
style={[!labelClassName && { color: foreground, ...(checked && appearance === 'plain' ? { textDecorationLine: 'underline' as const } : {}) }, labelStyle]}>{label}</RadioLabel>}
|
|
81
|
+
</RadioHost>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const RadioChip = memo(RadioChipComponent) as typeof RadioChipComponent;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { forwardRef, type KeyboardEvent, type ReactNode } from 'react';
|
|
2
|
+
import { Platform, type View, type StyleProp, type ViewStyle, type TextStyle } from 'react-native';
|
|
3
|
+
import { StyledPressable, StyledView } from '../styles/styled-primitives';
|
|
4
|
+
import { resolveNativeWebStyle } from '../styles/resolve-native-web-style';
|
|
5
|
+
import { useInteractiveWebCss } from '../styles/interactive-web-css';
|
|
6
|
+
import { Text } from '../typography';
|
|
7
|
+
import { TYPE_SCALE, type TypeScaleVariant } from '../typography/scale';
|
|
8
|
+
|
|
9
|
+
// RNW's unlayered View reset outranks consumer @layer classes. Radio owns its
|
|
10
|
+
// small DOM hosts so authored classes keep authority, while native uses styled
|
|
11
|
+
// primitives and the same styles/selection logic.
|
|
12
|
+
const BASE = `@layer base {
|
|
13
|
+
.bloom-radio-host { box-sizing:border-box; display:flex; flex-shrink:0; min-width:0; border:0 solid; padding:0; margin:0; background:transparent; font:inherit; text-align:start; }
|
|
14
|
+
.bloom-radio-group { display:flex; flex-direction:column; min-width:0; }
|
|
15
|
+
.bloom-radio-label { font-family:var(--bloom-font-sans); white-space:pre-wrap; overflow-wrap:break-word; }
|
|
16
|
+
}`;
|
|
17
|
+
interface HostProps {
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
accessibilityRole?: 'radio';
|
|
23
|
+
accessibilityLabel?: string;
|
|
24
|
+
accessibilityHint?: string;
|
|
25
|
+
nativeID?: string;
|
|
26
|
+
testID?: string;
|
|
27
|
+
hitSlop?: number | { top: number; bottom: number; left: number; right: number };
|
|
28
|
+
dataSet?: Record<string, string>;
|
|
29
|
+
'aria-checked'?: boolean;
|
|
30
|
+
'aria-disabled'?: boolean;
|
|
31
|
+
'aria-invalid'?: boolean;
|
|
32
|
+
'aria-describedby'?: string;
|
|
33
|
+
tabIndex?: 0 | -1;
|
|
34
|
+
onPress: () => void;
|
|
35
|
+
onPressIn?: () => void;
|
|
36
|
+
onPressOut?: () => void;
|
|
37
|
+
onHoverIn?: () => void;
|
|
38
|
+
onHoverOut?: () => void;
|
|
39
|
+
onBlur?: () => void;
|
|
40
|
+
onKeyDown?: (event: KeyboardEvent<HTMLElement>) => void;
|
|
41
|
+
onKeyUp?: (event: KeyboardEvent<HTMLElement>) => void;
|
|
42
|
+
}
|
|
43
|
+
export const RadioHost = forwardRef<View, HostProps>(function RadioHost(props, ref) {
|
|
44
|
+
useInteractiveWebCss('bloom-radio-host', BASE);
|
|
45
|
+
if (Platform.OS !== 'web') return <StyledPressable {...props} ref={ref} />;
|
|
46
|
+
const { children, className, style, disabled, accessibilityLabel, accessibilityHint,
|
|
47
|
+
nativeID, testID, dataSet, onPress, onPressIn, onPressOut, onHoverIn, onHoverOut,
|
|
48
|
+
onBlur, onKeyDown, onKeyUp, tabIndex } = props;
|
|
49
|
+
const data = Object.fromEntries(Object.entries(dataSet ?? {}).map(([key, value]) =>
|
|
50
|
+
[`data-${key.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)}`, value]));
|
|
51
|
+
return <button ref={ref as unknown as React.Ref<HTMLButtonElement>} type="button" role="radio"
|
|
52
|
+
{...data} id={nativeID} data-testid={testID} disabled={disabled} tabIndex={tabIndex}
|
|
53
|
+
aria-label={accessibilityLabel} aria-description={accessibilityHint}
|
|
54
|
+
aria-checked={props['aria-checked']} aria-disabled={disabled || undefined}
|
|
55
|
+
aria-invalid={props['aria-invalid']} aria-describedby={props['aria-describedby']}
|
|
56
|
+
className={['bloom-radio-host', className].filter(Boolean).join(' ')}
|
|
57
|
+
style={resolveNativeWebStyle(style)}
|
|
58
|
+
onClick={() => { if (!disabled) onPress(); }}
|
|
59
|
+
onPointerDown={() => { if (!disabled) onPressIn?.(); }} onPointerUp={onPressOut} onPointerCancel={onPressOut}
|
|
60
|
+
onMouseEnter={onHoverIn} onMouseLeave={() => { onHoverOut?.(); onPressOut?.(); }}
|
|
61
|
+
onKeyDown={event => {
|
|
62
|
+
if (event.key === ' ' || event.key === 'Enter') onPressIn?.();
|
|
63
|
+
onKeyDown?.(event);
|
|
64
|
+
if (event.key === 'Enter' && !disabled && !event.defaultPrevented) {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
if (!event.repeat) onPress();
|
|
67
|
+
}
|
|
68
|
+
}}
|
|
69
|
+
onKeyUp={event => { onPressOut?.(); onKeyUp?.(event); }}
|
|
70
|
+
onBlur={() => { onPressOut?.(); onBlur?.(); }}
|
|
71
|
+
>{children}</button>;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
interface LayoutProps {
|
|
75
|
+
children?: ReactNode; className?: string; style?: StyleProp<ViewStyle>; dir?: 'rtl';
|
|
76
|
+
accessibilityRole?: 'radiogroup'; accessibilityLabel?: string; testID?: string;
|
|
77
|
+
'aria-label'?: string; 'aria-describedby'?: string; 'aria-invalid'?: boolean;
|
|
78
|
+
'aria-disabled'?: boolean; 'aria-required'?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export function RadioGroupHost(props: LayoutProps) {
|
|
81
|
+
useInteractiveWebCss('bloom-radio-host', BASE);
|
|
82
|
+
if (Platform.OS !== 'web') return <StyledView {...props} />;
|
|
83
|
+
const { className, style, accessibilityRole, accessibilityLabel, testID, children, ...aria } = props;
|
|
84
|
+
return <div {...aria} role={accessibilityRole} aria-label={accessibilityLabel}
|
|
85
|
+
className={['bloom-radio-group', className].filter(Boolean).join(' ')} style={resolveNativeWebStyle(style)} data-testid={testID}>{children}</div>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function RadioLabel({ className, style, variant, children, numberOfLines }: {
|
|
89
|
+
className?: string; style?: StyleProp<TextStyle>; variant: TypeScaleVariant; children?: ReactNode; numberOfLines?: number;
|
|
90
|
+
}) {
|
|
91
|
+
if (Platform.OS !== 'web') return <Text className={className} variant={variant} style={style} numberOfLines={numberOfLines}>{children}</Text>;
|
|
92
|
+
return <span className={['bloom-radio-label', className].filter(Boolean).join(' ')}
|
|
93
|
+
style={{ ...(numberOfLines === 1 ? { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } : {}), ...resolveNativeWebStyle([!className && TYPE_SCALE[variant], style]) }}>{children}</span>;
|
|
94
|
+
}
|
package/src/radio/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Radio, RadioGroup } from './Radio';
|
|
2
|
+
export { RadioChip } from './RadioChip';
|
|
2
3
|
export { RadioCard } from './RadioCard';
|
|
3
|
-
export type { RadioProps, RadioGroupProps, RadioOption, RadioOptionState, RadioSize, RadioCardProps } from './types';
|
|
4
|
+
export type { RadioProps, RadioGroupProps, RadioOption, RadioOptionState, RadioSize, RadioCardProps, RadioChipProps } from './types';
|
package/src/radio/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode, ReactElement, RefObject } from 'react';
|
|
2
|
-
import type { BloomSize } from '../appearance';
|
|
2
|
+
import type { BloomAppearance, BloomSize } from '../appearance';
|
|
3
3
|
import type { BloomTone } from '../appearance';
|
|
4
4
|
import type { StyleProp, ViewStyle, TextStyle, View } from 'react-native';
|
|
5
5
|
|
|
@@ -33,6 +33,8 @@ export interface RadioProps<Value extends string = string> {
|
|
|
33
33
|
disabled?: boolean;
|
|
34
34
|
/** Colour of the checked indicator. Uses the theme primary by default. */
|
|
35
35
|
tone?: BloomTone;
|
|
36
|
+
className?: string;
|
|
37
|
+
labelClassName?: string;
|
|
36
38
|
style?: StyleProp<ViewStyle>;
|
|
37
39
|
labelStyle?: StyleProp<TextStyle>;
|
|
38
40
|
accessibilityLabel?: string;
|
|
@@ -44,6 +46,12 @@ export interface RadioProps<Value extends string = string> {
|
|
|
44
46
|
testID?: string;
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
/** A pill-shaped radio with no separate indicator. */
|
|
50
|
+
export interface RadioChipProps<Value extends string = string> extends RadioProps<Value> {
|
|
51
|
+
/** Paint of the selected option. Unselected chips retain a neutral outline. */
|
|
52
|
+
appearance?: BloomAppearance;
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
/** One option, as data, for {@link RadioGroupProps}. */
|
|
48
56
|
export interface RadioOption<Value extends string = string> {
|
|
49
57
|
value: Value;
|
|
@@ -91,14 +99,22 @@ export interface RadioGroupProps<Value extends string = string> {
|
|
|
91
99
|
tone?: BloomTone;
|
|
92
100
|
style?: StyleProp<ViewStyle>;
|
|
93
101
|
labelStyle?: StyleProp<TextStyle>;
|
|
94
|
-
/**
|
|
102
|
+
/** Class recipe on the group layout; replaces its default layout. */
|
|
103
|
+
className?: string;
|
|
104
|
+
/** Class recipes for owned options and their built-in string labels. */
|
|
105
|
+
optionClassName?: string | ((state: Readonly<RadioOptionState>) => string | undefined);
|
|
106
|
+
optionLabelClassName?: string | ((state: Readonly<RadioOptionState>) => string | undefined);
|
|
107
|
+
/** Selected chip paint; used with variant="chip". Defaults to outline. */
|
|
108
|
+
appearance?: BloomAppearance;
|
|
109
|
+
/** Layout/style on each owned Radio, RadioCard or RadioChip. */
|
|
95
110
|
optionStyle?: StyleProp<ViewStyle>;
|
|
96
111
|
/**
|
|
97
112
|
* `default` renders each option as a `Radio` row; `card` as a `RadioCard`
|
|
98
113
|
* (title + description left, the dot right, the whole
|
|
99
|
-
* card selectable).
|
|
114
|
+
* card selectable). `chip` renders a wrapping row of pill-shaped radios
|
|
115
|
+
* without an indicator. A card's title is the option's `label`.
|
|
100
116
|
*/
|
|
101
|
-
variant?: 'default' | 'card';
|
|
117
|
+
variant?: 'default' | 'card' | 'chip';
|
|
102
118
|
testID?: string;
|
|
103
119
|
}
|
|
104
120
|
|
|
@@ -119,6 +135,9 @@ export interface RadioCardProps<Value extends string = string> {
|
|
|
119
135
|
disabled?: boolean;
|
|
120
136
|
/** Accent for the checked dot. Uses the theme primary by default. */
|
|
121
137
|
tone?: BloomTone;
|
|
138
|
+
className?: string;
|
|
139
|
+
labelClassName?: string;
|
|
140
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
122
141
|
style?: StyleProp<ViewStyle>;
|
|
123
142
|
accessibilityLabel?: string;
|
|
124
143
|
testID?: string;
|