@homebound/beam 2.340.0 → 2.342.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.
@@ -1,6 +1,11 @@
1
1
  import { ReactNode } from "react";
2
2
  export interface CheckboxProps {
3
3
  label: string;
4
+ /** If false this will be wrap in a div element instead of the label
5
+ * Expects implementer to wrap within a label element to work properly
6
+ * @default true
7
+ */
8
+ withLabelElement?: boolean;
4
9
  checkboxOnly?: boolean;
5
10
  selected: boolean | "indeterminate";
6
11
  /** Handler that is called when the element's selection state changes. */
@@ -19,6 +19,11 @@ export interface CheckboxBaseProps extends BeamFocusableProps {
19
19
  checkboxOnly?: boolean;
20
20
  errorMsg?: string;
21
21
  helperText?: string | ReactNode;
22
+ /** If false this will be wrap in a div element instead of the label
23
+ * Expects implementer to wrap within a label element to work properly
24
+ * @default true
25
+ */
26
+ withLabelElement?: boolean;
22
27
  }
23
28
  export declare function CheckboxBase(props: CheckboxBaseProps): import("@emotion/react/jsx-runtime").JSX.Element;
24
29
  interface StyledCheckboxProps {
@@ -10,12 +10,12 @@ const ErrorMessage_1 = require("./ErrorMessage");
10
10
  const utils_1 = require("../utils");
11
11
  const defaultTestId_1 = require("../utils/defaultTestId");
12
12
  function CheckboxBase(props) {
13
- const { ariaProps, description, isDisabled = false, isIndeterminate = false, isSelected, inputProps, label, errorMsg, helperText, checkboxOnly = false, } = props;
13
+ const { ariaProps, description, isDisabled = false, isIndeterminate = false, inputProps, label, errorMsg, helperText, checkboxOnly = false, withLabelElement = true, } = props;
14
14
  const ref = (0, react_1.useRef)(null);
15
15
  const { isFocusVisible, focusProps } = (0, react_aria_1.useFocusRing)(ariaProps);
16
- const { hoverProps, isHovered } = (0, react_aria_1.useHover)({ isDisabled });
17
16
  const tid = (0, utils_1.useTestIds)(props, (0, defaultTestId_1.defaultTestId)(label));
18
- return ((0, jsx_runtime_1.jsxs)("label", { css: Css_1.Css.df.cursorPointer.relative
17
+ const Tag = withLabelElement ? "label" : "div";
18
+ return ((0, jsx_runtime_1.jsxs)(Tag, { css: Css_1.Css.df.cursorPointer.relative
19
19
  // Prevents accidental checkbox clicks due to label width being longer
20
20
  // than the content.
21
21
  .w("max-content")
@@ -11,6 +11,7 @@ type ToggleChipItemProps = {
11
11
  };
12
12
  export interface ToggleChipGroupProps {
13
13
  label: string;
14
+ labelStyle?: "above" | "left";
14
15
  options: ToggleChipItemProps[];
15
16
  values: string[];
16
17
  onChange: (values: string[]) => void;
@@ -10,11 +10,11 @@ const Label_1 = require("../components/Label");
10
10
  const Css_1 = require("../Css");
11
11
  const useTestIds_1 = require("../utils/useTestIds");
12
12
  function ToggleChipGroup(props) {
13
- const { values, label, options, hideLabel } = props;
13
+ const { values, label, labelStyle, options, hideLabel } = props;
14
14
  const state = (0, react_stately_1.useCheckboxGroupState)({ ...props, value: values });
15
15
  const { groupProps, labelProps } = (0, react_aria_1.useCheckboxGroup)(props, state);
16
16
  const tid = (0, useTestIds_1.useTestIds)(props, "toggleChip");
17
- return ((0, jsx_runtime_1.jsxs)("div", { ...groupProps, css: Css_1.Css.relative.$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, hidden: hideLabel }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.gap1.add("flexWrap", "wrap").$, 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))) })] }));
17
+ return ((0, jsx_runtime_1.jsxs)("div", { ...groupProps, css: Css_1.Css.relative.df.fdc.if(labelStyle === "left").fdr.maxw100.$, children: [(0, jsx_runtime_1.jsx)(Label_1.Label, { label: label, ...labelProps, hidden: hideLabel }), (0, jsx_runtime_1.jsx)("div", { css: Css_1.Css.df.gap1.add("flexWrap", "wrap").if(labelStyle === "left").ml2.$, 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))) })] }));
18
18
  }
19
19
  exports.ToggleChipGroup = ToggleChipGroup;
20
20
  function ToggleChip(props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/beam",
3
- "version": "2.340.0",
3
+ "version": "2.342.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",