UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

85 lines (81 loc) 2.19 kB
"use client"; import { Group } from "../group/group.js"; import { CheckboxGroupContext, useCheckboxGroup } from "../checkbox/use-checkbox-group.js"; import { CheckboxCardPropsContext, CheckboxCardRoot, component, useRootComponentProps } from "./checkbox-card.js"; import { useMemo } from "react"; import { jsx } from "react/jsx-runtime"; //#region src/components/checkbox-card/checkbox-card-group.tsx /** * `CheckboxCardGroup` is a component that groups `CheckboxCard` components. * * @see https://yamada-ui.com/docs/components/checkbox-card */ const CheckboxCardGroupRoot = component((props) => { const [, { colorScheme, size, variant, checkedIcon, children, disabled, errorBorderColor, focusBorderColor, invalid, items = [], justify, readOnly, shape, withIndicator,...rest }] = useRootComponentProps(props, "group", { transferProps: [ "variant", "colorScheme", "size", "shape", "justify", "withIndicator" ] }); const { max, value, getInputProps, getLabelProps, getRootProps, onChange } = useCheckboxGroup(rest); const computedChildren = useMemo(() => { if (children) return children; return items.map(({ value: value$1,...rest$1 }, index) => /* @__PURE__ */ jsx(CheckboxCardRoot, { value: value$1, ...rest$1 }, value$1 ?? index)); }, [items, children]); return /* @__PURE__ */ jsx(CheckboxCardPropsContext, { value: useMemo(() => ({ colorScheme, size, variant, checkedIcon, disabled, errorBorderColor, focusBorderColor, invalid, justify, readOnly, shape, withIndicator }), [ colorScheme, size, checkedIcon, variant, disabled, justify, withIndicator, errorBorderColor, focusBorderColor, invalid, readOnly, shape ]), children: /* @__PURE__ */ jsx(CheckboxGroupContext, { value: useMemo(() => ({ max, value, getInputProps, getLabelProps, onChange }), [ max, value, getInputProps, getLabelProps, onChange ]), children: /* @__PURE__ */ jsx(Group, { ...getRootProps(), children: computedChildren }) }) }); }, "group")(); //#endregion export { CheckboxCardGroupRoot }; //# sourceMappingURL=checkbox-card-group.js.map