@react-spectrum/tree 3.0.0-beta.1 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{TreeView.5c7cb24b.css → TreeView.1fe1dbfb.css} +80 -80
- package/dist/TreeView.1fe1dbfb.css.map +1 -0
- package/dist/TreeView.main.js +84 -84
- package/dist/TreeView.main.js.map +1 -1
- package/dist/TreeView.mjs +84 -84
- package/dist/TreeView.module.js +84 -84
- package/dist/TreeView.module.js.map +1 -1
- package/package.json +15 -15
- package/src/TreeView.tsx +1 -1
- package/dist/TreeView.5c7cb24b.css.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA0CD,MAAM,0DAAsB,CAAA,GAAA,0BAAY,EAA4B,CAAC;AAErE,SAAS;IACP,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB;AAEA,2DAA2D;AAE3D,4KAA4K;AAC5K,gHAAgH;AAChH,sIAAsI;AACtI,MAAM;;;;;;;;;;;;;;;;;AA0BN,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,IAAI,YAAC,QAAQ,kBAAE,cAAc,EAAC,GAAG;IAEjC,IAAI;IACJ,IAAI,OAAO,aAAa,YACtB,WAAW;IAGb,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,oBAAoB,mBAAmB,cAAc,YAAY;IAErE,qBACE,0DAAC,0CAAoB,QAAQ;QAAC,OAAO;sBAAC;QAAQ;qBAC5C,0DAAC,CAAA,GAAA,wCAAY;QAAG,GAAG,KAAK;QAAG,GAAG,UAAU;QAAE,WAAW,CAAC,WAAC,OAAO,EAAC,GAAK,2BAAK;yBAAC;YAAO;QAAI,mBAAmB;QAAwC,KAAK;OAClJ,MAA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qBACE,0DAAC;QACE,GAAG,WAAW;QACf,KAAK;QACL,kHAAkH;QAClH,UAAU,CAAA,GAAA,+BAAQ,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;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tree/src/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 {AriaTreeGridListProps} from '@react-aria/tree';\nimport {ButtonContext, Collection, TreeItemContentRenderProps, TreeItemProps, TreeItemRenderProps, TreeRenderProps, UNSTABLE_Tree, UNSTABLE_TreeItem, UNSTABLE_TreeItemContent, useContextProps} from 'react-aria-components';\nimport {Checkbox} from '@react-spectrum/checkbox';\nimport ChevronLeftMedium from '@spectrum-icons/ui/ChevronLeftMedium';\nimport ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium';\nimport {DOMRef, Expandable, Key, SelectionBehavior, SpectrumSelectionProps, StyleProps} from '@react-types/shared';\nimport {isAndroid} from '@react-aria/utils';\nimport React, {createContext, isValidElement, JSX, JSXElementConstructor, ReactElement, ReactNode, useContext, useRef} from 'react';\nimport {SlotProvider, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};\nimport {Text} from '@react-spectrum/text';\nimport {useButton} from '@react-aria/button';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface SpectrumTreeViewProps<T> extends Omit<AriaTreeGridListProps<T>, 'children'>, StyleProps, SpectrumSelectionProps, 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 on\n * 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<T extends object = object> extends Omit<TreeItemProps, 'className' | 'style' | 'value' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'> {\n /** Rendered contents of the tree item or child items. */\n children: ReactNode,\n /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean,\n /** A list of child tree item objects used when dynamically rendering the tree item children. */\n childItems?: Iterable<T>\n}\n\ninterface TreeRendererContextValue {\n renderer?: (item) => ReactElement<any, string | JSXElementConstructor<any>>\n}\nconst TreeRendererContext = createContext<TreeRendererContextValue>({});\n\nfunction useTreeRendererContext(): TreeRendererContextValue {\n return useContext(TreeRendererContext)!;\n}\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 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 width: {\n isEmpty: 'full'\n },\n height: {\n isEmpty: 'full'\n },\n display: {\n isEmpty: 'flex'\n }\n});\n\nfunction TreeView<T extends object>(props: SpectrumTreeViewProps<T>, ref: DOMRef<HTMLDivElement>) {\n let {children, selectionStyle} = 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 <UNSTABLE_Tree {...props} {...styleProps} className={({isEmpty}) => tree({isEmpty})} selectionBehavior={selectionBehavior as SelectionBehavior} ref={domRef}>\n {props.children}\n </UNSTABLE_Tree>\n </TreeRendererContext.Provider>\n );\n}\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: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 10, 'minmax(0, auto)', '1fr', 'minmax(0, auto)', 'auto'],\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: .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 },\n bottom: 0,\n pointerEvents: 'none',\n forcedColorAdjust: 'none',\n\n boxShadow: {\n isFocusVisible: '[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: '[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: '[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: '[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: '[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: '[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 = <T extends object>(props: SpectrumTreeViewItemProps<T>) => {\n let {\n children,\n childItems,\n hasChildItems,\n href\n } = props;\n\n let content;\n let nestedRows;\n let {renderer} = useTreeRendererContext();\n // TODO alternative api is that we have a separate prop for the TreeItems contents and expect the child to then be\n // a nested tree item\n\n if (typeof children === 'string') {\n content = <Text>{children}</Text>;\n } else {\n content = [];\n nestedRows = [];\n React.Children.forEach(children, node => {\n if (isValidElement(node) && node.type === TreeViewItem) {\n nestedRows.push(node);\n } else {\n content.push(node);\n }\n });\n }\n\n if (childItems != null && renderer) {\n nestedRows = (\n <Collection items={childItems}>\n {renderer}\n </Collection>\n );\n }\n\n return (\n // TODO right now all the tree rows have the various data attributes applied on their dom nodes, should they? Doesn't feel very useful\n <UNSTABLE_TreeItem\n {...props}\n className={renderProps => treeRow({\n ...renderProps,\n isLink: !!href\n })}>\n <UNSTABLE_TreeItemContent>\n {({isExpanded, hasChildRows, level, selectionMode, selectionBehavior, isDisabled, isSelected, isFocusVisible}) => (\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 <div style={{gridArea: 'level-padding', marginInlineEnd: `calc(${level - 1} * var(--spectrum-global-dimension-size-200))`}} />\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 {(hasChildRows || hasChildItems) && <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} />}\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: {UNSAFE_className: treeActionMenu(), UNSAFE_style: {marginInlineEnd: '.5rem'}, isQuiet: true}\n }}>\n {content}\n </SlotProvider>\n <div className={treeRowOutline({isFocusVisible, isSelected})} />\n </div>\n )}\n </UNSTABLE_TreeItemContent>\n {nestedRows}\n </UNSTABLE_TreeItem>\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<HTMLSpanElement>(null);\n let [fullProps, ref] = useContextProps({...props, slot: 'chevron'}, expandButtonRef, ButtonContext);\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 ...fullProps,\n elementType: 'span'\n }, ref);\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\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nconst _TreeView = React.forwardRef(TreeView) as <T>(props: SpectrumTreeViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_TreeView as TreeView};\n"],"names":[],"version":3,"file":"TreeView.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA0CD,MAAM,0DAAsB,CAAA,GAAA,0BAAY,EAA4B,CAAC;AAErE,SAAS;IACP,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB;AAEA,2DAA2D;AAE3D,4KAA4K;AAC5K,gHAAgH;AAChH,sIAAsI;AACtI,MAAM;;;;;;;;;;;;;;;;;AA0BN,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,IAAI,YAAC,QAAQ,kBAAE,cAAc,EAAC,GAAG;IAEjC,IAAI;IACJ,IAAI,OAAO,aAAa,YACtB,WAAW;IAGb,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,oBAAoB,mBAAmB,cAAc,YAAY;IAErE,qBACE,0DAAC,0CAAoB,QAAQ;QAAC,OAAO;sBAAC;QAAQ;qBAC5C,0DAAC,CAAA,GAAA,wCAAY;QAAG,GAAG,KAAK;QAAG,GAAG,UAAU;QAAE,WAAW,CAAC,WAAC,OAAO,EAAC,GAAK,2BAAK;yBAAC;YAAO;QAAI,mBAAmB;QAAwC,KAAK;OAClJ,MAAM,QAAQ;AAIvB;AAMA,MAAM;;;;;;;;;;;;;;;;;;;;AAwBN,MAAM;;;;;;;;;;;;;;AAiBN,gHAAgH;AAChH,MAAM;;;;;;;;AAON,MAAM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Aa;wBAAC;wBAAY;YAAY,OAAO,cAAc;QAAK;OAC1E,cAAc,sBAAQ,0DAAC,CAAA,GAAA,kEAAiB,yBAAO,0DAAC,CAAA,GAAA,iEAAgB;AAGvE;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tree/src/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 {AriaTreeGridListProps} from '@react-aria/tree';\nimport {ButtonContext, Collection, TreeItemContentRenderProps, TreeItemProps, TreeItemRenderProps, TreeRenderProps, UNSTABLE_Tree, UNSTABLE_TreeItem, UNSTABLE_TreeItemContent, useContextProps} from 'react-aria-components';\nimport {Checkbox} from '@react-spectrum/checkbox';\nimport ChevronLeftMedium from '@spectrum-icons/ui/ChevronLeftMedium';\nimport ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium';\nimport {DOMRef, Expandable, Key, SelectionBehavior, SpectrumSelectionProps, StyleProps} from '@react-types/shared';\nimport {isAndroid} from '@react-aria/utils';\nimport React, {createContext, isValidElement, JSX, JSXElementConstructor, ReactElement, ReactNode, useContext, useRef} from 'react';\nimport {SlotProvider, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};\nimport {Text} from '@react-spectrum/text';\nimport {useButton} from '@react-aria/button';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface SpectrumTreeViewProps<T> extends Omit<AriaTreeGridListProps<T>, 'children'>, StyleProps, SpectrumSelectionProps, 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 on\n * 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<T extends object = object> extends Omit<TreeItemProps, 'className' | 'style' | 'value' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'> {\n /** Rendered contents of the tree item or child items. */\n children: ReactNode,\n /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean,\n /** A list of child tree item objects used when dynamically rendering the tree item children. */\n childItems?: Iterable<T>\n}\n\ninterface TreeRendererContextValue {\n renderer?: (item) => ReactElement<any, string | JSXElementConstructor<any>>\n}\nconst TreeRendererContext = createContext<TreeRendererContextValue>({});\n\nfunction useTreeRendererContext(): TreeRendererContextValue {\n return useContext(TreeRendererContext)!;\n}\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 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 width: {\n isEmpty: 'full'\n },\n height: {\n isEmpty: 'full'\n },\n display: {\n isEmpty: 'flex'\n }\n});\n\nfunction TreeView<T extends object>(props: SpectrumTreeViewProps<T>, ref: DOMRef<HTMLDivElement>) {\n let {children, selectionStyle} = 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 <UNSTABLE_Tree {...props} {...styleProps} className={({isEmpty}) => tree({isEmpty})} selectionBehavior={selectionBehavior as SelectionBehavior} ref={domRef}>\n {props.children}\n </UNSTABLE_Tree>\n </TreeRendererContext.Provider>\n );\n}\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: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 10, 'minmax(0, auto)', '1fr', 'minmax(0, auto)', 'auto'],\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: .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 },\n bottom: 0,\n pointerEvents: 'none',\n forcedColorAdjust: 'none',\n\n boxShadow: {\n isFocusVisible: '[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: '[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: '[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: '[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: '[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: '[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 = <T extends object>(props: SpectrumTreeViewItemProps<T>) => {\n let {\n children,\n childItems,\n hasChildItems,\n href\n } = props;\n\n let content;\n let nestedRows;\n let {renderer} = useTreeRendererContext();\n // TODO alternative api is that we have a separate prop for the TreeItems contents and expect the child to then be\n // a nested tree item\n\n if (typeof children === 'string') {\n content = <Text>{children}</Text>;\n } else {\n content = [];\n nestedRows = [];\n React.Children.forEach(children, node => {\n if (isValidElement(node) && node.type === TreeViewItem) {\n nestedRows.push(node);\n } else {\n content.push(node);\n }\n });\n }\n\n if (childItems != null && renderer) {\n nestedRows = (\n <Collection items={childItems}>\n {renderer}\n </Collection>\n );\n }\n\n return (\n // TODO right now all the tree rows have the various data attributes applied on their dom nodes, should they? Doesn't feel very useful\n <UNSTABLE_TreeItem\n {...props}\n className={renderProps => treeRow({\n ...renderProps,\n isLink: !!href\n })}>\n <UNSTABLE_TreeItemContent>\n {({isExpanded, hasChildRows, level, selectionMode, selectionBehavior, isDisabled, isSelected, isFocusVisible}) => (\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 <div style={{gridArea: 'level-padding', marginInlineEnd: `calc(${level - 1} * var(--spectrum-global-dimension-size-200))`}} />\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 {(hasChildRows || hasChildItems) && <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} />}\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: {UNSAFE_className: treeActionMenu(), UNSAFE_style: {marginInlineEnd: '.5rem'}, isQuiet: true}\n }}>\n {content}\n </SlotProvider>\n <div className={treeRowOutline({isFocusVisible, isSelected})} />\n </div>\n )}\n </UNSTABLE_TreeItemContent>\n {nestedRows}\n </UNSTABLE_TreeItem>\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({...props, slot: 'chevron'}, expandButtonRef, ButtonContext);\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 ...fullProps,\n elementType: 'span'\n }, ref);\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\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nconst _TreeView = React.forwardRef(TreeView) as <T>(props: SpectrumTreeViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_TreeView as TreeView};\n"],"names":[],"version":3,"file":"TreeView.main.js.map"}
|
package/dist/TreeView.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./TreeView.
|
|
1
|
+
import "./TreeView.1fe1dbfb.css";
|
|
2
2
|
import {UNSTABLE_Tree as $FHprs$UNSTABLE_Tree, Collection as $FHprs$Collection, UNSTABLE_TreeItem as $FHprs$UNSTABLE_TreeItem, UNSTABLE_TreeItemContent as $FHprs$UNSTABLE_TreeItemContent, useContextProps as $FHprs$useContextProps, ButtonContext as $FHprs$ButtonContext} from "react-aria-components";
|
|
3
3
|
import {Checkbox as $FHprs$Checkbox} from "@react-spectrum/checkbox";
|
|
4
4
|
import $FHprs$spectrumiconsuiChevronLeftMedium from "@spectrum-icons/ui/ChevronLeftMedium";
|
|
@@ -40,19 +40,19 @@ function $48b8113347121625$var$useTreeRendererContext() {
|
|
|
40
40
|
// scroll into view due to how the ring is offset. Alternatively, have the tree render the top/bottom outline like it does in Listview
|
|
41
41
|
const $48b8113347121625$var$tree = function anonymous(props) {
|
|
42
42
|
let rules = "";
|
|
43
|
-
rules += '
|
|
44
|
-
rules += '
|
|
45
|
-
rules += '
|
|
46
|
-
rules += '
|
|
47
|
-
rules += '
|
|
48
|
-
rules += '
|
|
49
|
-
rules += '
|
|
50
|
-
rules += '
|
|
51
|
-
if (props.isEmpty) rules += '
|
|
52
|
-
if (props.isEmpty) rules += '
|
|
53
|
-
if (props.isEmpty) rules += '
|
|
54
|
-
if (props.isEmpty) rules += '
|
|
55
|
-
if (props.isEmpty) rules += '
|
|
43
|
+
rules += ' s1-ws1-c';
|
|
44
|
+
rules += ' s1-xs1-c';
|
|
45
|
+
rules += ' s1-us1-a';
|
|
46
|
+
rules += ' s1-vs1-a';
|
|
47
|
+
rules += ' s1-__ks1-a';
|
|
48
|
+
rules += ' s1-As1-a';
|
|
49
|
+
rules += ' s1-cs1-as1-___y';
|
|
50
|
+
rules += ' s1-cs1-a';
|
|
51
|
+
if (props.isEmpty) rules += ' s1-_Vs1-d';
|
|
52
|
+
if (props.isEmpty) rules += ' s1-_Us1-c';
|
|
53
|
+
if (props.isEmpty) rules += ' s1-os1-Y';
|
|
54
|
+
if (props.isEmpty) rules += ' s1-ns1-Y';
|
|
55
|
+
if (props.isEmpty) rules += ' s1-_Ss1-d';
|
|
56
56
|
return rules;
|
|
57
57
|
};
|
|
58
58
|
function $48b8113347121625$var$TreeView(props, ref) {
|
|
@@ -78,99 +78,99 @@ function $48b8113347121625$var$TreeView(props, ref) {
|
|
|
78
78
|
}
|
|
79
79
|
const $48b8113347121625$var$treeRow = function anonymous(props) {
|
|
80
80
|
let rules = "";
|
|
81
|
-
rules += '
|
|
82
|
-
rules += '
|
|
83
|
-
rules += '
|
|
84
|
-
rules += '
|
|
85
|
-
rules += '
|
|
86
|
-
rules += '
|
|
87
|
-
rules += '
|
|
88
|
-
rules += '
|
|
89
|
-
rules += '
|
|
90
|
-
rules += '
|
|
91
|
-
if (props.isLink) rules += '
|
|
92
|
-
else rules += '
|
|
93
|
-
if (props.isSelected) rules += ' b-7vr0l1';
|
|
94
|
-
else if (props.isPressed) rules += ' b-1t6gvb8';
|
|
95
|
-
else if (props.isFocusVisibleWithin) rules += ' b-ml9cvk';
|
|
96
|
-
else if (props.isHovered) rules += ' b-ml9cvk';
|
|
81
|
+
rules += ' s1-Xs1-c';
|
|
82
|
+
rules += ' s1-_Ss1-d';
|
|
83
|
+
rules += ' s1-ns1-k';
|
|
84
|
+
rules += ' s1-os1-Y';
|
|
85
|
+
rules += ' s1-__ks1-a';
|
|
86
|
+
rules += ' s1-6s1-c';
|
|
87
|
+
rules += ' s1-7s1-d';
|
|
88
|
+
rules += ' s1-9s1-b';
|
|
89
|
+
rules += ' s1-as1-___K';
|
|
90
|
+
rules += ' s1-_Es1-a';
|
|
91
|
+
if (props.isLink) rules += ' s1-__Es1-c';
|
|
92
|
+
else rules += ' s1-__Es1-b';
|
|
93
|
+
if (props.isSelected) rules += ' s1-b-7vr0l1';
|
|
94
|
+
else if (props.isPressed) rules += ' s1-b-1t6gvb8';
|
|
95
|
+
else if (props.isFocusVisibleWithin) rules += ' s1-b-ml9cvk';
|
|
96
|
+
else if (props.isHovered) rules += ' s1-b-ml9cvk';
|
|
97
97
|
return rules;
|
|
98
98
|
};
|
|
99
99
|
const $48b8113347121625$var$treeCellGrid = function anonymous(props) {
|
|
100
100
|
let rules = "";
|
|
101
|
-
rules += '
|
|
102
|
-
rules += '
|
|
103
|
-
rules += '
|
|
104
|
-
rules += ' __d-1nxidkl-1nxidkl-1nxidkl-3hmti-1nxidkl-375yi6-1nxidkl-ykdwf2';
|
|
105
|
-
rules += ' __e-375yi6';
|
|
106
|
-
rules += ' __f-1qk85yo';
|
|
101
|
+
rules += ' s1-_Ss1-f';
|
|
102
|
+
rules += ' s1-os1-Y';
|
|
103
|
+
rules += ' s1-_Us1-c';
|
|
104
|
+
rules += ' s1-__d-1nxidkl-1nxidkl-1nxidkl-3hmti-1nxidkl-375yi6-1nxidkl-ykdwf2';
|
|
105
|
+
rules += ' s1-__e-375yi6';
|
|
106
|
+
rules += ' s1-__f-1qk85yo';
|
|
107
107
|
if (props.isDisabled) {
|
|
108
|
-
rules += '
|
|
109
|
-
rules += '
|
|
108
|
+
rules += ' s1-as1-as1-___F';
|
|
109
|
+
rules += ' s1-as1-i';
|
|
110
110
|
}
|
|
111
111
|
return rules;
|
|
112
112
|
};
|
|
113
113
|
// TODO: These styles lose against the spectrum class names, so I've did unsafe for the ones that get overridden
|
|
114
114
|
const $48b8113347121625$var$treeCheckbox = function anonymous(props) {
|
|
115
115
|
let rules = "";
|
|
116
|
-
rules += ' __g-4wahvw';
|
|
117
|
-
rules += ' _J-37nn5o';
|
|
118
|
-
rules += '
|
|
119
|
-
rules += '
|
|
116
|
+
rules += ' s1-__g-4wahvw';
|
|
117
|
+
rules += ' s1-_J-37nn5o';
|
|
118
|
+
rules += ' s1-Cs1-d';
|
|
119
|
+
rules += ' s1-Ds1-a';
|
|
120
120
|
return rules;
|
|
121
121
|
};
|
|
122
122
|
const $48b8113347121625$var$treeIcon = function anonymous(props) {
|
|
123
123
|
let rules = "";
|
|
124
|
-
rules += ' __g-ykjmzy';
|
|
125
|
-
rules += '
|
|
124
|
+
rules += ' s1-__g-ykjmzy';
|
|
125
|
+
rules += ' s1-Ds1-c';
|
|
126
126
|
return rules;
|
|
127
127
|
};
|
|
128
128
|
const $48b8113347121625$var$treeContent = function anonymous(props) {
|
|
129
129
|
let rules = "";
|
|
130
|
-
rules += ' __g-1mod4sg';
|
|
131
|
-
rules += '
|
|
132
|
-
rules += '
|
|
133
|
-
rules += '
|
|
134
|
-
rules += '
|
|
130
|
+
rules += ' s1-__g-1mod4sg';
|
|
131
|
+
rules += ' s1-_gs1-a';
|
|
132
|
+
rules += ' s1-_ks1-b';
|
|
133
|
+
rules += ' s1-__ss1-b';
|
|
134
|
+
rules += ' s1-__ts1-b';
|
|
135
135
|
return rules;
|
|
136
136
|
};
|
|
137
137
|
const $48b8113347121625$var$treeActions = function anonymous(props) {
|
|
138
138
|
let rules = "";
|
|
139
|
-
rules += ' __g-8ayfo6';
|
|
140
|
-
rules += ' _3-3t1x';
|
|
141
|
-
rules += ' _2-3t1x';
|
|
142
|
-
rules += '
|
|
143
|
-
rules += '
|
|
139
|
+
rules += ' s1-__g-8ayfo6';
|
|
140
|
+
rules += ' s1-_3-3t1x';
|
|
141
|
+
rules += ' s1-_2-3t1x';
|
|
142
|
+
rules += ' s1-Cs1-F';
|
|
143
|
+
rules += ' s1-Ds1-b';
|
|
144
144
|
return rules;
|
|
145
145
|
};
|
|
146
146
|
const $48b8113347121625$var$treeActionMenu = function anonymous(props) {
|
|
147
147
|
let rules = "";
|
|
148
|
-
rules += ' __g-wit6hk';
|
|
149
|
-
rules += '
|
|
148
|
+
rules += ' s1-__g-wit6hk';
|
|
149
|
+
rules += ' s1-os1-i';
|
|
150
150
|
return rules;
|
|
151
151
|
};
|
|
152
152
|
const $48b8113347121625$var$treeRowOutline = function anonymous(props) {
|
|
153
153
|
let rules = "";
|
|
154
|
-
rules += '
|
|
155
|
-
rules += '
|
|
156
|
-
rules += '
|
|
157
|
-
rules += '
|
|
154
|
+
rules += ' s1-_Ss1-a';
|
|
155
|
+
rules += ' s1-Xs1-a';
|
|
156
|
+
rules += ' s1-Ys1-a';
|
|
157
|
+
rules += ' s1-Zs1-a';
|
|
158
158
|
if (props.isSelected) {
|
|
159
|
-
if (props.isFocusVisible) rules += '
|
|
160
|
-
else rules += '
|
|
161
|
-
} else if (props.isFocusVisible) rules += '
|
|
162
|
-
else rules += '
|
|
163
|
-
rules += '
|
|
164
|
-
rules += '
|
|
165
|
-
rules += '
|
|
159
|
+
if (props.isFocusVisible) rules += ' s1-0-yj8a3w';
|
|
160
|
+
else rules += ' s1-0-yj899n';
|
|
161
|
+
} else if (props.isFocusVisible) rules += ' s1-0-yj8a3w';
|
|
162
|
+
else rules += ' s1-0s1-a';
|
|
163
|
+
rules += ' s1-2s1-a';
|
|
164
|
+
rules += ' s1-__ys1-a';
|
|
165
|
+
rules += ' s1-_ts1-b';
|
|
166
166
|
if (props.isSelected) {
|
|
167
|
-
if (props.isFocusVisible) rules += '
|
|
168
|
-
else rules += '
|
|
169
|
-
} else if (props.isFocusVisible) rules += '
|
|
167
|
+
if (props.isFocusVisible) rules += ' s1-_os1-a-4bhpmf';
|
|
168
|
+
else rules += ' s1-_os1-a-zlnqab';
|
|
169
|
+
} else if (props.isFocusVisible) rules += ' s1-_os1-a-4bhpmf';
|
|
170
170
|
if (props.isSelected) {
|
|
171
|
-
if (props.isFocusVisible) rules += ' _o-ba5uxf';
|
|
172
|
-
else rules += ' _o-1ytnijz';
|
|
173
|
-
} else if (props.isFocusVisible) rules += ' _o-ba5uxf';
|
|
171
|
+
if (props.isFocusVisible) rules += ' s1-_o-ba5uxf';
|
|
172
|
+
else rules += ' s1-_o-1ytnijz';
|
|
173
|
+
} else if (props.isFocusVisible) rules += ' s1-_o-ba5uxf';
|
|
174
174
|
return rules;
|
|
175
175
|
};
|
|
176
176
|
const $48b8113347121625$export$6e77ea6719814e9c = (props)=>{
|
|
@@ -261,19 +261,19 @@ const $48b8113347121625$export$6e77ea6719814e9c = (props)=>{
|
|
|
261
261
|
};
|
|
262
262
|
const $48b8113347121625$var$expandButton = function anonymous(props) {
|
|
263
263
|
let rules = "";
|
|
264
|
-
rules += ' __g-pn4rxq';
|
|
265
|
-
rules += '
|
|
266
|
-
rules += '
|
|
267
|
-
rules += '
|
|
268
|
-
rules += '
|
|
269
|
-
rules += '
|
|
270
|
-
rules += '
|
|
271
|
-
rules += '
|
|
264
|
+
rules += ' s1-__g-pn4rxq';
|
|
265
|
+
rules += ' s1-ns1-Y';
|
|
266
|
+
rules += ' s1-4s1-b';
|
|
267
|
+
rules += ' s1-_Ss1-d';
|
|
268
|
+
rules += ' s1-_0s1-a';
|
|
269
|
+
rules += ' s1-_Ts1-b';
|
|
270
|
+
rules += ' s1-_Vs1-d';
|
|
271
|
+
rules += ' s1-_Es1-a';
|
|
272
272
|
if (props.isExpanded) {
|
|
273
|
-
if (props.isRTL) rules += ' W-negfvv';
|
|
274
|
-
else rules += ' W-10b8jr2';
|
|
273
|
+
if (props.isRTL) rules += ' s1-W-negfvv';
|
|
274
|
+
else rules += ' s1-W-10b8jr2';
|
|
275
275
|
}
|
|
276
|
-
rules += ' _H-1o2fh9e';
|
|
276
|
+
rules += ' s1-_H-1o2fh9e';
|
|
277
277
|
return rules;
|
|
278
278
|
};
|
|
279
279
|
function $48b8113347121625$var$ExpandableRowChevron(props) {
|
package/dist/TreeView.module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./TreeView.
|
|
1
|
+
import "./TreeView.1fe1dbfb.css";
|
|
2
2
|
import {UNSTABLE_Tree as $FHprs$UNSTABLE_Tree, Collection as $FHprs$Collection, UNSTABLE_TreeItem as $FHprs$UNSTABLE_TreeItem, UNSTABLE_TreeItemContent as $FHprs$UNSTABLE_TreeItemContent, useContextProps as $FHprs$useContextProps, ButtonContext as $FHprs$ButtonContext} from "react-aria-components";
|
|
3
3
|
import {Checkbox as $FHprs$Checkbox} from "@react-spectrum/checkbox";
|
|
4
4
|
import $FHprs$spectrumiconsuiChevronLeftMedium from "@spectrum-icons/ui/ChevronLeftMedium";
|
|
@@ -40,19 +40,19 @@ function $48b8113347121625$var$useTreeRendererContext() {
|
|
|
40
40
|
// scroll into view due to how the ring is offset. Alternatively, have the tree render the top/bottom outline like it does in Listview
|
|
41
41
|
const $48b8113347121625$var$tree = function anonymous(props) {
|
|
42
42
|
let rules = "";
|
|
43
|
-
rules += '
|
|
44
|
-
rules += '
|
|
45
|
-
rules += '
|
|
46
|
-
rules += '
|
|
47
|
-
rules += '
|
|
48
|
-
rules += '
|
|
49
|
-
rules += '
|
|
50
|
-
rules += '
|
|
51
|
-
if (props.isEmpty) rules += '
|
|
52
|
-
if (props.isEmpty) rules += '
|
|
53
|
-
if (props.isEmpty) rules += '
|
|
54
|
-
if (props.isEmpty) rules += '
|
|
55
|
-
if (props.isEmpty) rules += '
|
|
43
|
+
rules += ' s1-ws1-c';
|
|
44
|
+
rules += ' s1-xs1-c';
|
|
45
|
+
rules += ' s1-us1-a';
|
|
46
|
+
rules += ' s1-vs1-a';
|
|
47
|
+
rules += ' s1-__ks1-a';
|
|
48
|
+
rules += ' s1-As1-a';
|
|
49
|
+
rules += ' s1-cs1-as1-___y';
|
|
50
|
+
rules += ' s1-cs1-a';
|
|
51
|
+
if (props.isEmpty) rules += ' s1-_Vs1-d';
|
|
52
|
+
if (props.isEmpty) rules += ' s1-_Us1-c';
|
|
53
|
+
if (props.isEmpty) rules += ' s1-os1-Y';
|
|
54
|
+
if (props.isEmpty) rules += ' s1-ns1-Y';
|
|
55
|
+
if (props.isEmpty) rules += ' s1-_Ss1-d';
|
|
56
56
|
return rules;
|
|
57
57
|
};
|
|
58
58
|
function $48b8113347121625$var$TreeView(props, ref) {
|
|
@@ -78,99 +78,99 @@ function $48b8113347121625$var$TreeView(props, ref) {
|
|
|
78
78
|
}
|
|
79
79
|
const $48b8113347121625$var$treeRow = function anonymous(props) {
|
|
80
80
|
let rules = "";
|
|
81
|
-
rules += '
|
|
82
|
-
rules += '
|
|
83
|
-
rules += '
|
|
84
|
-
rules += '
|
|
85
|
-
rules += '
|
|
86
|
-
rules += '
|
|
87
|
-
rules += '
|
|
88
|
-
rules += '
|
|
89
|
-
rules += '
|
|
90
|
-
rules += '
|
|
91
|
-
if (props.isLink) rules += '
|
|
92
|
-
else rules += '
|
|
93
|
-
if (props.isSelected) rules += ' b-7vr0l1';
|
|
94
|
-
else if (props.isPressed) rules += ' b-1t6gvb8';
|
|
95
|
-
else if (props.isFocusVisibleWithin) rules += ' b-ml9cvk';
|
|
96
|
-
else if (props.isHovered) rules += ' b-ml9cvk';
|
|
81
|
+
rules += ' s1-Xs1-c';
|
|
82
|
+
rules += ' s1-_Ss1-d';
|
|
83
|
+
rules += ' s1-ns1-k';
|
|
84
|
+
rules += ' s1-os1-Y';
|
|
85
|
+
rules += ' s1-__ks1-a';
|
|
86
|
+
rules += ' s1-6s1-c';
|
|
87
|
+
rules += ' s1-7s1-d';
|
|
88
|
+
rules += ' s1-9s1-b';
|
|
89
|
+
rules += ' s1-as1-___K';
|
|
90
|
+
rules += ' s1-_Es1-a';
|
|
91
|
+
if (props.isLink) rules += ' s1-__Es1-c';
|
|
92
|
+
else rules += ' s1-__Es1-b';
|
|
93
|
+
if (props.isSelected) rules += ' s1-b-7vr0l1';
|
|
94
|
+
else if (props.isPressed) rules += ' s1-b-1t6gvb8';
|
|
95
|
+
else if (props.isFocusVisibleWithin) rules += ' s1-b-ml9cvk';
|
|
96
|
+
else if (props.isHovered) rules += ' s1-b-ml9cvk';
|
|
97
97
|
return rules;
|
|
98
98
|
};
|
|
99
99
|
const $48b8113347121625$var$treeCellGrid = function anonymous(props) {
|
|
100
100
|
let rules = "";
|
|
101
|
-
rules += '
|
|
102
|
-
rules += '
|
|
103
|
-
rules += '
|
|
104
|
-
rules += ' __d-1nxidkl-1nxidkl-1nxidkl-3hmti-1nxidkl-375yi6-1nxidkl-ykdwf2';
|
|
105
|
-
rules += ' __e-375yi6';
|
|
106
|
-
rules += ' __f-1qk85yo';
|
|
101
|
+
rules += ' s1-_Ss1-f';
|
|
102
|
+
rules += ' s1-os1-Y';
|
|
103
|
+
rules += ' s1-_Us1-c';
|
|
104
|
+
rules += ' s1-__d-1nxidkl-1nxidkl-1nxidkl-3hmti-1nxidkl-375yi6-1nxidkl-ykdwf2';
|
|
105
|
+
rules += ' s1-__e-375yi6';
|
|
106
|
+
rules += ' s1-__f-1qk85yo';
|
|
107
107
|
if (props.isDisabled) {
|
|
108
|
-
rules += '
|
|
109
|
-
rules += '
|
|
108
|
+
rules += ' s1-as1-as1-___F';
|
|
109
|
+
rules += ' s1-as1-i';
|
|
110
110
|
}
|
|
111
111
|
return rules;
|
|
112
112
|
};
|
|
113
113
|
// TODO: These styles lose against the spectrum class names, so I've did unsafe for the ones that get overridden
|
|
114
114
|
const $48b8113347121625$var$treeCheckbox = function anonymous(props) {
|
|
115
115
|
let rules = "";
|
|
116
|
-
rules += ' __g-4wahvw';
|
|
117
|
-
rules += ' _J-37nn5o';
|
|
118
|
-
rules += '
|
|
119
|
-
rules += '
|
|
116
|
+
rules += ' s1-__g-4wahvw';
|
|
117
|
+
rules += ' s1-_J-37nn5o';
|
|
118
|
+
rules += ' s1-Cs1-d';
|
|
119
|
+
rules += ' s1-Ds1-a';
|
|
120
120
|
return rules;
|
|
121
121
|
};
|
|
122
122
|
const $48b8113347121625$var$treeIcon = function anonymous(props) {
|
|
123
123
|
let rules = "";
|
|
124
|
-
rules += ' __g-ykjmzy';
|
|
125
|
-
rules += '
|
|
124
|
+
rules += ' s1-__g-ykjmzy';
|
|
125
|
+
rules += ' s1-Ds1-c';
|
|
126
126
|
return rules;
|
|
127
127
|
};
|
|
128
128
|
const $48b8113347121625$var$treeContent = function anonymous(props) {
|
|
129
129
|
let rules = "";
|
|
130
|
-
rules += ' __g-1mod4sg';
|
|
131
|
-
rules += '
|
|
132
|
-
rules += '
|
|
133
|
-
rules += '
|
|
134
|
-
rules += '
|
|
130
|
+
rules += ' s1-__g-1mod4sg';
|
|
131
|
+
rules += ' s1-_gs1-a';
|
|
132
|
+
rules += ' s1-_ks1-b';
|
|
133
|
+
rules += ' s1-__ss1-b';
|
|
134
|
+
rules += ' s1-__ts1-b';
|
|
135
135
|
return rules;
|
|
136
136
|
};
|
|
137
137
|
const $48b8113347121625$var$treeActions = function anonymous(props) {
|
|
138
138
|
let rules = "";
|
|
139
|
-
rules += ' __g-8ayfo6';
|
|
140
|
-
rules += ' _3-3t1x';
|
|
141
|
-
rules += ' _2-3t1x';
|
|
142
|
-
rules += '
|
|
143
|
-
rules += '
|
|
139
|
+
rules += ' s1-__g-8ayfo6';
|
|
140
|
+
rules += ' s1-_3-3t1x';
|
|
141
|
+
rules += ' s1-_2-3t1x';
|
|
142
|
+
rules += ' s1-Cs1-F';
|
|
143
|
+
rules += ' s1-Ds1-b';
|
|
144
144
|
return rules;
|
|
145
145
|
};
|
|
146
146
|
const $48b8113347121625$var$treeActionMenu = function anonymous(props) {
|
|
147
147
|
let rules = "";
|
|
148
|
-
rules += ' __g-wit6hk';
|
|
149
|
-
rules += '
|
|
148
|
+
rules += ' s1-__g-wit6hk';
|
|
149
|
+
rules += ' s1-os1-i';
|
|
150
150
|
return rules;
|
|
151
151
|
};
|
|
152
152
|
const $48b8113347121625$var$treeRowOutline = function anonymous(props) {
|
|
153
153
|
let rules = "";
|
|
154
|
-
rules += '
|
|
155
|
-
rules += '
|
|
156
|
-
rules += '
|
|
157
|
-
rules += '
|
|
154
|
+
rules += ' s1-_Ss1-a';
|
|
155
|
+
rules += ' s1-Xs1-a';
|
|
156
|
+
rules += ' s1-Ys1-a';
|
|
157
|
+
rules += ' s1-Zs1-a';
|
|
158
158
|
if (props.isSelected) {
|
|
159
|
-
if (props.isFocusVisible) rules += '
|
|
160
|
-
else rules += '
|
|
161
|
-
} else if (props.isFocusVisible) rules += '
|
|
162
|
-
else rules += '
|
|
163
|
-
rules += '
|
|
164
|
-
rules += '
|
|
165
|
-
rules += '
|
|
159
|
+
if (props.isFocusVisible) rules += ' s1-0-yj8a3w';
|
|
160
|
+
else rules += ' s1-0-yj899n';
|
|
161
|
+
} else if (props.isFocusVisible) rules += ' s1-0-yj8a3w';
|
|
162
|
+
else rules += ' s1-0s1-a';
|
|
163
|
+
rules += ' s1-2s1-a';
|
|
164
|
+
rules += ' s1-__ys1-a';
|
|
165
|
+
rules += ' s1-_ts1-b';
|
|
166
166
|
if (props.isSelected) {
|
|
167
|
-
if (props.isFocusVisible) rules += '
|
|
168
|
-
else rules += '
|
|
169
|
-
} else if (props.isFocusVisible) rules += '
|
|
167
|
+
if (props.isFocusVisible) rules += ' s1-_os1-a-4bhpmf';
|
|
168
|
+
else rules += ' s1-_os1-a-zlnqab';
|
|
169
|
+
} else if (props.isFocusVisible) rules += ' s1-_os1-a-4bhpmf';
|
|
170
170
|
if (props.isSelected) {
|
|
171
|
-
if (props.isFocusVisible) rules += ' _o-ba5uxf';
|
|
172
|
-
else rules += ' _o-1ytnijz';
|
|
173
|
-
} else if (props.isFocusVisible) rules += ' _o-ba5uxf';
|
|
171
|
+
if (props.isFocusVisible) rules += ' s1-_o-ba5uxf';
|
|
172
|
+
else rules += ' s1-_o-1ytnijz';
|
|
173
|
+
} else if (props.isFocusVisible) rules += ' s1-_o-ba5uxf';
|
|
174
174
|
return rules;
|
|
175
175
|
};
|
|
176
176
|
const $48b8113347121625$export$6e77ea6719814e9c = (props)=>{
|
|
@@ -261,19 +261,19 @@ const $48b8113347121625$export$6e77ea6719814e9c = (props)=>{
|
|
|
261
261
|
};
|
|
262
262
|
const $48b8113347121625$var$expandButton = function anonymous(props) {
|
|
263
263
|
let rules = "";
|
|
264
|
-
rules += ' __g-pn4rxq';
|
|
265
|
-
rules += '
|
|
266
|
-
rules += '
|
|
267
|
-
rules += '
|
|
268
|
-
rules += '
|
|
269
|
-
rules += '
|
|
270
|
-
rules += '
|
|
271
|
-
rules += '
|
|
264
|
+
rules += ' s1-__g-pn4rxq';
|
|
265
|
+
rules += ' s1-ns1-Y';
|
|
266
|
+
rules += ' s1-4s1-b';
|
|
267
|
+
rules += ' s1-_Ss1-d';
|
|
268
|
+
rules += ' s1-_0s1-a';
|
|
269
|
+
rules += ' s1-_Ts1-b';
|
|
270
|
+
rules += ' s1-_Vs1-d';
|
|
271
|
+
rules += ' s1-_Es1-a';
|
|
272
272
|
if (props.isExpanded) {
|
|
273
|
-
if (props.isRTL) rules += ' W-negfvv';
|
|
274
|
-
else rules += ' W-10b8jr2';
|
|
273
|
+
if (props.isRTL) rules += ' s1-W-negfvv';
|
|
274
|
+
else rules += ' s1-W-10b8jr2';
|
|
275
275
|
}
|
|
276
|
-
rules += ' _H-1o2fh9e';
|
|
276
|
+
rules += ' s1-_H-1o2fh9e';
|
|
277
277
|
return rules;
|
|
278
278
|
};
|
|
279
279
|
function $48b8113347121625$var$ExpandableRowChevron(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA0CD,MAAM,0DAAsB,CAAA,GAAA,oBAAY,EAA4B,CAAC;AAErE,SAAS;IACP,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB;AAEA,2DAA2D;AAE3D,4KAA4K;AAC5K,gHAAgH;AAChH,sIAAsI;AACtI,MAAM;;;;;;;;;;;;;;;;;AA0BN,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,IAAI,YAAC,QAAQ,kBAAE,cAAc,EAAC,GAAG;IAEjC,IAAI;IACJ,IAAI,OAAO,aAAa,YACtB,WAAW;IAGb,IAAI,cAAC,UAAU,EAAC,GAAG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IAAI,GAAG,CAAA,GAAA,sBAAc,EAAE;QAAC,GAAG,KAAK;QAAE,MAAM;IAAS,GAAG,iBAAiB,CAAA,GAAA,oBAAY;IACjG,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG;IAC/B,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAE1B,4KAA4K;IAC5K,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAAE;QAC5B,GAAG,SAAS;QACZ,aAAa;IACf,GAAG;IAEH,qBACE,gCAAC;QACE,GAAG,WAAW;QACf,KAAK;QACL,kHAAkH;QAClH,UAAU,CAAA,GAAA,gBAAQ,OAAO,CAAC,aAAa,KAAK;QAC5C,WAAW,mCAAa;wBAAC;wBAAY;YAAY,OAAO,cAAc;QAAK;OAC1E,cAAc,sBAAQ,gCAAC,CAAA,GAAA,wCAAiB,yBAAO,gCAAC,CAAA,GAAA,uCAAgB;AAGvE;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tree/src/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 {AriaTreeGridListProps} from '@react-aria/tree';\nimport {ButtonContext, Collection, TreeItemContentRenderProps, TreeItemProps, TreeItemRenderProps, TreeRenderProps, UNSTABLE_Tree, UNSTABLE_TreeItem, UNSTABLE_TreeItemContent, useContextProps} from 'react-aria-components';\nimport {Checkbox} from '@react-spectrum/checkbox';\nimport ChevronLeftMedium from '@spectrum-icons/ui/ChevronLeftMedium';\nimport ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium';\nimport {DOMRef, Expandable, Key, SelectionBehavior, SpectrumSelectionProps, StyleProps} from '@react-types/shared';\nimport {isAndroid} from '@react-aria/utils';\nimport React, {createContext, isValidElement, JSX, JSXElementConstructor, ReactElement, ReactNode, useContext, useRef} from 'react';\nimport {SlotProvider, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};\nimport {Text} from '@react-spectrum/text';\nimport {useButton} from '@react-aria/button';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface SpectrumTreeViewProps<T> extends Omit<AriaTreeGridListProps<T>, 'children'>, StyleProps, SpectrumSelectionProps, 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 on\n * 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<T extends object = object> extends Omit<TreeItemProps, 'className' | 'style' | 'value' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'> {\n /** Rendered contents of the tree item or child items. */\n children: ReactNode,\n /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean,\n /** A list of child tree item objects used when dynamically rendering the tree item children. */\n childItems?: Iterable<T>\n}\n\ninterface TreeRendererContextValue {\n renderer?: (item) => ReactElement<any, string | JSXElementConstructor<any>>\n}\nconst TreeRendererContext = createContext<TreeRendererContextValue>({});\n\nfunction useTreeRendererContext(): TreeRendererContextValue {\n return useContext(TreeRendererContext)!;\n}\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 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 width: {\n isEmpty: 'full'\n },\n height: {\n isEmpty: 'full'\n },\n display: {\n isEmpty: 'flex'\n }\n});\n\nfunction TreeView<T extends object>(props: SpectrumTreeViewProps<T>, ref: DOMRef<HTMLDivElement>) {\n let {children, selectionStyle} = 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 <UNSTABLE_Tree {...props} {...styleProps} className={({isEmpty}) => tree({isEmpty})} selectionBehavior={selectionBehavior as SelectionBehavior} ref={domRef}>\n {props.children}\n </UNSTABLE_Tree>\n </TreeRendererContext.Provider>\n );\n}\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: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 10, 'minmax(0, auto)', '1fr', 'minmax(0, auto)', 'auto'],\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: .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 },\n bottom: 0,\n pointerEvents: 'none',\n forcedColorAdjust: 'none',\n\n boxShadow: {\n isFocusVisible: '[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: '[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: '[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: '[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: '[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: '[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 = <T extends object>(props: SpectrumTreeViewItemProps<T>) => {\n let {\n children,\n childItems,\n hasChildItems,\n href\n } = props;\n\n let content;\n let nestedRows;\n let {renderer} = useTreeRendererContext();\n // TODO alternative api is that we have a separate prop for the TreeItems contents and expect the child to then be\n // a nested tree item\n\n if (typeof children === 'string') {\n content = <Text>{children}</Text>;\n } else {\n content = [];\n nestedRows = [];\n React.Children.forEach(children, node => {\n if (isValidElement(node) && node.type === TreeViewItem) {\n nestedRows.push(node);\n } else {\n content.push(node);\n }\n });\n }\n\n if (childItems != null && renderer) {\n nestedRows = (\n <Collection items={childItems}>\n {renderer}\n </Collection>\n );\n }\n\n return (\n // TODO right now all the tree rows have the various data attributes applied on their dom nodes, should they? Doesn't feel very useful\n <UNSTABLE_TreeItem\n {...props}\n className={renderProps => treeRow({\n ...renderProps,\n isLink: !!href\n })}>\n <UNSTABLE_TreeItemContent>\n {({isExpanded, hasChildRows, level, selectionMode, selectionBehavior, isDisabled, isSelected, isFocusVisible}) => (\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 <div style={{gridArea: 'level-padding', marginInlineEnd: `calc(${level - 1} * var(--spectrum-global-dimension-size-200))`}} />\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 {(hasChildRows || hasChildItems) && <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} />}\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: {UNSAFE_className: treeActionMenu(), UNSAFE_style: {marginInlineEnd: '.5rem'}, isQuiet: true}\n }}>\n {content}\n </SlotProvider>\n <div className={treeRowOutline({isFocusVisible, isSelected})} />\n </div>\n )}\n </UNSTABLE_TreeItemContent>\n {nestedRows}\n </UNSTABLE_TreeItem>\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<HTMLSpanElement>(null);\n let [fullProps, ref] = useContextProps({...props, slot: 'chevron'}, expandButtonRef, ButtonContext);\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 ...fullProps,\n elementType: 'span'\n }, ref);\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\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nconst _TreeView = React.forwardRef(TreeView) as <T>(props: SpectrumTreeViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_TreeView as TreeView};\n"],"names":[],"version":3,"file":"TreeView.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA0CD,MAAM,0DAAsB,CAAA,GAAA,oBAAY,EAA4B,CAAC;AAErE,SAAS;IACP,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB;AAEA,2DAA2D;AAE3D,4KAA4K;AAC5K,gHAAgH;AAChH,sIAAsI;AACtI,MAAM;;;;;;;;;;;;;;;;;AA0BN,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,IAAI,YAAC,QAAQ,kBAAE,cAAc,EAAC,GAAG;IAEjC,IAAI;IACJ,IAAI,OAAO,aAAa,YACtB,WAAW;IAGb,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,oBAAoB,mBAAmB,cAAc,YAAY;IAErE,qBACE,gCAAC,0CAAoB,QAAQ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C,GAAG;IAC/B,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAE1B,4KAA4K;IAC5K,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAAE;QAC5B,GAAG,SAAS;QACZ,aAAa;IACf,GAAG;IAEH,qBACE,gCAAC;QACE,GAAG,WAAW;QACf,KAAK;QACL,kHAAkH;QAClH,UAAU,CAAA,GAAA,gBAAQ,OAAO,CAAC,aAAa,KAAK;QAC5C,WAAW,mCAAa;wBAAC;wBAAY;YAAY,OAAO,cAAc;QAAK;OAC1E,cAAc,sBAAQ,gCAAC,CAAA,GAAA,wCAAiB,yBAAO,gCAAC,CAAA,GAAA,uCAAgB;AAGvE;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tree/src/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 {AriaTreeGridListProps} from '@react-aria/tree';\nimport {ButtonContext, Collection, TreeItemContentRenderProps, TreeItemProps, TreeItemRenderProps, TreeRenderProps, UNSTABLE_Tree, UNSTABLE_TreeItem, UNSTABLE_TreeItemContent, useContextProps} from 'react-aria-components';\nimport {Checkbox} from '@react-spectrum/checkbox';\nimport ChevronLeftMedium from '@spectrum-icons/ui/ChevronLeftMedium';\nimport ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium';\nimport {DOMRef, Expandable, Key, SelectionBehavior, SpectrumSelectionProps, StyleProps} from '@react-types/shared';\nimport {isAndroid} from '@react-aria/utils';\nimport React, {createContext, isValidElement, JSX, JSXElementConstructor, ReactElement, ReactNode, useContext, useRef} from 'react';\nimport {SlotProvider, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {style} from '@react-spectrum/style-macro-s1' with {type: 'macro'};\nimport {Text} from '@react-spectrum/text';\nimport {useButton} from '@react-aria/button';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface SpectrumTreeViewProps<T> extends Omit<AriaTreeGridListProps<T>, 'children'>, StyleProps, SpectrumSelectionProps, 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 on\n * 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<T extends object = object> extends Omit<TreeItemProps, 'className' | 'style' | 'value' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'> {\n /** Rendered contents of the tree item or child items. */\n children: ReactNode,\n /** Whether this item has children, even if not loaded yet. */\n hasChildItems?: boolean,\n /** A list of child tree item objects used when dynamically rendering the tree item children. */\n childItems?: Iterable<T>\n}\n\ninterface TreeRendererContextValue {\n renderer?: (item) => ReactElement<any, string | JSXElementConstructor<any>>\n}\nconst TreeRendererContext = createContext<TreeRendererContextValue>({});\n\nfunction useTreeRendererContext(): TreeRendererContextValue {\n return useContext(TreeRendererContext)!;\n}\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 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 width: {\n isEmpty: 'full'\n },\n height: {\n isEmpty: 'full'\n },\n display: {\n isEmpty: 'flex'\n }\n});\n\nfunction TreeView<T extends object>(props: SpectrumTreeViewProps<T>, ref: DOMRef<HTMLDivElement>) {\n let {children, selectionStyle} = 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 <UNSTABLE_Tree {...props} {...styleProps} className={({isEmpty}) => tree({isEmpty})} selectionBehavior={selectionBehavior as SelectionBehavior} ref={domRef}>\n {props.children}\n </UNSTABLE_Tree>\n </TreeRendererContext.Provider>\n );\n}\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: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 10, 'minmax(0, auto)', '1fr', 'minmax(0, auto)', 'auto'],\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: .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 },\n bottom: 0,\n pointerEvents: 'none',\n forcedColorAdjust: 'none',\n\n boxShadow: {\n isFocusVisible: '[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: '[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: '[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: '[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: '[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: '[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 = <T extends object>(props: SpectrumTreeViewItemProps<T>) => {\n let {\n children,\n childItems,\n hasChildItems,\n href\n } = props;\n\n let content;\n let nestedRows;\n let {renderer} = useTreeRendererContext();\n // TODO alternative api is that we have a separate prop for the TreeItems contents and expect the child to then be\n // a nested tree item\n\n if (typeof children === 'string') {\n content = <Text>{children}</Text>;\n } else {\n content = [];\n nestedRows = [];\n React.Children.forEach(children, node => {\n if (isValidElement(node) && node.type === TreeViewItem) {\n nestedRows.push(node);\n } else {\n content.push(node);\n }\n });\n }\n\n if (childItems != null && renderer) {\n nestedRows = (\n <Collection items={childItems}>\n {renderer}\n </Collection>\n );\n }\n\n return (\n // TODO right now all the tree rows have the various data attributes applied on their dom nodes, should they? Doesn't feel very useful\n <UNSTABLE_TreeItem\n {...props}\n className={renderProps => treeRow({\n ...renderProps,\n isLink: !!href\n })}>\n <UNSTABLE_TreeItemContent>\n {({isExpanded, hasChildRows, level, selectionMode, selectionBehavior, isDisabled, isSelected, isFocusVisible}) => (\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 <div style={{gridArea: 'level-padding', marginInlineEnd: `calc(${level - 1} * var(--spectrum-global-dimension-size-200))`}} />\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 {(hasChildRows || hasChildItems) && <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} />}\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: {UNSAFE_className: treeActionMenu(), UNSAFE_style: {marginInlineEnd: '.5rem'}, isQuiet: true}\n }}>\n {content}\n </SlotProvider>\n <div className={treeRowOutline({isFocusVisible, isSelected})} />\n </div>\n )}\n </UNSTABLE_TreeItemContent>\n {nestedRows}\n </UNSTABLE_TreeItem>\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({...props, slot: 'chevron'}, expandButtonRef, ButtonContext);\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 ...fullProps,\n elementType: 'span'\n }, ref);\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\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nconst _TreeView = React.forwardRef(TreeView) as <T>(props: SpectrumTreeViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_TreeView as TreeView};\n"],"names":[],"version":3,"file":"TreeView.module.js.map"}
|