{"version":3,"file":"DisclosureContent.cjs","sources":["../../../src/components/Disclosure/DisclosureContent.tsx"],"sourcesContent":["'use client'\n\nimport { type ComponentProps, type FC, type PropsWithChildren, useEffect } from 'react'\n\nimport { VisuallyHiddenText } from '../VisuallyHiddenText'\n\nimport { useDisclosure } from './useDisclosure'\n\ntype DisclosureContentAbstractProps = PropsWithChildren<{\n  /** DisclosureTriggerのtargetIdと紐づけるId */\n  id: string\n  /** 開閉状態。デフォルトは閉じている */\n  isOpen?: boolean\n  /** 閉じた状態でContentを要素として存在させるか。デフォルトでは要素は存在しない */\n  visuallyHidden?: boolean\n}>\n\ntype DisclosureContentProps = DisclosureContentAbstractProps &\n  Omit<ComponentProps<'div'>, keyof DisclosureContentAbstractProps>\n\nexport const DisclosureContent: FC<DisclosureContentProps> = ({\n  id,\n  isOpen,\n  visuallyHidden,\n  children,\n  ...rest\n}) => {\n  const [expanded, setExpanded] = useDisclosure(id)\n\n  useEffect(() => {\n    if (isOpen !== undefined) {\n      setExpanded(isOpen)\n    }\n  }, [isOpen, setExpanded])\n\n  if (expanded) {\n    return (\n      <div {...rest} id={id}>\n        {children}\n      </div>\n    )\n  }\n\n  if (visuallyHidden) {\n    return (\n      <VisuallyHiddenText {...rest} id={id} as=\"div\">\n        {children}\n      </VisuallyHiddenText>\n    )\n  }\n\n  return null\n}\n"],"names":[],"mappings":";;;;;;;;AAoBO;;;AAUH;;;AAGF;;;;;AAWE;;AAOF;AACF;;"}