@dxos/react-ui-list 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7
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/lib/browser/index.mjs +192 -166
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +192 -166
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/List/List.d.ts.map +1 -1
- package/dist/types/src/components/List/ListItem.d.ts +2 -2
- package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.d.ts +6 -5
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeContext.d.ts +21 -10
- package/dist/types/src/components/Tree/TreeContext.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItem.d.ts +8 -0
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/Tree/index.d.ts +2 -0
- package/dist/types/src/components/Tree/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/src/components/Accordion/Accordion.stories.tsx +3 -3
- package/src/components/Accordion/AccordionItem.tsx +1 -1
- package/src/components/List/List.stories.tsx +7 -7
- package/src/components/List/ListItem.tsx +10 -10
- package/src/components/Tree/Tree.stories.tsx +102 -26
- package/src/components/Tree/Tree.tsx +30 -40
- package/src/components/Tree/TreeContext.tsx +18 -9
- package/src/components/Tree/TreeItem.tsx +166 -99
- package/src/components/Tree/TreeItemHeading.tsx +5 -3
- package/src/components/Tree/TreeItemToggle.tsx +1 -1
- package/src/components/Tree/index.ts +2 -0
|
@@ -44,7 +44,7 @@ var AccordionItemHeader = ({ classNames, children, ...props }) => {
|
|
|
44
44
|
...props,
|
|
45
45
|
className: mx2(classNames)
|
|
46
46
|
}, /* @__PURE__ */ React2.createElement(AccordionPrimitive2.Trigger, {
|
|
47
|
-
className: "group flex items-center p-2 dx-focus-ring-inset
|
|
47
|
+
className: "group flex items-center p-2 dx-focus-ring-inset w-full text-start"
|
|
48
48
|
}, children, /* @__PURE__ */ React2.createElement(Icon, {
|
|
49
49
|
icon: "ph--caret-right--regular",
|
|
50
50
|
size: 4,
|
|
@@ -155,7 +155,7 @@ var idle = {
|
|
|
155
155
|
type: "idle"
|
|
156
156
|
};
|
|
157
157
|
var stateStyles = {
|
|
158
|
-
"
|
|
158
|
+
"w-dragging": "opacity-50"
|
|
159
159
|
};
|
|
160
160
|
var defaultContext = {};
|
|
161
161
|
var LIST_ITEM_NAME = "ListItem";
|
|
@@ -214,10 +214,10 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
214
214
|
} : void 0,
|
|
215
215
|
onDragStart: () => {
|
|
216
216
|
setState({
|
|
217
|
-
type: "
|
|
217
|
+
type: "w-dragging"
|
|
218
218
|
});
|
|
219
219
|
setRootState({
|
|
220
|
-
type: "
|
|
220
|
+
type: "w-dragging",
|
|
221
221
|
item
|
|
222
222
|
});
|
|
223
223
|
},
|
|
@@ -248,7 +248,7 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
248
248
|
onDragEnter: ({ self }) => {
|
|
249
249
|
const closestEdge = extractClosestEdge2(self.data);
|
|
250
250
|
setState({
|
|
251
|
-
type: "
|
|
251
|
+
type: "w-dragging-over",
|
|
252
252
|
closestEdge
|
|
253
253
|
});
|
|
254
254
|
},
|
|
@@ -258,11 +258,11 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
258
258
|
onDrag: ({ self }) => {
|
|
259
259
|
const closestEdge = extractClosestEdge2(self.data);
|
|
260
260
|
setState((current) => {
|
|
261
|
-
if (current.type === "
|
|
261
|
+
if (current.type === "w-dragging-over" && current.closestEdge === closestEdge) {
|
|
262
262
|
return current;
|
|
263
263
|
}
|
|
264
264
|
return {
|
|
265
|
-
type: "
|
|
265
|
+
type: "w-dragging-over",
|
|
266
266
|
closestEdge
|
|
267
267
|
};
|
|
268
268
|
});
|
|
@@ -283,7 +283,7 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
283
283
|
role: "listitem",
|
|
284
284
|
className: mx3("flex relative", classNames, stateStyles[state.type]),
|
|
285
285
|
...props
|
|
286
|
-
}, children, state.type === "
|
|
286
|
+
}, children, state.type === "w-dragging-over" && state.closestEdge && /* @__PURE__ */ React4.createElement(NaturalListItem.DropIndicator, {
|
|
287
287
|
edge: state.closestEdge
|
|
288
288
|
})));
|
|
289
289
|
};
|
|
@@ -337,7 +337,7 @@ var ListItemDragPreview = ({ children }) => {
|
|
|
337
337
|
}), state.container) : null;
|
|
338
338
|
};
|
|
339
339
|
var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */ React4.createElement("div", {
|
|
340
|
-
className: mx3("flex
|
|
340
|
+
className: mx3("flex w-full gap-2", classNames)
|
|
341
341
|
}, children);
|
|
342
342
|
var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */ React4.createElement("div", {
|
|
343
343
|
className: mx3("flex grow items-center truncate", classNames),
|
|
@@ -357,6 +357,7 @@ var List = {
|
|
|
357
357
|
};
|
|
358
358
|
|
|
359
359
|
// src/components/Tree/Tree.tsx
|
|
360
|
+
import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
360
361
|
import React8, { useMemo as useMemo2 } from "react";
|
|
361
362
|
import { Treegrid as Treegrid2 } from "@dxos/react-ui";
|
|
362
363
|
|
|
@@ -371,11 +372,12 @@ var useTree = () => useContext(TreeContext) ?? raise(new Error("TreeContext not
|
|
|
371
372
|
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
372
373
|
import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
373
374
|
import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
375
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
374
376
|
import * as Schema from "effect/Schema";
|
|
375
377
|
import React7, { memo as memo3, useCallback as useCallback3, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
|
|
376
378
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
377
379
|
import { TreeItem as NaturalTreeItem, Treegrid } from "@dxos/react-ui";
|
|
378
|
-
import { ghostFocusWithin, ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls } from "@dxos/ui-theme";
|
|
380
|
+
import { ghostFocusWithin, ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, mx as mx4 } from "@dxos/ui-theme";
|
|
379
381
|
|
|
380
382
|
// src/components/Tree/helpers.ts
|
|
381
383
|
var DEFAULT_INDENTATION = 8;
|
|
@@ -417,7 +419,7 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label,
|
|
|
417
419
|
variant: "ghost",
|
|
418
420
|
density: "fine",
|
|
419
421
|
classNames: [
|
|
420
|
-
"grow gap-2
|
|
422
|
+
"grow gap-2 ps-0.5 hover:bg-transparent dark:hover:bg-transparent",
|
|
421
423
|
"disabled:cursor-default disabled:opacity-100",
|
|
422
424
|
className
|
|
423
425
|
],
|
|
@@ -431,11 +433,11 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label,
|
|
|
431
433
|
icon: icon ?? "ph--placeholder--regular",
|
|
432
434
|
size: 5,
|
|
433
435
|
classNames: [
|
|
434
|
-
"
|
|
435
|
-
styles?.
|
|
436
|
+
"my-1",
|
|
437
|
+
styles?.surfaceText
|
|
436
438
|
]
|
|
437
439
|
}), /* @__PURE__ */ React5.createElement("span", {
|
|
438
|
-
className: "flex-1
|
|
440
|
+
className: "flex-1 w-0 truncate text-start font-normal",
|
|
439
441
|
"data-tooltip": true
|
|
440
442
|
}, toLocalizedString(label, t))));
|
|
441
443
|
}));
|
|
@@ -451,7 +453,7 @@ var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef2(({ open,
|
|
|
451
453
|
variant: "ghost",
|
|
452
454
|
density: "fine",
|
|
453
455
|
classNames: [
|
|
454
|
-
"
|
|
456
|
+
"h-full w-6 px-0",
|
|
455
457
|
"[&_svg]:transition-[transform] [&_svg]:duration-200",
|
|
456
458
|
open && "[&_svg]:rotate-90",
|
|
457
459
|
hidden ? "hidden" : !isBranch && "invisible",
|
|
@@ -476,7 +478,7 @@ var TreeDataSchema = Schema.Struct({
|
|
|
476
478
|
item: Schema.Any
|
|
477
479
|
});
|
|
478
480
|
var isTreeData = (data) => Schema.is(TreeDataSchema)(data);
|
|
479
|
-
var RawTreeItem = ({ item, path:
|
|
481
|
+
var RawTreeItem = ({ item, path: pathProp, levelOffset = 2, last, draggable: draggableProp, renderColumns: Columns, blockInstruction, canDrop, canSelect, onOpenChange, onSelect, onItemHover }) => {
|
|
480
482
|
const rowRef = useRef2(null);
|
|
481
483
|
const buttonRef = useRef2(null);
|
|
482
484
|
const openRef = useRef2(false);
|
|
@@ -484,18 +486,18 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
|
|
|
484
486
|
const [_state, setState] = useState3("idle");
|
|
485
487
|
const [instruction, setInstruction] = useState3(null);
|
|
486
488
|
const [menuOpen, setMenuOpen] = useState3(false);
|
|
487
|
-
const {
|
|
488
|
-
const items = useItems(item);
|
|
489
|
-
const { id, parentOf, label, className, headingClassName, icon, iconHue, disabled, testId } = getProps(item, _path);
|
|
489
|
+
const { itemProps: itemPropsAtom, childIds: childIdsAtom, itemOpen: itemOpenAtom, itemCurrent: itemCurrentAtom } = useTree();
|
|
490
490
|
const path = useMemo(() => [
|
|
491
|
-
...
|
|
492
|
-
id
|
|
491
|
+
...pathProp,
|
|
492
|
+
item.id
|
|
493
493
|
], [
|
|
494
|
-
|
|
495
|
-
id
|
|
494
|
+
pathProp,
|
|
495
|
+
item.id
|
|
496
496
|
]);
|
|
497
|
-
const
|
|
498
|
-
const
|
|
497
|
+
const { id, parentOf, draggable: itemDraggable, droppable: itemDroppable, label, className, headingClassName, icon, iconHue, disabled, testId } = useAtomValue(itemPropsAtom(path));
|
|
498
|
+
const childIds = useAtomValue(childIdsAtom(item.id));
|
|
499
|
+
const open = useAtomValue(itemOpenAtom(path));
|
|
500
|
+
const current = useAtomValue(itemCurrentAtom(path));
|
|
499
501
|
const level = path.length - levelOffset;
|
|
500
502
|
const isBranch = !!parentOf;
|
|
501
503
|
const mode = last ? "last-in-group" : open ? "expanded" : "standard";
|
|
@@ -503,122 +505,130 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
|
|
|
503
505
|
item,
|
|
504
506
|
path
|
|
505
507
|
}) ?? true;
|
|
508
|
+
const data = {
|
|
509
|
+
id,
|
|
510
|
+
path,
|
|
511
|
+
item
|
|
512
|
+
};
|
|
506
513
|
const cancelExpand = useCallback3(() => {
|
|
507
514
|
if (cancelExpandRef.current) {
|
|
508
515
|
clearTimeout(cancelExpandRef.current);
|
|
509
516
|
cancelExpandRef.current = null;
|
|
510
517
|
}
|
|
511
518
|
}, []);
|
|
519
|
+
const isItemDraggable = draggableProp && itemDraggable !== false;
|
|
520
|
+
const isItemDroppable = itemDroppable !== false;
|
|
512
521
|
useEffect3(() => {
|
|
513
|
-
if (!
|
|
522
|
+
if (!draggableProp) {
|
|
514
523
|
return;
|
|
515
524
|
}
|
|
516
525
|
invariant2(buttonRef.current, void 0, {
|
|
517
526
|
F: __dxlog_file2,
|
|
518
|
-
L:
|
|
527
|
+
L: 148,
|
|
519
528
|
S: void 0,
|
|
520
529
|
A: [
|
|
521
530
|
"buttonRef.current",
|
|
522
531
|
""
|
|
523
532
|
]
|
|
524
533
|
});
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
if (open) {
|
|
537
|
-
openRef.current = true;
|
|
538
|
-
onOpenChange?.({
|
|
539
|
-
item,
|
|
540
|
-
path,
|
|
541
|
-
open: false
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
},
|
|
545
|
-
onDrop: () => {
|
|
546
|
-
setState("idle");
|
|
547
|
-
if (openRef.current) {
|
|
548
|
-
onOpenChange?.({
|
|
549
|
-
item,
|
|
550
|
-
path,
|
|
551
|
-
open: true
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}),
|
|
556
|
-
// https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/hitbox/constellation/index/about.mdx
|
|
557
|
-
dropTargetForElements2({
|
|
558
|
-
element: buttonRef.current,
|
|
559
|
-
getData: ({ input, element }) => {
|
|
560
|
-
return attachInstruction(data, {
|
|
561
|
-
input,
|
|
562
|
-
element,
|
|
563
|
-
indentPerLevel: DEFAULT_INDENTATION,
|
|
564
|
-
currentLevel: level,
|
|
565
|
-
mode,
|
|
566
|
-
block: isBranch ? [] : [
|
|
567
|
-
"make-child"
|
|
568
|
-
]
|
|
534
|
+
const makeDraggable = () => draggable2({
|
|
535
|
+
element: buttonRef.current,
|
|
536
|
+
getInitialData: () => data,
|
|
537
|
+
onDragStart: () => {
|
|
538
|
+
setState("dragging");
|
|
539
|
+
if (open) {
|
|
540
|
+
openRef.current = true;
|
|
541
|
+
onOpenChange?.({
|
|
542
|
+
item,
|
|
543
|
+
path,
|
|
544
|
+
open: false
|
|
569
545
|
});
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
onDrag: ({ self, source }) => {
|
|
580
|
-
const desired = extractInstruction(self.data);
|
|
581
|
-
const block = desired && blockInstruction?.({
|
|
582
|
-
instruction: desired,
|
|
583
|
-
source: source.data,
|
|
584
|
-
target: data
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
onDrop: () => {
|
|
549
|
+
setState("idle");
|
|
550
|
+
if (openRef.current) {
|
|
551
|
+
onOpenChange?.({
|
|
552
|
+
item,
|
|
553
|
+
path,
|
|
554
|
+
open: true
|
|
585
555
|
});
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
if (!isItemDroppable) {
|
|
560
|
+
return isItemDraggable ? makeDraggable() : void 0;
|
|
561
|
+
}
|
|
562
|
+
const dropTarget = dropTargetForElements2({
|
|
563
|
+
element: buttonRef.current,
|
|
564
|
+
getData: ({ input, element }) => {
|
|
565
|
+
return attachInstruction(data, {
|
|
566
|
+
input,
|
|
567
|
+
element,
|
|
568
|
+
indentPerLevel: DEFAULT_INDENTATION,
|
|
569
|
+
currentLevel: level,
|
|
570
|
+
mode,
|
|
571
|
+
block: isBranch ? [] : [
|
|
572
|
+
"make-child"
|
|
573
|
+
]
|
|
574
|
+
});
|
|
575
|
+
},
|
|
576
|
+
canDrop: ({ source }) => {
|
|
577
|
+
const _canDrop = canDrop ?? (() => true);
|
|
578
|
+
return source.element !== buttonRef.current && _canDrop({
|
|
579
|
+
source: source.data,
|
|
580
|
+
target: data
|
|
581
|
+
});
|
|
582
|
+
},
|
|
583
|
+
getIsSticky: () => true,
|
|
584
|
+
onDrag: ({ self, source }) => {
|
|
585
|
+
const desired = extractInstruction(self.data);
|
|
586
|
+
const block = desired && blockInstruction?.({
|
|
587
|
+
instruction: desired,
|
|
588
|
+
source: source.data,
|
|
589
|
+
target: data
|
|
590
|
+
});
|
|
591
|
+
const instruction2 = block && desired.type !== "instruction-blocked" ? {
|
|
592
|
+
type: "instruction-blocked",
|
|
593
|
+
desired
|
|
594
|
+
} : desired;
|
|
595
|
+
if (source.data.id !== id) {
|
|
596
|
+
if (instruction2?.type === "make-child" && isBranch && !open && !cancelExpandRef.current) {
|
|
597
|
+
cancelExpandRef.current = setTimeout(() => {
|
|
598
|
+
onOpenChange?.({
|
|
599
|
+
item,
|
|
600
|
+
path,
|
|
601
|
+
open: true
|
|
602
|
+
});
|
|
603
|
+
}, 500);
|
|
608
604
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
setInstruction(
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
|
|
605
|
+
if (instruction2?.type !== "make-child") {
|
|
606
|
+
cancelExpand();
|
|
607
|
+
}
|
|
608
|
+
setInstruction(instruction2);
|
|
609
|
+
} else if (instruction2?.type === "reparent") {
|
|
610
|
+
setInstruction(instruction2);
|
|
611
|
+
} else {
|
|
616
612
|
setInstruction(null);
|
|
617
613
|
}
|
|
618
|
-
}
|
|
619
|
-
|
|
614
|
+
},
|
|
615
|
+
onDragLeave: () => {
|
|
616
|
+
cancelExpand();
|
|
617
|
+
setInstruction(null);
|
|
618
|
+
},
|
|
619
|
+
onDrop: () => {
|
|
620
|
+
cancelExpand();
|
|
621
|
+
setInstruction(null);
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
if (!isItemDraggable) {
|
|
625
|
+
return dropTarget;
|
|
626
|
+
}
|
|
627
|
+
return combine2(makeDraggable(), dropTarget);
|
|
620
628
|
}, [
|
|
621
|
-
|
|
629
|
+
draggableProp,
|
|
630
|
+
isItemDraggable,
|
|
631
|
+
isItemDroppable,
|
|
622
632
|
item,
|
|
623
633
|
id,
|
|
624
634
|
mode,
|
|
@@ -678,33 +688,46 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
|
|
|
678
688
|
handleOpenToggle,
|
|
679
689
|
handleSelect
|
|
680
690
|
]);
|
|
691
|
+
const handleItemHover = useCallback3(() => {
|
|
692
|
+
onItemHover?.({
|
|
693
|
+
item
|
|
694
|
+
});
|
|
695
|
+
}, [
|
|
696
|
+
onItemHover,
|
|
697
|
+
item
|
|
698
|
+
]);
|
|
699
|
+
const handleContextMenu = useCallback3((event) => {
|
|
700
|
+
event.preventDefault();
|
|
701
|
+
setMenuOpen(true);
|
|
702
|
+
}, [
|
|
703
|
+
setMenuOpen
|
|
704
|
+
]);
|
|
705
|
+
const childProps = {
|
|
706
|
+
draggable: draggableProp,
|
|
707
|
+
renderColumns: Columns,
|
|
708
|
+
blockInstruction,
|
|
709
|
+
canDrop,
|
|
710
|
+
canSelect,
|
|
711
|
+
onItemHover,
|
|
712
|
+
onOpenChange,
|
|
713
|
+
onSelect
|
|
714
|
+
};
|
|
681
715
|
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Treegrid.Row, {
|
|
682
716
|
ref: rowRef,
|
|
683
717
|
key: id,
|
|
684
718
|
id,
|
|
685
719
|
"aria-labelledby": `${id}__label`,
|
|
686
720
|
parentOf: parentOf?.join(Treegrid.PARENT_OF_SEPARATOR),
|
|
687
|
-
classNames: [
|
|
688
|
-
"grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-activeSurface",
|
|
689
|
-
hoverableControls,
|
|
690
|
-
hoverableFocusedKeyboardControls,
|
|
691
|
-
hoverableFocusedWithinControls,
|
|
692
|
-
hoverableDescriptionIcons,
|
|
693
|
-
ghostHover,
|
|
694
|
-
ghostFocusWithin,
|
|
695
|
-
className
|
|
696
|
-
],
|
|
697
721
|
"data-object-id": id,
|
|
698
722
|
"data-testid": testId,
|
|
699
723
|
// NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
|
|
700
724
|
// without alerting the user (except for in the correct link element). See also:
|
|
701
725
|
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current#description
|
|
702
726
|
"aria-current": current ? "" : void 0,
|
|
727
|
+
classNames: mx4("grid grid-cols-subgrid col-[tree-row] mt-0.5 is-current:bg-active-surface", hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, hoverableDescriptionIcons, ghostFocusWithin, ghostHover, className),
|
|
703
728
|
onKeyDown: handleKeyDown,
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
setMenuOpen(true);
|
|
707
|
-
}
|
|
729
|
+
onMouseEnter: handleItemHover,
|
|
730
|
+
onContextMenu: handleContextMenu
|
|
708
731
|
}, /* @__PURE__ */ React7.createElement("div", {
|
|
709
732
|
role: "none",
|
|
710
733
|
className: "indent relative grid grid-cols-subgrid col-[tree-row]",
|
|
@@ -733,36 +756,31 @@ var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _dragg
|
|
|
733
756
|
}), instruction && /* @__PURE__ */ React7.createElement(NaturalTreeItem.DropIndicator, {
|
|
734
757
|
instruction,
|
|
735
758
|
gap: 2
|
|
736
|
-
}))), open &&
|
|
737
|
-
key:
|
|
738
|
-
|
|
759
|
+
}))), open && childIds.map((childId, index) => /* @__PURE__ */ React7.createElement(TreeItemById, {
|
|
760
|
+
key: childId,
|
|
761
|
+
id: childId,
|
|
739
762
|
path,
|
|
740
|
-
last: index ===
|
|
741
|
-
|
|
742
|
-
renderColumns: Columns,
|
|
743
|
-
blockInstruction,
|
|
744
|
-
canDrop,
|
|
745
|
-
canSelect,
|
|
746
|
-
onOpenChange,
|
|
747
|
-
onSelect
|
|
763
|
+
last: index === childIds.length - 1,
|
|
764
|
+
...childProps
|
|
748
765
|
})));
|
|
749
766
|
};
|
|
750
767
|
var TreeItem = /* @__PURE__ */ memo3(RawTreeItem);
|
|
768
|
+
var RawTreeItemById = ({ id, ...props }) => {
|
|
769
|
+
const { item: itemAtom } = useTree();
|
|
770
|
+
const item = useAtomValue(itemAtom(id));
|
|
771
|
+
if (!item) {
|
|
772
|
+
return null;
|
|
773
|
+
}
|
|
774
|
+
return /* @__PURE__ */ React7.createElement(TreeItem, {
|
|
775
|
+
item,
|
|
776
|
+
...props
|
|
777
|
+
});
|
|
778
|
+
};
|
|
779
|
+
var TreeItemById = /* @__PURE__ */ memo3(RawTreeItemById);
|
|
751
780
|
|
|
752
781
|
// src/components/Tree/Tree.tsx
|
|
753
|
-
var Tree = ({
|
|
754
|
-
const
|
|
755
|
-
useItems,
|
|
756
|
-
getProps,
|
|
757
|
-
useIsOpen,
|
|
758
|
-
useIsCurrent
|
|
759
|
-
}), [
|
|
760
|
-
useItems,
|
|
761
|
-
getProps,
|
|
762
|
-
useIsOpen,
|
|
763
|
-
useIsCurrent
|
|
764
|
-
]);
|
|
765
|
-
const items = useItems(root);
|
|
782
|
+
var Tree = ({ model, rootId, path, id, draggable: draggable3 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, levelOffset, renderColumns, blockInstruction, canDrop, canSelect, onOpenChange, onSelect, onItemHover }) => {
|
|
783
|
+
const childIds = useAtomValue2(model.childIds(rootId));
|
|
766
784
|
const treePath = useMemo2(() => path ? [
|
|
767
785
|
...path,
|
|
768
786
|
id
|
|
@@ -772,15 +790,7 @@ var Tree = ({ root, path, id, useItems, getProps, useIsOpen, useIsCurrent, dragg
|
|
|
772
790
|
id,
|
|
773
791
|
path
|
|
774
792
|
]);
|
|
775
|
-
|
|
776
|
-
gridTemplateColumns,
|
|
777
|
-
classNames
|
|
778
|
-
}, /* @__PURE__ */ React8.createElement(TreeProvider, {
|
|
779
|
-
value: context
|
|
780
|
-
}, items.map((item, index) => /* @__PURE__ */ React8.createElement(TreeItem, {
|
|
781
|
-
key: item.id,
|
|
782
|
-
item,
|
|
783
|
-
last: index === items.length - 1,
|
|
793
|
+
const childProps = {
|
|
784
794
|
path: treePath,
|
|
785
795
|
levelOffset,
|
|
786
796
|
draggable: draggable3,
|
|
@@ -789,7 +799,19 @@ var Tree = ({ root, path, id, useItems, getProps, useIsOpen, useIsCurrent, dragg
|
|
|
789
799
|
canDrop,
|
|
790
800
|
canSelect,
|
|
791
801
|
onOpenChange,
|
|
792
|
-
onSelect
|
|
802
|
+
onSelect,
|
|
803
|
+
onItemHover
|
|
804
|
+
};
|
|
805
|
+
return /* @__PURE__ */ React8.createElement(Treegrid2.Root, {
|
|
806
|
+
gridTemplateColumns,
|
|
807
|
+
classNames
|
|
808
|
+
}, /* @__PURE__ */ React8.createElement(TreeProvider, {
|
|
809
|
+
value: model
|
|
810
|
+
}, childIds.map((childId, index) => /* @__PURE__ */ React8.createElement(TreeItemById, {
|
|
811
|
+
key: childId,
|
|
812
|
+
id: childId,
|
|
813
|
+
last: index === childIds.length - 1,
|
|
814
|
+
...childProps
|
|
793
815
|
}))));
|
|
794
816
|
};
|
|
795
817
|
|
|
@@ -810,13 +832,17 @@ var Path = {
|
|
|
810
832
|
};
|
|
811
833
|
export {
|
|
812
834
|
Accordion,
|
|
835
|
+
DEFAULT_INDENTATION,
|
|
813
836
|
List,
|
|
814
837
|
Path,
|
|
815
838
|
Tree,
|
|
816
839
|
TreeDataSchema,
|
|
817
840
|
TreeItem,
|
|
841
|
+
TreeItemById,
|
|
842
|
+
TreeItemToggle,
|
|
818
843
|
TreeProvider,
|
|
819
844
|
isTreeData,
|
|
845
|
+
paddingIndentation,
|
|
820
846
|
useTree
|
|
821
847
|
};
|
|
822
848
|
//# sourceMappingURL=index.mjs.map
|