{"version":3,"file":"AppNaviAnchor.cjs","sources":["../../../src/components/AppNavi/AppNaviAnchor.tsx"],"sourcesContent":["import {\n  type ComponentPropsWithoutRef,\n  type ComponentType,\n  type ElementType,\n  type FC,\n  type PropsWithoutRef,\n  type ReactElement,\n  type Ref,\n  forwardRef,\n  useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { itemClassNameGenerator } from './itemClassNameGenerator'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\nimport type { ComponentProps as IconProps } from '../Icon'\n\ntype ElementProps<T extends ElementType> = Omit<\n  ComponentPropsWithoutRef<T>,\n  keyof AppNaviAnchorProps<T> & ElementRefProps<T>\n>\n\nexport type AppNaviAnchorProps<T extends ElementType = 'a'> = {\n  /** アンカーの href */\n  href?: string\n  /** 表示するアイコンタイプ */\n  icon?: ComponentType<IconProps>\n  /** アクティブ状態であるかどうか */\n  current?: boolean\n  /** next/link などのカスタムコンポーネントを指定します。指定がない場合はデフォルトで `a` タグが使用されます。 */\n  elementAs?: T\n}\n\ntype AppNaviAnchorComponent = <T extends ElementType = 'a'>(\n  props: AppNaviAnchorProps<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n  extend: itemClassNameGenerator,\n  slots: {\n    wrapper: ['smarthr-ui-AppNavi-anchor', 'forced-colors:shr-underline'],\n  },\n})\n\nexport const AppNaviAnchor: AppNaviAnchorComponent = forwardRef(\n  <T extends ElementType = 'a'>(\n    {\n      children,\n      href,\n      icon: Icon,\n      current,\n      elementAs,\n      ...rest\n    }: PropsWithoutRef<AppNaviAnchorProps<T>> & ElementProps<T>,\n    ref: Ref<ElementRef<T>>,\n  ): ReactElement => {\n    const classNames = useMemo(() => {\n      const { wrapper, icon } = classNameGenerator({ active: current })\n\n      return {\n        wrapper: wrapper(),\n        icon: icon(),\n      }\n    }, [current])\n\n    const Component = elementAs || 'a'\n\n    return (\n      <Component\n        {...rest}\n        ref={ref}\n        href={href}\n        aria-current={current ? 'page' : undefined}\n        className={classNames.wrapper}\n      >\n        {Icon && <Icon className={classNames.icon} />}\n        {children}\n      </Component>\n    )\n  },\n)\n"],"names":["tv","itemClassNameGenerator","forwardRef","useMemo","_jsxs","_jsx"],"mappings":";;;;;;;AAsCA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,MAAM,EAAEC,gEAAsB;AAC9B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EAAE,CAAC,2BAA2B,EAAE,6BAA6B,CAAC;AACtE,KAAA;AACF,CAAA,CAAC;AAEK,MAAM,aAAa,GAA2BC,gBAAU,CAC7D,CACE,EACE,QAAQ,EACR,IAAI,EACJ,IAAI,EAAE,IAAI,EACV,OAAO,EACP,SAAS,EACT,GAAG,IAAI,EACkD,EAC3D,GAAuB,KACP;AAChB,IAAA,MAAM,UAAU,GAAGC,aAAO,CAAC,MAAK;AAC9B,QAAA,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,kBAAkB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QAEjE,OAAO;YACL,OAAO,EAAE,OAAO,EAAE;YAClB,IAAI,EAAE,IAAI,EAAE;SACb;AACH,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAEb,IAAA,MAAM,SAAS,GAAG,SAAS,IAAI,GAAG;IAElC,QACEC,gBAAC,SAAS,EAAA,EAAA,GACJ,IAAI,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,kBACI,OAAO,GAAG,MAAM,GAAG,SAAS,EAC1C,SAAS,EAAE,UAAU,CAAC,OAAO,EAAA,QAAA,EAAA,CAE5B,IAAI,IAAIC,cAAA,CAAC,IAAI,IAAC,SAAS,EAAE,UAAU,CAAC,IAAI,GAAI,EAC5C,QAAQ,CAAA,EAAA,CACC;AAEhB,CAAC;;;;"}