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SAAS,IAAI;QAClC,sBAAoB,kBAAkB;QACtC,gBAAc,OAAO,SAAS,IAAI;QAClC,wBAAsB,OAAO,cAAc,IAAI;QAC/C,uBAAqB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,YAAY,MAAM,gBAAgB,CAAC,aAAa;qBACvH,0DAAC;QAAK,GAAG,aAAa;QAAE,OAAO;YAAC,SAAS;QAAU;qBACjD,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,uCAAY;gBAAG;oBACd,OAAO;wBACL,QAAQ;oBACV;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,mDAAwB;gBAAG,CAAA,GAAA,mDAAwB;aAAE;YACtD;gBAAC,CAAA,GAAA,mDAAwB;gBAAG;oBAAC,YAAY,OAAO,UAAU;gBAAA;aAAE;SAC7D;OACA,YAAY,QAAQ;AAK/B","sources":["packages/react-aria-components/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {AriaTagGroupProps, useTag, useTagGroup} from 'react-aria/useTagGroup';\n\nimport {ButtonContext} from './Button';\nimport {\n  ClassNameOrFunction,\n  ContextValue,\n  dom,\n  DOMProps,\n  DOMRenderProps,\n  Provider,\n  RenderProps,\n  SlotProps,\n  StyleRenderProps,\n  useContextProps,\n  useRenderProps,\n  useSlot\n} from './utils';\nimport {Collection} from 'react-aria/Collection';\nimport {CollectionBuilder, createLeafComponent} from 'react-aria/CollectionBuilder';\nimport {CollectionProps, CollectionRendererContext, DefaultCollectionRenderer, ItemRenderProps, usePersistedKeys} from './Collection';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FocusEvents, forwardRefType, GlobalDOMAttributes, HoverEvents, Key, LinkDOMProps, PressEvents, RefObject} from '@react-types/shared';\nimport {ItemNode} from 'react-aria/private/collections/BaseCollection';\nimport {LabelContext} from './Label';\nimport {ListState, UNSTABLE_useFilteredListState, useListState} from 'react-stately/useListState';\nimport {ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {Node} from '@react-types/shared';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactNode, useContext, useEffect, useRef} from 'react';\nimport {SelectableCollectionContext, SelectableCollectionContextValue} from './Autocomplete';\nimport {SelectionIndicatorContext} from './SelectionIndicator';\nimport {SharedElementTransition} from './SharedElementTransition';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useHover} from 'react-aria/useHover';\nimport {useObjectRef} from 'react-aria/useObjectRef';\n\nexport interface TagGroupProps extends Omit<AriaTagGroupProps<unknown>, 'children' | 'items' | 'label' | 'description' | 'errorMessage' | 'keyboardDelegate'>, DOMProps, SlotProps, DOMRenderProps<'div', undefined>, GlobalDOMAttributes<HTMLDivElement> {\n  /**\n   * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element.\n   * @default 'react-aria-TagGroup'\n   */\n  className?: string\n}\n\nexport interface TagListRenderProps {\n  /**\n   * Whether the tag list has no items and should display its empty state.\n   * @selector [data-empty]\n   */\n  isEmpty: boolean,\n  /**\n   * Whether the tag list is currently focused.\n   * @selector [data-focused]\n   */\n  isFocused: boolean,\n  /**\n   * Whether the tag list is currently keyboard focused.\n   * @selector [data-focus-visible]\n   */\n  isFocusVisible: boolean,\n  /**\n   * State of the TagGroup.\n   */\n  state: ListState<unknown>\n}\n\nexport interface TagListProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'>, StyleRenderProps<TagListRenderProps, 'div'>, 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-TagList'\n   */\n  className?: ClassNameOrFunction<TagListRenderProps>,\n  /** Provides content to display when there are no items in the tag list. */\n  renderEmptyState?: (props: TagListRenderProps) => ReactNode\n}\n\nexport const TagGroupContext = createContext<ContextValue<TagGroupProps, HTMLDivElement>>(null);\nexport const TagListContext = createContext<ContextValue<TagListProps<any>, HTMLDivElement>>(null);\n\n/**\n * A tag group is a focusable list of labels, categories, keywords, filters, or other items, with support for keyboard navigation, selection, and removal.\n */\nexport const TagGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagGroup(props: TagGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n  [props, ref] = useContextProps(props, ref, TagGroupContext);\n  return (\n    <ListStateContext.Provider value={null}>\n      <CollectionBuilder content={props.children}>\n        {collection => <TagGroupInner props={props} forwardedRef={ref} collection={collection} />}\n      </CollectionBuilder>\n    </ListStateContext.Provider>\n  );\n});\n\ninterface TagGroupInnerProps<T> {\n  props: TagGroupProps & SelectableCollectionContextValue<T>,\n  forwardedRef: ForwardedRef<HTMLDivElement>,\n  collection: any\n}\n\nfunction TagGroupInner<T extends object>({props, forwardedRef: ref, collection}: TagGroupInnerProps<T>) {\n  let tagListRef = useRef<HTMLElement>(null);\n  // Extract the user provided id so it doesn't clash with the collection id provided by Autocomplete\n  let {id, ...otherProps} = props;\n  [otherProps, tagListRef] = useContextProps(otherProps, tagListRef, SelectableCollectionContext);\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  let {filter, shouldUseVirtualFocus, ...DOMCollectionProps} = otherProps;\n  let [labelRef, label] = useSlot(\n    !props['aria-label'] && !props['aria-labelledby']\n  );\n  let tagGroupState = useListState({\n    ...DOMCollectionProps,\n    children: undefined,\n    collection\n  });\n\n  let filteredState = UNSTABLE_useFilteredListState(tagGroupState as ListState<T>, filter);\n\n  // Prevent DOM props from going to two places.\n  let domProps = filterDOMProps(otherProps, {global: true});\n  let domPropOverrides = Object.fromEntries(Object.entries(domProps).map(([k, val]) => [k, k === 'id' ? val : undefined]));\n  let {\n    gridProps,\n    labelProps,\n    descriptionProps,\n    errorMessageProps\n  } = useTagGroup({\n    ...DOMCollectionProps,\n    ...domPropOverrides,\n    label\n  }, filteredState, tagListRef);\n\n  return (\n    <dom.div\n      render={props.render}\n      {...domProps}\n      id={id}\n      ref={ref}\n      slot={props.slot || undefined}\n      className={props.className ?? 'react-aria-TagGroup'}\n      style={props.style}>\n      <Provider\n        values={[\n          [LabelContext, {...labelProps, elementType: 'span', ref: labelRef}],\n          [TagListContext, {...gridProps, ref: tagListRef as RefObject<HTMLDivElement>}],\n          [ListStateContext, filteredState],\n          [TextContext, {\n            slots: {\n              description: descriptionProps,\n              errorMessage: errorMessageProps\n            }\n          }]\n        ]}>\n        {props.children}\n      </Provider>\n    </dom.div>\n  );\n}\n\n/**\n * A tag list is a container for tags within a TagGroup.\n */\nexport const TagList = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagList<T extends object>(props: TagListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {\n  let state = useContext(ListStateContext);\n  return state\n    ? <TagListInner props={props} forwardedRef={ref} />\n    : <Collection {...props} />;\n});\n\ninterface TagListInnerProps<T> {\n  props: TagListProps<T>,\n  forwardedRef: ForwardedRef<HTMLDivElement>\n}\n\nfunction TagListInner<T extends object>({props, forwardedRef}: TagListInnerProps<T>) {\n  let state = useContext(ListStateContext)!;\n  let {CollectionRoot} = useContext(CollectionRendererContext);\n  let [gridProps, ref] = useContextProps({}, forwardedRef, TagListContext);\n\n  let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n  let renderValues = {\n    isEmpty: state.collection.size === 0,\n    isFocused,\n    isFocusVisible,\n    state\n  };\n  let renderProps = useRenderProps({\n    ...props,\n    children: undefined,\n    defaultClassName: 'react-aria-TagList',\n    values: renderValues\n  });\n\n  let persistedKeys = usePersistedKeys(state.selectionManager.focusedKey);\n  let DOMProps = filterDOMProps(props, {global: true});\n\n  return (\n    <dom.div\n      {...mergeProps(DOMProps, renderProps, gridProps, focusProps)}\n      ref={ref}\n      data-empty={state.collection.size === 0 || undefined}\n      data-focused={isFocused || undefined}\n      data-focus-visible={isFocusVisible || undefined}>\n      <SharedElementTransition>\n        {state.collection.size === 0 && props.renderEmptyState\n          ? props.renderEmptyState(renderValues)\n          : <CollectionRoot collection={state.collection} persistedKeys={persistedKeys} />}\n      </SharedElementTransition>\n    </dom.div>\n  );\n}\n\nexport interface TagRenderProps extends Omit<ItemRenderProps, 'allowsDragging' | 'isDragging' | 'isDropTarget'> {\n  /**\n   * Whether the tag group allows items to be removed.\n   * @selector [data-allows-removing]\n   */\n  allowsRemoving: boolean\n}\n\nexport interface TagProps extends RenderProps<TagRenderProps, 'div'>, LinkDOMProps, HoverEvents, FocusEvents, PressEvents, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\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-Tag'\n   */\n  className?: ClassNameOrFunction<TagRenderProps>,\n  /** A unique id for the tag. */\n  id?: Key,\n  /**\n   * A string representation of the tags's contents, used for accessibility.\n   * Required if children is not a plain text string.\n   */\n  textValue?: string,\n  /** Whether the tag is disabled. */\n  isDisabled?: boolean,\n  /**\n   * Handler that is called when a user performs an action on the item. The exact user event depends on\n   * the collection's `selectionBehavior` prop and the interaction modality.\n   */\n  onAction?: () => void\n}\n\n/**\n * A Tag is an individual item within a TagList.\n */\nexport const Tag = /*#__PURE__*/ createLeafComponent(ItemNode, (props: TagProps, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<unknown>) => {\n  let state = useContext(ListStateContext)!;\n  let ref = useObjectRef<HTMLDivElement>(forwardedRef);\n  let {focusProps, isFocusVisible} = useFocusRing({within: false});\n  let {rowProps, gridCellProps, removeButtonProps, ...states} = useTag({item}, state, ref);\n\n  let {hoverProps, isHovered} = useHover({\n    isDisabled: !states.allowsSelection && !states.hasAction,\n    onHoverStart: item.props.onHoverStart,\n    onHoverChange: item.props.onHoverChange,\n    onHoverEnd: item.props.onHoverEnd\n  });\n\n  let renderProps = useRenderProps({\n    ...props,\n    id: undefined,\n    children: item.rendered,\n    defaultClassName: 'react-aria-Tag',\n    values: {\n      ...states,\n      isFocusVisible,\n      isHovered,\n      selectionMode: state.selectionManager.selectionMode,\n      selectionBehavior: state.selectionManager.selectionBehavior\n    }\n  });\n\n  useEffect(() => {\n    if (!item.textValue && process.env.NODE_ENV !== 'production') {\n      console.warn('A `textValue` prop is required for <Tag> elements with non-plain text children for accessibility.');\n    }\n  }, [item.textValue]);\n\n  let DOMProps = filterDOMProps(props as any, {global: true});\n  delete DOMProps.id;\n  delete DOMProps.onClick;\n\n  return (\n    <dom.div\n      ref={ref}\n      {...mergeProps(DOMProps, renderProps, rowProps, focusProps, hoverProps)}\n      data-selected={states.isSelected || undefined}\n      data-disabled={states.isDisabled || undefined}\n      data-hovered={isHovered || undefined}\n      data-focused={states.isFocused || undefined}\n      data-focus-visible={isFocusVisible || undefined}\n      data-pressed={states.isPressed || undefined}\n      data-allows-removing={states.allowsRemoving || undefined}\n      data-selection-mode={state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode}>\n      <div {...gridCellProps} style={{display: 'contents'}}>\n        <Provider\n          values={[\n            [ButtonContext, {\n              slots: {\n                remove: removeButtonProps\n              }\n            }],\n            [CollectionRendererContext, DefaultCollectionRenderer],\n            [SelectionIndicatorContext, {isSelected: states.isSelected}]\n          ]}>\n          {renderProps.children}\n        </Provider>\n      </div>\n    </dom.div>\n  );\n});\n"],"names":[],"version":3,"file":"TagGroup.cjs.map"}