@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.
Files changed (63) hide show
  1. package/docs/adoption-matrix.mdx +6 -6
  2. package/docs/checkbox.mdx +21 -0
  3. package/docs/media-header.mdx +21 -0
  4. package/docs/radio.mdx +20 -0
  5. package/lib/commonjs/checkbox/Checkbox.js +15 -9
  6. package/lib/commonjs/checkbox/Checkbox.js.map +1 -1
  7. package/lib/commonjs/hooks/use-choice-space-key.js +37 -0
  8. package/lib/commonjs/hooks/use-choice-space-key.js.map +1 -0
  9. package/lib/commonjs/media-header/FollowLabel.js +46 -0
  10. package/lib/commonjs/media-header/FollowLabel.js.map +1 -0
  11. package/lib/commonjs/media-header/MediaActionBar.js +19 -13
  12. package/lib/commonjs/media-header/MediaActionBar.js.map +1 -1
  13. package/lib/commonjs/radio/Radio.js +14 -3
  14. package/lib/commonjs/radio/Radio.js.map +1 -1
  15. package/lib/module/checkbox/Checkbox.js +15 -9
  16. package/lib/module/checkbox/Checkbox.js.map +1 -1
  17. package/lib/module/hooks/use-choice-space-key.js +34 -0
  18. package/lib/module/hooks/use-choice-space-key.js.map +1 -0
  19. package/lib/module/media-header/FollowLabel.js +42 -0
  20. package/lib/module/media-header/FollowLabel.js.map +1 -0
  21. package/lib/module/media-header/MediaActionBar.js +19 -13
  22. package/lib/module/media-header/MediaActionBar.js.map +1 -1
  23. package/lib/module/radio/Radio.js +14 -3
  24. package/lib/module/radio/Radio.js.map +1 -1
  25. package/lib/typescript/commonjs/checkbox/Checkbox.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/checkbox/types.d.ts +4 -0
  27. package/lib/typescript/commonjs/checkbox/types.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/hooks/use-choice-space-key.d.ts +14 -0
  29. package/lib/typescript/commonjs/hooks/use-choice-space-key.d.ts.map +1 -0
  30. package/lib/typescript/commonjs/media-header/FollowLabel.d.ts +11 -0
  31. package/lib/typescript/commonjs/media-header/FollowLabel.d.ts.map +1 -0
  32. package/lib/typescript/commonjs/media-header/MediaActionBar.d.ts +1 -1
  33. package/lib/typescript/commonjs/media-header/MediaActionBar.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/media-header/types.d.ts +10 -0
  35. package/lib/typescript/commonjs/media-header/types.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/radio/Radio.d.ts +1 -1
  37. package/lib/typescript/commonjs/radio/Radio.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/radio/types.d.ts +4 -0
  39. package/lib/typescript/commonjs/radio/types.d.ts.map +1 -1
  40. package/lib/typescript/module/checkbox/Checkbox.d.ts.map +1 -1
  41. package/lib/typescript/module/checkbox/types.d.ts +4 -0
  42. package/lib/typescript/module/checkbox/types.d.ts.map +1 -1
  43. package/lib/typescript/module/hooks/use-choice-space-key.d.ts +14 -0
  44. package/lib/typescript/module/hooks/use-choice-space-key.d.ts.map +1 -0
  45. package/lib/typescript/module/media-header/FollowLabel.d.ts +11 -0
  46. package/lib/typescript/module/media-header/FollowLabel.d.ts.map +1 -0
  47. package/lib/typescript/module/media-header/MediaActionBar.d.ts +1 -1
  48. package/lib/typescript/module/media-header/MediaActionBar.d.ts.map +1 -1
  49. package/lib/typescript/module/media-header/types.d.ts +10 -0
  50. package/lib/typescript/module/media-header/types.d.ts.map +1 -1
  51. package/lib/typescript/module/radio/Radio.d.ts +1 -1
  52. package/lib/typescript/module/radio/Radio.d.ts.map +1 -1
  53. package/lib/typescript/module/radio/types.d.ts +4 -0
  54. package/lib/typescript/module/radio/types.d.ts.map +1 -1
  55. package/package.json +1 -1
  56. package/src/checkbox/Checkbox.tsx +13 -3
  57. package/src/checkbox/types.ts +4 -0
  58. package/src/hooks/use-choice-space-key.ts +29 -0
  59. package/src/media-header/FollowLabel.tsx +23 -0
  60. package/src/media-header/MediaActionBar.tsx +11 -6
  61. package/src/media-header/types.ts +10 -0
  62. package/src/radio/Radio.tsx +13 -3
  63. package/src/radio/types.ts +4 -0
@@ -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 hasText = Boolean(label || description);
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
- {label && (
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: label ? DESCRIPTION_GAP : 0 }}
197
+ style={{ color: theme.colors.textSecondary, marginTop: hasLabel ? DESCRIPTION_GAP : 0 }}
188
198
  >
189
199
  {description}
190
200
  </Text>
@@ -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. */