@atlaskit/editor-plugin-table 5.4.15 → 5.4.17
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 +13 -0
- package/dist/cjs/plugins/table/commands/hover.js +4 -2
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +1 -1
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +2 -2
- package/dist/cjs/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/cjs/plugins/table/ui/DragHandle/index.js +3 -0
- package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +62 -33
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +62 -31
- package/dist/es2019/plugins/table/commands/hover.js +4 -2
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +2 -2
- package/dist/es2019/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/es2019/plugins/table/ui/DragHandle/index.js +2 -0
- package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +63 -33
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +61 -29
- package/dist/esm/plugins/table/commands/hover.js +4 -2
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +1 -1
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +2 -2
- package/dist/esm/plugins/table/ui/DragHandle/HandleIconComponent.js +3 -5
- package/dist/esm/plugins/table/ui/DragHandle/index.js +3 -0
- package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +62 -33
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +60 -29
- package/dist/types/plugins/table/types.d.ts +2 -0
- package/dist/types/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
- package/dist/types/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/HandleIconComponent.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/DragHandle/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/plugins/table/commands/hover.ts +2 -0
- package/src/plugins/table/nodeviews/TableComponent.tsx +1 -1
- package/src/plugins/table/nodeviews/TableResizer.tsx +4 -2
- package/src/plugins/table/types.ts +3 -0
- package/src/plugins/table/ui/DragHandle/HandleIconComponent.tsx +10 -9
- package/src/plugins/table/ui/DragHandle/index.tsx +4 -0
- package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +3 -2
- package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +118 -48
- package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +126 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.4.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#59009](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59009) [`f7e9d874ff37`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f7e9d874ff37) - Fix table expand selection when `platform.editor.table-shift-click-selection-backward` FF is enabled
|
|
8
|
+
- [#58768](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58768) [`a300aa54a8e9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a300aa54a8e9) - [ux] Fixes resize handle state when column is in danger
|
|
9
|
+
|
|
10
|
+
## 5.4.16
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#58843](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58843) [`630177f9bf2e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/630177f9bf2e) - [ux] add selected handle and also keep hover handle
|
|
15
|
+
|
|
3
16
|
## 5.4.15
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -106,7 +106,8 @@ var hoverTable = exports.hoverTable = function hoverTable(isInDanger, isSelected
|
|
|
106
106
|
decorationSet: (0, _utils2.updatePluginStateDecorations)(state, decorations, _types.TableDecorations.TABLE_CONTROLS_HOVER),
|
|
107
107
|
hoveredColumns: hoveredColumns,
|
|
108
108
|
hoveredRows: hoveredRows,
|
|
109
|
-
isInDanger: isInDanger
|
|
109
|
+
isInDanger: isInDanger,
|
|
110
|
+
isWholeTableInDanger: isInDanger
|
|
110
111
|
}
|
|
111
112
|
};
|
|
112
113
|
}, function (tr) {
|
|
@@ -119,7 +120,8 @@ var clearHoverSelection = exports.clearHoverSelection = function clearHoverSelec
|
|
|
119
120
|
type: 'CLEAR_HOVER_SELECTION',
|
|
120
121
|
data: {
|
|
121
122
|
decorationSet: (0, _utils2.updatePluginStateDecorations)(state, [], _types.TableDecorations.ALL_CONTROLS_HOVER),
|
|
122
|
-
isInDanger: false
|
|
123
|
+
isInDanger: false,
|
|
124
|
+
isWholeTableInDanger: false
|
|
123
125
|
}
|
|
124
126
|
};
|
|
125
127
|
});
|
|
@@ -286,7 +286,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
286
286
|
_this.containerWidth = _containerWidth;
|
|
287
287
|
_this.isInitialOverflowSent = false;
|
|
288
288
|
|
|
289
|
-
// store table size using previous full-width mode so can detect if it has changed
|
|
289
|
+
// store table size using previous full-width mode so can detect if it has changed.
|
|
290
290
|
var isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
291
291
|
_this.layoutSize = _this.tableNodeLayoutSize(_this.node, _containerWidth.width, {
|
|
292
292
|
isFullWidthModeEnabled: isFullWidthModeEnabled
|
|
@@ -105,7 +105,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
105
105
|
var resizerMinWidth = getResizerMinWidth(node);
|
|
106
106
|
var handleSize = getResizerHandleHeight(tableRef);
|
|
107
107
|
var _getPluginState = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
108
|
-
|
|
108
|
+
isWholeTableInDanger = _getPluginState.isWholeTableInDanger;
|
|
109
109
|
var _useMeasureFramerate = (0, _analytics2.useMeasureFramerate)(),
|
|
110
110
|
startMeasure = _useMeasureFramerate.startMeasure,
|
|
111
111
|
endMeasure = _useMeasureFramerate.endMeasure,
|
|
@@ -252,7 +252,7 @@ var TableResizer = exports.TableResizer = function TableResizer(_ref) {
|
|
|
252
252
|
snap: guidelineSnaps,
|
|
253
253
|
handlePositioning: "adjacent",
|
|
254
254
|
isHandleVisible: isTableSelected,
|
|
255
|
-
appearance:
|
|
255
|
+
appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
|
|
256
256
|
handleHighlight: "shadow",
|
|
257
257
|
handleTooltipContent: formatMessage(_messages.tableMessages.resizeTable)
|
|
258
258
|
}, children);
|
|
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _icons = require("../icons");
|
|
10
10
|
var HandleIconComponent = exports.HandleIconComponent = function HandleIconComponent(props) {
|
|
11
11
|
var direction = props.direction,
|
|
12
|
+
forceDefaultHandle = props.forceDefaultHandle,
|
|
12
13
|
isDragMenuOpen = props.isDragMenuOpen,
|
|
13
14
|
isRowHandleHovered = props.isRowHandleHovered,
|
|
14
15
|
isColumnHandleHovered = props.isColumnHandleHovered,
|
|
@@ -19,11 +20,8 @@ var HandleIconComponent = exports.HandleIconComponent = function HandleIconCompo
|
|
|
19
20
|
var isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
20
21
|
var isCurrentRowOrColumnSelected = isCurrentRowSelected || isCurrentColumnSelected;
|
|
21
22
|
var isDragMenuOpenOnCurrentRowOrColumn = isDragMenuOpen && dragMenuDirection === direction && isCurrentRowOrColumnSelected;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// hoverred handle or open drag menu
|
|
25
|
-
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
26
|
-
return showNormalHandle;
|
|
23
|
+
if (forceDefaultHandle || isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
24
|
+
return hasMergedCells ? /*#__PURE__*/_react.default.createElement(_icons.DragHandleDisabledIcon, null) : /*#__PURE__*/_react.default.createElement(_icons.DragHandleIcon, null);
|
|
27
25
|
}
|
|
28
26
|
return /*#__PURE__*/_react.default.createElement(_icons.MinimisedHandleIcon, null);
|
|
29
27
|
};
|
|
@@ -28,6 +28,8 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
28
28
|
_ref$appearance = _ref.appearance,
|
|
29
29
|
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
30
30
|
indexes = _ref.indexes,
|
|
31
|
+
_ref$forceDefaultHand = _ref.forceDefaultHandle,
|
|
32
|
+
forceDefaultHandle = _ref$forceDefaultHand === void 0 ? false : _ref$forceDefaultHand,
|
|
31
33
|
previewWidth = _ref.previewWidth,
|
|
32
34
|
previewHeight = _ref.previewHeight,
|
|
33
35
|
onMouseOver = _ref.onMouseOver,
|
|
@@ -59,6 +61,7 @@ var DragHandle = exports.DragHandle = function DragHandle(_ref) {
|
|
|
59
61
|
var handleIconProps = {
|
|
60
62
|
hasMergedCells: hasMergedCells,
|
|
61
63
|
direction: direction,
|
|
64
|
+
forceDefaultHandle: forceDefaultHandle,
|
|
62
65
|
isDragMenuOpen: isDragMenuOpen,
|
|
63
66
|
isRowHandleHovered: isRowHandleHovered,
|
|
64
67
|
isColumnHandleHovered: isColumnHandleHovered,
|
|
@@ -82,8 +82,8 @@ var DragMenu = exports.DragMenu = function DragMenu(_ref) {
|
|
|
82
82
|
var selection = state.selection;
|
|
83
83
|
var selectionRect = (0, _utils.isSelectionType)(selection, 'cell') ? (0, _utils.getSelectionRect)(selection) : (0, _utils.findCellRectClosestToPos)(selection.$from);
|
|
84
84
|
var hasMergedCells = direction === 'row' ? _utils2.hasMergedCellsInRow : _utils2.hasMergedCellsInColumn;
|
|
85
|
-
var
|
|
86
|
-
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth,
|
|
85
|
+
var shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
86
|
+
var dragMenuConfig = (0, _dragMenu.getDragMenuConfig)(direction, getEditorContainerWidth, shouldMoveDisabled, tableMap, index, targetCellPosition, selectionRect);
|
|
87
87
|
var _convertToDropdownIte = convertToDropdownItems(dragMenuConfig),
|
|
88
88
|
menuItems = _convertToDropdownIte.menuItems,
|
|
89
89
|
menuCallback = _convertToDropdownIte.menuCallback;
|
|
@@ -10,11 +10,14 @@ var _editorTables = require("@atlaskit/editor-tables");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-tables/utils");
|
|
11
11
|
var _commands = require("../../../commands");
|
|
12
12
|
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
13
|
+
var _pluginFactory = require("../../../pm-plugins/drag-and-drop/plugin-factory");
|
|
13
14
|
var _types = require("../../../types");
|
|
14
15
|
var _utils2 = require("../../../utils");
|
|
15
16
|
var _DragHandle = require("../../DragHandle");
|
|
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); }
|
|
17
18
|
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; }
|
|
19
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
20
|
+
|
|
18
21
|
var getSelectedColumns = function getSelectedColumns(selection) {
|
|
19
22
|
if (selection instanceof _editorTables.CellSelection && selection.isColSelection()) {
|
|
20
23
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
@@ -26,7 +29,7 @@ var getSelectedColumns = function getSelectedColumns(selection) {
|
|
|
26
29
|
return [];
|
|
27
30
|
};
|
|
28
31
|
var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
29
|
-
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce
|
|
32
|
+
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce;
|
|
30
33
|
var editorView = _ref.editorView,
|
|
31
34
|
tableActive = _ref.tableActive,
|
|
32
35
|
tableRef = _ref.tableRef,
|
|
@@ -46,13 +49,6 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
46
49
|
var columnParams = (0, _utils2.getRowsParams)(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
47
50
|
var colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
48
51
|
var selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
49
|
-
var gridColumnPosition = (0, _react.useMemo)(function () {
|
|
50
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
51
|
-
if (selectedColIndexes.includes(colIndex)) {
|
|
52
|
-
return "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length);
|
|
53
|
-
}
|
|
54
|
-
return "".concat(colIndex + 1, " / span 1");
|
|
55
|
-
}, [colIndex, selectedColIndexes]);
|
|
56
52
|
var firstRow = tableRef.querySelector('tr');
|
|
57
53
|
var hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
58
54
|
var marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
@@ -104,6 +100,63 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
104
100
|
var previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce(function (sum, cur) {
|
|
105
101
|
return sum + cur;
|
|
106
102
|
}, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
103
|
+
var generateHandleByType = (0, _react.useCallback)(function (type) {
|
|
104
|
+
var _colWidths;
|
|
105
|
+
if (!hoveredCell) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
109
|
+
isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
|
|
110
|
+
dragMenuIndex = _getDragDropPluginSta.dragMenuIndex,
|
|
111
|
+
dragMenuDirection = _getDragDropPluginSta.dragMenuDirection;
|
|
112
|
+
var isHover = type === 'hover';
|
|
113
|
+
var isHoveredOnSelectedColumn = isDragMenuOpen && dragMenuDirection === 'column' && dragMenuIndex === colIndex;
|
|
114
|
+
var showCondition = isHover ? !isHoveredOnSelectedColumn && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'column';
|
|
115
|
+
if (!showCondition) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
var selectedColumnPosition = "".concat(dragMenuIndex + 1, " / span ").concat(selectedColIndexes.length);
|
|
119
|
+
var gridColumnPosition = selectedColIndexes.includes(colIndex) ? "".concat(selectedColIndexes[0] + 1, " / span ").concat(selectedColIndexes.length) : "".concat(colIndex + 1, " / span 1");
|
|
120
|
+
var selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
121
|
+
var hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
122
|
+
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
key: type,
|
|
124
|
+
style: {
|
|
125
|
+
gridColumn: isHover ? gridColumnPosition : selectedColumnPosition,
|
|
126
|
+
display: 'flex',
|
|
127
|
+
justifyContent: 'center',
|
|
128
|
+
alignItems: 'center',
|
|
129
|
+
height: 'fit-content',
|
|
130
|
+
placeSelf: 'center',
|
|
131
|
+
zIndex: 99
|
|
132
|
+
},
|
|
133
|
+
"data-column-control-index": hoveredCell.colIndex,
|
|
134
|
+
"data-testid": isHover ? 'table-floating-column-control' : 'table-floating-column-control-selected'
|
|
135
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
136
|
+
direction: "column",
|
|
137
|
+
tableLocalId: localId || '',
|
|
138
|
+
indexes: isHover ? colIndexes : selectedColIndexes,
|
|
139
|
+
forceDefaultHandle: !isHover,
|
|
140
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
141
|
+
previewHeight: previewHeight,
|
|
142
|
+
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
143
|
+
onClick: handleClick,
|
|
144
|
+
onMouseOver: handleMouseOver,
|
|
145
|
+
onMouseOut: handleMouseOut,
|
|
146
|
+
onMouseUp: handleMouseUp,
|
|
147
|
+
editorView: editorView
|
|
148
|
+
}));
|
|
149
|
+
}, [colIndex, previewHeight, colWidths, colIndexes, editorView, handleClick, handleMouseOut, handleMouseOver, handleMouseUp, hoveredCell, isInDanger, localId, selectedColIndexes]);
|
|
150
|
+
var columnHandles = (0, _react.useCallback)(function (hoveredCell) {
|
|
151
|
+
if (!hoveredCell) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (hoveredCell.colIndex === undefined) {
|
|
155
|
+
return generateHandleByType('selected');
|
|
156
|
+
}
|
|
157
|
+
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
158
|
+
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
159
|
+
}, [generateHandleByType, selectedColIndexes]);
|
|
107
160
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
108
161
|
className: _types.TableCssClassName.DRAG_COLUMN_CONTROLS,
|
|
109
162
|
onMouseMove: handleMouseMove
|
|
@@ -132,30 +185,6 @@ var ColumnControls = exports.ColumnControls = function ColumnControls(_ref) {
|
|
|
132
185
|
right: '0'
|
|
133
186
|
} : {}
|
|
134
187
|
}));
|
|
135
|
-
}), tableActive && !isResizing &&
|
|
136
|
-
style: {
|
|
137
|
-
gridColumn: gridColumnPosition,
|
|
138
|
-
display: 'flex',
|
|
139
|
-
justifyContent: 'center',
|
|
140
|
-
alignItems: 'center',
|
|
141
|
-
height: 'fit-content',
|
|
142
|
-
placeSelf: 'center',
|
|
143
|
-
zIndex: 99
|
|
144
|
-
},
|
|
145
|
-
"data-column-control-index": hoveredCell.colIndex,
|
|
146
|
-
"data-testid": "table-floating-column-control"
|
|
147
|
-
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
148
|
-
direction: "column",
|
|
149
|
-
tableLocalId: localId || '',
|
|
150
|
-
indexes: colIndexes,
|
|
151
|
-
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
152
|
-
previewHeight: previewHeight,
|
|
153
|
-
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
154
|
-
onClick: handleClick,
|
|
155
|
-
onMouseOver: handleMouseOver,
|
|
156
|
-
onMouseOut: handleMouseOut,
|
|
157
|
-
onMouseUp: handleMouseUp,
|
|
158
|
-
editorView: editorView
|
|
159
|
-
}))));
|
|
188
|
+
}), tableActive && !isResizing && columnHandles(hoveredCell)));
|
|
160
189
|
};
|
|
161
190
|
var _default = exports.default = ColumnControls;
|
|
@@ -14,7 +14,8 @@ var _utils = require("@atlaskit/editor-tables/utils");
|
|
|
14
14
|
var _element = require("@atlaskit/pragmatic-drag-and-drop/adapter/element");
|
|
15
15
|
var _commands = require("../../../commands");
|
|
16
16
|
var _commands2 = require("../../../pm-plugins/drag-and-drop/commands");
|
|
17
|
-
var _pluginFactory = require("../../../pm-plugins/plugin-factory");
|
|
17
|
+
var _pluginFactory = require("../../../pm-plugins/drag-and-drop/plugin-factory");
|
|
18
|
+
var _pluginFactory2 = require("../../../pm-plugins/plugin-factory");
|
|
18
19
|
var _types = require("../../../types");
|
|
19
20
|
var _utils2 = require("../../../utils");
|
|
20
21
|
var _consts = require("../../consts");
|
|
@@ -22,6 +23,8 @@ var _DragHandle = require("../../DragHandle");
|
|
|
22
23
|
var _RowDropTarget = _interopRequireDefault(require("../RowDropTarget"));
|
|
23
24
|
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); }
|
|
24
25
|
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; }
|
|
26
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
27
|
+
|
|
25
28
|
var getSelectedRows = function getSelectedRows(selection) {
|
|
26
29
|
if (selection instanceof _editorTables.CellSelection && selection.isRowSelection()) {
|
|
27
30
|
var rect = (0, _utils.getSelectionRect)(selection);
|
|
@@ -68,7 +71,7 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
68
71
|
if (!indexes || !localId || type !== 'table-row') {
|
|
69
72
|
return false;
|
|
70
73
|
}
|
|
71
|
-
var _getTablePluginState = (0,
|
|
74
|
+
var _getTablePluginState = (0, _pluginFactory2.getPluginState)(editorView.state),
|
|
72
75
|
tableNode = _getTablePluginState.tableNode;
|
|
73
76
|
// If the draggable localId is the same as the current selected table localId then we will allow the monitor
|
|
74
77
|
// watch for changes
|
|
@@ -86,13 +89,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
86
89
|
(0, _commands2.toggleDragMenu)(undefined, 'row', hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex)(editorView.state, editorView.dispatch);
|
|
87
90
|
}, [editorView, hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex]);
|
|
88
91
|
var rowIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.rowIndex;
|
|
89
|
-
var gridRowPosition = (0, _react.useMemo)(function () {
|
|
90
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
91
|
-
if (selectedRowIndexes.includes(rowIndex)) {
|
|
92
|
-
return "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length);
|
|
93
|
-
}
|
|
94
|
-
return "".concat(rowIndex + 1, " / span 1");
|
|
95
|
-
}, [rowIndex, selectedRowIndexes]);
|
|
96
92
|
var handleMouseOut = (0, _react.useCallback)(function () {
|
|
97
93
|
if (tableActive) {
|
|
98
94
|
var state = editorView.state,
|
|
@@ -119,6 +115,62 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
119
115
|
var handleClick = (0, _react.useCallback)(function (e) {
|
|
120
116
|
selectRow(rowIndex, e === null || e === void 0 ? void 0 : e.shiftKey);
|
|
121
117
|
}, [rowIndex, selectRow]);
|
|
118
|
+
var generateHandleByType = (0, _react.useCallback)(function (type) {
|
|
119
|
+
if (!hoveredCell) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
var _getDragDropPluginSta = (0, _pluginFactory.getPluginState)(editorView.state),
|
|
123
|
+
isDragMenuOpen = _getDragDropPluginSta.isDragMenuOpen,
|
|
124
|
+
dragMenuIndex = _getDragDropPluginSta.dragMenuIndex,
|
|
125
|
+
dragMenuDirection = _getDragDropPluginSta.dragMenuDirection;
|
|
126
|
+
var isHover = type === 'hover';
|
|
127
|
+
var isHoveredOnSelectedRow = isDragMenuOpen && dragMenuDirection === 'row' && dragMenuIndex === rowIndex;
|
|
128
|
+
var showCondition = isHover ? !isHoveredOnSelectedRow && !selectedRowIndexes.includes(rowIndex) && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'row' && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex);
|
|
129
|
+
if (!showCondition) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
var gridRowPosition =
|
|
133
|
+
// if more than one row is selected, ensure the handle spans over the selected range
|
|
134
|
+
selectedRowIndexes.includes(rowIndex) ? "".concat(selectedRowIndexes[0] + 1, " / span ").concat(selectedRowIndexes.length) : "".concat(rowIndex + 1, " / span 1");
|
|
135
|
+
var selectedRowPosition = "".concat(dragMenuIndex + 1, " / span ").concat(selectedRowIndexes.length);
|
|
136
|
+
var selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
137
|
+
var hoveredAppearance = selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
138
|
+
return showCondition && /*#__PURE__*/_react.default.createElement("div", {
|
|
139
|
+
key: type,
|
|
140
|
+
style: {
|
|
141
|
+
gridRow: isHover ? gridRowPosition : selectedRowPosition,
|
|
142
|
+
gridColumn: '2',
|
|
143
|
+
display: 'flex',
|
|
144
|
+
height: '100%',
|
|
145
|
+
alignItems: 'center',
|
|
146
|
+
justifyContent: 'center'
|
|
147
|
+
},
|
|
148
|
+
"data-testid": isHover ? 'table-floating-row-drag-handle' : 'table-floating-row-control-selected'
|
|
149
|
+
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
150
|
+
direction: "row",
|
|
151
|
+
tableLocalId: currentNodeLocalId,
|
|
152
|
+
indexes: isHover ? rowIndexes : selectedRowIndexes,
|
|
153
|
+
forceDefaultHandle: !isHover,
|
|
154
|
+
previewWidth: tableWidth,
|
|
155
|
+
previewHeight: rowHeights[rowIndex],
|
|
156
|
+
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
157
|
+
onClick: handleClick,
|
|
158
|
+
onMouseOver: handleMouseOver,
|
|
159
|
+
onMouseOut: handleMouseOut,
|
|
160
|
+
onMouseUp: onMouseUp,
|
|
161
|
+
editorView: editorView
|
|
162
|
+
}));
|
|
163
|
+
}, [currentNodeLocalId, editorView, handleClick, handleMouseOut, handleMouseOver, hoveredCell, isInDanger, onMouseUp, rowHeights, rowIndex, rowIndexes, selectedRowIndexes, tableWidth]);
|
|
164
|
+
var rowHandles = (0, _react.useCallback)(function (hoveredCell) {
|
|
165
|
+
if (!hoveredCell) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
if (hoveredCell.rowIndex === undefined) {
|
|
169
|
+
return generateHandleByType('selected');
|
|
170
|
+
}
|
|
171
|
+
var sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
172
|
+
return hoveredCell.rowIndex < selectedRowIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
173
|
+
}, [generateHandleByType, selectedRowIndexes]);
|
|
122
174
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
123
175
|
className: _types.TableCssClassName.DRAG_ROW_CONTROLS,
|
|
124
176
|
style: {
|
|
@@ -158,27 +210,6 @@ var DragControlsComponent = function DragControlsComponent(_ref) {
|
|
|
158
210
|
left: "var(--ds-space-negative-100, -8px)"
|
|
159
211
|
}
|
|
160
212
|
}));
|
|
161
|
-
}), !isResizing &&
|
|
162
|
-
style: {
|
|
163
|
-
gridRow: gridRowPosition,
|
|
164
|
-
gridColumn: '2',
|
|
165
|
-
display: 'flex',
|
|
166
|
-
height: '100%',
|
|
167
|
-
alignItems: 'center',
|
|
168
|
-
justifyContent: 'center'
|
|
169
|
-
},
|
|
170
|
-
"data-testid": "table-floating-row-drag-handle"
|
|
171
|
-
}, /*#__PURE__*/_react.default.createElement(_DragHandle.DragHandle, {
|
|
172
|
-
tableLocalId: currentNodeLocalId,
|
|
173
|
-
indexes: rowIndexes,
|
|
174
|
-
previewWidth: tableWidth,
|
|
175
|
-
previewHeight: rowHeights[rowIndex],
|
|
176
|
-
appearance: selectedRowIndexes.includes(rowIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
177
|
-
onClick: handleClick,
|
|
178
|
-
onMouseOver: handleMouseOver,
|
|
179
|
-
onMouseOut: handleMouseOut,
|
|
180
|
-
onMouseUp: onMouseUp,
|
|
181
|
-
editorView: editorView
|
|
182
|
-
})));
|
|
213
|
+
}), !isResizing && Number.isFinite(rowIndex) && rowHandles(hoveredCell));
|
|
183
214
|
};
|
|
184
215
|
var DragControls = exports.DragControls = (0, _reactIntlNext.injectIntl)(DragControlsComponent);
|
|
@@ -85,7 +85,8 @@ export const hoverTable = (isInDanger, isSelected) => createCommand(state => {
|
|
|
85
85
|
decorationSet: updatePluginStateDecorations(state, decorations, TableDecorations.TABLE_CONTROLS_HOVER),
|
|
86
86
|
hoveredColumns,
|
|
87
87
|
hoveredRows,
|
|
88
|
-
isInDanger
|
|
88
|
+
isInDanger,
|
|
89
|
+
isWholeTableInDanger: isInDanger
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
92
|
}, tr => tr.setMeta('addToHistory', false));
|
|
@@ -93,7 +94,8 @@ export const clearHoverSelection = () => createCommand(state => ({
|
|
|
93
94
|
type: 'CLEAR_HOVER_SELECTION',
|
|
94
95
|
data: {
|
|
95
96
|
decorationSet: updatePluginStateDecorations(state, [], TableDecorations.ALL_CONTROLS_HOVER),
|
|
96
|
-
isInDanger: false
|
|
97
|
+
isInDanger: false,
|
|
98
|
+
isWholeTableInDanger: false
|
|
97
99
|
}
|
|
98
100
|
}));
|
|
99
101
|
export const showResizeHandleLine = cellColumnPositioning => createCommand(state => ({
|
|
@@ -284,7 +284,7 @@ class TableComponent extends React.Component {
|
|
|
284
284
|
this.containerWidth = _containerWidth;
|
|
285
285
|
this.isInitialOverflowSent = false;
|
|
286
286
|
|
|
287
|
-
// store table size using previous full-width mode so can detect if it has changed
|
|
287
|
+
// store table size using previous full-width mode so can detect if it has changed.
|
|
288
288
|
const isFullWidthModeEnabled = _options ? _options.wasFullWidthModeEnabled : false;
|
|
289
289
|
this.layoutSize = this.tableNodeLayoutSize(this.node, _containerWidth.width, {
|
|
290
290
|
isFullWidthModeEnabled
|
|
@@ -90,7 +90,7 @@ export const TableResizer = ({
|
|
|
90
90
|
const resizerMinWidth = getResizerMinWidth(node);
|
|
91
91
|
const handleSize = getResizerHandleHeight(tableRef);
|
|
92
92
|
const {
|
|
93
|
-
|
|
93
|
+
isWholeTableInDanger
|
|
94
94
|
} = getPluginState(editorView.state);
|
|
95
95
|
const {
|
|
96
96
|
startMeasure,
|
|
@@ -247,7 +247,7 @@ export const TableResizer = ({
|
|
|
247
247
|
snap: guidelineSnaps,
|
|
248
248
|
handlePositioning: "adjacent",
|
|
249
249
|
isHandleVisible: isTableSelected,
|
|
250
|
-
appearance:
|
|
250
|
+
appearance: isTableSelected && isWholeTableInDanger ? 'danger' : undefined,
|
|
251
251
|
handleHighlight: "shadow",
|
|
252
252
|
handleTooltipContent: formatMessage(messages.resizeTable)
|
|
253
253
|
}, children);
|
|
@@ -3,6 +3,7 @@ import { DragHandleDisabledIcon, DragHandleIcon, MinimisedHandleIcon } from '../
|
|
|
3
3
|
export const HandleIconComponent = props => {
|
|
4
4
|
const {
|
|
5
5
|
direction,
|
|
6
|
+
forceDefaultHandle,
|
|
6
7
|
isDragMenuOpen,
|
|
7
8
|
isRowHandleHovered,
|
|
8
9
|
isColumnHandleHovered,
|
|
@@ -14,11 +15,8 @@ export const HandleIconComponent = props => {
|
|
|
14
15
|
const isHandleHovered = isRowHandleHovered || isColumnHandleHovered;
|
|
15
16
|
const isCurrentRowOrColumnSelected = isCurrentRowSelected || isCurrentColumnSelected;
|
|
16
17
|
const isDragMenuOpenOnCurrentRowOrColumn = isDragMenuOpen && dragMenuDirection === direction && isCurrentRowOrColumnSelected;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// hoverred handle or open drag menu
|
|
20
|
-
if (isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
21
|
-
return showNormalHandle;
|
|
18
|
+
if (forceDefaultHandle || isHandleHovered || isDragMenuOpenOnCurrentRowOrColumn) {
|
|
19
|
+
return hasMergedCells ? /*#__PURE__*/React.createElement(DragHandleDisabledIcon, null) : /*#__PURE__*/React.createElement(DragHandleIcon, null);
|
|
22
20
|
}
|
|
23
21
|
return /*#__PURE__*/React.createElement(MinimisedHandleIcon, null);
|
|
24
22
|
};
|
|
@@ -14,6 +14,7 @@ export const DragHandle = ({
|
|
|
14
14
|
direction = 'row',
|
|
15
15
|
appearance = 'default',
|
|
16
16
|
indexes,
|
|
17
|
+
forceDefaultHandle = false,
|
|
17
18
|
previewWidth,
|
|
18
19
|
previewHeight,
|
|
19
20
|
onMouseOver,
|
|
@@ -45,6 +46,7 @@ export const DragHandle = ({
|
|
|
45
46
|
const handleIconProps = {
|
|
46
47
|
hasMergedCells,
|
|
47
48
|
direction,
|
|
49
|
+
forceDefaultHandle,
|
|
48
50
|
isDragMenuOpen,
|
|
49
51
|
isRowHandleHovered,
|
|
50
52
|
isColumnHandleHovered,
|
|
@@ -73,8 +73,8 @@ export const DragMenu = ({
|
|
|
73
73
|
} = state;
|
|
74
74
|
const selectionRect = isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
75
75
|
const hasMergedCells = direction === 'row' ? hasMergedCellsInRow : hasMergedCellsInColumn;
|
|
76
|
-
const
|
|
77
|
-
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth,
|
|
76
|
+
const shouldMoveDisabled = index !== undefined && hasMergedCells(index)(selection);
|
|
77
|
+
const dragMenuConfig = getDragMenuConfig(direction, getEditorContainerWidth, shouldMoveDisabled, tableMap, index, targetCellPosition, selectionRect);
|
|
78
78
|
const {
|
|
79
79
|
menuItems,
|
|
80
80
|
menuCallback
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
2
|
+
|
|
1
3
|
import React, { useCallback, useMemo } from 'react';
|
|
2
4
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
3
5
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
4
6
|
import { clearHoverSelection, hoverCell, hoverColumns, selectColumn } from '../../../commands';
|
|
5
7
|
import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
|
|
8
|
+
import { getPluginState as getDragDropPluginState } from '../../../pm-plugins/drag-and-drop/plugin-factory';
|
|
6
9
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
7
10
|
import { getRowsParams, getSelectedColumnIndexes } from '../../../utils';
|
|
8
11
|
import { DragHandle } from '../../DragHandle';
|
|
@@ -30,19 +33,12 @@ export const ColumnControls = ({
|
|
|
30
33
|
hasHeaderColumn,
|
|
31
34
|
isTableHovered
|
|
32
35
|
}) => {
|
|
33
|
-
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce
|
|
36
|
+
var _colWidths$map$join, _rowHeights$, _rowHeights$reduce;
|
|
34
37
|
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';
|
|
35
38
|
// TODO: reusing getRowsParams here because it's generic enough to work for columns -> rename
|
|
36
39
|
const columnParams = getRowsParams(colWidths !== null && colWidths !== void 0 ? colWidths : []);
|
|
37
40
|
const colIndex = hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex;
|
|
38
41
|
const selectedColIndexes = getSelectedColumns(editorView.state.selection);
|
|
39
|
-
const gridColumnPosition = useMemo(() => {
|
|
40
|
-
// if more than one row is selected, ensure the handle spans over the selected range
|
|
41
|
-
if (selectedColIndexes.includes(colIndex)) {
|
|
42
|
-
return `${selectedColIndexes[0] + 1} / span ${selectedColIndexes.length}`;
|
|
43
|
-
}
|
|
44
|
-
return `${colIndex + 1} / span 1`;
|
|
45
|
-
}, [colIndex, selectedColIndexes]);
|
|
46
42
|
const firstRow = tableRef.querySelector('tr');
|
|
47
43
|
const hasHeaderRow = firstRow ? firstRow.getAttribute('data-header-row') : false;
|
|
48
44
|
const marginTop = hasHeaderRow && stickyTop !== undefined ? (_rowHeights$ = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights[0]) !== null && _rowHeights$ !== void 0 ? _rowHeights$ : 0 : 0;
|
|
@@ -102,6 +98,64 @@ export const ColumnControls = ({
|
|
|
102
98
|
return [colIndex];
|
|
103
99
|
}, [colIndex]);
|
|
104
100
|
const previewHeight = (_rowHeights$reduce = rowHeights === null || rowHeights === void 0 ? void 0 : rowHeights.reduce((sum, cur) => sum + cur, 0)) !== null && _rowHeights$reduce !== void 0 ? _rowHeights$reduce : 0;
|
|
101
|
+
const generateHandleByType = useCallback(type => {
|
|
102
|
+
var _colWidths;
|
|
103
|
+
if (!hoveredCell) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
const {
|
|
107
|
+
isDragMenuOpen,
|
|
108
|
+
dragMenuIndex,
|
|
109
|
+
dragMenuDirection
|
|
110
|
+
} = getDragDropPluginState(editorView.state);
|
|
111
|
+
const isHover = type === 'hover';
|
|
112
|
+
const isHoveredOnSelectedColumn = isDragMenuOpen && dragMenuDirection === 'column' && dragMenuIndex === colIndex;
|
|
113
|
+
const showCondition = isHover ? !isHoveredOnSelectedColumn && Number.isFinite(hoveredCell === null || hoveredCell === void 0 ? void 0 : hoveredCell.colIndex) : isDragMenuOpen && dragMenuDirection === 'column';
|
|
114
|
+
if (!showCondition) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const selectedColumnPosition = `${dragMenuIndex + 1} / span ${selectedColIndexes.length}`;
|
|
118
|
+
const gridColumnPosition = selectedColIndexes.includes(colIndex) ? `${selectedColIndexes[0] + 1} / span ${selectedColIndexes.length}` : `${colIndex + 1} / span 1`;
|
|
119
|
+
const selectedApprearance = isInDanger ? 'danger' : 'selected';
|
|
120
|
+
const hoveredAppearance = selectedColIndexes.includes(colIndex) ? isInDanger ? 'danger' : 'selected' : 'default';
|
|
121
|
+
return showCondition && /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
key: type,
|
|
123
|
+
style: {
|
|
124
|
+
gridColumn: isHover ? gridColumnPosition : selectedColumnPosition,
|
|
125
|
+
display: 'flex',
|
|
126
|
+
justifyContent: 'center',
|
|
127
|
+
alignItems: 'center',
|
|
128
|
+
height: 'fit-content',
|
|
129
|
+
placeSelf: 'center',
|
|
130
|
+
zIndex: 99
|
|
131
|
+
},
|
|
132
|
+
"data-column-control-index": hoveredCell.colIndex,
|
|
133
|
+
"data-testid": isHover ? 'table-floating-column-control' : 'table-floating-column-control-selected'
|
|
134
|
+
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
135
|
+
direction: "column",
|
|
136
|
+
tableLocalId: localId || '',
|
|
137
|
+
indexes: isHover ? colIndexes : selectedColIndexes,
|
|
138
|
+
forceDefaultHandle: !isHover,
|
|
139
|
+
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
140
|
+
previewHeight: previewHeight,
|
|
141
|
+
appearance: isHover ? hoveredAppearance : selectedApprearance,
|
|
142
|
+
onClick: handleClick,
|
|
143
|
+
onMouseOver: handleMouseOver,
|
|
144
|
+
onMouseOut: handleMouseOut,
|
|
145
|
+
onMouseUp: handleMouseUp,
|
|
146
|
+
editorView: editorView
|
|
147
|
+
}));
|
|
148
|
+
}, [colIndex, previewHeight, colWidths, colIndexes, editorView, handleClick, handleMouseOut, handleMouseOver, handleMouseUp, hoveredCell, isInDanger, localId, selectedColIndexes]);
|
|
149
|
+
const columnHandles = useCallback(hoveredCell => {
|
|
150
|
+
if (!hoveredCell) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
if (hoveredCell.colIndex === undefined) {
|
|
154
|
+
return generateHandleByType('selected');
|
|
155
|
+
}
|
|
156
|
+
const sortedHandles = [generateHandleByType('hover'), generateHandleByType('selected')];
|
|
157
|
+
return hoveredCell.colIndex < selectedColIndexes[0] ? sortedHandles : sortedHandles.reverse();
|
|
158
|
+
}, [generateHandleByType, selectedColIndexes]);
|
|
105
159
|
return /*#__PURE__*/React.createElement("div", {
|
|
106
160
|
className: ClassName.DRAG_COLUMN_CONTROLS,
|
|
107
161
|
onMouseMove: handleMouseMove
|
|
@@ -129,30 +183,6 @@ export const ColumnControls = ({
|
|
|
129
183
|
style: columnParams.length - 1 === index ? {
|
|
130
184
|
right: '0'
|
|
131
185
|
} : {}
|
|
132
|
-
}))), tableActive && !isResizing &&
|
|
133
|
-
style: {
|
|
134
|
-
gridColumn: gridColumnPosition,
|
|
135
|
-
display: 'flex',
|
|
136
|
-
justifyContent: 'center',
|
|
137
|
-
alignItems: 'center',
|
|
138
|
-
height: 'fit-content',
|
|
139
|
-
placeSelf: 'center',
|
|
140
|
-
zIndex: 99
|
|
141
|
-
},
|
|
142
|
-
"data-column-control-index": hoveredCell.colIndex,
|
|
143
|
-
"data-testid": "table-floating-column-control"
|
|
144
|
-
}, /*#__PURE__*/React.createElement(DragHandle, {
|
|
145
|
-
direction: "column",
|
|
146
|
-
tableLocalId: localId || '',
|
|
147
|
-
indexes: colIndexes,
|
|
148
|
-
previewWidth: (_colWidths = colWidths === null || colWidths === void 0 ? void 0 : colWidths[colIndex]) !== null && _colWidths !== void 0 ? _colWidths : 48,
|
|
149
|
-
previewHeight: previewHeight,
|
|
150
|
-
appearance: selectedColIndexes.includes(hoveredCell.colIndex) ? isInDanger ? 'danger' : 'selected' : 'default',
|
|
151
|
-
onClick: handleClick,
|
|
152
|
-
onMouseOver: handleMouseOver,
|
|
153
|
-
onMouseOut: handleMouseOut,
|
|
154
|
-
onMouseUp: handleMouseUp,
|
|
155
|
-
editorView: editorView
|
|
156
|
-
}))));
|
|
186
|
+
}))), tableActive && !isResizing && columnHandles(hoveredCell)));
|
|
157
187
|
};
|
|
158
188
|
export default ColumnControls;
|