@homebound/beam 2.340.0 → 2.341.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,
|
|
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
|
-
|
|
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")
|