@homebound/beam 2.272.1 → 2.272.3
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/dist/components/IconButton.d.ts +2 -0
- package/dist/components/IconButton.js +2 -1
- package/dist/components/internal/MenuItem.js +3 -2
- package/dist/components/internal/MenuSection.js +1 -1
- package/dist/components/internal/OverlayTrigger.js +3 -1
- package/dist/inputs/internal/ComboBoxBase.js +12 -6
- package/package.json +1 -1
|
@@ -18,6 +18,8 @@ export interface IconButtonProps extends BeamButtonProps, BeamFocusableProps {
|
|
|
18
18
|
contrast?: boolean;
|
|
19
19
|
/** Denotes if this button is used to download a resource. Uses the anchor tag with the `download` attribute */
|
|
20
20
|
download?: boolean;
|
|
21
|
+
/** Provides label for screen readers - Will become a required soon */
|
|
22
|
+
label?: string;
|
|
21
23
|
}
|
|
22
24
|
export declare function IconButton(props: IconButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
23
25
|
export declare const iconButtonStylesHover: {
|
|
@@ -11,7 +11,7 @@ const utils_1 = require("../utils");
|
|
|
11
11
|
const getInteractiveElement_1 = require("../utils/getInteractiveElement");
|
|
12
12
|
const useTestIds_1 = require("../utils/useTestIds");
|
|
13
13
|
function IconButton(props) {
|
|
14
|
-
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, contrast = false, download = false, forceFocusStyles = false, } = props;
|
|
14
|
+
const { onClick: onPress, disabled, color, icon, autoFocus, inc, buttonRef, tooltip, menuTriggerProps, openInNew, compact = false, contrast = false, download = false, forceFocusStyles = false, label, } = props;
|
|
15
15
|
const isDisabled = !!disabled;
|
|
16
16
|
const ariaProps = { onPress, isDisabled, autoFocus, ...menuTriggerProps };
|
|
17
17
|
const ref = (0, useGetRef_1.useGetRef)(buttonRef);
|
|
@@ -39,6 +39,7 @@ function IconButton(props) {
|
|
|
39
39
|
className: typeof onPress === "string" ? components_1.navLink : undefined,
|
|
40
40
|
ref: ref,
|
|
41
41
|
css: styles,
|
|
42
|
+
"aria-label": label,
|
|
42
43
|
};
|
|
43
44
|
const buttonContent = ((0, jsx_runtime_1.jsx)(components_1.Icon, { icon: icon, color: color || (isDisabled ? Css_1.Palette.Gray400 : iconColor), inc: compact ? 2 : inc }));
|
|
44
45
|
// If we're disabled b/c of a non-boolean ReactNode, or the caller specified tooltip text, then show it in a tooltip
|
|
@@ -51,11 +51,12 @@ function MenuItemImpl(props) {
|
|
|
51
51
|
onClose,
|
|
52
52
|
}, state, ref);
|
|
53
53
|
return ((0, jsx_runtime_1.jsx)("li", { ...menuItemProps, ...hoverProps, ref: ref, css: {
|
|
54
|
-
...Css_1.Css.df.aic.py1.px2.cursorPointer.outline0.mh("42px").$,
|
|
54
|
+
...Css_1.Css.df.aic.py1.px2.cursorPointer.outline0.mh("42px").sm.$,
|
|
55
55
|
...(!isDisabled && isHovered ? (contrast ? Css_1.Css.bgGray800.$ : Css_1.Css.bgGray100.$) : {}),
|
|
56
56
|
...(isFocused ? Css_1.Css.add("boxShadow", `inset 0 0 0 1px ${Css_1.Palette.LightBlue700}`).$ : {}),
|
|
57
57
|
...(isDisabled ? Css_1.Css.gray500.cursorNotAllowed.$ : {}),
|
|
58
58
|
...(destructive ? Css_1.Css.red600.$ : {}),
|
|
59
|
+
...(isSelected ? Css_1.Css.fw5.$ : {}),
|
|
59
60
|
}, ...tid[(0, defaultTestId_1.defaultTestId)(menuItem.label)], children: (0, Tooltip_1.maybeTooltip)({
|
|
60
61
|
title: (0, Tooltip_1.resolveTooltip)(disabled),
|
|
61
62
|
placement: "right",
|
|
@@ -84,7 +85,7 @@ function maybeWrapInLink(onClick, content, disabled) {
|
|
|
84
85
|
if (disabled || typeof onClick !== "string") {
|
|
85
86
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: content });
|
|
86
87
|
}
|
|
87
|
-
return (0, utils_1.isAbsoluteUrl)(onClick) ? ((0, jsx_runtime_1.jsxs)("a", { href: onClick, target: "_blank", rel: "noopener noreferrer", className: "navLink", css: Css_1.Css.df.jcsb.w100.$, children: [content, (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.ml2.$, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "linkExternal" }) })] })) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.NavLink, { to: onClick, className: "navLink", children: content }));
|
|
88
|
+
return (0, utils_1.isAbsoluteUrl)(onClick) ? ((0, jsx_runtime_1.jsxs)("a", { href: onClick, target: "_blank", rel: "noopener noreferrer", className: "navLink", css: Css_1.Css.df.aic.jcsb.w100.$, children: [content, (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.fs0.ml2.$, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "linkExternal" }) })] })) : ((0, jsx_runtime_1.jsx)(react_router_dom_1.NavLink, { to: onClick, className: "navLink", children: content }));
|
|
88
89
|
}
|
|
89
90
|
function isIconMenuItem(item) {
|
|
90
91
|
return item && typeof item === "object" && "icon" in item;
|
|
@@ -12,6 +12,6 @@ function MenuSectionImpl(props) {
|
|
|
12
12
|
const { separatorProps } = (0, react_aria_1.useSeparator)({ elementType: "li" });
|
|
13
13
|
const isPersistentSection = section.key !== state.collection.getFirstKey();
|
|
14
14
|
const tid = (0, utils_1.useTestIds)(props);
|
|
15
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isPersistentSection && (0, jsx_runtime_1.jsx)("li", { ...separatorProps, css: Css_1.Css.bt.bGray200.$ }), (0, jsx_runtime_1.jsx)("li", { ...itemProps, css: Css_1.Css.if(!isPersistentSection).overflowAuto.if(contrast).white.$, children: (0, jsx_runtime_1.jsx)("ul", { css: Css_1.Css.listReset.$, ...groupProps, ...tid[isPersistentSection ? "persistentItems" : "menuItems"], children: [...section.childNodes].map((item) => ((0, jsx_runtime_1.jsx)(internal_1.MenuItemImpl, { item: item, state: state, onClose: onClose, contrast: contrast, ...tid }, item.key))) }) })] }));
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isPersistentSection && (0, jsx_runtime_1.jsx)("li", { ...separatorProps, css: Css_1.Css.bt.bGray200.$ }), (0, jsx_runtime_1.jsx)("li", { ...itemProps, css: Css_1.Css.gray900.if(!isPersistentSection).overflowAuto.if(contrast).white.$, children: (0, jsx_runtime_1.jsx)("ul", { css: Css_1.Css.listReset.$, ...groupProps, ...tid[isPersistentSection ? "persistentItems" : "menuItems"], children: [...section.childNodes].map((item) => ((0, jsx_runtime_1.jsx)(internal_1.MenuItemImpl, { item: item, state: state, onClose: onClose, contrast: contrast, ...tid }, item.key))) }) })] }));
|
|
16
16
|
}
|
|
17
17
|
exports.MenuSectionImpl = MenuSectionImpl;
|
|
@@ -33,7 +33,9 @@ function OverlayTrigger(props) {
|
|
|
33
33
|
: isIconButton(trigger)
|
|
34
34
|
? trigger.icon
|
|
35
35
|
: trigger.name);
|
|
36
|
-
return (
|
|
36
|
+
return (
|
|
37
|
+
// Add `line-height: 0` to prevent the Icon button and Avatar buttons from inheriting the line-height, causing them to be taller than they should.
|
|
38
|
+
(0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.dib.add("lineHeight", 0).$, children: [isTextButton(trigger) ? ((0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant ? variant : "secondary", contrast: contrast, ...trigger, menuTriggerProps: menuTriggerProps, buttonRef: buttonRef, endAdornment: !hideEndAdornment ? (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: state.isOpen ? "chevronUp" : "chevronDown" }) : null, disabled: disabled, tooltip: tooltip, onClick: (_a = menuTriggerProps.onPress) !== null && _a !== void 0 ? _a : utils_1.noop, forceFocusStyles: showActiveBorder && state.isOpen, ...tid })) : isNavLinkButton(trigger) ? ((0, jsx_runtime_1.jsx)(NavLink_1.NavLink, { ...trigger, label: trigger.navLabel, disabled: !!disabled, contrast: contrast, menuTriggerProps: menuTriggerProps, buttonRef: buttonRef, ...tid })) : isIconButton(trigger) ? ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { ...trigger, menuTriggerProps: menuTriggerProps, buttonRef: buttonRef, ...tid, disabled: disabled, tooltip: tooltip, onClick: (_b = menuTriggerProps.onPress) !== null && _b !== void 0 ? _b : utils_1.noop, forceFocusStyles: showActiveBorder && state.isOpen })) : ((0, jsx_runtime_1.jsx)(AvatarButton_1.AvatarButton, { ...trigger, menuTriggerProps: menuTriggerProps, buttonRef: buttonRef, ...tid, disabled: disabled, tooltip: tooltip, onClick: (_c = menuTriggerProps.onPress) !== null && _c !== void 0 ? _c : utils_1.noop, forceFocusStyles: showActiveBorder && state.isOpen })), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, { triggerRef: buttonRef, popoverRef: popoverRef, positionProps: positionProps, onClose: () => state.close(), isOpen: state.isOpen, children: children }))] }));
|
|
37
39
|
}
|
|
38
40
|
exports.OverlayTrigger = OverlayTrigger;
|
|
39
41
|
function isTextButton(trigger) {
|
|
@@ -205,12 +205,18 @@ function ComboBoxBase(props) {
|
|
|
205
205
|
}
|
|
206
206
|
}, [values]);
|
|
207
207
|
(0, react_1.useEffect)(() => {
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
|
|
208
|
+
// When options are an array, then use them as-is.
|
|
209
|
+
// If options are an object, then use the `initial` array if the menu has not been opened
|
|
210
|
+
// Otherwise, use the current fieldState array options.
|
|
211
|
+
const maybeUpdatedOptions = Array.isArray(maybeOptions)
|
|
212
|
+
? maybeOptions
|
|
213
|
+
: firstOpen.current === false
|
|
214
|
+
? fieldState.allOptions
|
|
215
|
+
: maybeOptions.initial;
|
|
216
|
+
if (maybeUpdatedOptions !== fieldState.allOptions) {
|
|
211
217
|
setFieldState((prevState) => {
|
|
212
218
|
var _a;
|
|
213
|
-
const selectedOptions =
|
|
219
|
+
const selectedOptions = maybeUpdatedOptions.filter((o) => values === null || values === void 0 ? void 0 : values.includes(getOptionValue(o)));
|
|
214
220
|
return {
|
|
215
221
|
...prevState,
|
|
216
222
|
selectedKeys: (_a = selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.map((o) => (0, Value_1.valueToKey)(getOptionValue(o)))) !== null && _a !== void 0 ? _a : [],
|
|
@@ -220,8 +226,8 @@ function ComboBoxBase(props) {
|
|
|
220
226
|
? nothingSelectedText
|
|
221
227
|
: "",
|
|
222
228
|
selectedOptions: selectedOptions,
|
|
223
|
-
filteredOptions:
|
|
224
|
-
allOptions:
|
|
229
|
+
filteredOptions: maybeUpdatedOptions,
|
|
230
|
+
allOptions: maybeUpdatedOptions,
|
|
225
231
|
};
|
|
226
232
|
});
|
|
227
233
|
}
|