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gB,KAA2B,EAAE,GAAiC;IACrF,IAAI,QAAC,OAAO,SAAQ,GAAG;IACvB,IAAI,cAAC,UAAU,YAAE,QAAQ,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;IACxC,IAAI,EAAC,gBAAgB,oBAAoB,EAAE,YAAY,gBAAgB,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE;QACtF,QAAQ;IACV;IACA,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;QAAE,QAAQ;YAAC;gBAAC,CAAA,GAAA,yCAAY;gBAAG;aAAK;SAAC;OAAG,MAAM,QAAQ;AAGhE","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, {\n  createContext,\n  DOMAttributes,\n  ForwardedRef,\n  forwardRef,\n  ReactNode,\n  useContext\n} from 'react';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useId} from 'react-aria/useId';\n\nexport interface DisclosureGroupProps\n  extends\n    StatelyDisclosureGroupProps,\n    RenderProps<DisclosureGroupRenderProps>,\n    DOMProps,\n    GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-DisclosureGroup'\n   */\n  className?: ClassNameOrFunction<DisclosureGroupRenderProps>;\n}\n\nexport interface DisclosureGroupRenderProps {\n  /**\n   * Whether the disclosure group is disabled.\n   *\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(\n  props: DisclosureGroupProps,\n  ref: ForwardedRef<HTMLDivElement>\n) {\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 {...domProps} {...renderProps} ref={ref} 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\n  extends\n    Omit<AriaDisclosureProps, 'children'>,\n    RenderProps<DisclosureRenderProps>,\n    SlotProps,\n    GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-Disclosure'\n   */\n  className?: ClassNameOrFunction<DisclosureRenderProps>;\n  /**\n   * An id for the disclosure when used within a DisclosureGroup, matching the id used in\n   * `expandedKeys`.\n   */\n  id?: Key;\n}\n\nexport interface DisclosureRenderProps {\n  /**\n   * Whether the disclosure is expanded.\n   *\n   * @selector [data-expanded]\n   */\n  isExpanded: boolean;\n  /**\n   * Whether the disclosure has keyboard focus.\n   *\n   * @selector [data-focus-visible-within]\n   */\n  isFocusVisibleWithin: boolean;\n  /**\n   * Whether the disclosure is disabled.\n   *\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\n * trigger button, and a panel that contains the content.\n */\nexport const Disclosure = /*#__PURE__*/ (forwardRef as forwardRefType)(function Disclosure(\n  props: DisclosureProps,\n  ref: ForwardedRef<HTMLDivElement>\n) {\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    {\n      ...props,\n      isExpanded,\n      isDisabled\n    },\n    state,\n    panelRef\n  );\n  let {isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps} = useFocusRing({\n    within: true\n  });\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        [\n          ButtonContext,\n          {\n            slots: {\n              [DEFAULT_SLOT]: {},\n              trigger: buttonProps\n            }\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   *\n   * @selector [data-focus-visible-within]\n   */\n  isFocusVisibleWithin: boolean;\n}\n\nexport interface DisclosurePanelProps\n  extends\n    RenderProps<DisclosurePanelRenderProps>,\n    DOMProps,\n    LabelAriaProps,\n    GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n   * element. A function may be provided to compute the class based on component state.\n   *\n   * @default 'react-aria-DisclosurePanel'\n   */\n  className?: ClassNameOrFunction<DisclosurePanelRenderProps>;\n  /**\n   * The accessibility role for the disclosure's panel.\n   *\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)(\n  function DisclosurePanel(props: DisclosurePanelProps, ref: ForwardedRef<HTMLDivElement>) {\n    let {role = 'group'} = props;\n    let {panelProps, panelRef} = useContext(InternalDisclosureContext)!;\n    let {isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps} = useFocusRing({\n      within: true\n    });\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 values={[[ButtonContext, null]]}>{props.children}</Provider>\n      </dom.div>\n    );\n  }\n);\n"],"names":[],"version":3,"file":"Disclosure.mjs.map"}