@dxos/react-ui-list 0.7.4 → 0.7.5-main.9cb18ac
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 +52 -133
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +63 -140
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +52 -133
- package/dist/lib/node-esm/index.mjs.map +4 -4
- 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.map +1 -1
- package/dist/types/src/components/List/ListRoot.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItem.d.ts +1 -0
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +18 -18
- package/src/components/List/ListItem.tsx +5 -3
- package/src/components/Tree/TreeItem.tsx +10 -5
- package/dist/types/src/components/List/DropIndicator.d.ts +0 -11
- package/dist/types/src/components/List/DropIndicator.d.ts.map +0 -1
- package/dist/types/src/components/Tree/DropIndicator.d.ts +0 -8
- package/dist/types/src/components/Tree/DropIndicator.d.ts.map +0 -1
- package/src/components/List/DropIndicator.tsx +0 -69
- package/src/components/Tree/DropIndicator.tsx +0 -78
package/dist/lib/node/index.cjs
CHANGED
|
@@ -48,73 +48,35 @@ var import_react_dom = require("react-dom");
|
|
|
48
48
|
var import_invariant = require("@dxos/invariant");
|
|
49
49
|
var import_react_ui = require("@dxos/react-ui");
|
|
50
50
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
51
|
-
var import_react2 = __toESM(require("react"));
|
|
52
|
-
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
53
51
|
var import_adapter2 = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
54
52
|
var import_closest_edge2 = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
55
53
|
var import_get_reorder_destination_index = require("@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index");
|
|
56
54
|
var import_react_context2 = require("@radix-ui/react-context");
|
|
55
|
+
var import_react2 = __toESM(require("react"));
|
|
57
56
|
var import_react3 = __toESM(require("react"));
|
|
58
|
-
var import_react4 = __toESM(require("react"));
|
|
59
57
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
60
|
-
var
|
|
58
|
+
var import_react4 = require("react");
|
|
61
59
|
var import_debug = require("@dxos/debug");
|
|
62
60
|
var import_combine2 = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
63
61
|
var import_adapter3 = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
64
62
|
var import_tree_item = require("@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item");
|
|
65
|
-
var
|
|
63
|
+
var import_react5 = __toESM(require("react"));
|
|
66
64
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
67
65
|
var import_invariant2 = require("@dxos/invariant");
|
|
68
66
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
72
|
-
var import_react8 = __toESM(require("react"));
|
|
67
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
68
|
+
var import_react6 = __toESM(require("react"));
|
|
73
69
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
74
70
|
var import_react_ui_text_tooltip = require("@dxos/react-ui-text-tooltip");
|
|
75
|
-
var
|
|
76
|
-
var
|
|
71
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
72
|
+
var import_react7 = __toESM(require("react"));
|
|
77
73
|
var import_react_ui5 = require("@dxos/react-ui");
|
|
78
|
-
var
|
|
79
|
-
var edgeToOrientationMap = {
|
|
80
|
-
top: "horizontal",
|
|
81
|
-
bottom: "horizontal",
|
|
82
|
-
left: "vertical",
|
|
83
|
-
right: "vertical"
|
|
84
|
-
};
|
|
85
|
-
var orientationStyles = {
|
|
86
|
-
horizontal: "h-[--line-thickness] left-[--terminal-radius] right-0 before:left-[--negative-terminal-size]",
|
|
87
|
-
vertical: "w-[--line-thickness] top-[--terminal-radius] bottom-0 before:top-[--negative-terminal-size]"
|
|
88
|
-
};
|
|
89
|
-
var edgeStyles = {
|
|
90
|
-
top: "top-[--line-offset] before:top-[--offset-terminal]",
|
|
91
|
-
right: "right-[--line-offset] before:right-[--offset-terminal]",
|
|
92
|
-
bottom: "bottom-[--line-offset] before:bottom-[--offset-terminal]",
|
|
93
|
-
left: "left-[--line-offset] before:left-[--offset-terminal]"
|
|
94
|
-
};
|
|
95
|
-
var strokeSize = 2;
|
|
96
|
-
var terminalSize = 8;
|
|
97
|
-
var offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
|
|
98
|
-
var DropIndicator = ({ edge, gap = 0 }) => {
|
|
99
|
-
const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize}px))`;
|
|
100
|
-
const orientation = edgeToOrientationMap[edge];
|
|
101
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
102
|
-
style: {
|
|
103
|
-
"--line-thickness": `${strokeSize}px`,
|
|
104
|
-
"--line-offset": `${lineOffset}`,
|
|
105
|
-
"--terminal-size": `${terminalSize}px`,
|
|
106
|
-
"--terminal-radius": `${terminalSize / 2}px`,
|
|
107
|
-
"--negative-terminal-size": `-${terminalSize}px`,
|
|
108
|
-
"--offset-terminal": `${offsetToAlignTerminalWithLine}px`
|
|
109
|
-
},
|
|
110
|
-
className: (0, import_react_ui_theme2.mx)("absolute z-10 pointer-events-none bg-blue-700", "before:content-[''] before:w-[--terminal-size] before:h-[--terminal-size] box-border before:absolute", "before:border-[length:--line-thickness] before:border-solid before:border-blue-700 before:rounded-full", orientationStyles[orientation], edgeStyles[edge])
|
|
111
|
-
});
|
|
112
|
-
};
|
|
74
|
+
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
113
75
|
var LIST_NAME = "List";
|
|
114
76
|
var [ListProvider, useListContext] = (0, import_react_context2.createContext)(LIST_NAME);
|
|
115
77
|
var defaultGetId = (item) => item?.id;
|
|
116
78
|
var ListRoot = ({ classNames, children, items, isItem, getId = defaultGetId, onMove, ...props }) => {
|
|
117
|
-
const isEqual = (0,
|
|
79
|
+
const isEqual = (0, import_react2.useCallback)((a, b) => {
|
|
118
80
|
const idA = getId?.(a);
|
|
119
81
|
const idB = getId?.(b);
|
|
120
82
|
if (idA !== void 0 && idB !== void 0) {
|
|
@@ -125,8 +87,8 @@ var ListRoot = ({ classNames, children, items, isItem, getId = defaultGetId, onM
|
|
|
125
87
|
}, [
|
|
126
88
|
getId
|
|
127
89
|
]);
|
|
128
|
-
const [state, setState] = (0,
|
|
129
|
-
(0,
|
|
90
|
+
const [state, setState] = (0, import_react2.useState)(idle);
|
|
91
|
+
(0, import_react2.useEffect)(() => {
|
|
130
92
|
if (!items) {
|
|
131
93
|
return;
|
|
132
94
|
}
|
|
@@ -162,7 +124,7 @@ var ListRoot = ({ classNames, children, items, isItem, getId = defaultGetId, onM
|
|
|
162
124
|
isEqual,
|
|
163
125
|
onMove
|
|
164
126
|
]);
|
|
165
|
-
return /* @__PURE__ */
|
|
127
|
+
return /* @__PURE__ */ import_react2.default.createElement(ListProvider, {
|
|
166
128
|
isItem,
|
|
167
129
|
state,
|
|
168
130
|
setState,
|
|
@@ -191,7 +153,7 @@ var ListItem = ({ children, classNames, item }) => {
|
|
|
191
153
|
const element = ref.current;
|
|
192
154
|
(0, import_invariant.invariant)(element, void 0, {
|
|
193
155
|
F: __dxlog_file,
|
|
194
|
-
L:
|
|
156
|
+
L: 90,
|
|
195
157
|
S: void 0,
|
|
196
158
|
A: [
|
|
197
159
|
"element",
|
|
@@ -228,6 +190,8 @@ var ListItem = ({ children, classNames, item }) => {
|
|
|
228
190
|
container,
|
|
229
191
|
item
|
|
230
192
|
});
|
|
193
|
+
return () => {
|
|
194
|
+
};
|
|
231
195
|
}
|
|
232
196
|
});
|
|
233
197
|
} : void 0,
|
|
@@ -303,7 +267,7 @@ var ListItem = ({ children, classNames, item }) => {
|
|
|
303
267
|
ref,
|
|
304
268
|
role: "listitem",
|
|
305
269
|
className: (0, import_react_ui_theme.mx)("flex overflow-hidden", classNames, stateStyles[state.type])
|
|
306
|
-
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ import_react.default.createElement(DropIndicator, {
|
|
270
|
+
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ import_react.default.createElement(import_react_ui.ListItem.DropIndicator, {
|
|
307
271
|
edge: state.closestEdge
|
|
308
272
|
})));
|
|
309
273
|
};
|
|
@@ -361,59 +325,17 @@ var List = {
|
|
|
361
325
|
ItemTitle: ListItemTitle,
|
|
362
326
|
IconButton
|
|
363
327
|
};
|
|
364
|
-
var TreeContext = /* @__PURE__ */ (0,
|
|
365
|
-
var useTree = () => (0,
|
|
328
|
+
var TreeContext = /* @__PURE__ */ (0, import_react4.createContext)(null);
|
|
329
|
+
var useTree = () => (0, import_react4.useContext)(TreeContext) ?? (0, import_debug.raise)(new Error("TreeContext not found"));
|
|
366
330
|
var TreeProvider = TreeContext.Provider;
|
|
367
|
-
var
|
|
368
|
-
"reorder-above": "sibling",
|
|
369
|
-
"reorder-below": "sibling",
|
|
370
|
-
"make-child": "child",
|
|
371
|
-
reparent: "child"
|
|
372
|
-
};
|
|
373
|
-
var orientationStyles2 = {
|
|
374
|
-
// TODO(wittjosiah): Stop using left/right here.
|
|
375
|
-
sibling: "bs-[--line-thickness] left-[--horizontal-indent] right-0 bg-accentSurface before:left-[--negative-terminal-size]",
|
|
376
|
-
child: "is-full block-start-0 block-end-0 border-[length:--line-thickness] before:invisible"
|
|
377
|
-
};
|
|
378
|
-
var instructionStyles = {
|
|
379
|
-
"reorder-above": "block-start-[--line-offset] before:block-start-[--offset-terminal]",
|
|
380
|
-
"reorder-below": "block-end-[--line-offset] before:block-end-[--offset-terminal]",
|
|
381
|
-
"make-child": "border-accentSurface",
|
|
382
|
-
// TODO(wittjosiah): This is not occurring in the current implementation.
|
|
383
|
-
reparent: ""
|
|
384
|
-
};
|
|
385
|
-
var strokeSize2 = 2;
|
|
386
|
-
var terminalSize2 = 8;
|
|
387
|
-
var offsetToAlignTerminalWithLine2 = (strokeSize2 - terminalSize2) / 2;
|
|
388
|
-
var DropIndicator2 = ({ instruction, gap = 0 }) => {
|
|
389
|
-
const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize2}px))`;
|
|
390
|
-
const isBlocked = instruction.type === "instruction-blocked";
|
|
391
|
-
const desiredInstruction = isBlocked ? instruction.desired : instruction;
|
|
392
|
-
const orientation = edgeToOrientationMap2[desiredInstruction.type];
|
|
393
|
-
if (isBlocked) {
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
return /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
397
|
-
style: {
|
|
398
|
-
"--line-thickness": `${strokeSize2}px`,
|
|
399
|
-
"--line-offset": `${lineOffset}`,
|
|
400
|
-
"--terminal-size": `${terminalSize2}px`,
|
|
401
|
-
"--terminal-radius": `${terminalSize2 / 2}px`,
|
|
402
|
-
"--negative-terminal-size": `-${terminalSize2}px`,
|
|
403
|
-
"--offset-terminal": `${offsetToAlignTerminalWithLine2}px`,
|
|
404
|
-
"--horizontal-indent": `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`
|
|
405
|
-
},
|
|
406
|
-
className: (0, import_react_ui_theme4.mx)("absolute z-10 pointer-events-none", "before:is-[--terminal-size] before:bs-[--terminal-size] box-border before:absolute", "before:border-[length:--line-thickness] before:border-solid before:border-accentSurface before:rounded-full", orientationStyles2[orientation], instructionStyles[desiredInstruction.type])
|
|
407
|
-
});
|
|
408
|
-
};
|
|
409
|
-
var TreeItemHeading = /* @__PURE__ */ (0, import_react8.memo)(/* @__PURE__ */ (0, import_react8.forwardRef)(({ label, icon, className, disabled, current, onSelect }, forwardedRef) => {
|
|
331
|
+
var TreeItemHeading = /* @__PURE__ */ (0, import_react6.memo)(/* @__PURE__ */ (0, import_react6.forwardRef)(({ label, icon, className, disabled, current, onSelect }, forwardedRef) => {
|
|
410
332
|
const { t } = (0, import_react_ui4.useTranslation)();
|
|
411
|
-
const handleSelect = (0,
|
|
333
|
+
const handleSelect = (0, import_react6.useCallback)((event) => {
|
|
412
334
|
onSelect?.(event.altKey);
|
|
413
335
|
}, [
|
|
414
336
|
onSelect
|
|
415
337
|
]);
|
|
416
|
-
const handleButtonKeydown = (0,
|
|
338
|
+
const handleButtonKeydown = (0, import_react6.useCallback)((event) => {
|
|
417
339
|
if (event.key === " " || event.key === "Enter") {
|
|
418
340
|
event.preventDefault();
|
|
419
341
|
event.stopPropagation();
|
|
@@ -422,46 +344,46 @@ var TreeItemHeading = /* @__PURE__ */ (0, import_react8.memo)(/* @__PURE__ */ (0
|
|
|
422
344
|
}, [
|
|
423
345
|
onSelect
|
|
424
346
|
]);
|
|
425
|
-
return /* @__PURE__ */
|
|
347
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_text_tooltip.TextTooltip, {
|
|
426
348
|
text: (0, import_react_ui4.toLocalizedString)(label, t),
|
|
427
349
|
side: "bottom",
|
|
428
350
|
truncateQuery: "span[data-tooltip]",
|
|
429
351
|
onlyWhenTruncating: true,
|
|
430
352
|
asChild: true,
|
|
431
353
|
ref: forwardedRef
|
|
432
|
-
}, /* @__PURE__ */
|
|
354
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui4.Button, {
|
|
433
355
|
"data-testid": "treeItem.heading",
|
|
434
356
|
variant: "ghost",
|
|
435
357
|
density: "fine",
|
|
436
|
-
classNames: (0,
|
|
358
|
+
classNames: (0, import_react_ui_theme3.mx)("grow gap-2 !pis-0.5 hover:!bg-transparent dark:hover:!bg-transparent", "disabled:!cursor-default disabled:!opacity-100", className),
|
|
437
359
|
disabled,
|
|
438
360
|
onClick: handleSelect,
|
|
439
361
|
onKeyDown: handleButtonKeydown,
|
|
440
362
|
...current && {
|
|
441
363
|
"aria-current": "location"
|
|
442
364
|
}
|
|
443
|
-
}, icon && /* @__PURE__ */
|
|
365
|
+
}, icon && /* @__PURE__ */ import_react6.default.createElement(import_react_ui4.Icon, {
|
|
444
366
|
icon: icon ?? "ph--placeholder--regular",
|
|
445
367
|
size: 4,
|
|
446
368
|
classNames: "is-[1em] bs-[1em] mlb-1"
|
|
447
|
-
}), /* @__PURE__ */
|
|
369
|
+
}), /* @__PURE__ */ import_react6.default.createElement("span", {
|
|
448
370
|
className: "flex-1 is-0 truncate text-start text-sm font-normal",
|
|
449
371
|
"data-tooltip": true
|
|
450
372
|
}, (0, import_react_ui4.toLocalizedString)(label, t))));
|
|
451
373
|
}));
|
|
452
|
-
var TreeItemToggle = /* @__PURE__ */ (0,
|
|
453
|
-
return /* @__PURE__ */
|
|
374
|
+
var TreeItemToggle = /* @__PURE__ */ (0, import_react7.memo)(/* @__PURE__ */ (0, import_react7.forwardRef)(({ open, isBranch, onToggle }, forwardedRef) => {
|
|
375
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Button, {
|
|
454
376
|
ref: forwardedRef,
|
|
455
377
|
"data-testid": "treeItem.toggle",
|
|
456
378
|
"aria-expanded": open,
|
|
457
379
|
variant: "ghost",
|
|
458
380
|
density: "fine",
|
|
459
|
-
classNames: (0,
|
|
381
|
+
classNames: (0, import_react_ui_theme4.mx)("is-6 !pli-1", !isBranch && "invisible"),
|
|
460
382
|
onClick: onToggle
|
|
461
|
-
}, /* @__PURE__ */
|
|
383
|
+
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui5.Icon, {
|
|
462
384
|
icon: "ph--caret-right--regular",
|
|
463
385
|
size: 3,
|
|
464
|
-
classNames: (0,
|
|
386
|
+
classNames: (0, import_react_ui_theme4.mx)("transition duration-200", open && "rotate-90")
|
|
465
387
|
}));
|
|
466
388
|
}));
|
|
467
389
|
var DEFAULT_INDENTATION = 8;
|
|
@@ -480,7 +402,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
480
402
|
const { getItems, getProps, isOpen, isCurrent } = useTree();
|
|
481
403
|
const items = getItems(item);
|
|
482
404
|
const { id, label, parentOf, icon, disabled, className, headingClassName, testId } = getProps(item, _path);
|
|
483
|
-
const path = (0,
|
|
405
|
+
const path = (0, import_react5.useMemo)(() => [
|
|
484
406
|
..._path,
|
|
485
407
|
id
|
|
486
408
|
], [
|
|
@@ -492,7 +414,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
492
414
|
const level = path.length - 2;
|
|
493
415
|
const isBranch = !!parentOf;
|
|
494
416
|
const mode = last ? "last-in-group" : open ? "expanded" : "standard";
|
|
495
|
-
const data = (0,
|
|
417
|
+
const data = (0, import_react5.useMemo)(() => ({
|
|
496
418
|
id,
|
|
497
419
|
path,
|
|
498
420
|
item
|
|
@@ -501,26 +423,26 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
501
423
|
path,
|
|
502
424
|
item
|
|
503
425
|
]);
|
|
504
|
-
const rowRef = (0,
|
|
505
|
-
const buttonRef = (0,
|
|
506
|
-
const openRef = (0,
|
|
507
|
-
const cancelExpandRef = (0,
|
|
508
|
-
const [_state, setState] = (0,
|
|
509
|
-
const [instruction, setInstruction] = (0,
|
|
510
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
511
|
-
const cancelExpand = (0,
|
|
426
|
+
const rowRef = (0, import_react5.useRef)(null);
|
|
427
|
+
const buttonRef = (0, import_react5.useRef)(null);
|
|
428
|
+
const openRef = (0, import_react5.useRef)(false);
|
|
429
|
+
const cancelExpandRef = (0, import_react5.useRef)(null);
|
|
430
|
+
const [_state, setState] = (0, import_react5.useState)("idle");
|
|
431
|
+
const [instruction, setInstruction] = (0, import_react5.useState)(null);
|
|
432
|
+
const [menuOpen, setMenuOpen] = (0, import_react5.useState)(false);
|
|
433
|
+
const cancelExpand = (0, import_react5.useCallback)(() => {
|
|
512
434
|
if (cancelExpandRef.current) {
|
|
513
435
|
clearTimeout(cancelExpandRef.current);
|
|
514
436
|
cancelExpandRef.current = null;
|
|
515
437
|
}
|
|
516
438
|
}, []);
|
|
517
|
-
(0,
|
|
439
|
+
(0, import_react5.useEffect)(() => {
|
|
518
440
|
if (!draggable2) {
|
|
519
441
|
return;
|
|
520
442
|
}
|
|
521
443
|
(0, import_invariant2.invariant)(buttonRef.current, void 0, {
|
|
522
444
|
F: __dxlog_file2,
|
|
523
|
-
L:
|
|
445
|
+
L: 109,
|
|
524
446
|
S: void 0,
|
|
525
447
|
A: [
|
|
526
448
|
"buttonRef.current",
|
|
@@ -610,10 +532,10 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
610
532
|
open,
|
|
611
533
|
canDrop
|
|
612
534
|
]);
|
|
613
|
-
(0,
|
|
535
|
+
(0, import_react5.useEffect)(() => () => cancelExpand(), [
|
|
614
536
|
cancelExpand
|
|
615
537
|
]);
|
|
616
|
-
const handleOpenChange = (0,
|
|
538
|
+
const handleOpenChange = (0, import_react5.useCallback)(() => onOpenChange?.({
|
|
617
539
|
item,
|
|
618
540
|
path,
|
|
619
541
|
open: !open
|
|
@@ -623,7 +545,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
623
545
|
path,
|
|
624
546
|
open
|
|
625
547
|
]);
|
|
626
|
-
const handleSelect = (0,
|
|
548
|
+
const handleSelect = (0, import_react5.useCallback)((option = false) => {
|
|
627
549
|
rowRef.current?.focus();
|
|
628
550
|
onSelect?.({
|
|
629
551
|
item,
|
|
@@ -637,7 +559,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
637
559
|
path,
|
|
638
560
|
current
|
|
639
561
|
]);
|
|
640
|
-
const handleKeyDown = (0,
|
|
562
|
+
const handleKeyDown = (0, import_react5.useCallback)((event) => {
|
|
641
563
|
switch (event.key) {
|
|
642
564
|
case "ArrowRight":
|
|
643
565
|
isBranch && !open && handleOpenChange();
|
|
@@ -655,13 +577,13 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
655
577
|
handleOpenChange,
|
|
656
578
|
handleSelect
|
|
657
579
|
]);
|
|
658
|
-
return /* @__PURE__ */
|
|
580
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Treegrid.Row, {
|
|
659
581
|
ref: rowRef,
|
|
660
582
|
key: id,
|
|
661
583
|
id,
|
|
662
584
|
"aria-labelledby": `${id}__label`,
|
|
663
585
|
parentOf: parentOf?.join(import_react_ui3.Treegrid.PARENT_OF_SEPARATOR),
|
|
664
|
-
classNames: (0,
|
|
586
|
+
classNames: (0, import_react_ui_theme2.mx)("grid grid-cols-subgrid col-[tree-row] mt-[2px] aria-[current]:bg-input", import_react_ui_theme2.hoverableControls, import_react_ui_theme2.hoverableFocusedKeyboardControls, import_react_ui_theme2.hoverableFocusedWithinControls, hoverableDescriptionIcons, import_react_ui_theme2.ghostHover, import_react_ui_theme2.focusRing, className),
|
|
665
587
|
"data-itemid": id,
|
|
666
588
|
"data-testid": testId,
|
|
667
589
|
// NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
|
|
@@ -673,18 +595,18 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
673
595
|
event.preventDefault();
|
|
674
596
|
setMenuOpen(true);
|
|
675
597
|
}
|
|
676
|
-
}, /* @__PURE__ */
|
|
598
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.Treegrid.Cell, {
|
|
677
599
|
indent: true,
|
|
678
600
|
classNames: "relative grid grid-cols-subgrid col-[tree-row]",
|
|
679
601
|
style: paddingIndendation(level)
|
|
680
|
-
}, /* @__PURE__ */
|
|
602
|
+
}, /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
681
603
|
role: "none",
|
|
682
604
|
className: "flex items-center"
|
|
683
|
-
}, /* @__PURE__ */
|
|
605
|
+
}, /* @__PURE__ */ import_react5.default.createElement(TreeItemToggle, {
|
|
684
606
|
open,
|
|
685
607
|
isBranch,
|
|
686
608
|
onToggle: handleOpenChange
|
|
687
|
-
}), /* @__PURE__ */
|
|
609
|
+
}), /* @__PURE__ */ import_react5.default.createElement(TreeItemHeading, {
|
|
688
610
|
ref: buttonRef,
|
|
689
611
|
label,
|
|
690
612
|
icon,
|
|
@@ -692,15 +614,16 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
692
614
|
disabled,
|
|
693
615
|
current,
|
|
694
616
|
onSelect: handleSelect
|
|
695
|
-
})), Columns && /* @__PURE__ */
|
|
617
|
+
})), Columns && /* @__PURE__ */ import_react5.default.createElement(Columns, {
|
|
696
618
|
item,
|
|
697
619
|
path,
|
|
620
|
+
open,
|
|
698
621
|
menuOpen,
|
|
699
622
|
setMenuOpen
|
|
700
|
-
}), instruction && /* @__PURE__ */
|
|
623
|
+
}), instruction && /* @__PURE__ */ import_react5.default.createElement(import_react_ui3.TreeItem.DropIndicator, {
|
|
701
624
|
instruction,
|
|
702
625
|
gap: 2
|
|
703
|
-
}))), open && items.map((item2, index) => /* @__PURE__ */
|
|
626
|
+
}))), open && items.map((item2, index) => /* @__PURE__ */ import_react5.default.createElement(TreeItem, {
|
|
704
627
|
key: item2.id,
|
|
705
628
|
item: item2,
|
|
706
629
|
path,
|
|
@@ -712,9 +635,9 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
712
635
|
onSelect
|
|
713
636
|
})));
|
|
714
637
|
};
|
|
715
|
-
var TreeItem = /* @__PURE__ */ (0,
|
|
638
|
+
var TreeItem = /* @__PURE__ */ (0, import_react5.memo)(RawTreeItem);
|
|
716
639
|
var Tree = ({ id, getItems, getProps, isOpen, isCurrent, draggable: draggable2 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, renderColumns, canDrop, onOpenChange, onSelect }) => {
|
|
717
|
-
const context = (0,
|
|
640
|
+
const context = (0, import_react3.useMemo)(() => ({
|
|
718
641
|
getItems,
|
|
719
642
|
getProps,
|
|
720
643
|
isOpen,
|
|
@@ -726,17 +649,17 @@ var Tree = ({ id, getItems, getProps, isOpen, isCurrent, draggable: draggable2 =
|
|
|
726
649
|
isCurrent
|
|
727
650
|
]);
|
|
728
651
|
const items = getItems();
|
|
729
|
-
const path = (0,
|
|
652
|
+
const path = (0, import_react3.useMemo)(() => [
|
|
730
653
|
id
|
|
731
654
|
], [
|
|
732
655
|
id
|
|
733
656
|
]);
|
|
734
|
-
return /* @__PURE__ */
|
|
657
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.Treegrid.Root, {
|
|
735
658
|
gridTemplateColumns,
|
|
736
659
|
classNames
|
|
737
|
-
}, /* @__PURE__ */
|
|
660
|
+
}, /* @__PURE__ */ import_react3.default.createElement(TreeProvider, {
|
|
738
661
|
value: context
|
|
739
|
-
}, items.map((item, index) => /* @__PURE__ */
|
|
662
|
+
}, items.map((item, index) => /* @__PURE__ */ import_react3.default.createElement(TreeItem, {
|
|
740
663
|
key: item.id,
|
|
741
664
|
item,
|
|
742
665
|
last: index === items.length - 1,
|