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AM;gBACJ,GAAG,UAAU;gBACb,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG,2BAA2B;oBAC9D,kBAAkB,CAAC,MAAM,YAAY;gBACvC;YACF;YACA,aAAa;gBACX,UAAU;YACZ;QACF;OACC,WAEF,kCACC,0DAAC,CAAA,GAAA,wCAAa;QACZ,IAAI;QACJ,iBAAA;QACA,MAAK;QACL,cAAY,gBAAgB,MAAM,CAAC;QACnC,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAGxC,aAAa,CAAC,oBAAoB,CAAC,4BAClC,0DAAC,CAAA,GAAA,2DAAU;QAAE,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;sBAEpD,0DAAC,CAAA,GAAA,iEAAgB;QAAE,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;UAG3D,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI,OAAO;IAI1C,IAAI,mBAAmB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG,kBAAkB;QAC1D,yCAAyC;QACzC,gDAAgD,kBAAkB;IACpE;IAEA,qBACE,0DAAC,CAAA,GAAA,+BAAI;QACF,GAAG,KAAK;QACT,KAAK;QACL,kBAAkB;QAClB,YAAY;QACZ,kBAAkB;QAClB,mBAAmB;QACnB,WAAW;QACX,kBAAkB;QAClB,mBAAmB;QACnB,eAAe;QACf,8CAAA;QACA,aAAY;OACX;AAGP","sources":["packages/@adobe/react-spectrum/src/picker/Picker.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 AlertMedium from '@spectrum-icons/ui/AlertMedium';\nimport {\n  Alignment,\n  AsyncLoadable,\n  DimensionValue,\n  DOMRef,\n  DOMRefValue,\n  FocusableRefValue,\n  LabelPosition,\n  SingleSelection,\n  SpectrumLabelableProps,\n  StyleProps\n} from '@react-types/shared';\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\nimport ChevronDownMedium from '@spectrum-icons/ui/ChevronDownMedium';\nimport {classNames} from '../utils/classNames';\nimport {dimensionValue} from '../utils/styleProps';\nimport {Field} from '../label/Field';\nimport {FieldButton} from '../button/FieldButton';\nimport intlMessages from '../../intl/picker/*.json';\nimport {ListBoxBase, useListBoxLayout} from '../listbox/ListBoxBase';\nimport {mergeProps} from 'react-aria/mergeProps';\n// @ts-ignore\nimport {Popover} from '../overlays/Popover';\nimport {PressResponder} from 'react-aria/private/interactions/PressResponder';\nimport {ProgressCircle} from '../progress/ProgressCircle';\nimport React, {ReactElement, useCallback, useRef, useState} from 'react';\nimport {SlotProvider, useSlotProps} from '../utils/Slots';\nimport styles from '@adobe/spectrum-css-temp/components/dropdown/vars.css';\nimport {Text} from '../text/Text';\nimport {Tray} from '../overlays/Tray';\nimport {useDOMRef, useUnwrapDOMRef} from '../utils/useDOMRef';\nimport {useFormProps} from '../form/Form';\nimport {useHover} from 'react-aria/useHover';\nimport {useId} from 'react-aria/useId';\nimport {useIsMobileDevice} from '../utils/useIsMobileDevice';\nimport {useLayoutEffect} from 'react-aria/private/utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\nimport {useProvider, useProviderProps} from '../provider/Provider';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\nimport {useSelectState} from 'react-stately/useSelectState';\n\nexport interface SpectrumPickerProps<T>\n  extends\n    Omit<\n      AriaSelectProps<T>,\n      | 'selectionMode'\n      | 'selectedKey'\n      | 'defaultSelectedKey'\n      | 'onSelectionChange'\n      | 'value'\n      | 'defaultValue'\n      | 'onChange'\n      | 'allowsEmptyCollection'\n    >,\n    Omit<SingleSelection, 'disallowEmptySelection'>,\n    AsyncLoadable,\n    SpectrumLabelableProps,\n    StyleProps {\n  /** Whether the textfield should be displayed with a quiet style. */\n  isQuiet?: boolean;\n  /**\n   * Alignment of the menu relative to the input target.\n   *\n   * @default 'start'\n   */\n  align?: Alignment;\n  /**\n   * Direction the menu will render relative to the Picker.\n   *\n   * @default 'bottom'\n   */\n  direction?: 'bottom' | 'top';\n  /**\n   * Whether the menu should automatically flip direction when space is limited.\n   *\n   * @default true\n   */\n  shouldFlip?: boolean;\n  /**\n   * Width of the menu. By default, matches width of the trigger. Note that the minimum width of the\n   * dropdown is always equal to the trigger's width.\n   */\n  menuWidth?: DimensionValue;\n  /** Whether the element should receive focus on render. */\n  autoFocus?: boolean;\n}\n\n/**\n * Pickers allow users to choose a single option from a collapsible list of options when space is\n * limited.\n */\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nexport const Picker = React.forwardRef(function Picker<T extends object>(\n  props: SpectrumPickerProps<T>,\n  ref: DOMRef<HTMLDivElement>\n) {\n  props = useSlotProps(props, 'picker');\n  props = useProviderProps(props);\n  props = useFormProps(props);\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/picker');\n  let {\n    autoComplete,\n    isDisabled,\n    direction = 'bottom',\n    align = 'start',\n    shouldFlip = true,\n    placeholder = stringFormatter.format('placeholder'),\n    isQuiet,\n    labelPosition = 'top' as LabelPosition,\n    menuWidth,\n    autoFocus\n  } = props;\n\n  let state = useSelectState(props);\n  let domRef = useDOMRef(ref);\n\n  let popoverRef = useRef<DOMRefValue<HTMLDivElement>>(null);\n  let triggerRef = useRef<FocusableRefValue<HTMLElement>>(null);\n  let unwrappedTriggerRef = useUnwrapDOMRef(triggerRef);\n  let listboxRef = useRef(null);\n\n  let isLoadingInitial = props.isLoading && state.collection.size === 0;\n  let isLoadingMore = props.isLoading && state.collection.size > 0;\n  let progressCircleId = useId();\n\n  // We create the listbox layout in Picker and pass it to ListBoxBase below\n  // so that the layout information can be cached even while the listbox is not mounted.\n  // We also use the layout as the keyboard delegate for type to select.\n  let layout = useListBoxLayout();\n  let {\n    labelProps,\n    triggerProps,\n    valueProps,\n    menuProps,\n    hiddenSelectProps,\n    descriptionProps,\n    errorMessageProps,\n    isInvalid,\n    validationErrors,\n    validationDetails\n  } = useSelect(\n    {\n      ...props,\n      'aria-describedby': isLoadingInitial ? progressCircleId : undefined\n    },\n    state,\n    unwrappedTriggerRef\n  );\n\n  let isMobile = useIsMobileDevice();\n  let {hoverProps, isHovered} = useHover({isDisabled});\n\n  // On small screen devices, the listbox is rendered in a tray, otherwise a popover.\n  let listbox = (\n    <ListBoxBase\n      {...menuProps}\n      ref={listboxRef}\n      disallowEmptySelection\n      autoFocus={state.focusStrategy || true}\n      shouldSelectOnPressUp\n      focusOnPointerEnter\n      layout={layout}\n      state={state}\n      width={isMobile ? '100%' : undefined}\n      // Set max height: inherit so Tray scrolling works\n      UNSAFE_style={{maxHeight: 'inherit'}}\n      isLoading={props.isLoading}\n      showLoadingSpinner={isLoadingMore}\n      onLoadMore={props.onLoadMore}\n    />\n  );\n\n  // Measure the width of the button to inform the width of the menu (below).\n  let [buttonWidth, setButtonWidth] = useState<number | undefined>(undefined);\n  let {scale} = useProvider();\n\n  let onResize = useCallback(() => {\n    if (!isMobile && unwrappedTriggerRef.current) {\n      let width = unwrappedTriggerRef.current.offsetWidth;\n      setButtonWidth(width);\n    }\n  }, [unwrappedTriggerRef, setButtonWidth, isMobile]);\n\n  useResizeObserver({\n    ref: unwrappedTriggerRef,\n    onResize: onResize\n  });\n\n  useLayoutEffect(onResize, [scale, state.selectedKey, onResize]);\n\n  let overlay;\n  if (isMobile) {\n    overlay = <Tray state={state}>{listbox}</Tray>;\n  } else {\n    // If quiet, use the default width, otherwise match the width of the button. This can be overridden by the menuWidth prop.\n    // Always have a minimum width of the button width. When quiet, there is an extra offset to add.\n    // Not using style props for this because they don't support `calc`.\n    let width = isQuiet ? undefined : buttonWidth;\n    let style = {\n      width: menuWidth ? dimensionValue(menuWidth) : width,\n      minWidth: isQuiet\n        ? `calc(${buttonWidth}px + calc(2 * var(--spectrum-dropdown-quiet-offset)))`\n        : buttonWidth\n    };\n\n    overlay = (\n      <Popover\n        UNSAFE_style={style}\n        UNSAFE_className={classNames(styles, 'spectrum-Dropdown-popover', {\n          'spectrum-Dropdown-popover--quiet': isQuiet\n        })}\n        ref={popoverRef}\n        placement={`${direction} ${align}`}\n        shouldFlip={shouldFlip}\n        hideArrow\n        state={state}\n        triggerRef={unwrappedTriggerRef}\n        scrollRef={listboxRef}\n        shouldContainFocus>\n        {listbox}\n      </Popover>\n    );\n  }\n\n  let contents = state.selectedItem ? state.selectedItem.rendered : placeholder;\n  if (typeof contents === 'string') {\n    contents = <Text>{contents}</Text>;\n  }\n\n  let picker = (\n    <div\n      className={classNames(styles, 'spectrum-Dropdown', {\n        'is-invalid': isInvalid && !isDisabled,\n        'is-disabled': isDisabled,\n        'spectrum-Dropdown--quiet': isQuiet\n      })}>\n      <HiddenSelect autoComplete={autoComplete} {...hiddenSelectProps} />\n      <PressResponder {...mergeProps(hoverProps, triggerProps)}>\n        <FieldButton\n          ref={triggerRef}\n          isActive={state.isOpen}\n          isQuiet={isQuiet}\n          isDisabled={isDisabled}\n          isInvalid={isInvalid}\n          autoFocus={autoFocus}\n          UNSAFE_className={classNames(styles, 'spectrum-Dropdown-trigger', {\n            'is-hovered': isHovered\n          })}>\n          <SlotProvider\n            slots={{\n              icon: {UNSAFE_className: classNames(styles, 'spectrum-Icon'), size: 'S'},\n              avatar: {\n                UNSAFE_className: classNames(styles, 'spectrum-Dropdown-avatar'),\n                size: 'avatar-size-100'\n              },\n              text: {\n                ...valueProps,\n                UNSAFE_className: classNames(styles, 'spectrum-Dropdown-label', {\n                  'is-placeholder': !state.selectedItem\n                })\n              },\n              description: {\n                isHidden: true\n              }\n            }}>\n            {contents}\n          </SlotProvider>\n          {isLoadingInitial && (\n            <ProgressCircle\n              id={progressCircleId}\n              isIndeterminate\n              size=\"S\"\n              aria-label={stringFormatter.format('loading')}\n              UNSAFE_className={classNames(styles, 'spectrum-Dropdown-progressCircle')}\n            />\n          )}\n          {isInvalid && !isLoadingInitial && !isDisabled && (\n            <AlertMedium UNSAFE_className={classNames(styles, 'spectrum-Dropdown-invalidIcon')} />\n          )}\n          <ChevronDownMedium UNSAFE_className={classNames(styles, 'spectrum-Dropdown-chevron')} />\n        </FieldButton>\n      </PressResponder>\n      {state.collection.size === 0 ? null : overlay}\n    </div>\n  );\n\n  let wrapperClassName = classNames(styles, 'spectrum-Field', {\n    'spectrum-Dropdown-fieldWrapper--quiet': isQuiet,\n    'spectrum-Dropdown-fieldWrapper--positionSide': labelPosition === 'side'\n  });\n\n  return (\n    <Field\n      {...props}\n      ref={domRef}\n      wrapperClassName={wrapperClassName}\n      labelProps={labelProps}\n      descriptionProps={descriptionProps}\n      errorMessageProps={errorMessageProps}\n      isInvalid={isInvalid}\n      validationErrors={validationErrors}\n      validationDetails={validationDetails}\n      showErrorIcon={false}\n      includeNecessityIndicatorInAccessibilityName\n      elementType=\"span\">\n      {picker}\n    </Field>\n  );\n}) as <T>(props: SpectrumPickerProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\n"],"names":[],"version":3,"file":"Picker.cjs.map"}