@homebound/beam 2.360.0 → 2.362.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.
@@ -4,7 +4,7 @@ import { IconKey } from "./Icon";
4
4
  export type ChipType = "caution" | "warning" | "success" | "light" | "dark" | "neutral" | "darkMode" | "info";
5
5
  export declare const ChipTypes: Record<ChipType, ChipType>;
6
6
  export interface ChipProps<X> {
7
- text: string;
7
+ text: ReactNode;
8
8
  title?: ReactNode;
9
9
  xss?: X;
10
10
  type?: ChipType;
@@ -1,8 +1,11 @@
1
1
  import { ReactNode } from "react";
2
+ import { Xss } from "../Css";
2
3
  import { PresentationFieldProps } from "../components/PresentationContext";
4
+ type ToggleChipXss = Xss<"color" | "backgroundColor">;
3
5
  type ToggleChipItemProps = {
4
6
  label: string;
5
7
  value: string;
8
+ startAdornment?: ReactNode;
6
9
  /**
7
10
  * Whether the interactive element is disabled.
8
11
  *
@@ -15,6 +18,7 @@ export interface ToggleChipGroupProps extends Pick<PresentationFieldProps, "labe
15
18
  options: ToggleChipItemProps[];
16
19
  values: string[];
17
20
  onChange: (values: string[]) => void;
21
+ xss?: ToggleChipXss;
18
22
  }
19
23
  export declare function ToggleChipGroup(props: ToggleChipGroupProps): import("@emotion/react/jsx-runtime").JSX.Element;
20
24
  export {};
@@ -14,18 +14,19 @@ function ToggleChipGroup(props) {
14
14
  var _a;
15
15
  const { fieldProps } = (0, PresentationContext_1.usePresentationContext)();
16
16
  const { labelLeftFieldWidth = "50%" } = fieldProps !== null && fieldProps !== void 0 ? fieldProps : {};
17
- const { values, label, labelStyle = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _a !== void 0 ? _a : "above", options } = props;
17
+ const { values, label, labelStyle = (_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.labelStyle) !== null && _a !== void 0 ? _a : "above", options, xss } = props;
18
18
  const state = (0, react_stately_1.useCheckboxGroupState)({ ...props, value: values });
19
19
  const { groupProps, labelProps } = (0, react_aria_1.useCheckboxGroup)(props, state);
20
20
  const tid = (0, useTestIds_1.useTestIds)(props, "toggleChip");
21
21
  return ((0, jsx_runtime_1.jsxs)("div", { ...groupProps, css: Css_1.Css.relative.df.fdc.if(labelStyle === "left").fdr.gap2.maxw100.jcsb.$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, hidden: labelStyle === "hidden", inline: labelStyle !== "above" }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.gap1
22
22
  .add("flexWrap", "wrap")
23
23
  .if(labelStyle === "left")
24
- .w(labelLeftFieldWidth).$, children: options.map((o) => ((0, jsx_runtime_1.jsx)(ToggleChip, { value: o.value, groupState: state, selected: state.value.includes(o.value), label: o.label, disabled: o.disabled, ...tid[o.value] }, o.value))) })] }));
24
+ .w(labelLeftFieldWidth).$, children: options.map((o) => ((0, jsx_runtime_1.jsx)(ToggleChip, { value: o.value, groupState: state, selected: state.value.includes(o.value), label: o.label, disabled: o.disabled, startAdornment: o.startAdornment, xss: xss, ...tid[o.value] }, o.value))) })] }));
25
25
  }
26
26
  exports.ToggleChipGroup = ToggleChipGroup;
27
27
  function ToggleChip(props) {
28
- const { label, value, groupState, selected: isSelected, disabled = false, ...others } = props;
28
+ var _a, _b, _c;
29
+ const { label, value, groupState, selected: isSelected, disabled = false, startAdornment, xss, ...others } = props;
29
30
  const isDisabled = !!disabled;
30
31
  const ref = (0, react_1.useRef)(null);
31
32
  const { inputProps } = (0, react_aria_1.useCheckboxGroupItem)({ value, "aria-label": label, isDisabled }, groupState, ref);
@@ -38,11 +39,11 @@ function ToggleChip(props) {
38
39
  ...Css_1.Css.relative.dib.br16.sm.px1.cursorPointer.pyPx(4).bgGray200.if(isDisabled).cursorNotAllowed.gray600.pr1.$,
39
40
  ...(isSelected
40
41
  ? {
41
- ...Css_1.Css.white.bgBlue700.$,
42
- ":hover:not([data-disabled='true'])": Css_1.Css.bgBlue800.$,
42
+ ...Css_1.Css.color((_a = xss === null || xss === void 0 ? void 0 : xss.color) !== null && _a !== void 0 ? _a : Css_1.Palette.White).bgColor((_b = xss === null || xss === void 0 ? void 0 : xss.backgroundColor) !== null && _b !== void 0 ? _b : Css_1.Palette.Blue700).$,
43
+ ":hover:not([data-disabled='true'])": Css_1.Css.bgColor((_c = xss === null || xss === void 0 ? void 0 : xss.backgroundColor) !== null && _c !== void 0 ? _c : Css_1.Palette.Blue800).$,
43
44
  }
44
45
  : { ":hover:not([data-disabled='true'])": Css_1.Css.bgGray300.$ }),
45
46
  ...(isFocusVisible ? Css_1.Css.bshFocus.$ : {}),
46
- }, "data-selected": isSelected, "data-disabled": isDisabled, "aria-disabled": isDisabled, ...others, children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ...inputProps, ...focusProps }) }), label] })),
47
+ }, "data-selected": isSelected, "data-disabled": isDisabled, "aria-disabled": isDisabled, ...others, children: [(0, jsx_runtime_1.jsx)(react_aria_1.VisuallyHidden, { children: (0, jsx_runtime_1.jsx)("input", { ...inputProps, ...focusProps }) }), (0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.df.gap1.$, children: [startAdornment, label] })] })),
47
48
  });
48
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.360.0",
3
+ "version": "2.362.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",