@react-spectrum/tree 3.0.0-alpha.3 → 3.0.0-beta.0
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.057cd1da.css → TreeView.5c7cb24b.css} +3 -3
- package/dist/{TreeView.057cd1da.css.map → TreeView.5c7cb24b.css.map} +1 -1
- package/dist/TreeView.main.js +2 -2
- package/dist/TreeView.main.js.map +1 -1
- package/dist/TreeView.mjs +2 -2
- package/dist/TreeView.module.js +2 -2
- package/dist/TreeView.module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -15
- package/src/TreeView.tsx +1 -2
- package/LICENSE +0 -201
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
align-items: center;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
.__d-1nxidkl-1nxidkl-1nxidkl-
|
|
88
|
-
grid-template-columns: minmax(0, auto) minmax(0, auto) minmax(0, auto)
|
|
87
|
+
.__d-1nxidkl-1nxidkl-1nxidkl-3hmti-1nxidkl-375yi6-1nxidkl-ykdwf2 {
|
|
88
|
+
grid-template-columns: minmax(0, auto) minmax(0, auto) minmax(0, auto) 2.5rem minmax(0, auto) 1fr minmax(0, auto) auto;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
.__e-375yi6 {
|
|
@@ -312,4 +312,4 @@
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
|
-
/*# sourceMappingURL=TreeView.
|
|
315
|
+
/*# sourceMappingURL=TreeView.5c7cb24b.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"ACAA;EAGE;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAYA;;;;EAMA;;;;EApCA;;;;EAYA;;;;EAYA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAYA;;;;EAMA;;;;EAMA;;;;;EAYA;;;;EAMA;;;;EA1FA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EApCA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAlBA;;;;EAMA;;;;EANA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAxBA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAxBA;;;;EAMA;;;;EANA;;;;EAMA;;;;EAMA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAMA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAMA;;;;EAYA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAYA;;;;EAMA;;;;EA9EA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;;;;AA/DF;;AA4CA;EACE;IACE;;;;IAAA;;;;IA8CA;;;;IAIA","sources":["f54a9241b0b1bdd2","packages/@react-spectrum/tree/src/TreeView.tsx"],"sourcesContent":["@import \"43ede2ea230cbe77\";\n@import \"d6186a3bcdea23c0\";\n@import \"9b0163e48ed44108\";\n@import \"4145f5de7372e962\";\n@import \"5c8e7aff246c25c0\";\n@import \"e6e7b4c2a4a805d7\";\n@import \"ed226d1e6a9f6d5d\";\n@import \"af6efb89500ab023\";\n@import \"5458487886ba8cfe\";\n@import \"5be3595defba4bd4\";\n","@layer a, b;\n\n@layer a {\n .wc {\n border-top-width: var(--spectrum-alias-border-size-thick, var(--spectrum-global-dimension-static-size-25));\n }\n}\n\n@layer a {\n .xc {\n border-bottom-width: var(--spectrum-alias-border-size-thick, var(--spectrum-global-dimension-static-size-25));\n }\n}\n\n@layer a {\n .ua {\n border-inline-start-width: 0px;\n }\n}\n\n@layer a {\n .va {\n border-inline-end-width: 0px;\n }\n}\n\n@layer a {\n .__ka {\n box-sizing: border-box;\n }\n}\n\n@layer a {\n .Aa {\n border-style: solid;\n }\n}\n\n@layer a {\n .ca {\n border-color: transparent;\n }\n}\n\n@layer b.a {\n @media (forced-colors: active) {\n .ca___y {\n border-color: Background;\n }\n }\n}\n\n@layer a {\n ._Vd {\n justify-content: center;\n }\n}\n\n@layer a {\n ._Uc {\n align-items: center;\n }\n}\n\n@layer a {\n .oY {\n width: 100%;\n }\n}\n\n@layer a {\n .nY {\n height: 100%;\n }\n}\n\n@layer a {\n ._Sd {\n display: flex;\n }\n}\n\n"],"names":[],"version":3,"file":"TreeView.
|
|
1
|
+
{"mappings":"ACAA;EAGE;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAYA;;;;EAMA;;;;EApCA;;;;EAYA;;;;EAYA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAYA;;;;EAMA;;;;EAMA;;;;;EAYA;;;;EAMA;;;;EA1FA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EApCA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAlBA;;;;EAMA;;;;EANA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAxBA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAxBA;;;;EAMA;;;;EANA;;;;EAMA;;;;EAMA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAMA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAMA;;;;EAYA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAYA;;;;EAMA;;;;EA9EA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;EAMA;;;;;;;AA/DF;;AA4CA;EACE;IACE;;;;IAAA;;;;IA8CA;;;;IAIA","sources":["f54a9241b0b1bdd2","packages/@react-spectrum/tree/src/TreeView.tsx"],"sourcesContent":["@import \"43ede2ea230cbe77\";\n@import \"d6186a3bcdea23c0\";\n@import \"9b0163e48ed44108\";\n@import \"4145f5de7372e962\";\n@import \"5c8e7aff246c25c0\";\n@import \"e6e7b4c2a4a805d7\";\n@import \"ed226d1e6a9f6d5d\";\n@import \"af6efb89500ab023\";\n@import \"5458487886ba8cfe\";\n@import \"5be3595defba4bd4\";\n","@layer a, b;\n\n@layer a {\n .wc {\n border-top-width: var(--spectrum-alias-border-size-thick, var(--spectrum-global-dimension-static-size-25));\n }\n}\n\n@layer a {\n .xc {\n border-bottom-width: var(--spectrum-alias-border-size-thick, var(--spectrum-global-dimension-static-size-25));\n }\n}\n\n@layer a {\n .ua {\n border-inline-start-width: 0px;\n }\n}\n\n@layer a {\n .va {\n border-inline-end-width: 0px;\n }\n}\n\n@layer a {\n .__ka {\n box-sizing: border-box;\n }\n}\n\n@layer a {\n .Aa {\n border-style: solid;\n }\n}\n\n@layer a {\n .ca {\n border-color: transparent;\n }\n}\n\n@layer b.a {\n @media (forced-colors: active) {\n .ca___y {\n border-color: Background;\n }\n }\n}\n\n@layer a {\n ._Vd {\n justify-content: center;\n }\n}\n\n@layer a {\n ._Uc {\n align-items: center;\n }\n}\n\n@layer a {\n .oY {\n width: 100%;\n }\n}\n\n@layer a {\n .nY {\n height: 100%;\n }\n}\n\n@layer a {\n ._Sd {\n display: flex;\n }\n}\n\n"],"names":[],"version":3,"file":"TreeView.5c7cb24b.css.map"}
|
package/dist/TreeView.main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require("./TreeView.
|
|
1
|
+
require("./TreeView.5c7cb24b.css");
|
|
2
2
|
var $6Q8R1$reactariacomponents = require("react-aria-components");
|
|
3
3
|
var $6Q8R1$reactspectrumcheckbox = require("@react-spectrum/checkbox");
|
|
4
4
|
var $6Q8R1$spectrumiconsuiChevronLeftMedium = require("@spectrum-icons/ui/ChevronLeftMedium");
|
|
@@ -112,7 +112,7 @@ const $9b0dbe0a88ecfa3f$var$treeCellGrid = function anonymous(props) {
|
|
|
112
112
|
rules += ' _Sf';
|
|
113
113
|
rules += ' oY';
|
|
114
114
|
rules += ' _Uc';
|
|
115
|
-
rules += ' __d-1nxidk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AiB,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 // TODO: needed to use spectrum var since gridTemplateColumns uses baseSizing and not scaled sizing\n gridTemplateColumns: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 'var(--spectrum-global-dimension-size-500)', '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;;;;;;AAKN,MAAM;;;;;;;;;AAON,MAAM;;;;;;;;;AASN,MAAM;;;;;;AAKN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;AAkCC,MAAM,4CAAe,CAAmB;IAC7C,IA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AEC,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"}
|
package/dist/TreeView.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./TreeView.
|
|
1
|
+
import "./TreeView.5c7cb24b.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";
|
|
@@ -101,7 +101,7 @@ const $48b8113347121625$var$treeCellGrid = function anonymous(props) {
|
|
|
101
101
|
rules += ' _Sf';
|
|
102
102
|
rules += ' oY';
|
|
103
103
|
rules += ' _Uc';
|
|
104
|
-
rules += ' __d-1nxidkl-1nxidkl-1nxidkl-
|
|
104
|
+
rules += ' __d-1nxidkl-1nxidkl-1nxidkl-3hmti-1nxidkl-375yi6-1nxidkl-ykdwf2';
|
|
105
105
|
rules += ' __e-375yi6';
|
|
106
106
|
rules += ' __f-1qk85yo';
|
|
107
107
|
if (props.isDisabled) {
|
package/dist/TreeView.module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./TreeView.
|
|
1
|
+
import "./TreeView.5c7cb24b.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";
|
|
@@ -101,7 +101,7 @@ const $48b8113347121625$var$treeCellGrid = function anonymous(props) {
|
|
|
101
101
|
rules += ' _Sf';
|
|
102
102
|
rules += ' oY';
|
|
103
103
|
rules += ' _Uc';
|
|
104
|
-
rules += ' __d-1nxidkl-1nxidkl-1nxidkl-
|
|
104
|
+
rules += ' __d-1nxidkl-1nxidkl-1nxidkl-3hmti-1nxidkl-375yi6-1nxidkl-ykdwf2';
|
|
105
105
|
rules += ' __e-375yi6';
|
|
106
106
|
rules += ' __f-1qk85yo';
|
|
107
107
|
if (props.isDisabled) {
|
|
@@ -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,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,oBAAoB,mBAAmB,cAAc,YAAY;IAErE,qBACE,gCAAC,0CAAoB,QAAQ;QAAC,OAAO;sBAAC;QAAQ;qBAC5C,gCAAC,CAAA,GAAA,oBAAY;QAAG,GAAG,KAAK;QAAG,GAAG,UAAU;QAAE,WAAW,CAAC,WAAC,OAAO,EAAC,GAAK,2BAAK;yBAAC;YAAO;QAAI,mBAAmB;QAAwC,KAAK;OAClJ,MAAM,QAAQ;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ACE,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 // TODO: needed to use spectrum var since gridTemplateColumns uses baseSizing and not scaled sizing\n gridTemplateColumns: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 'var(--spectrum-global-dimension-size-500)', '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;QAAC,OAAO;sBAAC;QAAQ;qBAC5C,gCAAC,CAAA,GAAA,oBAAY;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;;;;;;;;;;;;;;AAi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AO,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"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AA0BA,uCAAuC,CAAC,CAAE,SAAQ,IAAI,CAAC,sBAAsB,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU;IAC1I,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,IAAI,OAAO,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9B;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC,CAAA;CAChD;AAED,2CAA2C,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,GAAG,YAAY,GAAG,eAAe,CAAC;IAClL,yDAAyD;IACzD,QAAQ,EAAE,SAAS,CAAC;IACpB,8DAA8D;IAC9D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gGAAgG;IAChG,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CACzB;
|
|
1
|
+
{"mappings":";;;;AA0BA,uCAAuC,CAAC,CAAE,SAAQ,IAAI,CAAC,sBAAsB,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU;IAC1I,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,IAAI,OAAO,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9B;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,CAAC,CAAA;CAChD;AAED,2CAA2C,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,GAAG,YAAY,GAAG,eAAe,CAAC;IAClL,yDAAyD;IACzD,QAAQ,EAAE,SAAS,CAAC;IACpB,8DAA8D;IAC9D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gGAAgG;IAChG,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CACzB;AAgLD,OAAO,MAAM,eAAgB,CAAC,SAAS,MAAM,SAAS,0BAA0B,CAAC,CAAC,gBAoFjF,CAAC;AAkDF;;GAEG;AACH,OAAA,MAAM,UAA0C,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,OAAO,cAAc,CAAC,CAAA;CAAC,KAAK,YAAY,CAAC","sources":["packages/@react-spectrum/tree/src/packages/@react-spectrum/tree/src/TreeView.tsx","packages/@react-spectrum/tree/src/packages/@react-spectrum/tree/src/index.ts","packages/@react-spectrum/tree/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport {TreeViewItem, TreeView} from './TreeView';\nexport type {SpectrumTreeViewProps, SpectrumTreeViewItemProps} from './TreeView';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/tree",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/button": "^3.
|
|
40
|
-
"@react-aria/i18n": "^3.12.
|
|
41
|
-
"@react-aria/tree": "3.0.0-
|
|
42
|
-
"@react-aria/utils": "^3.25.
|
|
43
|
-
"@react-spectrum/checkbox": "^3.9.
|
|
44
|
-
"@react-spectrum/text": "^3.5.
|
|
45
|
-
"@react-spectrum/utils": "^3.11.
|
|
46
|
-
"@react-types/shared": "^3.
|
|
47
|
-
"@spectrum-icons/ui": "^3.6.
|
|
39
|
+
"@react-aria/button": "^3.10.0",
|
|
40
|
+
"@react-aria/i18n": "^3.12.3",
|
|
41
|
+
"@react-aria/tree": "3.0.0-beta.0",
|
|
42
|
+
"@react-aria/utils": "^3.25.3",
|
|
43
|
+
"@react-spectrum/checkbox": "^3.9.9",
|
|
44
|
+
"@react-spectrum/text": "^3.5.8",
|
|
45
|
+
"@react-spectrum/utils": "^3.11.11",
|
|
46
|
+
"@react-types/shared": "^3.25.0",
|
|
47
|
+
"@spectrum-icons/ui": "^3.6.10",
|
|
48
48
|
"@swc/helpers": "^0.5.0",
|
|
49
|
-
"react-aria-components": "^1.
|
|
49
|
+
"react-aria-components": "^1.4.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@react-spectrum/provider": "^3.0.0",
|
|
@@ -55,10 +55,9 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@adobe/spectrum-css-temp": "3.0.0-alpha.1",
|
|
58
|
-
"@react-spectrum/style-macro-s1": "3.0.0-alpha.
|
|
58
|
+
"@react-spectrum/style-macro-s1": "3.0.0-alpha.1"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/TreeView.tsx
CHANGED
|
@@ -140,8 +140,7 @@ const treeCellGrid = style({
|
|
|
140
140
|
display: 'grid',
|
|
141
141
|
width: 'full',
|
|
142
142
|
alignItems: 'center',
|
|
143
|
-
|
|
144
|
-
gridTemplateColumns: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 'var(--spectrum-global-dimension-size-500)', 'minmax(0, auto)', '1fr', 'minmax(0, auto)', 'auto'],
|
|
143
|
+
gridTemplateColumns: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 10, 'minmax(0, auto)', '1fr', 'minmax(0, auto)', 'auto'],
|
|
145
144
|
gridTemplateRows: '1fr',
|
|
146
145
|
gridTemplateAreas: [
|
|
147
146
|
'drag-handle checkbox level-padding expand-button icon content actions actionmenu'
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2019 Adobe
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|