@homebound/beam 2.333.1 → 2.334.0
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.
|
@@ -197,7 +197,8 @@ function GridTable(props) {
|
|
|
197
197
|
}
|
|
198
198
|
evt.preventDefault();
|
|
199
199
|
// set flags for css spacer
|
|
200
|
-
|
|
200
|
+
// don't set none for the row we are entering
|
|
201
|
+
recursiveSetDraggedOver(rows.filter((r) => r.id !== row.id), RowState_1.DraggedOver.None);
|
|
201
202
|
if (draggedRowRef.current) {
|
|
202
203
|
if (draggedRowRef.current.id === row.id) {
|
|
203
204
|
return;
|
|
@@ -213,7 +214,8 @@ function GridTable(props) {
|
|
|
213
214
|
}
|
|
214
215
|
evt.preventDefault();
|
|
215
216
|
if (draggedRowRef.current) {
|
|
216
|
-
if (draggedRowRef.current.id === row.id) {
|
|
217
|
+
if (draggedRowRef.current.id === row.id || !evt.currentTarget) {
|
|
218
|
+
tableState.maybeSetRowDraggedOver(row.id, RowState_1.DraggedOver.None, draggedRowRef.current);
|
|
217
219
|
return;
|
|
218
220
|
}
|
|
219
221
|
// continuously determine above or below
|
|
@@ -12,6 +12,7 @@ const TableState_1 = require("../utils/TableState");
|
|
|
12
12
|
const utils_1 = require("../utils/utils");
|
|
13
13
|
const Css_1 = require("../../../Css");
|
|
14
14
|
const utils_2 = require("../../../utils");
|
|
15
|
+
const use_debounce_1 = require("use-debounce");
|
|
15
16
|
// We extract Row to its own mini-component primarily so we can React.memo'ize it.
|
|
16
17
|
function RowImpl(props) {
|
|
17
18
|
var _a, _b, _c;
|
|
@@ -32,8 +33,12 @@ function RowImpl(props) {
|
|
|
32
33
|
const showRowHoverColor = !utils_1.reservedRowKinds.includes(row.kind) && !omitRowHover && style.rowHoverColor !== "none";
|
|
33
34
|
const rowStyleCellCss = (0, utils_1.maybeApplyFunction)(row, rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.cellCss);
|
|
34
35
|
const levelIndent = style.levels && ((_b = style.levels[level]) === null || _b === void 0 ? void 0 : _b.rowIndent);
|
|
36
|
+
const containerCss = {
|
|
37
|
+
...Css_1.Css.add("transition", "padding 0.25s ease-in-out").$,
|
|
38
|
+
...(rs.isDraggedOver === RowState_1.DraggedOver.Above && Css_1.Css.ptPx(25).$),
|
|
39
|
+
...(rs.isDraggedOver === RowState_1.DraggedOver.Below && Css_1.Css.pbPx(25).$),
|
|
40
|
+
};
|
|
35
41
|
const rowCss = {
|
|
36
|
-
...Css_1.Css.add("transition", "padding 0.5s ease-in-out").$,
|
|
37
42
|
...(!utils_1.reservedRowKinds.includes(row.kind) && style.nonHeaderRowCss),
|
|
38
43
|
// Optionally include the row hover styles, by default they should be turned on.
|
|
39
44
|
...(showRowHoverColor && {
|
|
@@ -56,8 +61,6 @@ function RowImpl(props) {
|
|
|
56
61
|
[`:hover > .${revealOnRowHoverClass} > *`]: Css_1.Css.visible.$,
|
|
57
62
|
},
|
|
58
63
|
...(isLastKeptRow && Css_1.Css.addIn("&>*", style.keptLastRowCss).$),
|
|
59
|
-
...(rs.isDraggedOver === RowState_1.DraggedOver.Above && Css_1.Css.add("paddingTop", "35px").$),
|
|
60
|
-
...(rs.isDraggedOver === RowState_1.DraggedOver.Below && Css_1.Css.add("paddingBottom", "35px").$),
|
|
61
64
|
};
|
|
62
65
|
let currentColspan = 1;
|
|
63
66
|
// Keep a running count of how many expanded columns are being shown.
|
|
@@ -67,10 +70,11 @@ function RowImpl(props) {
|
|
|
67
70
|
let expandColumnHidden = false;
|
|
68
71
|
// used to render the whole row when dragging with the handle
|
|
69
72
|
const ref = (0, react_1.useRef)(null);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
// debounce drag over callback to avoid excessive re-renders
|
|
74
|
+
const dragOverCallback = (0, react_1.useCallback)((row, evt) => onDragOver === null || onDragOver === void 0 ? void 0 : onDragOver(row, evt), [onDragOver]);
|
|
75
|
+
// when the event is not called, we still need to call preventDefault
|
|
76
|
+
const onDragOverDebounced = (0, use_debounce_1.useDebouncedCallback)(dragOverCallback, 100);
|
|
77
|
+
const RowContent = () => ((0, jsx_runtime_1.jsx)(RowTag, { css: rowCss, ...others, "data-gridrow": true, ...getCount(row.id), children: isKeptGroupRow ? ((0, jsx_runtime_1.jsx)(KeptGroupRow_1.KeptGroupRow, { as: as, style: style, columnSizes: columnSizes, row: row, colSpan: columns.length })) : (columns.map((column, columnIndex) => {
|
|
74
78
|
var _a, _b, _c, _d;
|
|
75
79
|
// If the expandable column was hidden, then we need to look at the previous column to format the `expandHeader` and 'header' kinds correctly.
|
|
76
80
|
const maybeExpandedColumn = expandColumnHidden ? columns[columnIndex - 1] : column;
|
|
@@ -126,7 +130,7 @@ function RowImpl(props) {
|
|
|
126
130
|
onDragEnd,
|
|
127
131
|
onDrop,
|
|
128
132
|
onDragEnter,
|
|
129
|
-
onDragOver,
|
|
133
|
+
onDragOver: onDragOverDebounced,
|
|
130
134
|
});
|
|
131
135
|
// Only use the `numExpandedColumns` as the `colspan` when rendering the "Expandable Header"
|
|
132
136
|
currentColspan =
|
|
@@ -229,6 +233,15 @@ function RowImpl(props) {
|
|
|
229
233
|
: (0, cell_1.defaultRenderFn)(as, currentColspan);
|
|
230
234
|
return renderFn(columnIndex, cellCss, content, row, rowStyle, cellClassNames, cellOnClick, tooltip);
|
|
231
235
|
})) }));
|
|
236
|
+
return row.draggable ? ((0, jsx_runtime_1.jsx)("div", { css: containerCss,
|
|
237
|
+
// these events are necessary to get the dragged-over row for the drop event
|
|
238
|
+
// and spacer styling
|
|
239
|
+
onDrop: (evt) => onDrop === null || onDrop === void 0 ? void 0 : onDrop(row, evt), onDragEnter: (evt) => onDragEnter === null || onDragEnter === void 0 ? void 0 : onDragEnter(row, evt), onDragOver: (evt) => {
|
|
240
|
+
// when the event isn't called due to debounce, we still need to
|
|
241
|
+
// call preventDefault for the drop event to fire
|
|
242
|
+
evt.preventDefault();
|
|
243
|
+
onDragOverDebounced(row, evt);
|
|
244
|
+
}, ref: ref, children: RowContent() })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: RowContent() }));
|
|
232
245
|
}
|
|
233
246
|
/**
|
|
234
247
|
* Memoizes rows so that re-rendering the table doesn't re-render every single row.
|
|
@@ -201,30 +201,21 @@ function dragHandleColumn(columnDef) {
|
|
|
201
201
|
id: "beamDragHandleColumn",
|
|
202
202
|
clientSideSort: false,
|
|
203
203
|
align: "center",
|
|
204
|
-
// Defining `w: 40px` to accommodate for the `16px` wide checkbox and `12px` of padding on either side.
|
|
205
204
|
w: "40px",
|
|
206
205
|
wrapAction: false,
|
|
207
206
|
isAction: true,
|
|
208
207
|
expandColumns: undefined,
|
|
209
|
-
// Select Column should not display the select toggle for `expandableHeader` or `totals` row kinds
|
|
210
208
|
expandableHeader: utils_1.emptyCell,
|
|
211
209
|
totals: utils_1.emptyCell,
|
|
212
210
|
// Use any of the user's per-row kind methods if they have them.
|
|
213
211
|
...columnDef,
|
|
214
212
|
};
|
|
215
|
-
// return newMethodMissingProxy(base, (key) => {
|
|
216
|
-
// return (data: any, { row, level }: { row: GridDataRow<any>; level: number }) => ({
|
|
217
|
-
// content: <CollapseToggle row={row} compact={level > 0} />,
|
|
218
|
-
// });
|
|
219
|
-
// }) as any;
|
|
220
213
|
return (0, utils_2.newMethodMissingProxy)(base, (key) => {
|
|
221
214
|
return (data, { row, dragData }) => {
|
|
222
215
|
if (!dragData)
|
|
223
216
|
return;
|
|
224
217
|
const { rowRenderRef: ref, onDragStart, onDragEnd, onDrop, onDragEnter, onDragOver } = dragData;
|
|
225
218
|
return {
|
|
226
|
-
// how do we get the callbacks and the ref here?
|
|
227
|
-
// inject them into the row in the Row component?
|
|
228
219
|
content: row.draggable ? ((0, jsx_runtime_1.jsx)("div", { draggable: row.draggable, onDragStart: (evt) => {
|
|
229
220
|
// show the whole row being dragged when dragging with the handle
|
|
230
221
|
ref.current && evt.dataTransfer.setDragImage(ref.current, 0, 0);
|
|
@@ -179,8 +179,8 @@ exports.insertAtIndex = insertAtIndex;
|
|
|
179
179
|
function isCursorBelowMidpoint(target, clientY) {
|
|
180
180
|
const style = window.getComputedStyle(target);
|
|
181
181
|
const rect = target.getBoundingClientRect();
|
|
182
|
-
const pt =
|
|
183
|
-
const pb =
|
|
182
|
+
const pt = parseFloat(style.getPropertyValue("padding-top"));
|
|
183
|
+
const pb = parseFloat(style.getPropertyValue("padding-bottom"));
|
|
184
184
|
return clientY > rect.top + pt + (rect.height - pb) / 2;
|
|
185
185
|
}
|
|
186
186
|
exports.isCursorBelowMidpoint = isCursorBelowMidpoint;
|