@homebound/beam 2.238.2 → 2.239.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.
@@ -7,6 +7,8 @@ export interface RadioFieldOption<K extends string> {
7
7
  description?: string | (() => ReactNode);
8
8
  /** The undisplayed value, i.e. an id of some sort. */
9
9
  value: K;
10
+ /** Disable only specific option, with an optional reason */
11
+ disabled?: boolean | ReactNode;
10
12
  }
11
13
  export interface RadioGroupFieldProps<K extends string> extends Pick<PresentationFieldProps, "labelStyle"> {
12
14
  /** The label for the choice itself, i.e. "Favorite Cheese". */
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const react_aria_1 = require("react-aria");
7
7
  const react_stately_1 = require("react-stately");
8
+ const components_1 = require("../components");
8
9
  const HelperText_1 = require("../components/HelperText");
9
10
  const Label_1 = require("../components/Label");
10
11
  const Css_1 = require("../Css");
@@ -38,7 +39,14 @@ function RadioGroupField(props) {
38
39
  const anyDescriptions = options.some((o) => !!o.description);
39
40
  return (
40
41
  // default styling to position `<Label />` above.
41
- (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.fdc.gap1.aifs.if(labelStyle === "left").fdr.gap2.jcsb.$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, ...tid.label, hidden: labelStyle === "hidden" }), (0, jsx_runtime_1.jsxs)("div", { ...radioGroupProps, children: [options.map((option) => ((0, jsx_runtime_1.jsx)(Radio, { parentId: name, option: option, state: state, ...otherProps, ...tid[option.value] }, option.value))), errorMsg && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { errorMsg: errorMsg, ...tid.errorMsg }), helperText && (0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { helperText: helperText })] })] }));
42
+ (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.fdc.gap1.aifs.if(labelStyle === "left").fdr.gap2.jcsb.$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, ...tid.label, hidden: labelStyle === "hidden" }), (0, jsx_runtime_1.jsxs)("div", { ...radioGroupProps, children: [options.map((option) => {
43
+ const isDisabled = state.isDisabled || !!option.disabled;
44
+ return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (0, components_1.maybeTooltip)({
45
+ title: (0, components_1.resolveTooltip)(option.disabled),
46
+ placement: "bottom",
47
+ children: ((0, jsx_runtime_1.jsx)(Radio, { parentId: name, option: option, state: { ...state, isDisabled }, ...otherProps, ...tid[option.value] })),
48
+ }) }, option.value));
49
+ }), errorMsg && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { errorMsg: errorMsg, ...tid.errorMsg }), helperText && (0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { helperText: helperText })] })] }));
42
50
  }
43
51
  exports.RadioGroupField = RadioGroupField;
44
52
  // Not meant to be standalone, but its own component so it can use hooks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.238.2",
3
+ "version": "2.239.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",