@homebound/beam 2.283.0 → 2.284.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.
@@ -10,7 +10,7 @@ export type ButtonGroupButton = {
10
10
  icon?: IconProps["icon"];
11
11
  iconColor?: IconProps["color"];
12
12
  iconInc?: IconProps["inc"];
13
- text?: string;
13
+ text?: ReactNode;
14
14
  onClick?: VoidFunction;
15
15
  /** Disables the button. Pass a ReactNode to disable the button and show a tooltip */
16
16
  disabled?: boolean | ReactNode;
@@ -20,7 +20,6 @@ function ButtonGroup(props) {
20
20
  }
21
21
  exports.ButtonGroup = ButtonGroup;
22
22
  function GroupButton(props) {
23
- var _a;
24
23
  const { icon, iconInc, iconColor, text, active, onClick: onPress, disabled, size, tooltip, ...otherProps } = props;
25
24
  const ariaProps = { onPress, isDisabled: !!disabled, ...otherProps };
26
25
  const ref = (0, react_1.useRef)(null);
@@ -38,7 +37,7 @@ function GroupButton(props) {
38
37
  ...(active ? activeStyles : {}),
39
38
  ...(isPressed ? pressedStyles : isHovered ? hoverStyles : {}),
40
39
  ...(icon ? iconStyles[size] : {}),
41
- }, ...tid[(0, defaultTestId_1.defaultTestId)((_a = text !== null && text !== void 0 ? text : icon) !== null && _a !== void 0 ? _a : "button")], children: [icon && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { xss: Css_1.Css.if(!!text).mrPx(4).$, icon: icon, color: disabled ? undefined : iconColor, inc: iconInc })), text] })),
40
+ }, ...tid[(0, defaultTestId_1.defaultTestId)((typeof text === "string" && text) || icon || "button")], children: [icon && ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { xss: Css_1.Css.if(!!text).mrPx(4).$, icon: icon, color: disabled ? undefined : iconColor, inc: iconInc })), text] })),
42
41
  }) }));
43
42
  }
44
43
  const pressedStyles = Css_1.Css.bgGray200.$;
@@ -6,16 +6,7 @@ const ComboBoxBase_1 = require("./internal/ComboBoxBase");
6
6
  function MultiSelectField(props) {
7
7
  const { getOptionValue = (opt) => opt.id, // if unset, assume O implements HasId
8
8
  getOptionLabel = (opt) => opt.name, // if unset, assume O implements HasName
9
- options, onSelect, values, ...otherProps } = props;
10
- return ((0, jsx_runtime_1.jsx)(ComboBoxBase_1.ComboBoxBase, { multiselect: true, ...otherProps, options: options, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, values: values, onSelect: (values) => {
11
- const [selectedValues, selectedOptions] = options
12
- .filter((o) => values.includes(getOptionValue(o)))
13
- .reduce((acc, o) => {
14
- acc[0].push(getOptionValue(o));
15
- acc[1].push(o);
16
- return acc;
17
- }, [[], []]);
18
- onSelect(selectedValues, selectedOptions);
19
- } }));
9
+ ...otherProps } = props;
10
+ return (0, jsx_runtime_1.jsx)(ComboBoxBase_1.ComboBoxBase, { multiselect: true, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, ...otherProps });
20
11
  }
21
12
  exports.MultiSelectField = MultiSelectField;
@@ -5,6 +5,11 @@ import { HasIdAndName, Optional } from "../types";
5
5
  export interface SelectFieldProps<O, V extends Value> extends Omit<ComboBoxBaseProps<O, V>, "values" | "onSelect" | "multiselect"> {
6
6
  /** The current value; it can be `undefined`, even if `V` cannot be. */
7
7
  value: V | undefined;
8
+ /**
9
+ * Called when a value is selected, or `undefined` if `unsetLabel` is being used.
10
+ *
11
+ * Ideally callers that didn't pass `unsetLabel` would not have to handle the ` | undefined` here.
12
+ */
8
13
  onSelect: (value: V | undefined, opt: O | undefined) => void;
9
14
  }
10
15
  /**
@@ -8,6 +8,7 @@ function SelectField(props) {
8
8
  getOptionLabel = (opt) => opt.name, // if unset, assume O implements HasName
9
9
  options, onSelect, value, ...otherProps } = props;
10
10
  return ((0, jsx_runtime_1.jsx)(ComboBoxBase_1.ComboBoxBase, { ...otherProps, options: options, getOptionLabel: getOptionLabel, getOptionValue: getOptionValue, values: [value], onSelect: (values, options) => {
11
+ // If the user used `unsetLabel`, then values will be `[undefined]` and options `[unsetOption]`
11
12
  if (values.length > 0 && options.length > 0) {
12
13
  const option = options[0];
13
14
  onSelect(values[0], option === ComboBoxBase_1.unsetOption ? undefined : option);
@@ -29,13 +29,25 @@ export interface ComboBoxBaseProps<O, V extends Value> extends BeamFocusableProp
29
29
  onBlur?: () => void;
30
30
  onFocus?: () => void;
31
31
  sizeToContent?: boolean;
32
- /** The text to show when nothing is selected, i.e. could be "All" for filters. */
32
+ /**
33
+ * The text to show when nothing is selected, i.e. could be "All" for filters.
34
+ *
35
+ * Unlike `unsetLabel`, this does not add an explicit option for the user to select.
36
+ */
33
37
  nothingSelectedText?: string;
34
38
  /** When set the SelectField is expected to be put on a darker background */
35
39
  contrast?: boolean;
36
40
  /** Placeholder content */
37
41
  placeholder?: string;
38
- /** Only used for Single Select Fields. If set, prepends an option with a `undefined` value at the top of the list */
42
+ /**
43
+ * If set, prepends an option with an `undefined` value at the top of the list to allow
44
+ * unsetting the field.
45
+ *
46
+ * Unlike `nothingSelectedText`, which provides the label for empty value state, but doesn't
47
+ * add an option for the user to explicitly select the empty state.
48
+ *
49
+ * Only available for Single Select Fields.
50
+ */
39
51
  unsetLabel?: string;
40
52
  hideErrorMessage?: boolean;
41
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.283.0",
3
+ "version": "2.284.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",