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AAgB,KAA2B,EAAE,GAAiC;IACjK,IAAI,QAAC,OAAO,SAAQ,GAAG;IACvB,IAAI,cAAC,UAAU,YAAE,QAAQ,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;IACxC,IAAI,EACF,gBAAgB,oBAAoB,EACpC,YAAY,gBAAgB,EAC7B,GAAG,CAAA,GAAA,mBAAW,EAAE;QAAC,QAAQ;IAAI;IAC9B,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;kCACN;QACF;IACF;IACA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;QAAM,WAAW;IAAI;IACnE,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,aAAa,YAAY,iBAAiB;QACnE,KAAK,CAAA,GAAA,gBAAQ,EAAE,KAAK;QACpB,MAAM;QACN,6BAA2B,wBAAwB;qBACnD,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAY;gBAAG;aAAK;SACtB;OACA,MAAM,QAAQ;AAIvB","sources":["packages/react-aria-components/src/Disclosure.tsx"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaDisclosureProps, useDisclosure} from 'react-aria/useDisclosure';\n\nimport {ButtonContext} from './Button';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  DEFAULT_SLOT,\n  dom,\n  Provider,\n  RenderProps,\n  SlotProps,\n  useContextProps,\n  useRenderProps\n} from './utils';\nimport {\n  DisclosureGroupState,\n  DisclosureGroupProps as StatelyDisclosureGroupProps,\n  useDisclosureGroupState\n} from 'react-stately/useDisclosureGroupState';\nimport {DisclosureState, useDisclosureState} from 'react-stately/useDisclosureState';\n\nimport {DOMProps, forwardRefType, GlobalDOMAttributes, Key} from '@react-types/shared';\n\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {LabelAriaProps} from 'react-aria/useLabel';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {mergeRefs} from 'react-aria/mergeRefs';\nimport React, {createContext, DOMAttributes, ForwardedRef, forwardRef, ReactNode, useContext} from 'react';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useId} from 'react-aria/useId';\n\nexport interface DisclosureGroupProps extends StatelyDisclosureGroupProps, RenderProps<DisclosureGroupRenderProps>, DOMProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-DisclosureGroup'\n   */\n  className?: ClassNameOrFunction<DisclosureGroupRenderProps>\n}\n\nexport interface DisclosureGroupRenderProps {\n  /**\n   * Whether the disclosure group is disabled.\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean,\n  /**\n   * State of the disclosure group.\n   */\n  state: DisclosureGroupState\n}\n\nexport const DisclosureGroupStateContext = createContext<DisclosureGroupState | null>(null);\n\n/**\n * A DisclosureGroup is a grouping of related disclosures, sometimes called an accordion.\n * It supports both single and multiple expanded items.\n */\nexport const DisclosureGroup = forwardRef(function DisclosureGroup(props: DisclosureGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n  let state = useDisclosureGroupState(props);\n\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-DisclosureGroup',\n    values: {\n      isDisabled: state.isDisabled,\n      state\n    }\n  });\n\n  let domProps = filterDOMProps(props, {global: true});\n\n  return (\n    <dom.div\n      {...domProps}\n      {...renderProps}\n      ref={ref}\n      data-disabled={props.isDisabled || undefined}>\n      <DisclosureGroupStateContext.Provider value={state}>\n        {renderProps.children}\n      </DisclosureGroupStateContext.Provider>\n    </dom.div>\n  );\n});\n\nexport interface DisclosureProps extends Omit<AriaDisclosureProps, 'children'>, RenderProps<DisclosureRenderProps>, SlotProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-Disclosure'\n   */\n  className?: ClassNameOrFunction<DisclosureRenderProps>,\n  /** An id for the disclosure when used within a DisclosureGroup, matching the id used in `expandedKeys`. */\n  id?: Key\n}\n\nexport interface DisclosureRenderProps {\n  /**\n   * Whether the disclosure is expanded.\n   * @selector [data-expanded]\n   */\n  isExpanded: boolean,\n  /**\n   * Whether the disclosure has keyboard focus.\n   * @selector [data-focus-visible-within]\n   */\n  isFocusVisibleWithin: boolean,\n  /**\n   * Whether the disclosure is disabled.\n   * @selector [data-disabled]\n   */\n  isDisabled: boolean,\n  /**\n   * State of the disclosure.\n   */\n  state: DisclosureState\n}\n\nexport const DisclosureContext = createContext<ContextValue<DisclosureProps, HTMLDivElement>>(null);\nexport const DisclosureStateContext = createContext<DisclosureState | null>(null);\n\ninterface InternalDisclosureContextValue {\n  panelProps: DOMAttributes<HTMLElement>,\n  panelRef: React.RefObject<HTMLDivElement | null>\n}\n\nconst InternalDisclosureContext = createContext<InternalDisclosureContextValue | null>(null);\n\n/**\n * A disclosure is a collapsible section of content. It is composed of a a header with a heading and trigger button, and a panel that contains the content.\n */\nexport const Disclosure = /*#__PURE__*/ (forwardRef as forwardRefType)(function Disclosure(props: DisclosureProps, ref: ForwardedRef<HTMLDivElement>) {\n  [props, ref] = useContextProps(props, ref, DisclosureContext);\n  let groupState = useContext(DisclosureGroupStateContext)!;\n  let {id, ...otherProps} = props;\n\n  // Generate an id if one wasn't provided.\n  // (can't pass id into useId since it can also be a number)\n  let defaultId = useId();\n  id ||= defaultId;\n\n  let isExpanded = groupState ? groupState.expandedKeys.has(id) : props.isExpanded;\n  let state = useDisclosureState({\n    ...props,\n    isExpanded,\n    onExpandedChange(isExpanded) {\n      if (groupState) {\n        groupState.toggleKey(id);\n      }\n\n      props.onExpandedChange?.(isExpanded);\n    }\n  });\n\n  let panelRef = React.useRef<HTMLDivElement | null>(null);\n  let isDisabled = props.isDisabled || groupState?.isDisabled || false;\n  let {buttonProps, panelProps} = useDisclosure({\n    ...props,\n    isExpanded,\n    isDisabled\n  }, state, panelRef);\n  let {\n    isFocusVisible: isFocusVisibleWithin,\n    focusProps: focusWithinProps\n  } = useFocusRing({within: true});\n\n  let renderProps = useRenderProps({\n    ...props,\n    id: undefined,\n    defaultClassName: 'react-aria-Disclosure',\n    values: {\n      isExpanded: state.isExpanded,\n      isDisabled,\n      isFocusVisibleWithin,\n      state\n    }\n  });\n\n  let domProps = filterDOMProps(otherProps, {global: true});\n\n  return (\n    <Provider\n      values={[\n        [ButtonContext, {\n          slots: {\n            [DEFAULT_SLOT]: {},\n            trigger: buttonProps\n          }\n        }],\n        [InternalDisclosureContext, {panelProps, panelRef}],\n        [DisclosureStateContext, state]\n      ]}>\n      <dom.div\n        {...mergeProps(domProps, renderProps, focusWithinProps)}\n        ref={ref}\n        data-expanded={state.isExpanded || undefined}\n        data-disabled={isDisabled || undefined}\n        data-focus-visible-within={isFocusVisibleWithin || undefined}>\n        {renderProps.children}\n      </dom.div>\n    </Provider>\n  );\n});\n\nexport interface DisclosurePanelRenderProps {\n  /**\n   * Whether keyboard focus is within the disclosure panel.\n   * @selector [data-focus-visible-within]\n   */\n  isFocusVisibleWithin: boolean\n}\n\nexport interface DisclosurePanelProps extends RenderProps<DisclosurePanelRenderProps>, DOMProps, LabelAriaProps, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.\n   * @default 'react-aria-DisclosurePanel'\n   */\n  className?: ClassNameOrFunction<DisclosurePanelRenderProps>,\n  /**\n   * The accessibility role for the disclosure's panel.\n   * @default 'group'\n   */\n  role?: 'group' | 'region',\n  /**\n   * The children of the component.\n   */\n  children: ReactNode\n}\n\n/**\n * A DisclosurePanel provides the content for a disclosure.\n */\nexport const DisclosurePanel = /*#__PURE__*/ (forwardRef as forwardRefType)(function DisclosurePanel(props: DisclosurePanelProps, ref: ForwardedRef<HTMLDivElement>) {\n  let {role = 'group'} = props;\n  let {panelProps, panelRef} = useContext(InternalDisclosureContext)!;\n  let {\n    isFocusVisible: isFocusVisibleWithin,\n    focusProps: focusWithinProps\n  } = useFocusRing({within: true});\n  let renderProps = useRenderProps({\n    ...props,\n    defaultClassName: 'react-aria-DisclosurePanel',\n    values: {\n      isFocusVisibleWithin\n    }\n  });\n  let DOMProps = filterDOMProps(props, {global: true, labelable: true});\n  return (\n    <dom.div\n      {...mergeProps(DOMProps, renderProps, panelProps, focusWithinProps)}\n      ref={mergeRefs(ref, panelRef)}\n      role={role}\n      data-focus-visible-within={isFocusVisibleWithin || undefined}>\n      <Provider\n        values={[\n          [ButtonContext, null]\n        ]}>\n        {props.children}\n      </Provider>\n    </dom.div>\n  );\n});\n"],"names":[],"version":3,"file":"Disclosure.mjs.map"}