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