{"version":3,"file":"TdRadioButton.cjs","sources":["../../../src/components/Table/TdRadioButton.tsx"],"sourcesContent":["import { type ComponentProps, type PropsWithChildren, forwardRef, useMemo } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { RadioButton } from '../RadioButton'\nimport { VisuallyHiddenText } from '../VisuallyHiddenText'\n\nimport { Td } from './Td'\n\ntype Props = PropsWithChildren<{\n  /** RadioButtonのaccessible nameとして設定するテキストを参照するためのid属性値。同じ親Tr配下のTdかTh、もしくはその子孫要素のidを指定する。複数要素のテキストを指定する場合は空白区切りでidをつなぐ */\n  'aria-labelledby': string\n}> &\n  ComponentProps<typeof RadioButton> &\n  Pick<ComponentProps<typeof Td>, 'vAlign'>\n\nconst classNameGenerator = tv({\n  slots: {\n    inner: [\n      'shr-relative',\n      'shr-flex shr-justify-center shr-px-1 shr-py-0.75',\n      '[&:not(:has([disabled]))]:shr-cursor-pointer',\n    ],\n    wrapper: 'shr-w-min shr-p-0',\n    radio: ['shr-leading-[0]', '[&>span]:shr-translate-y-[unset]'],\n  },\n})\n\nexport const TdRadioButton = forwardRef<HTMLInputElement, Props>(\n  ({ vAlign, children, className, ...rest }, ref) => {\n    const classNames = useMemo(() => {\n      const { wrapper, inner, radio } = classNameGenerator()\n\n      return {\n        wrapper: wrapper({ className }),\n        inner: inner(),\n        radio: radio(),\n      }\n    }, [className])\n\n    return (\n      // Td に必要な属性やイベントは不要\n      <Td vAlign={vAlign} className={classNames.wrapper}>\n        <label className={classNames.inner}>\n          {/* eslint-disable-next-line smarthr/a11y-prohibit-checkbox-or-radio-in-table-cell */}\n          <RadioButton {...rest} ref={ref} className={classNames.radio} />\n          {children && <VisuallyHiddenText>{children}</VisuallyHiddenText>}\n        </label>\n      </Td>\n    )\n  },\n)\n"],"names":["tv","forwardRef","useMemo","_jsx","Td","_jsxs","RadioButton","VisuallyHiddenText"],"mappings":";;;;;;;;;AAeA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,KAAK,EAA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