@dxos/react-ui-list 0.7.4 → 0.7.5-feature-compute.4d9d99a
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 +132 -209
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +142 -215
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +132 -209
- 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 +2 -1
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +19 -19
- package/src/components/List/ListItem.tsx +5 -3
- package/src/components/Tree/TreeItem.tsx +17 -15
- 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
|
@@ -4,56 +4,18 @@ import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-d
|
|
|
4
4
|
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
5
5
|
import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
6
6
|
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
7
|
-
import
|
|
7
|
+
import React2, { forwardRef, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
9
|
import { invariant } from "@dxos/invariant";
|
|
10
|
-
import { Icon } from "@dxos/react-ui";
|
|
11
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
12
|
-
|
|
13
|
-
// packages/ui/react-ui-list/src/components/List/DropIndicator.tsx
|
|
14
|
-
import React from "react";
|
|
10
|
+
import { Icon, ListItem as NaturalListItem } from "@dxos/react-ui";
|
|
15
11
|
import { mx } from "@dxos/react-ui-theme";
|
|
16
|
-
var edgeToOrientationMap = {
|
|
17
|
-
top: "horizontal",
|
|
18
|
-
bottom: "horizontal",
|
|
19
|
-
left: "vertical",
|
|
20
|
-
right: "vertical"
|
|
21
|
-
};
|
|
22
|
-
var orientationStyles = {
|
|
23
|
-
horizontal: "h-[--line-thickness] left-[--terminal-radius] right-0 before:left-[--negative-terminal-size]",
|
|
24
|
-
vertical: "w-[--line-thickness] top-[--terminal-radius] bottom-0 before:top-[--negative-terminal-size]"
|
|
25
|
-
};
|
|
26
|
-
var edgeStyles = {
|
|
27
|
-
top: "top-[--line-offset] before:top-[--offset-terminal]",
|
|
28
|
-
right: "right-[--line-offset] before:right-[--offset-terminal]",
|
|
29
|
-
bottom: "bottom-[--line-offset] before:bottom-[--offset-terminal]",
|
|
30
|
-
left: "left-[--line-offset] before:left-[--offset-terminal]"
|
|
31
|
-
};
|
|
32
|
-
var strokeSize = 2;
|
|
33
|
-
var terminalSize = 8;
|
|
34
|
-
var offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
|
|
35
|
-
var DropIndicator = ({ edge, gap = 0 }) => {
|
|
36
|
-
const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize}px))`;
|
|
37
|
-
const orientation = edgeToOrientationMap[edge];
|
|
38
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
39
|
-
style: {
|
|
40
|
-
"--line-thickness": `${strokeSize}px`,
|
|
41
|
-
"--line-offset": `${lineOffset}`,
|
|
42
|
-
"--terminal-size": `${terminalSize}px`,
|
|
43
|
-
"--terminal-radius": `${terminalSize / 2}px`,
|
|
44
|
-
"--negative-terminal-size": `-${terminalSize}px`,
|
|
45
|
-
"--offset-terminal": `${offsetToAlignTerminalWithLine}px`
|
|
46
|
-
},
|
|
47
|
-
className: 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])
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
12
|
|
|
51
13
|
// packages/ui/react-ui-list/src/components/List/ListRoot.tsx
|
|
52
14
|
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
53
15
|
import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
54
16
|
import { getReorderDestinationIndex } from "@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index";
|
|
55
17
|
import { createContext } from "@radix-ui/react-context";
|
|
56
|
-
import
|
|
18
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
57
19
|
var LIST_NAME = "List";
|
|
58
20
|
var [ListProvider, useListContext] = createContext(LIST_NAME);
|
|
59
21
|
var defaultGetId = (item) => item?.id;
|
|
@@ -106,7 +68,7 @@ var ListRoot = ({ classNames, children, items, isItem, getId = defaultGetId, onM
|
|
|
106
68
|
isEqual,
|
|
107
69
|
onMove
|
|
108
70
|
]);
|
|
109
|
-
return /* @__PURE__ */
|
|
71
|
+
return /* @__PURE__ */ React.createElement(ListProvider, {
|
|
110
72
|
isItem,
|
|
111
73
|
state,
|
|
112
74
|
setState,
|
|
@@ -137,7 +99,7 @@ var ListItem = ({ children, classNames, item }) => {
|
|
|
137
99
|
const element = ref.current;
|
|
138
100
|
invariant(element, void 0, {
|
|
139
101
|
F: __dxlog_file,
|
|
140
|
-
L:
|
|
102
|
+
L: 90,
|
|
141
103
|
S: void 0,
|
|
142
104
|
A: [
|
|
143
105
|
"element",
|
|
@@ -174,6 +136,8 @@ var ListItem = ({ children, classNames, item }) => {
|
|
|
174
136
|
container,
|
|
175
137
|
item
|
|
176
138
|
});
|
|
139
|
+
return () => {
|
|
140
|
+
};
|
|
177
141
|
}
|
|
178
142
|
});
|
|
179
143
|
} : void 0,
|
|
@@ -240,25 +204,25 @@ var ListItem = ({ children, classNames, item }) => {
|
|
|
240
204
|
}, [
|
|
241
205
|
item
|
|
242
206
|
]);
|
|
243
|
-
return /* @__PURE__ */
|
|
207
|
+
return /* @__PURE__ */ React2.createElement(ListItemProvider, {
|
|
244
208
|
item,
|
|
245
209
|
dragHandleRef
|
|
246
|
-
}, /* @__PURE__ */
|
|
210
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
247
211
|
className: "relative"
|
|
248
|
-
}, /* @__PURE__ */
|
|
212
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
249
213
|
ref,
|
|
250
214
|
role: "listitem",
|
|
251
|
-
className:
|
|
252
|
-
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */
|
|
215
|
+
className: mx("flex overflow-hidden", classNames, stateStyles[state.type])
|
|
216
|
+
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React2.createElement(NaturalListItem.DropIndicator, {
|
|
253
217
|
edge: state.closestEdge
|
|
254
218
|
})));
|
|
255
219
|
};
|
|
256
220
|
var IconButton = /* @__PURE__ */ forwardRef(({ classNames, icon, ...props }, forwardedRef) => {
|
|
257
|
-
return /* @__PURE__ */
|
|
221
|
+
return /* @__PURE__ */ React2.createElement("button", {
|
|
258
222
|
ref: forwardedRef,
|
|
259
|
-
className:
|
|
223
|
+
className: mx("flex items-center justify-center", classNames),
|
|
260
224
|
...props
|
|
261
|
-
}, /* @__PURE__ */
|
|
225
|
+
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
262
226
|
icon,
|
|
263
227
|
classNames: "cursor-pointer",
|
|
264
228
|
size: 4
|
|
@@ -267,7 +231,7 @@ var IconButton = /* @__PURE__ */ forwardRef(({ classNames, icon, ...props }, for
|
|
|
267
231
|
var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, ...props }) => {
|
|
268
232
|
const { state } = useListContext("DELETE_BUTTON");
|
|
269
233
|
const isDisabled = state.type !== "idle" || disabled;
|
|
270
|
-
return /* @__PURE__ */
|
|
234
|
+
return /* @__PURE__ */ React2.createElement(IconButton, {
|
|
271
235
|
icon: "ph--x--regular",
|
|
272
236
|
disabled: isDisabled,
|
|
273
237
|
classNames: [
|
|
@@ -279,7 +243,7 @@ var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, ...props })
|
|
|
279
243
|
};
|
|
280
244
|
var ListItemDragHandle = () => {
|
|
281
245
|
const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
|
|
282
|
-
return /* @__PURE__ */
|
|
246
|
+
return /* @__PURE__ */ React2.createElement(IconButton, {
|
|
283
247
|
ref: dragHandleRef,
|
|
284
248
|
icon: "ph--dots-six-vertical--regular"
|
|
285
249
|
});
|
|
@@ -290,11 +254,11 @@ var ListItemDragPreview = ({ children }) => {
|
|
|
290
254
|
item: state.item
|
|
291
255
|
}), state.container) : null;
|
|
292
256
|
};
|
|
293
|
-
var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */
|
|
294
|
-
className:
|
|
257
|
+
var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */ React2.createElement("div", {
|
|
258
|
+
className: mx("flex is-full gap-2", classNames)
|
|
295
259
|
}, children);
|
|
296
|
-
var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */
|
|
297
|
-
className:
|
|
260
|
+
var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */ React2.createElement("div", {
|
|
261
|
+
className: mx("flex grow items-center truncate", classNames),
|
|
298
262
|
...props
|
|
299
263
|
}, children);
|
|
300
264
|
|
|
@@ -311,7 +275,7 @@ var List = {
|
|
|
311
275
|
};
|
|
312
276
|
|
|
313
277
|
// packages/ui/react-ui-list/src/components/Tree/Tree.tsx
|
|
314
|
-
import
|
|
278
|
+
import React6, { useMemo as useMemo2 } from "react";
|
|
315
279
|
import { Treegrid as Treegrid2 } from "@dxos/react-ui";
|
|
316
280
|
|
|
317
281
|
// packages/ui/react-ui-list/src/components/Tree/TreeContext.tsx
|
|
@@ -323,65 +287,19 @@ var TreeProvider = TreeContext.Provider;
|
|
|
323
287
|
|
|
324
288
|
// packages/ui/react-ui-list/src/components/Tree/TreeItem.tsx
|
|
325
289
|
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
326
|
-
import { draggable as
|
|
290
|
+
import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
327
291
|
import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
328
|
-
import
|
|
292
|
+
import React5, { memo as memo3, useCallback as useCallback3, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
|
|
329
293
|
import { S } from "@dxos/echo-schema";
|
|
330
294
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
331
|
-
import { Treegrid } from "@dxos/react-ui";
|
|
332
|
-
import { focusRing, ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, mx as
|
|
333
|
-
|
|
334
|
-
// packages/ui/react-ui-list/src/components/Tree/DropIndicator.tsx
|
|
335
|
-
import React4 from "react";
|
|
336
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
337
|
-
var edgeToOrientationMap2 = {
|
|
338
|
-
"reorder-above": "sibling",
|
|
339
|
-
"reorder-below": "sibling",
|
|
340
|
-
"make-child": "child",
|
|
341
|
-
reparent: "child"
|
|
342
|
-
};
|
|
343
|
-
var orientationStyles2 = {
|
|
344
|
-
// TODO(wittjosiah): Stop using left/right here.
|
|
345
|
-
sibling: "bs-[--line-thickness] left-[--horizontal-indent] right-0 bg-accentSurface before:left-[--negative-terminal-size]",
|
|
346
|
-
child: "is-full block-start-0 block-end-0 border-[length:--line-thickness] before:invisible"
|
|
347
|
-
};
|
|
348
|
-
var instructionStyles = {
|
|
349
|
-
"reorder-above": "block-start-[--line-offset] before:block-start-[--offset-terminal]",
|
|
350
|
-
"reorder-below": "block-end-[--line-offset] before:block-end-[--offset-terminal]",
|
|
351
|
-
"make-child": "border-accentSurface",
|
|
352
|
-
// TODO(wittjosiah): This is not occurring in the current implementation.
|
|
353
|
-
reparent: ""
|
|
354
|
-
};
|
|
355
|
-
var strokeSize2 = 2;
|
|
356
|
-
var terminalSize2 = 8;
|
|
357
|
-
var offsetToAlignTerminalWithLine2 = (strokeSize2 - terminalSize2) / 2;
|
|
358
|
-
var DropIndicator2 = ({ instruction, gap = 0 }) => {
|
|
359
|
-
const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize2}px))`;
|
|
360
|
-
const isBlocked = instruction.type === "instruction-blocked";
|
|
361
|
-
const desiredInstruction = isBlocked ? instruction.desired : instruction;
|
|
362
|
-
const orientation = edgeToOrientationMap2[desiredInstruction.type];
|
|
363
|
-
if (isBlocked) {
|
|
364
|
-
return null;
|
|
365
|
-
}
|
|
366
|
-
return /* @__PURE__ */ React4.createElement("div", {
|
|
367
|
-
style: {
|
|
368
|
-
"--line-thickness": `${strokeSize2}px`,
|
|
369
|
-
"--line-offset": `${lineOffset}`,
|
|
370
|
-
"--terminal-size": `${terminalSize2}px`,
|
|
371
|
-
"--terminal-radius": `${terminalSize2 / 2}px`,
|
|
372
|
-
"--negative-terminal-size": `-${terminalSize2}px`,
|
|
373
|
-
"--offset-terminal": `${offsetToAlignTerminalWithLine2}px`,
|
|
374
|
-
"--horizontal-indent": `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`
|
|
375
|
-
},
|
|
376
|
-
className: mx3("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])
|
|
377
|
-
});
|
|
378
|
-
};
|
|
295
|
+
import { Treegrid, TreeItem as NaturalTreeItem } from "@dxos/react-ui";
|
|
296
|
+
import { focusRing, ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, mx as mx4 } from "@dxos/react-ui-theme";
|
|
379
297
|
|
|
380
298
|
// packages/ui/react-ui-list/src/components/Tree/TreeItemHeading.tsx
|
|
381
|
-
import
|
|
299
|
+
import React3, { forwardRef as forwardRef2, memo, useCallback as useCallback2 } from "react";
|
|
382
300
|
import { Button, Icon as Icon2, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
383
301
|
import { TextTooltip } from "@dxos/react-ui-text-tooltip";
|
|
384
|
-
import { mx as
|
|
302
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
385
303
|
var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label, icon, className, disabled, current, onSelect }, forwardedRef) => {
|
|
386
304
|
const { t } = useTranslation();
|
|
387
305
|
const handleSelect = useCallback2((event) => {
|
|
@@ -398,51 +316,51 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ label,
|
|
|
398
316
|
}, [
|
|
399
317
|
onSelect
|
|
400
318
|
]);
|
|
401
|
-
return /* @__PURE__ */
|
|
319
|
+
return /* @__PURE__ */ React3.createElement(TextTooltip, {
|
|
402
320
|
text: toLocalizedString(label, t),
|
|
403
321
|
side: "bottom",
|
|
404
322
|
truncateQuery: "span[data-tooltip]",
|
|
405
323
|
onlyWhenTruncating: true,
|
|
406
324
|
asChild: true,
|
|
407
325
|
ref: forwardedRef
|
|
408
|
-
}, /* @__PURE__ */
|
|
326
|
+
}, /* @__PURE__ */ React3.createElement(Button, {
|
|
409
327
|
"data-testid": "treeItem.heading",
|
|
410
328
|
variant: "ghost",
|
|
411
329
|
density: "fine",
|
|
412
|
-
classNames:
|
|
330
|
+
classNames: mx2("grow gap-2 !pis-0.5 hover:!bg-transparent dark:hover:!bg-transparent", "disabled:!cursor-default disabled:!opacity-100", className),
|
|
413
331
|
disabled,
|
|
414
332
|
onClick: handleSelect,
|
|
415
333
|
onKeyDown: handleButtonKeydown,
|
|
416
334
|
...current && {
|
|
417
335
|
"aria-current": "location"
|
|
418
336
|
}
|
|
419
|
-
}, icon && /* @__PURE__ */
|
|
337
|
+
}, icon && /* @__PURE__ */ React3.createElement(Icon2, {
|
|
420
338
|
icon: icon ?? "ph--placeholder--regular",
|
|
421
339
|
size: 4,
|
|
422
340
|
classNames: "is-[1em] bs-[1em] mlb-1"
|
|
423
|
-
}), /* @__PURE__ */
|
|
341
|
+
}), /* @__PURE__ */ React3.createElement("span", {
|
|
424
342
|
className: "flex-1 is-0 truncate text-start text-sm font-normal",
|
|
425
343
|
"data-tooltip": true
|
|
426
344
|
}, toLocalizedString(label, t))));
|
|
427
345
|
}));
|
|
428
346
|
|
|
429
347
|
// packages/ui/react-ui-list/src/components/Tree/TreeItemToggle.tsx
|
|
430
|
-
import
|
|
348
|
+
import React4, { forwardRef as forwardRef3, memo as memo2 } from "react";
|
|
431
349
|
import { Button as Button2, Icon as Icon3 } from "@dxos/react-ui";
|
|
432
|
-
import { mx as
|
|
350
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
433
351
|
var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef3(({ open, isBranch, onToggle }, forwardedRef) => {
|
|
434
|
-
return /* @__PURE__ */
|
|
352
|
+
return /* @__PURE__ */ React4.createElement(Button2, {
|
|
435
353
|
ref: forwardedRef,
|
|
436
354
|
"data-testid": "treeItem.toggle",
|
|
437
355
|
"aria-expanded": open,
|
|
438
356
|
variant: "ghost",
|
|
439
357
|
density: "fine",
|
|
440
|
-
classNames:
|
|
358
|
+
classNames: mx3("is-6 !pli-1", !isBranch && "invisible"),
|
|
441
359
|
onClick: onToggle
|
|
442
|
-
}, /* @__PURE__ */
|
|
360
|
+
}, /* @__PURE__ */ React4.createElement(Icon3, {
|
|
443
361
|
icon: "ph--caret-right--regular",
|
|
444
362
|
size: 3,
|
|
445
|
-
classNames:
|
|
363
|
+
classNames: mx3("transition duration-200", open && "rotate-90")
|
|
446
364
|
}));
|
|
447
365
|
}));
|
|
448
366
|
|
|
@@ -461,7 +379,7 @@ var TreeDataSchema = S.Struct({
|
|
|
461
379
|
item: S.Any
|
|
462
380
|
});
|
|
463
381
|
var isTreeData = (data) => S.is(TreeDataSchema)(data);
|
|
464
|
-
var RawTreeItem = ({ item, path: _path, last, draggable:
|
|
382
|
+
var RawTreeItem = ({ item, path: _path, last, draggable: _draggable, renderColumns: Columns, canDrop, onOpenChange, onSelect }) => {
|
|
465
383
|
const { getItems, getProps, isOpen, isCurrent } = useTree();
|
|
466
384
|
const items = getItems(item);
|
|
467
385
|
const { id, label, parentOf, icon, disabled, className, headingClassName, testId } = getProps(item, _path);
|
|
@@ -500,94 +418,98 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
500
418
|
}
|
|
501
419
|
}, []);
|
|
502
420
|
useEffect3(() => {
|
|
503
|
-
if (!
|
|
421
|
+
if (!_draggable) {
|
|
504
422
|
return;
|
|
505
423
|
}
|
|
506
424
|
invariant2(buttonRef.current, void 0, {
|
|
507
425
|
F: __dxlog_file2,
|
|
508
|
-
L:
|
|
426
|
+
L: 105,
|
|
509
427
|
S: void 0,
|
|
510
428
|
A: [
|
|
511
429
|
"buttonRef.current",
|
|
512
430
|
""
|
|
513
431
|
]
|
|
514
432
|
});
|
|
515
|
-
return combine2(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
433
|
+
return combine2(
|
|
434
|
+
draggable2({
|
|
435
|
+
element: buttonRef.current,
|
|
436
|
+
getInitialData: () => data,
|
|
437
|
+
onDragStart: () => {
|
|
438
|
+
setState("dragging");
|
|
439
|
+
if (open) {
|
|
440
|
+
openRef.current = true;
|
|
441
|
+
onOpenChange?.({
|
|
442
|
+
item,
|
|
443
|
+
path,
|
|
444
|
+
open: false
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
onDrop: () => {
|
|
449
|
+
setState("idle");
|
|
450
|
+
if (openRef.current) {
|
|
451
|
+
onOpenChange?.({
|
|
452
|
+
item,
|
|
453
|
+
path,
|
|
454
|
+
open: true
|
|
455
|
+
});
|
|
456
|
+
}
|
|
527
457
|
}
|
|
528
|
-
},
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
458
|
+
}),
|
|
459
|
+
// https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/hitbox/constellation/index/about.mdx
|
|
460
|
+
dropTargetForElements2({
|
|
461
|
+
element: buttonRef.current,
|
|
462
|
+
getData: ({ input, element }) => {
|
|
463
|
+
return attachInstruction(data, {
|
|
464
|
+
input,
|
|
465
|
+
element,
|
|
466
|
+
indentPerLevel: DEFAULT_INDENTATION,
|
|
467
|
+
currentLevel: level,
|
|
468
|
+
mode,
|
|
469
|
+
block: isBranch ? [] : [
|
|
470
|
+
"make-child"
|
|
471
|
+
]
|
|
536
472
|
});
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
onOpenChange?.({
|
|
564
|
-
item,
|
|
565
|
-
path,
|
|
566
|
-
open: true
|
|
567
|
-
});
|
|
568
|
-
}, 500);
|
|
569
|
-
}
|
|
570
|
-
if (instruction2?.type !== "make-child") {
|
|
571
|
-
cancelExpand();
|
|
473
|
+
},
|
|
474
|
+
canDrop: ({ source }) => {
|
|
475
|
+
const _canDrop = canDrop ?? (() => true);
|
|
476
|
+
return source.element !== buttonRef.current && _canDrop(source.data, data);
|
|
477
|
+
},
|
|
478
|
+
getIsSticky: () => true,
|
|
479
|
+
onDrag: ({ self, source }) => {
|
|
480
|
+
const instruction2 = extractInstruction(self.data);
|
|
481
|
+
if (source.data.id !== id) {
|
|
482
|
+
if (instruction2?.type === "make-child" && isBranch && !open && !cancelExpandRef.current) {
|
|
483
|
+
cancelExpandRef.current = setTimeout(() => {
|
|
484
|
+
onOpenChange?.({
|
|
485
|
+
item,
|
|
486
|
+
path,
|
|
487
|
+
open: true
|
|
488
|
+
});
|
|
489
|
+
}, 500);
|
|
490
|
+
}
|
|
491
|
+
if (instruction2?.type !== "make-child") {
|
|
492
|
+
cancelExpand();
|
|
493
|
+
}
|
|
494
|
+
setInstruction(instruction2);
|
|
495
|
+
} else if (instruction2?.type === "reparent") {
|
|
496
|
+
setInstruction(instruction2);
|
|
497
|
+
} else {
|
|
498
|
+
setInstruction(null);
|
|
572
499
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
500
|
+
},
|
|
501
|
+
onDragLeave: () => {
|
|
502
|
+
cancelExpand();
|
|
503
|
+
setInstruction(null);
|
|
504
|
+
},
|
|
505
|
+
onDrop: () => {
|
|
506
|
+
cancelExpand();
|
|
577
507
|
setInstruction(null);
|
|
578
508
|
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
cancelExpand();
|
|
582
|
-
setInstruction(null);
|
|
583
|
-
},
|
|
584
|
-
onDrop: () => {
|
|
585
|
-
cancelExpand();
|
|
586
|
-
setInstruction(null);
|
|
587
|
-
}
|
|
588
|
-
}));
|
|
509
|
+
})
|
|
510
|
+
);
|
|
589
511
|
}, [
|
|
590
|
-
|
|
512
|
+
_draggable,
|
|
591
513
|
item,
|
|
592
514
|
id,
|
|
593
515
|
mode,
|
|
@@ -640,13 +562,13 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
640
562
|
handleOpenChange,
|
|
641
563
|
handleSelect
|
|
642
564
|
]);
|
|
643
|
-
return /* @__PURE__ */
|
|
565
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(Treegrid.Row, {
|
|
644
566
|
ref: rowRef,
|
|
645
567
|
key: id,
|
|
646
568
|
id,
|
|
647
569
|
"aria-labelledby": `${id}__label`,
|
|
648
570
|
parentOf: parentOf?.join(Treegrid.PARENT_OF_SEPARATOR),
|
|
649
|
-
classNames:
|
|
571
|
+
classNames: mx4("grid grid-cols-subgrid col-[tree-row] mt-[2px] aria-[current]:bg-input", hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, hoverableDescriptionIcons, ghostHover, focusRing, className),
|
|
650
572
|
"data-itemid": id,
|
|
651
573
|
"data-testid": testId,
|
|
652
574
|
// NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
|
|
@@ -658,18 +580,18 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
658
580
|
event.preventDefault();
|
|
659
581
|
setMenuOpen(true);
|
|
660
582
|
}
|
|
661
|
-
}, /* @__PURE__ */
|
|
583
|
+
}, /* @__PURE__ */ React5.createElement(Treegrid.Cell, {
|
|
662
584
|
indent: true,
|
|
663
585
|
classNames: "relative grid grid-cols-subgrid col-[tree-row]",
|
|
664
586
|
style: paddingIndendation(level)
|
|
665
|
-
}, /* @__PURE__ */
|
|
587
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
666
588
|
role: "none",
|
|
667
589
|
className: "flex items-center"
|
|
668
|
-
}, /* @__PURE__ */
|
|
590
|
+
}, /* @__PURE__ */ React5.createElement(TreeItemToggle, {
|
|
669
591
|
open,
|
|
670
592
|
isBranch,
|
|
671
593
|
onToggle: handleOpenChange
|
|
672
|
-
}), /* @__PURE__ */
|
|
594
|
+
}), /* @__PURE__ */ React5.createElement(TreeItemHeading, {
|
|
673
595
|
ref: buttonRef,
|
|
674
596
|
label,
|
|
675
597
|
icon,
|
|
@@ -677,20 +599,21 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
677
599
|
disabled,
|
|
678
600
|
current,
|
|
679
601
|
onSelect: handleSelect
|
|
680
|
-
})), Columns && /* @__PURE__ */
|
|
602
|
+
})), Columns && /* @__PURE__ */ React5.createElement(Columns, {
|
|
681
603
|
item,
|
|
682
604
|
path,
|
|
605
|
+
open,
|
|
683
606
|
menuOpen,
|
|
684
607
|
setMenuOpen
|
|
685
|
-
}), instruction && /* @__PURE__ */
|
|
608
|
+
}), instruction && /* @__PURE__ */ React5.createElement(NaturalTreeItem.DropIndicator, {
|
|
686
609
|
instruction,
|
|
687
610
|
gap: 2
|
|
688
|
-
}))), open && items.map((item2, index) => /* @__PURE__ */
|
|
611
|
+
}))), open && items.map((item2, index) => /* @__PURE__ */ React5.createElement(TreeItem, {
|
|
689
612
|
key: item2.id,
|
|
690
613
|
item: item2,
|
|
691
614
|
path,
|
|
692
615
|
last: index === items.length - 1,
|
|
693
|
-
draggable:
|
|
616
|
+
draggable: _draggable,
|
|
694
617
|
renderColumns: Columns,
|
|
695
618
|
canDrop,
|
|
696
619
|
onOpenChange,
|
|
@@ -700,7 +623,7 @@ var RawTreeItem = ({ item, path: _path, last, draggable: draggable2, renderColum
|
|
|
700
623
|
var TreeItem = /* @__PURE__ */ memo3(RawTreeItem);
|
|
701
624
|
|
|
702
625
|
// packages/ui/react-ui-list/src/components/Tree/Tree.tsx
|
|
703
|
-
var Tree = ({ id, getItems, getProps, isOpen, isCurrent, draggable:
|
|
626
|
+
var Tree = ({ id, getItems, getProps, isOpen, isCurrent, draggable: draggable3 = false, gridTemplateColumns = "[tree-row-start] 1fr min-content [tree-row-end]", classNames, renderColumns, canDrop, onOpenChange, onSelect }) => {
|
|
704
627
|
const context = useMemo2(() => ({
|
|
705
628
|
getItems,
|
|
706
629
|
getProps,
|
|
@@ -718,17 +641,17 @@ var Tree = ({ id, getItems, getProps, isOpen, isCurrent, draggable: draggable2 =
|
|
|
718
641
|
], [
|
|
719
642
|
id
|
|
720
643
|
]);
|
|
721
|
-
return /* @__PURE__ */
|
|
644
|
+
return /* @__PURE__ */ React6.createElement(Treegrid2.Root, {
|
|
722
645
|
gridTemplateColumns,
|
|
723
646
|
classNames
|
|
724
|
-
}, /* @__PURE__ */
|
|
647
|
+
}, /* @__PURE__ */ React6.createElement(TreeProvider, {
|
|
725
648
|
value: context
|
|
726
|
-
}, items.map((item, index) => /* @__PURE__ */
|
|
649
|
+
}, items.map((item, index) => /* @__PURE__ */ React6.createElement(TreeItem, {
|
|
727
650
|
key: item.id,
|
|
728
651
|
item,
|
|
729
652
|
last: index === items.length - 1,
|
|
730
653
|
path,
|
|
731
|
-
draggable:
|
|
654
|
+
draggable: draggable3,
|
|
732
655
|
renderColumns,
|
|
733
656
|
canDrop,
|
|
734
657
|
onOpenChange,
|