UNPKG

@yamada-ui/react

Version:

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

1 lines 3.83 kB
{"version":3,"file":"radio.cjs","names":["createSlotComponent","radioStyle","useRadio","useInputBorder","styled"],"sources":["../../../../src/components/radio/radio.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement } from \"react\"\nimport type { GenericsComponent, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { UseInputBorderProps } from \"../input\"\nimport type { RadioStyle } from \"./radio.style\"\nimport type { UseRadioProps } from \"./use-radio\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useInputBorder } from \"../input\"\nimport { radioStyle } from \"./radio.style\"\nimport { useRadio } from \"./use-radio\"\n\nexport interface RadioProps<Y extends string = string>\n extends Merge<HTMLStyledProps<\"label\">, UseRadioProps<Y>>,\n ThemeProps<RadioStyle>,\n UseInputBorderProps {\n /**\n * Props for the indicator component.\n */\n indicatorProps?: RadioIndicatorProps\n /**\n * Props for the input element.\n */\n inputProps?: HTMLStyledProps<\"input\">\n /**\n * Props for the label component.\n */\n labelProps?: RadioLabelProps\n /**\n * Props for the label element.\n */\n rootProps?: HTMLStyledProps<\"label\">\n}\n\nconst {\n component,\n PropsContext: RadioPropsContext,\n usePropsContext: useRadioPropsContext,\n withContext,\n withProvider,\n useRootComponentProps,\n} = createSlotComponent<RadioProps, RadioStyle>(\"radio\", radioStyle)\n\nexport {\n component,\n RadioPropsContext,\n useRadioPropsContext,\n useRootComponentProps,\n}\n\n/**\n * `Radio` is a component used for allowing users to select one option from multiple choices.\n *\n * @see https://yamada-ui.com/docs/components/radio\n */\nexport const Radio = withProvider<\"label\", RadioProps>(\n ({\n children,\n errorBorderColor,\n focusBorderColor,\n indicatorProps,\n inputProps,\n labelProps,\n rootProps,\n ...rest\n }) => {\n const { getIndicatorProps, getInputProps, getRootProps } = useRadio(rest)\n const varProps = useInputBorder({ errorBorderColor, focusBorderColor })\n const input = useMemo(() => {\n return <styled.input {...getInputProps(inputProps)} />\n }, [getInputProps, inputProps])\n const indicator = useMemo(() => {\n return <RadioIndicator {...getIndicatorProps(indicatorProps)} />\n }, [getIndicatorProps, indicatorProps])\n\n return (\n <styled.label {...getRootProps({ ...varProps, ...rootProps })}>\n {input}\n {indicator}\n {children ? <RadioLabel {...labelProps}>{children}</RadioLabel> : null}\n </styled.label>\n )\n },\n \"root\",\n)() as GenericsComponent<{\n <Y extends string = string>(props: RadioProps<Y>): ReactElement\n}>\n\ninterface RadioIndicatorProps extends HTMLStyledProps {}\n\nconst RadioIndicator = withContext<\"div\", RadioIndicatorProps>(\n \"div\",\n \"indicator\",\n)()\n\ninterface RadioLabelProps extends HTMLStyledProps<\"span\"> {}\n\nconst RadioLabel = withContext<\"span\", RadioLabelProps>(\"span\", \"label\")()\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,MAAM,EACJ,WACA,cAAc,mBACd,iBAAiB,sBACjB,aACA,cACA,0BACEA,6CAA4C,SAASC,+BAAW;;;;;;AAcpE,MAAa,QAAQ,cAClB,EACC,UACA,kBACA,kBACA,gBACA,YACA,YACA,UACA,GAAG,WACC;CACJ,MAAM,EAAE,mBAAmB,eAAe,iBAAiBC,2BAAS,KAAK;CACzE,MAAM,WAAWC,wCAAe;EAAE;EAAkB;EAAkB,CAAC;CACvE,MAAM,iCAAsB;AAC1B,SAAO,2CAACC,uBAAO,SAAM,GAAI,cAAc,WAAW,GAAI;IACrD,CAAC,eAAe,WAAW,CAAC;CAC/B,MAAM,qCAA0B;AAC9B,SAAO,2CAAC,kBAAe,GAAI,kBAAkB,eAAe,GAAI;IAC/D,CAAC,mBAAmB,eAAe,CAAC;AAEvC,QACE,4CAACA,uBAAO;EAAM,GAAI,aAAa;GAAE,GAAG;GAAU,GAAG;GAAW,CAAC;;GAC1D;GACA;GACA,WAAW,2CAAC;IAAW,GAAI;IAAa;KAAsB,GAAG;;GACrD;GAGnB,OACD,EAAE;AAMH,MAAM,iBAAiB,YACrB,OACA,YACD,EAAE;AAIH,MAAM,aAAa,YAAqC,QAAQ,QAAQ,EAAE"}