@dxos/react-ui-list 0.8.4-main.2e9d522 → 0.8.4-main.3c1ae3b
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 +107 -91
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +107 -91
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Accordion/Accordion.stories.d.ts +7 -4
- package/dist/types/src/components/Accordion/Accordion.stories.d.ts.map +1 -1
- package/dist/types/src/components/Accordion/AccordionItem.d.ts +1 -1
- package/dist/types/src/components/Accordion/AccordionItem.d.ts.map +1 -1
- package/dist/types/src/components/List/List.d.ts +6 -6
- package/dist/types/src/components/List/List.d.ts.map +1 -1
- package/dist/types/src/components/List/List.stories.d.ts +14 -5
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/ListItem.d.ts +4 -7
- package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
- package/dist/types/src/components/List/ListRoot.d.ts.map +1 -1
- package/dist/types/src/components/List/testing.d.ts +1 -1
- package/dist/types/src/components/List/testing.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.d.ts +3 -3
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +36 -6
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeContext.d.ts +3 -2
- package/dist/types/src/components/Tree/TreeContext.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItem.d.ts +12 -2
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItemHeading.d.ts +4 -3
- package/dist/types/src/components/Tree/TreeItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItemToggle.d.ts +3 -3
- package/dist/types/src/components/Tree/TreeItemToggle.d.ts.map +1 -1
- package/dist/types/src/components/Tree/testing.d.ts +2 -2
- package/dist/types/src/components/Tree/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -24
- package/src/components/Accordion/Accordion.stories.tsx +7 -9
- package/src/components/Accordion/Accordion.tsx +1 -1
- package/src/components/Accordion/AccordionItem.tsx +5 -2
- package/src/components/List/List.stories.tsx +19 -17
- package/src/components/List/List.tsx +2 -5
- package/src/components/List/ListItem.tsx +39 -27
- package/src/components/List/ListRoot.tsx +1 -1
- package/src/components/List/testing.ts +3 -3
- package/src/components/Tree/Tree.stories.tsx +51 -48
- package/src/components/Tree/Tree.tsx +16 -2
- package/src/components/Tree/TreeContext.tsx +3 -2
- package/src/components/Tree/TreeItem.tsx +50 -37
- package/src/components/Tree/TreeItemHeading.tsx +9 -6
- package/src/components/Tree/TreeItemToggle.tsx +29 -18
- package/src/components/Tree/testing.ts +4 -3
|
@@ -36,7 +36,7 @@ var AccordionRoot = ({ classNames, items, getId = defaultGetId, children, value,
|
|
|
36
36
|
|
|
37
37
|
// src/components/Accordion/AccordionItem.tsx
|
|
38
38
|
var ACCORDION_ITEM_NAME = "AccordionItem";
|
|
39
|
-
var [AccordionItemProvider,
|
|
39
|
+
var [AccordionItemProvider, useDxAccordionItemContext] = createContext2(ACCORDION_ITEM_NAME);
|
|
40
40
|
var AccordionItem = ({ children, classNames, item }) => {
|
|
41
41
|
var _effect = _useSignals2();
|
|
42
42
|
try {
|
|
@@ -97,10 +97,10 @@ import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-d
|
|
|
97
97
|
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
98
98
|
import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
99
99
|
import { createContext as createContext4 } from "@radix-ui/react-context";
|
|
100
|
-
import React4, {
|
|
100
|
+
import React4, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
101
101
|
import { createPortal } from "react-dom";
|
|
102
102
|
import { invariant } from "@dxos/invariant";
|
|
103
|
-
import {
|
|
103
|
+
import { IconButton, ListItem as NaturalListItem, useTranslation } from "@dxos/react-ui";
|
|
104
104
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
105
105
|
|
|
106
106
|
// src/components/List/ListRoot.tsx
|
|
@@ -200,7 +200,7 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
200
200
|
const element = ref.current;
|
|
201
201
|
invariant(element, void 0, {
|
|
202
202
|
F: __dxlog_file,
|
|
203
|
-
L:
|
|
203
|
+
L: 98,
|
|
204
204
|
S: void 0,
|
|
205
205
|
A: [
|
|
206
206
|
"element",
|
|
@@ -309,67 +309,54 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
309
309
|
return /* @__PURE__ */ React4.createElement(ListItemProvider, {
|
|
310
310
|
item,
|
|
311
311
|
dragHandleRef
|
|
312
|
-
}, /* @__PURE__ */ React4.createElement("div", {
|
|
313
|
-
role: "none",
|
|
314
|
-
className: "relative"
|
|
315
312
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
316
313
|
ref,
|
|
317
314
|
role: "listitem",
|
|
318
|
-
className: mx3("flex
|
|
315
|
+
className: mx3("flex relative", classNames, stateStyles[state.type]),
|
|
319
316
|
...props
|
|
320
|
-
}, children
|
|
317
|
+
}, children, state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React4.createElement(NaturalListItem.DropIndicator, {
|
|
321
318
|
edge: state.closestEdge
|
|
322
319
|
})));
|
|
323
320
|
} finally {
|
|
324
321
|
_effect.f();
|
|
325
322
|
}
|
|
326
323
|
};
|
|
327
|
-
var
|
|
328
|
-
var _effect = _useSignals4();
|
|
329
|
-
try {
|
|
330
|
-
return /* @__PURE__ */ React4.createElement("button", {
|
|
331
|
-
ref: forwardedRef,
|
|
332
|
-
className: mx3("flex items-center justify-center", classNames),
|
|
333
|
-
...props
|
|
334
|
-
}, /* @__PURE__ */ React4.createElement(Icon2, {
|
|
335
|
-
icon,
|
|
336
|
-
classNames: "cursor-pointer",
|
|
337
|
-
size: 4
|
|
338
|
-
}));
|
|
339
|
-
} finally {
|
|
340
|
-
_effect.f();
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", ...props }) => {
|
|
324
|
+
var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", label, ...props }) => {
|
|
344
325
|
var _effect = _useSignals4();
|
|
345
326
|
try {
|
|
346
327
|
const { state } = useListContext("DELETE_BUTTON");
|
|
347
328
|
const isDisabled = state.type !== "idle" || disabled;
|
|
329
|
+
const { t } = useTranslation("os");
|
|
348
330
|
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
331
|
+
iconOnly: true,
|
|
332
|
+
variant: "ghost",
|
|
333
|
+
...props,
|
|
349
334
|
icon,
|
|
350
335
|
disabled: isDisabled,
|
|
336
|
+
label: label ?? t("delete label"),
|
|
351
337
|
classNames: [
|
|
352
338
|
classNames,
|
|
353
339
|
autoHide && disabled && "hidden"
|
|
354
|
-
]
|
|
355
|
-
...props
|
|
340
|
+
]
|
|
356
341
|
});
|
|
357
342
|
} finally {
|
|
358
343
|
_effect.f();
|
|
359
344
|
}
|
|
360
345
|
};
|
|
361
|
-
var ListItemButton = ({ autoHide = true, classNames, disabled, ...props }) => {
|
|
346
|
+
var ListItemButton = ({ autoHide = true, iconOnly = true, variant = "ghost", classNames, disabled, ...props }) => {
|
|
362
347
|
var _effect = _useSignals4();
|
|
363
348
|
try {
|
|
364
349
|
const { state } = useListContext("ITEM_BUTTON");
|
|
365
350
|
const isDisabled = state.type !== "idle" || disabled;
|
|
366
351
|
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
352
|
+
...props,
|
|
367
353
|
disabled: isDisabled,
|
|
354
|
+
iconOnly,
|
|
355
|
+
variant,
|
|
368
356
|
classNames: [
|
|
369
357
|
classNames,
|
|
370
358
|
autoHide && disabled && "hidden"
|
|
371
|
-
]
|
|
372
|
-
...props
|
|
359
|
+
]
|
|
373
360
|
});
|
|
374
361
|
} finally {
|
|
375
362
|
_effect.f();
|
|
@@ -379,7 +366,11 @@ var ListItemDragHandle = ({ disabled }) => {
|
|
|
379
366
|
var _effect = _useSignals4();
|
|
380
367
|
try {
|
|
381
368
|
const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
|
|
369
|
+
const { t } = useTranslation("os");
|
|
382
370
|
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
371
|
+
iconOnly: true,
|
|
372
|
+
variant: "ghost",
|
|
373
|
+
label: t("drag handle label"),
|
|
383
374
|
ref: dragHandleRef,
|
|
384
375
|
icon: "ph--dots-six-vertical--regular",
|
|
385
376
|
disabled
|
|
@@ -425,8 +416,7 @@ var List = {
|
|
|
425
416
|
ItemDragHandle: ListItemDragHandle,
|
|
426
417
|
ItemDeleteButton: ListItemDeleteButton,
|
|
427
418
|
ItemButton: ListItemButton,
|
|
428
|
-
ItemTitle: ListItemTitle
|
|
429
|
-
IconButton
|
|
419
|
+
ItemTitle: ListItemTitle
|
|
430
420
|
};
|
|
431
421
|
|
|
432
422
|
// src/components/Tree/Tree.tsx
|
|
@@ -446,21 +436,29 @@ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking"
|
|
|
446
436
|
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
447
437
|
import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
448
438
|
import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
449
|
-
import
|
|
439
|
+
import * as Schema from "effect/Schema";
|
|
450
440
|
import React7, { memo as memo3, useCallback as useCallback3, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
|
|
451
441
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
452
|
-
import {
|
|
453
|
-
import { ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls } from "@dxos/react-ui-theme";
|
|
442
|
+
import { TreeItem as NaturalTreeItem, Treegrid } from "@dxos/react-ui";
|
|
443
|
+
import { ghostFocusWithin, ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls } from "@dxos/react-ui-theme";
|
|
444
|
+
|
|
445
|
+
// src/components/Tree/helpers.ts
|
|
446
|
+
var DEFAULT_INDENTATION = 8;
|
|
447
|
+
var paddingIndentation = (level, indentation = DEFAULT_INDENTATION) => ({
|
|
448
|
+
paddingInlineStart: `${(level - 1) * indentation}px`
|
|
449
|
+
});
|
|
454
450
|
|
|
455
451
|
// src/components/Tree/TreeItemHeading.tsx
|
|
456
452
|
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
457
|
-
import React5, { forwardRef
|
|
458
|
-
import { Button, Icon as
|
|
453
|
+
import React5, { forwardRef, memo, useCallback as useCallback2 } from "react";
|
|
454
|
+
import { Button, Icon as Icon2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
459
455
|
import { TextTooltip } from "@dxos/react-ui-text-tooltip";
|
|
460
|
-
|
|
456
|
+
import { getStyles } from "@dxos/react-ui-theme";
|
|
457
|
+
var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label, className, icon, iconHue, disabled, current, onSelect }, forwardedRef) => {
|
|
461
458
|
var _effect = _useSignals5();
|
|
462
459
|
try {
|
|
463
|
-
const { t } =
|
|
460
|
+
const { t } = useTranslation2();
|
|
461
|
+
const styles = iconHue ? getStyles(iconHue) : void 0;
|
|
464
462
|
const handleSelect = useCallback2((event) => {
|
|
465
463
|
onSelect?.(event.altKey);
|
|
466
464
|
}, [
|
|
@@ -497,10 +495,13 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label,
|
|
|
497
495
|
...current && {
|
|
498
496
|
"aria-current": "location"
|
|
499
497
|
}
|
|
500
|
-
}, icon && /* @__PURE__ */ React5.createElement(
|
|
498
|
+
}, icon && /* @__PURE__ */ React5.createElement(Icon2, {
|
|
501
499
|
icon: icon ?? "ph--placeholder--regular",
|
|
502
500
|
size: 5,
|
|
503
|
-
classNames:
|
|
501
|
+
classNames: [
|
|
502
|
+
"mlb-1",
|
|
503
|
+
styles?.icon
|
|
504
|
+
]
|
|
504
505
|
}), /* @__PURE__ */ React5.createElement("span", {
|
|
505
506
|
className: "flex-1 is-0 truncate text-start text-sm font-normal",
|
|
506
507
|
"data-tooltip": true
|
|
@@ -512,41 +513,37 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label,
|
|
|
512
513
|
|
|
513
514
|
// src/components/Tree/TreeItemToggle.tsx
|
|
514
515
|
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
515
|
-
import React6, { forwardRef as
|
|
516
|
-
import {
|
|
517
|
-
var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */
|
|
516
|
+
import React6, { forwardRef as forwardRef2, memo as memo2 } from "react";
|
|
517
|
+
import { IconButton as IconButton2 } from "@dxos/react-ui";
|
|
518
|
+
var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef2(({ open, isBranch, hidden, classNames, ...props }, forwardedRef) => {
|
|
518
519
|
var _effect = _useSignals6();
|
|
519
520
|
try {
|
|
520
|
-
return /* @__PURE__ */ React6.createElement(
|
|
521
|
+
return /* @__PURE__ */ React6.createElement(IconButton2, {
|
|
521
522
|
ref: forwardedRef,
|
|
522
523
|
"data-testid": "treeItem.toggle",
|
|
523
524
|
"aria-expanded": open,
|
|
524
525
|
variant: "ghost",
|
|
525
526
|
density: "fine",
|
|
526
527
|
classNames: [
|
|
527
|
-
"is-6 pli-0
|
|
528
|
-
|
|
528
|
+
"bs-full is-6 pli-0",
|
|
529
|
+
"[&_svg]:transition-[transform] [&_svg]:duration-200",
|
|
530
|
+
open && "[&_svg]:rotate-90",
|
|
531
|
+
hidden ? "hidden" : !isBranch && "invisible",
|
|
532
|
+
classNames
|
|
529
533
|
],
|
|
530
|
-
onClick: onToggle
|
|
531
|
-
}, /* @__PURE__ */ React6.createElement(Icon4, {
|
|
532
|
-
icon: "ph--caret-right--bold",
|
|
533
534
|
size: 3,
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
535
|
+
icon: "ph--caret-right--bold",
|
|
536
|
+
iconOnly: true,
|
|
537
|
+
noTooltip: true,
|
|
538
|
+
label: open ? "Click to close" : "Click to open",
|
|
539
|
+
tabIndex: -1,
|
|
540
|
+
...props
|
|
541
|
+
});
|
|
539
542
|
} finally {
|
|
540
543
|
_effect.f();
|
|
541
544
|
}
|
|
542
545
|
}));
|
|
543
546
|
|
|
544
|
-
// src/components/Tree/helpers.ts
|
|
545
|
-
var DEFAULT_INDENTATION = 8;
|
|
546
|
-
var paddingIndentation = (level, indentation = DEFAULT_INDENTATION) => ({
|
|
547
|
-
paddingInlineStart: `${(level - 1) * indentation}px`
|
|
548
|
-
});
|
|
549
|
-
|
|
550
547
|
// src/components/Tree/TreeItem.tsx
|
|
551
548
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-list/src/components/Tree/TreeItem.tsx";
|
|
552
549
|
var hoverableDescriptionIcons = "[--icons-color:inherit] hover-hover:[--icons-color:var(--description-text)] hover-hover:hover:[--icons-color:inherit] focus-within:[--icons-color:inherit]";
|
|
@@ -556,7 +553,7 @@ var TreeDataSchema = Schema.Struct({
|
|
|
556
553
|
item: Schema.Any
|
|
557
554
|
});
|
|
558
555
|
var isTreeData = (data) => Schema.is(TreeDataSchema)(data);
|
|
559
|
-
var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColumns: Columns, canDrop, onOpenChange, onSelect
|
|
556
|
+
var RawTreeItem = ({ item, path: _path, levelOffset = 2, last, draggable: _draggable, renderColumns: Columns, blockInstruction, canDrop, canSelect, onOpenChange, onSelect }) => {
|
|
560
557
|
var _effect = _useSignals7();
|
|
561
558
|
try {
|
|
562
559
|
const rowRef = useRef2(null);
|
|
@@ -568,7 +565,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
568
565
|
const [menuOpen, setMenuOpen] = useState3(false);
|
|
569
566
|
const { useItems, getProps, isOpen, isCurrent } = useTree();
|
|
570
567
|
const items = useItems(item);
|
|
571
|
-
const { id, label,
|
|
568
|
+
const { id, parentOf, label, className, headingClassName, icon, iconHue, disabled, testId } = getProps(item, _path);
|
|
572
569
|
const path = useMemo(() => [
|
|
573
570
|
..._path,
|
|
574
571
|
id
|
|
@@ -581,6 +578,10 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
581
578
|
const level = path.length - levelOffset;
|
|
582
579
|
const isBranch = !!parentOf;
|
|
583
580
|
const mode = last ? "last-in-group" : open ? "expanded" : "standard";
|
|
581
|
+
const canSelectItem = canSelect?.({
|
|
582
|
+
item,
|
|
583
|
+
path
|
|
584
|
+
}) ?? true;
|
|
584
585
|
const cancelExpand = useCallback3(() => {
|
|
585
586
|
if (cancelExpandRef.current) {
|
|
586
587
|
clearTimeout(cancelExpandRef.current);
|
|
@@ -593,7 +594,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
593
594
|
}
|
|
594
595
|
invariant2(buttonRef.current, void 0, {
|
|
595
596
|
F: __dxlog_file2,
|
|
596
|
-
L:
|
|
597
|
+
L: 112,
|
|
597
598
|
S: void 0,
|
|
598
599
|
A: [
|
|
599
600
|
"buttonRef.current",
|
|
@@ -655,7 +656,16 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
655
656
|
},
|
|
656
657
|
getIsSticky: () => true,
|
|
657
658
|
onDrag: ({ self, source }) => {
|
|
658
|
-
const
|
|
659
|
+
const desired = extractInstruction(self.data);
|
|
660
|
+
const block = desired && blockInstruction?.({
|
|
661
|
+
instruction: desired,
|
|
662
|
+
source: source.data,
|
|
663
|
+
target: data
|
|
664
|
+
});
|
|
665
|
+
const instruction2 = block && desired.type !== "instruction-blocked" ? {
|
|
666
|
+
type: "instruction-blocked",
|
|
667
|
+
desired
|
|
668
|
+
} : desired;
|
|
659
669
|
if (source.data.id !== id) {
|
|
660
670
|
if (instruction2?.type === "make-child" && isBranch && !open && !cancelExpandRef.current) {
|
|
661
671
|
cancelExpandRef.current = setTimeout(() => {
|
|
@@ -693,12 +703,13 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
693
703
|
mode,
|
|
694
704
|
path,
|
|
695
705
|
open,
|
|
706
|
+
blockInstruction,
|
|
696
707
|
canDrop
|
|
697
708
|
]);
|
|
698
709
|
useEffect3(() => () => cancelExpand(), [
|
|
699
710
|
cancelExpand
|
|
700
711
|
]);
|
|
701
|
-
const
|
|
712
|
+
const handleOpenToggle = useCallback3(() => onOpenChange?.({
|
|
702
713
|
item,
|
|
703
714
|
path,
|
|
704
715
|
open: !open
|
|
@@ -709,9 +720,13 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
709
720
|
open
|
|
710
721
|
]);
|
|
711
722
|
const handleSelect = useCallback3((option = false) => {
|
|
712
|
-
if (isBranch) {
|
|
713
|
-
|
|
714
|
-
} else {
|
|
723
|
+
if (isBranch && (option || current)) {
|
|
724
|
+
handleOpenToggle();
|
|
725
|
+
} else if (canSelectItem) {
|
|
726
|
+
canSelect?.({
|
|
727
|
+
item,
|
|
728
|
+
path
|
|
729
|
+
});
|
|
715
730
|
rowRef.current?.focus();
|
|
716
731
|
onSelect?.({
|
|
717
732
|
item,
|
|
@@ -725,25 +740,21 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
725
740
|
path,
|
|
726
741
|
current,
|
|
727
742
|
isBranch,
|
|
728
|
-
|
|
743
|
+
canSelectItem,
|
|
744
|
+
handleOpenToggle,
|
|
729
745
|
onSelect
|
|
730
746
|
]);
|
|
731
747
|
const handleKeyDown = useCallback3((event) => {
|
|
732
748
|
switch (event.key) {
|
|
733
749
|
case "ArrowRight":
|
|
734
|
-
isBranch && !open && handleOpenChange();
|
|
735
|
-
break;
|
|
736
750
|
case "ArrowLeft":
|
|
737
|
-
isBranch &&
|
|
738
|
-
break;
|
|
739
|
-
case " ":
|
|
740
|
-
handleSelect(event.altKey);
|
|
751
|
+
isBranch && handleOpenToggle();
|
|
741
752
|
break;
|
|
742
753
|
}
|
|
743
754
|
}, [
|
|
744
755
|
isBranch,
|
|
745
756
|
open,
|
|
746
|
-
|
|
757
|
+
handleOpenToggle,
|
|
747
758
|
handleSelect
|
|
748
759
|
]);
|
|
749
760
|
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Treegrid.Row, {
|
|
@@ -759,9 +770,10 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
759
770
|
hoverableFocusedWithinControls,
|
|
760
771
|
hoverableDescriptionIcons,
|
|
761
772
|
ghostHover,
|
|
773
|
+
ghostFocusWithin,
|
|
762
774
|
className
|
|
763
775
|
],
|
|
764
|
-
"data-
|
|
776
|
+
"data-object-id": id,
|
|
765
777
|
"data-testid": testId,
|
|
766
778
|
// NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
|
|
767
779
|
// without alerting the user (except for in the correct link element). See also:
|
|
@@ -772,25 +784,25 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
772
784
|
event.preventDefault();
|
|
773
785
|
setMenuOpen(true);
|
|
774
786
|
}
|
|
775
|
-
}, /* @__PURE__ */ React7.createElement(Treegrid.Cell, {
|
|
776
|
-
indent: true,
|
|
777
|
-
classNames: "relative grid grid-cols-subgrid col-[tree-row]",
|
|
778
|
-
style: paddingIndentation(level)
|
|
779
787
|
}, /* @__PURE__ */ React7.createElement("div", {
|
|
780
788
|
role: "none",
|
|
781
|
-
className: "
|
|
789
|
+
className: "indent relative grid grid-cols-subgrid col-[tree-row]",
|
|
790
|
+
style: paddingIndentation(level)
|
|
791
|
+
}, /* @__PURE__ */ React7.createElement(Treegrid.Cell, {
|
|
792
|
+
classNames: "flex items-center"
|
|
782
793
|
}, /* @__PURE__ */ React7.createElement(TreeItemToggle, {
|
|
783
794
|
isBranch,
|
|
784
795
|
open,
|
|
785
|
-
|
|
796
|
+
onClick: handleOpenToggle
|
|
786
797
|
}), /* @__PURE__ */ React7.createElement(TreeItemHeading, {
|
|
787
|
-
ref: buttonRef,
|
|
788
|
-
label,
|
|
789
|
-
icon,
|
|
790
|
-
className: headingClassName,
|
|
791
798
|
disabled,
|
|
792
799
|
current,
|
|
793
|
-
|
|
800
|
+
label,
|
|
801
|
+
className: headingClassName,
|
|
802
|
+
icon,
|
|
803
|
+
iconHue,
|
|
804
|
+
onSelect: handleSelect,
|
|
805
|
+
ref: buttonRef
|
|
794
806
|
})), Columns && /* @__PURE__ */ React7.createElement(Columns, {
|
|
795
807
|
item,
|
|
796
808
|
path,
|
|
@@ -807,7 +819,9 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
807
819
|
last: index === items.length - 1,
|
|
808
820
|
draggable: _draggable,
|
|
809
821
|
renderColumns: Columns,
|
|
822
|
+
blockInstruction,
|
|
810
823
|
canDrop,
|
|
824
|
+
canSelect,
|
|
811
825
|
onOpenChange,
|
|
812
826
|
onSelect
|
|
813
827
|
})));
|
|
@@ -818,7 +832,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColum
|
|
|
818
832
|
var TreeItem = /* @__PURE__ */ memo3(RawTreeItem);
|
|
819
833
|
|
|
820
834
|
// src/components/Tree/Tree.tsx
|
|
821
|
-
var Tree = ({ root, path, id, useItems, getProps, isOpen, isCurrent, draggable: draggable3 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, levelOffset, renderColumns, canDrop, onOpenChange, onSelect }) => {
|
|
835
|
+
var Tree = ({ root, path, id, useItems, getProps, isOpen, isCurrent, draggable: draggable3 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, levelOffset, renderColumns, blockInstruction, canDrop, canSelect, onOpenChange, onSelect }) => {
|
|
822
836
|
var _effect = _useSignals8();
|
|
823
837
|
try {
|
|
824
838
|
const context = useMemo2(() => ({
|
|
@@ -855,7 +869,9 @@ var Tree = ({ root, path, id, useItems, getProps, isOpen, isCurrent, draggable:
|
|
|
855
869
|
levelOffset,
|
|
856
870
|
draggable: draggable3,
|
|
857
871
|
renderColumns,
|
|
872
|
+
blockInstruction,
|
|
858
873
|
canDrop,
|
|
874
|
+
canSelect,
|
|
859
875
|
onOpenChange,
|
|
860
876
|
onSelect
|
|
861
877
|
}))));
|