UNPKG

@yamada-ui/react

Version:

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

51 lines (47 loc) 1.88 kB
"use client"; import { styled } from "../../core/system/factory.js"; import { createSlotComponent } from "../../core/components/create-component.js"; import { useInputBorder } from "../input/use-input-border.js"; import { radioStyle } from "./radio.style.js"; import { useRadio } from "./use-radio.js"; import { useMemo } from "react"; import { jsx, jsxs } from "react/jsx-runtime"; //#region src/components/radio/radio.tsx const { component, PropsContext: RadioPropsContext, usePropsContext: useRadioPropsContext, withContext, withProvider, useRootComponentProps } = createSlotComponent("radio", radioStyle); /** * `Radio` is a component used for allowing users to select one option from multiple choices. * * @see https://yamada-ui.com/docs/components/radio */ const Radio = withProvider(({ children, errorBorderColor, focusBorderColor, indicatorProps, inputProps, labelProps, rootProps,...rest }) => { const { getIndicatorProps, getInputProps, getRootProps } = useRadio(rest); const varProps = useInputBorder({ errorBorderColor, focusBorderColor }); const input = useMemo(() => { return /* @__PURE__ */ jsx(styled.input, { ...getInputProps(inputProps) }); }, [getInputProps, inputProps]); const indicator = useMemo(() => { return /* @__PURE__ */ jsx(RadioIndicator, { ...getIndicatorProps(indicatorProps) }); }, [getIndicatorProps, indicatorProps]); return /* @__PURE__ */ jsxs(styled.label, { ...getRootProps({ ...varProps, ...rootProps }), children: [ input, indicator, children ? /* @__PURE__ */ jsx(RadioLabel, { ...labelProps, children }) : null ] }); }, "root")(); const RadioIndicator = withContext("div", "indicator")(); const RadioLabel = withContext("span", "label")(); //#endregion export { Radio, RadioPropsContext, component, useRadioPropsContext, useRootComponentProps }; //# sourceMappingURL=radio.js.map