@elliemae/ds-data-table 2.0.0-rc.3 → 2.0.0-rc.7
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/cjs/DataTableSchema.js +1 -1
- package/cjs/addons/Filters/Components/index.js +0 -2
- package/cjs/addons/Filters/index.js +0 -2
- package/cjs/exported-related/FilterPopover.js +17 -3
- package/cjs/exported-related/FilterTypes.js +0 -1
- package/cjs/exported-related/Filters/applyOutOfTheBoxFilters.js +0 -2
- package/cjs/exported-related/Filters/index.js +0 -2
- package/cjs/exported-related/index.js +0 -2
- package/cjs/helpers/dndkit/hierarchy/customCollisionDetection.js +27 -14
- package/cjs/helpers/dndkit/hierarchy/getHierarchyKeyboardCoordinates.js +22 -20
- package/cjs/helpers/dndkit/hierarchy/useHierarchyDndkitConfig.js +5 -3
- package/cjs/helpers/dndkit/tree/customCollisionDetection.js +45 -25
- package/cjs/helpers/dndkit/tree/getTreeKeyboardCoordinates.js +25 -30
- package/cjs/helpers/dndkit/tree/useTreeDndkitConfig.js +5 -3
- package/cjs/helpers/refs-helpers.js +2 -2
- package/cjs/index.js +0 -2
- package/cjs/parts/FilterBar/FiltersBar.js +0 -2
- package/cjs/parts/FilterBar/components/index.js +0 -2
- package/cjs/parts/Filters/index.js +10 -12
- package/cjs/parts/Headers/HeaderCellGroup.js +4 -3
- package/cjs/parts/Headers/index.js +1 -1
- package/cjs/parts/HoC/withConditionalDnDColumnContext.js +17 -13
- package/cjs/parts/HoC/withConditionalDnDRowContext.js +9 -10
- package/cjs/parts/HoC/withConditionalDnDSortableContext.js +1 -1
- package/cjs/parts/HoC/withDnDSortableColumnContext.js +5 -19
- package/cjs/parts/HoC/withDnDSortableRowContext.js +3 -17
- package/cjs/parts/Row.js +10 -10
- package/cjs/parts/Rows.js +1 -1
- package/cjs/parts/index.js +1 -1
- package/cjs/styled.js +1 -1
- package/esm/DataTableSchema.js +1 -1
- package/esm/addons/Filters/Components/index.js +0 -1
- package/esm/addons/Filters/index.js +0 -1
- package/esm/exported-related/FilterPopover.js +17 -3
- package/esm/exported-related/FilterTypes.js +0 -1
- package/esm/exported-related/Filters/applyOutOfTheBoxFilters.js +0 -2
- package/esm/exported-related/Filters/index.js +0 -1
- package/esm/exported-related/index.js +0 -1
- package/esm/helpers/dndkit/hierarchy/customCollisionDetection.js +27 -14
- package/esm/helpers/dndkit/hierarchy/getHierarchyKeyboardCoordinates.js +22 -20
- package/esm/helpers/dndkit/hierarchy/useHierarchyDndkitConfig.js +6 -4
- package/esm/helpers/dndkit/tree/customCollisionDetection.js +45 -25
- package/esm/helpers/dndkit/tree/getTreeKeyboardCoordinates.js +26 -31
- package/esm/helpers/dndkit/tree/useTreeDndkitConfig.js +6 -4
- package/esm/helpers/refs-helpers.js +2 -2
- package/esm/index.js +0 -1
- package/esm/parts/FilterBar/FiltersBar.js +0 -2
- package/esm/parts/FilterBar/components/index.js +0 -1
- package/esm/parts/Filters/index.js +0 -2
- package/esm/parts/Headers/HeaderCellGroup.js +4 -4
- package/esm/parts/Headers/index.js +2 -2
- package/esm/parts/HoC/withConditionalDnDColumnContext.js +19 -15
- package/esm/parts/HoC/withConditionalDnDRowContext.js +11 -12
- package/esm/parts/HoC/withConditionalDnDSortableContext.js +1 -1
- package/esm/parts/HoC/withDnDSortableColumnContext.js +6 -20
- package/esm/parts/HoC/withDnDSortableRowContext.js +4 -18
- package/esm/parts/Row.js +7 -10
- package/esm/styled.js +1 -1
- package/package.json +17 -33
- package/types/addons/Filters/Components/SelectFilter/components.d.ts +6 -6
- package/types/addons/Filters/Components/index.d.ts +0 -1
- package/types/exported-related/FilterTypes.d.ts +0 -1
- package/types/exported-related/Filters/index.d.ts +0 -1
- package/types/helpers/dndkit/hierarchy/types.d.ts +3 -3
- package/types/helpers/dndkit/tree/types.d.ts +3 -4
- package/types/helpers/dndkit/types.d.ts +2 -2
- package/types/helpers/refs-helpers.d.ts +1 -1
- package/types/parts/FilterBar/components/index.d.ts +0 -1
- package/types/parts/FilterBar/styled.d.ts +2 -2
- package/types/parts/Headers/HeaderCellGroup.d.ts +4 -3
- package/types/parts/Row.d.ts +2 -1
- package/types/styled.d.ts +19 -19
- package/types/types/props.d.ts +2 -2
- package/cjs/addons/Filters/Components/TextInputFilter/index.js +0 -92
- package/cjs/exported-related/Filters/textFilterFn.js +0 -14
- package/cjs/parts/FilterBar/components/TextPill.js +0 -42
- package/cjs/parts/HoC/DragOverlayContext.js +0 -11
- package/esm/addons/Filters/Components/TextInputFilter/index.js +0 -84
- package/esm/exported-related/Filters/textFilterFn.js +0 -10
- package/esm/parts/FilterBar/components/TextPill.js +0 -34
- package/esm/parts/HoC/DragOverlayContext.js +0 -7
- package/types/addons/Filters/Components/TextInputFilter/index.d.ts +0 -3
- package/types/exported-related/Filters/textFilterFn.d.ts +0 -2
- package/types/parts/FilterBar/components/TextPill.d.ts +0 -2
- package/types/parts/HoC/DragOverlayContext.d.ts +0 -6
|
@@ -4,11 +4,11 @@ import 'core-js/modules/esnext.iterator.constructor.js';
|
|
|
4
4
|
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
5
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
6
6
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
7
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
9
8
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
9
|
import { KeyboardCode, getViewRect, closestCorners } from '@dnd-kit/core';
|
|
11
10
|
import { DATA_TESTID } from '../../../configs/constants.js';
|
|
11
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
12
12
|
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
13
13
|
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
14
14
|
import 'react';
|
|
@@ -48,16 +48,14 @@ const getHorizontalKeyboardCoordinates = _ref => {
|
|
|
48
48
|
event,
|
|
49
49
|
currentCoordinates,
|
|
50
50
|
droppableContainers,
|
|
51
|
-
|
|
51
|
+
collisionRect
|
|
52
52
|
} = _ref;
|
|
53
53
|
if (vertical.includes(event.code)) return undefined;
|
|
54
|
-
const activeItem = items.find(item => item.id === active);
|
|
54
|
+
const activeItem = items.find(item => item.id === active.id);
|
|
55
55
|
const overRect = over.rect;
|
|
56
56
|
const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
let [id, container] = _ref2;
|
|
60
|
-
|
|
58
|
+
droppableContainers.forEach(container => {
|
|
61
59
|
if (container !== null && container !== void 0 && container.disabled || !overRect) {
|
|
62
60
|
return;
|
|
63
61
|
}
|
|
@@ -68,44 +66,48 @@ const getHorizontalKeyboardCoordinates = _ref => {
|
|
|
68
66
|
return;
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
const itemParent = items.find(item => item.id === id).parentId;
|
|
69
|
+
const itemParent = items.find(item => item.id === container.id).parentId;
|
|
72
70
|
if (itemParent !== activeItem.parentId) return;
|
|
73
71
|
const rect = getViewRect(node);
|
|
74
72
|
|
|
75
|
-
if (event.code === KeyboardCode.Left &&
|
|
76
|
-
layoutRects.push(
|
|
77
|
-
} else if (event.code === KeyboardCode.Right &&
|
|
78
|
-
layoutRects.push(
|
|
73
|
+
if (event.code === KeyboardCode.Left && collisionRect.left > rect.right - 10) {
|
|
74
|
+
layoutRects.push(container);
|
|
75
|
+
} else if (event.code === KeyboardCode.Right && collisionRect.left < rect.left) {
|
|
76
|
+
layoutRects.push(container);
|
|
79
77
|
}
|
|
80
78
|
});
|
|
81
79
|
const dragOverlayRect = (_document$querySelect = (_document$querySelect2 = document.querySelector("[data-testid=\"".concat(DATA_TESTID.DATA_TABLE_COLUMN_DRAG_OVERLAY, "\"]"))) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.getBoundingClientRect()) !== null && _document$querySelect !== void 0 ? _document$querySelect : {
|
|
82
80
|
width: 150,
|
|
83
81
|
left: 0
|
|
84
82
|
};
|
|
85
|
-
const closestId = closestCorners(
|
|
83
|
+
const closestId = closestCorners({
|
|
84
|
+
droppableContainers: layoutRects,
|
|
85
|
+
collisionRect,
|
|
86
|
+
active
|
|
87
|
+
});
|
|
86
88
|
if (!closestId) return undefined;
|
|
87
|
-
const closestRect = getViewRect(droppableContainers
|
|
88
|
-
const activeRect = getViewRect(droppableContainers
|
|
89
|
+
const closestRect = getViewRect(droppableContainers.get(closestId).node.current);
|
|
90
|
+
const activeRect = getViewRect(droppableContainers.get(active.id).node.current);
|
|
89
91
|
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
90
92
|
x: closestRect.left + (closestRect.width - dragOverlayRect.width) / 2 + (closestRect.offsetLeft < activeRect.left ? -1 : 1)
|
|
91
93
|
});
|
|
92
94
|
};
|
|
93
95
|
|
|
94
|
-
const getHierarchyKeyboardCoordinates = (context, isHorizontalDnD) => (event,
|
|
96
|
+
const getHierarchyKeyboardCoordinates = (context, isHorizontalDnD) => (event, _ref2) => {
|
|
95
97
|
let {
|
|
96
|
-
active,
|
|
97
98
|
currentCoordinates,
|
|
98
99
|
context: {
|
|
100
|
+
active,
|
|
99
101
|
over,
|
|
100
|
-
|
|
102
|
+
collisionRect,
|
|
101
103
|
droppableContainers
|
|
102
104
|
}
|
|
103
|
-
} =
|
|
105
|
+
} = _ref2;
|
|
104
106
|
|
|
105
107
|
if (directions.includes(event.code)) {
|
|
106
108
|
event.preventDefault();
|
|
107
109
|
|
|
108
|
-
if (!
|
|
110
|
+
if (!collisionRect) {
|
|
109
111
|
return undefined;
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -121,7 +123,7 @@ const getHierarchyKeyboardCoordinates = (context, isHorizontalDnD) => (event, _r
|
|
|
121
123
|
event,
|
|
122
124
|
currentCoordinates,
|
|
123
125
|
droppableContainers,
|
|
124
|
-
|
|
126
|
+
collisionRect
|
|
125
127
|
};
|
|
126
128
|
if (isHorizontalDnD) return getHorizontalKeyboardCoordinates(args);
|
|
127
129
|
return undefined;
|
|
@@ -10,7 +10,7 @@ import 'core-js/modules/esnext.iterator.find.js';
|
|
|
10
10
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
11
11
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
12
12
|
import { useState, useMemo, useRef, useEffect } from 'react';
|
|
13
|
-
import {
|
|
13
|
+
import { MeasuringStrategy, useSensors, useSensor, PointerSensor, KeyboardSensor } from '@dnd-kit/core';
|
|
14
14
|
import { useHierarchyActionHandlers } from './useHierarchyActionHandlers.js';
|
|
15
15
|
import { useHierarchyPreviewHandlers } from './useHierarchyPreviewHandlers.js';
|
|
16
16
|
import { getHierarchyKeyboardCoordinates } from './getHierarchyKeyboardCoordinates.js';
|
|
@@ -39,8 +39,10 @@ const adjustTranslate = function (_ref) {
|
|
|
39
39
|
return newTransform;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const measuring = {
|
|
43
|
+
droppable: {
|
|
44
|
+
strategy: MeasuringStrategy.Always
|
|
45
|
+
}
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
const useHierarchyDndkitConfig = _ref2 => {
|
|
@@ -89,7 +91,7 @@ const useHierarchyDndkitConfig = _ref2 => {
|
|
|
89
91
|
announcements,
|
|
90
92
|
modifiers,
|
|
91
93
|
sensors,
|
|
92
|
-
|
|
94
|
+
measuring,
|
|
93
95
|
collisionDetection: customCollisionDetection(activeId, activeItem === null || activeItem === void 0 ? void 0 : activeItem.parentId, dndItems)
|
|
94
96
|
}, dragActionHandlers), [announcements, modifiers, sensors, activeId, activeItem === null || activeItem === void 0 ? void 0 : activeItem.parentId, dndItems, dragActionHandlers]);
|
|
95
97
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
2
2
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
3
|
import 'core-js/modules/esnext.iterator.find.js';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
4
|
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
6
5
|
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
6
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
7
7
|
import { DropIndicatorPosition } from '../../../parts/HoC/SortableItemContext.js';
|
|
8
8
|
|
|
9
9
|
const DUMMY_ID = 'DUMMY_ID_INTERNAL_USE_ONLY';
|
|
@@ -29,58 +29,78 @@ const RECT_DOWN = {
|
|
|
29
29
|
const thresholdRatio = 0.2; // Percentage to be inside
|
|
30
30
|
|
|
31
31
|
const insideThreshold = 0.7;
|
|
32
|
-
const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition) => _ref => {
|
|
33
|
+
var _originalContainer$re;
|
|
34
|
+
|
|
35
|
+
let {
|
|
36
|
+
droppableContainers,
|
|
37
|
+
collisionRect
|
|
38
|
+
} = _ref;
|
|
39
|
+
const originalContainer = droppableContainers.find(_ref2 => {
|
|
40
|
+
let {
|
|
41
|
+
id
|
|
42
|
+
} = _ref2;
|
|
43
|
+
return id === activeId;
|
|
44
|
+
});
|
|
45
|
+
const originalRect = originalContainer === null || originalContainer === void 0 ? void 0 : (_originalContainer$re = originalContainer.rect) === null || _originalContainer$re === void 0 ? void 0 : _originalContainer$re.current; // We first check if the item was moved up or down
|
|
37
46
|
// This modifies how to search the matching colliding rect
|
|
38
47
|
|
|
39
48
|
let isUp = lastPosition === 'up';
|
|
40
49
|
|
|
41
50
|
if (originalRect) {
|
|
42
|
-
isUp = originalRect
|
|
51
|
+
isUp = originalRect.offsetTop > collisionRect.top;
|
|
43
52
|
} // Threshold
|
|
44
53
|
|
|
45
54
|
|
|
46
|
-
const threshold =
|
|
47
|
-
let
|
|
55
|
+
const threshold = collisionRect.height * thresholdRatio;
|
|
56
|
+
let collidingContainer = null;
|
|
48
57
|
|
|
49
58
|
if (isUp) {
|
|
50
59
|
// Up -- We need to find the first rectangle downwards
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
collidingContainer = droppableContainers.reduce((acc, container) => {
|
|
61
|
+
const rect = container.rect.current;
|
|
53
62
|
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
63
|
+
if (rect.offsetTop + threshold > collisionRect.top && rect.offsetTop < acc.rect.current.offsetTop) {
|
|
64
|
+
return container;
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
return acc;
|
|
59
|
-
},
|
|
68
|
+
}, {
|
|
69
|
+
id: DUMMY_ID,
|
|
70
|
+
rect: {
|
|
71
|
+
current: RECT_DOWN
|
|
72
|
+
}
|
|
73
|
+
});
|
|
60
74
|
} else {
|
|
61
75
|
// Down -- We need to find the first rectangle upwards
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
collidingContainer = droppableContainers.reduce((acc, container) => {
|
|
77
|
+
const rect = container.rect.current;
|
|
64
78
|
|
|
65
|
-
if (
|
|
66
|
-
return
|
|
79
|
+
if (rect.offsetTop - threshold < collisionRect.top && rect.offsetTop > acc.rect.current.offsetTop) {
|
|
80
|
+
return container;
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
return acc;
|
|
70
|
-
},
|
|
84
|
+
}, {
|
|
85
|
+
id: DUMMY_ID,
|
|
86
|
+
rect: {
|
|
87
|
+
current: RECT_UP
|
|
88
|
+
}
|
|
89
|
+
});
|
|
71
90
|
} // If we didn't find a match, return null
|
|
72
91
|
|
|
73
92
|
|
|
74
|
-
if (
|
|
93
|
+
if (collidingContainer.id === DUMMY_ID) {
|
|
75
94
|
return null;
|
|
76
|
-
}
|
|
95
|
+
}
|
|
77
96
|
|
|
97
|
+
const collidingRect = collidingContainer.rect.current; // Calculate the intersection interval
|
|
78
98
|
|
|
79
|
-
const [top, bottom] = [Math.max(
|
|
99
|
+
const [top, bottom] = [Math.max(collisionRect.top, collidingRect.offsetTop), Math.min(collisionRect.bottom, collidingRect.offsetTop + collidingRect.height)]; // Calculate the percentage of intersection
|
|
80
100
|
|
|
81
|
-
const intersectionPercentage = Math.abs(bottom - top) / collidingRect
|
|
101
|
+
const intersectionPercentage = Math.abs(bottom - top) / collidingRect.height;
|
|
82
102
|
|
|
83
|
-
if (intersectionPercentage > insideThreshold && visibleItemsDictionary[
|
|
103
|
+
if (intersectionPercentage > insideThreshold && visibleItemsDictionary[collidingContainer.id].depth + 1 <= maxDragAndDropLevel && collidingContainer.id !== activeId) {
|
|
84
104
|
setDropIndicatorPosition(DropIndicatorPosition.Inside);
|
|
85
105
|
} else {
|
|
86
106
|
setDropIndicatorPosition(isUp ? DropIndicatorPosition.Before : DropIndicatorPosition.After);
|
|
@@ -88,7 +108,7 @@ const customCollisionDetection = (activeId, visibleItemsDictionary, setDropIndic
|
|
|
88
108
|
|
|
89
109
|
if (isUp && lastPosition !== 'up') setLastPosition('up');else if (!isUp && lastPosition !== 'down') setLastPosition('down'); // Return the id of the match rectangle
|
|
90
110
|
|
|
91
|
-
return
|
|
111
|
+
return collidingContainer.id;
|
|
92
112
|
};
|
|
93
113
|
|
|
94
114
|
export { customCollisionDetection };
|
|
@@ -2,12 +2,11 @@ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
|
2
2
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
3
3
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
4
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
6
5
|
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
7
6
|
import 'core-js/modules/esnext.iterator.find.js';
|
|
8
7
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
9
8
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
|
-
import { KeyboardCode,
|
|
9
|
+
import { KeyboardCode, closestCorners, getViewRect } from '@dnd-kit/core';
|
|
11
10
|
import { DropIndicatorPosition } from '../../../parts/HoC/SortableItemContext.js';
|
|
12
11
|
|
|
13
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -24,80 +23,76 @@ const getVerticalKeyboardCoordinates = _ref => {
|
|
|
24
23
|
event,
|
|
25
24
|
currentCoordinates,
|
|
26
25
|
droppableContainers,
|
|
27
|
-
|
|
26
|
+
collisionRect,
|
|
28
27
|
dropIndicatorPosition,
|
|
29
28
|
maxDragAndDropLevel
|
|
30
29
|
} = _ref;
|
|
31
30
|
if (horizontal.includes(event.code)) return undefined;
|
|
32
|
-
const activeRect = droppableContainers[active].rect.current;
|
|
33
31
|
const overRect = over.rect;
|
|
34
32
|
const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
let [id, container] = _ref2;
|
|
38
|
-
|
|
34
|
+
droppableContainers.forEach(container => {
|
|
39
35
|
if (container !== null && container !== void 0 && container.disabled || !overRect) {
|
|
40
36
|
return;
|
|
41
37
|
}
|
|
42
38
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
if (!node) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const rect = getViewRect(node);
|
|
39
|
+
const rect = container.rect.current;
|
|
50
40
|
|
|
51
|
-
if (event.code === KeyboardCode.Down &&
|
|
52
|
-
layoutRects.push(
|
|
53
|
-
} else if (event.code === KeyboardCode.Up &&
|
|
54
|
-
layoutRects.push(
|
|
41
|
+
if (event.code === KeyboardCode.Down && collisionRect.top - 2 <= rect.offsetTop) {
|
|
42
|
+
layoutRects.push(container);
|
|
43
|
+
} else if (event.code === KeyboardCode.Up && collisionRect.top >= rect.offsetTop) {
|
|
44
|
+
layoutRects.push(container);
|
|
55
45
|
}
|
|
56
46
|
});
|
|
57
|
-
const closestId = closestCorners(
|
|
47
|
+
const closestId = closestCorners({
|
|
48
|
+
collisionRect,
|
|
49
|
+
droppableContainers: layoutRects,
|
|
50
|
+
active
|
|
51
|
+
});
|
|
58
52
|
if (!closestId) return undefined;
|
|
59
53
|
const closestItem = items.find(item => item.uid === closestId);
|
|
60
|
-
const closestRect = getViewRect(droppableContainers
|
|
54
|
+
const closestRect = getViewRect(droppableContainers.get(closestId).node.current);
|
|
61
55
|
|
|
62
56
|
if (event.code === KeyboardCode.Up) {
|
|
63
57
|
// If the drop indicator is inside (or over ourselves)
|
|
64
58
|
// We are gonna go to the before position
|
|
65
59
|
// Else we are gonna go inside the over rect
|
|
66
|
-
if (dropIndicatorPosition === DropIndicatorPosition.Inside || closestId === active || closestItem.depth + 1 > maxDragAndDropLevel) {
|
|
60
|
+
if (dropIndicatorPosition === DropIndicatorPosition.Inside || closestId === active.id || closestItem.depth + 1 > maxDragAndDropLevel) {
|
|
67
61
|
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
68
|
-
y: closestRect.top -
|
|
62
|
+
y: closestRect.top - collisionRect.height / 2
|
|
69
63
|
});
|
|
70
64
|
}
|
|
71
65
|
|
|
72
66
|
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
73
|
-
y: closestRect.top + Math.abs(closestRect.height -
|
|
67
|
+
y: closestRect.top + Math.abs(closestRect.height - collisionRect.height) / 2
|
|
74
68
|
});
|
|
75
69
|
} // If the drop indicator is inside (or over ourselves)
|
|
76
70
|
// We are gonna go to the after position
|
|
77
71
|
// Else we are gonna go inside the over rect
|
|
78
72
|
|
|
79
73
|
|
|
80
|
-
if (dropIndicatorPosition === DropIndicatorPosition.Inside || closestId === active || closestItem.depth + 1 > maxDragAndDropLevel) {
|
|
74
|
+
if (dropIndicatorPosition === DropIndicatorPosition.Inside || closestId === active.id || closestItem.depth + 1 > maxDragAndDropLevel) {
|
|
81
75
|
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
82
|
-
y: closestRect.top +
|
|
76
|
+
y: closestRect.top + collisionRect.height / 2
|
|
83
77
|
});
|
|
84
78
|
}
|
|
85
79
|
|
|
86
80
|
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
87
|
-
y: closestRect.top + Math.abs(closestRect.height -
|
|
81
|
+
y: closestRect.top + Math.abs(closestRect.height - collisionRect.height) / 2
|
|
88
82
|
});
|
|
89
83
|
};
|
|
90
84
|
|
|
91
|
-
const getTreeKeyboardCoordinates = (context, isHorizontalDnD, maxDragAndDropLevel) => (event,
|
|
85
|
+
const getTreeKeyboardCoordinates = (context, isHorizontalDnD, maxDragAndDropLevel) => (event, _ref2) => {
|
|
92
86
|
let {
|
|
93
|
-
active,
|
|
94
87
|
currentCoordinates,
|
|
95
88
|
context: {
|
|
96
89
|
over,
|
|
97
90
|
translatedRect,
|
|
98
|
-
droppableContainers
|
|
91
|
+
droppableContainers,
|
|
92
|
+
active,
|
|
93
|
+
collisionRect
|
|
99
94
|
}
|
|
100
|
-
} =
|
|
95
|
+
} = _ref2;
|
|
101
96
|
|
|
102
97
|
if (directions.includes(event.code)) {
|
|
103
98
|
if (!translatedRect) {
|
|
@@ -117,7 +112,7 @@ const getTreeKeyboardCoordinates = (context, isHorizontalDnD, maxDragAndDropLeve
|
|
|
117
112
|
event,
|
|
118
113
|
currentCoordinates,
|
|
119
114
|
droppableContainers,
|
|
120
|
-
|
|
115
|
+
collisionRect,
|
|
121
116
|
dropIndicatorPosition,
|
|
122
117
|
maxDragAndDropLevel
|
|
123
118
|
};
|
|
@@ -8,7 +8,7 @@ import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
|
8
8
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
9
9
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
10
|
import { useState, useMemo, useRef, useEffect } from 'react';
|
|
11
|
-
import {
|
|
11
|
+
import { MeasuringStrategy, useSensors, useSensor, PointerSensor, KeyboardSensor } from '@dnd-kit/core';
|
|
12
12
|
import { horizontalListSortingStrategy, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
13
13
|
import { useTreePreviewHandlers } from './useTreePreviewHandlers.js';
|
|
14
14
|
import { getTreeKeyboardCoordinates } from './getTreeKeyboardCoordinates.js';
|
|
@@ -39,8 +39,10 @@ const adjustTranslate = function (_ref) {
|
|
|
39
39
|
return newTransform;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const measuring = {
|
|
43
|
+
droppable: {
|
|
44
|
+
strategy: MeasuringStrategy.BeforeDragging
|
|
45
|
+
}
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
const useTreeDndkitConfig = _ref2 => {
|
|
@@ -111,7 +113,7 @@ const useTreeDndkitConfig = _ref2 => {
|
|
|
111
113
|
announcements,
|
|
112
114
|
modifiers,
|
|
113
115
|
sensors,
|
|
114
|
-
|
|
116
|
+
measuring,
|
|
115
117
|
collisionDetection: customCollisionDetection(activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition)
|
|
116
118
|
}, dragActionHandlers), [announcements, modifiers, sensors, dragActionHandlers, visibleItemsDictionary, setDropIndicatorPosition, activeId, maxDragAndDropLevel, lastPosition, setLastPosition]);
|
|
117
119
|
const sortableContextProps = useMemo(() => ({
|
|
@@ -11,8 +11,8 @@ const setMultipleRefs = function () {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const filteredRefs = refs.filter(Boolean);
|
|
14
|
-
if (!filteredRefs.length) return null;
|
|
15
|
-
if (filteredRefs.length === 0) return
|
|
14
|
+
if (!filteredRefs.length) return () => null;
|
|
15
|
+
if (filteredRefs.length === 0) return () => null;
|
|
16
16
|
return newRef => {
|
|
17
17
|
filteredRefs.forEach(refToBeUpdated => {
|
|
18
18
|
if (typeof refToBeUpdated === 'function') {
|
package/esm/index.js
CHANGED
|
@@ -6,7 +6,6 @@ export { groupBy } from './exported-related/groupBy.js';
|
|
|
6
6
|
export { FILTER_TYPES } from './exported-related/FilterTypes.js';
|
|
7
7
|
export { ROW_VARIANTS, ROW_VARIANT_COMPACT_KEY, ROW_VARIANT_KEY } from './exported-related/RowVariants.js';
|
|
8
8
|
export { applyOutOfTheBoxFilters } from './exported-related/Filters/applyOutOfTheBoxFilters.js';
|
|
9
|
-
export { textFilterFn } from './exported-related/Filters/textFilterFn.js';
|
|
10
9
|
export { singleDateFilterFn } from './exported-related/Filters/singleDateFilterFn.js';
|
|
11
10
|
export { singleSelectFilterFn } from './exported-related/Filters/singleSelectFilterFn.js';
|
|
12
11
|
export { multiSelectFilterFn } from './exported-related/Filters/multiSelectFilterFn.js';
|
|
@@ -45,14 +45,12 @@ import { MultiSelectPill } from './components/MultiSelectPill.js';
|
|
|
45
45
|
import { NumberRangePill } from './components/NumberRangePill.js';
|
|
46
46
|
import { SelectPill } from './components/SelectPill.js';
|
|
47
47
|
import { SingleDatePill } from './components/SingleDatePill.js';
|
|
48
|
-
import { TextPill } from './components/TextPill.js';
|
|
49
48
|
import { StyledWrapper, StyledDropdownMenu } from './styled.js';
|
|
50
49
|
|
|
51
50
|
var _MoreOptionsVert;
|
|
52
51
|
const pillRenderMapper = {
|
|
53
52
|
[FILTER_TYPES.SELECT]: SelectPill,
|
|
54
53
|
[FILTER_TYPES.MULTI_SELECT]: MultiSelectPill,
|
|
55
|
-
[FILTER_TYPES.TEXT]: TextPill,
|
|
56
54
|
[FILTER_TYPES.SINGLE_DATE]: SingleDatePill,
|
|
57
55
|
[FILTER_TYPES.DATE_RANGE]: DateRangePill,
|
|
58
56
|
[FILTER_TYPES.DATE_SWITCHER]: DateSwitcherPill,
|
|
@@ -15,7 +15,6 @@ import { CurrencyRangeFilter } from '../../addons/Filters/Components/CurrencyRan
|
|
|
15
15
|
import { SingleSelectFilter } from '../../addons/Filters/Components/SelectFilter/SingleSelectFilter.js';
|
|
16
16
|
import { MultiSelectFilter } from '../../addons/Filters/Components/SelectFilter/MultiSelectFilter.js';
|
|
17
17
|
import { SingleDateFilter } from '../../addons/Filters/Components/SingleDateFilter/index.js';
|
|
18
|
-
import { TextInputFilter } from '../../addons/Filters/Components/TextInputFilter/index.js';
|
|
19
18
|
import '@babel/runtime/helpers/esm/jsx';
|
|
20
19
|
import '@elliemae/ds-button';
|
|
21
20
|
import '@elliemae/ds-popperjs';
|
|
@@ -55,7 +54,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
55
54
|
const FilterMapper = {
|
|
56
55
|
[FILTER_TYPES.SELECT]: SingleSelectFilter,
|
|
57
56
|
[FILTER_TYPES.MULTI_SELECT]: MultiSelectFilter,
|
|
58
|
-
[FILTER_TYPES.TEXT]: TextInputFilter,
|
|
59
57
|
[FILTER_TYPES.SINGLE_DATE]: SingleDateFilter,
|
|
60
58
|
[FILTER_TYPES.DATE_RANGE]: DateRangeFilter,
|
|
61
59
|
[FILTER_TYPES.DATE_SWITCHER]: DateSwitcherFilter,
|
|
@@ -54,7 +54,7 @@ const HeaderCellGroupComp = _ref => {
|
|
|
54
54
|
const children = header.columns;
|
|
55
55
|
const isDragging = draggableProps && draggableProps.isDragging || isDraggingParent;
|
|
56
56
|
const dropIndicatorPosition = draggableProps && draggableProps.shouldShowDropIndicatorPosition && draggableProps.dropIndicatorPosition;
|
|
57
|
-
const ChildGroup = isDragOverlay ?
|
|
57
|
+
const ChildGroup = isDragOverlay ? HeaderCellGroup : HeaderCellGroupSortable;
|
|
58
58
|
const colSpan = (_children$length = children === null || children === void 0 ? void 0 : children.length) !== null && _children$length !== void 0 ? _children$length : 1;
|
|
59
59
|
return /*#__PURE__*/jsxs(StyledWrapper, {
|
|
60
60
|
ref: draggableProps ? draggableProps.setNodeRef : null,
|
|
@@ -84,7 +84,7 @@ const HeaderCellGroupComp = _ref => {
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
// We need to declare this because we MUST avoid the useSortable call in the recursive calls of the function
|
|
87
|
-
const
|
|
88
|
-
const
|
|
87
|
+
const HeaderCellGroup = HeaderCellGroupComp;
|
|
88
|
+
const HeaderCellGroupSortable = withDnDSortableColumnContext(HeaderCellGroupComp);
|
|
89
89
|
|
|
90
|
-
export { HeaderCellGroup };
|
|
90
|
+
export { HeaderCellGroup, HeaderCellGroupSortable as default };
|
|
@@ -5,7 +5,7 @@ import { useContext, useMemo } from 'react';
|
|
|
5
5
|
import { StyledHeadTr, StyledHeadWrapper } from '../../styled.js';
|
|
6
6
|
import DataTableContext from '../../DataTableContext.js';
|
|
7
7
|
import { withConditionalDnDColumnContext } from '../HoC/withConditionalDnDColumnContext.js';
|
|
8
|
-
import
|
|
8
|
+
import HeaderCellGroupSortable from './HeaderCellGroup.js';
|
|
9
9
|
import { SortableHeaderCell } from '../SortableHeaderCell.js';
|
|
10
10
|
import { jsx } from 'react/jsx-runtime';
|
|
11
11
|
|
|
@@ -29,7 +29,7 @@ const HeadersComp = () => {
|
|
|
29
29
|
cols: gridLayout,
|
|
30
30
|
colsLayoutStyle: colsLayoutStyle,
|
|
31
31
|
isExpandable: isExpandable
|
|
32
|
-
}, void 0, visibleColumns.map((h, index) => /*#__PURE__*/_jsx(
|
|
32
|
+
}, void 0, visibleColumns.map((h, index) => /*#__PURE__*/_jsx(HeaderCellGroupSortable, {
|
|
33
33
|
header: h,
|
|
34
34
|
isLast: index === visibleColumns.length - 1
|
|
35
35
|
}, h.id)))), [isExpandable, visibleColumns, gridLayout, colsLayoutStyle]);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
1
3
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
4
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
5
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
6
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
7
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
8
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
7
|
-
import 'core-js/modules/esnext.async-iterator.
|
|
8
|
-
import 'core-js/modules/esnext.iterator.
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
9
11
|
import React, { useMemo, useCallback, createContext } from 'react';
|
|
10
12
|
import { DndContext, DragOverlay } from '@dnd-kit/core';
|
|
11
13
|
import { arrayMove } from '@dnd-kit/sortable';
|
|
12
|
-
import { DragOverlayContext } from './DragOverlayContext.js';
|
|
13
14
|
import useHierarchyDndkitConfig from '../../helpers/dndkit/hierarchy/useHierarchyDndkitConfig.js';
|
|
14
15
|
import DataTableContext from '../../DataTableContext.js';
|
|
16
|
+
import { HeaderCellGroup } from '../Headers/HeaderCellGroup.js';
|
|
15
17
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
16
18
|
|
|
17
19
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -26,7 +28,9 @@ const flattenColumns = cols => {
|
|
|
26
28
|
|
|
27
29
|
const flatten = function (col, index) {
|
|
28
30
|
let parentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
29
|
-
const
|
|
31
|
+
const {
|
|
32
|
+
id
|
|
33
|
+
} = col;
|
|
30
34
|
flattened.push([{
|
|
31
35
|
id,
|
|
32
36
|
parentId,
|
|
@@ -44,13 +48,11 @@ const withConditionalDnDColumnContext = Component => props => {
|
|
|
44
48
|
const {
|
|
45
49
|
tableProps: {
|
|
46
50
|
dragAndDropColumns,
|
|
47
|
-
columns,
|
|
48
51
|
onColumnsReorder
|
|
49
|
-
}
|
|
52
|
+
},
|
|
53
|
+
visibleColumns
|
|
50
54
|
} = React.useContext(DataTableContext);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const flattenedItems = useMemo(() => flattenColumns(columns), [columns]);
|
|
55
|
+
const flattenedItems = useMemo(() => flattenColumns(visibleColumns), [visibleColumns]);
|
|
54
56
|
const onReorder = useCallback((movedItem, indexes) => {
|
|
55
57
|
// Send from index to target index
|
|
56
58
|
const newFlattenedData = arrayMove(flattenedItems, indexes.fromIndex, indexes.targetIndex); // Pull the cols's data into an object
|
|
@@ -84,15 +86,17 @@ const withConditionalDnDColumnContext = Component => props => {
|
|
|
84
86
|
onReorder
|
|
85
87
|
});
|
|
86
88
|
if (dragAndDropColumns) return /*#__PURE__*/jsxs(DndContext, _objectSpread(_objectSpread({}, dndContextProps), {}, {
|
|
87
|
-
children: [/*#__PURE__*/_jsx(
|
|
88
|
-
value: {
|
|
89
|
-
setPureDraggedJSX
|
|
90
|
-
}
|
|
91
|
-
}, void 0, /*#__PURE__*/_jsx(DnDGroupContext.Provider, {
|
|
89
|
+
children: [/*#__PURE__*/_jsx(DnDGroupContext.Provider, {
|
|
92
90
|
value: {
|
|
93
91
|
activeIndex
|
|
94
92
|
}
|
|
95
|
-
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)))
|
|
93
|
+
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props))), /*#__PURE__*/_jsx(DragOverlay, {}, void 0, activeId ? /*#__PURE__*/_jsx(HeaderCellGroup, {
|
|
94
|
+
header: flattenedItems.find(_ref3 => {
|
|
95
|
+
let [item] = _ref3;
|
|
96
|
+
return item.id === activeId;
|
|
97
|
+
})[1],
|
|
98
|
+
isDragOverlay: true
|
|
99
|
+
}) : null)]
|
|
96
100
|
}));
|
|
97
101
|
return /*#__PURE__*/jsx(Component, _objectSpread({}, props));
|
|
98
102
|
};
|