UNPKG

@yamada-ui/react

Version:

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

83 lines (79 loc) 2.09 kB
"use client"; import { Group } from "../group/group.js"; import { RadioGroupContext, useRadioGroup } from "../radio/use-radio-group.js"; import { RadioCardPropsContext, RadioCardRoot, component, useRootComponentProps } from "./radio-card.js"; import { useMemo } from "react"; import { jsx } from "react/jsx-runtime"; //#region src/components/radio-card/radio-card-group.tsx /** * `RadioCardGroup` is a component that groups `RadioCard` components. * * @see https://yamada-ui.com/docs/components/radio-card */ const RadioCardGroupRoot = component((props) => { const [, { colorScheme, size, variant, children, disabled, errorBorderColor, focusBorderColor, invalid, items = [], justify, readOnly, shape, withIndicator,...rest }] = useRootComponentProps(props, "group", { transferProps: [ "variant", "colorScheme", "size", "shape", "justify", "withIndicator" ] }); const { name, value, getInputProps, getLabelProps, getRootProps, onChange } = useRadioGroup(rest); const computedChildren = useMemo(() => { if (children) return children; return items.map(({ value: value$1,...rest$1 }, index) => /* @__PURE__ */ jsx(RadioCardRoot, { value: value$1, ...rest$1 }, value$1 ?? index)); }, [items, children]); return /* @__PURE__ */ jsx(RadioCardPropsContext, { value: useMemo(() => ({ colorScheme, size, variant, disabled, errorBorderColor, focusBorderColor, invalid, justify, readOnly, shape, withIndicator }), [ colorScheme, size, variant, disabled, justify, withIndicator, errorBorderColor, focusBorderColor, invalid, readOnly, shape ]), children: /* @__PURE__ */ jsx(RadioGroupContext, { value: useMemo(() => ({ name, value, getInputProps, getLabelProps, onChange }), [ name, value, getInputProps, getLabelProps, onChange ]), children: /* @__PURE__ */ jsx(Group, { ...getRootProps(), children: computedChildren }) }) }); }, "group")(); //#endregion export { RadioCardGroupRoot }; //# sourceMappingURL=radio-card-group.js.map