@react-spectrum/s2 3.0.0-nightly-4b8b33a02-250211 → 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/TreeView.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import {Checkbox as $9b405e0f8095dce0$export$48513f6b9f8ce62d} from "./Checkbox.
|
|
|
6
6
|
import $4b69f02ec06b9226$export$2e2bcd8739ae039 from "./Chevron.mjs";
|
|
7
7
|
import {IconContext as $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed} from "../icons/Icon.mjs";
|
|
8
8
|
import {Text as $8e847109a6ab556d$export$5f1af8db9871e1d6, TextContext as $8e847109a6ab556d$export$9afb8bc826b033ea} from "./Content.mjs";
|
|
9
|
+
import {useScale as $859432f3b3573fcb$export$a8d2043b2d807f4d} from "./utils.mjs";
|
|
9
10
|
import {jsx as $iOVFT$jsx, jsxs as $iOVFT$jsxs} from "react/jsx-runtime";
|
|
10
11
|
import {UNSTABLE_ListLayout as $iOVFT$UNSTABLE_ListLayout, UNSTABLE_Virtualizer as $iOVFT$UNSTABLE_Virtualizer, UNSTABLE_Tree as $iOVFT$UNSTABLE_Tree, Collection as $iOVFT$Collection, UNSTABLE_TreeItem as $iOVFT$UNSTABLE_TreeItem, UNSTABLE_TreeItemContent as $iOVFT$UNSTABLE_TreeItemContent, Provider as $iOVFT$Provider, useContextProps as $iOVFT$useContextProps, ButtonContext as $iOVFT$ButtonContext, Button as $iOVFT$Button} from "react-aria-components";
|
|
11
12
|
import {isAndroid as $iOVFT$isAndroid} from "@react-aria/utils";
|
|
@@ -36,6 +37,7 @@ import {useLocale as $iOVFT$useLocale} from "react-aria";
|
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
|
|
40
|
+
|
|
39
41
|
const $03960a2740ca2b19$var$TreeRendererContext = /*#__PURE__*/ (0, $iOVFT$createContext)({});
|
|
40
42
|
function $03960a2740ca2b19$var$useTreeRendererContext() {
|
|
41
43
|
return (0, $iOVFT$useContext)($03960a2740ca2b19$var$TreeRendererContext);
|
|
@@ -75,15 +77,18 @@ const $03960a2740ca2b19$var$tree = function anonymous(props, overrides) {
|
|
|
75
77
|
};
|
|
76
78
|
function $03960a2740ca2b19$var$TreeView(props, ref) {
|
|
77
79
|
let { children: children, isDetached: isDetached, isEmphasized: isEmphasized } = props;
|
|
80
|
+
let scale = (0, $859432f3b3573fcb$export$a8d2043b2d807f4d)();
|
|
78
81
|
let renderer;
|
|
79
82
|
if (typeof children === 'function') renderer = children;
|
|
80
83
|
let domRef = (0, $iOVFT$useDOMRef)(ref);
|
|
84
|
+
let rowHeight = isDetached ? 44 : 40;
|
|
85
|
+
if (scale === 'large') rowHeight = isDetached ? 54 : 50;
|
|
81
86
|
let layout = (0, $iOVFT$useMemo)(()=>{
|
|
82
87
|
return new (0, $iOVFT$UNSTABLE_ListLayout)({
|
|
83
|
-
rowHeight:
|
|
88
|
+
rowHeight: rowHeight
|
|
84
89
|
});
|
|
85
90
|
}, [
|
|
86
|
-
|
|
91
|
+
rowHeight
|
|
87
92
|
]);
|
|
88
93
|
return /*#__PURE__*/ (0, $iOVFT$jsx)((0, $iOVFT$UNSTABLE_Virtualizer), {
|
|
89
94
|
layout: layout,
|
|
@@ -186,9 +191,10 @@ const $03960a2740ca2b19$var$treeCellGrid = function anonymous(props) {
|
|
|
186
191
|
let rules = " .";
|
|
187
192
|
rules += ' _3f';
|
|
188
193
|
rules += ' kb';
|
|
194
|
+
rules += ' jb';
|
|
189
195
|
rules += ' _4b';
|
|
190
196
|
rules += ' _5c';
|
|
191
|
-
rules += ' __l-
|
|
197
|
+
rules += ' __l-22ig44';
|
|
192
198
|
rules += ' __m-2wzs0i';
|
|
193
199
|
rules += ' __n-17p9pp0';
|
|
194
200
|
rules += ' b-19jpv4m';
|
|
@@ -246,7 +252,7 @@ const $03960a2740ca2b19$var$treeCellGrid = function anonymous(props) {
|
|
|
246
252
|
const $03960a2740ca2b19$var$treeCheckbox = " __e-5dolv4 __f-5dolv4 __g-5dolv4 __h-5dolv4 Be Ca Ga";
|
|
247
253
|
const $03960a2740ca2b19$var$treeIcon = " __e-qb5q8i __f-qb5q8i __g-qb5q8i __h-qb5q8i CG CbH -rwx0fg_d-b";
|
|
248
254
|
const $03960a2740ca2b19$var$treeContent = " __e-drkpd0 __f-drkpd0 __g-drkpd0 __h-drkpd0 _qa _tb __zb __Ab";
|
|
249
|
-
const $03960a2740ca2b19$var$treeActions = " __e-1k7szui __f-1k7szui __g-1k7szui __h-1k7szui
|
|
255
|
+
const $03960a2740ca2b19$var$treeActions = " __e-1k7szui __f-1k7szui __g-1k7szui __h-1k7szui Bb Cc";
|
|
250
256
|
const $03960a2740ca2b19$var$treeActionMenu = " __e-2npmt8 __f-2npmt8 __g-2npmt8 __h-2npmt8";
|
|
251
257
|
const $03960a2740ca2b19$var$cellFocus = {
|
|
252
258
|
outlineStyle: {
|
|
@@ -265,6 +271,7 @@ const $03960a2740ca2b19$export$6e77ea6719814e9c = (props1)=>{
|
|
|
265
271
|
let nestedRows;
|
|
266
272
|
let { renderer: renderer } = $03960a2740ca2b19$var$useTreeRendererContext();
|
|
267
273
|
let { isDetached: isDetached, isEmphasized: isEmphasized } = (0, $iOVFT$useContext)($03960a2740ca2b19$var$InternalTreeContext);
|
|
274
|
+
let scale = (0, $859432f3b3573fcb$export$a8d2043b2d807f4d)();
|
|
268
275
|
if (typeof children === 'string') content = /*#__PURE__*/ (0, $iOVFT$jsx)((0, $8e847109a6ab556d$export$5f1af8db9871e1d6), {
|
|
269
276
|
children: children
|
|
270
277
|
});
|
|
@@ -316,9 +323,11 @@ const $03960a2740ca2b19$export$6e77ea6719814e9c = (props1)=>{
|
|
|
316
323
|
/*#__PURE__*/ (0, $iOVFT$jsx)("div", {
|
|
317
324
|
className: " __e-u3oh8l __f-u3oh8l __g-u3oh8l __h-u3oh8l k-19lybgs"
|
|
318
325
|
}),
|
|
319
|
-
|
|
326
|
+
/*#__PURE__*/ (0, $iOVFT$jsx)($03960a2740ca2b19$var$ExpandableRowChevron, {
|
|
320
327
|
isDisabled: isDisabled,
|
|
321
|
-
isExpanded: isExpanded
|
|
328
|
+
isExpanded: isExpanded,
|
|
329
|
+
scale: scale,
|
|
330
|
+
isHidden: !(hasChildRows || hasChildItems)
|
|
322
331
|
}),
|
|
323
332
|
/*#__PURE__*/ (0, $iOVFT$jsx)((0, $iOVFT$Provider), {
|
|
324
333
|
values: [
|
|
@@ -392,8 +401,12 @@ const $03960a2740ca2b19$var$expandButton = function anonymous(props) {
|
|
|
392
401
|
rules += ' __f-ajol1u';
|
|
393
402
|
rules += ' __g-ajol1u';
|
|
394
403
|
rules += ' __h-ajol1u';
|
|
395
|
-
|
|
396
|
-
|
|
404
|
+
if (props.isDisabled) {
|
|
405
|
+
rules += ' aa_____O';
|
|
406
|
+
rules += ' aj';
|
|
407
|
+
} else rules += ' a-17zqamw';
|
|
408
|
+
rules += ' j2';
|
|
409
|
+
rules += ' k2';
|
|
397
410
|
rules += ' _3d';
|
|
398
411
|
rules += ' __ba';
|
|
399
412
|
rules += ' _4b';
|
|
@@ -404,11 +417,17 @@ const $03960a2740ca2b19$var$expandButton = function anonymous(props) {
|
|
|
404
417
|
if (props.isRTL) rules += ' X-197phm7';
|
|
405
418
|
else rules += ' X-7hkt2a';
|
|
406
419
|
}
|
|
420
|
+
rules += ' Ha';
|
|
421
|
+
rules += ' Ia';
|
|
422
|
+
rules += ' Fa';
|
|
423
|
+
rules += ' Ga';
|
|
407
424
|
rules += ' _Sa';
|
|
408
425
|
rules += ' _U-375x7f';
|
|
409
426
|
rules += ' _Va';
|
|
410
427
|
rules += ' ba';
|
|
411
428
|
rules += ' zf';
|
|
429
|
+
rules += ' __V-yksgrp';
|
|
430
|
+
if (props.isHidden) rules += ' __Ib';
|
|
412
431
|
return rules;
|
|
413
432
|
};
|
|
414
433
|
function $03960a2740ca2b19$var$ExpandableRowChevron(props1) {
|
|
@@ -417,8 +436,9 @@ function $03960a2740ca2b19$var$ExpandableRowChevron(props1) {
|
|
|
417
436
|
...props1,
|
|
418
437
|
slot: 'chevron'
|
|
419
438
|
}, expandButtonRef, (0, $iOVFT$ButtonContext));
|
|
420
|
-
let { isExpanded: isExpanded, isDisabled: isDisabled } = fullProps;
|
|
439
|
+
let { isExpanded: isExpanded, isDisabled: isDisabled, scale: scale, isHidden: isHidden } = fullProps;
|
|
421
440
|
let { direction: direction } = (0, $iOVFT$useLocale)();
|
|
441
|
+
isDisabled = isDisabled || isHidden;
|
|
422
442
|
return /*#__PURE__*/ (0, $iOVFT$jsx)((0, $iOVFT$Button), {
|
|
423
443
|
...props1,
|
|
424
444
|
ref: ref,
|
|
@@ -429,7 +449,9 @@ function $03960a2740ca2b19$var$ExpandableRowChevron(props1) {
|
|
|
429
449
|
className: (renderProps)=>$03960a2740ca2b19$var$expandButton({
|
|
430
450
|
...renderProps,
|
|
431
451
|
isExpanded: isExpanded,
|
|
432
|
-
isRTL: direction === 'rtl'
|
|
452
|
+
isRTL: direction === 'rtl',
|
|
453
|
+
scale: scale,
|
|
454
|
+
isHidden: isHidden
|
|
433
455
|
}),
|
|
434
456
|
children: /*#__PURE__*/ (0, $iOVFT$jsx)((0, $4b69f02ec06b9226$export$2e2bcd8739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AAgB,SAAS;wCAAI;qCAAE;iCAC7D;0CACA;;4BAEF,kBAAkB,4BAAc,gBAAC;gCAAI,MAAK;gCAAe,WAAW;;;;;;;;;;;;;;;;;;kCAAsD;oCAAC,gBAAgB;gCAAI;;;;gBAGtJ;;YAED;;;AAGP;AAQA,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;AAqBN,SAAS,2CAAqB,MAAgC;IAC5D,IAAI,kBAAkB,CAAA,GAAA,aAAK,EAAqB;IAChD,IAAI,CAAC,WAAW,IAAI,GAAG,CAAA,GAAA,sBAAc,EAAE;QAAC,GAAG,MAAK;QAAE,MAAM;IAAS,GAAG,iBAAiB,CAAA,GAAA,oBAAY;IACjG,IAAI,cAAC,UAAU,cAAE,UAAU,EAAC,GAAG;IAC/B,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAE1B,qBACE,gBAAC,CAAA,GAAA,aAAK;QACH,GAAG,MAAK;QACT,KAAK;QACL,MAAK;QACL,kHAAkH;QAClH,qBAAqB,CAAA,GAAA,gBAAQ,OAAO,CAAC;QACrC,mBAAmB;QACnB,WAAW,CAAA,cAAe,mCAAa;gBAAC,GAAG,WAAW;4BAAE;gBAAY,OAAO,cAAc;YAAK;kBAC9F,cAAA,gBAAC,CAAA,GAAA,wCAAM;YACL,WAAW;;;;;;;;cAWR;2BAAC;YAAS;;;AAGrB;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,iBAAS,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.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwDD,MAAM,0DAAsB,CAAA,GAAA,oBAAY,EAA4B,CAAC;AAErE,SAAS;IACP,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB;AAGA,IAAI,0DAAsB,CAAA,GAAA,oBAAY,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;IAC3C,IAAI,QAAQ,CAAA,GAAA,yCAAO;IAEnB,IAAI;IACJ,IAAI,OAAO,aAAa,YACtB,WAAW;IAGb,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IAEvB,IAAI,YAAY,aAAa,KAAK;IAClC,IAAI,UAAU,SACZ,YAAY,aAAa,KAAK;IAEhC,IAAI,SAAS,CAAA,GAAA,cAAM,EAAE;QACnB,OAAO,IAAI,CAAA,GAAA,0BAAkB,EAAE;uBAC7B;QACF;IACF,GAAG;QAAC;KAAU;IAEd,qBACE,gBAAC,CAAA,GAAA,2BAAmB;QAAE,QAAQ;kBAC5B,cAAA,gBAAC,0CAAoB,QAAQ;YAAC,OAAO;0BAAC;YAAQ;sBAC5C,cAAA,gBAAC,0CAAoB,QAAQ;gBAAC,OAAO;gCAAC;kCAAY;gBAAY;0BAC5D,cAAA,gBAAC,CAAA,GAAA,oBAAY;oBACV,GAAG,KAAK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A;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,iBAAS,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.mjs.map"}
|