@yamada-ui/checkbox
Version:
Yamada UI checkbox component
99 lines (97 loc) • 2.34 kB
JavaScript
"use client"
import {
CheckboxCard
} from "./chunk-EYKGMSLM.mjs";
import {
useCheckboxGroup
} from "./chunk-5MTF62B3.mjs";
import {
CheckboxCardGroupProvider
} from "./chunk-2VDJDPFI.mjs";
// src/checkbox-card-group.tsx
import { useFormControl } from "@yamada-ui/form-control";
import { Flex } from "@yamada-ui/layouts";
import { cx, getValidChildren } from "@yamada-ui/utils";
import { forwardRef } from "react";
import { jsx } from "react/jsx-runtime";
var CheckboxCardGroup = forwardRef(
({
className,
colorScheme,
size,
variant,
children,
direction = "row",
gap = "0.5rem",
items = [],
withIcon = true,
addonProps,
descriptionProps,
labelProps,
...props
}, ref) => {
const {
props: computedProps,
value,
getContainerProps,
onChange
} = useCheckboxGroup(props);
const {
disabled,
invalid,
isDisabled: _isDisabled,
isInvalid: _isInvalid,
isReadOnly: _isReadOnly,
isRequired: _isRequired,
labelId,
readOnly,
required,
...rest
} = useFormControl(computedProps);
const validChildren = getValidChildren(children);
let computedChildren = [];
if (!validChildren.length && items.length)
computedChildren = items.map((props2, i) => /* @__PURE__ */ jsx(CheckboxCard, { ...props2 }, i));
return /* @__PURE__ */ jsx(
CheckboxCardGroupProvider,
{
value: {
colorScheme,
size,
variant,
disabled,
invalid,
readOnly,
required,
value,
withIcon,
addonProps,
descriptionProps,
labelProps,
onChange
},
children: /* @__PURE__ */ jsx(
Flex,
{
ref,
className: cx("ui-checkbox-card-group", className),
gap,
w: "100%",
...getContainerProps({
"aria-labelledby": labelId,
...rest
}),
direction,
children: children != null ? children : computedChildren
}
)
}
);
}
);
CheckboxCardGroup.displayName = "CheckboxCardGroup";
CheckboxCardGroup.__ui__ = "CheckboxCardGroup";
export {
CheckboxCardGroup
};
//# sourceMappingURL=chunk-GDZGQZ7J.mjs.map