{"version":3,"file":"SectioningContent.cjs","sources":["../../../src/components/SectioningContent/SectioningContent.tsx"],"sourcesContent":["'use client'\n\nimport {\n  type ComponentProps,\n  type ComponentPropsWithRef,\n  type FC,\n  type PropsWithChildren,\n  forwardRef,\n  useContext,\n} from 'react'\n\nimport { LevelContext } from './levelContext'\n\ntype AbstractProps = PropsWithChildren<{\n  // via https://html.spec.whatwg.org/multipage/dom.html#sectioning-content\n  as?: 'article' | 'aside' | 'nav' | 'section'\n  baseLevel?: number\n}>\ntype PropsWithAs = AbstractProps & Omit<ComponentPropsWithRef<'section'>, keyof AbstractProps>\ntype Props = Omit<ComponentProps<typeof SectioningContent>, 'as'>\n\nconst SectioningContent = forwardRef<HTMLElement, PropsWithAs>(\n  ({ children, baseLevel, as: Wrapper = 'section', ...rest }, ref) => (\n    <Wrapper {...rest} ref={ref}>\n      {/* eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content */}\n      <SectioningFragment baseLevel={baseLevel}>{children}</SectioningFragment>\n    </Wrapper>\n  ),\n)\n\nexport const Section: FC<Props> = SectioningContent\nexport const Article: FC<Props> = forwardRef<HTMLElement, Props>((props, ref) => (\n  <SectioningContent {...props} ref={ref} as=\"article\" />\n))\nexport const Aside: FC<Props> = forwardRef<HTMLElement, Props>((props, ref) => (\n  <SectioningContent {...props} ref={ref} as=\"aside\" />\n))\nexport const Nav: FC<Props> = forwardRef<HTMLElement, Props>((props, ref) => (\n  <SectioningContent {...props} ref={ref} as=\"nav\" />\n))\n\nexport const SectioningFragment: FC<PropsWithChildren<{ baseLevel?: number }>> = ({\n  children,\n  baseLevel,\n}) => {\n  const level = useContext(LevelContext)\n\n  return <LevelContext.Provider value={baseLevel || level + 1}>{children}</LevelContext.Provider>\n}\n"],"names":[],"mappings":";;;;;;;AAqBA;AASO;AACA;AAGA;AAGA;AAIA;AAIL;AAEA;AACF;;;;;;"}