@headless-tree/core 0.0.0-20250807163338 → 0.0.0-20250807215101
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/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @headless-tree/core
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20250807215101
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
- b413f74: Fix `aria-posinset` and `aria-level` to be 1-based indexing
|
|
16
16
|
- a250b3b: Fix a bug where expand from the initial keyboard focus fails when rootItemId is an empty string
|
|
17
17
|
- 62867e8: Introduced a short delay before hiding the drag line when leaving a drag target, which helps to reduce flickering of the dragline when moving between items
|
|
18
|
+
- c4579eb: Update keyboard drag and drop to include the focused item in the dragged items
|
|
18
19
|
- 662e2a8: Improved customizability of checkboxes feature (still alpha state), allowing you to customize `propagateCheckedState` and `canCheckFolders` independently
|
|
19
20
|
- 662e2a8: Changed to new buildtool in core packages (now using tsup) to hopefully fix some ESM/CJS integrations
|
|
20
21
|
|
package/dist/index.js
CHANGED
|
@@ -1740,7 +1740,11 @@ var keyboardDragAndDropFeature = {
|
|
|
1740
1740
|
preventDefault: true,
|
|
1741
1741
|
isEnabled: (tree) => !tree.getState().dnd,
|
|
1742
1742
|
handler: (_, tree) => {
|
|
1743
|
-
tree.
|
|
1743
|
+
const selectedItems = tree.getSelectedItems();
|
|
1744
|
+
const focusedItem = tree.getFocusedItem();
|
|
1745
|
+
tree.startKeyboardDrag(
|
|
1746
|
+
selectedItems.includes(focusedItem) ? selectedItems : selectedItems.concat(focusedItem)
|
|
1747
|
+
);
|
|
1744
1748
|
}
|
|
1745
1749
|
},
|
|
1746
1750
|
dragUp: {
|
package/dist/index.mjs
CHANGED
|
@@ -1696,7 +1696,11 @@ var keyboardDragAndDropFeature = {
|
|
|
1696
1696
|
preventDefault: true,
|
|
1697
1697
|
isEnabled: (tree) => !tree.getState().dnd,
|
|
1698
1698
|
handler: (_, tree) => {
|
|
1699
|
-
tree.
|
|
1699
|
+
const selectedItems = tree.getSelectedItems();
|
|
1700
|
+
const focusedItem = tree.getFocusedItem();
|
|
1701
|
+
tree.startKeyboardDrag(
|
|
1702
|
+
selectedItems.includes(focusedItem) ? selectedItems : selectedItems.concat(focusedItem)
|
|
1703
|
+
);
|
|
1700
1704
|
}
|
|
1701
1705
|
},
|
|
1702
1706
|
dragUp: {
|
package/package.json
CHANGED
|
@@ -191,7 +191,14 @@ export const keyboardDragAndDropFeature: FeatureImplementation = {
|
|
|
191
191
|
preventDefault: true,
|
|
192
192
|
isEnabled: (tree) => !tree.getState().dnd,
|
|
193
193
|
handler: (_, tree) => {
|
|
194
|
-
tree.
|
|
194
|
+
const selectedItems = tree.getSelectedItems();
|
|
195
|
+
const focusedItem = tree.getFocusedItem();
|
|
196
|
+
|
|
197
|
+
tree.startKeyboardDrag(
|
|
198
|
+
selectedItems.includes(focusedItem)
|
|
199
|
+
? selectedItems
|
|
200
|
+
: selectedItems.concat(focusedItem),
|
|
201
|
+
);
|
|
195
202
|
},
|
|
196
203
|
},
|
|
197
204
|
dragUp: {
|
|
@@ -49,6 +49,37 @@ describe("core-feature/keyboard-drag-and-drop", () => {
|
|
|
49
49
|
tree.expect.substate("assistiveDndState", AssistiveDndState.Started);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
it("starts dragging only focused item", () => {
|
|
53
|
+
tree.item("x3").setFocused();
|
|
54
|
+
tree.do.hotkey("startDrag");
|
|
55
|
+
tree.expect.substate("dnd", {
|
|
56
|
+
draggedItems: [tree.item("x3")],
|
|
57
|
+
dragTarget: {
|
|
58
|
+
childIndex: 3,
|
|
59
|
+
dragLineIndex: 19,
|
|
60
|
+
dragLineLevel: 0,
|
|
61
|
+
insertionIndex: 2,
|
|
62
|
+
item: tree.item("x"),
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("starts dragging both selected and focused item", () => {
|
|
68
|
+
tree.do.selectMultiple("x111", "x112");
|
|
69
|
+
tree.item("x3").setFocused();
|
|
70
|
+
tree.do.hotkey("startDrag");
|
|
71
|
+
tree.expect.substate("dnd", {
|
|
72
|
+
draggedItems: [tree.item("x111"), tree.item("x112"), tree.item("x3")],
|
|
73
|
+
dragTarget: {
|
|
74
|
+
childIndex: 3,
|
|
75
|
+
dragLineIndex: 19,
|
|
76
|
+
dragLineLevel: 0,
|
|
77
|
+
insertionIndex: 2,
|
|
78
|
+
item: tree.item("x"),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
52
83
|
it("moves down 1", () => {
|
|
53
84
|
tree.do.selectMultiple("x111", "x112");
|
|
54
85
|
tree.do.hotkey("startDrag");
|
|
@@ -355,13 +386,13 @@ describe("core-feature/keyboard-drag-and-drop", () => {
|
|
|
355
386
|
|
|
356
387
|
it("doesnt go below end of tree", () => {
|
|
357
388
|
const lastState = {
|
|
358
|
-
draggedItems: [tree.item("x111")],
|
|
389
|
+
draggedItems: [tree.item("x111"), tree.item("x3")],
|
|
359
390
|
dragTarget: {
|
|
360
391
|
item: tree.item("x"),
|
|
361
392
|
childIndex: 4,
|
|
362
393
|
dragLineIndex: 20,
|
|
363
394
|
dragLineLevel: 0,
|
|
364
|
-
insertionIndex:
|
|
395
|
+
insertionIndex: 3,
|
|
365
396
|
},
|
|
366
397
|
};
|
|
367
398
|
|
|
@@ -378,7 +409,7 @@ describe("core-feature/keyboard-drag-and-drop", () => {
|
|
|
378
409
|
|
|
379
410
|
it("doesnt go above top of tree", () => {
|
|
380
411
|
const firstState = {
|
|
381
|
-
draggedItems: [tree.item("x111")],
|
|
412
|
+
draggedItems: [tree.item("x111"), tree.item("x1")],
|
|
382
413
|
dragTarget: {
|
|
383
414
|
item: tree.item("x"),
|
|
384
415
|
childIndex: 0,
|