@atlaskit/editor-plugin-table 5.3.8 → 5.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/commands.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +3 -2
- package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +6 -1
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +6 -4
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +9 -19
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +70 -0
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +12 -77
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +45 -20
- package/dist/cjs/plugins/table/ui/icons/index.js +19 -0
- package/dist/cjs/plugins/table/ui/ui-styles.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/commands.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +3 -2
- package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +6 -1
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +5 -3
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +7 -15
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +62 -0
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +8 -74
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +45 -19
- package/dist/es2019/plugins/table/ui/icons/index.js +2 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +0 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +2 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/commands.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +3 -2
- package/dist/esm/plugins/table/pm-plugins/drag-and-drop/utils/monitor.js +6 -1
- package/dist/esm/plugins/table/ui/DragHandle/index.js +5 -3
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +8 -16
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +61 -0
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +9 -72
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +45 -20
- package/dist/esm/plugins/table/ui/icons/index.js +2 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +1 -1
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +9 -0
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -3
- package/dist/types/plugins/table/ui/TableFloatingColumnControls/index.d.ts +2 -0
- package/dist/types/plugins/table/ui/icons/index.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -3
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingColumnControls/index.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +2 -0
- package/package.json +2 -1
- package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +58 -12
- package/src/plugins/table/nodeviews/TableComponent.tsx +2 -1
- package/src/plugins/table/pm-plugins/drag-and-drop/commands.ts +1 -4
- package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +7 -2
- package/src/plugins/table/pm-plugins/drag-and-drop/utils/monitor.ts +5 -0
- package/src/plugins/table/types.ts +1 -0
- package/src/plugins/table/ui/DragHandle/index.tsx +3 -1
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +9 -17
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +74 -0
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +12 -80
- package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +61 -31
- package/src/plugins/table/ui/icons/index.ts +2 -0
- package/src/plugins/table/ui/ui-styles.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.3.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41924](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41924) [`71cb328c202`](https://bitbucket.org/atlassian/atlassian-frontend/commits/71cb328c202) - Fixed the column controls drag and drop targets. The monitor was not responding to the targets due to there layering and pointer value. The targets are now added/removed on demand when the user starts/stop dragging
|
|
8
|
+
|
|
3
9
|
## 5.3.8
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -499,13 +499,14 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
499
499
|
var colControls = /*#__PURE__*/_react.default.createElement(_TableFloatingColumnControls.default, {
|
|
500
500
|
editorView: view,
|
|
501
501
|
tableRef: tableRef,
|
|
502
|
+
getNode: getNode,
|
|
502
503
|
tableActive: tableActive,
|
|
503
504
|
hoveredRows: hoveredRows,
|
|
504
505
|
hoveredCell: hoveredCell,
|
|
505
506
|
isResizing: isResizing,
|
|
506
507
|
ordering: ordering,
|
|
507
508
|
hasHeaderRow: hasHeaderRow
|
|
508
|
-
// pass `selection`
|
|
509
|
+
// pass `selection` to control re-render
|
|
509
510
|
,
|
|
510
511
|
selection: view.state.selection,
|
|
511
512
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
@@ -77,6 +77,6 @@ var moveSource = exports.moveSource = function moveSource(sourceType, sourceInde
|
|
|
77
77
|
return tr.setMeta('addToHistory', false);
|
|
78
78
|
}
|
|
79
79
|
var move = sourceType === 'table-row' ? _utils.moveRow : _utils.moveColumn;
|
|
80
|
-
return move(sourceIndex, targetIndex
|
|
80
|
+
return move(sourceIndex, targetIndex)(tr);
|
|
81
81
|
});
|
|
82
82
|
};
|
|
@@ -76,7 +76,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
76
76
|
}
|
|
77
77
|
var sourceType = data.sourceType,
|
|
78
78
|
sourceIndexes = data.sourceIndexes,
|
|
79
|
-
targetAdjustedIndex = data.targetAdjustedIndex
|
|
79
|
+
targetAdjustedIndex = data.targetAdjustedIndex,
|
|
80
|
+
direction = data.direction;
|
|
80
81
|
|
|
81
82
|
// If the drop target index contains merged cells then we should not allow the drop to occur.
|
|
82
83
|
var hasMergedCells = sourceType === 'table-row' ? _mergedCells.hasMergedCellsInRow : _mergedCells.hasMergedCellsInColumn;
|
|
@@ -86,7 +87,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
86
87
|
}
|
|
87
88
|
var _sourceIndexes = (0, _slicedToArray2.default)(sourceIndexes, 1),
|
|
88
89
|
sourceIndex = _sourceIndexes[0];
|
|
89
|
-
(0, _commands.moveSource)(sourceType, sourceIndex, targetAdjustedIndex)(editorView.state, editorView.dispatch);
|
|
90
|
+
(0, _commands.moveSource)(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1))(editorView.state, editorView.dispatch);
|
|
90
91
|
}
|
|
91
92
|
})
|
|
92
93
|
};
|
|
@@ -46,6 +46,10 @@ var getDraggableDataFromEvent = exports.getDraggableDataFromEvent = function get
|
|
|
46
46
|
// This introduces an offset in the event the drop occured closer to the bottom/right of the target. We want
|
|
47
47
|
// the new target index to be 1 index higher.
|
|
48
48
|
var targetOffset = targetClosestEdge === 'right' || targetClosestEdge === 'bottom' ? 1 : 0;
|
|
49
|
+
|
|
50
|
+
// since only consecutive rows/cols can be moved we can assume that if the first index is greater then
|
|
51
|
+
// the target index, the then the direction of the DnD is decreasing
|
|
52
|
+
var direction = sourceIndexes[0] > targetIndex ? -1 : 1;
|
|
49
53
|
return {
|
|
50
54
|
sourceType: sourceType,
|
|
51
55
|
sourceLocalId: sourceLocalId,
|
|
@@ -54,6 +58,7 @@ var getDraggableDataFromEvent = exports.getDraggableDataFromEvent = function get
|
|
|
54
58
|
targetLocalId: targetLocalId,
|
|
55
59
|
targetIndex: targetIndex,
|
|
56
60
|
targetAdjustedIndex: targetIndex + targetOffset,
|
|
57
|
-
targetClosestEdge: targetClosestEdge
|
|
61
|
+
targetClosestEdge: targetClosestEdge,
|
|
62
|
+
direction: direction
|
|
58
63
|
};
|
|
59
64
|
};
|
|
@@ -14,7 +14,7 @@ var _setCustomNativeDragPreview = require("@atlaskit/pragmatic-drag-and-drop/uti
|
|
|
14
14
|
var _colors = require("@atlaskit/theme/colors");
|
|
15
15
|
var _types = require("../../types");
|
|
16
16
|
var _DragPreview = require("../DragPreview");
|
|
17
|
-
var
|
|
17
|
+
var _icons = require("../icons");
|
|
18
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
20
|
var mapStateToProps = function mapStateToProps(state) {
|
|
@@ -98,9 +98,11 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
98
98
|
backgroundColor: "var(--ds-surface, white)",
|
|
99
99
|
borderRadius: '4px',
|
|
100
100
|
border: "2px solid ".concat("var(--ds-surface, white)"),
|
|
101
|
-
transform: direction === 'column' ? 'none' : 'rotate(90deg)'
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
transform: direction === 'column' ? 'none' : 'rotate(90deg)',
|
|
102
|
+
pointerEvents: 'auto'
|
|
103
|
+
},
|
|
104
|
+
"data-testid": "table-floating-column-controls-drag-handle"
|
|
105
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, iconProps), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_DragPreview.DragPreview, {
|
|
104
106
|
direction: direction,
|
|
105
107
|
width: previewWidth,
|
|
106
108
|
height: previewHeight
|
|
@@ -1,43 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.ColumnControls = void 0;
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _types = require("../../../types");
|
|
10
|
-
var _utils = require("../../../utils");
|
|
11
10
|
var _DragHandle = require("../../DragHandle");
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
11
|
var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
15
|
-
var _rowHeights
|
|
12
|
+
var _rowHeights$, _colWidths$map$join;
|
|
16
13
|
var editorView = _ref.editorView,
|
|
17
14
|
tableActive = _ref.tableActive,
|
|
18
15
|
tableRef = _ref.tableRef,
|
|
19
16
|
hoveredCell = _ref.hoveredCell,
|
|
20
17
|
isResizing = _ref.isResizing,
|
|
21
|
-
tableHeight = _ref.tableHeight,
|
|
22
18
|
stickyTop = _ref.stickyTop,
|
|
23
|
-
localId = _ref.localId
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (tableRef && !!tableHeight) {
|
|
27
|
-
return (0, _utils.getRowHeights)(tableRef);
|
|
28
|
-
}
|
|
29
|
-
return [0];
|
|
30
|
-
}, [tableRef, tableHeight]);
|
|
19
|
+
localId = _ref.localId,
|
|
20
|
+
rowHeights = _ref.rowHeights,
|
|
21
|
+
colWidths = _ref.colWidths;
|
|
31
22
|
if (!tableRef) {
|
|
32
23
|
return null;
|
|
33
24
|
}
|
|
34
25
|
var firstRow = tableRef.querySelector('tr');
|
|
35
26
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
36
27
|
var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
37
|
-
var
|
|
38
|
-
var widths = colWidths.map(function (width) {
|
|
28
|
+
var widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width) {
|
|
39
29
|
return width ? "".concat(width - 1, "px") : '0px';
|
|
40
|
-
}).join(' ');
|
|
30
|
+
}).join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
41
31
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
42
32
|
var _onClick = function onClick(index, event) {};
|
|
43
33
|
var onMouseOver = function onMouseOver() {};
|
|
@@ -60,7 +50,7 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
60
50
|
"data-testid": "table-floating-column-control"
|
|
61
51
|
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
62
52
|
direction: "column",
|
|
63
|
-
indexes: [],
|
|
53
|
+
indexes: [colIndex],
|
|
64
54
|
onClick: function onClick(event) {
|
|
65
55
|
return _onClick(colIndex, event);
|
|
66
56
|
},
|
package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ColumnDropTarget = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge");
|
|
10
|
+
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
var ColumnDropTarget = exports.ColumnDropTarget = function ColumnDropTarget(_ref) {
|
|
14
|
+
var index = _ref.index,
|
|
15
|
+
localId = _ref.localId,
|
|
16
|
+
width = _ref.width,
|
|
17
|
+
height = _ref.height,
|
|
18
|
+
marginTop = _ref.marginTop;
|
|
19
|
+
var dropTargetRef = (0, _react.useRef)(null);
|
|
20
|
+
(0, _react.useEffect)(function () {
|
|
21
|
+
if (!dropTargetRef.current) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return (0, _element.dropTargetForElements)({
|
|
25
|
+
element: dropTargetRef.current,
|
|
26
|
+
canDrop: function canDrop(_ref2) {
|
|
27
|
+
var _data$indexes, _data$indexes2;
|
|
28
|
+
var source = _ref2.source;
|
|
29
|
+
var data = source.data;
|
|
30
|
+
return (
|
|
31
|
+
// Only draggables of row type can be dropped on this target
|
|
32
|
+
data.type === 'table-column' &&
|
|
33
|
+
// Only draggables which came from the same table can be dropped on this target
|
|
34
|
+
data.localId === localId &&
|
|
35
|
+
// Only draggables which DO NOT include this drop targets index can be dropped
|
|
36
|
+
!!((_data$indexes = data.indexes) !== null && _data$indexes !== void 0 && _data$indexes.length) && ((_data$indexes2 = data.indexes) === null || _data$indexes2 === void 0 ? void 0 : _data$indexes2.indexOf(index)) === -1
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
getIsSticky: function getIsSticky() {
|
|
40
|
+
return true;
|
|
41
|
+
},
|
|
42
|
+
getData: function getData(_ref3) {
|
|
43
|
+
var input = _ref3.input,
|
|
44
|
+
element = _ref3.element;
|
|
45
|
+
var data = {
|
|
46
|
+
localId: localId,
|
|
47
|
+
type: 'table-column',
|
|
48
|
+
targetIndex: index
|
|
49
|
+
};
|
|
50
|
+
return (0, _closestEdge.attachClosestEdge)(data, {
|
|
51
|
+
input: input,
|
|
52
|
+
element: element,
|
|
53
|
+
allowedEdges: ['left', 'right']
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}, [index, localId]);
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
59
|
+
ref: dropTargetRef,
|
|
60
|
+
style: {
|
|
61
|
+
width: width && "".concat(width - 1, "px"),
|
|
62
|
+
height: height && "".concat(height, "px"),
|
|
63
|
+
marginTop: marginTop && "".concat(marginTop, "px"),
|
|
64
|
+
pointerEvents: 'auto'
|
|
65
|
+
},
|
|
66
|
+
"data-drop-target-index": index,
|
|
67
|
+
"data-drop-target-localid": localId,
|
|
68
|
+
"data-testid": "table-floating-column-controls-drop-target"
|
|
69
|
+
});
|
|
70
|
+
};
|
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
8
|
-
var _react =
|
|
9
|
-
var _closestEdge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge");
|
|
10
|
-
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
7
|
+
exports.ColumnDropTargets = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
var _types = require("../../../types");
|
|
12
|
-
var
|
|
13
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
+
var _ColumnDropTarget = require("./ColumnDropTarget");
|
|
15
11
|
var ColumnDropTargets = exports.ColumnDropTargets = function ColumnDropTargets(_ref) {
|
|
16
12
|
var _rowHeights$;
|
|
17
|
-
var
|
|
18
|
-
tableRef = _ref.tableRef,
|
|
13
|
+
var tableRef = _ref.tableRef,
|
|
19
14
|
tableHeight = _ref.tableHeight,
|
|
20
15
|
stickyTop = _ref.stickyTop,
|
|
21
|
-
localId = _ref.localId
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
|
|
25
|
-
if (tableRef && !!tableHeight) {
|
|
26
|
-
return (0, _utils.getRowHeights)(tableRef);
|
|
27
|
-
}
|
|
28
|
-
return [0];
|
|
29
|
-
}, [tableRef, tableHeight]);
|
|
16
|
+
localId = _ref.localId,
|
|
17
|
+
rowHeights = _ref.rowHeights,
|
|
18
|
+
colWidths = _ref.colWidths;
|
|
30
19
|
if (!tableRef) {
|
|
31
20
|
return null;
|
|
32
21
|
}
|
|
@@ -34,12 +23,13 @@ var ColumnDropTargets = exports.ColumnDropTargets = function ColumnDropTargets(_
|
|
|
34
23
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
35
24
|
var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
36
25
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
37
|
-
className: _types.TableCssClassName.COLUMN_DROP_TARGET_CONTROLS
|
|
26
|
+
className: _types.TableCssClassName.COLUMN_DROP_TARGET_CONTROLS,
|
|
27
|
+
contentEditable: false
|
|
38
28
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
39
29
|
className: _types.TableCssClassName.COLUMN_CONTROLS_INNER,
|
|
40
30
|
"data-testid": "table-floating-column-controls-drop-targets"
|
|
41
|
-
}, colWidths.map(function (width, index) {
|
|
42
|
-
return /*#__PURE__*/_react.default.createElement(ColumnDropTarget, {
|
|
31
|
+
}, colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(function (width, index) {
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(_ColumnDropTarget.ColumnDropTarget, {
|
|
43
33
|
key: index,
|
|
44
34
|
index: index,
|
|
45
35
|
localId: localId,
|
|
@@ -48,59 +38,4 @@ var ColumnDropTargets = exports.ColumnDropTargets = function ColumnDropTargets(_
|
|
|
48
38
|
marginTop: marginTop
|
|
49
39
|
});
|
|
50
40
|
})));
|
|
51
|
-
};
|
|
52
|
-
var _default = exports.default = ColumnDropTargets;
|
|
53
|
-
var ColumnDropTarget = function ColumnDropTarget(_ref2) {
|
|
54
|
-
var index = _ref2.index,
|
|
55
|
-
localId = _ref2.localId,
|
|
56
|
-
width = _ref2.width,
|
|
57
|
-
height = _ref2.height,
|
|
58
|
-
marginTop = _ref2.marginTop;
|
|
59
|
-
var dropTargetRef = (0, _react.useRef)(null);
|
|
60
|
-
(0, _react.useEffect)(function () {
|
|
61
|
-
if (!dropTargetRef.current) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
return (0, _element.dropTargetForElements)({
|
|
65
|
-
element: dropTargetRef.current,
|
|
66
|
-
canDrop: function canDrop(_ref3) {
|
|
67
|
-
var _data$indexes, _data$indexes2;
|
|
68
|
-
var source = _ref3.source;
|
|
69
|
-
var data = source.data;
|
|
70
|
-
return (
|
|
71
|
-
// Only draggables of row type can be dropped on this target
|
|
72
|
-
data.type === 'table-column' &&
|
|
73
|
-
// Only draggables which came from the same table can be dropped on this target
|
|
74
|
-
data.localId === localId &&
|
|
75
|
-
// Only draggables which DO NOT include this drop targets index can be dropped
|
|
76
|
-
!!((_data$indexes = data.indexes) !== null && _data$indexes !== void 0 && _data$indexes.length) && ((_data$indexes2 = data.indexes) === null || _data$indexes2 === void 0 ? void 0 : _data$indexes2.indexOf(index)) === -1
|
|
77
|
-
);
|
|
78
|
-
},
|
|
79
|
-
getData: function getData(_ref4) {
|
|
80
|
-
var input = _ref4.input,
|
|
81
|
-
element = _ref4.element;
|
|
82
|
-
var data = {
|
|
83
|
-
localId: localId,
|
|
84
|
-
type: 'table-column',
|
|
85
|
-
targetIndex: index
|
|
86
|
-
};
|
|
87
|
-
return (0, _closestEdge.attachClosestEdge)(data, {
|
|
88
|
-
input: input,
|
|
89
|
-
element: element,
|
|
90
|
-
allowedEdges: ['left', 'right']
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}, [index, localId]);
|
|
95
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
96
|
-
ref: dropTargetRef,
|
|
97
|
-
style: {
|
|
98
|
-
width: width && "".concat(width - 1, "px"),
|
|
99
|
-
height: height && "".concat(height, "px"),
|
|
100
|
-
marginTop: marginTop && "".concat(marginTop, "px")
|
|
101
|
-
},
|
|
102
|
-
"data-drop-target-index": index,
|
|
103
|
-
"data-drop-target-localid": localId,
|
|
104
|
-
"data-testid": "table-floating-column-controls-drop-target"
|
|
105
|
-
});
|
|
106
41
|
};
|
|
@@ -9,8 +9,9 @@ exports.default = exports.TableFloatingColumnControls = void 0;
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
12
|
-
var
|
|
12
|
+
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
13
13
|
var _types = require("../../types");
|
|
14
|
+
var _utils = require("../../utils");
|
|
14
15
|
var _ColumnControls = require("./ColumnControls");
|
|
15
16
|
var _ColumnDropTargets = require("./ColumnDropTargets");
|
|
16
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -21,6 +22,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
21
22
|
var TableFloatingColumnControls = exports.TableFloatingColumnControls = function TableFloatingColumnControls(_ref) {
|
|
22
23
|
var editorView = _ref.editorView,
|
|
23
24
|
tableRef = _ref.tableRef,
|
|
25
|
+
getNode = _ref.getNode,
|
|
24
26
|
tableActive = _ref.tableActive,
|
|
25
27
|
hasHeaderRow = _ref.hasHeaderRow,
|
|
26
28
|
hoveredCell = _ref.hoveredCell,
|
|
@@ -34,6 +36,12 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
34
36
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
35
37
|
tableRect = _useState2[0],
|
|
36
38
|
setTableRect = _useState2[1];
|
|
39
|
+
var _useState3 = (0, _react.useState)(false),
|
|
40
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
41
|
+
hasDropTargets = _useState4[0],
|
|
42
|
+
setHasDropTargets = _useState4[1];
|
|
43
|
+
var node = getNode();
|
|
44
|
+
var currentNodeLocalId = node === null || node === void 0 ? void 0 : node.attrs.localId;
|
|
37
45
|
(0, _react.useEffect)(function () {
|
|
38
46
|
var _window;
|
|
39
47
|
if (tableRef && (_window = window) !== null && _window !== void 0 && _window.ResizeObserver) {
|
|
@@ -65,26 +73,41 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
65
73
|
};
|
|
66
74
|
}
|
|
67
75
|
}, [tableRef]);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
(0, _react.useEffect)(function () {
|
|
77
|
+
return (0, _element.monitorForElements)({
|
|
78
|
+
canMonitor: function canMonitor(_ref2) {
|
|
79
|
+
var source = _ref2.source;
|
|
80
|
+
var _ref3 = source.data,
|
|
81
|
+
type = _ref3.type,
|
|
82
|
+
localId = _ref3.localId,
|
|
83
|
+
indexes = _ref3.indexes;
|
|
84
|
+
return type === 'table-column' && !!(indexes !== null && indexes !== void 0 && indexes.length) && localId === currentNodeLocalId;
|
|
85
|
+
},
|
|
86
|
+
onDragStart: function onDragStart() {
|
|
87
|
+
setHasDropTargets(true);
|
|
88
|
+
},
|
|
89
|
+
onDrop: function onDrop() {
|
|
90
|
+
setHasDropTargets(false);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}, [editorView, currentNodeLocalId]);
|
|
94
|
+
var rowHeights = (0, _react.useMemo)(function () {
|
|
95
|
+
// NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
|
|
96
|
+
if (tableRef && !!tableRect.height) {
|
|
97
|
+
return (0, _utils.getRowHeights)(tableRef);
|
|
75
98
|
}
|
|
76
|
-
return
|
|
77
|
-
}, [
|
|
99
|
+
return [0];
|
|
100
|
+
}, [tableRef, tableRect.height]);
|
|
78
101
|
if (!tableRef) {
|
|
79
102
|
return null;
|
|
80
103
|
}
|
|
104
|
+
var colWidths = (0, _utils.getColumnsWidths)(editorView);
|
|
81
105
|
var stickyTop = stickyHeader && stickyHeader.sticky && hasHeaderRow ? stickyHeader.top : undefined;
|
|
82
106
|
var mountTo = tableRef && (tableRef === null || tableRef === void 0 ? void 0 : tableRef.parentElement) || document.body;
|
|
83
107
|
return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement("div", {
|
|
84
|
-
className: _types.TableCssClassName.COLUMN_CONTROLS_WRAPPER
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return e.preventDefault();
|
|
108
|
+
className: _types.TableCssClassName.COLUMN_CONTROLS_WRAPPER,
|
|
109
|
+
style: {
|
|
110
|
+
pointerEvents: 'none'
|
|
88
111
|
},
|
|
89
112
|
"data-testid": "table-floating-column-controls-wrapper"
|
|
90
113
|
}, /*#__PURE__*/_react.default.createElement(_ColumnControls.ColumnControls, {
|
|
@@ -94,14 +117,16 @@ var TableFloatingColumnControls = exports.TableFloatingColumnControls = function
|
|
|
94
117
|
isResizing: isResizing,
|
|
95
118
|
tableActive: tableActive,
|
|
96
119
|
stickyTop: tableActive ? stickyTop : undefined,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
localId: currentNodeLocalId,
|
|
121
|
+
rowHeights: rowHeights,
|
|
122
|
+
colWidths: colWidths
|
|
123
|
+
}), hasDropTargets && /*#__PURE__*/_react.default.createElement(_ColumnDropTargets.ColumnDropTargets, {
|
|
101
124
|
tableRef: tableRef,
|
|
102
125
|
stickyTop: tableActive ? stickyTop : undefined,
|
|
103
126
|
tableHeight: tableRect.height,
|
|
104
|
-
localId:
|
|
105
|
-
|
|
127
|
+
localId: currentNodeLocalId,
|
|
128
|
+
rowHeights: rowHeights,
|
|
129
|
+
colWidths: colWidths
|
|
130
|
+
})), mountTo);
|
|
106
131
|
};
|
|
107
132
|
var _default = exports.default = TableFloatingColumnControls;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DragHandleIcon", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _DragHandleIcon.DragHandleIcon;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "DragInMotionIcon", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _DragInMotionIcon.DragInMotionIcon;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _DragHandleIcon = require("./DragHandleIcon");
|
|
19
|
+
var _DragInMotionIcon = require("./DragInMotionIcon");
|
|
@@ -71,7 +71,7 @@ var getFloatingDotOverrides = function getFloatingDotOverrides(props) {
|
|
|
71
71
|
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') ? (0, _react.css)(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2.default)(["\n tr\n th:last-child\n .", "::before,\n tr\n td:last-child\n .", "::before {\n content: '';\n background-color: ", ";\n position: absolute;\n height: ", "px;\n width: ", "px;\n border-radius: 50%;\n pointer-events: none;\n top: ", ";\n right: 0px;\n }\n "])), _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, _types.TableCssClassName.COLUMN_CONTROLS_DECORATIONS, (0, _consts.tableBorderColor)(props), _consts.lineMarkerSize, _consts.lineMarkerSize, "var(--ds-space-025, 2px)") : '';
|
|
72
72
|
};
|
|
73
73
|
var floatingColumnControls = exports.floatingColumnControls = function floatingColumnControls(props) {
|
|
74
|
-
return (0, _react.css)(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n box-sizing: border-box;\n position: absolute;\n top: 0;\n
|
|
74
|
+
return (0, _react.css)(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n box-sizing: border-box;\n position: absolute;\n top: 0;\n\n .", " {\n display: flex;\n flex-direction: row;\n }\n }\n\n .", " {\n box-sizing: border-box;\n\n .", " {\n display: grid;\n justify-items: center;\n }\n }\n "])), _types.TableCssClassName.COLUMN_DROP_TARGET_CONTROLS, _types.TableCssClassName.COLUMN_CONTROLS_INNER, _types.TableCssClassName.COLUMN_CONTROLS_WITH_DRAG, _types.TableCssClassName.COLUMN_CONTROLS_INNER);
|
|
75
75
|
};
|
|
76
76
|
var rowControlsWrapperDotStyle = exports.rowControlsWrapperDotStyle = function rowControlsWrapperDotStyle(props) {
|
|
77
77
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table.drag-and-drop')) {
|
|
@@ -497,13 +497,14 @@ class TableComponent extends React.Component {
|
|
|
497
497
|
const colControls = /*#__PURE__*/React.createElement(TableFloatingColumnControls, {
|
|
498
498
|
editorView: view,
|
|
499
499
|
tableRef: tableRef,
|
|
500
|
+
getNode: getNode,
|
|
500
501
|
tableActive: tableActive,
|
|
501
502
|
hoveredRows: hoveredRows,
|
|
502
503
|
hoveredCell: hoveredCell,
|
|
503
504
|
isResizing: isResizing,
|
|
504
505
|
ordering: ordering,
|
|
505
506
|
hasHeaderRow: hasHeaderRow
|
|
506
|
-
// pass `selection`
|
|
507
|
+
// pass `selection` to control re-render
|
|
507
508
|
,
|
|
508
509
|
selection: view.state.selection,
|
|
509
510
|
headerRowHeight: headerRow ? headerRow.offsetHeight : undefined,
|
|
@@ -63,5 +63,5 @@ export const moveSource = (sourceType, sourceIndex, targetIndex) => createComman
|
|
|
63
63
|
return tr.setMeta('addToHistory', false);
|
|
64
64
|
}
|
|
65
65
|
const move = sourceType === 'table-row' ? moveRow : moveColumn;
|
|
66
|
-
return move(sourceIndex, targetIndex
|
|
66
|
+
return move(sourceIndex, targetIndex)(tr);
|
|
67
67
|
});
|
|
@@ -72,7 +72,8 @@ export const createPlugin = (dispatch, eventDispatcher) => {
|
|
|
72
72
|
const {
|
|
73
73
|
sourceType,
|
|
74
74
|
sourceIndexes,
|
|
75
|
-
targetAdjustedIndex
|
|
75
|
+
targetAdjustedIndex,
|
|
76
|
+
direction
|
|
76
77
|
} = data;
|
|
77
78
|
|
|
78
79
|
// If the drop target index contains merged cells then we should not allow the drop to occur.
|
|
@@ -82,7 +83,7 @@ export const createPlugin = (dispatch, eventDispatcher) => {
|
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
const [sourceIndex] = sourceIndexes;
|
|
85
|
-
moveSource(sourceType, sourceIndex, targetAdjustedIndex)(editorView.state, editorView.dispatch);
|
|
86
|
+
moveSource(sourceType, sourceIndex, targetAdjustedIndex + (direction === -1 ? 0 : -1))(editorView.state, editorView.dispatch);
|
|
86
87
|
}
|
|
87
88
|
})
|
|
88
89
|
};
|
|
@@ -43,6 +43,10 @@ export const getDraggableDataFromEvent = ({
|
|
|
43
43
|
// This introduces an offset in the event the drop occured closer to the bottom/right of the target. We want
|
|
44
44
|
// the new target index to be 1 index higher.
|
|
45
45
|
const targetOffset = targetClosestEdge === 'right' || targetClosestEdge === 'bottom' ? 1 : 0;
|
|
46
|
+
|
|
47
|
+
// since only consecutive rows/cols can be moved we can assume that if the first index is greater then
|
|
48
|
+
// the target index, the then the direction of the DnD is decreasing
|
|
49
|
+
const direction = sourceIndexes[0] > targetIndex ? -1 : 1;
|
|
46
50
|
return {
|
|
47
51
|
sourceType,
|
|
48
52
|
sourceLocalId,
|
|
@@ -51,6 +55,7 @@ export const getDraggableDataFromEvent = ({
|
|
|
51
55
|
targetLocalId,
|
|
52
56
|
targetIndex,
|
|
53
57
|
targetAdjustedIndex: targetIndex + targetOffset,
|
|
54
|
-
targetClosestEdge
|
|
58
|
+
targetClosestEdge,
|
|
59
|
+
direction
|
|
55
60
|
};
|
|
56
61
|
};
|
|
@@ -5,7 +5,7 @@ import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/ut
|
|
|
5
5
|
import { N200, N700 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { TableCssClassName as ClassName } from '../../types';
|
|
7
7
|
import { DragPreview } from '../DragPreview';
|
|
8
|
-
import { DragHandleIcon } from '../icons
|
|
8
|
+
import { DragHandleIcon } from '../icons';
|
|
9
9
|
const mapStateToProps = state => {
|
|
10
10
|
switch (state) {
|
|
11
11
|
case 'danger':
|
|
@@ -84,8 +84,10 @@ export const DragHandle = ({
|
|
|
84
84
|
backgroundColor: `${"var(--ds-surface, white)"}`,
|
|
85
85
|
borderRadius: '4px',
|
|
86
86
|
border: `2px solid ${"var(--ds-surface, white)"}`,
|
|
87
|
-
transform: direction === 'column' ? 'none' : 'rotate(90deg)'
|
|
88
|
-
|
|
87
|
+
transform: direction === 'column' ? 'none' : 'rotate(90deg)',
|
|
88
|
+
pointerEvents: 'auto'
|
|
89
|
+
},
|
|
90
|
+
"data-testid": "table-floating-column-controls-drag-handle"
|
|
89
91
|
}, /*#__PURE__*/React.createElement(DragHandleIcon, iconProps), previewContainer && previewWidth !== undefined && previewHeight !== undefined && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(DragPreview, {
|
|
90
92
|
direction: direction,
|
|
91
93
|
width: previewWidth,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
3
|
-
import { getColumnsWidths, getRowHeights } from '../../../utils';
|
|
4
3
|
import { DragHandle } from '../../DragHandle';
|
|
5
4
|
export const ColumnControls = ({
|
|
6
5
|
editorView,
|
|
@@ -8,26 +7,19 @@ export const ColumnControls = ({
|
|
|
8
7
|
tableRef,
|
|
9
8
|
hoveredCell,
|
|
10
9
|
isResizing,
|
|
11
|
-
tableHeight,
|
|
12
10
|
stickyTop,
|
|
13
|
-
localId
|
|
11
|
+
localId,
|
|
12
|
+
rowHeights,
|
|
13
|
+
colWidths
|
|
14
14
|
}) => {
|
|
15
|
-
var _rowHeights
|
|
16
|
-
const rowHeights = useMemo(() => {
|
|
17
|
-
// NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
|
|
18
|
-
if (tableRef && !!tableHeight) {
|
|
19
|
-
return getRowHeights(tableRef);
|
|
20
|
-
}
|
|
21
|
-
return [0];
|
|
22
|
-
}, [tableRef, tableHeight]);
|
|
15
|
+
var _rowHeights$, _colWidths$map$join;
|
|
23
16
|
if (!tableRef) {
|
|
24
17
|
return null;
|
|
25
18
|
}
|
|
26
19
|
const firstRow = tableRef.querySelector('tr');
|
|
27
20
|
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
28
21
|
const marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
29
|
-
const
|
|
30
|
-
const widths = colWidths.map(width => width ? `${width - 1}px` : '0px').join(' ');
|
|
22
|
+
const widths = (_colWidths$map$join = colWidths === null || colWidths === void 0 ? void 0 : colWidths.map(width => width ? `${width - 1}px` : '0px').join(' ')) !== null && _colWidths$map$join !== void 0 ? _colWidths$map$join : '0px';
|
|
31
23
|
const colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
32
24
|
const onClick = (index, event) => {};
|
|
33
25
|
const onMouseOver = () => {};
|
|
@@ -50,7 +42,7 @@ export const ColumnControls = ({
|
|
|
50
42
|
"data-testid": "table-floating-column-control"
|
|
51
43
|
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
52
44
|
direction: "column",
|
|
53
|
-
indexes: [],
|
|
45
|
+
indexes: [colIndex],
|
|
54
46
|
onClick: event => onClick(colIndex, event),
|
|
55
47
|
onMouseOver: onMouseOver,
|
|
56
48
|
onMouseOut: onMouseOut,
|