@react-spectrum/s2 3.0.0-nightly-cc08a8dbc-250210 → 3.0.0-nightly-56da82e3e-250212
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/Accordion.cjs.map +1 -1
- package/dist/Accordion.css.map +1 -1
- package/dist/Accordion.mjs.map +1 -1
- package/dist/ActionButton.cjs.map +1 -1
- package/dist/ActionButton.css.map +1 -1
- package/dist/ActionButton.mjs.map +1 -1
- package/dist/ActionMenu.cjs.map +1 -1
- package/dist/ActionMenu.mjs.map +1 -1
- package/dist/Avatar.cjs.map +1 -1
- package/dist/Avatar.css.map +1 -1
- package/dist/Avatar.mjs.map +1 -1
- package/dist/AvatarGroup.cjs.map +1 -1
- package/dist/AvatarGroup.css.map +1 -1
- package/dist/AvatarGroup.mjs.map +1 -1
- package/dist/Breadcrumbs.cjs.map +1 -1
- package/dist/Breadcrumbs.css.map +1 -1
- package/dist/Breadcrumbs.mjs.map +1 -1
- package/dist/Button.cjs.map +1 -1
- package/dist/Button.css.map +1 -1
- package/dist/Button.mjs.map +1 -1
- package/dist/ButtonGroup.cjs.map +1 -1
- package/dist/ButtonGroup.css.map +1 -1
- package/dist/ButtonGroup.mjs.map +1 -1
- package/dist/CardView.cjs.map +1 -1
- package/dist/CardView.css.map +1 -1
- package/dist/CardView.mjs.map +1 -1
- package/dist/Checkbox.cjs.map +1 -1
- package/dist/Checkbox.css.map +1 -1
- package/dist/Checkbox.mjs.map +1 -1
- package/dist/CheckboxGroup.cjs.map +1 -1
- package/dist/CheckboxGroup.css.map +1 -1
- package/dist/CheckboxGroup.mjs.map +1 -1
- package/dist/CloseButton.cjs.map +1 -1
- package/dist/CloseButton.css.map +1 -1
- package/dist/CloseButton.mjs.map +1 -1
- package/dist/ColorArea.cjs.map +1 -1
- package/dist/ColorArea.css.map +1 -1
- package/dist/ColorArea.mjs.map +1 -1
- package/dist/ColorField.cjs.map +1 -1
- package/dist/ColorField.css.map +1 -1
- package/dist/ColorField.mjs.map +1 -1
- package/dist/ColorSlider.cjs.map +1 -1
- package/dist/ColorSlider.css.map +1 -1
- package/dist/ColorSlider.mjs.map +1 -1
- package/dist/ColorSwatch.cjs.map +1 -1
- package/dist/ColorSwatch.css.map +1 -1
- package/dist/ColorSwatch.mjs.map +1 -1
- package/dist/ColorWheel.cjs.map +1 -1
- package/dist/ColorWheel.css.map +1 -1
- package/dist/ColorWheel.mjs.map +1 -1
- package/dist/Content.cjs.map +1 -1
- package/dist/Content.mjs.map +1 -1
- package/dist/ContextualHelp.cjs.map +1 -1
- package/dist/ContextualHelp.css.map +1 -1
- package/dist/ContextualHelp.mjs.map +1 -1
- package/dist/Disclosure.cjs.map +1 -1
- package/dist/Disclosure.css.map +1 -1
- package/dist/Disclosure.mjs.map +1 -1
- package/dist/Divider.cjs.map +1 -1
- package/dist/Divider.css.map +1 -1
- package/dist/Divider.mjs.map +1 -1
- package/dist/DropZone.cjs.map +1 -1
- package/dist/DropZone.css.map +1 -1
- package/dist/DropZone.mjs.map +1 -1
- package/dist/Field.cjs.map +1 -1
- package/dist/Field.css.map +1 -1
- package/dist/Field.mjs.map +1 -1
- package/dist/Form.cjs.map +1 -1
- package/dist/Form.css.map +1 -1
- package/dist/Form.mjs.map +1 -1
- package/dist/IllustratedMessage.cjs.map +1 -1
- package/dist/IllustratedMessage.css.map +1 -1
- package/dist/IllustratedMessage.mjs.map +1 -1
- package/dist/Image.cjs.map +1 -1
- package/dist/Image.css.map +1 -1
- package/dist/Image.mjs.map +1 -1
- package/dist/Link.cjs.map +1 -1
- package/dist/Link.css.map +1 -1
- package/dist/Link.mjs.map +1 -1
- package/dist/Menu.cjs +1 -0
- package/dist/Menu.cjs.map +1 -1
- package/dist/Menu.css +4 -0
- package/dist/Menu.css.map +1 -1
- package/dist/Menu.mjs +1 -0
- package/dist/Menu.mjs.map +1 -1
- package/dist/Meter.cjs.map +1 -1
- package/dist/Meter.css.map +1 -1
- package/dist/Meter.mjs.map +1 -1
- package/dist/NumberField.cjs.map +1 -1
- package/dist/NumberField.css.map +1 -1
- package/dist/NumberField.mjs.map +1 -1
- package/dist/Picker.cjs +1 -0
- package/dist/Picker.cjs.map +1 -1
- package/dist/Picker.css +4 -0
- package/dist/Picker.css.map +1 -1
- package/dist/Picker.mjs +1 -0
- package/dist/Picker.mjs.map +1 -1
- package/dist/ProgressBar.cjs.map +1 -1
- package/dist/ProgressBar.css.map +1 -1
- package/dist/ProgressBar.mjs.map +1 -1
- package/dist/ProgressCircle.cjs.map +1 -1
- package/dist/ProgressCircle.css.map +1 -1
- package/dist/ProgressCircle.mjs.map +1 -1
- package/dist/RadioGroup.cjs.map +1 -1
- package/dist/RadioGroup.css.map +1 -1
- package/dist/RadioGroup.mjs.map +1 -1
- package/dist/RangeSlider.cjs.map +1 -1
- package/dist/RangeSlider.mjs.map +1 -1
- package/dist/SearchField.cjs.map +1 -1
- package/dist/SearchField.css.map +1 -1
- package/dist/SearchField.mjs.map +1 -1
- package/dist/SegmentedControl.cjs.map +1 -1
- package/dist/SegmentedControl.css.map +1 -1
- package/dist/SegmentedControl.mjs.map +1 -1
- package/dist/Slider.cjs.map +1 -1
- package/dist/Slider.css.map +1 -1
- package/dist/Slider.mjs.map +1 -1
- package/dist/StatusLight.cjs.map +1 -1
- package/dist/StatusLight.css.map +1 -1
- package/dist/StatusLight.mjs.map +1 -1
- package/dist/Switch.cjs.map +1 -1
- package/dist/Switch.css.map +1 -1
- package/dist/Switch.mjs.map +1 -1
- package/dist/TableView.cjs.map +1 -1
- package/dist/TableView.css.map +1 -1
- package/dist/TableView.mjs.map +1 -1
- package/dist/Tabs.cjs +5 -17
- package/dist/Tabs.cjs.map +1 -1
- package/dist/Tabs.css +4 -28
- package/dist/Tabs.css.map +1 -1
- package/dist/Tabs.mjs +5 -17
- package/dist/Tabs.mjs.map +1 -1
- package/dist/TagGroup.cjs.map +1 -1
- package/dist/TagGroup.css.map +1 -1
- package/dist/TagGroup.mjs.map +1 -1
- package/dist/TextField.cjs.map +1 -1
- package/dist/TextField.css.map +1 -1
- package/dist/TextField.mjs.map +1 -1
- package/dist/ToggleButton.cjs.map +1 -1
- package/dist/ToggleButton.css.map +1 -1
- package/dist/ToggleButton.mjs.map +1 -1
- package/dist/ToggleButtonGroup.cjs.map +1 -1
- package/dist/ToggleButtonGroup.mjs.map +1 -1
- package/dist/Tooltip.cjs.map +1 -1
- package/dist/Tooltip.css.map +1 -1
- package/dist/Tooltip.mjs.map +1 -1
- package/dist/TreeView.cjs +32 -10
- package/dist/TreeView.cjs.map +1 -1
- package/dist/TreeView.css +46 -26
- package/dist/TreeView.css.map +1 -1
- package/dist/TreeView.mjs +32 -10
- package/dist/TreeView.mjs.map +1 -1
- package/dist/types.d.ts +73 -71
- package/dist/types.d.ts.map +1 -1
- package/icons/Icon.cjs.map +1 -1
- package/icons/Icon.mjs.map +1 -1
- package/icons/Skeleton.cjs.map +1 -1
- package/icons/Skeleton.css.map +1 -1
- package/icons/Skeleton.mjs.map +1 -1
- package/package.json +21 -21
- package/src/Accordion.tsx +1 -1
- package/src/ActionButton.tsx +2 -2
- package/src/ActionMenu.tsx +1 -1
- package/src/Avatar.tsx +1 -1
- package/src/AvatarGroup.tsx +1 -1
- package/src/Breadcrumbs.tsx +4 -4
- package/src/Button.tsx +4 -4
- package/src/ButtonGroup.tsx +1 -1
- package/src/CardView.tsx +1 -1
- package/src/Checkbox.tsx +1 -1
- package/src/CheckboxGroup.tsx +2 -2
- package/src/CloseButton.tsx +1 -1
- package/src/ColorArea.tsx +1 -1
- package/src/ColorField.tsx +1 -1
- package/src/ColorSlider.tsx +1 -1
- package/src/ColorSwatch.tsx +1 -1
- package/src/ColorWheel.tsx +1 -1
- package/src/Content.tsx +7 -7
- package/src/ContextualHelp.tsx +2 -2
- package/src/Disclosure.tsx +1 -1
- package/src/Divider.tsx +1 -1
- package/src/DropZone.tsx +2 -2
- package/src/Field.tsx +1 -1
- package/src/Form.tsx +2 -2
- package/src/Icon.tsx +2 -2
- package/src/IllustratedMessage.tsx +1 -1
- package/src/Image.tsx +1 -1
- package/src/Link.tsx +2 -2
- package/src/Menu.tsx +4 -3
- package/src/Meter.tsx +1 -1
- package/src/NumberField.tsx +1 -1
- package/src/Picker.tsx +2 -1
- package/src/ProgressBar.tsx +1 -1
- package/src/ProgressCircle.tsx +1 -1
- package/src/RadioGroup.tsx +2 -2
- package/src/RangeSlider.tsx +1 -1
- package/src/SearchField.tsx +1 -1
- package/src/SegmentedControl.tsx +2 -2
- package/src/Skeleton.tsx +1 -1
- package/src/Slider.tsx +1 -1
- package/src/StatusLight.tsx +2 -2
- package/src/Switch.tsx +1 -1
- package/src/TableView.tsx +1 -1
- package/src/Tabs.tsx +16 -16
- package/src/TagGroup.tsx +2 -2
- package/src/TextField.tsx +2 -2
- package/src/ToggleButton.tsx +2 -2
- package/src/ToggleButtonGroup.tsx +1 -1
- package/src/Tooltip.tsx +3 -3
- package/src/TreeView.tsx +33 -12
package/dist/Tooltip.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmCD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DN,MAAM;;;;;;;;;;;;AAmBN,IAAI,oEAAgC,CAAA,GAAA,0BAAY,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmCD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DN,MAAM;;;;;;;;;;;;AAmBN,IAAI,oEAAgC,CAAA,GAAA,0BAAY,EAAgC,CAAC;AAK1E,MAAM,0DAAU,CAAA,GAAA,uBAAS,EAAE,SAAS,QAAQ,KAAmB,EAAE,GAA2B;IACjG,IAAI,YAAC,QAAQ,gBA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AAG;IAEJ,qBACE,gCAAC,CAAA,GAAA,yCAAiB;QAAG,GAAG,YAAY;kBAClC,cAAA,gCAAC,oDAA8B,QAAQ;YACrC,OAAO;gBACL,kBAAkB;gBAClB,aAAa;gBACb,QAAQ;gBACR,WAAW;gBACX,YAAY;YACd;sBACC,MAAM,QAAQ;;;AAIvB;AAMO,SAAS,0CAAgB,KAAgB;IAC9C,qBAAO,gCAAC;AACV","sources":["packages/@react-spectrum/s2/src/Tooltip.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 {\n Tooltip as AriaTooltip,\n TooltipProps as AriaTooltipProps,\n TooltipTrigger as AriaTooltipTrigger,\n TooltipTriggerComponentProps as AriaTooltipTriggerComponentProps,\n OverlayArrow,\n TooltipRenderProps,\n useLocale\n} from 'react-aria-components';\nimport {centerPadding, colorScheme, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorScheme} from '@react-types/provider';\nimport {ColorSchemeContext} from './Provider';\nimport {createContext, forwardRef, MutableRefObject, ReactNode, useCallback, useContext, useState} from 'react';\nimport {DOMRef} from '@react-types/shared';\nimport {style} from '../style' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\n\nexport interface TooltipTriggerProps extends Omit<AriaTooltipTriggerComponentProps, 'children' | 'closeDelay'>, Pick<AriaTooltipProps, 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'> {\n /** The content of the tooltip. */\n children: ReactNode,\n /**\n * The placement of the element with respect to its anchor element.\n *\n * @default 'top'\n */\n placement?: 'start' | 'end' | 'right' | 'left' | 'top' | 'bottom'\n}\n\nexport interface TooltipProps extends Omit<AriaTooltipProps, 'children' | 'className' | 'style' | 'triggerRef' | 'UNSTABLE_portalContainer' | 'isEntering' | 'isExiting' | 'placement' | 'containerPadding' | 'offset' | 'crossOffset' | 'shouldFlip' | 'arrowBoundaryOffset' | 'isOpen' | 'defaultOpen' | 'onOpenChange'>, UnsafeStyles {\n /** The content of the tooltip. */\n children: ReactNode\n}\n\nconst tooltip = style<TooltipRenderProps & {colorScheme: ColorScheme | 'light dark' | null}>({\n ...colorScheme(),\n justifyContent: 'center',\n alignItems: 'center',\n maxWidth: 160,\n minHeight: 24,\n boxSizing: 'border-box',\n font: 'ui-sm',\n color: {\n default: 'gray-25',\n forcedColors: 'ButtonText'\n },\n borderWidth: {\n forcedColors: 1\n },\n borderStyle: {\n forcedColors: 'solid'\n },\n borderColor: {\n forcedColors: 'transparent'\n },\n backgroundColor: 'neutral',\n borderRadius: 'control',\n paddingX: 'edge-to-text',\n paddingY: centerPadding(),\n margin: 8,\n transition: 'default',\n transitionDuration: 200,\n transitionTimingFunction: {\n isExiting: 'in'\n },\n translateX: {\n placement: {\n left: {\n isEntering: 4,\n isExiting: 4\n },\n right: {\n isEntering: -4,\n isExiting: -4\n }\n }\n },\n translateY: {\n placement: {\n top: {\n isEntering: 4,\n isExiting: 4\n },\n bottom: {\n isEntering: -4,\n isExiting: -4\n }\n }\n },\n opacity: {\n isEntering: 0,\n isExiting: 0\n }\n});\n\nconst arrowStyles = style<TooltipRenderProps>({\n display: 'block',\n fill: 'gray-800',\n rotate: {\n placement: {\n top: 0,\n bottom: '180deg',\n left: '-90deg',\n right: '90deg'\n }\n },\n translateX: {\n placement: {\n left: '[-25%]',\n right: '[25%]'\n }\n }\n});\n\nlet InternalTooltipTriggerContext = createContext<Partial<TooltipTriggerProps>>({});\n\n/**\n * Display container for Tooltip content. Has a directional arrow dependent on its placement.\n */\nexport const Tooltip = forwardRef(function Tooltip(props: TooltipProps, ref: DOMRef<HTMLDivElement>) {\n let {children, UNSAFE_style, UNSAFE_className = ''} = props;\n let domRef = useDOMRef(ref);\n let {\n containerPadding,\n crossOffset,\n offset,\n placement = 'top',\n shouldFlip\n } = useContext(InternalTooltipTriggerContext);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n let [borderRadius, setBorderRadius] = useState(0);\n\n // TODO: should we pass through lang and dir props in RAC?\n let tooltipRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n let spectrumBorderRadius = window.getComputedStyle(el).borderRadius;\n if (spectrumBorderRadius !== '') {\n setBorderRadius(parseInt(spectrumBorderRadius, 10));\n }\n }\n }, [locale, direction, domRef]);\n\n return (\n <AriaTooltip\n {...props}\n arrowBoundaryOffset={borderRadius}\n containerPadding={containerPadding}\n crossOffset={crossOffset}\n offset={offset}\n placement={placement}\n shouldFlip={shouldFlip}\n ref={tooltipRef}\n style={UNSAFE_style}\n className={renderProps => UNSAFE_className + tooltip({...renderProps, colorScheme})}>\n {renderProps => (\n <>\n <OverlayArrow>\n <svg className={arrowStyles(renderProps)} xmlns=\"http://www.w3.org/2000/svg\" width=\"10\" height=\"5\" viewBox=\"0 0 10 5\">\n <path d=\"M4.29289 4.29289L0 0H10L5.70711 4.29289C5.31658 4.68342 4.68342 4.68342 4.29289 4.29289Z\" />\n </svg>\n </OverlayArrow>\n {children}\n </>\n )}\n </AriaTooltip>\n );\n});\n\n/**\n * TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing\n * the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip\n * relative to the trigger.\n */\nexport function TooltipTrigger(props: TooltipTriggerProps) {\n let {\n containerPadding,\n crossOffset,\n offset,\n placement,\n shouldFlip,\n ...triggerProps\n } = props;\n\n return (\n <AriaTooltipTrigger {...triggerProps}>\n <InternalTooltipTriggerContext.Provider\n value={{\n containerPadding: containerPadding,\n crossOffset: crossOffset,\n offset: offset,\n placement: placement,\n shouldFlip: shouldFlip\n }}>\n {props.children}\n </InternalTooltipTriggerContext.Provider>\n </AriaTooltipTrigger>\n );\n}\n\n\n// This is purely so that storybook generates the types for both Menu and MenuTrigger\ninterface ICombined extends Omit<TooltipProps, 'placement'>, TooltipTriggerProps {}\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function CombinedTooltip(props: ICombined) {\n return <div />;\n}\n"],"names":[],"version":3,"file":"Tooltip.cjs.map"}
|
package/dist/Tooltip.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AC6CgB;EAAA;;;;EAAA;;;;;;EAAA;IAAA;;;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;;EAAA;;;;EA6DI;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;;;AA7DJ;EAAA;;;;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;IAAA;;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA","sources":["aa7688246f893a38","packages/@react-spectrum/s2/src/Tooltip.tsx"],"sourcesContent":["@import \"98a0a1b80e895d38\";\n@import \"c07030e64bc8758c\";\n","/*\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 {\n Tooltip as AriaTooltip,\n TooltipProps as AriaTooltipProps,\n TooltipTrigger as AriaTooltipTrigger,\n TooltipTriggerComponentProps as AriaTooltipTriggerComponentProps,\n OverlayArrow,\n TooltipRenderProps,\n useLocale\n} from 'react-aria-components';\nimport {centerPadding, colorScheme, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorScheme} from '@react-types/provider';\nimport {ColorSchemeContext} from './Provider';\nimport {createContext, forwardRef, MutableRefObject, ReactNode, useCallback, useContext, useState} from 'react';\nimport {DOMRef} from '@react-types/shared';\nimport {style} from '../style' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\n\nexport interface TooltipTriggerProps extends Omit<AriaTooltipTriggerComponentProps, 'children' | 'closeDelay'>, Pick<AriaTooltipProps, 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'> {\n /** The content of the tooltip. */\n children
|
|
1
|
+
{"mappings":"AC6CgB;EAAA;;;;EAAA;;;;;;EAAA;IAAA;;;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;;EAAA;;;;EA6DI;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;;;AA7DJ;EAAA;;;;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;IAAA;;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA","sources":["aa7688246f893a38","packages/@react-spectrum/s2/src/Tooltip.tsx"],"sourcesContent":["@import \"98a0a1b80e895d38\";\n@import \"c07030e64bc8758c\";\n","/*\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 {\n Tooltip as AriaTooltip,\n TooltipProps as AriaTooltipProps,\n TooltipTrigger as AriaTooltipTrigger,\n TooltipTriggerComponentProps as AriaTooltipTriggerComponentProps,\n OverlayArrow,\n TooltipRenderProps,\n useLocale\n} from 'react-aria-components';\nimport {centerPadding, colorScheme, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorScheme} from '@react-types/provider';\nimport {ColorSchemeContext} from './Provider';\nimport {createContext, forwardRef, MutableRefObject, ReactNode, useCallback, useContext, useState} from 'react';\nimport {DOMRef} from '@react-types/shared';\nimport {style} from '../style' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\n\nexport interface TooltipTriggerProps extends Omit<AriaTooltipTriggerComponentProps, 'children' | 'closeDelay'>, Pick<AriaTooltipProps, 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'> {\n /** The content of the tooltip. */\n children: ReactNode,\n /**\n * The placement of the element with respect to its anchor element.\n *\n * @default 'top'\n */\n placement?: 'start' | 'end' | 'right' | 'left' | 'top' | 'bottom'\n}\n\nexport interface TooltipProps extends Omit<AriaTooltipProps, 'children' | 'className' | 'style' | 'triggerRef' | 'UNSTABLE_portalContainer' | 'isEntering' | 'isExiting' | 'placement' | 'containerPadding' | 'offset' | 'crossOffset' | 'shouldFlip' | 'arrowBoundaryOffset' | 'isOpen' | 'defaultOpen' | 'onOpenChange'>, UnsafeStyles {\n /** The content of the tooltip. */\n children: ReactNode\n}\n\nconst tooltip = style<TooltipRenderProps & {colorScheme: ColorScheme | 'light dark' | null}>({\n ...colorScheme(),\n justifyContent: 'center',\n alignItems: 'center',\n maxWidth: 160,\n minHeight: 24,\n boxSizing: 'border-box',\n font: 'ui-sm',\n color: {\n default: 'gray-25',\n forcedColors: 'ButtonText'\n },\n borderWidth: {\n forcedColors: 1\n },\n borderStyle: {\n forcedColors: 'solid'\n },\n borderColor: {\n forcedColors: 'transparent'\n },\n backgroundColor: 'neutral',\n borderRadius: 'control',\n paddingX: 'edge-to-text',\n paddingY: centerPadding(),\n margin: 8,\n transition: 'default',\n transitionDuration: 200,\n transitionTimingFunction: {\n isExiting: 'in'\n },\n translateX: {\n placement: {\n left: {\n isEntering: 4,\n isExiting: 4\n },\n right: {\n isEntering: -4,\n isExiting: -4\n }\n }\n },\n translateY: {\n placement: {\n top: {\n isEntering: 4,\n isExiting: 4\n },\n bottom: {\n isEntering: -4,\n isExiting: -4\n }\n }\n },\n opacity: {\n isEntering: 0,\n isExiting: 0\n }\n});\n\nconst arrowStyles = style<TooltipRenderProps>({\n display: 'block',\n fill: 'gray-800',\n rotate: {\n placement: {\n top: 0,\n bottom: '180deg',\n left: '-90deg',\n right: '90deg'\n }\n },\n translateX: {\n placement: {\n left: '[-25%]',\n right: '[25%]'\n }\n }\n});\n\nlet InternalTooltipTriggerContext = createContext<Partial<TooltipTriggerProps>>({});\n\n/**\n * Display container for Tooltip content. Has a directional arrow dependent on its placement.\n */\nexport const Tooltip = forwardRef(function Tooltip(props: TooltipProps, ref: DOMRef<HTMLDivElement>) {\n let {children, UNSAFE_style, UNSAFE_className = ''} = props;\n let domRef = useDOMRef(ref);\n let {\n containerPadding,\n crossOffset,\n offset,\n placement = 'top',\n shouldFlip\n } = useContext(InternalTooltipTriggerContext);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n let [borderRadius, setBorderRadius] = useState(0);\n\n // TODO: should we pass through lang and dir props in RAC?\n let tooltipRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n let spectrumBorderRadius = window.getComputedStyle(el).borderRadius;\n if (spectrumBorderRadius !== '') {\n setBorderRadius(parseInt(spectrumBorderRadius, 10));\n }\n }\n }, [locale, direction, domRef]);\n\n return (\n <AriaTooltip\n {...props}\n arrowBoundaryOffset={borderRadius}\n containerPadding={containerPadding}\n crossOffset={crossOffset}\n offset={offset}\n placement={placement}\n shouldFlip={shouldFlip}\n ref={tooltipRef}\n style={UNSAFE_style}\n className={renderProps => UNSAFE_className + tooltip({...renderProps, colorScheme})}>\n {renderProps => (\n <>\n <OverlayArrow>\n <svg className={arrowStyles(renderProps)} xmlns=\"http://www.w3.org/2000/svg\" width=\"10\" height=\"5\" viewBox=\"0 0 10 5\">\n <path d=\"M4.29289 4.29289L0 0H10L5.70711 4.29289C5.31658 4.68342 4.68342 4.68342 4.29289 4.29289Z\" />\n </svg>\n </OverlayArrow>\n {children}\n </>\n )}\n </AriaTooltip>\n );\n});\n\n/**\n * TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing\n * the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip\n * relative to the trigger.\n */\nexport function TooltipTrigger(props: TooltipTriggerProps) {\n let {\n containerPadding,\n crossOffset,\n offset,\n placement,\n shouldFlip,\n ...triggerProps\n } = props;\n\n return (\n <AriaTooltipTrigger {...triggerProps}>\n <InternalTooltipTriggerContext.Provider\n value={{\n containerPadding: containerPadding,\n crossOffset: crossOffset,\n offset: offset,\n placement: placement,\n shouldFlip: shouldFlip\n }}>\n {props.children}\n </InternalTooltipTriggerContext.Provider>\n </AriaTooltipTrigger>\n );\n}\n\n\n// This is purely so that storybook generates the types for both Menu and MenuTrigger\ninterface ICombined extends Omit<TooltipProps, 'placement'>, TooltipTriggerProps {}\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function CombinedTooltip(props: ICombined) {\n return <div />;\n}\n"],"names":[],"version":3,"file":"Tooltip.css.map"}
|
package/dist/Tooltip.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmCD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DN,MAAM;;;;;;;;;;;;AAmBN,IAAI,oEAAgC,CAAA,GAAA,oBAAY,
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAmCD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DN,MAAM;;;;;;;;;;;;AAmBN,IAAI,oEAAgC,CAAA,GAAA,oBAAY,EAAgC,CAAC;AAK1E,MAAM,0DAAU,CAAA,GAAA,iBAAS,EAAE,SAAS,QAAQ,KAAmB,EAAE,GAA2B;IACjG,IAAI,YAAC,QAAQ,gBAAE,YAAY,oBAAE,mBAAmB,IAAG,GAAG;IACtD,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,oBACF,gBAAgB,eAChB,WAAW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AkB;gBAClB,aAAa;gBACb,QAAQ;gBACR,WAAW;gBACX,YAAY;YACd;sBACC,MAAM,QAAQ;;;AAIvB;AAMO,SAAS,0CAAgB,KAAgB;IAC9C,qBAAO,gBAAC;AACV","sources":["packages/@react-spectrum/s2/src/Tooltip.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 {\n Tooltip as AriaTooltip,\n TooltipProps as AriaTooltipProps,\n TooltipTrigger as AriaTooltipTrigger,\n TooltipTriggerComponentProps as AriaTooltipTriggerComponentProps,\n OverlayArrow,\n TooltipRenderProps,\n useLocale\n} from 'react-aria-components';\nimport {centerPadding, colorScheme, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorScheme} from '@react-types/provider';\nimport {ColorSchemeContext} from './Provider';\nimport {createContext, forwardRef, MutableRefObject, ReactNode, useCallback, useContext, useState} from 'react';\nimport {DOMRef} from '@react-types/shared';\nimport {style} from '../style' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\n\nexport interface TooltipTriggerProps extends Omit<AriaTooltipTriggerComponentProps, 'children' | 'closeDelay'>, Pick<AriaTooltipProps, 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'> {\n /** The content of the tooltip. */\n children: ReactNode,\n /**\n * The placement of the element with respect to its anchor element.\n *\n * @default 'top'\n */\n placement?: 'start' | 'end' | 'right' | 'left' | 'top' | 'bottom'\n}\n\nexport interface TooltipProps extends Omit<AriaTooltipProps, 'children' | 'className' | 'style' | 'triggerRef' | 'UNSTABLE_portalContainer' | 'isEntering' | 'isExiting' | 'placement' | 'containerPadding' | 'offset' | 'crossOffset' | 'shouldFlip' | 'arrowBoundaryOffset' | 'isOpen' | 'defaultOpen' | 'onOpenChange'>, UnsafeStyles {\n /** The content of the tooltip. */\n children: ReactNode\n}\n\nconst tooltip = style<TooltipRenderProps & {colorScheme: ColorScheme | 'light dark' | null}>({\n ...colorScheme(),\n justifyContent: 'center',\n alignItems: 'center',\n maxWidth: 160,\n minHeight: 24,\n boxSizing: 'border-box',\n font: 'ui-sm',\n color: {\n default: 'gray-25',\n forcedColors: 'ButtonText'\n },\n borderWidth: {\n forcedColors: 1\n },\n borderStyle: {\n forcedColors: 'solid'\n },\n borderColor: {\n forcedColors: 'transparent'\n },\n backgroundColor: 'neutral',\n borderRadius: 'control',\n paddingX: 'edge-to-text',\n paddingY: centerPadding(),\n margin: 8,\n transition: 'default',\n transitionDuration: 200,\n transitionTimingFunction: {\n isExiting: 'in'\n },\n translateX: {\n placement: {\n left: {\n isEntering: 4,\n isExiting: 4\n },\n right: {\n isEntering: -4,\n isExiting: -4\n }\n }\n },\n translateY: {\n placement: {\n top: {\n isEntering: 4,\n isExiting: 4\n },\n bottom: {\n isEntering: -4,\n isExiting: -4\n }\n }\n },\n opacity: {\n isEntering: 0,\n isExiting: 0\n }\n});\n\nconst arrowStyles = style<TooltipRenderProps>({\n display: 'block',\n fill: 'gray-800',\n rotate: {\n placement: {\n top: 0,\n bottom: '180deg',\n left: '-90deg',\n right: '90deg'\n }\n },\n translateX: {\n placement: {\n left: '[-25%]',\n right: '[25%]'\n }\n }\n});\n\nlet InternalTooltipTriggerContext = createContext<Partial<TooltipTriggerProps>>({});\n\n/**\n * Display container for Tooltip content. Has a directional arrow dependent on its placement.\n */\nexport const Tooltip = forwardRef(function Tooltip(props: TooltipProps, ref: DOMRef<HTMLDivElement>) {\n let {children, UNSAFE_style, UNSAFE_className = ''} = props;\n let domRef = useDOMRef(ref);\n let {\n containerPadding,\n crossOffset,\n offset,\n placement = 'top',\n shouldFlip\n } = useContext(InternalTooltipTriggerContext);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n let [borderRadius, setBorderRadius] = useState(0);\n\n // TODO: should we pass through lang and dir props in RAC?\n let tooltipRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n let spectrumBorderRadius = window.getComputedStyle(el).borderRadius;\n if (spectrumBorderRadius !== '') {\n setBorderRadius(parseInt(spectrumBorderRadius, 10));\n }\n }\n }, [locale, direction, domRef]);\n\n return (\n <AriaTooltip\n {...props}\n arrowBoundaryOffset={borderRadius}\n containerPadding={containerPadding}\n crossOffset={crossOffset}\n offset={offset}\n placement={placement}\n shouldFlip={shouldFlip}\n ref={tooltipRef}\n style={UNSAFE_style}\n className={renderProps => UNSAFE_className + tooltip({...renderProps, colorScheme})}>\n {renderProps => (\n <>\n <OverlayArrow>\n <svg className={arrowStyles(renderProps)} xmlns=\"http://www.w3.org/2000/svg\" width=\"10\" height=\"5\" viewBox=\"0 0 10 5\">\n <path d=\"M4.29289 4.29289L0 0H10L5.70711 4.29289C5.31658 4.68342 4.68342 4.68342 4.29289 4.29289Z\" />\n </svg>\n </OverlayArrow>\n {children}\n </>\n )}\n </AriaTooltip>\n );\n});\n\n/**\n * TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing\n * the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip\n * relative to the trigger.\n */\nexport function TooltipTrigger(props: TooltipTriggerProps) {\n let {\n containerPadding,\n crossOffset,\n offset,\n placement,\n shouldFlip,\n ...triggerProps\n } = props;\n\n return (\n <AriaTooltipTrigger {...triggerProps}>\n <InternalTooltipTriggerContext.Provider\n value={{\n containerPadding: containerPadding,\n crossOffset: crossOffset,\n offset: offset,\n placement: placement,\n shouldFlip: shouldFlip\n }}>\n {props.children}\n </InternalTooltipTriggerContext.Provider>\n </AriaTooltipTrigger>\n );\n}\n\n\n// This is purely so that storybook generates the types for both Menu and MenuTrigger\ninterface ICombined extends Omit<TooltipProps, 'placement'>, TooltipTriggerProps {}\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function CombinedTooltip(props: ICombined) {\n return <div />;\n}\n"],"names":[],"version":3,"file":"Tooltip.mjs.map"}
|
package/dist/TreeView.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var $af04e099a53d3e85$exports = require("./Checkbox.cjs");
|
|
|
6
6
|
var $1df9f1c9262ce5df$exports = require("./Chevron.cjs");
|
|
7
7
|
var $bde97c91243ed164$exports = require("../icons/Icon.cjs");
|
|
8
8
|
var $6367bc87eb7d24ad$exports = require("./Content.cjs");
|
|
9
|
+
var $ee7b4c497f520c08$exports = require("./utils.cjs");
|
|
9
10
|
var $6K4Mt$reactjsxruntime = require("react/jsx-runtime");
|
|
10
11
|
var $6K4Mt$reactariacomponents = require("react-aria-components");
|
|
11
12
|
var $6K4Mt$reactariautils = require("@react-aria/utils");
|
|
@@ -47,6 +48,7 @@ $parcel$export(module.exports, "TreeView", () => $8a2a97a0cb171e69$export$6940b0
|
|
|
47
48
|
|
|
48
49
|
|
|
49
50
|
|
|
51
|
+
|
|
50
52
|
const $8a2a97a0cb171e69$var$TreeRendererContext = /*#__PURE__*/ (0, $6K4Mt$react.createContext)({});
|
|
51
53
|
function $8a2a97a0cb171e69$var$useTreeRendererContext() {
|
|
52
54
|
return (0, $6K4Mt$react.useContext)($8a2a97a0cb171e69$var$TreeRendererContext);
|
|
@@ -86,15 +88,18 @@ const $8a2a97a0cb171e69$var$tree = function anonymous(props, overrides) {
|
|
|
86
88
|
};
|
|
87
89
|
function $8a2a97a0cb171e69$var$TreeView(props, ref) {
|
|
88
90
|
let { children: children, isDetached: isDetached, isEmphasized: isEmphasized } = props;
|
|
91
|
+
let scale = (0, $ee7b4c497f520c08$exports.useScale)();
|
|
89
92
|
let renderer;
|
|
90
93
|
if (typeof children === 'function') renderer = children;
|
|
91
94
|
let domRef = (0, $6K4Mt$reactspectrumutils.useDOMRef)(ref);
|
|
95
|
+
let rowHeight = isDetached ? 44 : 40;
|
|
96
|
+
if (scale === 'large') rowHeight = isDetached ? 54 : 50;
|
|
92
97
|
let layout = (0, $6K4Mt$react.useMemo)(()=>{
|
|
93
98
|
return new (0, $6K4Mt$reactariacomponents.UNSTABLE_ListLayout)({
|
|
94
|
-
rowHeight:
|
|
99
|
+
rowHeight: rowHeight
|
|
95
100
|
});
|
|
96
101
|
}, [
|
|
97
|
-
|
|
102
|
+
rowHeight
|
|
98
103
|
]);
|
|
99
104
|
return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.UNSTABLE_Virtualizer), {
|
|
100
105
|
layout: layout,
|
|
@@ -197,9 +202,10 @@ const $8a2a97a0cb171e69$var$treeCellGrid = function anonymous(props) {
|
|
|
197
202
|
let rules = " .";
|
|
198
203
|
rules += ' _3f';
|
|
199
204
|
rules += ' kb';
|
|
205
|
+
rules += ' jb';
|
|
200
206
|
rules += ' _4b';
|
|
201
207
|
rules += ' _5c';
|
|
202
|
-
rules += ' __l-
|
|
208
|
+
rules += ' __l-22ig44';
|
|
203
209
|
rules += ' __m-2wzs0i';
|
|
204
210
|
rules += ' __n-17p9pp0';
|
|
205
211
|
rules += ' b-19jpv4m';
|
|
@@ -257,7 +263,7 @@ const $8a2a97a0cb171e69$var$treeCellGrid = function anonymous(props) {
|
|
|
257
263
|
const $8a2a97a0cb171e69$var$treeCheckbox = " __e-5dolv4 __f-5dolv4 __g-5dolv4 __h-5dolv4 Be Ca Ga";
|
|
258
264
|
const $8a2a97a0cb171e69$var$treeIcon = " __e-qb5q8i __f-qb5q8i __g-qb5q8i __h-qb5q8i CG CbH -rwx0fg_d-b";
|
|
259
265
|
const $8a2a97a0cb171e69$var$treeContent = " __e-drkpd0 __f-drkpd0 __g-drkpd0 __h-drkpd0 _qa _tb __zb __Ab";
|
|
260
|
-
const $8a2a97a0cb171e69$var$treeActions = " __e-1k7szui __f-1k7szui __g-1k7szui __h-1k7szui
|
|
266
|
+
const $8a2a97a0cb171e69$var$treeActions = " __e-1k7szui __f-1k7szui __g-1k7szui __h-1k7szui Bb Cc";
|
|
261
267
|
const $8a2a97a0cb171e69$var$treeActionMenu = " __e-2npmt8 __f-2npmt8 __g-2npmt8 __h-2npmt8";
|
|
262
268
|
const $8a2a97a0cb171e69$var$cellFocus = {
|
|
263
269
|
outlineStyle: {
|
|
@@ -276,6 +282,7 @@ const $8a2a97a0cb171e69$export$6e77ea6719814e9c = (props1)=>{
|
|
|
276
282
|
let nestedRows;
|
|
277
283
|
let { renderer: renderer } = $8a2a97a0cb171e69$var$useTreeRendererContext();
|
|
278
284
|
let { isDetached: isDetached, isEmphasized: isEmphasized } = (0, $6K4Mt$react.useContext)($8a2a97a0cb171e69$var$InternalTreeContext);
|
|
285
|
+
let scale = (0, $ee7b4c497f520c08$exports.useScale)();
|
|
279
286
|
if (typeof children === 'string') content = /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), {
|
|
280
287
|
children: children
|
|
281
288
|
});
|
|
@@ -327,9 +334,11 @@ const $8a2a97a0cb171e69$export$6e77ea6719814e9c = (props1)=>{
|
|
|
327
334
|
/*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)("div", {
|
|
328
335
|
className: " __e-u3oh8l __f-u3oh8l __g-u3oh8l __h-u3oh8l k-19lybgs"
|
|
329
336
|
}),
|
|
330
|
-
|
|
337
|
+
/*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)($8a2a97a0cb171e69$var$ExpandableRowChevron, {
|
|
331
338
|
isDisabled: isDisabled,
|
|
332
|
-
isExpanded: isExpanded
|
|
339
|
+
isExpanded: isExpanded,
|
|
340
|
+
scale: scale,
|
|
341
|
+
isHidden: !(hasChildRows || hasChildItems)
|
|
333
342
|
}),
|
|
334
343
|
/*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.Provider), {
|
|
335
344
|
values: [
|
|
@@ -403,8 +412,12 @@ const $8a2a97a0cb171e69$var$expandButton = function anonymous(props) {
|
|
|
403
412
|
rules += ' __f-ajol1u';
|
|
404
413
|
rules += ' __g-ajol1u';
|
|
405
414
|
rules += ' __h-ajol1u';
|
|
406
|
-
|
|
407
|
-
|
|
415
|
+
if (props.isDisabled) {
|
|
416
|
+
rules += ' aa_____O';
|
|
417
|
+
rules += ' aj';
|
|
418
|
+
} else rules += ' a-17zqamw';
|
|
419
|
+
rules += ' j2';
|
|
420
|
+
rules += ' k2';
|
|
408
421
|
rules += ' _3d';
|
|
409
422
|
rules += ' __ba';
|
|
410
423
|
rules += ' _4b';
|
|
@@ -415,11 +428,17 @@ const $8a2a97a0cb171e69$var$expandButton = function anonymous(props) {
|
|
|
415
428
|
if (props.isRTL) rules += ' X-197phm7';
|
|
416
429
|
else rules += ' X-7hkt2a';
|
|
417
430
|
}
|
|
431
|
+
rules += ' Ha';
|
|
432
|
+
rules += ' Ia';
|
|
433
|
+
rules += ' Fa';
|
|
434
|
+
rules += ' Ga';
|
|
418
435
|
rules += ' _Sa';
|
|
419
436
|
rules += ' _U-375x7f';
|
|
420
437
|
rules += ' _Va';
|
|
421
438
|
rules += ' ba';
|
|
422
439
|
rules += ' zf';
|
|
440
|
+
rules += ' __V-yksgrp';
|
|
441
|
+
if (props.isHidden) rules += ' __Ib';
|
|
423
442
|
return rules;
|
|
424
443
|
};
|
|
425
444
|
function $8a2a97a0cb171e69$var$ExpandableRowChevron(props1) {
|
|
@@ -428,8 +447,9 @@ function $8a2a97a0cb171e69$var$ExpandableRowChevron(props1) {
|
|
|
428
447
|
...props1,
|
|
429
448
|
slot: 'chevron'
|
|
430
449
|
}, expandButtonRef, (0, $6K4Mt$reactariacomponents.ButtonContext));
|
|
431
|
-
let { isExpanded: isExpanded, isDisabled: isDisabled } = fullProps;
|
|
450
|
+
let { isExpanded: isExpanded, isDisabled: isDisabled, scale: scale, isHidden: isHidden } = fullProps;
|
|
432
451
|
let { direction: direction } = (0, $6K4Mt$reactaria.useLocale)();
|
|
452
|
+
isDisabled = isDisabled || isHidden;
|
|
433
453
|
return /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $6K4Mt$reactariacomponents.Button), {
|
|
434
454
|
...props1,
|
|
435
455
|
ref: ref,
|
|
@@ -440,7 +460,9 @@ function $8a2a97a0cb171e69$var$ExpandableRowChevron(props1) {
|
|
|
440
460
|
className: (renderProps)=>$8a2a97a0cb171e69$var$expandButton({
|
|
441
461
|
...renderProps,
|
|
442
462
|
isExpanded: isExpanded,
|
|
443
|
-
isRTL: direction === 'rtl'
|
|
463
|
+
isRTL: direction === 'rtl',
|
|
464
|
+
scale: scale,
|
|
465
|
+
isHidden: isHidden
|
|
444
466
|
}),
|
|
445
467
|
children: /*#__PURE__*/ (0, $6K4Mt$reactjsxruntime.jsx)((0, $1df9f1c9262ce5df$exports.default), {
|
|
446
468
|
className: function anonymous(props) {
|
package/dist/TreeView.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;AAuDD,MAAM,0DAAsB,CAAA,GAAA,0BAAY,EAA4B,CAAC;AAErE,SAAS;IACP,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB;AAGA,IAAI,0DAAsB,CAAA,GAAA,0BAAY,EAAkD,CAAC;AAEzF,4KAA4K;AAC5K,gHAAgH;AAChH,sIAAsI;AACtI,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBN,SAAS,+BAAS,KAAoB,EAAE,GAA2B;IACjE,IAAI,YAAC,QAAQ,cAAE,UAAU,gBAAE,YAAY,EAAC,GAAG;IAE3C,IAAI;IACJ,IAAI,OAAO,aAAa,YACtB,WAAW;IAGb,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IAEvB,IAAI,SAAS,CAAA,GAAA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AAqB,CAAA,GAAA,+BAAQ,OAAO,CAAC;QACrC,mBAAmB;QACnB,WAAW,CAAA,cAAe,mCAAa;gBAAC,GAAG,WAAW;4BAAE;gBAAY,OAAO,cAAc;YAAK;kBAC9F,cAAA,gCAAC,CAAA,GAAA,iCAAM;YACL,WAAW;;;;;;;;cAWR;2BAAC;YAAS;;;AAGrB;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,uBAAS,EAAE","sources":["packages/@react-spectrum/s2/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 {ActionButtonGroupContext} from './ActionButtonGroup';\nimport {ActionMenuContext} from './ActionMenu';\nimport {\n Button,\n ButtonContext,\n Collection,\n Provider,\n TreeItemProps as RACTreeItemProps,\n TreeProps as RACTreeProps,\n UNSTABLE_ListLayout,\n UNSTABLE_Tree,\n UNSTABLE_TreeItem,\n UNSTABLE_TreeItemContent,\n UNSTABLE_Virtualizer,\n useContextProps\n} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {Checkbox} from './Checkbox';\nimport Chevron from '../ui-icons/Chevron';\nimport {colorMix, fontRelative, lightDark, style} from '../style' with {type: 'macro'};\nimport {DOMRef, Key} from '@react-types/shared';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {IconContext} from './Icon';\nimport {isAndroid} from '@react-aria/utils';\nimport {raw} from '../style/style-macro' with {type: 'macro'};\nimport React, {createContext, forwardRef, isValidElement, JSXElementConstructor, ReactElement, useContext, useMemo, useRef} from 'react';\nimport {Text, TextContext} from './Content';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useLocale} from 'react-aria';\n\ninterface S2TreeProps {\n // Only detatched is supported right now with the current styles from Spectrum\n isDetached?: boolean,\n onAction?: (key: Key) => void,\n // not fully supported yet\n isEmphasized?: boolean\n}\n\nexport interface TreeViewProps extends Omit<RACTreeProps<any>, 'style' | 'className' | 'onRowAction' | 'selectionBehavior' | 'onScroll' | 'onCellAction' | 'dragAndDropHooks'>, UnsafeStyles, S2TreeProps {\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight\n}\n\nexport interface TreeViewItemProps<T extends object = object> extends Omit<RACTreeItemProps, 'className' | 'style'> {\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\nlet InternalTreeContext = createContext<{isDetached?: boolean, isEmphasized?: boolean}>({});\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({\n userSelect: 'none',\n minHeight: 0,\n minWidth: 0,\n width: 'full',\n overflow: 'auto',\n boxSizing: 'border-box',\n justifyContent: {\n isEmpty: 'center'\n },\n alignItems: {\n isEmpty: 'center'\n },\n height: {\n isEmpty: 'full'\n },\n '--indent': {\n type: 'width',\n value: 16\n }\n}, getAllowedOverrides({height: true}));\n\nfunction TreeView(props: TreeViewProps, ref: DOMRef<HTMLDivElement>) {\n let {children, isDetached, isEmphasized} = props;\n\n let renderer;\n if (typeof children === 'function') {\n renderer = children;\n }\n\n let domRef = useDOMRef(ref);\n\n let layout = useMemo(() => {\n return new UNSTABLE_ListLayout({\n rowHeight: isDetached ? 42 : 40\n });\n }, [isDetached]);\n\n return (\n <UNSTABLE_Virtualizer layout={layout}>\n <TreeRendererContext.Provider value={{renderer}}>\n <InternalTreeContext.Provider value={{isDetached, isEmphasized}}>\n <UNSTABLE_Tree\n {...props}\n className={({isEmpty}) => tree({isEmpty, isDetached}, props.styles)}\n selectionBehavior=\"toggle\"\n ref={domRef}>\n {props.children}\n </UNSTABLE_Tree>\n </InternalTreeContext.Provider>\n </TreeRendererContext.Provider>\n </UNSTABLE_Virtualizer>\n );\n}\n\nconst selectedBackground = lightDark(colorMix('gray-25', 'informative-900', 10), colorMix('gray-25', 'informative-700', 10));\nconst selectedActiveBackground = lightDark(colorMix('gray-25', 'informative-900', 15), colorMix('gray-25', 'informative-700', 15));\n\nconst rowBackgroundColor = {\n default: '--s2-container-bg',\n isFocusVisibleWithin: colorMix('gray-25', 'gray-900', 7),\n isHovered: colorMix('gray-25', 'gray-900', 7),\n isPressed: colorMix('gray-25', 'gray-900', 10),\n isSelected: {\n default: colorMix('gray-25', 'gray-900', 7),\n isEmphasized: selectedBackground,\n isFocusVisibleWithin: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n },\n isHovered: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n },\n isPressed: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n }\n },\n forcedColors: {\n default: 'Background'\n }\n} as const;\n\nconst treeRow = style({\n position: 'relative',\n display: 'flex',\n height: 40,\n width: 'full',\n boxSizing: 'border-box',\n font: 'ui',\n color: 'body',\n outlineStyle: 'none',\n cursor: {\n default: 'default',\n isLink: 'pointer'\n },\n '--rowBackgroundColor': {\n type: 'backgroundColor',\n value: rowBackgroundColor\n },\n '--rowFocusIndicatorColor': {\n type: 'outlineColor',\n value: {\n default: 'focus-ring',\n forcedColors: 'Highlight'\n }\n }\n});\n\n\nconst treeCellGrid = style({\n display: 'grid',\n width: 'full',\n alignContent: 'center',\n alignItems: 'center',\n gridTemplateColumns: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 40, '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 backgroundColor: '--rowBackgroundColor',\n paddingEnd: 4, // account for any focus rings on the last item in the cell\n color: {\n isDisabled: {\n default: 'gray-400',\n forcedColors: 'GrayText'\n }\n },\n '--rowSelectedBorderColor': {\n type: 'outlineColor',\n value: {\n default: 'gray-800',\n isFocusVisible: 'focus-ring',\n forcedColors: 'Highlight'\n }\n },\n '--rowForcedFocusBorderColor': {\n type: 'outlineColor',\n value: {\n default: 'focus-ring',\n forcedColors: 'Highlight'\n }\n },\n borderTopColor: {\n default: 'transparent',\n isSelected: {\n isFirst: 'transparent'\n },\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderInlineEndColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderBottomColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isNextSelected: 'transparent',\n isNextFocused: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderInlineStartColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderTopWidth: {\n default: 0,\n isFirst: {\n default: 1,\n forcedColors: 0\n },\n isDetached: 1\n },\n borderBottomWidth: {\n default: 0,\n isDetached: 1\n },\n borderStartWidth: {\n default: 0,\n isDetached: 1\n },\n borderEndWidth: {\n default: 0,\n isDetached: 1\n },\n borderRadius: {\n isDetached: 'default'\n },\n borderStyle: 'solid'\n});\n\nconst treeCheckbox = style({\n gridArea: 'checkbox',\n marginStart: 12,\n marginEnd: 0,\n paddingEnd: 0\n});\n\nconst treeIcon = style({\n gridArea: 'icon',\n marginEnd: 'text-to-visual',\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n});\n\nconst treeContent = style({\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: 2,\n marginEnd: 4\n});\n\nconst treeActionMenu = style({\n gridArea: 'actionmenu'\n});\n\nconst cellFocus = {\n outlineStyle: {\n default: 'none',\n isFocusVisible: 'solid'\n },\n outlineOffset: -2,\n outlineWidth: 2,\n outlineColor: 'focus-ring',\n borderRadius: '[6px]'\n} as const;\n\nconst treeRowFocusIndicator = raw(`\n &:before {\n content: \"\";\n display: inline-block;\n position: sticky;\n inset-inline-start: 0;\n width: 3px;\n height: 100%;\n margin-inline-end: -3px;\n margin-block-end: 1px;\n z-index: 3;\n background-color: var(--rowFocusIndicatorColor);\n }`\n);\n\n\nexport const TreeViewItem = <T extends object>(props: TreeViewItemProps<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 let {isDetached, isEmphasized} = useContext(InternalTreeContext);\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 <UNSTABLE_TreeItem\n {...props}\n className={(renderProps) => treeRow({...renderProps, isLink: !!href, isEmphasized}) + (renderProps.isFocusVisible && !isDetached ? ' ' + treeRowFocusIndicator : '')}>\n <UNSTABLE_TreeItemContent>\n {({isExpanded, hasChildRows, selectionMode, selectionBehavior, isDisabled, isFocusVisible, isSelected, id, state}) => {\n let isNextSelected = false;\n let isNextFocused = false;\n let keyAfter = state.collection.getKeyAfter(id);\n if (keyAfter != null) {\n isNextSelected = state.selectionManager.isSelected(keyAfter);\n }\n let isFirst = state.collection.getFirstKey() === id;\n return (\n <div className={treeCellGrid({isDisabled, isNextSelected, isSelected, isFirst, isNextFocused, isDetached})}>\n {selectionMode !== 'none' && selectionBehavior === 'toggle' && (\n // TODO: add transition?\n <div className={treeCheckbox}>\n <Checkbox\n isEmphasized={isEmphasized}\n slot=\"selection\" />\n </div>\n )}\n <div\n className={style({\n gridArea: 'level-padding',\n width: '[calc(calc(var(--tree-item-level, 0) - 1) * var(--indent))]'\n })} />\n {/* TODO: revisit when we do async loading, at the moment hasChildItems will only cause the chevron to be rendered, no aria/data attributes indicating the row's expandability are added */}\n {(hasChildRows || hasChildItems) && <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} />}\n <Provider\n values={[\n [TextContext, {styles: treeContent}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: treeIcon}),\n styles: style({size: fontRelative(20), flexShrink: 0})\n }],\n [ActionButtonGroupContext, {styles: treeActions}],\n [ActionMenuContext, {styles: treeActionMenu, isQuiet: true}]\n ]}>\n {content}\n </Provider>\n {isFocusVisible && isDetached && <div role=\"presentation\" className={style({...cellFocus, position: 'absolute', inset: 0})({isFocusVisible: true})} />}\n </div>\n );\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 cursor: 'default',\n transform: {\n isExpanded: {\n default: 'rotate(90deg)',\n isRTL: 'rotate(-90deg)'\n }\n },\n transition: 'default',\n backgroundColor: 'transparent',\n borderStyle: 'none'\n});\n\nfunction ExpandableRowChevron(props: ExpandableRowChevronProps) {\n let expandButtonRef = useRef<HTMLButtonElement>(null);\n let [fullProps, ref] = useContextProps({...props, slot: 'chevron'}, expandButtonRef, ButtonContext);\n let {isExpanded, isDisabled} = fullProps;\n let {direction} = useLocale();\n\n return (\n <Button\n {...props}\n ref={ref}\n slot=\"chevron\"\n // Override tabindex so that grid keyboard nav skips over it. Needs -1 so android talkback can actually \"focus\" it\n excludeFromTabOrder={isAndroid() && !isDisabled}\n preventFocusOnPress\n className={renderProps => expandButton({...renderProps, isExpanded, isRTL: direction === 'rtl'})}>\n <Chevron\n className={style({\n scale: {\n direction: {\n ltr: '1',\n rtl: '-1'\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n })({direction})} />\n </Button>\n );\n}\n\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nconst _TreeView = forwardRef(TreeView);\nexport {_TreeView as TreeView};\n"],"names":[],"version":3,"file":"TreeView.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwDD,MAAM,0DAAsB,CAAA,GAAA,0BAAY,EAA4B,CAAC;AAErE,SAAS;IACP,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB;AAGA,IAAI,0DAAsB,CAAA,GAAA,0BAAY,EAAkD,CAAC;AAEzF,4KAA4K;AAC5K,gHAAgH;AAChH,sIAAsI;AACtI,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBN,SAAS,+BAAS,KAAoB,EAAE,GAA2B;IACjE,IAAI,YAAC,QAAQ,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D,IAAI,CAAC,WAAW,IAAI,GAAG,CAAA,GAAA,0CAAc,EAAE;QAAC,GAAG,MAAK;QAAE,MAAM;IAAS,GAAG,iBAAiB,CAAA,GAAA,wCAAY;IACjG,IAAI,cAAC,UAAU,cAAE,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAC,GAAG;IAChD,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,0BAAQ;IAC1B,aAAa,cAAc;IAE3B,qBACE,gCAAC,CAAA,GAAA,iCAAK;QACH,GAAG,MAAK;QACT,KAAK;QACL,MAAK;QACL,kHAAkH;QAClH,qBAAqB,CAAA,GAAA,+BAAQ,OAAO,CAAC;QACrC,mBAAmB;QACnB,WAAW,CAAA,cAAe,mCAAa;gBAAC,GAAG,WAAW;4BAAE;gBAAY,OAAO,cAAc;uBAAO;0BAAO;YAAQ;kBAC/G,cAAA,gCAAC,CAAA,GAAA,iCAAM;YACL,WAAW;;;;;;;;cAWR;2BAAC;YAAS;;;AAGrB;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,uBAAS,EAAE","sources":["packages/@react-spectrum/s2/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 {ActionButtonGroupContext} from './ActionButtonGroup';\nimport {ActionMenuContext} from './ActionMenu';\nimport {\n Button,\n ButtonContext,\n Collection,\n Provider,\n TreeItemProps as RACTreeItemProps,\n TreeProps as RACTreeProps,\n UNSTABLE_ListLayout,\n UNSTABLE_Tree,\n UNSTABLE_TreeItem,\n UNSTABLE_TreeItemContent,\n UNSTABLE_Virtualizer,\n useContextProps\n} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {Checkbox} from './Checkbox';\nimport Chevron from '../ui-icons/Chevron';\nimport {colorMix, fontRelative, lightDark, style} from '../style' with {type: 'macro'};\nimport {DOMRef, Key} from '@react-types/shared';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {IconContext} from './Icon';\nimport {isAndroid} from '@react-aria/utils';\nimport {raw} from '../style/style-macro' with {type: 'macro'};\nimport React, {createContext, forwardRef, isValidElement, JSXElementConstructor, ReactElement, useContext, useMemo, useRef} from 'react';\nimport {Text, TextContext} from './Content';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useLocale} from 'react-aria';\nimport {useScale} from './utils';\n\ninterface S2TreeProps {\n // Only detatched is supported right now with the current styles from Spectrum\n isDetached?: boolean,\n onAction?: (key: Key) => void,\n // not fully supported yet\n isEmphasized?: boolean\n}\n\nexport interface TreeViewProps extends Omit<RACTreeProps<any>, 'style' | 'className' | 'onRowAction' | 'selectionBehavior' | 'onScroll' | 'onCellAction' | 'dragAndDropHooks'>, UnsafeStyles, S2TreeProps {\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight\n}\n\nexport interface TreeViewItemProps<T extends object = object> extends Omit<RACTreeItemProps, 'className' | 'style'> {\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\nlet InternalTreeContext = createContext<{isDetached?: boolean, isEmphasized?: boolean}>({});\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({\n userSelect: 'none',\n minHeight: 0,\n minWidth: 0,\n width: 'full',\n overflow: 'auto',\n boxSizing: 'border-box',\n justifyContent: {\n isEmpty: 'center'\n },\n alignItems: {\n isEmpty: 'center'\n },\n height: {\n isEmpty: 'full'\n },\n '--indent': {\n type: 'width',\n value: 16\n }\n}, getAllowedOverrides({height: true}));\n\nfunction TreeView(props: TreeViewProps, ref: DOMRef<HTMLDivElement>) {\n let {children, isDetached, isEmphasized} = props;\n let scale = useScale();\n\n let renderer;\n if (typeof children === 'function') {\n renderer = children;\n }\n\n let domRef = useDOMRef(ref);\n\n let rowHeight = isDetached ? 44 : 40;\n if (scale === 'large') {\n rowHeight = isDetached ? 54 : 50;\n }\n let layout = useMemo(() => {\n return new UNSTABLE_ListLayout({\n rowHeight\n });\n }, [rowHeight]);\n\n return (\n <UNSTABLE_Virtualizer layout={layout}>\n <TreeRendererContext.Provider value={{renderer}}>\n <InternalTreeContext.Provider value={{isDetached, isEmphasized}}>\n <UNSTABLE_Tree\n {...props}\n className={({isEmpty}) => tree({isEmpty, isDetached}, props.styles)}\n selectionBehavior=\"toggle\"\n ref={domRef}>\n {props.children}\n </UNSTABLE_Tree>\n </InternalTreeContext.Provider>\n </TreeRendererContext.Provider>\n </UNSTABLE_Virtualizer>\n );\n}\n\nconst selectedBackground = lightDark(colorMix('gray-25', 'informative-900', 10), colorMix('gray-25', 'informative-700', 10));\nconst selectedActiveBackground = lightDark(colorMix('gray-25', 'informative-900', 15), colorMix('gray-25', 'informative-700', 15));\n\nconst rowBackgroundColor = {\n default: '--s2-container-bg',\n isFocusVisibleWithin: colorMix('gray-25', 'gray-900', 7),\n isHovered: colorMix('gray-25', 'gray-900', 7),\n isPressed: colorMix('gray-25', 'gray-900', 10),\n isSelected: {\n default: colorMix('gray-25', 'gray-900', 7),\n isEmphasized: selectedBackground,\n isFocusVisibleWithin: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n },\n isHovered: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n },\n isPressed: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n }\n },\n forcedColors: {\n default: 'Background'\n }\n} as const;\n\nconst treeRow = style({\n position: 'relative',\n display: 'flex',\n height: 40,\n width: 'full',\n boxSizing: 'border-box',\n font: 'ui',\n color: 'body',\n outlineStyle: 'none',\n cursor: {\n default: 'default',\n isLink: 'pointer'\n },\n '--rowBackgroundColor': {\n type: 'backgroundColor',\n value: rowBackgroundColor\n },\n '--rowFocusIndicatorColor': {\n type: 'outlineColor',\n value: {\n default: 'focus-ring',\n forcedColors: 'Highlight'\n }\n }\n});\n\n\nconst treeCellGrid = style({\n display: 'grid',\n width: 'full',\n height: 'full',\n alignContent: 'center',\n alignItems: 'center',\n gridTemplateColumns: ['auto', 'auto', 'auto', 'auto', '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 backgroundColor: '--rowBackgroundColor',\n paddingEnd: 4, // account for any focus rings on the last item in the cell\n color: {\n isDisabled: {\n default: 'gray-400',\n forcedColors: 'GrayText'\n }\n },\n '--rowSelectedBorderColor': {\n type: 'outlineColor',\n value: {\n default: 'gray-800',\n isFocusVisible: 'focus-ring',\n forcedColors: 'Highlight'\n }\n },\n '--rowForcedFocusBorderColor': {\n type: 'outlineColor',\n value: {\n default: 'focus-ring',\n forcedColors: 'Highlight'\n }\n },\n borderTopColor: {\n default: 'transparent',\n isSelected: {\n isFirst: 'transparent'\n },\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderInlineEndColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderBottomColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isNextSelected: 'transparent',\n isNextFocused: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderInlineStartColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderTopWidth: {\n default: 0,\n isFirst: {\n default: 1,\n forcedColors: 0\n },\n isDetached: 1\n },\n borderBottomWidth: {\n default: 0,\n isDetached: 1\n },\n borderStartWidth: {\n default: 0,\n isDetached: 1\n },\n borderEndWidth: {\n default: 0,\n isDetached: 1\n },\n borderRadius: {\n isDetached: 'default'\n },\n borderStyle: 'solid'\n});\n\nconst treeCheckbox = style({\n gridArea: 'checkbox',\n marginStart: 12,\n marginEnd: 0,\n paddingEnd: 0\n});\n\nconst treeIcon = style({\n gridArea: 'icon',\n marginEnd: 'text-to-visual',\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n});\n\nconst treeContent = style({\n gridArea: 'content',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n overflow: 'hidden'\n});\n\nconst treeActions = style({\n gridArea: 'actions',\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: 2,\n marginEnd: 4\n});\n\nconst treeActionMenu = style({\n gridArea: 'actionmenu'\n});\n\nconst cellFocus = {\n outlineStyle: {\n default: 'none',\n isFocusVisible: 'solid'\n },\n outlineOffset: -2,\n outlineWidth: 2,\n outlineColor: 'focus-ring',\n borderRadius: '[6px]'\n} as const;\n\nconst treeRowFocusIndicator = raw(`\n &:before {\n content: \"\";\n display: inline-block;\n position: sticky;\n inset-inline-start: 0;\n width: 3px;\n height: 100%;\n margin-inline-end: -3px;\n margin-block-end: 1px;\n z-index: 3;\n background-color: var(--rowFocusIndicatorColor);\n }`\n);\n\n\nexport const TreeViewItem = <T extends object>(props: TreeViewItemProps<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 let {isDetached, isEmphasized} = useContext(InternalTreeContext);\n let scale = useScale();\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 <UNSTABLE_TreeItem\n {...props}\n className={(renderProps) => treeRow({...renderProps, isLink: !!href, isEmphasized}) + (renderProps.isFocusVisible && !isDetached ? ' ' + treeRowFocusIndicator : '')}>\n <UNSTABLE_TreeItemContent>\n {({isExpanded, hasChildRows, selectionMode, selectionBehavior, isDisabled, isFocusVisible, isSelected, id, state}) => {\n let isNextSelected = false;\n let isNextFocused = false;\n let keyAfter = state.collection.getKeyAfter(id);\n if (keyAfter != null) {\n isNextSelected = state.selectionManager.isSelected(keyAfter);\n }\n let isFirst = state.collection.getFirstKey() === id;\n return (\n <div className={treeCellGrid({isDisabled, isNextSelected, isSelected, isFirst, isNextFocused, isDetached})}>\n {selectionMode !== 'none' && selectionBehavior === 'toggle' && (\n // TODO: add transition?\n <div className={treeCheckbox}>\n <Checkbox\n isEmphasized={isEmphasized}\n slot=\"selection\" />\n </div>\n )}\n <div\n className={style({\n gridArea: 'level-padding',\n width: '[calc(calc(var(--tree-item-level, 0) - 1) * var(--indent))]'\n })} />\n {/* TODO: revisit when we do async loading, at the moment hasChildItems will only cause the chevron to be rendered, no aria/data attributes indicating the row's expandability are added */}\n <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} scale={scale} isHidden={!(hasChildRows || hasChildItems)} />\n <Provider\n values={[\n [TextContext, {styles: treeContent}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: treeIcon}),\n styles: style({size: fontRelative(20), flexShrink: 0})\n }],\n [ActionButtonGroupContext, {styles: treeActions}],\n [ActionMenuContext, {styles: treeActionMenu, isQuiet: true}]\n ]}>\n {content}\n </Provider>\n {isFocusVisible && isDetached && <div role=\"presentation\" className={style({...cellFocus, position: 'absolute', inset: 0})({isFocusVisible: true})} />}\n </div>\n );\n }}\n </UNSTABLE_TreeItemContent>\n {nestedRows}\n </UNSTABLE_TreeItem>\n );\n};\n\ninterface ExpandableRowChevronProps {\n isExpanded?: boolean,\n isDisabled?: boolean,\n isRTL?: boolean,\n scale: 'medium' | 'large',\n isHidden?: boolean\n}\n\nconst expandButton = style<ExpandableRowChevronProps>({\n gridArea: 'expand-button',\n color: {\n default: '[inherit]',\n isDisabled: {\n default: 'disabled',\n forcedColors: 'GrayText'\n }\n },\n height: 40,\n width: 40,\n display: 'flex',\n flexWrap: 'wrap',\n alignContent: 'center',\n justifyContent: 'center',\n outlineStyle: 'none',\n cursor: 'default',\n transform: {\n isExpanded: {\n default: 'rotate(90deg)',\n isRTL: 'rotate(-90deg)'\n }\n },\n padding: 0,\n transition: 'default',\n backgroundColor: 'transparent',\n borderStyle: 'none',\n disableTapHighlight: true,\n visibility: {\n isHidden: 'hidden'\n }\n});\n\nfunction ExpandableRowChevron(props: ExpandableRowChevronProps) {\n let expandButtonRef = useRef<HTMLButtonElement>(null);\n let [fullProps, ref] = useContextProps({...props, slot: 'chevron'}, expandButtonRef, ButtonContext);\n let {isExpanded, isDisabled, scale, isHidden} = fullProps;\n let {direction} = useLocale();\n isDisabled = isDisabled || isHidden;\n\n return (\n <Button\n {...props}\n ref={ref}\n slot=\"chevron\"\n // Override tabindex so that grid keyboard nav skips over it. Needs -1 so android talkback can actually \"focus\" it\n excludeFromTabOrder={isAndroid() && !isDisabled}\n preventFocusOnPress\n className={renderProps => expandButton({...renderProps, isExpanded, isRTL: direction === 'rtl', scale, isHidden})}>\n <Chevron\n className={style({\n scale: {\n direction: {\n ltr: '1',\n rtl: '-1'\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n })({direction})} />\n </Button>\n );\n}\n\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nconst _TreeView = forwardRef(TreeView);\nexport {_TreeView as TreeView};\n"],"names":[],"version":3,"file":"TreeView.cjs.map"}
|
package/dist/TreeView.css
CHANGED
|
@@ -28,10 +28,6 @@
|
|
|
28
28
|
position: relative;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
.j2 {
|
|
32
|
-
height: calc(2.5rem * var(--s2-scale));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
31
|
.__ra {
|
|
36
32
|
box-sizing: border-box;
|
|
37
33
|
}
|
|
@@ -94,12 +90,16 @@
|
|
|
94
90
|
width: 100%;
|
|
95
91
|
}
|
|
96
92
|
|
|
93
|
+
.jb {
|
|
94
|
+
height: 100%;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
97
|
._5c {
|
|
98
98
|
align-items: center;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
.__l-
|
|
102
|
-
grid-template-columns:
|
|
101
|
+
.__l-22ig44 {
|
|
102
|
+
grid-template-columns: auto auto auto auto auto 1fr minmax(0, auto) auto;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
.__m-2wzs0i {
|
|
@@ -118,10 +118,6 @@
|
|
|
118
118
|
padding-inline-end: .25rem;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
.aj {
|
|
122
|
-
color: var(--lightningcss-light, #c6c6c6) var(--lightningcss-dark, #444);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
121
|
.-fm23a5_c-n {
|
|
126
122
|
--rowSelectedBorderColor: var(--lightningcss-light, #292929) var(--lightningcss-dark, #dbdbdb);
|
|
127
123
|
}
|
|
@@ -242,10 +238,6 @@
|
|
|
242
238
|
margin-inline-end: 0;
|
|
243
239
|
}
|
|
244
240
|
|
|
245
|
-
.Ga {
|
|
246
|
-
padding-inline-end: 0;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
241
|
.__e-qb5q8i {
|
|
250
242
|
grid-column-start: icon;
|
|
251
243
|
}
|
|
@@ -314,10 +306,6 @@
|
|
|
314
306
|
grid-row-end: actions;
|
|
315
307
|
}
|
|
316
308
|
|
|
317
|
-
.__d-3t1x {
|
|
318
|
-
flex-grow: 0;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
309
|
.Bb {
|
|
322
310
|
margin-inline-start: .125rem;
|
|
323
311
|
}
|
|
@@ -455,12 +443,20 @@
|
|
|
455
443
|
grid-row-end: expand-button;
|
|
456
444
|
}
|
|
457
445
|
|
|
458
|
-
.
|
|
459
|
-
|
|
446
|
+
.a-17zqamw {
|
|
447
|
+
color: inherit;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.aj {
|
|
451
|
+
color: var(--lightningcss-light, #c6c6c6) var(--lightningcss-dark, #444);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.j2 {
|
|
455
|
+
height: calc(2.5rem * var(--s2-scale));
|
|
460
456
|
}
|
|
461
457
|
|
|
462
|
-
.
|
|
463
|
-
|
|
458
|
+
.k2 {
|
|
459
|
+
width: calc(2.5rem * var(--s2-scale));
|
|
464
460
|
}
|
|
465
461
|
|
|
466
462
|
._3d {
|
|
@@ -495,6 +491,22 @@
|
|
|
495
491
|
transform: rotate(-90deg);
|
|
496
492
|
}
|
|
497
493
|
|
|
494
|
+
.Ha {
|
|
495
|
+
padding-top: 0;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.Ia {
|
|
499
|
+
padding-bottom: 0;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.Fa {
|
|
503
|
+
padding-inline-start: 0;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.Ga {
|
|
507
|
+
padding-inline-end: 0;
|
|
508
|
+
}
|
|
509
|
+
|
|
498
510
|
._Sa {
|
|
499
511
|
transition-property: color, background-color, var(--gp), border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter;
|
|
500
512
|
}
|
|
@@ -515,6 +527,14 @@
|
|
|
515
527
|
border-style: none;
|
|
516
528
|
}
|
|
517
529
|
|
|
530
|
+
.__V-yksgrp {
|
|
531
|
+
-webkit-tap-highlight-color: #0000;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.__Ib {
|
|
535
|
+
visibility: hidden;
|
|
536
|
+
}
|
|
537
|
+
|
|
518
538
|
.V-375khm {
|
|
519
539
|
--scaleX: 1;
|
|
520
540
|
scale: var(--scaleX, 1) var(--scaleY, 1);
|
|
@@ -608,10 +628,6 @@
|
|
|
608
628
|
--rowFocusIndicatorColor: Highlight;
|
|
609
629
|
}
|
|
610
630
|
|
|
611
|
-
.aa_____O {
|
|
612
|
-
color: graytext;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
631
|
.-fm23a5_c-a_____M {
|
|
616
632
|
--rowSelectedBorderColor: Highlight;
|
|
617
633
|
}
|
|
@@ -627,6 +643,10 @@
|
|
|
627
643
|
.ca_____M {
|
|
628
644
|
outline-color: highlight;
|
|
629
645
|
}
|
|
646
|
+
|
|
647
|
+
.aa_____O {
|
|
648
|
+
color: graytext;
|
|
649
|
+
}
|
|
630
650
|
}
|
|
631
651
|
}
|
|
632
652
|
/*# sourceMappingURL=TreeView.css.map */
|
package/dist/TreeView.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AC6Ea;EAAA;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAoFG;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA2BK;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;E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AA;;;;IA2O8D","sources":["56ed516746d0036e","packages/@react-spectrum/s2/src/TreeView.tsx"],"sourcesContent":["@import \"9f0cb543acce7895\";\n@import \"1efe6bd9df94f465\";\n@import \"bdf071bf66df1ce3\";\n@import \"0330b2193d88b3df\";\n@import \"888ae06603582201\";\n@import \"73010de75c5ff12a\";\n@import \"6f9cf7ba5fc61169\";\n@import \"e3d8cbff54f98abf\";\n@import \"5ce50fd84b82affa\";\n@import \"e7f15e944ad73835\";\n@import \"17e37b578317afa7\";\n@import \"664b85d9761c64e2\";\n@import \"b6201a1b57a21b4e\";\n@import \"73100caf88a76f92\";\n","/*\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 {ActionButtonGroupContext} from './ActionButtonGroup';\nimport {ActionMenuContext} from './ActionMenu';\nimport {\n Button,\n ButtonContext,\n Collection,\n Provider,\n TreeItemProps as RACTreeItemProps,\n TreeProps as RACTreeProps,\n UNSTABLE_ListLayout,\n UNSTABLE_Tree,\n UNSTABLE_TreeItem,\n UNSTABLE_TreeItemContent,\n UNSTABLE_Virtualizer,\n useContextProps\n} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {Checkbox} from './Checkbox';\nimport Chevron from '../ui-icons/Chevron';\nimport {colorMix, fontRelative, lightDark, style} from '../style' with {type: 'macro'};\nimport {DOMRef, Key} from '@react-types/shared';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {IconContext} from './Icon';\nimport {isAndroid} from '@react-aria/utils';\nimport {raw} from '../style/style-macro' with {type: 'macro'};\nimport React, {createContext, forwardRef, isValidElement, JSXElementConstructor, ReactElement, useContext, useMemo, useRef} from 'react';\nimport {Text, TextContext} from './Content';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useLocale} from 'react-aria';\n\ninterface S2TreeProps {\n // Only detatched is supported right now with the current styles from Spectrum\n isDetached?: boolean,\n onAction?: (key: Key) => void,\n // not fully supported yet\n isEmphasized?: boolean\n}\n\nexport interface TreeViewProps extends Omit<RACTreeProps<any>, 'style' | 'className' | 'onRowAction' | 'selectionBehavior' | 'onScroll' | 'onCellAction' | 'dragAndDropHooks'>, UnsafeStyles, S2TreeProps {\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight\n}\n\nexport interface TreeViewItemProps<T extends object = object> extends Omit<RACTreeItemProps, 'className' | 'style'> {\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\nlet InternalTreeContext = createContext<{isDetached?: boolean, isEmphasized?: boolean}>({});\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({\n userSelect: 'none',\n minHeight: 0,\n minWidth: 0,\n width: 'full',\n overflow: 'auto',\n boxSizing: 'border-box',\n justifyContent: {\n isEmpty: 'center'\n },\n alignItems: {\n isEmpty: 'center'\n },\n height: {\n isEmpty: 'full'\n },\n '--indent': {\n type: 'width',\n value: 16\n }\n}, getAllowedOverrides({height: true}));\n\nfunction TreeView(props: TreeViewProps, ref: DOMRef<HTMLDivElement>) {\n let {children, isDetached, isEmphasized} = props;\n\n let renderer;\n if (typeof children === 'function') {\n renderer = children;\n }\n\n let domRef = useDOMRef(ref);\n\n let layout = useMemo(() => {\n return new UNSTABLE_ListLayout({\n rowHeight: isDetached ? 42 : 40\n });\n }, [isDetached]);\n\n return (\n <UNSTABLE_Virtualizer layout={layout}>\n <TreeRendererContext.Provider value={{renderer}}>\n <InternalTreeContext.Provider value={{isDetached, isEmphasized}}>\n <UNSTABLE_Tree\n {...props}\n className={({isEmpty}) => tree({isEmpty, isDetached}, props.styles)}\n selectionBehavior=\"toggle\"\n ref={domRef}>\n {props.children}\n </UNSTABLE_Tree>\n </InternalTreeContext.Provider>\n </TreeRendererContext.Provider>\n </UNSTABLE_Virtualizer>\n );\n}\n\nconst selectedBackground = lightDark(colorMix('gray-25', 'informative-900', 10), colorMix('gray-25', 'informative-700', 10));\nconst selectedActiveBackground = lightDark(colorMix('gray-25', 'informative-900', 15), colorMix('gray-25', 'informative-700', 15));\n\nconst rowBackgroundColor = {\n default: '--s2-container-bg',\n isFocusVisibleWithin: colorMix('gray-25', 'gray-900', 7),\n isHovered: colorMix('gray-25', 'gray-900', 7),\n isPressed: colorMix('gray-25', 'gray-900', 10),\n isSelected: {\n default: colorMix('gray-25', 'gray-900', 7),\n isEmphasized: selectedBackground,\n isFocusVisibleWithin: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n },\n isHovered: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n },\n isPressed: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n }\n },\n forcedColors: {\n default: 'Background'\n }\n} as const;\n\nconst treeRow = style({\n position: 'relative',\n display: 'flex',\n height: 40,\n width: 'full',\n boxSizing: 'border-box',\n font: 'ui',\n color: 'body',\n outlineStyle: 'none',\n cursor: {\n default: 'default',\n isLink: 'pointer'\n },\n '--rowBackgroundColor': {\n type: 'backgroundColor',\n value: rowBackgroundColor\n },\n '--rowFocusIndicatorColor': {\n type: 'outlineColor',\n value: {\n default: 'focus-ring',\n forcedColors: 'Highlight'\n }\n }\n});\n\n\nconst treeCellGrid = style({\n display: 'grid',\n width: 'full',\n alignContent: 'center',\n alignItems: 'center',\n gridTemplateColumns: ['minmax(0, auto)', 'minmax(0, auto)', 'minmax(0, auto)', 40, '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 backgroundColor: '--rowBackgroundColor',\n paddingEnd: 4, // account for any focus rings on the last item in the cell\n color: {\n isDisabled: {\n default: 'gray-400',\n forcedColors: 'GrayText'\n }\n },\n '--rowSelectedBorderColor': {\n type: 'outlineColor',\n value: {\n default: 'gray-800',\n isFocusVisible: 'focus-ring',\n forcedColors: 'Highlight'\n }\n },\n '--rowForcedFocusBorderColor': {\n type: 'outlineColor',\n value: {\n default: 'focus-ring',\n forcedColors: 'Highlight'\n }\n },\n borderTopColor: {\n default: 'transparent',\n isSelected: {\n isFirst: 'transparent'\n },\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderInlineEndColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderBottomColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isNextSelected: 'transparent',\n isNextFocused: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderInlineStartColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderTopWidth: {\n default: 0,\n isFirst: {\n default: 1,\n forcedColors: 0\n },\n isDetached: 1\n },\n borderBottomWidth: {\n default: 0,\n isDetached: 1\n },\n borderStartWidth: {\n default: 0,\n isDetached: 1\n },\n borderEndWidth: {\n default: 0,\n isDetached: 1\n },\n borderRadius: {\n isDetached: 'default'\n },\n borderStyle: 'solid'\n});\n\nconst treeCheckbox = style({\n gridArea: 'checkbox',\n marginStart: 12,\n marginEnd: 0,\n paddingEnd: 0\n});\n\nconst treeIcon = style({\n gridArea: 'icon',\n marginEnd: 'text-to-visual',\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n});\n\nconst treeContent = style({\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: 2,\n marginEnd: 4\n});\n\nconst treeActionMenu = style({\n gridArea: 'actionmenu'\n});\n\nconst cellFocus = {\n outlineStyle: {\n default: 'none',\n isFocusVisible: 'solid'\n },\n outlineOffset: -2,\n outlineWidth: 2,\n outlineColor: 'focus-ring',\n borderRadius: '[6px]'\n} as const;\n\nconst treeRowFocusIndicator = raw(`\n &:before {\n content: \"\";\n display: inline-block;\n position: sticky;\n inset-inline-start: 0;\n width: 3px;\n height: 100%;\n margin-inline-end: -3px;\n margin-block-end: 1px;\n z-index: 3;\n background-color: var(--rowFocusIndicatorColor);\n }`\n);\n\n\nexport const TreeViewItem = <T extends object>(props: TreeViewItemProps<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 let {isDetached, isEmphasized} = useContext(InternalTreeContext);\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 <UNSTABLE_TreeItem\n {...props}\n className={(renderProps) => treeRow({...renderProps, isLink: !!href, isEmphasized}) + (renderProps.isFocusVisible && !isDetached ? ' ' + treeRowFocusIndicator : '')}>\n <UNSTABLE_TreeItemContent>\n {({isExpanded, hasChildRows, selectionMode, selectionBehavior, isDisabled, isFocusVisible, isSelected, id, state}) => {\n let isNextSelected = false;\n let isNextFocused = false;\n let keyAfter = state.collection.getKeyAfter(id);\n if (keyAfter != null) {\n isNextSelected = state.selectionManager.isSelected(keyAfter);\n }\n let isFirst = state.collection.getFirstKey() === id;\n return (\n <div className={treeCellGrid({isDisabled, isNextSelected, isSelected, isFirst, isNextFocused, isDetached})}>\n {selectionMode !== 'none' && selectionBehavior === 'toggle' && (\n // TODO: add transition?\n <div className={treeCheckbox}>\n <Checkbox\n isEmphasized={isEmphasized}\n slot=\"selection\" />\n </div>\n )}\n <div\n className={style({\n gridArea: 'level-padding',\n width: '[calc(calc(var(--tree-item-level, 0) - 1) * var(--indent))]'\n })} />\n {/* TODO: revisit when we do async loading, at the moment hasChildItems will only cause the chevron to be rendered, no aria/data attributes indicating the row's expandability are added */}\n {(hasChildRows || hasChildItems) && <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} />}\n <Provider\n values={[\n [TextContext, {styles: treeContent}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: treeIcon}),\n styles: style({size: fontRelative(20), flexShrink: 0})\n }],\n [ActionButtonGroupContext, {styles: treeActions}],\n [ActionMenuContext, {styles: treeActionMenu, isQuiet: true}]\n ]}>\n {content}\n </Provider>\n {isFocusVisible && isDetached && <div role=\"presentation\" className={style({...cellFocus, position: 'absolute', inset: 0})({isFocusVisible: true})} />}\n </div>\n );\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 cursor: 'default',\n transform: {\n isExpanded: {\n default: 'rotate(90deg)',\n isRTL: 'rotate(-90deg)'\n }\n },\n transition: 'default',\n backgroundColor: 'transparent',\n borderStyle: 'none'\n});\n\nfunction ExpandableRowChevron(props: ExpandableRowChevronProps) {\n let expandButtonRef = useRef<HTMLButtonElement>(null);\n let [fullProps, ref] = useContextProps({...props, slot: 'chevron'}, expandButtonRef, ButtonContext);\n let {isExpanded, isDisabled} = fullProps;\n let {direction} = useLocale();\n\n return (\n <Button\n {...props}\n ref={ref}\n slot=\"chevron\"\n // Override tabindex so that grid keyboard nav skips over it. Needs -1 so android talkback can actually \"focus\" it\n excludeFromTabOrder={isAndroid() && !isDisabled}\n preventFocusOnPress\n className={renderProps => expandButton({...renderProps, isExpanded, isRTL: direction === 'rtl'})}>\n <Chevron\n className={style({\n scale: {\n direction: {\n ltr: '1',\n rtl: '-1'\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n })({direction})} />\n </Button>\n );\n}\n\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nconst _TreeView = forwardRef(TreeView);\nexport {_TreeView as TreeView};\n"],"names":[],"version":3,"file":"TreeView.css.map"}
|
|
1
|
+
{"mappings":"AC8Ea;EAAA;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAyFG;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA2BK;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;E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AAA;;;;IA2O8D;;;;IAkB9D","sources":["56ed516746d0036e","packages/@react-spectrum/s2/src/TreeView.tsx"],"sourcesContent":["@import \"9f0cb543acce7895\";\n@import \"1efe6bd9df94f465\";\n@import \"bdf071bf66df1ce3\";\n@import \"0330b2193d88b3df\";\n@import \"888ae06603582201\";\n@import \"73010de75c5ff12a\";\n@import \"6f9cf7ba5fc61169\";\n@import \"e3d8cbff54f98abf\";\n@import \"5ce50fd84b82affa\";\n@import \"e7f15e944ad73835\";\n@import \"17e37b578317afa7\";\n@import \"664b85d9761c64e2\";\n@import \"b6201a1b57a21b4e\";\n@import \"73100caf88a76f92\";\n","/*\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 {ActionButtonGroupContext} from './ActionButtonGroup';\nimport {ActionMenuContext} from './ActionMenu';\nimport {\n Button,\n ButtonContext,\n Collection,\n Provider,\n TreeItemProps as RACTreeItemProps,\n TreeProps as RACTreeProps,\n UNSTABLE_ListLayout,\n UNSTABLE_Tree,\n UNSTABLE_TreeItem,\n UNSTABLE_TreeItemContent,\n UNSTABLE_Virtualizer,\n useContextProps\n} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {Checkbox} from './Checkbox';\nimport Chevron from '../ui-icons/Chevron';\nimport {colorMix, fontRelative, lightDark, style} from '../style' with {type: 'macro'};\nimport {DOMRef, Key} from '@react-types/shared';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {IconContext} from './Icon';\nimport {isAndroid} from '@react-aria/utils';\nimport {raw} from '../style/style-macro' with {type: 'macro'};\nimport React, {createContext, forwardRef, isValidElement, JSXElementConstructor, ReactElement, useContext, useMemo, useRef} from 'react';\nimport {Text, TextContext} from './Content';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useLocale} from 'react-aria';\nimport {useScale} from './utils';\n\ninterface S2TreeProps {\n // Only detatched is supported right now with the current styles from Spectrum\n isDetached?: boolean,\n onAction?: (key: Key) => void,\n // not fully supported yet\n isEmphasized?: boolean\n}\n\nexport interface TreeViewProps extends Omit<RACTreeProps<any>, 'style' | 'className' | 'onRowAction' | 'selectionBehavior' | 'onScroll' | 'onCellAction' | 'dragAndDropHooks'>, UnsafeStyles, S2TreeProps {\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight\n}\n\nexport interface TreeViewItemProps<T extends object = object> extends Omit<RACTreeItemProps, 'className' | 'style'> {\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\nlet InternalTreeContext = createContext<{isDetached?: boolean, isEmphasized?: boolean}>({});\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({\n userSelect: 'none',\n minHeight: 0,\n minWidth: 0,\n width: 'full',\n overflow: 'auto',\n boxSizing: 'border-box',\n justifyContent: {\n isEmpty: 'center'\n },\n alignItems: {\n isEmpty: 'center'\n },\n height: {\n isEmpty: 'full'\n },\n '--indent': {\n type: 'width',\n value: 16\n }\n}, getAllowedOverrides({height: true}));\n\nfunction TreeView(props: TreeViewProps, ref: DOMRef<HTMLDivElement>) {\n let {children, isDetached, isEmphasized} = props;\n let scale = useScale();\n\n let renderer;\n if (typeof children === 'function') {\n renderer = children;\n }\n\n let domRef = useDOMRef(ref);\n\n let rowHeight = isDetached ? 44 : 40;\n if (scale === 'large') {\n rowHeight = isDetached ? 54 : 50;\n }\n let layout = useMemo(() => {\n return new UNSTABLE_ListLayout({\n rowHeight\n });\n }, [rowHeight]);\n\n return (\n <UNSTABLE_Virtualizer layout={layout}>\n <TreeRendererContext.Provider value={{renderer}}>\n <InternalTreeContext.Provider value={{isDetached, isEmphasized}}>\n <UNSTABLE_Tree\n {...props}\n className={({isEmpty}) => tree({isEmpty, isDetached}, props.styles)}\n selectionBehavior=\"toggle\"\n ref={domRef}>\n {props.children}\n </UNSTABLE_Tree>\n </InternalTreeContext.Provider>\n </TreeRendererContext.Provider>\n </UNSTABLE_Virtualizer>\n );\n}\n\nconst selectedBackground = lightDark(colorMix('gray-25', 'informative-900', 10), colorMix('gray-25', 'informative-700', 10));\nconst selectedActiveBackground = lightDark(colorMix('gray-25', 'informative-900', 15), colorMix('gray-25', 'informative-700', 15));\n\nconst rowBackgroundColor = {\n default: '--s2-container-bg',\n isFocusVisibleWithin: colorMix('gray-25', 'gray-900', 7),\n isHovered: colorMix('gray-25', 'gray-900', 7),\n isPressed: colorMix('gray-25', 'gray-900', 10),\n isSelected: {\n default: colorMix('gray-25', 'gray-900', 7),\n isEmphasized: selectedBackground,\n isFocusVisibleWithin: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n },\n isHovered: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n },\n isPressed: {\n default: colorMix('gray-25', 'gray-900', 10),\n isEmphasized: selectedActiveBackground\n }\n },\n forcedColors: {\n default: 'Background'\n }\n} as const;\n\nconst treeRow = style({\n position: 'relative',\n display: 'flex',\n height: 40,\n width: 'full',\n boxSizing: 'border-box',\n font: 'ui',\n color: 'body',\n outlineStyle: 'none',\n cursor: {\n default: 'default',\n isLink: 'pointer'\n },\n '--rowBackgroundColor': {\n type: 'backgroundColor',\n value: rowBackgroundColor\n },\n '--rowFocusIndicatorColor': {\n type: 'outlineColor',\n value: {\n default: 'focus-ring',\n forcedColors: 'Highlight'\n }\n }\n});\n\n\nconst treeCellGrid = style({\n display: 'grid',\n width: 'full',\n height: 'full',\n alignContent: 'center',\n alignItems: 'center',\n gridTemplateColumns: ['auto', 'auto', 'auto', 'auto', '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 backgroundColor: '--rowBackgroundColor',\n paddingEnd: 4, // account for any focus rings on the last item in the cell\n color: {\n isDisabled: {\n default: 'gray-400',\n forcedColors: 'GrayText'\n }\n },\n '--rowSelectedBorderColor': {\n type: 'outlineColor',\n value: {\n default: 'gray-800',\n isFocusVisible: 'focus-ring',\n forcedColors: 'Highlight'\n }\n },\n '--rowForcedFocusBorderColor': {\n type: 'outlineColor',\n value: {\n default: 'focus-ring',\n forcedColors: 'Highlight'\n }\n },\n borderTopColor: {\n default: 'transparent',\n isSelected: {\n isFirst: 'transparent'\n },\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderInlineEndColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderBottomColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isNextSelected: 'transparent',\n isNextFocused: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderInlineStartColor: {\n default: 'transparent',\n isSelected: 'transparent',\n isDetached: {\n default: 'transparent',\n isSelected: '--rowSelectedBorderColor'\n }\n },\n borderTopWidth: {\n default: 0,\n isFirst: {\n default: 1,\n forcedColors: 0\n },\n isDetached: 1\n },\n borderBottomWidth: {\n default: 0,\n isDetached: 1\n },\n borderStartWidth: {\n default: 0,\n isDetached: 1\n },\n borderEndWidth: {\n default: 0,\n isDetached: 1\n },\n borderRadius: {\n isDetached: 'default'\n },\n borderStyle: 'solid'\n});\n\nconst treeCheckbox = style({\n gridArea: 'checkbox',\n marginStart: 12,\n marginEnd: 0,\n paddingEnd: 0\n});\n\nconst treeIcon = style({\n gridArea: 'icon',\n marginEnd: 'text-to-visual',\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n});\n\nconst treeContent = style({\n gridArea: 'content',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n overflow: 'hidden'\n});\n\nconst treeActions = style({\n gridArea: 'actions',\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: 2,\n marginEnd: 4\n});\n\nconst treeActionMenu = style({\n gridArea: 'actionmenu'\n});\n\nconst cellFocus = {\n outlineStyle: {\n default: 'none',\n isFocusVisible: 'solid'\n },\n outlineOffset: -2,\n outlineWidth: 2,\n outlineColor: 'focus-ring',\n borderRadius: '[6px]'\n} as const;\n\nconst treeRowFocusIndicator = raw(`\n &:before {\n content: \"\";\n display: inline-block;\n position: sticky;\n inset-inline-start: 0;\n width: 3px;\n height: 100%;\n margin-inline-end: -3px;\n margin-block-end: 1px;\n z-index: 3;\n background-color: var(--rowFocusIndicatorColor);\n }`\n);\n\n\nexport const TreeViewItem = <T extends object>(props: TreeViewItemProps<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 let {isDetached, isEmphasized} = useContext(InternalTreeContext);\n let scale = useScale();\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 <UNSTABLE_TreeItem\n {...props}\n className={(renderProps) => treeRow({...renderProps, isLink: !!href, isEmphasized}) + (renderProps.isFocusVisible && !isDetached ? ' ' + treeRowFocusIndicator : '')}>\n <UNSTABLE_TreeItemContent>\n {({isExpanded, hasChildRows, selectionMode, selectionBehavior, isDisabled, isFocusVisible, isSelected, id, state}) => {\n let isNextSelected = false;\n let isNextFocused = false;\n let keyAfter = state.collection.getKeyAfter(id);\n if (keyAfter != null) {\n isNextSelected = state.selectionManager.isSelected(keyAfter);\n }\n let isFirst = state.collection.getFirstKey() === id;\n return (\n <div className={treeCellGrid({isDisabled, isNextSelected, isSelected, isFirst, isNextFocused, isDetached})}>\n {selectionMode !== 'none' && selectionBehavior === 'toggle' && (\n // TODO: add transition?\n <div className={treeCheckbox}>\n <Checkbox\n isEmphasized={isEmphasized}\n slot=\"selection\" />\n </div>\n )}\n <div\n className={style({\n gridArea: 'level-padding',\n width: '[calc(calc(var(--tree-item-level, 0) - 1) * var(--indent))]'\n })} />\n {/* TODO: revisit when we do async loading, at the moment hasChildItems will only cause the chevron to be rendered, no aria/data attributes indicating the row's expandability are added */}\n <ExpandableRowChevron isDisabled={isDisabled} isExpanded={isExpanded} scale={scale} isHidden={!(hasChildRows || hasChildItems)} />\n <Provider\n values={[\n [TextContext, {styles: treeContent}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: treeIcon}),\n styles: style({size: fontRelative(20), flexShrink: 0})\n }],\n [ActionButtonGroupContext, {styles: treeActions}],\n [ActionMenuContext, {styles: treeActionMenu, isQuiet: true}]\n ]}>\n {content}\n </Provider>\n {isFocusVisible && isDetached && <div role=\"presentation\" className={style({...cellFocus, position: 'absolute', inset: 0})({isFocusVisible: true})} />}\n </div>\n );\n }}\n </UNSTABLE_TreeItemContent>\n {nestedRows}\n </UNSTABLE_TreeItem>\n );\n};\n\ninterface ExpandableRowChevronProps {\n isExpanded?: boolean,\n isDisabled?: boolean,\n isRTL?: boolean,\n scale: 'medium' | 'large',\n isHidden?: boolean\n}\n\nconst expandButton = style<ExpandableRowChevronProps>({\n gridArea: 'expand-button',\n color: {\n default: '[inherit]',\n isDisabled: {\n default: 'disabled',\n forcedColors: 'GrayText'\n }\n },\n height: 40,\n width: 40,\n display: 'flex',\n flexWrap: 'wrap',\n alignContent: 'center',\n justifyContent: 'center',\n outlineStyle: 'none',\n cursor: 'default',\n transform: {\n isExpanded: {\n default: 'rotate(90deg)',\n isRTL: 'rotate(-90deg)'\n }\n },\n padding: 0,\n transition: 'default',\n backgroundColor: 'transparent',\n borderStyle: 'none',\n disableTapHighlight: true,\n visibility: {\n isHidden: 'hidden'\n }\n});\n\nfunction ExpandableRowChevron(props: ExpandableRowChevronProps) {\n let expandButtonRef = useRef<HTMLButtonElement>(null);\n let [fullProps, ref] = useContextProps({...props, slot: 'chevron'}, expandButtonRef, ButtonContext);\n let {isExpanded, isDisabled, scale, isHidden} = fullProps;\n let {direction} = useLocale();\n isDisabled = isDisabled || isHidden;\n\n return (\n <Button\n {...props}\n ref={ref}\n slot=\"chevron\"\n // Override tabindex so that grid keyboard nav skips over it. Needs -1 so android talkback can actually \"focus\" it\n excludeFromTabOrder={isAndroid() && !isDisabled}\n preventFocusOnPress\n className={renderProps => expandButton({...renderProps, isExpanded, isRTL: direction === 'rtl', scale, isHidden})}>\n <Chevron\n className={style({\n scale: {\n direction: {\n ltr: '1',\n rtl: '-1'\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n })({direction})} />\n </Button>\n );\n}\n\n/**\n * A tree view provides users with a way to navigate nested hierarchical information.\n */\nconst _TreeView = forwardRef(TreeView);\nexport {_TreeView as TreeView};\n"],"names":[],"version":3,"file":"TreeView.css.map"}
|