UNPKG

@yamada-ui/checkbox

Version:

Yamada UI checkbox component

91 lines (89 loc) 2.17 kB
"use client" import { useCheckboxGroup } from "./chunk-5MTF62B3.mjs"; import { Checkbox } from "./chunk-D3OZWWL7.mjs"; import { CheckboxGroupProvider } from "./chunk-2VDJDPFI.mjs"; // src/checkbox-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 CheckboxGroup = forwardRef( ({ className, colorScheme, size, variant, children, direction = "column", gap, items = [], ...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, index) => /* @__PURE__ */ jsx(Checkbox, { ...props2 }, index)); } return /* @__PURE__ */ jsx( CheckboxGroupProvider, { value: { colorScheme, size, variant, disabled, invalid, readOnly, required, value, onChange }, children: /* @__PURE__ */ jsx( Flex, { ref, className: cx("ui-checkbox-group", className), direction, gap: gap != null ? gap : direction === "row" ? "1rem" : void 0, ...getContainerProps({ "aria-labelledby": labelId, ...rest }), children: children != null ? children : computedChildren } ) } ); } ); CheckboxGroup.displayName = "CheckboxGroup"; CheckboxGroup.__ui__ = "CheckboxGroup"; export { CheckboxGroup }; //# sourceMappingURL=chunk-T6F7WS7M.mjs.map