@oxy.so/bloom 7.14.3 → 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.
- package/docs/button.mdx +28 -0
- package/lib/commonjs/button/Button.js +14 -2
- package/lib/commonjs/button/Button.js.map +1 -1
- package/lib/commonjs/button/Button.web.js +50 -12
- package/lib/commonjs/button/Button.web.js.map +1 -1
- package/lib/module/button/Button.js +14 -2
- package/lib/module/button/Button.js.map +1 -1
- package/lib/module/button/Button.web.js +50 -12
- package/lib/module/button/Button.web.js.map +1 -1
- package/lib/typescript/commonjs/button/Button.d.ts +1 -1
- package/lib/typescript/commonjs/button/Button.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/Button.web.d.ts +1 -1
- package/lib/typescript/commonjs/button/Button.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/index.d.ts +1 -1
- package/lib/typescript/commonjs/button/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/button/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/button/types.d.ts +14 -1
- package/lib/typescript/commonjs/button/types.d.ts.map +1 -1
- package/lib/typescript/module/button/Button.d.ts +1 -1
- package/lib/typescript/module/button/Button.d.ts.map +1 -1
- package/lib/typescript/module/button/Button.web.d.ts +1 -1
- package/lib/typescript/module/button/Button.web.d.ts.map +1 -1
- package/lib/typescript/module/button/index.d.ts +1 -1
- package/lib/typescript/module/button/index.d.ts.map +1 -1
- package/lib/typescript/module/button/index.web.d.ts +1 -1
- package/lib/typescript/module/button/index.web.d.ts.map +1 -1
- package/lib/typescript/module/button/types.d.ts +14 -1
- package/lib/typescript/module/button/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/button/Button.tsx +12 -2
- package/src/button/Button.web.tsx +48 -12
- package/src/button/index.ts +2 -0
- package/src/button/index.web.ts +2 -0
- package/src/button/types.ts +15 -1
|
@@ -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
|
|
|
@@ -150,6 +152,12 @@ ${surfaceMaterialCss('.bloom-btn--surface', 'var(--bloom-btn-bg)', `background-c
|
|
|
150
152
|
|
|
151
153
|
const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebComponent({
|
|
152
154
|
onPress,
|
|
155
|
+
onFocus,
|
|
156
|
+
onBlur,
|
|
157
|
+
onHoverIn,
|
|
158
|
+
onHoverOut,
|
|
159
|
+
onKeyDown,
|
|
160
|
+
onKeyUp,
|
|
153
161
|
onLayout,
|
|
154
162
|
'aria-hidden': ariaHidden,
|
|
155
163
|
accessibilityElementsHidden,
|
|
@@ -220,6 +228,26 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
|
|
|
220
228
|
const isLink = appearance === 'plain' && (href != null || linkTone != null);
|
|
221
229
|
const isInteractionBlocked = disabled || loading;
|
|
222
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
|
+
};
|
|
223
251
|
const iconSize = typeof iconSizeProp === 'number' && Number.isFinite(iconSizeProp) && iconSizeProp > 0 ? iconSizeProp : isIconVariant ? ICON_BUTTON_ICON_SIZE[size] : geometry.iconSize;
|
|
224
252
|
|
|
225
253
|
const palette = useMemo(
|
|
@@ -427,7 +455,9 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
|
|
|
427
455
|
style?: CSSProperties;
|
|
428
456
|
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
429
457
|
onPointerDown?: React.PointerEventHandler<HTMLElement>;
|
|
458
|
+
onPointerEnter?: React.PointerEventHandler<HTMLElement>;
|
|
430
459
|
onPointerLeave?: React.PointerEventHandler<HTMLElement>;
|
|
460
|
+
onFocus?: React.FocusEventHandler<HTMLElement>;
|
|
431
461
|
onBlur?: React.FocusEventHandler<HTMLElement>;
|
|
432
462
|
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
|
433
463
|
onKeyUp?: React.KeyboardEventHandler<HTMLElement>;
|
|
@@ -447,10 +477,12 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
|
|
|
447
477
|
className: [composedClassName, childProps.className].filter(Boolean).join(' '),
|
|
448
478
|
style: { ...containerStyle, ...resolvedStyle, ...childProps.style },
|
|
449
479
|
onPointerDown: event => { childProps.onPointerDown?.(event); longPress.onPointerDown(event); },
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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); },
|
|
454
486
|
onContextMenu: event => { childProps.onContextMenu?.(event); longPress.onContextMenu(event); },
|
|
455
487
|
onClick: (event: MouseEvent<HTMLElement>) => {
|
|
456
488
|
if (longPress.suppressClick(event)) return;
|
|
@@ -486,10 +518,12 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
|
|
|
486
518
|
className={composedClassName}
|
|
487
519
|
style={{ ...containerStyle, ...resolvedStyle }}
|
|
488
520
|
onPointerDown={longPress.onPointerDown}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
521
|
+
onPointerEnter={handlePointerEnter}
|
|
522
|
+
onPointerLeave={handlePointerLeave}
|
|
523
|
+
onFocus={onFocus}
|
|
524
|
+
onBlur={handleBlur}
|
|
525
|
+
onKeyDown={handleKeyDown}
|
|
526
|
+
onKeyUp={handleKeyUp}
|
|
493
527
|
onContextMenu={longPress.onContextMenu}
|
|
494
528
|
onClick={handleClick}
|
|
495
529
|
aria-disabled={isInteractionBlocked || undefined}
|
|
@@ -516,10 +550,12 @@ const ButtonWebComponent = forwardRef<View, ButtonProps>(function ButtonWebCompo
|
|
|
516
550
|
className={composedClassName}
|
|
517
551
|
style={{ ...containerStyle, ...resolvedStyle }}
|
|
518
552
|
onPointerDown={longPress.onPointerDown}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
553
|
+
onPointerEnter={handlePointerEnter}
|
|
554
|
+
onPointerLeave={handlePointerLeave}
|
|
555
|
+
onFocus={onFocus}
|
|
556
|
+
onBlur={handleBlur}
|
|
557
|
+
onKeyDown={handleKeyDown}
|
|
558
|
+
onKeyUp={handleKeyUp}
|
|
523
559
|
onContextMenu={longPress.onContextMenu}
|
|
524
560
|
onClick={handleClick}
|
|
525
561
|
role={accessibilityRole}
|
package/src/button/index.ts
CHANGED
package/src/button/index.web.ts
CHANGED
package/src/button/types.ts
CHANGED
|
@@ -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
|