@oxy.so/bloom 7.17.0 → 7.18.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/checkbox.mdx +21 -0
- package/docs/media-header.mdx +21 -0
- package/docs/radio.mdx +20 -0
- package/lib/commonjs/checkbox/Checkbox.js +15 -9
- package/lib/commonjs/checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/hooks/use-choice-space-key.js +37 -0
- package/lib/commonjs/hooks/use-choice-space-key.js.map +1 -0
- package/lib/commonjs/media-header/FollowLabel.js +46 -0
- package/lib/commonjs/media-header/FollowLabel.js.map +1 -0
- package/lib/commonjs/media-header/MediaActionBar.js +19 -13
- package/lib/commonjs/media-header/MediaActionBar.js.map +1 -1
- package/lib/commonjs/radio/Radio.js +14 -3
- package/lib/commonjs/radio/Radio.js.map +1 -1
- package/lib/module/checkbox/Checkbox.js +15 -9
- package/lib/module/checkbox/Checkbox.js.map +1 -1
- package/lib/module/hooks/use-choice-space-key.js +34 -0
- package/lib/module/hooks/use-choice-space-key.js.map +1 -0
- package/lib/module/media-header/FollowLabel.js +42 -0
- package/lib/module/media-header/FollowLabel.js.map +1 -0
- package/lib/module/media-header/MediaActionBar.js +19 -13
- package/lib/module/media-header/MediaActionBar.js.map +1 -1
- package/lib/module/radio/Radio.js +14 -3
- package/lib/module/radio/Radio.js.map +1 -1
- package/lib/typescript/commonjs/checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/commonjs/checkbox/types.d.ts +4 -0
- package/lib/typescript/commonjs/checkbox/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-choice-space-key.d.ts +14 -0
- package/lib/typescript/commonjs/hooks/use-choice-space-key.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-header/FollowLabel.d.ts +11 -0
- package/lib/typescript/commonjs/media-header/FollowLabel.d.ts.map +1 -0
- package/lib/typescript/commonjs/media-header/MediaActionBar.d.ts +1 -1
- package/lib/typescript/commonjs/media-header/MediaActionBar.d.ts.map +1 -1
- package/lib/typescript/commonjs/media-header/types.d.ts +10 -0
- package/lib/typescript/commonjs/media-header/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/Radio.d.ts +1 -1
- package/lib/typescript/commonjs/radio/Radio.d.ts.map +1 -1
- package/lib/typescript/commonjs/radio/types.d.ts +4 -0
- package/lib/typescript/commonjs/radio/types.d.ts.map +1 -1
- package/lib/typescript/module/checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/module/checkbox/types.d.ts +4 -0
- package/lib/typescript/module/checkbox/types.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-choice-space-key.d.ts +14 -0
- package/lib/typescript/module/hooks/use-choice-space-key.d.ts.map +1 -0
- package/lib/typescript/module/media-header/FollowLabel.d.ts +11 -0
- package/lib/typescript/module/media-header/FollowLabel.d.ts.map +1 -0
- package/lib/typescript/module/media-header/MediaActionBar.d.ts +1 -1
- package/lib/typescript/module/media-header/MediaActionBar.d.ts.map +1 -1
- package/lib/typescript/module/media-header/types.d.ts +10 -0
- package/lib/typescript/module/media-header/types.d.ts.map +1 -1
- package/lib/typescript/module/radio/Radio.d.ts +1 -1
- package/lib/typescript/module/radio/Radio.d.ts.map +1 -1
- package/lib/typescript/module/radio/types.d.ts +4 -0
- package/lib/typescript/module/radio/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/checkbox/Checkbox.tsx +13 -3
- package/src/checkbox/types.ts +4 -0
- package/src/hooks/use-choice-space-key.ts +29 -0
- package/src/media-header/FollowLabel.tsx +23 -0
- package/src/media-header/MediaActionBar.tsx +11 -6
- package/src/media-header/types.ts +10 -0
- package/src/radio/Radio.tsx +13 -3
- package/src/radio/types.ts +4 -0
package/src/radio/Radio.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useChoiceSpaceKey } from '../hooks/use-choice-space-key';
|
|
1
2
|
import { useControllableState } from '../hooks/use-controllable-state';
|
|
2
3
|
import { useBloomAppearance } from '../appearance';
|
|
3
4
|
import { resolveBloomColors } from '../appearance/colors';
|
|
@@ -94,6 +95,7 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
94
95
|
checked: checkedProp,
|
|
95
96
|
onValueChange,
|
|
96
97
|
label,
|
|
98
|
+
labelContent,
|
|
97
99
|
description,
|
|
98
100
|
size: sizeProp,
|
|
99
101
|
disabled = false,
|
|
@@ -123,7 +125,8 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
123
125
|
useInteractiveWebCss(STYLE_ID, BLOOM_RADIO_CSS);
|
|
124
126
|
const sizeConfig = SIZE_CONFIG[size];
|
|
125
127
|
const { accent } = useMemo(() => resolveButtonRamps(theme), [theme]);
|
|
126
|
-
const
|
|
128
|
+
const hasLabel = labelContent != null || Boolean(label);
|
|
129
|
+
const hasText = hasLabel || Boolean(description);
|
|
127
130
|
|
|
128
131
|
const handlePress = useCallback(() => {
|
|
129
132
|
// Re-choosing the chosen option is a no-op. A radio, unlike a checkbox, has
|
|
@@ -144,8 +147,11 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
144
147
|
...ringOffset,
|
|
145
148
|
};
|
|
146
149
|
|
|
150
|
+
const spaceKey = useChoiceSpaceKey(isDisabled, handlePress);
|
|
151
|
+
|
|
147
152
|
return (
|
|
148
153
|
<Pressable
|
|
154
|
+
{...spaceKey}
|
|
149
155
|
{...(IS_WEB ? ({ dataSet: { bloomRadio: '' } } as Record<string, unknown>) : {})}
|
|
150
156
|
style={[rowStyle, style]}
|
|
151
157
|
onPress={handlePress}
|
|
@@ -176,7 +182,11 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
176
182
|
|
|
177
183
|
{hasText && (
|
|
178
184
|
<View style={{ flex: 1 }}>
|
|
179
|
-
{
|
|
185
|
+
{labelContent != null ? (
|
|
186
|
+
<View pointerEvents="none" aria-hidden accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
|
|
187
|
+
{labelContent}
|
|
188
|
+
</View>
|
|
189
|
+
) : label && (
|
|
180
190
|
<Text variant={sizeConfig.label} style={[{ color: theme.colors.text }, labelStyle]}>
|
|
181
191
|
{label}
|
|
182
192
|
</Text>
|
|
@@ -184,7 +194,7 @@ const RadioComponent = function Radio<Value extends string = string>({
|
|
|
184
194
|
{description && (
|
|
185
195
|
<Text
|
|
186
196
|
variant={sizeConfig.description}
|
|
187
|
-
style={{ color: theme.colors.textSecondary, marginTop:
|
|
197
|
+
style={{ color: theme.colors.textSecondary, marginTop: hasLabel ? DESCRIPTION_GAP : 0 }}
|
|
188
198
|
>
|
|
189
199
|
{description}
|
|
190
200
|
</Text>
|
package/src/radio/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { BloomSize } from '../appearance';
|
|
2
3
|
import type { BloomTone } from '../appearance';
|
|
3
4
|
import type { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
@@ -21,6 +22,9 @@ export interface RadioProps<Value extends string = string> {
|
|
|
21
22
|
onValueChange?: (value: Value) => void;
|
|
22
23
|
/** Optional label text. */
|
|
23
24
|
label?: string;
|
|
25
|
+
/** Decorative label layout, rendered in a View instead of Text. Supply
|
|
26
|
+
* `label` or `accessibilityLabel` for its accessible name. Do not nest controls. */
|
|
27
|
+
labelContent?: ReactNode;
|
|
24
28
|
/** Optional description shown below the label. */
|
|
25
29
|
description?: string;
|
|
26
30
|
/** Size preset. */
|