@oxy.so/bloom 7.24.1 → 7.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/adoption-matrix.mdx +6 -6
- package/docs/radio.mdx +32 -0
- package/docs/screen.mdx +7 -2
- package/lib/commonjs/page-header/PageHeader.js +3 -1
- package/lib/commonjs/page-header/PageHeader.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/commonjs/screen/Screen.js +18 -13
- package/lib/commonjs/screen/Screen.js.map +1 -1
- package/lib/commonjs/screen/context.js +4 -1
- package/lib/commonjs/screen/context.js.map +1 -1
- package/lib/module/page-header/PageHeader.js +4 -2
- package/lib/module/page-header/PageHeader.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/module/screen/Screen.js +20 -15
- package/lib/module/screen/Screen.js.map +1 -1
- package/lib/module/screen/context.js +3 -0
- package/lib/module/screen/context.js.map +1 -1
- package/lib/typescript/commonjs/page-header/PageHeader.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/commonjs/screen/Screen.d.ts.map +1 -1
- package/lib/typescript/commonjs/screen/context.d.ts +2 -0
- package/lib/typescript/commonjs/screen/context.d.ts.map +1 -1
- package/lib/typescript/module/page-header/PageHeader.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/lib/typescript/module/screen/Screen.d.ts.map +1 -1
- package/lib/typescript/module/screen/context.d.ts +2 -0
- package/lib/typescript/module/screen/context.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/page-header/PageHeader.tsx +4 -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/screen/Screen.tsx +7 -6
- package/src/screen/context.ts +3 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { type KeyboardEvent, type ReactNode } from 'react';
|
|
2
|
+
import { type View, type StyleProp, type ViewStyle, type TextStyle } from 'react-native';
|
|
3
|
+
import { type TypeScaleVariant } from '../typography/scale';
|
|
4
|
+
interface HostProps {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: StyleProp<ViewStyle>;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
accessibilityRole?: 'radio';
|
|
10
|
+
accessibilityLabel?: string;
|
|
11
|
+
accessibilityHint?: string;
|
|
12
|
+
nativeID?: string;
|
|
13
|
+
testID?: string;
|
|
14
|
+
hitSlop?: number | {
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
left: number;
|
|
18
|
+
right: number;
|
|
19
|
+
};
|
|
20
|
+
dataSet?: Record<string, string>;
|
|
21
|
+
'aria-checked'?: boolean;
|
|
22
|
+
'aria-disabled'?: boolean;
|
|
23
|
+
'aria-invalid'?: boolean;
|
|
24
|
+
'aria-describedby'?: string;
|
|
25
|
+
tabIndex?: 0 | -1;
|
|
26
|
+
onPress: () => void;
|
|
27
|
+
onPressIn?: () => void;
|
|
28
|
+
onPressOut?: () => void;
|
|
29
|
+
onHoverIn?: () => void;
|
|
30
|
+
onHoverOut?: () => void;
|
|
31
|
+
onBlur?: () => void;
|
|
32
|
+
onKeyDown?: (event: KeyboardEvent<HTMLElement>) => void;
|
|
33
|
+
onKeyUp?: (event: KeyboardEvent<HTMLElement>) => void;
|
|
34
|
+
}
|
|
35
|
+
export declare const RadioHost: React.ForwardRefExoticComponent<HostProps & React.RefAttributes<View>>;
|
|
36
|
+
interface LayoutProps {
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
className?: string;
|
|
39
|
+
style?: StyleProp<ViewStyle>;
|
|
40
|
+
dir?: 'rtl';
|
|
41
|
+
accessibilityRole?: 'radiogroup';
|
|
42
|
+
accessibilityLabel?: string;
|
|
43
|
+
testID?: string;
|
|
44
|
+
'aria-label'?: string;
|
|
45
|
+
'aria-describedby'?: string;
|
|
46
|
+
'aria-invalid'?: boolean;
|
|
47
|
+
'aria-disabled'?: boolean;
|
|
48
|
+
'aria-required'?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare function RadioGroupHost(props: LayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export declare function RadioLabel({ className, style, variant, children, numberOfLines }: {
|
|
52
|
+
className?: string;
|
|
53
|
+
style?: StyleProp<TextStyle>;
|
|
54
|
+
variant: TypeScaleVariant;
|
|
55
|
+
children?: ReactNode;
|
|
56
|
+
numberOfLines?: number;
|
|
57
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=RadioHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioHost.d.ts","sourceRoot":"","sources":["../../../../src/radio/RadioHost.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAY,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAKnG,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAUxE,UAAU,SAAS;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,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G,CAAC,EAAE,KAAK,CAAC;IACpF,iBAAiB,CAAC,EAAE,YAAY,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAC7E,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACtD;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,2CAMhD;AAED,wBAAgB,UAAU,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAC3H,2CAIA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
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';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/radio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/radio/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -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
|
export type RadioSize = BloomSize;
|
|
@@ -31,6 +31,8 @@ export interface RadioProps<Value extends string = string> {
|
|
|
31
31
|
disabled?: boolean;
|
|
32
32
|
/** Colour of the checked indicator. Uses the theme primary by default. */
|
|
33
33
|
tone?: BloomTone;
|
|
34
|
+
className?: string;
|
|
35
|
+
labelClassName?: string;
|
|
34
36
|
style?: StyleProp<ViewStyle>;
|
|
35
37
|
labelStyle?: StyleProp<TextStyle>;
|
|
36
38
|
accessibilityLabel?: string;
|
|
@@ -41,6 +43,11 @@ export interface RadioProps<Value extends string = string> {
|
|
|
41
43
|
nativeID?: string;
|
|
42
44
|
testID?: string;
|
|
43
45
|
}
|
|
46
|
+
/** A pill-shaped radio with no separate indicator. */
|
|
47
|
+
export interface RadioChipProps<Value extends string = string> extends RadioProps<Value> {
|
|
48
|
+
/** Paint of the selected option. Unselected chips retain a neutral outline. */
|
|
49
|
+
appearance?: BloomAppearance;
|
|
50
|
+
}
|
|
44
51
|
/** One option, as data, for {@link RadioGroupProps}. */
|
|
45
52
|
export interface RadioOption<Value extends string = string> {
|
|
46
53
|
value: Value;
|
|
@@ -86,14 +93,22 @@ export interface RadioGroupProps<Value extends string = string> {
|
|
|
86
93
|
tone?: BloomTone;
|
|
87
94
|
style?: StyleProp<ViewStyle>;
|
|
88
95
|
labelStyle?: StyleProp<TextStyle>;
|
|
89
|
-
/**
|
|
96
|
+
/** Class recipe on the group layout; replaces its default layout. */
|
|
97
|
+
className?: string;
|
|
98
|
+
/** Class recipes for owned options and their built-in string labels. */
|
|
99
|
+
optionClassName?: string | ((state: Readonly<RadioOptionState>) => string | undefined);
|
|
100
|
+
optionLabelClassName?: string | ((state: Readonly<RadioOptionState>) => string | undefined);
|
|
101
|
+
/** Selected chip paint; used with variant="chip". Defaults to outline. */
|
|
102
|
+
appearance?: BloomAppearance;
|
|
103
|
+
/** Layout/style on each owned Radio, RadioCard or RadioChip. */
|
|
90
104
|
optionStyle?: StyleProp<ViewStyle>;
|
|
91
105
|
/**
|
|
92
106
|
* `default` renders each option as a `Radio` row; `card` as a `RadioCard`
|
|
93
107
|
* (title + description left, the dot right, the whole
|
|
94
|
-
* card selectable).
|
|
108
|
+
* card selectable). `chip` renders a wrapping row of pill-shaped radios
|
|
109
|
+
* without an indicator. A card's title is the option's `label`.
|
|
95
110
|
*/
|
|
96
|
-
variant?: 'default' | 'card';
|
|
111
|
+
variant?: 'default' | 'card' | 'chip';
|
|
97
112
|
testID?: string;
|
|
98
113
|
}
|
|
99
114
|
export interface RadioCardProps<Value extends string = string> {
|
|
@@ -113,6 +128,9 @@ export interface RadioCardProps<Value extends string = string> {
|
|
|
113
128
|
disabled?: boolean;
|
|
114
129
|
/** Accent for the checked dot. Uses the theme primary by default. */
|
|
115
130
|
tone?: BloomTone;
|
|
131
|
+
className?: string;
|
|
132
|
+
labelClassName?: string;
|
|
133
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
116
134
|
style?: StyleProp<ViewStyle>;
|
|
117
135
|
accessibilityLabel?: string;
|
|
118
136
|
testID?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/radio/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/radio/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IACvD,wCAAwC;IACxC,KAAK,EAAE,KAAK,CAAC;IACb,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;8EAC0E;IAC1E,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;wFACoF;IACpF,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,sCAAsC;I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;CACjB;AAED,MAAM,WAAW,cAAc,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IAC3D,sCAAsC;IACtC,KAAK,EAAE,KAAK,CAAC;IACb,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Screen.d.ts","sourceRoot":"","sources":["../../../../src/screen/Screen.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,eAAsB,EAAE,eAA2B,EAAE,cAAsB,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAqB,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"Screen.d.ts","sourceRoot":"","sources":["../../../../src/screen/Screen.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,eAAsB,EAAE,eAA2B,EAAE,cAAsB,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAqB,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,2CAgDrP"}
|
|
@@ -14,6 +14,8 @@ export type ScreenNavigationState = Pick<ScreenContextValue, 'collapseProgress'
|
|
|
14
14
|
bottomInset?: number;
|
|
15
15
|
};
|
|
16
16
|
export declare const ScreenNavigationContext: import("react").Context<ScreenNavigationState | null>;
|
|
17
|
+
/** Only the Screen header slot owns chrome positioning; content headers remain independent. */
|
|
18
|
+
export declare const ScreenHeaderContext: import("react").Context<ScreenContextValue | null>;
|
|
17
19
|
export declare const ScreenContext: import("react").Context<ScreenContextValue | null>;
|
|
18
20
|
export declare function useScreenContext(): ScreenContextValue | null;
|
|
19
21
|
export declare function useScreen(): ScreenContextValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/screen/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,gBAAgB,EAAE,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,uEAAuE;IACvE,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACj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,CAI9C"}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
|
18
18
|
|
|
19
19
|
import { useHeaderDockContext } from '../layout/header-dock';
|
|
20
20
|
import { useSurfaceFill } from '../styles/surface-levels';
|
|
21
|
-
import { useScreenContext } from '../screen/context';
|
|
21
|
+
import { ScreenHeaderContext, useScreenContext } from '../screen/context';
|
|
22
22
|
import { Button } from '../button';
|
|
23
23
|
import { BUTTON_SHADOW } from '../button/shared';
|
|
24
24
|
import { BloomScope } from "../appearance";
|
|
@@ -192,6 +192,8 @@ function PageHeaderComponent({
|
|
|
192
192
|
// it a header inside a scrolling panel followed `window.scrollY`, which on a
|
|
193
193
|
// desktop shell never moves, so the header looked deliberately inert.
|
|
194
194
|
const screen = useScreenContext();
|
|
195
|
+
const headerScreen = useContext(ScreenHeaderContext);
|
|
196
|
+
const positionedByScreen = screen != null && headerScreen === screen;
|
|
195
197
|
const contextScrollY = useScrollOffset();
|
|
196
198
|
const metrics = useScrollMetricsValue();
|
|
197
199
|
const internalScrollY = useSharedValue(0);
|
|
@@ -353,7 +355,7 @@ function PageHeaderComponent({
|
|
|
353
355
|
) : null;
|
|
354
356
|
|
|
355
357
|
const containerWeb: WebCssStyle | null =
|
|
356
|
-
isWeb && sticky && !overlay
|
|
358
|
+
isWeb && sticky && !overlay && !positionedByScreen
|
|
357
359
|
? { position: WEB_POSITION_STICKY, top: WEB_SURFACE_STICKY_TOP, zIndex: Z_INDEX.floating,
|
|
358
360
|
transitionProperty: 'top', transitionDuration: 'var(--bloom-panel-inset-duration, 0ms)', transitionTimingFunction: 'ease-in-out' }
|
|
359
361
|
: null;
|
package/src/radio/Radio.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useRadioGroupItem } from './use-radio-group-item';
|
|
2
2
|
import { RadioGroupContext } from './context';
|
|
3
|
-
import { useIsRtl } from '../hooks/use-is-rtl';
|
|
3
|
+
import { useDirectionProps, useIsRtl } from '../hooks/use-is-rtl';
|
|
4
4
|
import { useControllableState } from '../hooks/use-controllable-state';
|
|
5
5
|
import { useBloomAppearance } from '../appearance';
|
|
6
6
|
import { resolveBloomColors } from '../appearance/colors';
|
|
7
7
|
import React, { memo, useCallback, useMemo, useRef, type KeyboardEvent } from 'react';
|
|
8
|
-
import { View, Platform
|
|
8
|
+
import { View, Platform } from 'react-native';
|
|
9
9
|
|
|
10
10
|
import { useTheme } from '../theme/use-theme';
|
|
11
11
|
import { Text } from '../typography';
|
|
@@ -20,6 +20,8 @@ import type { WebCssStyle } from '../styles/web-view-style';
|
|
|
20
20
|
import { RadioIndicator } from '../radio-indicator';
|
|
21
21
|
import { useFieldMembership } from '../field/membership';
|
|
22
22
|
import { RadioCard } from './RadioCard';
|
|
23
|
+
import { RadioChip } from './RadioChip';
|
|
24
|
+
import { RadioHost, RadioGroupHost, RadioLabel } from './RadioHost';
|
|
23
25
|
import type { RadioGroupProps, RadioProps } from './types';
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -66,7 +68,7 @@ const STYLE_ID = 'bloom-radio-web-css';
|
|
|
66
68
|
const ROW = '[data-bloom-radio]';
|
|
67
69
|
const DOT = '[data-bloom-radio-dot]';
|
|
68
70
|
|
|
69
|
-
const BLOOM_RADIO_CSS = interactiveWebCss({
|
|
71
|
+
const BLOOM_RADIO_CSS = `@layer base {${interactiveWebCss({
|
|
70
72
|
selector: ROW,
|
|
71
73
|
varPrefix: 'bloom-radio',
|
|
72
74
|
base: `
|
|
@@ -88,7 +90,7 @@ ${ROW}:focus-visible {
|
|
|
88
90
|
${ROW}:focus-visible ${DOT} {
|
|
89
91
|
box-shadow: ${focusRingShadow('--bloom-radio-ring')};
|
|
90
92
|
}`,
|
|
91
|
-
})
|
|
93
|
+
})}}`;
|
|
92
94
|
|
|
93
95
|
const IS_WEB = Platform.OS === 'web';
|
|
94
96
|
|
|
@@ -104,6 +106,8 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
104
106
|
tone: toneProp,
|
|
105
107
|
style,
|
|
106
108
|
labelStyle,
|
|
109
|
+
className,
|
|
110
|
+
labelClassName,
|
|
107
111
|
accessibilityLabel,
|
|
108
112
|
nativeID,
|
|
109
113
|
testID,
|
|
@@ -152,10 +156,11 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
152
156
|
const spaceKey = useRadioGroupItem(value, isDisabled, handlePress);
|
|
153
157
|
|
|
154
158
|
return (
|
|
155
|
-
<
|
|
159
|
+
<RadioHost
|
|
160
|
+
className={className}
|
|
156
161
|
{...spaceKey}
|
|
157
162
|
{...(IS_WEB ? ({ dataSet: { bloomRadio: '' } } as Record<string, unknown>) : {})}
|
|
158
|
-
style={[rowStyle, style]}
|
|
163
|
+
style={[className ? { '--bloom-radio-ring': rowStyle['--bloom-radio-ring'], ...ringOffset } : rowStyle, style]}
|
|
159
164
|
onPress={handlePress}
|
|
160
165
|
disabled={isDisabled}
|
|
161
166
|
nativeID={field.nativeID}
|
|
@@ -189,9 +194,9 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
189
194
|
{labelContent}
|
|
190
195
|
</View>
|
|
191
196
|
) : label && (
|
|
192
|
-
<
|
|
197
|
+
<RadioLabel className={labelClassName} variant={sizeConfig.label} style={[!labelClassName && { color: theme.colors.text }, labelStyle]}>
|
|
193
198
|
{label}
|
|
194
|
-
</
|
|
199
|
+
</RadioLabel>
|
|
195
200
|
)}
|
|
196
201
|
{description && (
|
|
197
202
|
<Text
|
|
@@ -203,7 +208,7 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
203
208
|
)}
|
|
204
209
|
</View>
|
|
205
210
|
)}
|
|
206
|
-
</
|
|
211
|
+
</RadioHost>
|
|
207
212
|
);
|
|
208
213
|
};
|
|
209
214
|
|
|
@@ -230,6 +235,10 @@ const RadioGroupComponent = function RadioGroup<Value extends string = string>(p
|
|
|
230
235
|
style,
|
|
231
236
|
labelStyle,
|
|
232
237
|
optionStyle,
|
|
238
|
+
className,
|
|
239
|
+
optionClassName,
|
|
240
|
+
optionLabelClassName,
|
|
241
|
+
appearance,
|
|
233
242
|
renderOption,
|
|
234
243
|
variant = 'default',
|
|
235
244
|
testID,
|
|
@@ -243,9 +252,10 @@ const RadioGroupComponent = function RadioGroup<Value extends string = string>(p
|
|
|
243
252
|
// own — so it goes in as the caller's name and outranks the field's.
|
|
244
253
|
const field = useFieldMembership({ accessibilityLabel: label, disabled });
|
|
245
254
|
const isDisabled = field.disabled;
|
|
246
|
-
const { size: scopedSize, tone } = useBloomAppearance({size: sizeProp, tone: toneProp}, {size: 'md', tone: 'accent'});
|
|
255
|
+
const { size: scopedSize, tone } = useBloomAppearance({size: sizeProp, tone: toneProp}, {size: 'md', tone: variant === 'chip' ? 'neutral' : 'accent'});
|
|
247
256
|
const size = scopedSize;
|
|
248
257
|
const rtl = useIsRtl();
|
|
258
|
+
const direction = useDirectionProps();
|
|
249
259
|
const nodes = useRef(new Map<string, React.RefObject<View | null>>());
|
|
250
260
|
const controlRef = useCallback((option: string) => {
|
|
251
261
|
let ref = nodes.current.get(option);
|
|
@@ -282,19 +292,34 @@ const RadioGroupComponent = function RadioGroup<Value extends string = string>(p
|
|
|
282
292
|
};
|
|
283
293
|
return (
|
|
284
294
|
<RadioGroupContext.Provider value={{ tabValue, register, onKeyDown }}>
|
|
285
|
-
<
|
|
286
|
-
|
|
295
|
+
<RadioGroupHost
|
|
296
|
+
{...direction}
|
|
297
|
+
className={className}
|
|
298
|
+
style={[!className && { gap: space.sm, ...(variant === 'chip' ? { flexDirection: 'row' as const, flexWrap: 'wrap' as const } : {}) }, style]}
|
|
287
299
|
accessibilityRole="radiogroup"
|
|
288
300
|
accessibilityLabel={field.accessibilityLabel}
|
|
289
301
|
aria-label={field.accessibilityLabel}
|
|
290
302
|
aria-describedby={field.describedBy}
|
|
291
303
|
aria-invalid={field.invalid || undefined}
|
|
304
|
+
aria-disabled={isDisabled || undefined}
|
|
305
|
+
aria-required={field.required || undefined}
|
|
292
306
|
testID={testID}
|
|
293
307
|
>
|
|
294
308
|
{options.map((option) => {
|
|
295
309
|
const checked = option.value === value;
|
|
296
310
|
const optionDisabled = isDisabled || option.disabled === true;
|
|
297
|
-
const
|
|
311
|
+
const state = { checked, disabled: optionDisabled, controlRef: controlRef(option.value) };
|
|
312
|
+
const optionClasses = typeof optionClassName === 'function' ? optionClassName(state) : optionClassName;
|
|
313
|
+
const labelClasses = typeof optionLabelClassName === 'function' ? optionLabelClassName(state) : optionLabelClassName;
|
|
314
|
+
const ownedControl = variant === 'chip' ? (
|
|
315
|
+
<RadioChip
|
|
316
|
+
key={option.value} value={option.value} checked={checked} onValueChange={onValueChange}
|
|
317
|
+
label={option.label} labelContent={option.labelContent} accessibilityLabel={option.accessibilityLabel}
|
|
318
|
+
description={option.description} disabled={optionDisabled} size={size} tone={tone} appearance={appearance}
|
|
319
|
+
style={optionStyle} labelStyle={labelStyle} className={optionClasses} labelClassName={labelClasses}
|
|
320
|
+
testID={option.testID}
|
|
321
|
+
/>
|
|
322
|
+
) : variant === 'card' ? (
|
|
298
323
|
<RadioCard
|
|
299
324
|
key={option.value}
|
|
300
325
|
value={option.value}
|
|
@@ -307,6 +332,9 @@ const RadioGroupComponent = function RadioGroup<Value extends string = string>(p
|
|
|
307
332
|
disabled={optionDisabled}
|
|
308
333
|
tone={tone}
|
|
309
334
|
style={optionStyle}
|
|
335
|
+
labelStyle={labelStyle}
|
|
336
|
+
className={optionClasses}
|
|
337
|
+
labelClassName={labelClasses}
|
|
310
338
|
testID={option.testID}
|
|
311
339
|
/>
|
|
312
340
|
) : (
|
|
@@ -324,14 +352,16 @@ const RadioGroupComponent = function RadioGroup<Value extends string = string>(p
|
|
|
324
352
|
tone={tone}
|
|
325
353
|
labelStyle={labelStyle}
|
|
326
354
|
style={optionStyle}
|
|
355
|
+
className={optionClasses}
|
|
356
|
+
labelClassName={labelClasses}
|
|
327
357
|
testID={option.testID}
|
|
328
358
|
/>
|
|
329
359
|
);
|
|
330
360
|
return <React.Fragment key={option.value}>{renderOption
|
|
331
|
-
? renderOption(option, ownedControl,
|
|
361
|
+
? renderOption(option, ownedControl, state)
|
|
332
362
|
: ownedControl}</React.Fragment>;
|
|
333
363
|
})}
|
|
334
|
-
</
|
|
364
|
+
</RadioGroupHost>
|
|
335
365
|
</RadioGroupContext.Provider>
|
|
336
366
|
);
|
|
337
367
|
};
|
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';
|