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AkB,CAAA,GAAA,mBAAK,EAAE;IAC7B,IAAI,CAAC,WAAW,IAAI,GAAG,CAAA,GAAA,+CAAc,EACnC;QAAC,GAAG,KAAK;QAAE,MAAM;IAAS,GAC1B,iBACA,CAAA,GAAA,8CAAY;IAEd,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG;IAC/B,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,sCAAQ;IAE1B,4KAA4K;IAC5K,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,mCAAQ,EAC1B;QACE,GAAG,SAAS;QACZ,aAAa;IACf,GACA;IAGF,qBACE,0DAAC;QACE,GAAG,WAAW;QACf,KAAK;QACL,kHAAkH;QAClH,UAAU,CAAA,GAAA,8CAAQ,OAAO,CAAC,aAAa,KAAK;QAC5C,WAAW,mCAAa;wBAAC;wBAAY;YAAY,OAAO,cAAc;QAAK;OAC1E,cAAc,sBAAQ,0DAAC,CAAA,GAAA,kEAAiB,yBAAO,0DAAC,CAAA,GAAA,iEAAgB;AAGvE","sources":["packages/@adobe/react-spectrum/src/tree/TreeView.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 {AriaTreeProps} from 'react-aria/useTree';\n\nimport {ButtonContext} from 'react-aria-components/Button';\n\nimport {Checkbox} from '../checkbox/Checkbox';\n\nimport ChevronLeftMedium from '@spectrum-icons/ui/ChevronLeftMedium';\nimport ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium';\nimport {\n  DOMRef,\n  Expandable,\n  Key,\n  SelectionBehavior,\n  SpectrumSelectionProps,\n  StyleProps\n} from '@react-types/shared';\nimport {focusRing, style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};\nimport {isAndroid} from 'react-aria/private/utils/platform';\nimport React, {\n  createContext,\n  JSX,\n  JSXElementConstructor,\n  ReactElement,\n  ReactNode,\n  useRef\n} from 'react';\nimport {SlotProvider} from '../utils/Slots';\nimport {\n  Tree,\n  TreeItem,\n  TreeItemContent,\n  TreeItemContentProps,\n  TreeItemContentRenderProps,\n  TreeItemProps,\n  TreeItemRenderProps,\n  TreeRenderProps\n} from 'react-aria-components/Tree';\nimport {useButton} from 'react-aria/useButton';\nimport {useContextProps} from 'react-aria-components/slots';\nimport {useDOMRef} from '../utils/useDOMRef';\nimport {useLocale} from 'react-aria/I18nProvider';\nimport {useStyleProps} from '../utils/styleProps';\n\nexport interface SpectrumTreeViewProps<T>\n  extends\n    Omit<AriaTreeProps<T>, 'children' | 'render'>,\n    StyleProps,\n    SpectrumSelectionProps,\n    Expandable {\n  /** Provides content to display when there are no items in the tree. */\n  renderEmptyState?: () => JSX.Element;\n  /**\n   * Handler that is called when a user performs an action on an item. The exact user event depends\n   * on the collection's `selectionStyle` prop and the interaction modality.\n   */\n  onAction?: (key: Key) => void;\n  /**\n   * The contents of the tree.\n   */\n  children?: ReactNode | ((item: T) => ReactNode);\n}\n\nexport interface SpectrumTreeViewItemProps extends Omit<\n  TreeItemProps,\n  | 'className'\n  | 'style'\n  | 'render'\n  | 'value'\n  | 'onHoverStart'\n  | 'onHoverEnd'\n  | 'onHoverChange'\n  | 'onClick'\n> {\n  /** Rendered contents of the tree item or child items. */\n  children: ReactNode;\n}\n\ninterface TreeRendererContextValue {\n  renderer?: (item) => ReactElement<any, string | JSXElementConstructor<any>>;\n}\nconst TreeRendererContext = createContext<TreeRendererContextValue>({});\n\n// TODO: add animations for rows appearing and disappearing\n\n// TODO: the below is needed so the borders of the top and bottom row isn't cut off if the TreeView is wrapped within a container by always reserving the 2px needed for the\n// keyboard focus ring. Perhaps find a different way of rendering the outlines since the top of the item doesn't\n// scroll into view due to how the ring is offset. Alternatively, have the tree render the top/bottom outline like it does in Listview\nconst tree = style<Pick<TreeRenderProps, 'isEmpty'>>({\n  ...focusRing(),\n  outlineOffset: '[-2px]', // make certain we are visible inside overflow hidden containers\n  height: 'full',\n  width: 'full',\n  borderWidth: 2,\n  boxSizing: 'border-box',\n  borderXWidth: 0,\n  borderStyle: 'solid',\n  borderColor: {\n    default: 'transparent',\n    forcedColors: 'Background'\n  },\n  justifyContent: {\n    isEmpty: 'center'\n  },\n  alignItems: {\n    isEmpty: 'center'\n  },\n  display: {\n    isEmpty: 'flex'\n  },\n  overflow: 'auto'\n});\n\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nexport const TreeView = React.forwardRef(function TreeView<T extends object>(\n  props: SpectrumTreeViewProps<T>,\n  ref: DOMRef<HTMLDivElement>\n) {\n  let {children, selectionStyle, UNSAFE_className} = props;\n\n  let renderer;\n  if (typeof children === 'function') {\n    renderer = children;\n  }\n\n  let {styleProps} = useStyleProps(props);\n  let domRef = useDOMRef(ref);\n  let selectionBehavior = selectionStyle === 'highlight' ? 'replace' : 'toggle';\n\n  return (\n    <TreeRendererContext.Provider value={{renderer}}>\n      <Tree\n        {...props}\n        {...styleProps}\n        className={renderProps => (UNSAFE_className ?? '') + tree(renderProps)}\n        selectionBehavior={selectionBehavior as SelectionBehavior}\n        ref={domRef}>\n        {props.children}\n      </Tree>\n    </TreeRendererContext.Provider>\n  );\n}) as <T>(props: SpectrumTreeViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\n\ninterface TreeRowRenderProps extends TreeItemRenderProps {\n  isLink?: boolean;\n}\n\nconst treeRow = style<TreeRowRenderProps>({\n  position: 'relative',\n  display: 'flex',\n  height: 10,\n  width: 'full',\n  boxSizing: 'border-box',\n  fontSize: 'base',\n  fontWeight: 'normal',\n  lineHeight: 200,\n  color: 'body',\n  outlineStyle: 'none',\n  cursor: {\n    default: 'default',\n    isLink: 'pointer'\n  },\n  // TODO: not sure where to get the equivalent colors here, for instance isHovered is spectrum 600 with 10% opacity but I don't think that exists in the theme\n  backgroundColor: {\n    isHovered: '[var(--spectrum-table-row-background-color-hover)]',\n    isFocusVisibleWithin: '[var(--spectrum-table-row-background-color-hover)]',\n    isPressed: '[var(--spectrum-table-row-background-color-down)]',\n    isSelected: '[var(--spectrum-table-row-background-color-selected)]'\n  }\n});\n\nconst treeCellGrid = style({\n  display: 'grid',\n  width: 'full',\n  alignItems: 'center',\n  gridTemplateColumns: [\n    'minmax(0, auto)',\n    'minmax(0, auto)',\n    'minmax(0, auto)',\n    10,\n    'minmax(0, auto)',\n    '1fr',\n    'minmax(0, auto)',\n    'auto'\n  ],\n  gridTemplateRows: '1fr',\n  gridTemplateAreas: [\n    'drag-handle checkbox level-padding expand-button icon content actions actionmenu'\n  ],\n  color: {\n    isDisabled: {\n      default: 'gray-400',\n      forcedColors: 'GrayText'\n    }\n  }\n});\n\n// TODO: These styles lose against the spectrum class names, so I've did unsafe for the ones that get overridden\nconst treeCheckbox = style({\n  gridArea: 'checkbox',\n  transitionDuration: '160ms',\n  marginStart: 3,\n  marginEnd: 0\n});\n\nconst treeIcon = style({\n  gridArea: 'icon',\n  marginEnd: 2\n});\n\nconst treeContent = style<Pick<TreeItemContentRenderProps, 'isDisabled'>>({\n  gridArea: 'content',\n  textOverflow: 'ellipsis',\n  whiteSpace: 'nowrap',\n  overflow: 'hidden'\n});\n\nconst treeActions = style({\n  gridArea: 'actions',\n  flexGrow: 0,\n  flexShrink: 0,\n  /* TODO: I made this one up, confirm desired behavior. These paddings are to make sure the action group has enough padding for the focus ring */\n  marginStart: 0.5,\n  marginEnd: 1\n});\n\nconst treeActionMenu = style({\n  gridArea: 'actionmenu',\n  width: 8\n});\n\nconst treeRowOutline = style({\n  content: '',\n  display: 'block',\n  position: 'absolute',\n  insetStart: 0,\n  insetEnd: 0,\n  top: {\n    default: 0,\n    isFocusVisible: '[-2px]',\n    isSelected: {\n      default: '[-1px]',\n      isFocusVisible: '[-2px]'\n    },\n    isFirst: 0\n  },\n  bottom: 0,\n  pointerEvents: 'none',\n  forcedColorAdjust: 'none',\n\n  boxShadow: {\n    isFocusVisible:\n      '[inset 2px 0 0 0 var(--spectrum-alias-focus-color), inset -2px 0 0 0 var(--spectrum-alias-focus-color), inset 0 -2px 0 0 var(--spectrum-alias-focus-color), inset 0 2px 0 0 var(--spectrum-alias-focus-color)]',\n    isSelected: {\n      default:\n        '[inset 1px 0 0 0 var(--spectrum-alias-focus-color), inset -1px 0 0 0 var(--spectrum-alias-focus-color), inset 0 -1px 0 0 var(--spectrum-alias-focus-color), inset 0 1px 0 0 var(--spectrum-alias-focus-color)]',\n      isFocusVisible:\n        '[inset 2px 0 0 0 var(--spectrum-alias-focus-color), inset -2px 0 0 0 var(--spectrum-alias-focus-color), inset 0 -2px 0 0 var(--spectrum-alias-focus-color), inset 0 2px 0 0 var(--spectrum-alias-focus-color)]'\n    },\n    forcedColors: {\n      isFocusVisible:\n        '[inset 2px 0 0 0 Highlight, inset -2px 0 0 0 Highlight, inset 0 -2px 0 0 Highlight, inset 0 2px 0 0 Highlight]',\n      isSelected: {\n        default:\n          '[inset 1px 0 0 0 Highlight, inset -1px 0 0 0 Highlight, inset 0 -1px 0 0 Highlight, inset 0 1px 0 0 Highlight]',\n        isFocusVisible:\n          '[inset 2px 0 0 0 Highlight, inset -2px 0 0 0 Highlight, inset 0 -2px 0 0 Highlight, inset 0 2px 0 0 Highlight]'\n      }\n    }\n  }\n});\n\nexport const TreeViewItem = (props: SpectrumTreeViewItemProps): ReactNode => {\n  let {href} = props;\n\n  return (\n    <TreeItem\n      {...props}\n      className={renderProps =>\n        treeRow({\n          ...renderProps,\n          isLink: !!href\n        })\n      }\n    />\n  );\n};\n\nexport interface SpectrumTreeViewItemContentProps extends Omit<TreeItemContentProps, 'children'> {\n  /** Rendered contents of the tree item or child items. */\n  children: ReactNode;\n}\n\nexport const TreeViewItemContent = (props: SpectrumTreeViewItemContentProps): ReactNode => {\n  let {children} = props;\n\n  return (\n    <TreeItemContent>\n      {({\n        isExpanded,\n        hasChildItems,\n        level,\n        selectionMode,\n        selectionBehavior,\n        isDisabled,\n        isSelected,\n        isFocusVisible,\n        state,\n        id\n      }) => {\n        let isFirst = state.collection.getFirstKey() === id;\n        return (\n          <div className={treeCellGrid({isDisabled})}>\n            {selectionMode !== 'none' && selectionBehavior === 'toggle' && (\n              // TODO: add transition?\n              <Checkbox\n                isEmphasized\n                UNSAFE_className={treeCheckbox()}\n                UNSAFE_style={{paddingInlineEnd: '0px'}}\n                slot=\"selection\"\n              />\n            )}\n            <div\n              style={{\n                gridArea: 'level-padding',\n                marginInlineEnd: `calc(${level - 1} * var(--spectrum-global-dimension-size-200))`\n              }}\n            />\n            {/* TODO: revisit when we do async loading, at the moment hasChildItems will only cause the chevron to be rendered, no aria/data attributes indicating the row's expandability are added */}\n            {hasChildItems && (\n              <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} />\n            )}\n            <SlotProvider\n              slots={{\n                text: {UNSAFE_className: treeContent({isDisabled})},\n                // Note there is also an issue here where these icon props are making into the action menu's icon. Resolved by 8ab0ffb276ff437a65b365c9a3be0323a1b24656\n                // but could crop up later for other components\n                icon: {UNSAFE_className: treeIcon(), size: 'S'},\n                actionButton: {UNSAFE_className: treeActions(), isQuiet: true},\n                actionGroup: {\n                  UNSAFE_className: treeActions(),\n                  isQuiet: true,\n                  density: 'compact',\n                  buttonLabelBehavior: 'hide',\n                  isDisabled,\n                  overflowMode: 'collapse'\n                },\n                actionMenu: {\n                  UNSAFE_className: treeActionMenu(),\n                  UNSAFE_style: {marginInlineEnd: '.5rem'},\n                  isQuiet: true\n                }\n              }}>\n              {children}\n            </SlotProvider>\n            <div className={treeRowOutline({isFocusVisible, isSelected, isFirst})} />\n          </div>\n        );\n      }}\n    </TreeItemContent>\n  );\n};\n\ninterface ExpandableRowChevronProps {\n  isExpanded?: boolean;\n  isDisabled?: boolean;\n  isRTL?: boolean;\n}\n\nconst expandButton = style<ExpandableRowChevronProps>({\n  gridArea: 'expand-button',\n  height: 'full',\n  aspectRatio: 'square',\n  display: 'flex',\n  flexWrap: 'wrap',\n  alignContent: 'center',\n  justifyContent: 'center',\n  outlineStyle: 'none',\n  transform: {\n    isExpanded: {\n      default: 'rotate(90deg)',\n      isRTL: 'rotate(-90deg)'\n    }\n  },\n  transition: '[transform ease var(--spectrum-global-animation-duration-100)]'\n});\n\nfunction ExpandableRowChevron(props: ExpandableRowChevronProps) {\n  let expandButtonRef = useRef(null);\n  let [fullProps, ref] = useContextProps(\n    {...props, slot: 'chevron'},\n    expandButtonRef,\n    ButtonContext\n  );\n  let {isExpanded, isDisabled} = fullProps;\n  let {direction} = useLocale();\n\n  // Will need to keep the chevron as a button for iOS VO at all times since VO doesn't focus the cell. Also keep as button if cellAction is defined by the user in the future\n  let {buttonProps} = useButton(\n    {\n      ...fullProps,\n      elementType: 'span'\n    },\n    ref\n  );\n\n  return (\n    <span\n      {...buttonProps}\n      ref={ref}\n      // Override tabindex so that grid keyboard nav skips over it. Needs -1 so android talkback can actually \"focus\" it\n      tabIndex={isAndroid() && !isDisabled ? -1 : undefined}\n      className={expandButton({isExpanded, isDisabled, isRTL: direction === 'rtl'})}>\n      {direction === 'ltr' ? <ChevronRightMedium /> : <ChevronLeftMedium />}\n    </span>\n  );\n}\n"],"names":[],"version":3,"file":"TreeView.cjs.map"}