@elliemae/ds-data-table 2.0.0-rc.1 → 2.0.0-rc.13
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 +21 -12
- package/cjs/addons/Editables/TextEditableCell/TextEditableCell.js +16 -0
- package/cjs/addons/Filters/Components/CurrencyRangeFilter/index.js +24 -2
- package/cjs/addons/Filters/Components/DateRangeFilter/index.js +4 -1
- package/cjs/addons/Filters/Components/NumberRangeFilter/index.js +25 -3
- package/cjs/addons/Filters/Components/SingleDateFilter/index.js +4 -1
- package/cjs/addons/Filters/Components/index.js +0 -2
- package/cjs/addons/Filters/index.js +0 -2
- package/cjs/configs/usePaginationConfig.js +1 -1
- package/cjs/configs/useRowFlattenization.js +3 -3
- package/cjs/exported-related/EditableCell.js +13 -7
- 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/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/Headers/useHeaderCellHandlers.js +4 -2
- package/cjs/parts/HoC/withConditionalDnDColumnContext.js +37 -16
- package/cjs/parts/HoC/withConditionalDnDRowContext.js +11 -12
- 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 +18 -13
- package/esm/DataTableSchema.js +21 -12
- package/esm/addons/Editables/TextEditableCell/TextEditableCell.js +16 -0
- package/esm/addons/Filters/Components/CurrencyRangeFilter/index.js +24 -2
- package/esm/addons/Filters/Components/DateRangeFilter/index.js +4 -1
- package/esm/addons/Filters/Components/NumberRangeFilter/index.js +25 -3
- package/esm/addons/Filters/Components/SingleDateFilter/index.js +4 -1
- package/esm/addons/Filters/Components/index.js +0 -1
- package/esm/addons/Filters/index.js +0 -1
- package/esm/configs/usePaginationConfig.js +1 -1
- package/esm/configs/useRowFlattenization.js +3 -3
- package/esm/exported-related/EditableCell.js +13 -7
- 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/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/Headers/useHeaderCellHandlers.js +4 -2
- package/esm/parts/HoC/withConditionalDnDColumnContext.js +38 -17
- package/esm/parts/HoC/withConditionalDnDRowContext.js +12 -13
- 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 +18 -13
- package/package.json +26 -103
- package/types/DataTable.d.ts +245 -43
- package/types/DataTableSchema.d.ts +245 -43
- 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/refs-helpers.d.ts +1 -1
- package/types/parts/FilterBar/components/index.d.ts +0 -1
- package/types/parts/FilterBar/styled.d.ts +165 -30
- package/types/parts/Headers/HeaderCellGroup.d.ts +4 -3
- package/types/parts/Row.d.ts +2 -1
- package/types/styled.d.ts +21 -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/helpers/dndkit/hierarchy/customCollisionDetection.js +0 -76
- package/cjs/helpers/dndkit/hierarchy/getHierarchyKeyboardCoordinates.js +0 -141
- package/cjs/helpers/dndkit/hierarchy/types.js +0 -2
- package/cjs/helpers/dndkit/hierarchy/useHierarchyActionHandlers.js +0 -55
- package/cjs/helpers/dndkit/hierarchy/useHierarchyAnnouncements.js +0 -36
- package/cjs/helpers/dndkit/hierarchy/useHierarchyDndkitConfig.js +0 -109
- package/cjs/helpers/dndkit/hierarchy/useHierarchyPreviewHandlers.js +0 -87
- package/cjs/helpers/dndkit/tree/customCollisionDetection.js +0 -98
- package/cjs/helpers/dndkit/tree/getTreeKeyboardCoordinates.js +0 -139
- package/cjs/helpers/dndkit/tree/types.js +0 -2
- package/cjs/helpers/dndkit/tree/useTreeActionHandlers.js +0 -75
- package/cjs/helpers/dndkit/tree/useTreeAnnouncements.js +0 -55
- package/cjs/helpers/dndkit/tree/useTreeDndkitConfig.js +0 -139
- package/cjs/helpers/dndkit/tree/useTreePreviewHandlers.js +0 -54
- package/cjs/helpers/dndkit/types.js +0 -2
- package/cjs/helpers/dndkit/utilities.js +0 -52
- 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/helpers/dndkit/hierarchy/customCollisionDetection.js +0 -72
- package/esm/helpers/dndkit/hierarchy/getHierarchyKeyboardCoordinates.js +0 -133
- package/esm/helpers/dndkit/hierarchy/types.js +0 -1
- package/esm/helpers/dndkit/hierarchy/useHierarchyActionHandlers.js +0 -51
- package/esm/helpers/dndkit/hierarchy/useHierarchyAnnouncements.js +0 -32
- package/esm/helpers/dndkit/hierarchy/useHierarchyDndkitConfig.js +0 -103
- package/esm/helpers/dndkit/hierarchy/useHierarchyPreviewHandlers.js +0 -83
- package/esm/helpers/dndkit/tree/customCollisionDetection.js +0 -94
- package/esm/helpers/dndkit/tree/getTreeKeyboardCoordinates.js +0 -131
- package/esm/helpers/dndkit/tree/types.js +0 -1
- package/esm/helpers/dndkit/tree/useTreeActionHandlers.js +0 -71
- package/esm/helpers/dndkit/tree/useTreeAnnouncements.js +0 -51
- package/esm/helpers/dndkit/tree/useTreeDndkitConfig.js +0 -133
- package/esm/helpers/dndkit/tree/useTreePreviewHandlers.js +0 -50
- package/esm/helpers/dndkit/types.js +0 -1
- package/esm/helpers/dndkit/utilities.js +0 -47
- 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/helpers/dndkit/hierarchy/customCollisionDetection.d.ts +0 -3
- package/types/helpers/dndkit/hierarchy/getHierarchyKeyboardCoordinates.d.ts +0 -3
- package/types/helpers/dndkit/hierarchy/types.d.ts +0 -66
- package/types/helpers/dndkit/hierarchy/useHierarchyActionHandlers.d.ts +0 -2
- package/types/helpers/dndkit/hierarchy/useHierarchyAnnouncements.d.ts +0 -3
- package/types/helpers/dndkit/hierarchy/useHierarchyDndkitConfig.d.ts +0 -3
- package/types/helpers/dndkit/hierarchy/useHierarchyPreviewHandlers.d.ts +0 -2
- package/types/helpers/dndkit/tree/customCollisionDetection.d.ts +0 -4
- package/types/helpers/dndkit/tree/getTreeKeyboardCoordinates.d.ts +0 -3
- package/types/helpers/dndkit/tree/types.d.ts +0 -83
- package/types/helpers/dndkit/tree/useTreeActionHandlers.d.ts +0 -2
- package/types/helpers/dndkit/tree/useTreeAnnouncements.d.ts +0 -4
- package/types/helpers/dndkit/tree/useTreeDndkitConfig.d.ts +0 -3
- package/types/helpers/dndkit/tree/useTreePreviewHandlers.d.ts +0 -2
- package/types/helpers/dndkit/types.d.ts +0 -20
- package/types/helpers/dndkit/utilities.d.ts +0 -7
- package/types/parts/FilterBar/components/TextPill.d.ts +0 -2
- package/types/parts/HoC/DragOverlayContext.d.ts +0 -6
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
-
var React = require('react');
|
|
13
|
-
var core = require('@dnd-kit/core');
|
|
14
|
-
var sortable = require('@dnd-kit/sortable');
|
|
15
|
-
var useTreePreviewHandlers = require('./useTreePreviewHandlers.js');
|
|
16
|
-
var getTreeKeyboardCoordinates = require('./getTreeKeyboardCoordinates.js');
|
|
17
|
-
var utilities = require('../utilities.js');
|
|
18
|
-
var useTreeActionHandlers = require('./useTreeActionHandlers.js');
|
|
19
|
-
var customCollisionDetection = require('./customCollisionDetection.js');
|
|
20
|
-
var useTreeAnnouncements = require('./useTreeAnnouncements.js');
|
|
21
|
-
|
|
22
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
-
|
|
24
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
// if second parameter is true, the space will be done on the horizontal axis
|
|
30
|
-
|
|
31
|
-
const adjustTranslate = function (_ref) {
|
|
32
|
-
let {
|
|
33
|
-
transform
|
|
34
|
-
} = _ref;
|
|
35
|
-
let isHorizontalDnD = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
36
|
-
|
|
37
|
-
const newTransform = _objectSpread({}, transform);
|
|
38
|
-
|
|
39
|
-
if (isHorizontalDnD) {
|
|
40
|
-
newTransform.x = transform.x + 25;
|
|
41
|
-
} else {
|
|
42
|
-
newTransform.x = transform.x + 15;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return newTransform;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const layoutMeasuring = {
|
|
49
|
-
strategy: core.LayoutMeasuringStrategy.BeforeDragging
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const useTreeDndkitConfig = _ref2 => {
|
|
53
|
-
var _visibleItemsDictiona, _visibleItemsDictiona2;
|
|
54
|
-
|
|
55
|
-
let {
|
|
56
|
-
flattenedItems,
|
|
57
|
-
visibleItems: preVisibleItems,
|
|
58
|
-
isHorizontalDnD = false,
|
|
59
|
-
isExpandable = false,
|
|
60
|
-
onReorder,
|
|
61
|
-
maxDragAndDropLevel
|
|
62
|
-
} = _ref2;
|
|
63
|
-
const [activeId, setActiveId] = React.useState(null);
|
|
64
|
-
const [overId, setOverId] = React.useState(null);
|
|
65
|
-
const [dropIndicatorPosition, setDropIndicatorPosition] = React.useState(null);
|
|
66
|
-
const [lastPosition, setLastPosition] = React.useState(null); // Remove activeId's children
|
|
67
|
-
|
|
68
|
-
const visibleItems = React.useMemo(() => utilities.removeChildrenOf(preVisibleItems, activeId), [preVisibleItems, activeId]); // Sorted ids for the library
|
|
69
|
-
|
|
70
|
-
const sortedIds = React.useMemo(() => visibleItems.map(item => item.uid), [visibleItems]);
|
|
71
|
-
/**
|
|
72
|
-
* Dictionary from UID to ITEM
|
|
73
|
-
* This dictionary is computed since on every DnD move, I need to know the
|
|
74
|
-
* depth of a particular row, so O(1) per DnD move instead of O(#ITEMS)
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
const visibleItemsDictionary = React.useMemo(() => {
|
|
78
|
-
// Using plain for to achieve O(#ITEMS) performance
|
|
79
|
-
const dictionary = {};
|
|
80
|
-
visibleItems.forEach(item => {
|
|
81
|
-
dictionary[item.uid] = item;
|
|
82
|
-
});
|
|
83
|
-
return dictionary;
|
|
84
|
-
}, [visibleItems]);
|
|
85
|
-
const modifiers = React.useMemo(() => [options => adjustTranslate(options, isHorizontalDnD)], [isHorizontalDnD]);
|
|
86
|
-
const sensorContext = React.useRef({
|
|
87
|
-
items: visibleItems,
|
|
88
|
-
dropIndicatorPosition,
|
|
89
|
-
setDropIndicatorPosition
|
|
90
|
-
});
|
|
91
|
-
React.useEffect(() => {
|
|
92
|
-
sensorContext.current = {
|
|
93
|
-
items: visibleItems,
|
|
94
|
-
dropIndicatorPosition,
|
|
95
|
-
setDropIndicatorPosition
|
|
96
|
-
};
|
|
97
|
-
}, [visibleItems, dropIndicatorPosition, setDropIndicatorPosition]);
|
|
98
|
-
const coordinateGetter = React.useMemo(() => getTreeKeyboardCoordinates.getTreeKeyboardCoordinates(sensorContext, isHorizontalDnD, maxDragAndDropLevel), [sensorContext, isHorizontalDnD, maxDragAndDropLevel]);
|
|
99
|
-
const sensors = core.useSensors(core.useSensor(core.PointerSensor), core.useSensor(core.KeyboardSensor, {
|
|
100
|
-
coordinateGetter
|
|
101
|
-
})); // where is the activeItem being positioned (depth and parent)
|
|
102
|
-
|
|
103
|
-
const projected = React.useMemo(() => overId ? utilities.getProjection(visibleItems, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) : null, [overId, visibleItems, visibleItemsDictionary, dropIndicatorPosition, isExpandable]);
|
|
104
|
-
const dragPreviewHandlers = useTreePreviewHandlers.useTreePreviewHandlers({
|
|
105
|
-
setActiveId,
|
|
106
|
-
setOverId,
|
|
107
|
-
setDropIndicatorPosition
|
|
108
|
-
});
|
|
109
|
-
const dragActionHandlers = useTreeActionHandlers.useTreeActionHandlers(_objectSpread(_objectSpread({}, dragPreviewHandlers), {}, {
|
|
110
|
-
onReorder,
|
|
111
|
-
projected,
|
|
112
|
-
flattenedItems,
|
|
113
|
-
dropIndicatorPosition
|
|
114
|
-
}));
|
|
115
|
-
const announcements = useTreeAnnouncements.useTreeAnnouncements(visibleItemsDictionary, dropIndicatorPosition);
|
|
116
|
-
const dndContextProps = React.useMemo(() => _objectSpread({
|
|
117
|
-
announcements,
|
|
118
|
-
modifiers,
|
|
119
|
-
sensors,
|
|
120
|
-
layoutMeasuring,
|
|
121
|
-
collisionDetection: customCollisionDetection.customCollisionDetection(activeId, visibleItemsDictionary, setDropIndicatorPosition, maxDragAndDropLevel, lastPosition, setLastPosition)
|
|
122
|
-
}, dragActionHandlers), [announcements, modifiers, sensors, dragActionHandlers, visibleItemsDictionary, setDropIndicatorPosition, activeId, maxDragAndDropLevel, lastPosition, setLastPosition]);
|
|
123
|
-
const sortableContextProps = React.useMemo(() => ({
|
|
124
|
-
items: sortedIds,
|
|
125
|
-
strategy: isHorizontalDnD ? sortable.horizontalListSortingStrategy : sortable.verticalListSortingStrategy
|
|
126
|
-
}), [sortedIds, isHorizontalDnD]);
|
|
127
|
-
return {
|
|
128
|
-
dndContextProps,
|
|
129
|
-
sortableContextProps,
|
|
130
|
-
activeId,
|
|
131
|
-
activeIndex: (_visibleItemsDictiona = (_visibleItemsDictiona2 = visibleItemsDictionary[activeId]) === null || _visibleItemsDictiona2 === void 0 ? void 0 : _visibleItemsDictiona2.realIndex) !== null && _visibleItemsDictiona !== void 0 ? _visibleItemsDictiona : -1,
|
|
132
|
-
overId,
|
|
133
|
-
depth: projected ? projected.depth : 0,
|
|
134
|
-
dropIndicatorPosition,
|
|
135
|
-
visibleItems
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
module.exports = useTreeDndkitConfig;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var SortableItemContext = require('../../../parts/HoC/SortableItemContext.js');
|
|
7
|
-
|
|
8
|
-
const useTreePreviewHandlers = _ref => {
|
|
9
|
-
let {
|
|
10
|
-
setOverId,
|
|
11
|
-
setActiveId,
|
|
12
|
-
setDropIndicatorPosition
|
|
13
|
-
} = _ref;
|
|
14
|
-
const resetState = React.useCallback(() => {
|
|
15
|
-
setOverId(null);
|
|
16
|
-
setActiveId(null);
|
|
17
|
-
document.body.style.setProperty('cursor', '');
|
|
18
|
-
}, [setOverId, setActiveId]);
|
|
19
|
-
const handlePreviewDragStart = React.useCallback(_ref2 => {
|
|
20
|
-
let {
|
|
21
|
-
active: {
|
|
22
|
-
id
|
|
23
|
-
}
|
|
24
|
-
} = _ref2;
|
|
25
|
-
setActiveId(id);
|
|
26
|
-
setOverId(id);
|
|
27
|
-
setDropIndicatorPosition(SortableItemContext.DropIndicatorPosition.Inside);
|
|
28
|
-
document.body.style.setProperty('cursor', 'grabbing');
|
|
29
|
-
}, [setActiveId, setDropIndicatorPosition, setOverId]);
|
|
30
|
-
const handlePreviewDragMove = React.useCallback(() => null, []);
|
|
31
|
-
const handlePreviewDragOver = React.useCallback(_ref3 => {
|
|
32
|
-
var _over$id;
|
|
33
|
-
|
|
34
|
-
let {
|
|
35
|
-
over
|
|
36
|
-
} = _ref3;
|
|
37
|
-
setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : null);
|
|
38
|
-
}, [setOverId]);
|
|
39
|
-
const handlePreviewDragEnd = React.useCallback(() => {
|
|
40
|
-
resetState();
|
|
41
|
-
}, [resetState]);
|
|
42
|
-
const handlePreviewDragCancel = React.useCallback(() => {
|
|
43
|
-
resetState();
|
|
44
|
-
}, [resetState]);
|
|
45
|
-
return {
|
|
46
|
-
handlePreviewDragStart,
|
|
47
|
-
handlePreviewDragMove,
|
|
48
|
-
handlePreviewDragOver,
|
|
49
|
-
handlePreviewDragEnd,
|
|
50
|
-
handlePreviewDragCancel
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
exports.useTreePreviewHandlers = useTreePreviewHandlers;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
-
var SortableItemContext = require('../../parts/HoC/SortableItemContext.js');
|
|
9
|
-
|
|
10
|
-
const getMinDepth = item => {
|
|
11
|
-
if (item) return item.depth;
|
|
12
|
-
return 0;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const getProjection = (items, visibleItemsDictionary, overId, dropIndicatorPosition, isExpandable) => {
|
|
16
|
-
const overItemIndex = visibleItemsDictionary[overId].realIndex;
|
|
17
|
-
const previousItem = items[overItemIndex];
|
|
18
|
-
const nextItem = items[overItemIndex + 1];
|
|
19
|
-
|
|
20
|
-
if (dropIndicatorPosition === SortableItemContext.DropIndicatorPosition.Inside && isExpandable) {
|
|
21
|
-
return {
|
|
22
|
-
depth: visibleItemsDictionary[overId].depth + 1,
|
|
23
|
-
parentId: overId
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (dropIndicatorPosition === SortableItemContext.DropIndicatorPosition.Before) {
|
|
28
|
-
return {
|
|
29
|
-
depth: getMinDepth(previousItem),
|
|
30
|
-
parentId: previousItem.parentId
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
depth: getMinDepth(nextItem),
|
|
36
|
-
parentId: nextItem === null || nextItem === void 0 ? void 0 : nextItem.parentId
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
const removeChildrenOf = (items, id) => {
|
|
40
|
-
const excludeParentIds = [id];
|
|
41
|
-
return items.filter(item => {
|
|
42
|
-
if (item.parentId !== null && excludeParentIds.includes(item.parentId)) {
|
|
43
|
-
excludeParentIds.push(item.uid);
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return true;
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
exports.getProjection = getProjection;
|
|
52
|
-
exports.removeChildrenOf = removeChildrenOf;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
9
|
-
var React = require('react');
|
|
10
|
-
var dsPills = require('@elliemae/ds-pills');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
15
|
-
|
|
16
|
-
const TextPill = _ref => {
|
|
17
|
-
let {
|
|
18
|
-
columnHeader,
|
|
19
|
-
column,
|
|
20
|
-
value,
|
|
21
|
-
filters,
|
|
22
|
-
onFiltersChange,
|
|
23
|
-
prevRef,
|
|
24
|
-
innerRef,
|
|
25
|
-
nextRef
|
|
26
|
-
} = _ref;
|
|
27
|
-
const handleOnRemove = React.useCallback(() => {
|
|
28
|
-
if (prevRef !== null && prevRef !== void 0 && prevRef.current) prevRef.current.focus();else nextRef.current.focus();
|
|
29
|
-
onFiltersChange(filters.filter(filter => filter.id !== column));
|
|
30
|
-
}, [onFiltersChange, filters, prevRef, nextRef, column]);
|
|
31
|
-
return value ? /*#__PURE__*/_jsx__default["default"](dsPills.DSPillGroupV2, {}, void 0, /*#__PURE__*/_jsx__default["default"](dsPills.DSPillV2, {
|
|
32
|
-
type: "label",
|
|
33
|
-
label: columnHeader
|
|
34
|
-
}), /*#__PURE__*/_jsx__default["default"](dsPills.DSPillV2, {
|
|
35
|
-
type: "removable",
|
|
36
|
-
label: value,
|
|
37
|
-
onRemove: handleOnRemove,
|
|
38
|
-
innerRef: innerRef
|
|
39
|
-
})) : null;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.TextPill = TextPill;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
|
|
7
|
-
const DragOverlayContext = /*#__PURE__*/React.createContext({
|
|
8
|
-
setPureDraggedJSX: () => null
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
exports.DragOverlayContext = DragOverlayContext;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import 'react';
|
|
3
|
-
import { SearchXsmall } from '@elliemae/ds-icons';
|
|
4
|
-
import { FilterPopover } from '../../../../exported-related/FilterPopover.js';
|
|
5
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
6
|
-
import '../../../../styled.js';
|
|
7
|
-
import '../../../../DataTableContext.js';
|
|
8
|
-
import 'react/jsx-runtime';
|
|
9
|
-
import 'styled-components';
|
|
10
|
-
import '@elliemae/ds-button';
|
|
11
|
-
import '@elliemae/ds-utilities';
|
|
12
|
-
import '../../../../configs/constants.js';
|
|
13
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
14
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
15
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
16
|
-
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
17
|
-
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
18
|
-
import 'react-virtual';
|
|
19
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
20
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
21
|
-
import '../../../../configs/useRowFlattenization.js';
|
|
22
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
23
|
-
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
24
|
-
import 'core-js/modules/esnext.iterator.map.js';
|
|
25
|
-
import '@elliemae/ds-form';
|
|
26
|
-
import '../../../../parts/TableContent.js';
|
|
27
|
-
import '@elliemae/ds-grid';
|
|
28
|
-
import '@elliemae/ds-circular-progress-indicator';
|
|
29
|
-
import '@elliemae/ds-system';
|
|
30
|
-
import '../../../../parts/Row.js';
|
|
31
|
-
import '../../../../parts/Footer.js';
|
|
32
|
-
import '../../../../parts/HoC/SortableItemContext.js';
|
|
33
|
-
import 'uid';
|
|
34
|
-
import { FILTER_TYPES } from '../../../../exported-related/FilterTypes.js';
|
|
35
|
-
import '../../../../exported-related/Filters/applyOutOfTheBoxFilters.js';
|
|
36
|
-
import 'moment';
|
|
37
|
-
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
38
|
-
import 'core-js/modules/esnext.iterator.some.js';
|
|
39
|
-
|
|
40
|
-
var _SearchXsmall;
|
|
41
|
-
const TextInputFilter = props => {
|
|
42
|
-
const {
|
|
43
|
-
column,
|
|
44
|
-
filterValue = '',
|
|
45
|
-
reduxHeader,
|
|
46
|
-
onValueChange,
|
|
47
|
-
ctx: {
|
|
48
|
-
tableProps: {
|
|
49
|
-
data
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
innerRef
|
|
53
|
-
} = props;
|
|
54
|
-
const count = data.length;
|
|
55
|
-
|
|
56
|
-
const handleChange = event => {
|
|
57
|
-
var _event$target;
|
|
58
|
-
|
|
59
|
-
const newText = (event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value) || '';
|
|
60
|
-
onValueChange(FILTER_TYPES.TEXT, newText);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
return /*#__PURE__*/_jsx(FilterPopover, {
|
|
64
|
-
reduxHeader: reduxHeader,
|
|
65
|
-
column: column,
|
|
66
|
-
columnId: column.id,
|
|
67
|
-
menuContent:
|
|
68
|
-
/*#__PURE__*/
|
|
69
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
70
|
-
_jsx("input", {
|
|
71
|
-
value: filterValue,
|
|
72
|
-
onChange: handleChange,
|
|
73
|
-
placeholder: "Search ".concat(count, " records..."),
|
|
74
|
-
autoFocus: true
|
|
75
|
-
}),
|
|
76
|
-
triggerIcon: _SearchXsmall || (_SearchXsmall = /*#__PURE__*/_jsx(SearchXsmall, {})),
|
|
77
|
-
removeWrapperStyles: true,
|
|
78
|
-
innerRef: innerRef,
|
|
79
|
-
ariaLabel: "Open Text Input Filter",
|
|
80
|
-
"data-testid": "filter-popover"
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export { TextInputFilter };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
|
|
5
|
-
const textFilterFn = (unfilteredData, filterKey, filterValue) => {
|
|
6
|
-
if (filterValue.length < 3) return unfilteredData;
|
|
7
|
-
return unfilteredData.filter(datum => datum[filterKey].includes(filterValue));
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { textFilterFn };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
-
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
6
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
7
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
8
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
9
|
-
import { DATA_TESTID } from '../../../configs/constants.js';
|
|
10
|
-
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
11
|
-
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
12
|
-
import 'react';
|
|
13
|
-
import 'react-virtual';
|
|
14
|
-
import '../../../configs/useRowFlattenization.js';
|
|
15
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
16
|
-
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
17
|
-
import 'core-js/modules/esnext.iterator.map.js';
|
|
18
|
-
import '@babel/runtime/helpers/esm/jsx';
|
|
19
|
-
import '@elliemae/ds-icons';
|
|
20
|
-
import 'styled-components';
|
|
21
|
-
import '../../../styled.js';
|
|
22
|
-
import 'react/jsx-runtime';
|
|
23
|
-
import '@elliemae/ds-form';
|
|
24
|
-
import '../../../parts/TableContent.js';
|
|
25
|
-
import '@elliemae/ds-grid';
|
|
26
|
-
import '@elliemae/ds-circular-progress-indicator';
|
|
27
|
-
import '@elliemae/ds-system';
|
|
28
|
-
import '@elliemae/ds-button';
|
|
29
|
-
import '../../../DataTableContext.js';
|
|
30
|
-
import '../../../parts/Row.js';
|
|
31
|
-
import '../../../parts/Footer.js';
|
|
32
|
-
import '../../../parts/HoC/SortableItemContext.js';
|
|
33
|
-
|
|
34
|
-
const customCollisionDetection = (activeId, activeParent, dndItems) => (entries, target) => {
|
|
35
|
-
var _document$querySelect, _document$querySelect2;
|
|
36
|
-
|
|
37
|
-
const entriesWithSameParent = entries.filter(_ref => {
|
|
38
|
-
var _dndItems$find;
|
|
39
|
-
|
|
40
|
-
let [id] = _ref;
|
|
41
|
-
return ((_dndItems$find = dndItems.find(item => item.id === id)) === null || _dndItems$find === void 0 ? void 0 : _dndItems$find.parentId) === activeParent;
|
|
42
|
-
});
|
|
43
|
-
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 : {
|
|
44
|
-
width: 150
|
|
45
|
-
};
|
|
46
|
-
const originalRect = entriesWithSameParent.find(_ref2 => {
|
|
47
|
-
let [id] = _ref2;
|
|
48
|
-
return id === activeId;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
if (originalRect[1].offsetLeft <= target.offsetLeft && target.offsetLeft <= originalRect[1].offsetLeft + originalRect[1].width) {
|
|
52
|
-
return originalRect[0];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const isLeft = target.offsetLeft <= originalRect[1].offsetLeft + dragOverlayRect.width / 2 + 5;
|
|
56
|
-
let match = null; // If going to the left, search the closest offset left
|
|
57
|
-
// Otherwise, get the closest offset right
|
|
58
|
-
|
|
59
|
-
const collisionPoint = target.offsetLeft + dragOverlayRect.width / 2;
|
|
60
|
-
entriesWithSameParent.forEach(entry => {
|
|
61
|
-
const [, rect] = entry;
|
|
62
|
-
const offsetRight = rect.offsetLeft + rect.width;
|
|
63
|
-
if (!match) match = entry;else if (isLeft && Math.abs(collisionPoint - rect.offsetLeft) <= Math.abs(collisionPoint - match[1].offsetLeft)) {
|
|
64
|
-
match = entry;
|
|
65
|
-
} else if (!isLeft && Math.abs(collisionPoint - offsetRight) <= Math.abs(collisionPoint - match[1].offsetLeft - match[1].width)) {
|
|
66
|
-
match = entry;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
return match === null ? null : match[0];
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export { customCollisionDetection };
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
6
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
7
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
9
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
|
-
import { KeyboardCode, getViewRect, closestCorners } from '@dnd-kit/core';
|
|
11
|
-
import { DATA_TESTID } from '../../../configs/constants.js';
|
|
12
|
-
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
13
|
-
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
14
|
-
import 'react';
|
|
15
|
-
import 'react-virtual';
|
|
16
|
-
import '../../../configs/useRowFlattenization.js';
|
|
17
|
-
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
18
|
-
import 'core-js/modules/esnext.iterator.map.js';
|
|
19
|
-
import '@babel/runtime/helpers/esm/jsx';
|
|
20
|
-
import '@elliemae/ds-icons';
|
|
21
|
-
import 'styled-components';
|
|
22
|
-
import '../../../styled.js';
|
|
23
|
-
import 'react/jsx-runtime';
|
|
24
|
-
import '@elliemae/ds-form';
|
|
25
|
-
import '../../../parts/TableContent.js';
|
|
26
|
-
import '@elliemae/ds-grid';
|
|
27
|
-
import '@elliemae/ds-circular-progress-indicator';
|
|
28
|
-
import '@elliemae/ds-system';
|
|
29
|
-
import '@elliemae/ds-button';
|
|
30
|
-
import '../../../DataTableContext.js';
|
|
31
|
-
import '../../../parts/Row.js';
|
|
32
|
-
import '../../../parts/Footer.js';
|
|
33
|
-
import '../../../parts/HoC/SortableItemContext.js';
|
|
34
|
-
|
|
35
|
-
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; }
|
|
36
|
-
|
|
37
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
38
|
-
const directions = [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
|
|
39
|
-
const vertical = [KeyboardCode.Up, KeyboardCode.Down];
|
|
40
|
-
|
|
41
|
-
const getHorizontalKeyboardCoordinates = _ref => {
|
|
42
|
-
var _document$querySelect, _document$querySelect2;
|
|
43
|
-
|
|
44
|
-
let {
|
|
45
|
-
items,
|
|
46
|
-
active,
|
|
47
|
-
over,
|
|
48
|
-
event,
|
|
49
|
-
currentCoordinates,
|
|
50
|
-
droppableContainers,
|
|
51
|
-
translatedRect
|
|
52
|
-
} = _ref;
|
|
53
|
-
if (vertical.includes(event.code)) return undefined;
|
|
54
|
-
const activeItem = items.find(item => item.id === active);
|
|
55
|
-
const overRect = over.rect;
|
|
56
|
-
const layoutRects = []; // Get the reacheable rects depending on the arrow key pressed
|
|
57
|
-
|
|
58
|
-
Object.entries(droppableContainers).forEach(_ref2 => {
|
|
59
|
-
let [id, container] = _ref2;
|
|
60
|
-
|
|
61
|
-
if (container !== null && container !== void 0 && container.disabled || !overRect) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const node = container === null || container === void 0 ? void 0 : container.node.current;
|
|
66
|
-
|
|
67
|
-
if (!node) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const itemParent = items.find(item => item.id === id).parentId;
|
|
72
|
-
if (itemParent !== activeItem.parentId) return;
|
|
73
|
-
const rect = getViewRect(node);
|
|
74
|
-
|
|
75
|
-
if (event.code === KeyboardCode.Left && translatedRect.left > rect.right - 10) {
|
|
76
|
-
layoutRects.push([id, rect]);
|
|
77
|
-
} else if (event.code === KeyboardCode.Right && translatedRect.left < rect.left) {
|
|
78
|
-
layoutRects.push([id, rect]);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
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
|
-
width: 150,
|
|
83
|
-
left: 0
|
|
84
|
-
};
|
|
85
|
-
const closestId = closestCorners(layoutRects, translatedRect);
|
|
86
|
-
if (!closestId) return undefined;
|
|
87
|
-
const closestRect = getViewRect(droppableContainers[closestId].node.current);
|
|
88
|
-
const activeRect = getViewRect(droppableContainers[active].node.current);
|
|
89
|
-
return _objectSpread(_objectSpread({}, currentCoordinates), {}, {
|
|
90
|
-
x: closestRect.left + (closestRect.width - dragOverlayRect.width) / 2 + (closestRect.offsetLeft < activeRect.left ? -1 : 1)
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const getHierarchyKeyboardCoordinates = (context, isHorizontalDnD) => (event, _ref3) => {
|
|
95
|
-
let {
|
|
96
|
-
active,
|
|
97
|
-
currentCoordinates,
|
|
98
|
-
context: {
|
|
99
|
-
over,
|
|
100
|
-
translatedRect,
|
|
101
|
-
droppableContainers
|
|
102
|
-
}
|
|
103
|
-
} = _ref3;
|
|
104
|
-
|
|
105
|
-
if (directions.includes(event.code)) {
|
|
106
|
-
event.preventDefault();
|
|
107
|
-
|
|
108
|
-
if (!translatedRect) {
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const {
|
|
113
|
-
current: {
|
|
114
|
-
items
|
|
115
|
-
}
|
|
116
|
-
} = context;
|
|
117
|
-
const args = {
|
|
118
|
-
items,
|
|
119
|
-
active,
|
|
120
|
-
over,
|
|
121
|
-
event,
|
|
122
|
-
currentCoordinates,
|
|
123
|
-
droppableContainers,
|
|
124
|
-
translatedRect
|
|
125
|
-
};
|
|
126
|
-
if (isHorizontalDnD) return getHorizontalKeyboardCoordinates(args);
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return undefined;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export { getHierarchyKeyboardCoordinates };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
const useHierarchyActionHandlers = _ref => {
|
|
4
|
-
let {
|
|
5
|
-
handlePreviewDragStart,
|
|
6
|
-
handlePreviewDragMove,
|
|
7
|
-
handlePreviewDragOver,
|
|
8
|
-
handlePreviewDragEnd,
|
|
9
|
-
handlePreviewDragCancel,
|
|
10
|
-
onReorder,
|
|
11
|
-
dndItems
|
|
12
|
-
} = _ref;
|
|
13
|
-
const onDragStart = useCallback(e => {
|
|
14
|
-
handlePreviewDragStart(e);
|
|
15
|
-
}, [handlePreviewDragStart]);
|
|
16
|
-
const onDragMove = useCallback(e => {
|
|
17
|
-
handlePreviewDragMove(e);
|
|
18
|
-
}, [handlePreviewDragMove]);
|
|
19
|
-
const onDragOver = useCallback(e => {
|
|
20
|
-
handlePreviewDragOver(e);
|
|
21
|
-
}, [handlePreviewDragOver]);
|
|
22
|
-
const onDragEnd = useCallback(e => {
|
|
23
|
-
handlePreviewDragEnd(e);
|
|
24
|
-
const {
|
|
25
|
-
active,
|
|
26
|
-
over
|
|
27
|
-
} = e;
|
|
28
|
-
if (!over) return;
|
|
29
|
-
|
|
30
|
-
if (active.id !== over.id) {
|
|
31
|
-
const activeIndex = dndItems.findIndex(item => item.id === active.id);
|
|
32
|
-
const overIndex = dndItems.findIndex(item => item.id === over.id);
|
|
33
|
-
onReorder(dndItems[activeIndex], {
|
|
34
|
-
targetIndex: overIndex,
|
|
35
|
-
fromIndex: activeIndex
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}, [handlePreviewDragEnd, dndItems, onReorder]);
|
|
39
|
-
const onDragCancel = useCallback(e => {
|
|
40
|
-
handlePreviewDragCancel(e);
|
|
41
|
-
}, [handlePreviewDragCancel]);
|
|
42
|
-
return {
|
|
43
|
-
onDragStart,
|
|
44
|
-
onDragMove,
|
|
45
|
-
onDragOver,
|
|
46
|
-
onDragEnd,
|
|
47
|
-
onDragCancel
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export { useHierarchyActionHandlers };
|