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