@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.
Files changed (77) hide show
  1. package/docs/adoption-matrix.mdx +6 -6
  2. package/docs/radio.mdx +32 -0
  3. package/docs/screen.mdx +7 -2
  4. package/lib/commonjs/page-header/PageHeader.js +3 -1
  5. package/lib/commonjs/page-header/PageHeader.js.map +1 -1
  6. package/lib/commonjs/radio/Radio.js +63 -16
  7. package/lib/commonjs/radio/Radio.js.map +1 -1
  8. package/lib/commonjs/radio/RadioCard.js +14 -5
  9. package/lib/commonjs/radio/RadioCard.js.map +1 -1
  10. package/lib/commonjs/radio/RadioChip.js +169 -0
  11. package/lib/commonjs/radio/RadioChip.js.map +1 -0
  12. package/lib/commonjs/radio/RadioHost.js +153 -0
  13. package/lib/commonjs/radio/RadioHost.js.map +1 -0
  14. package/lib/commonjs/radio/index.js +7 -0
  15. package/lib/commonjs/radio/index.js.map +1 -1
  16. package/lib/commonjs/screen/Screen.js +18 -13
  17. package/lib/commonjs/screen/Screen.js.map +1 -1
  18. package/lib/commonjs/screen/context.js +4 -1
  19. package/lib/commonjs/screen/context.js.map +1 -1
  20. package/lib/module/page-header/PageHeader.js +4 -2
  21. package/lib/module/page-header/PageHeader.js.map +1 -1
  22. package/lib/module/radio/Radio.js +65 -18
  23. package/lib/module/radio/Radio.js.map +1 -1
  24. package/lib/module/radio/RadioCard.js +15 -6
  25. package/lib/module/radio/RadioCard.js.map +1 -1
  26. package/lib/module/radio/RadioChip.js +164 -0
  27. package/lib/module/radio/RadioChip.js.map +1 -0
  28. package/lib/module/radio/RadioHost.js +147 -0
  29. package/lib/module/radio/RadioHost.js.map +1 -0
  30. package/lib/module/radio/index.js +1 -0
  31. package/lib/module/radio/index.js.map +1 -1
  32. package/lib/module/screen/Screen.js +20 -15
  33. package/lib/module/screen/Screen.js.map +1 -1
  34. package/lib/module/screen/context.js +3 -0
  35. package/lib/module/screen/context.js.map +1 -1
  36. package/lib/typescript/commonjs/page-header/PageHeader.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/radio/Radio.d.ts +1 -1
  38. package/lib/typescript/commonjs/radio/Radio.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/radio/RadioCard.d.ts +1 -1
  40. package/lib/typescript/commonjs/radio/RadioCard.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/radio/RadioChip.d.ts +5 -0
  42. package/lib/typescript/commonjs/radio/RadioChip.d.ts.map +1 -0
  43. package/lib/typescript/commonjs/radio/RadioHost.d.ts +59 -0
  44. package/lib/typescript/commonjs/radio/RadioHost.d.ts.map +1 -0
  45. package/lib/typescript/commonjs/radio/index.d.ts +2 -1
  46. package/lib/typescript/commonjs/radio/index.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/radio/types.d.ts +22 -4
  48. package/lib/typescript/commonjs/radio/types.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/screen/Screen.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/screen/context.d.ts +2 -0
  51. package/lib/typescript/commonjs/screen/context.d.ts.map +1 -1
  52. package/lib/typescript/module/page-header/PageHeader.d.ts.map +1 -1
  53. package/lib/typescript/module/radio/Radio.d.ts +1 -1
  54. package/lib/typescript/module/radio/Radio.d.ts.map +1 -1
  55. package/lib/typescript/module/radio/RadioCard.d.ts +1 -1
  56. package/lib/typescript/module/radio/RadioCard.d.ts.map +1 -1
  57. package/lib/typescript/module/radio/RadioChip.d.ts +5 -0
  58. package/lib/typescript/module/radio/RadioChip.d.ts.map +1 -0
  59. package/lib/typescript/module/radio/RadioHost.d.ts +59 -0
  60. package/lib/typescript/module/radio/RadioHost.d.ts.map +1 -0
  61. package/lib/typescript/module/radio/index.d.ts +2 -1
  62. package/lib/typescript/module/radio/index.d.ts.map +1 -1
  63. package/lib/typescript/module/radio/types.d.ts +22 -4
  64. package/lib/typescript/module/radio/types.d.ts.map +1 -1
  65. package/lib/typescript/module/screen/Screen.d.ts.map +1 -1
  66. package/lib/typescript/module/screen/context.d.ts +2 -0
  67. package/lib/typescript/module/screen/context.d.ts.map +1 -1
  68. package/package.json +1 -1
  69. package/src/page-header/PageHeader.tsx +4 -2
  70. package/src/radio/Radio.tsx +45 -15
  71. package/src/radio/RadioCard.tsx +11 -6
  72. package/src/radio/RadioChip.tsx +84 -0
  73. package/src/radio/RadioHost.tsx +94 -0
  74. package/src/radio/index.ts +2 -1
  75. package/src/radio/types.ts +23 -4
  76. package/src/screen/Screen.tsx +7 -6
  77. package/src/screen/context.ts +3 -0
@@ -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
- /** Layout/style on each owned Radio or RadioCard row. */
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). A card's title is the option's `label`.
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;
@@ -3,16 +3,16 @@ import { Keyboard, Platform, View } from 'react-native';
3
3
  import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
4
4
  import { windowEdgeGap } from '../layout/edge';
5
5
  import { useSharedValue } from 'react-native-reanimated';
6
- import { useTheme } from '../theme/use-theme';
7
- import { WEB_POSITION_STICKY, WEB_VIEWPORT_HEIGHT } from '../styles/web-view-style';
6
+ import { useSurfaceFill } from '../styles/surface-levels';
7
+ import { WEB_POSITION_STICKY, WEB_SURFACE_STICKY_TOP, WEB_VIEWPORT_HEIGHT, type WebCssStyle } from '../styles/web-view-style';
8
8
  import { Z_INDEX } from '../styles/z-index';
9
- import { ScreenContext, ScreenNavigationContext } from './context';
9
+ import { ScreenContext, ScreenHeaderContext, ScreenNavigationContext } from './context';
10
10
  import { useScreenWindowBinding } from './use-screen-window-scroll';
11
11
  import type { ScreenProps } from './types';
12
12
 
13
13
  /** One continuous canvas; chrome overlays it and content reserves its measured footprint. */
14
14
  export function Screen({ header, bottomBar, primaryAction, active: requestedActive = true, navigationScope = 'inherit', documentScroll = false, headerHeight, bottomBarHeight, contentClearance = 16, children, style, testID, ...props }: ScreenProps) {
15
- const { colors } = useTheme();
15
+ const surfaceFill = useSurfaceFill();
16
16
  const parentScreen = useContext(ScreenContext);
17
17
  const active = requestedActive && (navigationScope === 'isolated' ? true : parentScreen?.active ?? true);
18
18
  const scrollY = useSharedValue(0);
@@ -40,12 +40,13 @@ export function Screen({ header, bottomBar, primaryAction, active: requestedActi
40
40
  contentInsetsHandled: document, topInset: header ? top : 0, bottomInset: keyboardVisible ? contentClearance : hasBottom ? bottom + contentClearance : navigationScope === 'inherit' ? inheritedNavigation?.bottomInset ?? contentClearance : contentClearance,
41
41
  }), [active, scrollY, collapseProgress, collapseTarget, activeScrollerId, header, hasBottom, top, bottom, contentClearance, navigationScope, inheritedNavigation?.bottomInset, document, keyboardVisible]);
42
42
  useScreenWindowBinding(value, { active: document });
43
- const headerNode = header ? <View testID={testID ? `${testID}-header` : undefined} pointerEvents="box-none" onLayout={event => setTop(event.nativeEvent.layout.height)} style={document ? { position: WEB_POSITION_STICKY, top: 0, zIndex: Z_INDEX.floating, marginBottom: -top } : { position: 'absolute', top: 0, left: 0, right: 0 }}>{header}</View> : null;
43
+ const documentHeaderStyle: WebCssStyle = { position: WEB_POSITION_STICKY, top: WEB_SURFACE_STICKY_TOP, zIndex: Z_INDEX.floating, marginBottom: -top, transitionProperty: 'top', transitionDuration: 'var(--bloom-panel-inset-duration, 0ms)', transitionTimingFunction: 'ease-in-out' };
44
+ const headerNode = header ? <View testID={testID ? `${testID}-header` : undefined} pointerEvents="box-none" onLayout={event => setTop(event.nativeEvent.layout.height)} style={document ? documentHeaderStyle : { position: 'absolute', top: 0, left: 0, right: 0 }}><ScreenHeaderContext.Provider value={value}>{header}</ScreenHeaderContext.Provider></View> : null;
44
45
  const bottomNode = hasBottom ? <View testID={testID ? `${testID}-bottom` : undefined} pointerEvents="box-none" onLayout={event => setBottom(event.nativeEvent.layout.height)} style={document ? { position: WEB_POSITION_STICKY, bottom: 0, zIndex: Z_INDEX.floating, marginTop: -bottom } : { position: 'absolute', bottom: 0, left: 0, right: 0 }}>{bottomBar ?? <View pointerEvents="box-none" style={{ alignItems: 'flex-end', paddingHorizontal: 16, paddingBottom: windowEdgeGap(insets?.bottom ?? 0), minHeight: bottom }}>{primaryAction}</View>}</View> : null;
45
46
  return (
46
47
  <ScreenNavigationContext.Provider value={navigationScope === 'inherit' ? inheritedNavigation : { ...navigation, bottomInset: value.bottomInset }}>
47
48
  <ScreenContext.Provider value={value}>
48
- <View {...props} testID={testID} style={[document ? { minHeight: WEB_VIEWPORT_HEIGHT, width: '100%', position: 'relative', backgroundColor: colors.background } : { flex: 1, minHeight: 0, position: 'relative', backgroundColor: colors.background }, style]}>
49
+ <View {...props} testID={testID} style={[document ? { minHeight: WEB_VIEWPORT_HEIGHT, width: '100%', position: 'relative', backgroundColor: surfaceFill } : { flex: 1, minHeight: 0, position: 'relative', backgroundColor: surfaceFill }, style]}>
49
50
  {document ? headerNode : null}
50
51
  {document ? <View testID={testID ? `${testID}-content` : undefined} style={{
51
52
  flexGrow: 1, flexShrink: 0,
@@ -16,6 +16,9 @@ export interface ScreenContextValue {
16
16
  export type ScreenNavigationState = Pick<ScreenContextValue, 'collapseProgress' | 'collapseTarget' | 'activeScrollerId'> & { bottomInset?: number };
17
17
  export const ScreenNavigationContext = createContext<ScreenNavigationState | null>(null);
18
18
 
19
+ /** Only the Screen header slot owns chrome positioning; content headers remain independent. */
20
+ export const ScreenHeaderContext = createContext<ScreenContextValue | null>(null);
21
+
19
22
  export const ScreenContext = createContext<ScreenContextValue | null>(null);
20
23
  export function useScreenContext() { return useContext(ScreenContext); }
21
24
  export function useScreen(): ScreenContextValue {