@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
|
@@ -37,6 +37,8 @@ import '../../../../exported-related/Filters/applyOutOfTheBoxFilters.js';
|
|
|
37
37
|
import 'moment';
|
|
38
38
|
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
39
39
|
import 'core-js/modules/esnext.iterator.some.js';
|
|
40
|
+
import '../../../../redux/reducers/headersReducers/headersReducers.js';
|
|
41
|
+
import { useDispatchHeadersActions } from '../../../../redux/reducers/headersReducers/useDispatchHeadersActions.js';
|
|
40
42
|
|
|
41
43
|
var _SearchXsmall;
|
|
42
44
|
|
|
@@ -85,13 +87,27 @@ const NumberRangeFilter = props => {
|
|
|
85
87
|
onValueChange(FILTER_TYPES.CURRENCY_RANGE, nextValue);
|
|
86
88
|
};
|
|
87
89
|
|
|
90
|
+
const {
|
|
91
|
+
patchHeader
|
|
92
|
+
} = useDispatchHeadersActions(); // workaround to close menu with esc key since DSInputMask has stoppropagation on key down
|
|
93
|
+
|
|
94
|
+
const closePopover = e => {
|
|
95
|
+
if (e.code === 'Escape') {
|
|
96
|
+
patchHeader(column.id, {
|
|
97
|
+
hideFilterMenu: true,
|
|
98
|
+
hideFilterButton: false
|
|
99
|
+
});
|
|
100
|
+
innerRef.current.focus();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
88
104
|
const idPreffix = 'datatable-number-range';
|
|
89
105
|
return /*#__PURE__*/_jsx(FilterPopover, {
|
|
90
106
|
reduxHeader: reduxHeader,
|
|
91
107
|
column: column,
|
|
92
108
|
columnId: column.id,
|
|
93
109
|
menuContent: /*#__PURE__*/_jsx(Grid, {
|
|
94
|
-
"data-testid": DATA_TESTID.
|
|
110
|
+
"data-testid": DATA_TESTID.DATA_TABLE_NUMBER_RANGE_CONTROLLER,
|
|
95
111
|
gutter: "xxxs",
|
|
96
112
|
padding: "xxs",
|
|
97
113
|
cols: ['auto', 'auto']
|
|
@@ -109,7 +125,10 @@ const NumberRangeFilter = props => {
|
|
|
109
125
|
onChange: handleFromChange,
|
|
110
126
|
placeholder: "0",
|
|
111
127
|
mask: number => MASK_TYPES.NUMBER(opts)(number),
|
|
112
|
-
autoFocus: true
|
|
128
|
+
autoFocus: true,
|
|
129
|
+
onKeyDown: e => {
|
|
130
|
+
closePopover(e);
|
|
131
|
+
}
|
|
113
132
|
})), /*#__PURE__*/_jsx(DSFormLayoutBlockItem, {
|
|
114
133
|
label: "High",
|
|
115
134
|
inputID: "".concat(idPreffix, "-high-").concat(column.id)
|
|
@@ -123,7 +142,10 @@ const NumberRangeFilter = props => {
|
|
|
123
142
|
value: "".concat((_filterValue$to = filterValue === null || filterValue === void 0 ? void 0 : filterValue.to) !== null && _filterValue$to !== void 0 ? _filterValue$to : ''),
|
|
124
143
|
onChange: handleToChange,
|
|
125
144
|
placeholder: "0",
|
|
126
|
-
mask: number => MASK_TYPES.NUMBER(opts)(number)
|
|
145
|
+
mask: number => MASK_TYPES.NUMBER(opts)(number),
|
|
146
|
+
onKeyDown: e => {
|
|
147
|
+
closePopover(e);
|
|
148
|
+
}
|
|
127
149
|
}))),
|
|
128
150
|
triggerIcon: _SearchXsmall || (_SearchXsmall = /*#__PURE__*/_jsx(SearchXsmall, {})),
|
|
129
151
|
customStyles: {
|
|
@@ -70,7 +70,10 @@ const SingleDateFilter = props => {
|
|
|
70
70
|
"data-testid": DATA_TESTID.DATA_TABLE_SINGLE_DATE_CONTROLLER,
|
|
71
71
|
width: "260px"
|
|
72
72
|
}, void 0, /*#__PURE__*/_jsx(Grid, {
|
|
73
|
-
p: "xxs"
|
|
73
|
+
p: "xxs",
|
|
74
|
+
style: {
|
|
75
|
+
background: 'white'
|
|
76
|
+
}
|
|
74
77
|
}, void 0, /*#__PURE__*/_jsx(DSControlledDateTimePicker, {
|
|
75
78
|
date: date,
|
|
76
79
|
onDateChange: setDate,
|
|
@@ -5,4 +5,3 @@ export { CurrencyRangeFilter } from './CurrencyRangeFilter/index.js';
|
|
|
5
5
|
export { SingleSelectFilter } from './SelectFilter/SingleSelectFilter.js';
|
|
6
6
|
export { MultiSelectFilter } from './SelectFilter/MultiSelectFilter.js';
|
|
7
7
|
export { SingleDateFilter } from './SingleDateFilter/index.js';
|
|
8
|
-
export { TextInputFilter } from './TextInputFilter/index.js';
|
|
@@ -5,4 +5,3 @@ export { CurrencyRangeFilter } from './Components/CurrencyRangeFilter/index.js';
|
|
|
5
5
|
export { SingleSelectFilter } from './Components/SelectFilter/SingleSelectFilter.js';
|
|
6
6
|
export { MultiSelectFilter } from './Components/SelectFilter/MultiSelectFilter.js';
|
|
7
7
|
export { SingleDateFilter } from './Components/SingleDateFilter/index.js';
|
|
8
|
-
export { TextInputFilter } from './Components/TextInputFilter/index.js';
|
|
@@ -20,7 +20,7 @@ const usePaginationConfig = (props, flattenedData) => {
|
|
|
20
20
|
onPreviousPage = emptyFunc,
|
|
21
21
|
onNextPage = emptyFunc,
|
|
22
22
|
onPageChange = emptyFunc,
|
|
23
|
-
pageCount = Math.
|
|
23
|
+
pageCount = Math.ceil(flattenedData.length / pageSize),
|
|
24
24
|
perPageStep = 5,
|
|
25
25
|
minPerPage = 0,
|
|
26
26
|
maxPerPage = 100,
|
|
@@ -21,7 +21,7 @@ const flatten = function (data, expandedRows, uniqueRowAccessor) {
|
|
|
21
21
|
const id = (parentId ? "".concat(parentId, ".") : '') + index.toString();
|
|
22
22
|
const uid = getIdFromUniqueRowAccessor(uniqueRowAccessor, {
|
|
23
23
|
id,
|
|
24
|
-
original: row
|
|
24
|
+
original: row !== null && row !== void 0 ? row : {}
|
|
25
25
|
});
|
|
26
26
|
const isExpanded = expandedRows[uid];
|
|
27
27
|
const rowToPush = {
|
|
@@ -33,11 +33,11 @@ const flatten = function (data, expandedRows, uniqueRowAccessor) {
|
|
|
33
33
|
parentIndex,
|
|
34
34
|
depth,
|
|
35
35
|
isExpanded,
|
|
36
|
-
original: row
|
|
36
|
+
original: row !== null && row !== void 0 ? row : {}
|
|
37
37
|
};
|
|
38
38
|
result.push(rowToPush); // If we have subrows and we are expanded
|
|
39
39
|
|
|
40
|
-
if (row.subRows && expandedRows[uid] && depth <= maxDepth) {
|
|
40
|
+
if (row !== null && row !== void 0 && row.subRows && expandedRows[uid] && depth <= maxDepth) {
|
|
41
41
|
row.subRows.forEach((subRow, i) => doit(subRow, i, uid, rowToPush.realIndex, depth + 1));
|
|
42
42
|
}
|
|
43
43
|
};
|
|
@@ -11,7 +11,8 @@ const EditableCell = props => {
|
|
|
11
11
|
StandardRender,
|
|
12
12
|
EditableRenderer,
|
|
13
13
|
cell,
|
|
14
|
-
isRowSelected
|
|
14
|
+
isRowSelected,
|
|
15
|
+
setValue
|
|
15
16
|
} = props;
|
|
16
17
|
const {
|
|
17
18
|
virtualListHelpers
|
|
@@ -33,20 +34,25 @@ const EditableCell = props => {
|
|
|
33
34
|
}
|
|
34
35
|
}, [isEditing]);
|
|
35
36
|
const handleOnKeyDown = useCallback(e => {
|
|
36
|
-
if (isEditing)
|
|
37
|
+
if (isEditing) {
|
|
38
|
+
e.stopPropagation();
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
if (['Enter', 'Escape'].includes(e.code)) {
|
|
41
|
+
setIsEditing(false);
|
|
42
|
+
}
|
|
43
|
+
} else if (['Enter', 'Space'].includes(e.code)) {
|
|
39
44
|
handleCellClick(e);
|
|
40
45
|
}
|
|
41
|
-
}, [isEditing, handleCellClick]);
|
|
46
|
+
}, [isEditing, handleCellClick, setIsEditing]);
|
|
42
47
|
const handleOnBlur = useCallback(event => {
|
|
43
48
|
if (isEditing && !event.currentTarget.contains(event.relatedTarget)) {
|
|
44
49
|
// Not triggered when swapping focus between children
|
|
45
50
|
setIsEditing(false);
|
|
46
51
|
}
|
|
47
52
|
}, [isEditing]);
|
|
53
|
+
const cols = !isEditing ? ['auto', 'min-content'] : ['auto'];
|
|
48
54
|
return /*#__PURE__*/jsxs(StyledEditableContainer, {
|
|
49
|
-
cols:
|
|
55
|
+
cols: cols,
|
|
50
56
|
tabIndex: isRowSelected && !isEditing ? 0 : -1,
|
|
51
57
|
ref: cell.ref,
|
|
52
58
|
onClick: handleCellClick,
|
|
@@ -54,14 +60,14 @@ const EditableCell = props => {
|
|
|
54
60
|
onBlur: handleOnBlur,
|
|
55
61
|
shouldDisplayEditIcon: cell.column.alwaysDisplayEditIcon,
|
|
56
62
|
role: "cell",
|
|
57
|
-
"aria-
|
|
63
|
+
"aria-labelledby": isEditing ? undefined : cell.id,
|
|
58
64
|
children: [!isEditing ? StandardRender : EditableRenderer, !isEditing && (_StyledPencilIcon || (_StyledPencilIcon = /*#__PURE__*/_jsx(StyledPencilIcon, {}))), /*#__PURE__*/_jsx("span", {
|
|
59
65
|
id: cell.id,
|
|
60
66
|
style: {
|
|
61
67
|
display: 'none'
|
|
62
68
|
},
|
|
63
69
|
"aria-hidden": "true"
|
|
64
|
-
}, void 0, "
|
|
70
|
+
}, void 0, cell.value, ", editable cell. To edit the content's of this cell, press the Enter key")]
|
|
65
71
|
});
|
|
66
72
|
};
|
|
67
73
|
|
|
@@ -41,6 +41,9 @@ const FilterButton = /*#__PURE__*/styled.span.withConfig({
|
|
|
41
41
|
const Button = /*#__PURE__*/styled(DSButton).withConfig({
|
|
42
42
|
componentId: "sc-16i88ut-1"
|
|
43
43
|
})(["position:relative;justify-self:flex-end;"]);
|
|
44
|
+
const PopperContent = /*#__PURE__*/styled.div.withConfig({
|
|
45
|
+
componentId: "sc-16i88ut-2"
|
|
46
|
+
})(["background-color:'#fff';"]);
|
|
44
47
|
const FilterPopover = _ref2 => {
|
|
45
48
|
var _column$ref$current$o, _column$ref, _column$ref$current;
|
|
46
49
|
|
|
@@ -141,9 +144,20 @@ const FilterPopover = _ref2 => {
|
|
|
141
144
|
minWidth: (_column$ref$current$o = (_column$ref = column.ref) === null || _column$ref === void 0 ? void 0 : (_column$ref$current = _column$ref.current) === null || _column$ref$current === void 0 ? void 0 : _column$ref$current.offsetWidth) !== null && _column$ref$current$o !== void 0 ? _column$ref$current$o : '0px'
|
|
142
145
|
}),
|
|
143
146
|
placementOrderPreference: ['bottom-end']
|
|
144
|
-
}, void 0, /*#__PURE__*/jsx(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
}, void 0, /*#__PURE__*/jsx(PopperContent, {
|
|
148
|
+
onKeyDown: e => {
|
|
149
|
+
if (e.code === 'Tab') {
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
var _popperRef$current;
|
|
152
|
+
|
|
153
|
+
if (!(popperRef !== null && popperRef !== void 0 && (_popperRef$current = popperRef.current) !== null && _popperRef$current !== void 0 && _popperRef$current.contains(document.activeElement))) {
|
|
154
|
+
patchHeader(columnId, {
|
|
155
|
+
hideFilterMenu: true,
|
|
156
|
+
hideFilterButton: false
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
147
161
|
},
|
|
148
162
|
ref: popperRef,
|
|
149
163
|
children: menuContent
|
|
@@ -3,7 +3,6 @@ import 'core-js/modules/esnext.iterator.constructor.js';
|
|
|
3
3
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
4
|
import { singleSelectFilterFn } from './singleSelectFilterFn.js';
|
|
5
5
|
import { multiSelectFilterFn } from './multiSelectFilterFn.js';
|
|
6
|
-
import { textFilterFn } from './textFilterFn.js';
|
|
7
6
|
import { singleDateFilterFn } from './singleDateFilterFn.js';
|
|
8
7
|
import { dateRangeFilterFn } from './dateRangeFilterFn.js';
|
|
9
8
|
import { dateSwitcherFilterFn } from './dateSwitcherFilterFn.js';
|
|
@@ -15,7 +14,6 @@ import { FILTER_TYPES } from '../FilterTypes.js';
|
|
|
15
14
|
const filterMapper = {
|
|
16
15
|
[FILTER_TYPES.SELECT]: singleSelectFilterFn,
|
|
17
16
|
[FILTER_TYPES.MULTI_SELECT]: multiSelectFilterFn,
|
|
18
|
-
[FILTER_TYPES.TEXT]: textFilterFn,
|
|
19
17
|
[FILTER_TYPES.SINGLE_DATE]: singleDateFilterFn,
|
|
20
18
|
[FILTER_TYPES.DATE_RANGE]: dateRangeFilterFn,
|
|
21
19
|
[FILTER_TYPES.DATE_SWITCHER]: dateSwitcherFilterFn,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { applyOutOfTheBoxFilters } from './applyOutOfTheBoxFilters.js';
|
|
2
|
-
export { textFilterFn } from './textFilterFn.js';
|
|
3
2
|
export { singleDateFilterFn } from './singleDateFilterFn.js';
|
|
4
3
|
export { singleSelectFilterFn } from './singleSelectFilterFn.js';
|
|
5
4
|
export { multiSelectFilterFn } from './multiSelectFilterFn.js';
|
|
@@ -5,7 +5,6 @@ export { groupBy } from './groupBy.js';
|
|
|
5
5
|
export { FILTER_TYPES } from './FilterTypes.js';
|
|
6
6
|
export { ROW_VARIANTS, ROW_VARIANT_COMPACT_KEY, ROW_VARIANT_KEY } from './RowVariants.js';
|
|
7
7
|
export { applyOutOfTheBoxFilters } from './Filters/applyOutOfTheBoxFilters.js';
|
|
8
|
-
export { textFilterFn } from './Filters/textFilterFn.js';
|
|
9
8
|
export { singleDateFilterFn } from './Filters/singleDateFilterFn.js';
|
|
10
9
|
export { singleSelectFilterFn } from './Filters/singleSelectFilterFn.js';
|
|
11
10
|
export { multiSelectFilterFn } from './Filters/multiSelectFilterFn.js';
|
|
@@ -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]);
|
|
@@ -37,7 +37,9 @@ const useHeaderCellHandlers = _ref => {
|
|
|
37
37
|
patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD));
|
|
38
38
|
}, [column.id, hasDnD, hasFilter, patchHeader, reduxHeader]);
|
|
39
39
|
const onMouseLeave = useCallback(() => {
|
|
40
|
-
|
|
40
|
+
var _headerRef$current;
|
|
41
|
+
|
|
42
|
+
if (!(headerRef !== null && headerRef !== void 0 && (_headerRef$current = headerRef.current) !== null && _headerRef$current !== void 0 && _headerRef$current.contains(document.activeElement))) {
|
|
41
43
|
patchHeader(column.id, buildNextHeader(reduxHeader, false, hasFilter, hasDnD));
|
|
42
44
|
}
|
|
43
45
|
}, [column.id, hasDnD, hasFilter, headerRef, patchHeader, reduxHeader]);
|
|
@@ -72,7 +74,7 @@ const useHeaderCellHandlers = _ref => {
|
|
|
72
74
|
}, [column.canSort, column.id, onColumnSortChange, patchHeader, reduxHeader, hasFilter, hasDnD, dragHandleRef, filterIconRef]);
|
|
73
75
|
const onFocus = useCallback(e => {
|
|
74
76
|
// Don't do anything if focus wasn't placed in the element (bubling issues)
|
|
75
|
-
if (e.target === headerRef.current) {
|
|
77
|
+
if (e.target === (headerRef === null || headerRef === void 0 ? void 0 : headerRef.current)) {
|
|
76
78
|
patchHeader(column.id, buildNextHeader(reduxHeader, true, hasFilter, hasDnD));
|
|
77
79
|
}
|
|
78
80
|
}, [column.id, hasDnD, hasFilter, headerRef, patchHeader, reduxHeader]);
|
|
@@ -1,17 +1,20 @@
|
|
|
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';
|
|
13
|
+
import { useHierarchyDndkitConfig } from '@elliemae/ds-drag-and-drop';
|
|
11
14
|
import { arrayMove } from '@dnd-kit/sortable';
|
|
12
|
-
import { DragOverlayContext } from './DragOverlayContext.js';
|
|
13
|
-
import useHierarchyDndkitConfig from '../../helpers/dndkit/hierarchy/useHierarchyDndkitConfig.js';
|
|
14
15
|
import DataTableContext from '../../DataTableContext.js';
|
|
16
|
+
import { HeaderCellGroup } from '../Headers/HeaderCellGroup.js';
|
|
17
|
+
import { DATA_TESTID } from '../../configs/constants.js';
|
|
15
18
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
16
19
|
|
|
17
20
|
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 +29,9 @@ const flattenColumns = cols => {
|
|
|
26
29
|
|
|
27
30
|
const flatten = function (col, index) {
|
|
28
31
|
let parentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
29
|
-
const
|
|
32
|
+
const {
|
|
33
|
+
id
|
|
34
|
+
} = col;
|
|
30
35
|
flattened.push([{
|
|
31
36
|
id,
|
|
32
37
|
parentId,
|
|
@@ -44,13 +49,11 @@ const withConditionalDnDColumnContext = Component => props => {
|
|
|
44
49
|
const {
|
|
45
50
|
tableProps: {
|
|
46
51
|
dragAndDropColumns,
|
|
47
|
-
columns,
|
|
48
52
|
onColumnsReorder
|
|
49
|
-
}
|
|
53
|
+
},
|
|
54
|
+
visibleColumns
|
|
50
55
|
} = React.useContext(DataTableContext);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const flattenedItems = useMemo(() => flattenColumns(columns), [columns]);
|
|
56
|
+
const flattenedItems = useMemo(() => flattenColumns(visibleColumns), [visibleColumns]);
|
|
54
57
|
const onReorder = useCallback((movedItem, indexes) => {
|
|
55
58
|
// Send from index to target index
|
|
56
59
|
const newFlattenedData = arrayMove(flattenedItems, indexes.fromIndex, indexes.targetIndex); // Pull the cols's data into an object
|
|
@@ -74,25 +77,43 @@ const withConditionalDnDColumnContext = Component => props => {
|
|
|
74
77
|
});
|
|
75
78
|
onColumnsReorder(newData, indexes);
|
|
76
79
|
}, [flattenedItems, onColumnsReorder]);
|
|
80
|
+
const onPreviewResetState = useCallback(() => {
|
|
81
|
+
const el = document.body.querySelector("[data-testid=\"".concat(DATA_TESTID.DATA_TABLE_SCROLLABLE_CONTAINER, "\"]"));
|
|
82
|
+
if (el) el.onscroll = () => null;
|
|
83
|
+
}, []);
|
|
84
|
+
const onPreviewDragStart = useCallback(() => {
|
|
85
|
+
const el = document.body.querySelector("[data-testid=\"".concat(DATA_TESTID.DATA_TABLE_SCROLLABLE_CONTAINER, "\"]"));
|
|
86
|
+
|
|
87
|
+
if (el) {
|
|
88
|
+
const y = el.scrollTop;
|
|
89
|
+
|
|
90
|
+
el.onscroll = () => el.scrollTo(0, y);
|
|
91
|
+
}
|
|
92
|
+
}, []);
|
|
77
93
|
const {
|
|
78
94
|
dndContextProps,
|
|
79
95
|
activeId,
|
|
80
96
|
activeIndex
|
|
81
97
|
} = useHierarchyDndkitConfig({
|
|
82
98
|
flattenedItems,
|
|
99
|
+
dragOverlayDataTestid: DATA_TESTID.DATA_TABLE_COLUMN_DRAG_OVERLAY,
|
|
83
100
|
isHorizontalDnD: true,
|
|
84
|
-
onReorder
|
|
101
|
+
onReorder,
|
|
102
|
+
onPreviewResetState,
|
|
103
|
+
onPreviewDragStart
|
|
85
104
|
});
|
|
86
105
|
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, {
|
|
106
|
+
children: [/*#__PURE__*/_jsx(DnDGroupContext.Provider, {
|
|
92
107
|
value: {
|
|
93
108
|
activeIndex
|
|
94
109
|
}
|
|
95
|
-
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)))
|
|
110
|
+
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props))), /*#__PURE__*/_jsx(DragOverlay, {}, void 0, activeId ? /*#__PURE__*/_jsx(HeaderCellGroup, {
|
|
111
|
+
header: flattenedItems.find(_ref3 => {
|
|
112
|
+
let [item] = _ref3;
|
|
113
|
+
return item.id === activeId;
|
|
114
|
+
})[1],
|
|
115
|
+
isDragOverlay: true
|
|
116
|
+
}) : null)]
|
|
96
117
|
}));
|
|
97
118
|
return /*#__PURE__*/jsx(Component, _objectSpread({}, props));
|
|
98
119
|
};
|
|
@@ -1,18 +1,20 @@
|
|
|
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/web.dom-collections.iterator.js';
|
|
4
6
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
7
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
8
|
import 'core-js/modules/esnext.iterator.for-each.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, { createContext, useCallback } from 'react';
|
|
10
12
|
import { DndContext, DragOverlay } from '@dnd-kit/core';
|
|
11
13
|
import { SortableContext } from '@dnd-kit/sortable';
|
|
12
14
|
import DataTableContext from '../../DataTableContext.js';
|
|
13
|
-
import useTreeDndkitConfig from '
|
|
14
|
-
import { DragOverlayContext } from './DragOverlayContext.js';
|
|
15
|
+
import { useTreeDndkitConfig } from '@elliemae/ds-drag-and-drop';
|
|
15
16
|
import { DropIndicatorPosition } from './SortableItemContext.js';
|
|
17
|
+
import { Row } from '../Row.js';
|
|
16
18
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
17
19
|
|
|
18
20
|
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; }
|
|
@@ -38,8 +40,6 @@ const withConditionalDnDRowContext = Component => props => {
|
|
|
38
40
|
flattenedData,
|
|
39
41
|
allDataFlattened
|
|
40
42
|
} = React.useContext(DataTableContext);
|
|
41
|
-
const [PureDraggedJSX, setPureDraggedJSX] = React.useState(null); // todo: check if this can be done via portal
|
|
42
|
-
|
|
43
43
|
const [lastActiveId, setLastActiveId] = React.useState(null);
|
|
44
44
|
const onReorder = useCallback((newData, indexes, considerExpanding) => {
|
|
45
45
|
// Pull the row's original data into an object
|
|
@@ -79,11 +79,7 @@ const withConditionalDnDRowContext = Component => props => {
|
|
|
79
79
|
if (lastActiveId !== activeId && activeId) setLastActiveId(activeId);
|
|
80
80
|
if (dragAndDropRows) return /*#__PURE__*/jsxs(DndContext, _objectSpread(_objectSpread({}, dndContextProps), {}, {
|
|
81
81
|
children: [/*#__PURE__*/jsx(SortableContext, _objectSpread(_objectSpread({}, sortableContextProps), {}, {
|
|
82
|
-
children: /*#__PURE__*/_jsx(
|
|
83
|
-
value: {
|
|
84
|
-
setPureDraggedJSX
|
|
85
|
-
}
|
|
86
|
-
}, void 0, /*#__PURE__*/_jsx(DnDTreeContext.Provider, {
|
|
82
|
+
children: /*#__PURE__*/_jsx(DnDTreeContext.Provider, {
|
|
87
83
|
value: {
|
|
88
84
|
activeIndex,
|
|
89
85
|
depth,
|
|
@@ -92,12 +88,15 @@ const withConditionalDnDRowContext = Component => props => {
|
|
|
92
88
|
lastActiveId,
|
|
93
89
|
setLastActiveId
|
|
94
90
|
}
|
|
95
|
-
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)))
|
|
91
|
+
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)))
|
|
96
92
|
})), /*#__PURE__*/_jsx(DragOverlay, {
|
|
97
93
|
style: {
|
|
98
94
|
width: 'auto'
|
|
99
95
|
}
|
|
100
|
-
}, void 0, activeId ?
|
|
96
|
+
}, void 0, activeId ? /*#__PURE__*/_jsx(Row, {
|
|
97
|
+
row: flattenedData.find(row => row.uid === activeId),
|
|
98
|
+
isDragOverlay: true
|
|
99
|
+
}) : null)]
|
|
101
100
|
}));
|
|
102
101
|
return /*#__PURE__*/jsx(Component, _objectSpread({}, props));
|
|
103
102
|
};
|
|
@@ -26,7 +26,7 @@ const withConditionalDnDSortableContext = function (items) {
|
|
|
26
26
|
// It's important that drag overlays DO NOT have any sortable functionality!
|
|
27
27
|
|
|
28
28
|
if (!isDragOverlay && dragAndDropColumns) return /*#__PURE__*/_jsx(SortableContext, {
|
|
29
|
-
items: items.map(item => item.
|
|
29
|
+
items: items.map(item => item.id),
|
|
30
30
|
strategy: horizontalListSortingStrategy
|
|
31
31
|
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)));
|
|
32
32
|
return /*#__PURE__*/jsx(Component, _objectSpread({}, props));
|
|
@@ -5,10 +5,9 @@ import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
-
import { useContext, useMemo
|
|
8
|
+
import { useContext, useMemo } from 'react';
|
|
9
9
|
import { useSortable } from '@dnd-kit/sortable';
|
|
10
10
|
import DataTableContext from '../../DataTableContext.js';
|
|
11
|
-
import { DragOverlayContext } from './DragOverlayContext.js';
|
|
12
11
|
import { DnDGroupContext } from './withConditionalDnDColumnContext.js';
|
|
13
12
|
import { DropIndicatorPosition, SortableItemContext } from './SortableItemContext.js';
|
|
14
13
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -22,18 +21,14 @@ const withDnDSortableColumnContext = Component => props => {
|
|
|
22
21
|
dragAndDropColumns
|
|
23
22
|
}
|
|
24
23
|
} = useContext(DataTableContext);
|
|
25
|
-
const {
|
|
26
|
-
setPureDraggedJSX
|
|
27
|
-
} = useContext(DragOverlayContext);
|
|
28
24
|
const {
|
|
29
25
|
activeIndex
|
|
30
26
|
} = useContext(DnDGroupContext); // onMount generate unique options, so everyting is only ran once
|
|
31
27
|
|
|
32
28
|
const draggableOptions = useMemo(() => ({
|
|
33
|
-
id: props.header.
|
|
34
|
-
}), [props.header.
|
|
35
|
-
const useSortableHelpers = useSortable(draggableOptions);
|
|
36
|
-
const PureComponentJSX = useMemo(() => /*#__PURE__*/jsx(Component, _objectSpread({}, props)), [props]); // calculate all the "useSortable" values as per required
|
|
29
|
+
id: props.header.id
|
|
30
|
+
}), [props.header.id]);
|
|
31
|
+
const useSortableHelpers = useSortable(draggableOptions); // calculate all the "useSortable" values as per required
|
|
37
32
|
|
|
38
33
|
const draggableProps = useMemo(() => {
|
|
39
34
|
if (!dragAndDropColumns) return false;
|
|
@@ -45,16 +40,7 @@ const withDnDSortableColumnContext = Component => props => {
|
|
|
45
40
|
shouldShowDropIndicatorPosition: overIndex === index && overIndex !== -1,
|
|
46
41
|
dropIndicatorPosition: index > activeIndex ? DropIndicatorPosition.After : DropIndicatorPosition.Before
|
|
47
42
|
});
|
|
48
|
-
}, [useSortableHelpers, dragAndDropColumns, activeIndex]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
// We assume the structure of the inner element WON'T change during DnD
|
|
51
|
-
// This is a huge performance boost
|
|
52
|
-
if (useSortableHelpers.isDragging) {
|
|
53
|
-
setPureDraggedJSX( /*#__PURE__*/cloneElement(PureComponentJSX, {
|
|
54
|
-
isDragOverlay: true
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
}, [useSortableHelpers.isDragging, setPureDraggedJSX]); // we use a context so we can easly access information wherever without bubbling down
|
|
43
|
+
}, [useSortableHelpers, dragAndDropColumns, activeIndex]); // we use a context so we can easly access information wherever without bubbling down
|
|
58
44
|
// this context is all Memoized so as long as component is not re-mounted,
|
|
59
45
|
// the context won't trigger un-required renders per-se...
|
|
60
46
|
|
|
@@ -64,7 +50,7 @@ const withDnDSortableColumnContext = Component => props => {
|
|
|
64
50
|
|
|
65
51
|
return /*#__PURE__*/_jsx(SortableItemContext.Provider, {
|
|
66
52
|
value: ctx
|
|
67
|
-
}, void 0,
|
|
53
|
+
}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)));
|
|
68
54
|
};
|
|
69
55
|
|
|
70
56
|
export { withDnDSortableColumnContext };
|