@oxy.so/bloom 7.14.2 → 7.15.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 (36) hide show
  1. package/docs/adoption-matrix.mdx +2 -2
  2. package/docs/button.mdx +76 -0
  3. package/lib/commonjs/button/Button.js +143 -67
  4. package/lib/commonjs/button/Button.js.map +1 -1
  5. package/lib/commonjs/button/Button.web.js +97 -31
  6. package/lib/commonjs/button/Button.web.js.map +1 -1
  7. package/lib/module/button/Button.js +144 -68
  8. package/lib/module/button/Button.js.map +1 -1
  9. package/lib/module/button/Button.web.js +97 -31
  10. package/lib/module/button/Button.web.js.map +1 -1
  11. package/lib/typescript/commonjs/button/Button.d.ts +1 -1
  12. package/lib/typescript/commonjs/button/Button.d.ts.map +1 -1
  13. package/lib/typescript/commonjs/button/Button.web.d.ts +1 -1
  14. package/lib/typescript/commonjs/button/Button.web.d.ts.map +1 -1
  15. package/lib/typescript/commonjs/button/index.d.ts +1 -1
  16. package/lib/typescript/commonjs/button/index.d.ts.map +1 -1
  17. package/lib/typescript/commonjs/button/index.web.d.ts +1 -1
  18. package/lib/typescript/commonjs/button/index.web.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/button/types.d.ts +14 -1
  20. package/lib/typescript/commonjs/button/types.d.ts.map +1 -1
  21. package/lib/typescript/module/button/Button.d.ts +1 -1
  22. package/lib/typescript/module/button/Button.d.ts.map +1 -1
  23. package/lib/typescript/module/button/Button.web.d.ts +1 -1
  24. package/lib/typescript/module/button/Button.web.d.ts.map +1 -1
  25. package/lib/typescript/module/button/index.d.ts +1 -1
  26. package/lib/typescript/module/button/index.d.ts.map +1 -1
  27. package/lib/typescript/module/button/index.web.d.ts +1 -1
  28. package/lib/typescript/module/button/index.web.d.ts.map +1 -1
  29. package/lib/typescript/module/button/types.d.ts +14 -1
  30. package/lib/typescript/module/button/types.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/src/button/Button.tsx +107 -73
  33. package/src/button/Button.web.tsx +82 -31
  34. package/src/button/index.ts +2 -0
  35. package/src/button/index.web.ts +2 -0
  36. package/src/button/types.ts +15 -1
@@ -1,5 +1,5 @@
1
1
  export { Button, PrimaryButton, SecondaryButton, IconButton, GhostButton, TextButton, InverseButton, OutlineButton, LinkButton, DestructiveButton, } from './Button.web';
2
2
  export { CloseButton } from './CloseButton';
3
3
  export { GlyphButton } from './GlyphButton';
4
- export type { ButtonProps, ButtonSize, ButtonIconComponent, ButtonLinkTone, ButtonUnderline, LinkButtonProps, CloseButtonProps, GlyphButtonProps, } from './types';
4
+ export type { ButtonProps, ButtonSize, ButtonFocusEvent, ButtonHoverEvent, ButtonIconComponent, ButtonLinkTone, ButtonUnderline, LinkButtonProps, CloseButtonProps, GlyphButtonProps, } from './types';
5
5
  //# sourceMappingURL=index.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/button/index.web.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,MAAM,EACN,aAAa,EACb,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EACV,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/button/index.web.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,MAAM,EACN,aAAa,EACb,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
@@ -1,13 +1,23 @@
1
1
  import type { BloomAppearance, BloomTone, BloomSize } from '../appearance/types';
2
2
  import type { BloomIconRenderer } from '../icons/render-icon';
3
3
  import type { ReactNode } from 'react';
4
- import type { GestureResponderEvent, LayoutChangeEvent, ViewProps, StyleProp, ViewStyle, TextStyle } from 'react-native';
4
+ import type { GestureResponderEvent, FocusEvent as NativeFocusEvent, MouseEvent as NativeMouseEvent, LayoutChangeEvent, ViewProps, StyleProp, ViewStyle, TextStyle } from 'react-native';
5
5
  import type { WebAriaProps } from '../styles/styled-primitives';
6
6
  import type { BloomIconComponent } from '../icons/icon-component';
7
7
  import type { TypeScaleVariant } from '../typography/scale';
8
8
  /** Shared control size; square geometry is expressed with iconOnly. */
9
9
  export type ButtonSize = BloomSize;
10
+ /** The original platform focus event, without a synthetic cross-platform adapter. */
11
+ export type ButtonFocusEvent = NativeFocusEvent | React.FocusEvent<HTMLElement>;
12
+ /** Native Pressable hover event or the original non-touch web pointer event. */
13
+ export type ButtonHoverEvent = NativeMouseEvent | React.PointerEvent<HTMLElement>;
10
14
  export interface ButtonProps {
15
+ /** Focus lifecycle on the interactive host; does not activate the button. */
16
+ onFocus?: (event: ButtonFocusEvent) => void;
17
+ onBlur?: (event: ButtonFocusEvent) => void;
18
+ /** Pointer preview lifecycle. Touch gestures do not synthesize web hover. */
19
+ onHoverIn?: (event: ButtonHoverEvent) => void;
20
+ onHoverOut?: (event: ButtonHoverEvent) => void;
11
21
  onLayout?: (event: LayoutChangeEvent) => void;
12
22
  'aria-hidden'?: boolean;
13
23
  accessibilityElementsHidden?: boolean;
@@ -151,6 +161,9 @@ export interface ButtonProps {
151
161
  * and `'reset'` to reset a form.
152
162
  */
153
163
  type?: 'button' | 'submit' | 'reset';
164
+ /** Original DOM keyboard event (web only). preventDefault cancels native key behavior. */
165
+ onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
166
+ onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
154
167
  /**
155
168
  * Web click handler. Aliased to the same logical action as `onPress` — either
156
169
  * (or both) may be provided; both fire on click. `onPress` is kept for
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC;AAEnC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,yBAAyB,CAAC,EAAE,SAAS,CAAC,2BAA2B,CAAC,CAAC;IACnE,yEAAyE;IACzE,MAAM,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC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CAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,4CAA4C;IAC5C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,QAAQ,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,YAAY,CAAC,eAAe,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,gFAAgF;AAChF,+FAA+F;AAC/F,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/bloom",
3
- "version": "7.14.2",
3
+ "version": "7.15.0",
4
4
  "packageManager": "bun@1.3.14",
5
5
  "description": "Bloom UI — Oxy ecosystem component library for React Native + Expo + Web",
6
6
  "main": "lib/commonjs/index.js",
@@ -1,6 +1,6 @@
1
1
  import { useSurfaceLayer } from '../surface/use-surface-layer';
2
2
  import type { LinkButtonProps } from './types';
3
- import React, { forwardRef, useMemo, useRef, useEffect, memo, type ComponentType } from 'react';
3
+ import React, { forwardRef, useMemo, useRef, useEffect, memo, type ComponentType, createContext, useContext } from 'react';
4
4
  import { resolveIconSlot } from '../icons/render-icon';
5
5
  import {
6
6
  ActivityIndicator,
@@ -63,6 +63,8 @@ function renderTextContent(node: React.ReactNode, wrap: (text: React.ReactNode)
63
63
  export type {
64
64
  ButtonProps, LinkButtonProps,
65
65
  ButtonSize,
66
+ ButtonFocusEvent,
67
+ ButtonHoverEvent,
66
68
  ButtonIconComponent,
67
69
  } from './types';
68
70
 
@@ -154,10 +156,11 @@ type ButtonPressableProps = Pick<
154
156
  | 'accessibilityLabel'
155
157
  | 'accessibilityRole'
156
158
  | 'accessibilityState'
157
- | 'children'
158
159
  | 'className'
159
160
  | 'disabled'
160
161
  | 'hitSlop'
162
+ | 'onFocus'
163
+ | 'onBlur'
161
164
  | 'onHoverIn'
162
165
  | 'onHoverOut'
163
166
  | 'onPress'
@@ -168,16 +171,73 @@ type ButtonPressableProps = Pick<
168
171
  | 'onPressIn'
169
172
  | 'onPressOut'
170
173
  | 'testID'
171
- > & { style?: StyleProp<ViewStyle>; 'aria-hidden'?: boolean; 'aria-expanded'?: boolean; 'aria-pressed'?: boolean };
174
+ > & { children?: React.ReactNode; style?: StyleProp<ViewStyle>; baseStyle?: StyleProp<ViewStyle>; 'aria-hidden'?: boolean; 'aria-expanded'?: boolean; 'aria-pressed'?: boolean };
172
175
 
173
- const ButtonPressable: ComponentType<ButtonPressableProps> = Pressable;
176
+ const CONTENT_TEXT_KEYS = ['color', 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle',
177
+ 'lineHeight', 'letterSpacing', 'textAlign', 'textDecorationLine'] as const;
174
178
 
175
- const StyledPressable: ComponentType<ButtonPressableProps & React.RefAttributes<View>> = styled(ButtonPressable, {
179
+ const ContentStyleContext = createContext<{ text?: TextStyle; layout?: ViewStyle }>({});
180
+
181
+ // Resolve utilities without mixing Bloom's defaults into their input. The
182
+ // defaults are merged only after interop, so caller classes have final say.
183
+ const ButtonPressable = forwardRef<View, ButtonPressableProps>(function ButtonPressable({
184
+ baseStyle, style, children, ...props
185
+ }, ref) {
186
+ const resolved = StyleSheet.flatten(style) as TextStyle | undefined;
187
+ const layout: TextStyle = { ...resolved };
188
+ const text: TextStyle = {};
189
+ // Read a copy: the CSS resolver can share its cached style objects with
190
+ // other controls. Moving properties out of that cache changes their styles.
191
+ for (const key of CONTENT_TEXT_KEYS) {
192
+ if (resolved?.[key] !== undefined) Object.assign(text, { [key]: resolved[key] });
193
+ delete layout[key];
194
+ }
195
+ return <Pressable {...props} ref={ref} style={[baseStyle, layout]}>
196
+ <ContentStyleContext.Provider value={{ text, layout }}>
197
+ {children}
198
+ </ContentStyleContext.Provider>
199
+ </Pressable>;
200
+ });
201
+
202
+ function ButtonContent({ loading, gap, children }: {
203
+ loading: boolean; gap: number; children: (style: TextStyle) => React.ReactNode;
204
+ }) {
205
+ const { text, layout } = useContext(ContentStyleContext);
206
+ const contentLayout = layout && {
207
+ ...(layout.flexDirection !== undefined && { flexDirection: layout.flexDirection }),
208
+ ...(layout.flexWrap !== undefined && { flexWrap: layout.flexWrap }),
209
+ ...(layout.alignItems !== undefined && { alignItems: layout.alignItems }),
210
+ ...(layout.justifyContent !== undefined && { justifyContent: layout.justifyContent }),
211
+ ...(layout.gap !== undefined && { gap: layout.gap }),
212
+ ...(layout.rowGap !== undefined && { rowGap: layout.rowGap }),
213
+ ...(layout.columnGap !== undefined && { columnGap: layout.columnGap }),
214
+ };
215
+ return <View pointerEvents={loading ? 'none' : undefined}
216
+ style={[styles.content, { gap }, contentLayout, loading && { opacity: 0 }]}
217
+ importantForAccessibility={loading ? 'no-hide-descendants' : undefined}
218
+ accessibilityElementsHidden={loading || undefined}>
219
+ {children(text ?? {})}
220
+ </View>;
221
+ }
222
+
223
+ function ButtonLoading({ color, fallback }: { color?: string; fallback: string }) {
224
+ const { text } = useContext(ContentStyleContext);
225
+ return <View pointerEvents="none" style={styles.loadingOverlay}>
226
+ <ActivityIndicator size="small" color={color ?? text?.color ?? fallback} />
227
+ </View>;
228
+ }
229
+
230
+ const ButtonInterop: ComponentType<ButtonPressableProps> = ButtonPressable;
231
+ const StyledPressable: ComponentType<ButtonPressableProps & React.RefAttributes<View>> = styled(ButtonInterop, {
176
232
  className: 'style',
177
233
  });
178
234
 
179
235
  const ButtonComponent = forwardRef<View, ButtonProps>(function ButtonComponent({
180
236
  onPress,
237
+ onFocus,
238
+ onBlur,
239
+ onHoverIn,
240
+ onHoverOut,
181
241
  onLayout,
182
242
  'aria-hidden': ariaHidden,
183
243
  accessibilityElementsHidden,
@@ -339,55 +399,45 @@ const ButtonComponent = forwardRef<View, ButtonProps>(function ButtonComponent({
339
399
  : (android ? ANDROID_SIZE_HIT_SLOP : SIZE_HIT_SLOP)[size];
340
400
 
341
401
  const IconFromProp = icon != null && isIconComponent(icon) ? icon : null;
342
- const iconNode = IconFromProp ? (
343
- <IconFromProp width={iconSize} height={iconSize} fill={paint.foreground} />
344
- ) : (
345
- (icon as React.ReactNode) ?? null
346
- );
347
-
348
- const content = (
349
- <>
350
- {resolveIconSlot(renderLeadingIcon, iconSize, paint.foreground, () =>
351
- LeadingIcon ? (
352
- <LeadingIcon width={iconSize} height={iconSize} fill={paint.foreground} />
353
- ) : null,
354
- )}
355
- {leading}
356
- {iconNode}
357
- {children != null && (!isSquare || (!renderLeadingIcon && !LeadingIcon && !iconNode))
358
- ? renderTextContent(children, text => (
359
- <Text variant={textVariant ?? geometry.type} numberOfLines={numberOfLines} style={[computedTextStyle, textStyle]}>
360
- {text}
361
- </Text>
362
- )) : null}
363
- {trailing}
364
- {!isSquare
365
- ? resolveIconSlot(renderTrailingIcon, iconSize, paint.foreground, () =>
366
- TrailingIcon ? (
367
- <TrailingIcon width={iconSize} height={iconSize} fill={paint.foreground} />
368
- ) : null,
369
- )
370
- : null}
371
- </>
372
- );
402
+ const content = (classText: TextStyle) => {
403
+ const foreground = typeof classText.color === 'string' ? classText.color : paint.foreground;
404
+ const iconNode = IconFromProp ? (
405
+ <IconFromProp width={iconSize} height={iconSize} fill={foreground} />
406
+ ) : (
407
+ (icon as React.ReactNode) ?? null
408
+ );
409
+
410
+ return (
411
+ <>
412
+ {resolveIconSlot(renderLeadingIcon, iconSize, foreground, () =>
413
+ LeadingIcon ? (
414
+ <LeadingIcon width={iconSize} height={iconSize} fill={foreground} />
415
+ ) : null,
416
+ )}
417
+ {leading}
418
+ {iconNode}
419
+ {children != null && (!isSquare || (!renderLeadingIcon && !LeadingIcon && !iconNode))
420
+ ? renderTextContent(children, text => (
421
+ <Text variant={textVariant ?? geometry.type} numberOfLines={numberOfLines} style={[computedTextStyle, classText, textStyle]}>
422
+ {text}
423
+ </Text>
424
+ )) : null}
425
+ {trailing}
426
+ {!isSquare
427
+ ? resolveIconSlot(renderTrailingIcon, iconSize, foreground, () =>
428
+ TrailingIcon ? (
429
+ <TrailingIcon width={iconSize} height={iconSize} fill={foreground} />
430
+ ) : null,
431
+ )
432
+ : null}
433
+ </>
434
+ );
435
+ };
373
436
 
374
437
  const handlePress = isInteractionBlocked
375
438
  ? undefined
376
439
  : onPress ?? (href != null ? () => void Linking.openURL(href) : undefined);
377
440
 
378
- // Retain one content host for its entire lifetime. Match caller layout
379
- // overrides inside it, while padding and the outer button box stay put.
380
- const callerStyle = StyleSheet.flatten(style);
381
- const contentLayout = callerStyle && {
382
- ...(callerStyle.flexDirection !== undefined && { flexDirection: callerStyle.flexDirection }),
383
- ...(callerStyle.flexWrap !== undefined && { flexWrap: callerStyle.flexWrap }),
384
- ...(callerStyle.alignItems !== undefined && { alignItems: callerStyle.alignItems }),
385
- ...(callerStyle.justifyContent !== undefined && { justifyContent: callerStyle.justifyContent }),
386
- ...(callerStyle.gap !== undefined && { gap: callerStyle.gap }),
387
- ...(callerStyle.rowGap !== undefined && { rowGap: callerStyle.rowGap }),
388
- ...(callerStyle.columnGap !== undefined && { columnGap: callerStyle.columnGap }),
389
- };
390
-
391
441
  return (
392
442
  <StyledPressable
393
443
  ref={ref}
@@ -396,10 +446,8 @@ const ButtonComponent = forwardRef<View, ButtonProps>(function ButtonComponent({
396
446
  accessibilityElementsHidden={accessibilityElementsHidden}
397
447
  importantForAccessibility={importantForAccessibility}
398
448
  className={className}
399
- style={[
400
- baseStyles,
401
- style,
402
- ]}
449
+ baseStyle={baseStyles}
450
+ style={style}
403
451
  onLongPress={isInteractionBlocked ? undefined : onLongPress}
404
452
  onPress={handlePress ? event => {
405
453
  if (stopPropagation) event.stopPropagation();
@@ -407,8 +455,10 @@ const ButtonComponent = forwardRef<View, ButtonProps>(function ButtonComponent({
407
455
  } : undefined}
408
456
  onPressIn={handlePressIn}
409
457
  onPressOut={handlePressOut}
410
- onHoverIn={isInteractionBlocked ? undefined : onHoveredIn}
411
- onHoverOut={isInteractionBlocked ? undefined : onHoveredOut}
458
+ onFocus={onFocus}
459
+ onBlur={onBlur}
460
+ onHoverIn={isInteractionBlocked ? undefined : event => { onHoveredIn(); onHoverIn?.(event); }}
461
+ onHoverOut={event => { onHoveredOut(); onHoverOut?.(event); }}
412
462
  disabled={isInteractionBlocked}
413
463
  hitSlop={hitSlop ?? defaultHitSlop}
414
464
  accessibilityLabel={accessibilityLabel}
@@ -428,24 +478,8 @@ const ButtonComponent = forwardRef<View, ButtonProps>(function ButtonComponent({
428
478
  {paint.surface ? (
429
479
  <SurfacePaint fill={paint.background} radius={StyleSheet.flatten(style)?.borderRadius ?? BUTTON_RADIUS} />
430
480
  ) : null}
431
- <View
432
- pointerEvents={loading ? 'none' : undefined}
433
- style={[
434
- styles.content,
435
- { gap: geometry.gap },
436
- contentLayout,
437
- loading && { opacity: 0 },
438
- ]}
439
- importantForAccessibility={loading ? 'no-hide-descendants' : undefined}
440
- accessibilityElementsHidden={loading || undefined}
441
- >
442
- {content}
443
- </View>
444
- {loading ? (
445
- <View pointerEvents="none" style={styles.loadingOverlay}>
446
- <ActivityIndicator size="small" color={loadingColor ?? paint.foreground} />
447
- </View>
448
- ) : null}
481
+ <ButtonContent loading={loading} gap={geometry.gap}>{content}</ButtonContent>
482
+ {loading ? <ButtonLoading color={loadingColor} fallback={paint.foreground} /> : null}
449
483
  </StyledPressable>
450
484
  );
451
485
  });
@@ -33,6 +33,8 @@ import type { ButtonIconComponent, ButtonProps } from './types';
33
33
  export type {
34
34
  ButtonProps, LinkButtonProps,
35
35
  ButtonSize,
36
+ ButtonFocusEvent,
37
+ ButtonHoverEvent,
36
38
  ButtonIconComponent,
37
39
  } from './types';
38
40
 
@@ -62,10 +64,18 @@ const DISABLED = '.bloom-btn:disabled:not([aria-busy="true"]),\n.bloom-btn[aria-
62
64
  * applies none of them, so a modifier class alone proves nothing about whether
63
65
  * an underline is drawn.
64
66
  */
65
- export const BLOOM_BUTTON_CSS = interactiveWebCss({
67
+ export const BLOOM_BUTTON_CSS = `@layer base {\n${interactiveWebCss({
66
68
  selector: '.bloom-btn',
67
69
  varPrefix: 'bloom-btn',
68
70
  base: `
71
+ height: var(--bloom-btn-height);
72
+ width: var(--bloom-btn-width, auto);
73
+ padding-inline: var(--bloom-btn-padding);
74
+ border-radius: var(--bloom-btn-radius);
75
+ font-size: var(--bloom-btn-font-size);
76
+ line-height: var(--bloom-btn-line-height);
77
+ font-weight: var(--bloom-btn-font-weight);
78
+ letter-spacing: var(--bloom-btn-letter-spacing, normal);
69
79
  flex-direction: row;
70
80
  gap: var(--bloom-btn-gap, 2px);
71
81
  position: relative;
@@ -134,7 +144,7 @@ ${surfaceMaterialCss('.bloom-btn--surface', 'var(--bloom-btn-bg)', `background-c
134
144
  transition: none;
135
145
  }
136
146
  }`,
137
- });
147
+ })}\n}`;
138
148
 
139
149
  // ---------------------------------------------------------------------------
140
150
  // Component
@@ -142,6 +152,12 @@ ${surfaceMaterialCss('.bloom-btn--surface', 'var(--bloom-btn-bg)', `background-c
142
152
 
143
153
  const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebComponent({
144
154
  onPress,
155
+ onFocus,
156
+ onBlur,
157
+ onHoverIn,
158
+ onHoverOut,
159
+ onKeyDown,
160
+ onKeyUp,
145
161
  onLayout,
146
162
  'aria-hidden': ariaHidden,
147
163
  accessibilityElementsHidden,
@@ -212,6 +228,26 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
212
228
  const isLink = appearance === 'plain' && (href != null || linkTone != null);
213
229
  const isInteractionBlocked = disabled || loading;
214
230
  const longPress = useLongPress(onLongPress, isInteractionBlocked, onPressIn, onPressOut);
231
+ const handleBlur: React.FocusEventHandler<HTMLElement> = event => {
232
+ onBlur?.(event);
233
+ longPress.onBlur();
234
+ };
235
+ const handleKeyDown: React.KeyboardEventHandler<HTMLElement> = event => {
236
+ onKeyDown?.(event);
237
+ longPress.onKeyDown(event);
238
+ };
239
+ const handleKeyUp: React.KeyboardEventHandler<HTMLElement> = event => {
240
+ onKeyUp?.(event);
241
+ // Cleanup remains unconditional even when a caller cancels default behavior.
242
+ longPress.onKeyUp(event);
243
+ };
244
+ const handlePointerEnter: React.PointerEventHandler<HTMLElement> = event => {
245
+ if (!isInteractionBlocked && event.pointerType !== 'touch') onHoverIn?.(event);
246
+ };
247
+ const handlePointerLeave: React.PointerEventHandler<HTMLElement> = event => {
248
+ if (event.pointerType !== 'touch') onHoverOut?.(event);
249
+ longPress.onPointerLeave();
250
+ };
215
251
  const iconSize = typeof iconSizeProp === 'number' && Number.isFinite(iconSizeProp) && iconSizeProp > 0 ? iconSizeProp : isIconVariant ? ICON_BUTTON_ICON_SIZE[size] : geometry.iconSize;
216
252
 
217
253
  const palette = useMemo(
@@ -223,14 +259,13 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
223
259
  const containerStyle = useMemo((): CSSProperties => {
224
260
  const shadow = palette.shadow ? BUTTON_SHADOW[theme.isDark ? 'dark' : 'light'] : 'none';
225
261
  const base: CSSProperties = {
226
- height: geometry.height,
227
- paddingLeft: geometry.paddingHorizontal,
228
- paddingRight: geometry.paddingHorizontal,
229
- borderRadius: BUTTON_RADIUS,
230
- fontSize: geometry.fontSize,
231
- lineHeight: `${geometry.lineHeight}px`,
232
- fontWeight: Number(geometry.fontWeight),
233
- letterSpacing: geometry.letterSpacing || undefined,
262
+ ['--bloom-btn-height' as string]: `${geometry.height}px`,
263
+ ['--bloom-btn-padding' as string]: `${geometry.paddingHorizontal}px`,
264
+ ['--bloom-btn-radius' as string]: `${BUTTON_RADIUS}px`,
265
+ ['--bloom-btn-font-size' as string]: `${geometry.fontSize}px`,
266
+ ['--bloom-btn-line-height' as string]: `${geometry.lineHeight}px`,
267
+ ['--bloom-btn-font-weight' as string]: geometry.fontWeight,
268
+ ['--bloom-btn-letter-spacing' as string]: geometry.letterSpacing ? `${geometry.letterSpacing}px` : 'normal',
234
269
  // CSS custom props consumed by the static stylesheet — see its header.
235
270
  ['--bloom-surface-rim' as string]: resolveSurfaceOptics(theme.isDark).rim,
236
271
  ['--bloom-surface-sheen' as string]: resolveSurfaceOptics(theme.isDark).sheenCss,
@@ -254,22 +289,30 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
254
289
  ['--bloom-btn-border-active' as string]: palette.active.border,
255
290
  ['--bloom-btn-border-disabled' as string]: palette.disabled.border,
256
291
  };
292
+ // Keep the existing inline defaults for callers without utilities. When
293
+ // classes are present, the same defaults come from the base layer.
294
+ if (!className) Object.assign(base, {
295
+ height: geometry.height, paddingLeft: geometry.paddingHorizontal,
296
+ paddingRight: geometry.paddingHorizontal, borderRadius: BUTTON_RADIUS,
297
+ fontSize: geometry.fontSize, lineHeight: `${geometry.lineHeight}px`,
298
+ fontWeight: Number(geometry.fontWeight), letterSpacing: geometry.letterSpacing || undefined,
299
+ });
257
300
  if (isSquare) {
258
- base.width = geometry.height;
259
- base.paddingLeft = 0;
260
- base.paddingRight = 0;
301
+ if (!className) Object.assign(base, { width: geometry.height, paddingLeft: 0, paddingRight: 0 });
302
+ (base as Record<string, unknown>)['--bloom-btn-width'] = `${geometry.height}px`;
303
+ (base as Record<string, unknown>)['--bloom-btn-padding'] = '0px';
261
304
  }
262
305
  if (isLink && !isSquare) {
263
306
  // LinkButton: no container at all — the label's own line box,
264
307
  // a 4px gap, and a 4px corner that only the focus ring shows.
265
- base.height = undefined;
266
- base.paddingLeft = 0;
267
- base.paddingRight = 0;
268
- base.borderRadius = 4;
308
+ if (!className) Object.assign(base, { height: undefined, paddingLeft: 0, paddingRight: 0, borderRadius: 4 });
309
+ (base as Record<string, unknown>)['--bloom-btn-height'] = 'auto';
310
+ (base as Record<string, unknown>)['--bloom-btn-padding'] = '0px';
311
+ (base as Record<string, unknown>)['--bloom-btn-radius'] = '4px';
269
312
  (base as Record<string, unknown>)['--bloom-btn-gap'] = `${LINK_BUTTON_GAP}px`;
270
313
  }
271
314
  return base;
272
- }, [geometry, palette, theme.isDark, isSquare, isIconVariant, isLink, togglePressed, loading]);
315
+ }, [geometry, palette, theme.isDark, isSquare, isIconVariant, isLink, togglePressed, loading, className]);
273
316
 
274
317
  const handleClick = useCallback(
275
318
  (event: MouseEvent<HTMLElement>) => {
@@ -293,7 +336,7 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
293
336
  .join(' ');
294
337
 
295
338
  const spinnerColor =
296
- loadingColor ?? (disabled ? palette.disabled.foreground : palette.rest.foreground);
339
+ loadingColor ?? 'currentColor';
297
340
 
298
341
  // Normalize the caller's `style` (single object, StyleProp array, or falsy)
299
342
  // into ONE flat plain object here, once, so neither raw-DOM merge site below
@@ -412,7 +455,9 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
412
455
  style?: CSSProperties;
413
456
  onClick?: (event: MouseEvent<HTMLElement>) => void;
414
457
  onPointerDown?: React.PointerEventHandler<HTMLElement>;
458
+ onPointerEnter?: React.PointerEventHandler<HTMLElement>;
415
459
  onPointerLeave?: React.PointerEventHandler<HTMLElement>;
460
+ onFocus?: React.FocusEventHandler<HTMLElement>;
416
461
  onBlur?: React.FocusEventHandler<HTMLElement>;
417
462
  onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
418
463
  onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
@@ -432,10 +477,12 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
432
477
  className: [composedClassName, childProps.className].filter(Boolean).join(' '),
433
478
  style: { ...containerStyle, ...resolvedStyle, ...childProps.style },
434
479
  onPointerDown: event => { childProps.onPointerDown?.(event); longPress.onPointerDown(event); },
435
- onPointerLeave: event => { childProps.onPointerLeave?.(event); longPress.onPointerLeave(); },
436
- onBlur: event => { childProps.onBlur?.(event); longPress.onBlur(); },
437
- onKeyDown: event => { childProps.onKeyDown?.(event); longPress.onKeyDown(event); },
438
- onKeyUp: event => { childProps.onKeyUp?.(event); longPress.onKeyUp(event); },
480
+ onPointerEnter: event => { childProps.onPointerEnter?.(event); handlePointerEnter(event); },
481
+ onPointerLeave: event => { childProps.onPointerLeave?.(event); handlePointerLeave(event); },
482
+ onFocus: event => { childProps.onFocus?.(event); onFocus?.(event); },
483
+ onBlur: event => { childProps.onBlur?.(event); handleBlur(event); },
484
+ onKeyDown: event => { childProps.onKeyDown?.(event); handleKeyDown(event); },
485
+ onKeyUp: event => { childProps.onKeyUp?.(event); handleKeyUp(event); },
439
486
  onContextMenu: event => { childProps.onContextMenu?.(event); longPress.onContextMenu(event); },
440
487
  onClick: (event: MouseEvent<HTMLElement>) => {
441
488
  if (longPress.suppressClick(event)) return;
@@ -471,10 +518,12 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
471
518
  className={composedClassName}
472
519
  style={{ ...containerStyle, ...resolvedStyle }}
473
520
  onPointerDown={longPress.onPointerDown}
474
- onPointerLeave={longPress.onPointerLeave}
475
- onBlur={longPress.onBlur}
476
- onKeyDown={longPress.onKeyDown}
477
- onKeyUp={longPress.onKeyUp}
521
+ onPointerEnter={handlePointerEnter}
522
+ onPointerLeave={handlePointerLeave}
523
+ onFocus={onFocus}
524
+ onBlur={handleBlur}
525
+ onKeyDown={handleKeyDown}
526
+ onKeyUp={handleKeyUp}
478
527
  onContextMenu={longPress.onContextMenu}
479
528
  onClick={handleClick}
480
529
  aria-disabled={isInteractionBlocked || undefined}
@@ -501,10 +550,12 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
501
550
  className={composedClassName}
502
551
  style={{ ...containerStyle, ...resolvedStyle }}
503
552
  onPointerDown={longPress.onPointerDown}
504
- onPointerLeave={longPress.onPointerLeave}
505
- onBlur={longPress.onBlur}
506
- onKeyDown={longPress.onKeyDown}
507
- onKeyUp={longPress.onKeyUp}
553
+ onPointerEnter={handlePointerEnter}
554
+ onPointerLeave={handlePointerLeave}
555
+ onFocus={onFocus}
556
+ onBlur={handleBlur}
557
+ onKeyDown={handleKeyDown}
558
+ onKeyUp={handleKeyUp}
508
559
  onContextMenu={longPress.onContextMenu}
509
560
  onClick={handleClick}
510
561
  role={accessibilityRole}
@@ -16,6 +16,8 @@ export { GlyphButton } from './GlyphButton';
16
16
  export type {
17
17
  ButtonProps,
18
18
  ButtonSize,
19
+ ButtonFocusEvent,
20
+ ButtonHoverEvent,
19
21
  ButtonIconComponent,
20
22
  ButtonLinkTone,
21
23
  ButtonUnderline,
@@ -21,6 +21,8 @@ export { GlyphButton } from './GlyphButton';
21
21
  export type {
22
22
  ButtonProps,
23
23
  ButtonSize,
24
+ ButtonFocusEvent,
25
+ ButtonHoverEvent,
24
26
  ButtonIconComponent,
25
27
  ButtonLinkTone,
26
28
  ButtonUnderline,
@@ -1,7 +1,7 @@
1
1
  import type { BloomAppearance, BloomTone, BloomSize } from '../appearance/types';
2
2
  import type { BloomIconRenderer } from '../icons/render-icon';
3
3
  import type { ReactNode } from 'react';
4
- import type { GestureResponderEvent, LayoutChangeEvent, ViewProps, StyleProp, ViewStyle, TextStyle } from 'react-native';
4
+ import type { GestureResponderEvent, FocusEvent as NativeFocusEvent, MouseEvent as NativeMouseEvent, LayoutChangeEvent, ViewProps, StyleProp, ViewStyle, TextStyle } from 'react-native';
5
5
  import type { WebAriaProps } from '../styles/styled-primitives';
6
6
  import type { BloomIconComponent } from '../icons/icon-component';
7
7
  import type { TypeScaleVariant } from '../typography/scale';
@@ -9,7 +9,18 @@ import type { TypeScaleVariant } from '../typography/scale';
9
9
  /** Shared control size; square geometry is expressed with iconOnly. */
10
10
  export type ButtonSize = BloomSize;
11
11
 
12
+ /** The original platform focus event, without a synthetic cross-platform adapter. */
13
+ export type ButtonFocusEvent = NativeFocusEvent | React.FocusEvent<HTMLElement>;
14
+ /** Native Pressable hover event or the original non-touch web pointer event. */
15
+ export type ButtonHoverEvent = NativeMouseEvent | React.PointerEvent<HTMLElement>;
16
+
12
17
  export interface ButtonProps {
18
+ /** Focus lifecycle on the interactive host; does not activate the button. */
19
+ onFocus?: (event: ButtonFocusEvent) => void;
20
+ onBlur?: (event: ButtonFocusEvent) => void;
21
+ /** Pointer preview lifecycle. Touch gestures do not synthesize web hover. */
22
+ onHoverIn?: (event: ButtonHoverEvent) => void;
23
+ onHoverOut?: (event: ButtonHoverEvent) => void;
13
24
  onLayout?: (event: LayoutChangeEvent) => void;
14
25
  'aria-hidden'?: boolean;
15
26
  accessibilityElementsHidden?: boolean;
@@ -166,6 +177,9 @@ export interface ButtonProps {
166
177
  * and `'reset'` to reset a form.
167
178
  */
168
179
  type?: 'button' | 'submit' | 'reset';
180
+ /** Original DOM keyboard event (web only). preventDefault cancels native key behavior. */
181
+ onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
182
+ onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
169
183
  /**
170
184
  * Web click handler. Aliased to the same logical action as `onPress` — either
171
185
  * (or both) may be provided; both fire on click. `onPress` is kept for