@homebound/beam 2.153.1 → 2.155.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.
@@ -20,4 +20,4 @@ export interface ButtonProps extends BeamButtonProps, BeamFocusableProps {
20
20
  }
21
21
  export declare function Button(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
22
22
  export declare type ButtonSize = "sm" | "md" | "lg";
23
- export declare type ButtonVariant = "primary" | "secondary" | "tertiary" | "danger" | "text";
23
+ export declare type ButtonVariant = "primary" | "secondary" | "tertiary" | "tertiaryDanger" | "danger" | "text";
@@ -13,11 +13,9 @@ function Button(props) {
13
13
  const { onClick: onPress, disabled, endAdornment, menuTriggerProps, tooltip, openInNew, download, contrast = false, ...otherProps } = props;
14
14
  const asLink = typeof onPress === "string";
15
15
  const showExternalLinkIcon = (asLink && (0, utils_1.isAbsoluteUrl)(onPress)) || openInNew;
16
- const [isDisabled, setIsDisabled] = (0, react_1.useState)(!!disabled);
17
- (0, react_1.useEffect)(() => {
18
- setIsDisabled(!!disabled);
19
- }, [disabled]);
20
- const ariaProps = { onPress, isDisabled, ...otherProps, ...menuTriggerProps };
16
+ const [asyncInProgress, setAsyncInProgress] = (0, react_1.useState)(false);
17
+ const isDisabled = !!disabled;
18
+ const ariaProps = { onPress, isDisabled: isDisabled || asyncInProgress, ...otherProps, ...menuTriggerProps };
21
19
  const { label,
22
20
  // Default the icon based on other properties.
23
21
  icon = download ? "download" : showExternalLinkIcon ? "linkExternal" : undefined, variant = "primary", size = "sm", buttonRef, } = ariaProps;
@@ -30,8 +28,8 @@ function Button(props) {
30
28
  : (e) => {
31
29
  const result = onPress(e);
32
30
  if (isPromise(result)) {
33
- setIsDisabled(true);
34
- result.finally(() => setIsDisabled(false));
31
+ setAsyncInProgress(true);
32
+ result.finally(() => setAsyncInProgress(false));
35
33
  }
36
34
  return result;
37
35
  },
@@ -39,12 +37,7 @@ function Button(props) {
39
37
  }, ref);
40
38
  const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)(ariaProps);
41
39
  const { hoverProps, isHovered } = (0, react_aria_1.useHover)(ariaProps);
42
- const { baseStyles, hoverStyles, disabledStyles, pressedStyles } = (0, react_1.useMemo)(() => getButtonStyles(variant, size, contrast), [variant, size, contrast]);
43
- const focusStyles = (0, react_1.useMemo)(() => !contrast
44
- ? variant === "danger"
45
- ? Css_1.Css.bshDanger.$
46
- : Css_1.Css.bshFocus.$
47
- : Css_1.Css.boxShadow(`0 0 0 2px ${variant === "tertiary" ? Css_1.Palette.LightBlue700 : Css_1.Palette.White}`).if(variant === "tertiary").bgGray700.white.$, [variant, contrast]);
40
+ const { baseStyles, hoverStyles, disabledStyles, pressedStyles, focusStyles } = (0, react_1.useMemo)(() => getButtonStyles(variant, size, contrast), [variant, size, contrast]);
48
41
  const buttonContent = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon && (0, jsx_runtime_1.jsx)(components_1.Icon, { xss: iconStyles[size], icon: icon }, void 0), label, endAdornment && (0, jsx_runtime_1.jsx)("span", Object.assign({ css: Css_1.Css.ml1.$ }, { children: endAdornment }), void 0)] }, void 0));
49
42
  const buttonAttrs = {
50
43
  ref: ref,
@@ -57,7 +50,7 @@ function Button(props) {
57
50
  ...baseStyles,
58
51
  ...(isHovered && !isPressed ? hoverStyles : {}),
59
52
  ...(isPressed ? pressedStyles : {}),
60
- ...(isDisabled ? { ...disabledStyles, ...Css_1.Css.cursorNotAllowed.$ } : {}),
53
+ ...(isDisabled || asyncInProgress ? { ...disabledStyles, ...Css_1.Css.cursorNotAllowed.$ } : {}),
61
54
  ...(isFocusVisible ? focusStyles : {}),
62
55
  },
63
56
  ...tid,
@@ -87,30 +80,44 @@ const variantStyles = (contrast) => ({
87
80
  hoverStyles: Css_1.Css.bgLightBlue900.if(contrast).bgLightBlue500.$,
88
81
  pressedStyles: Css_1.Css.bgLightBlue500.if(contrast).bgLightBlue900.$,
89
82
  disabledStyles: Css_1.Css.bgLightBlue200.if(contrast).gray600.bgLightBlue900.$,
83
+ focusStyles: Css_1.Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${Css_1.Palette.White}`).$,
90
84
  },
91
85
  secondary: {
92
86
  baseStyles: Css_1.Css.bgWhite.bGray300.bw1.ba.gray800.$,
93
87
  hoverStyles: Css_1.Css.bgGray100.if(contrast).bgGray300.$,
94
88
  pressedStyles: Css_1.Css.bgGray200.if(contrast).bgGray100.$,
95
89
  disabledStyles: Css_1.Css.bgWhite.gray400.$,
90
+ focusStyles: Css_1.Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${Css_1.Palette.White}`).$,
96
91
  },
97
92
  tertiary: {
98
93
  baseStyles: Css_1.Css.bgTransparent.lightBlue700.if(contrast).lightBlue400.$,
99
94
  hoverStyles: Css_1.Css.bgGray100.if(contrast).bgGray700.white.$,
100
95
  pressedStyles: Css_1.Css.lightBlue900.if(contrast).bgWhite.gray900.$,
101
96
  disabledStyles: Css_1.Css.gray400.if(contrast).gray700.$,
97
+ focusStyles: Css_1.Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${Css_1.Palette.LightBlue700}`).bgGray700.white.$,
98
+ },
99
+ tertiaryDanger: {
100
+ baseStyles: Css_1.Css.bgTransparent.red500.if(contrast).red500.$,
101
+ hoverStyles: Css_1.Css.bgGray100.if(contrast).bgGray700.white.$,
102
+ pressedStyles: Css_1.Css.red900.if(contrast).bgWhite.gray900.$,
103
+ disabledStyles: Css_1.Css.gray400.if(contrast).gray700.$,
104
+ focusStyles: Css_1.Css.boxShadow(`0px 0px 0px 2px ${Css_1.Palette.White}, 0px 0px 0px 4px ${Css_1.Palette.Red500}`)
105
+ .if(contrast)
106
+ .boxShadow(`0px 0px 0px 2px ${Css_1.Palette.Red500}`).$,
102
107
  },
103
108
  danger: {
104
109
  baseStyles: Css_1.Css.bgRed900.white.if(contrast).bgRed800.$,
105
110
  hoverStyles: Css_1.Css.bgRed500.if(contrast).bgRed600.$,
106
111
  pressedStyles: Css_1.Css.bgRed900.if(contrast).bgRed800.$,
107
112
  disabledStyles: Css_1.Css.bgRed200.if(contrast).bgRed900.gray600.$,
113
+ focusStyles: Css_1.Css.bshDanger.if(contrast).boxShadow(`0 0 0 2px ${Css_1.Palette.White}`).$,
108
114
  },
109
115
  text: {
110
116
  baseStyles: Css_1.Css.lightBlue700.add("fontSize", "inherit").if(contrast).lightBlue400.$,
111
117
  hoverStyles: Css_1.Css.lightBlue600.if(contrast).lightBlue300.$,
112
118
  pressedStyles: Css_1.Css.lightBlue700.if(contrast).lightBlue200.$,
113
119
  disabledStyles: Css_1.Css.lightBlue300.if(contrast).lightBlue700.$,
120
+ focusStyles: Css_1.Css.bshFocus.if(contrast).boxShadow(`0 0 0 2px ${Css_1.Palette.White}`).$,
114
121
  },
115
122
  });
116
123
  const sizeStyles = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.153.1",
3
+ "version": "2.155.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",