@dxos/react-ui-list 0.8.4-main.4a85c3132b → 0.8.4-main.51f1e5ca51
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 +149 -144
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +149 -144
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Accordion/Accordion.d.ts +1 -1
- package/dist/types/src/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/types/src/components/Accordion/Accordion.stories.d.ts.map +1 -1
- package/dist/types/src/components/Accordion/AccordionItem.d.ts.map +1 -1
- package/dist/types/src/components/Accordion/AccordionRoot.d.ts +1 -1
- package/dist/types/src/components/Accordion/AccordionRoot.d.ts.map +1 -1
- package/dist/types/src/components/List/List.d.ts +8 -6
- package/dist/types/src/components/List/List.d.ts.map +1 -1
- package/dist/types/src/components/List/List.stories.d.ts +2 -2
- package/dist/types/src/components/List/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/List/ListItem.d.ts +12 -10
- 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.map +1 -1
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeContext.d.ts +4 -0
- package/dist/types/src/components/Tree/TreeContext.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/Tree/helpers.d.ts.map +1 -1
- package/dist/types/src/components/Tree/testing.d.ts.map +1 -1
- package/dist/types/src/util/path.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -20
- package/src/components/Accordion/Accordion.stories.tsx +3 -3
- package/src/components/Accordion/AccordionItem.tsx +0 -1
- package/src/components/List/List.stories.tsx +5 -5
- package/src/components/List/List.tsx +4 -9
- package/src/components/List/ListItem.tsx +66 -46
- package/src/components/List/ListRoot.tsx +1 -1
- package/src/components/List/testing.ts +4 -4
- package/src/components/Tree/Tree.stories.tsx +4 -5
- package/src/components/Tree/TreeContext.tsx +4 -0
- package/src/components/Tree/TreeItem.tsx +94 -64
- package/src/components/Tree/TreeItemHeading.tsx +1 -4
- package/src/components/Tree/TreeItemToggle.tsx +3 -3
- package/src/components/Tree/testing.ts +5 -5
|
@@ -69,11 +69,12 @@ var Accordion = {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// src/components/List/ListItem.tsx
|
|
72
|
+
import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
72
73
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
73
74
|
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
74
75
|
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
75
|
-
import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
76
76
|
import { createContext as createContext4 } from "@radix-ui/react-context";
|
|
77
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
77
78
|
import React4, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
78
79
|
import { createPortal } from "react-dom";
|
|
79
80
|
import { invariant } from "@dxos/invariant";
|
|
@@ -81,9 +82,9 @@ import { IconButton, ListItem as NaturalListItem, useTranslation } from "@dxos/r
|
|
|
81
82
|
import { mx as mx3, osTranslations } from "@dxos/ui-theme";
|
|
82
83
|
|
|
83
84
|
// src/components/List/ListRoot.tsx
|
|
84
|
-
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
85
85
|
import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
86
86
|
import { getReorderDestinationIndex } from "@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index";
|
|
87
|
+
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
87
88
|
import { createContext as createContext3 } from "@radix-ui/react-context";
|
|
88
89
|
import React3, { useCallback, useEffect, useState } from "react";
|
|
89
90
|
var LIST_NAME = "List";
|
|
@@ -155,27 +156,20 @@ var idle = {
|
|
|
155
156
|
type: "idle"
|
|
156
157
|
};
|
|
157
158
|
var stateStyles = {
|
|
158
|
-
"
|
|
159
|
+
"is-dragging": "opacity-50"
|
|
159
160
|
};
|
|
160
161
|
var defaultContext = {};
|
|
161
162
|
var LIST_ITEM_NAME = "ListItem";
|
|
162
163
|
var [ListItemProvider, useListItemContext] = createContext4(LIST_ITEM_NAME, defaultContext);
|
|
163
|
-
var ListItem = ({ children, classNames, item, ...props }) => {
|
|
164
|
+
var ListItem = ({ children, classNames, item, asChild, selected, ...props }) => {
|
|
165
|
+
const Comp = asChild ? Slot : "div";
|
|
164
166
|
const { isItem, readonly, dragPreview, setState: setRootState } = useListContext(LIST_ITEM_NAME);
|
|
165
|
-
const
|
|
167
|
+
const rootRef = useRef(null);
|
|
166
168
|
const dragHandleRef = useRef(null);
|
|
167
169
|
const [state, setState] = useState2(idle);
|
|
168
170
|
useEffect2(() => {
|
|
169
|
-
const element =
|
|
170
|
-
invariant(element, void 0, {
|
|
171
|
-
F: __dxlog_file,
|
|
172
|
-
L: 98,
|
|
173
|
-
S: void 0,
|
|
174
|
-
A: [
|
|
175
|
-
"element",
|
|
176
|
-
""
|
|
177
|
-
]
|
|
178
|
-
});
|
|
171
|
+
const element = rootRef.current;
|
|
172
|
+
invariant(element, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 37, S: void 0, A: ["element", ""] });
|
|
179
173
|
return combine(
|
|
180
174
|
//
|
|
181
175
|
// https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#draggable
|
|
@@ -214,10 +208,10 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
214
208
|
} : void 0,
|
|
215
209
|
onDragStart: () => {
|
|
216
210
|
setState({
|
|
217
|
-
type: "
|
|
211
|
+
type: "is-dragging"
|
|
218
212
|
});
|
|
219
213
|
setRootState({
|
|
220
|
-
type: "
|
|
214
|
+
type: "is-dragging",
|
|
221
215
|
item
|
|
222
216
|
});
|
|
223
217
|
},
|
|
@@ -248,7 +242,7 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
248
242
|
onDragEnter: ({ self }) => {
|
|
249
243
|
const closestEdge = extractClosestEdge2(self.data);
|
|
250
244
|
setState({
|
|
251
|
-
type: "
|
|
245
|
+
type: "is-dragging-over",
|
|
252
246
|
closestEdge
|
|
253
247
|
});
|
|
254
248
|
},
|
|
@@ -258,11 +252,11 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
258
252
|
onDrag: ({ self }) => {
|
|
259
253
|
const closestEdge = extractClosestEdge2(self.data);
|
|
260
254
|
setState((current) => {
|
|
261
|
-
if (current.type === "
|
|
255
|
+
if (current.type === "is-dragging-over" && current.closestEdge === closestEdge) {
|
|
262
256
|
return current;
|
|
263
257
|
}
|
|
264
258
|
return {
|
|
265
|
-
type: "
|
|
259
|
+
type: "is-dragging-over",
|
|
266
260
|
closestEdge
|
|
267
261
|
};
|
|
268
262
|
});
|
|
@@ -278,40 +272,41 @@ var ListItem = ({ children, classNames, item, ...props }) => {
|
|
|
278
272
|
return /* @__PURE__ */ React4.createElement(ListItemProvider, {
|
|
279
273
|
item,
|
|
280
274
|
dragHandleRef
|
|
281
|
-
}, /* @__PURE__ */ React4.createElement(
|
|
282
|
-
|
|
275
|
+
}, /* @__PURE__ */ React4.createElement(Comp, {
|
|
276
|
+
...props,
|
|
283
277
|
role: "listitem",
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
278
|
+
"aria-selected": selected,
|
|
279
|
+
className: mx3("relative p-1 dx-selected dx-hover", classNames, stateStyles[state.type]),
|
|
280
|
+
ref: rootRef
|
|
281
|
+
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React4.createElement(NaturalListItem.DropIndicator, {
|
|
287
282
|
edge: state.closestEdge
|
|
288
|
-
}))
|
|
283
|
+
}));
|
|
289
284
|
};
|
|
290
|
-
var
|
|
291
|
-
const { state } = useListContext("
|
|
285
|
+
var ListItemIconButton = ({ autoHide = true, iconOnly = true, variant = "ghost", classNames, disabled, ...props }) => {
|
|
286
|
+
const { state } = useListContext("ITEM_BUTTON");
|
|
292
287
|
const isDisabled = state.type !== "idle" || disabled;
|
|
293
|
-
const { t } = useTranslation(osTranslations);
|
|
294
288
|
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
295
|
-
iconOnly: true,
|
|
296
|
-
variant: "ghost",
|
|
297
289
|
...props,
|
|
298
|
-
icon,
|
|
299
290
|
disabled: isDisabled,
|
|
300
|
-
|
|
291
|
+
iconOnly,
|
|
292
|
+
variant,
|
|
301
293
|
classNames: [
|
|
302
294
|
classNames,
|
|
303
295
|
autoHide && disabled && "hidden"
|
|
304
296
|
]
|
|
305
297
|
});
|
|
306
298
|
};
|
|
307
|
-
var
|
|
308
|
-
const { state } = useListContext("
|
|
299
|
+
var ListItemDeleteButton = ({ autoHide = true, classNames, disabled, icon = "ph--x--regular", label, ...props }) => {
|
|
300
|
+
const { state } = useListContext("DELETE_BUTTON");
|
|
309
301
|
const isDisabled = state.type !== "idle" || disabled;
|
|
302
|
+
const { t } = useTranslation(osTranslations);
|
|
310
303
|
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
311
304
|
...props,
|
|
305
|
+
variant: "ghost",
|
|
312
306
|
disabled: isDisabled,
|
|
313
|
-
|
|
314
|
-
|
|
307
|
+
icon,
|
|
308
|
+
iconOnly: true,
|
|
309
|
+
label: label ?? t("delete.label"),
|
|
315
310
|
classNames: [
|
|
316
311
|
classNames,
|
|
317
312
|
autoHide && disabled && "hidden"
|
|
@@ -322,12 +317,12 @@ var ListItemDragHandle = ({ disabled }) => {
|
|
|
322
317
|
const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
|
|
323
318
|
const { t } = useTranslation(osTranslations);
|
|
324
319
|
return /* @__PURE__ */ React4.createElement(IconButton, {
|
|
325
|
-
iconOnly: true,
|
|
326
320
|
variant: "ghost",
|
|
327
|
-
|
|
328
|
-
ref: dragHandleRef,
|
|
321
|
+
disabled,
|
|
329
322
|
icon: "ph--dots-six-vertical--regular",
|
|
330
|
-
|
|
323
|
+
iconOnly: true,
|
|
324
|
+
label: t("drag-handle.label"),
|
|
325
|
+
ref: dragHandleRef
|
|
331
326
|
});
|
|
332
327
|
};
|
|
333
328
|
var ListItemDragPreview = ({ children }) => {
|
|
@@ -337,9 +332,11 @@ var ListItemDragPreview = ({ children }) => {
|
|
|
337
332
|
}), state.container) : null;
|
|
338
333
|
};
|
|
339
334
|
var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */ React4.createElement("div", {
|
|
335
|
+
role: "none",
|
|
340
336
|
className: mx3("flex w-full gap-2", classNames)
|
|
341
337
|
}, children);
|
|
342
338
|
var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */ React4.createElement("div", {
|
|
339
|
+
role: "none",
|
|
343
340
|
className: mx3("flex grow items-center truncate", classNames),
|
|
344
341
|
...props
|
|
345
342
|
}, children);
|
|
@@ -351,8 +348,8 @@ var List = {
|
|
|
351
348
|
ItemDragPreview: ListItemDragPreview,
|
|
352
349
|
ItemWrapper: ListItemWrapper,
|
|
353
350
|
ItemDragHandle: ListItemDragHandle,
|
|
351
|
+
ItemIconButton: ListItemIconButton,
|
|
354
352
|
ItemDeleteButton: ListItemDeleteButton,
|
|
355
|
-
ItemButton: ListItemButton,
|
|
356
353
|
ItemTitle: ListItemTitle
|
|
357
354
|
};
|
|
358
355
|
|
|
@@ -369,14 +366,14 @@ var TreeProvider = TreeContext.Provider;
|
|
|
369
366
|
var useTree = () => useContext(TreeContext) ?? raise(new Error("TreeContext not found"));
|
|
370
367
|
|
|
371
368
|
// src/components/Tree/TreeItem.tsx
|
|
369
|
+
import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
372
370
|
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
373
371
|
import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
374
|
-
import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
375
372
|
import { useAtomValue } from "@effect-atom/atom-react";
|
|
376
373
|
import * as Schema from "effect/Schema";
|
|
377
374
|
import React7, { memo as memo3, useCallback as useCallback3, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
|
|
378
375
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
379
|
-
import { TreeItem as NaturalTreeItem, Treegrid } from "@dxos/react-ui";
|
|
376
|
+
import { TreeItem as NaturalTreeItem, Treegrid, TREEGRID_PARENT_OF_SEPARATOR } from "@dxos/react-ui";
|
|
380
377
|
import { ghostFocusWithin, ghostHover, hoverableControls, hoverableFocusedKeyboardControls, hoverableFocusedWithinControls, mx as mx4 } from "@dxos/ui-theme";
|
|
381
378
|
|
|
382
379
|
// src/components/Tree/helpers.ts
|
|
@@ -417,7 +414,6 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label,
|
|
|
417
414
|
}, /* @__PURE__ */ React5.createElement(Button, {
|
|
418
415
|
"data-testid": "treeItem.heading",
|
|
419
416
|
variant: "ghost",
|
|
420
|
-
density: "fine",
|
|
421
417
|
classNames: [
|
|
422
418
|
"grow gap-2 ps-0.5 hover:bg-transparent dark:hover:bg-transparent",
|
|
423
419
|
"disabled:cursor-default disabled:opacity-100",
|
|
@@ -431,7 +427,6 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label,
|
|
|
431
427
|
}
|
|
432
428
|
}, icon && /* @__PURE__ */ React5.createElement(Icon2, {
|
|
433
429
|
icon: icon ?? "ph--placeholder--regular",
|
|
434
|
-
size: 5,
|
|
435
430
|
classNames: [
|
|
436
431
|
"my-1",
|
|
437
432
|
styles?.surfaceText
|
|
@@ -445,7 +440,7 @@ var TreeItemHeading = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ label,
|
|
|
445
440
|
// src/components/Tree/TreeItemToggle.tsx
|
|
446
441
|
import React6, { forwardRef as forwardRef2, memo as memo2 } from "react";
|
|
447
442
|
import { IconButton as IconButton2 } from "@dxos/react-ui";
|
|
448
|
-
var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef2(({ open, isBranch, hidden,
|
|
443
|
+
var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef2(({ classNames, open, isBranch, hidden, ...props }, forwardedRef) => {
|
|
449
444
|
return /* @__PURE__ */ React6.createElement(IconButton2, {
|
|
450
445
|
ref: forwardedRef,
|
|
451
446
|
"data-testid": "treeItem.toggle",
|
|
@@ -454,8 +449,8 @@ var TreeItemToggle = /* @__PURE__ */ memo2(/* @__PURE__ */ forwardRef2(({ open,
|
|
|
454
449
|
density: "fine",
|
|
455
450
|
classNames: [
|
|
456
451
|
"h-full w-6 px-0",
|
|
457
|
-
"[&_svg]:transition-
|
|
458
|
-
open
|
|
452
|
+
"[&_svg]:transition-transform [&_svg]:duration-200",
|
|
453
|
+
open ? "[&_svg]:rotate-90" : "[&_svg]:rotate-0",
|
|
459
454
|
hidden ? "hidden" : !isBranch && "invisible",
|
|
460
455
|
classNames
|
|
461
456
|
],
|
|
@@ -494,7 +489,7 @@ var RawTreeItem = ({ item, path: pathProp, levelOffset = 2, last, draggable: dra
|
|
|
494
489
|
pathProp,
|
|
495
490
|
item.id
|
|
496
491
|
]);
|
|
497
|
-
const { id, parentOf, label, className, headingClassName, icon, iconHue, disabled, testId } = useAtomValue(itemPropsAtom(path));
|
|
492
|
+
const { id, parentOf, draggable: itemDraggable, droppable: itemDroppable, label, className, headingClassName, icon, iconHue, disabled, testId } = useAtomValue(itemPropsAtom(path));
|
|
498
493
|
const childIds = useAtomValue(childIdsAtom(item.id));
|
|
499
494
|
const open = useAtomValue(itemOpenAtom(path));
|
|
500
495
|
const current = useAtomValue(itemCurrentAtom(path));
|
|
@@ -510,117 +505,127 @@ var RawTreeItem = ({ item, path: pathProp, levelOffset = 2, last, draggable: dra
|
|
|
510
505
|
path,
|
|
511
506
|
item
|
|
512
507
|
};
|
|
508
|
+
const shouldSeedNativeDragData = typeof document !== "undefined" && document.body.hasAttribute("data-platform");
|
|
513
509
|
const cancelExpand = useCallback3(() => {
|
|
514
510
|
if (cancelExpandRef.current) {
|
|
515
511
|
clearTimeout(cancelExpandRef.current);
|
|
516
512
|
cancelExpandRef.current = null;
|
|
517
513
|
}
|
|
518
514
|
}, []);
|
|
515
|
+
const isItemDraggable = draggableProp && itemDraggable !== false;
|
|
516
|
+
const isItemDroppable = itemDroppable !== false;
|
|
517
|
+
const nativeDragText = id;
|
|
519
518
|
useEffect3(() => {
|
|
520
519
|
if (!draggableProp) {
|
|
521
520
|
return;
|
|
522
521
|
}
|
|
523
|
-
invariant2(buttonRef.current, void 0, {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
]
|
|
531
|
-
});
|
|
532
|
-
return combine2(
|
|
533
|
-
draggable2({
|
|
534
|
-
element: buttonRef.current,
|
|
535
|
-
getInitialData: () => data,
|
|
536
|
-
onDragStart: () => {
|
|
537
|
-
setState("dragging");
|
|
538
|
-
if (open) {
|
|
539
|
-
openRef.current = true;
|
|
540
|
-
onOpenChange?.({
|
|
541
|
-
item,
|
|
542
|
-
path,
|
|
543
|
-
open: false
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
|
-
onDrop: () => {
|
|
548
|
-
setState("idle");
|
|
549
|
-
if (openRef.current) {
|
|
550
|
-
onOpenChange?.({
|
|
551
|
-
item,
|
|
552
|
-
path,
|
|
553
|
-
open: true
|
|
554
|
-
});
|
|
555
|
-
}
|
|
522
|
+
invariant2(buttonRef.current, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 70, S: void 0, A: ["buttonRef.current", ""] });
|
|
523
|
+
const makeDraggable = () => draggable2({
|
|
524
|
+
element: buttonRef.current,
|
|
525
|
+
getInitialData: () => data,
|
|
526
|
+
getInitialDataForExternal: () => {
|
|
527
|
+
if (!shouldSeedNativeDragData) {
|
|
528
|
+
return {};
|
|
556
529
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
"make-child"
|
|
570
|
-
]
|
|
571
|
-
});
|
|
572
|
-
},
|
|
573
|
-
canDrop: ({ source }) => {
|
|
574
|
-
const _canDrop = canDrop ?? (() => true);
|
|
575
|
-
return source.element !== buttonRef.current && _canDrop({
|
|
576
|
-
source: source.data,
|
|
577
|
-
target: data
|
|
530
|
+
return {
|
|
531
|
+
"text/plain": nativeDragText
|
|
532
|
+
};
|
|
533
|
+
},
|
|
534
|
+
onDragStart: () => {
|
|
535
|
+
setState("dragging");
|
|
536
|
+
if (open) {
|
|
537
|
+
openRef.current = true;
|
|
538
|
+
onOpenChange?.({
|
|
539
|
+
item,
|
|
540
|
+
path,
|
|
541
|
+
open: false
|
|
578
542
|
});
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
onDrop: () => {
|
|
546
|
+
setState("idle");
|
|
547
|
+
if (openRef.current) {
|
|
548
|
+
onOpenChange?.({
|
|
549
|
+
item,
|
|
550
|
+
path,
|
|
551
|
+
open: true
|
|
587
552
|
});
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
if (!isItemDroppable) {
|
|
557
|
+
return isItemDraggable ? makeDraggable() : void 0;
|
|
558
|
+
}
|
|
559
|
+
const dropTarget = dropTargetForElements2({
|
|
560
|
+
element: buttonRef.current,
|
|
561
|
+
getData: ({ input, element }) => {
|
|
562
|
+
return attachInstruction(data, {
|
|
563
|
+
input,
|
|
564
|
+
element,
|
|
565
|
+
indentPerLevel: DEFAULT_INDENTATION,
|
|
566
|
+
currentLevel: level,
|
|
567
|
+
mode,
|
|
568
|
+
block: isBranch ? [] : [
|
|
569
|
+
"make-child"
|
|
570
|
+
]
|
|
571
|
+
});
|
|
572
|
+
},
|
|
573
|
+
canDrop: ({ source }) => {
|
|
574
|
+
const _canDrop = canDrop ?? (() => true);
|
|
575
|
+
return source.element !== buttonRef.current && _canDrop({
|
|
576
|
+
source: source.data,
|
|
577
|
+
target: data
|
|
578
|
+
});
|
|
579
|
+
},
|
|
580
|
+
getIsSticky: () => true,
|
|
581
|
+
onDrag: ({ self, source }) => {
|
|
582
|
+
const desired = extractInstruction(self.data);
|
|
583
|
+
const block = desired && blockInstruction?.({
|
|
584
|
+
instruction: desired,
|
|
585
|
+
source: source.data,
|
|
586
|
+
target: data
|
|
587
|
+
});
|
|
588
|
+
const instruction2 = block && desired.type !== "instruction-blocked" ? {
|
|
589
|
+
type: "instruction-blocked",
|
|
590
|
+
desired
|
|
591
|
+
} : desired;
|
|
592
|
+
if (source.data.id !== id) {
|
|
593
|
+
if (instruction2?.type === "make-child" && isBranch && !open && !cancelExpandRef.current) {
|
|
594
|
+
cancelExpandRef.current = setTimeout(() => {
|
|
595
|
+
onOpenChange?.({
|
|
596
|
+
item,
|
|
597
|
+
path,
|
|
598
|
+
open: true
|
|
599
|
+
});
|
|
600
|
+
}, 500);
|
|
610
601
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
setInstruction(
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
|
|
602
|
+
if (instruction2?.type !== "make-child") {
|
|
603
|
+
cancelExpand();
|
|
604
|
+
}
|
|
605
|
+
setInstruction(instruction2);
|
|
606
|
+
} else if (instruction2?.type === "reparent") {
|
|
607
|
+
setInstruction(instruction2);
|
|
608
|
+
} else {
|
|
618
609
|
setInstruction(null);
|
|
619
610
|
}
|
|
620
|
-
}
|
|
621
|
-
|
|
611
|
+
},
|
|
612
|
+
onDragLeave: () => {
|
|
613
|
+
cancelExpand();
|
|
614
|
+
setInstruction(null);
|
|
615
|
+
},
|
|
616
|
+
onDrop: () => {
|
|
617
|
+
cancelExpand();
|
|
618
|
+
setInstruction(null);
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
if (!isItemDraggable) {
|
|
622
|
+
return dropTarget;
|
|
623
|
+
}
|
|
624
|
+
return combine2(makeDraggable(), dropTarget);
|
|
622
625
|
}, [
|
|
623
626
|
draggableProp,
|
|
627
|
+
isItemDraggable,
|
|
628
|
+
isItemDroppable,
|
|
624
629
|
item,
|
|
625
630
|
id,
|
|
626
631
|
mode,
|
|
@@ -709,7 +714,7 @@ var RawTreeItem = ({ item, path: pathProp, levelOffset = 2, last, draggable: dra
|
|
|
709
714
|
key: id,
|
|
710
715
|
id,
|
|
711
716
|
"aria-labelledby": `${id}__label`,
|
|
712
|
-
parentOf: parentOf?.join(
|
|
717
|
+
parentOf: parentOf?.join(TREEGRID_PARENT_OF_SEPARATOR),
|
|
713
718
|
"data-object-id": id,
|
|
714
719
|
"data-testid": testId,
|
|
715
720
|
// NOTE(thure): This is intentionally an empty string to for descendents to select by in the CSS
|