@carbon/ibm-products 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +123 -5628
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +4 -4
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +45 -3424
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +3 -3
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +91 -3894
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +4 -4
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +91 -3895
- package/css/index.css.map +1 -1
- package/css/index.min.css +4 -4
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +11 -6
- package/es/components/AddSelect/AddSelectColumn.js +44 -7
- package/es/components/ButtonMenu/ButtonMenu.js +1 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +316 -133
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +113 -69
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +22 -5
- package/es/components/DataSpreadsheet/checkActiveHeaderCell.js +34 -0
- package/es/components/DataSpreadsheet/createActiveCellFn.js +3 -1
- package/es/components/InlineEdit/InlineEdit.js +11 -21
- package/es/components/OptionsTile/OptionsTile.js +11 -1
- package/es/components/PageHeader/PageHeader.js +48 -40
- package/es/components/PageHeader/PageHeaderUtils.js +3 -7
- package/es/components/TagSet/TagSet.js +12 -3
- package/es/components/UserProfileImage/UserProfileImage.js +2 -1
- package/lib/components/AddSelect/AddSelect.js +11 -6
- package/lib/components/AddSelect/AddSelectColumn.js +55 -13
- package/lib/components/ButtonMenu/ButtonMenu.js +1 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +317 -134
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +112 -70
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +24 -5
- package/lib/components/DataSpreadsheet/checkActiveHeaderCell.js +45 -0
- package/lib/components/DataSpreadsheet/createActiveCellFn.js +3 -1
- package/lib/components/InlineEdit/InlineEdit.js +10 -20
- package/lib/components/OptionsTile/OptionsTile.js +11 -1
- package/lib/components/PageHeader/PageHeader.js +47 -40
- package/lib/components/PageHeader/PageHeaderUtils.js +3 -7
- package/lib/components/TagSet/TagSet.js +13 -3
- package/lib/components/UserProfileImage/UserProfileImage.js +2 -1
- package/package.json +14 -14
- package/scss/components/AddSelect/_add-select.scss +27 -14
- package/scss/components/CreateInfluencer/_create-influencer.scss +2 -0
- package/scss/components/CreateModal/_create-modal.scss +1 -0
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
- package/scss/components/CreateTearsheetNarrow/_create-tearsheet-narrow.scss +1 -0
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +12 -7
- package/scss/components/InlineEdit/_inline-edit.scss +20 -11
- package/scss/components/InlineEdit/_storybook-styles.scss +1 -0
- package/scss/components/LoadingBar/_loading-bar.scss +13 -0
- package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -0
- package/scss/components/PageHeader/_page-header.scss +2 -0
- package/scss/components/SidePanel/_side-panel.scss +11 -4
- package/scss/components/StatusIcon/_status-icon.scss +1 -0
- package/scss/components/UserProfileImage/_user-profile-image.scss +9 -0
- package/scss/components/WebTerminal/_web-terminal.scss +2 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
3
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
3
4
|
|
4
5
|
/**
|
@@ -7,7 +8,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
7
8
|
* This source code is licensed under the Apache-2.0 license found in the
|
8
9
|
* LICENSE file in the root directory of this source tree.
|
9
10
|
*/
|
10
|
-
import React, { useRef, useCallback, useEffect } from 'react';
|
11
|
+
import React, { useRef, useCallback, useEffect, forwardRef } from 'react';
|
11
12
|
import PropTypes from 'prop-types';
|
12
13
|
import { FixedSizeList } from 'react-window';
|
13
14
|
import cx from 'classnames';
|
@@ -15,9 +16,11 @@ import { pkg } from '../../settings';
|
|
15
16
|
import { deepCloneObject } from '../../global/js/utils/deepCloneObject';
|
16
17
|
import uuidv4 from '../../global/js/utils/uuidv4';
|
17
18
|
import { createCellSelectionArea } from './createCellSelectionArea';
|
19
|
+
import { checkActiveHeaderCell } from './checkActiveHeaderCell';
|
18
20
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
19
|
-
export var DataSpreadsheetBody = function
|
20
|
-
var
|
21
|
+
export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
22
|
+
var activeCellCoordinates = _ref.activeCellCoordinates,
|
23
|
+
defaultColumn = _ref.defaultColumn,
|
21
24
|
getTableBodyProps = _ref.getTableBodyProps,
|
22
25
|
id = _ref.id,
|
23
26
|
prepareRow = _ref.prepareRow,
|
@@ -32,7 +35,8 @@ export var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
32
35
|
setClickAndHoldActive = _ref.setClickAndHoldActive,
|
33
36
|
currentMatcher = _ref.currentMatcher,
|
34
37
|
setCurrentMatcher = _ref.setCurrentMatcher;
|
35
|
-
// Create cell selection areas based on selectionAreas array
|
38
|
+
var currentMatcherRef = ref; // Create cell selection areas based on selectionAreas array
|
39
|
+
|
36
40
|
useEffect(function () {
|
37
41
|
if (selectionAreas && selectionAreas.length) {
|
38
42
|
selectionAreas.map(function (area) {
|
@@ -72,7 +76,6 @@ export var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
72
76
|
row: Number(cellButton.getAttribute('data-row-index')),
|
73
77
|
column: Number(cellButton.getAttribute('data-column-index'))
|
74
78
|
};
|
75
|
-
setCurrentMatcher(null);
|
76
79
|
setSelectionAreas(function (prev) {
|
77
80
|
var selectionAreaClone = deepCloneObject(prev);
|
78
81
|
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
@@ -97,11 +100,16 @@ export var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
97
100
|
return;
|
98
101
|
}
|
99
102
|
|
100
|
-
var
|
101
|
-
return item.matcher
|
103
|
+
var notYetCreatedSelections = selectionAreaClone.filter(function (item) {
|
104
|
+
return !item.areaCreated && item.matcher === currentMatcher;
|
102
105
|
});
|
103
|
-
|
104
|
-
|
106
|
+
var previouslyCreatedSelectionAreas = selectionAreaClone.filter(function (item) {
|
107
|
+
return item.point2 && item.areaCreated;
|
108
|
+
}); // We want to ensure that there is only ever one item in selectionAreas
|
109
|
+
// that has not been created yet. This item's point1 values will always
|
110
|
+
// be equal to the activeCellCoordinates
|
111
|
+
|
112
|
+
setSelectionAreas([].concat(_toConsumableArray(notYetCreatedSelections), _toConsumableArray(previouslyCreatedSelectionAreas)));
|
105
113
|
}
|
106
114
|
};
|
107
115
|
|
@@ -109,7 +117,7 @@ export var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
109
117
|
return function () {
|
110
118
|
document.removeEventListener('mouseup', handleMouseUp);
|
111
119
|
};
|
112
|
-
}, [selectionAreas, currentMatcher, setSelectionAreas, setClickAndHoldActive, setCurrentMatcher]); // Make sure that if the cellSize prop changes, the active
|
120
|
+
}, [selectionAreas, currentMatcher, setSelectionAreas, setClickAndHoldActive, setCurrentMatcher, ref]); // Make sure that if the cellSize prop changes, the active
|
113
121
|
// cell also gets updated with the new size
|
114
122
|
|
115
123
|
useEffect(function () {
|
@@ -122,67 +130,99 @@ export var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
122
130
|
}, [defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight]); // onClick fn for each cell in the data spreadsheet body,
|
123
131
|
// adds the active cell highlight
|
124
132
|
|
125
|
-
var handleBodyCellClick = useCallback(function (
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
var tempMatcher = uuidv4();
|
133
|
-
setActiveCellCoordinates(activeCoordinates); // prevent multiple selections unless cmd key is held
|
134
|
-
// meaning that selectionAreas should only have one item by default
|
135
|
-
|
136
|
-
if (isHoldingCommandKey) {
|
137
|
-
setSelectionAreas(function (prev) {
|
138
|
-
return [].concat(_toConsumableArray(prev), [{
|
139
|
-
point1: activeCoordinates,
|
140
|
-
matcher: tempMatcher
|
141
|
-
}]);
|
142
|
-
});
|
143
|
-
} else {
|
144
|
-
// remove all previous cell selections
|
145
|
-
var cellSelections = spreadsheetBodyRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
|
146
|
-
Array.from(cellSelections).forEach(function (element) {
|
147
|
-
return element.remove();
|
148
|
-
});
|
149
|
-
setSelectionAreas([{
|
150
|
-
point1: activeCoordinates,
|
151
|
-
matcher: tempMatcher
|
152
|
-
}]);
|
153
|
-
}
|
154
|
-
|
155
|
-
setCurrentMatcher(tempMatcher);
|
156
|
-
setClickAndHoldActive(true);
|
157
|
-
}, [setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher]);
|
158
|
-
var handleBodyCellHover = useCallback(function (event, cell, columnIndex) {
|
159
|
-
if (clickAndHoldActive) {
|
160
|
-
var cellCoordinates = {
|
133
|
+
var handleBodyCellClick = useCallback(function (cell, columnIndex) {
|
134
|
+
return function (event) {
|
135
|
+
event.preventDefault();
|
136
|
+
var isHoldingCommandKey = event.metaKey || event.ctrlKey;
|
137
|
+
var isHoldingShiftKey = event.shiftKey;
|
138
|
+
setContainerHasFocus(true);
|
139
|
+
var activeCoordinates = {
|
161
140
|
row: cell.row.index,
|
162
141
|
column: columnIndex
|
163
142
|
};
|
164
|
-
|
165
|
-
|
143
|
+
var tempMatcher = uuidv4(); // prevent multiple selections unless cmd key is held
|
144
|
+
// meaning that selectionAreas should only have one item by default
|
166
145
|
|
167
|
-
|
146
|
+
if (isHoldingCommandKey) {
|
147
|
+
setActiveCellCoordinates(activeCoordinates);
|
148
|
+
setCurrentMatcher(tempMatcher);
|
149
|
+
setSelectionAreas(function (prev) {
|
150
|
+
return [].concat(_toConsumableArray(prev), [{
|
151
|
+
point1: activeCoordinates,
|
152
|
+
matcher: tempMatcher
|
153
|
+
}]);
|
154
|
+
});
|
155
|
+
} else if (isHoldingShiftKey) {
|
156
|
+
setContainerHasFocus(true);
|
157
|
+
var selectionAreaClone = deepCloneObject(selectionAreas);
|
168
158
|
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
169
159
|
return item.matcher === currentMatcher;
|
170
|
-
});
|
160
|
+
});
|
171
161
|
|
172
162
|
if (indexOfItemToUpdate === -1) {
|
173
|
-
|
174
|
-
|
163
|
+
// There is always a selectionArea with a point1 object that updates
|
164
|
+
// whenever the activeCellCoordinates update, we should always be able
|
165
|
+
// to find an index, but if we do not for some reason we should return
|
166
|
+
// at this point.
|
167
|
+
return;
|
168
|
+
} else {
|
169
|
+
// Update the selectionArea that was found, do not update currentMatcher
|
170
|
+
selectionAreaClone[indexOfItemToUpdate].point1 = activeCellCoordinates;
|
171
|
+
selectionAreaClone[indexOfItemToUpdate].point2 = activeCoordinates;
|
172
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
173
|
+
selectionAreaClone[indexOfItemToUpdate].matcher = currentMatcher;
|
174
|
+
setSelectionAreas(selectionAreaClone);
|
175
|
+
}
|
176
|
+
} else {
|
177
|
+
setActiveCellCoordinates(activeCoordinates); // remove all previous cell selections
|
175
178
|
|
179
|
+
var cellSelections = spreadsheetBodyRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
|
176
180
|
|
177
|
-
|
178
|
-
return
|
179
|
-
}
|
181
|
+
_toConsumableArray(cellSelections).forEach(function (element) {
|
182
|
+
return element.remove();
|
183
|
+
});
|
180
184
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
185
|
+
setSelectionAreas([{
|
186
|
+
point1: activeCoordinates,
|
187
|
+
matcher: tempMatcher
|
188
|
+
}]);
|
189
|
+
setCurrentMatcher(tempMatcher);
|
190
|
+
}
|
191
|
+
|
192
|
+
currentMatcherRef.current = tempMatcher;
|
193
|
+
setClickAndHoldActive(true);
|
194
|
+
};
|
195
|
+
}, [currentMatcherRef, currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher]);
|
196
|
+
var handleBodyCellHover = useCallback(function (cell, columnIndex) {
|
197
|
+
return function () {
|
198
|
+
if (clickAndHoldActive) {
|
199
|
+
var cellCoordinates = {
|
200
|
+
row: cell.row.index,
|
201
|
+
column: columnIndex
|
202
|
+
};
|
203
|
+
setSelectionAreas(function (prev) {
|
204
|
+
var _selectionAreaClone$i, _selectionAreaClone$i2;
|
205
|
+
|
206
|
+
var selectionAreaClone = deepCloneObject(prev);
|
207
|
+
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
208
|
+
return item.matcher === currentMatcher;
|
209
|
+
}); // No items in the array match up with the currentMatcher value
|
210
|
+
|
211
|
+
if (indexOfItemToUpdate === -1) {
|
212
|
+
return prev;
|
213
|
+
} // Do not update state if you're still hovering on the same cell
|
214
|
+
|
215
|
+
|
216
|
+
if (((_selectionAreaClone$i = selectionAreaClone[indexOfItemToUpdate].point2) === null || _selectionAreaClone$i === void 0 ? void 0 : _selectionAreaClone$i.row) === cellCoordinates.row && ((_selectionAreaClone$i2 = selectionAreaClone[indexOfItemToUpdate].point2) === null || _selectionAreaClone$i2 === void 0 ? void 0 : _selectionAreaClone$i2.column) === cellCoordinates.column) {
|
217
|
+
return prev;
|
218
|
+
}
|
219
|
+
|
220
|
+
selectionAreaClone[indexOfItemToUpdate].point2 = cellCoordinates;
|
221
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
222
|
+
return selectionAreaClone;
|
223
|
+
});
|
224
|
+
}
|
225
|
+
};
|
186
226
|
}, [clickAndHoldActive, currentMatcher, setSelectionAreas]); // Renders each cell in the spreadsheet body
|
187
227
|
|
188
228
|
var RenderRow = useCallback(function (_ref2) {
|
@@ -200,7 +240,7 @@ export var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
200
240
|
"data-row-index": index,
|
201
241
|
"data-column-index": "header",
|
202
242
|
type: "button",
|
203
|
-
className: cx("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th"), "".concat(blockClass, "--interactive-cell-element")),
|
243
|
+
className: cx("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th"), "".concat(blockClass, "--interactive-cell-element"), _defineProperty({}, "".concat(blockClass, "__td-th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === index || checkActiveHeaderCell(index, selectionAreas, 'row'))),
|
204
244
|
style: {
|
205
245
|
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
|
206
246
|
}
|
@@ -212,17 +252,13 @@ export var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
212
252
|
}, cell.getCellProps(), {
|
213
253
|
className: cx("".concat(blockClass, "__td"), "".concat(blockClass, "__body--td"), "".concat(blockClass, "--interactive-cell-element")),
|
214
254
|
key: "cell_".concat(index),
|
215
|
-
onMouseDown:
|
216
|
-
|
217
|
-
},
|
218
|
-
onMouseOver: function onMouseOver(event) {
|
219
|
-
return handleBodyCellHover(event, cell, index);
|
220
|
-
},
|
255
|
+
onMouseDown: handleBodyCellClick(cell, index),
|
256
|
+
onMouseOver: handleBodyCellHover(cell, index),
|
221
257
|
onFocus: function onFocus() {},
|
222
258
|
type: "button"
|
223
259
|
}), cell.render('Cell'));
|
224
260
|
}));
|
225
|
-
}, [prepareRow, rows, defaultColumn.rowHeaderWidth, handleBodyCellClick, handleBodyCellHover]);
|
261
|
+
}, [prepareRow, rows, defaultColumn.rowHeaderWidth, handleBodyCellClick, handleBodyCellHover, activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, selectionAreas]);
|
226
262
|
var spreadsheetBodyRef = useRef();
|
227
263
|
return /*#__PURE__*/React.createElement("div", _extends({
|
228
264
|
ref: spreadsheetBodyRef,
|
@@ -234,8 +270,16 @@ export var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
234
270
|
itemSize: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
235
271
|
width: totalColumnsWidth + scrollBarSize
|
236
272
|
}, RenderRow));
|
237
|
-
};
|
273
|
+
});
|
238
274
|
DataSpreadsheetBody.propTypes = {
|
275
|
+
/**
|
276
|
+
* Object containing the active cell coordinates
|
277
|
+
*/
|
278
|
+
activeCellCoordinates: PropTypes.shape({
|
279
|
+
row: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
280
|
+
column: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
281
|
+
}),
|
282
|
+
|
239
283
|
/**
|
240
284
|
* Is the user clicking and holding in the data spreadsheet body
|
241
285
|
*/
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
3
|
|
3
4
|
/**
|
4
5
|
* Copyright IBM Corp. 2022, 2022
|
@@ -10,10 +11,13 @@ import React from 'react';
|
|
10
11
|
import PropTypes from 'prop-types';
|
11
12
|
import cx from 'classnames';
|
12
13
|
import { pkg } from '../../settings';
|
14
|
+
import { checkActiveHeaderCell } from './checkActiveHeaderCell';
|
13
15
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
14
16
|
export var DataSpreadsheetHeader = function DataSpreadsheetHeader(_ref) {
|
15
|
-
var
|
16
|
-
|
17
|
+
var activeCellCoordinates = _ref.activeCellCoordinates,
|
18
|
+
defaultColumn = _ref.defaultColumn,
|
19
|
+
headerGroups = _ref.headerGroups,
|
20
|
+
selectionAreas = _ref.selectionAreas;
|
17
21
|
return /*#__PURE__*/React.createElement("div", {
|
18
22
|
className: cx("".concat(blockClass, "__header--container"))
|
19
23
|
}, headerGroups.map(function (headerGroup, index) {
|
@@ -26,7 +30,7 @@ export var DataSpreadsheetHeader = function DataSpreadsheetHeader(_ref) {
|
|
26
30
|
"data-column-index": "header",
|
27
31
|
type: "button",
|
28
32
|
tabIndex: -1,
|
29
|
-
className: cx("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element")),
|
33
|
+
className: cx("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), _defineProperty({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header')),
|
30
34
|
style: {
|
31
35
|
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth,
|
32
36
|
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
@@ -41,13 +45,21 @@ export var DataSpreadsheetHeader = function DataSpreadsheetHeader(_ref) {
|
|
41
45
|
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
42
46
|
}
|
43
47
|
}, column.getHeaderProps(), {
|
44
|
-
className: cx("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element")),
|
48
|
+
className: cx("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), _defineProperty({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === index || checkActiveHeaderCell(index, selectionAreas, 'column'))),
|
45
49
|
type: "button"
|
46
50
|
}), column.render('Header'));
|
47
51
|
}));
|
48
52
|
}));
|
49
53
|
};
|
50
54
|
DataSpreadsheetHeader.propTypes = {
|
55
|
+
/**
|
56
|
+
* Object containing the active cell coordinates
|
57
|
+
*/
|
58
|
+
activeCellCoordinates: PropTypes.shape({
|
59
|
+
row: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
60
|
+
column: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
61
|
+
}),
|
62
|
+
|
51
63
|
/**
|
52
64
|
* Default spreadsheet sizing values
|
53
65
|
*/
|
@@ -60,5 +72,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
60
72
|
/**
|
61
73
|
* Headers provided from useTable hook
|
62
74
|
*/
|
63
|
-
headerGroups: PropTypes.arrayOf(PropTypes.object)
|
75
|
+
headerGroups: PropTypes.arrayOf(PropTypes.object),
|
76
|
+
|
77
|
+
/**
|
78
|
+
* All of the cell selection area items
|
79
|
+
*/
|
80
|
+
selectionAreas: PropTypes.arrayOf(PropTypes.object)
|
64
81
|
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Copyright IBM Corp. 2022, 2022
|
5
|
+
*
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
import { deepCloneObject } from '../../global/js/utils/deepCloneObject'; // Determines if a row or column header cell should receive a highlight/active background color
|
10
|
+
// Check each object in selectionAreas and see if the headerIndex is between
|
11
|
+
// point1.row and point2.row, inclusive
|
12
|
+
|
13
|
+
export var checkActiveHeaderCell = function checkActiveHeaderCell(headerIndex, selectionAreas, headerType) {
|
14
|
+
var areasCloned = deepCloneObject(selectionAreas);
|
15
|
+
var activeRowIndexes = [];
|
16
|
+
areasCloned.forEach(function (area) {
|
17
|
+
var _area$point, _area$point2, _area$point3, _area$point4;
|
18
|
+
|
19
|
+
var greatestRowIndex = Math.max((_area$point = area.point1) === null || _area$point === void 0 ? void 0 : _area$point[headerType], (_area$point2 = area.point2) === null || _area$point2 === void 0 ? void 0 : _area$point2[headerType]);
|
20
|
+
var lowestRowIndex = Math.min((_area$point3 = area.point1) === null || _area$point3 === void 0 ? void 0 : _area$point3[headerType], (_area$point4 = area.point2) === null || _area$point4 === void 0 ? void 0 : _area$point4[headerType]);
|
21
|
+
|
22
|
+
for (var i = lowestRowIndex; i <= greatestRowIndex; i++) {
|
23
|
+
activeRowIndexes.push(i);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
|
27
|
+
var activeRowIndexesNoDuplicates = _toConsumableArray(new Set(activeRowIndexes));
|
28
|
+
|
29
|
+
if (areasCloned !== null && areasCloned !== void 0 && areasCloned.length && activeRowIndexesNoDuplicates.includes(headerIndex)) {
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
|
33
|
+
return false;
|
34
|
+
};
|
@@ -15,7 +15,8 @@ export var createActiveCellFn = function createActiveCellFn(_ref) {
|
|
15
15
|
_ref$blockClass = _ref.blockClass,
|
16
16
|
blockClass = _ref$blockClass === void 0 ? "".concat(pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
|
17
17
|
onActiveCellChange = _ref.onActiveCellChange,
|
18
|
-
activeCellValue = _ref.activeCellValue
|
18
|
+
activeCellValue = _ref.activeCellValue,
|
19
|
+
handleActiveCellMouseEnter = _ref.handleActiveCellMouseEnter;
|
19
20
|
|
20
21
|
if (!coords) {
|
21
22
|
return;
|
@@ -30,6 +31,7 @@ export var createActiveCellFn = function createActiveCellFn(_ref) {
|
|
30
31
|
};
|
31
32
|
var activeCellButton = (contextRef === null || contextRef === void 0 ? void 0 : contextRef.current.querySelector(".".concat(blockClass, "__active-cell--highlight"))) || document.createElement('button');
|
32
33
|
activeCellButton.classList.add("".concat(blockClass, "__active-cell--highlight"), "".concat(blockClass, "--interactive-cell-element"));
|
34
|
+
activeCellButton.addEventListener('mouseenter', handleActiveCellMouseEnter);
|
33
35
|
activeCellButton.style.width = px(placementElement === null || placementElement === void 0 ? void 0 : placementElement.offsetWidth);
|
34
36
|
activeCellButton.style.height = px(placementElement === null || placementElement === void 0 ? void 0 : placementElement.offsetHeight);
|
35
37
|
activeCellButton.style.left = px(relativePosition.left);
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
-
var _excluded = ["cancelDescription", "className", "disabled", "editAlwaysVisible", "editDescription", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value"
|
5
|
+
var _excluded = ["cancelDescription", "className", "disabled", "editAlwaysVisible", "editDescription", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value"];
|
6
6
|
|
7
7
|
/**
|
8
8
|
* Copyright IBM Corp. 2022, 2022
|
@@ -21,7 +21,7 @@ import { pkg, carbon } from '../../settings'; // Carbon and package components w
|
|
21
21
|
/* TODO: @import(s) of carbon components and other package components. */
|
22
22
|
|
23
23
|
import { Button } from 'carbon-components-react';
|
24
|
-
import { Close16, Edit16, EditOff16, Checkmark16, WarningFilled16
|
24
|
+
import { Close16, Edit16, EditOff16, Checkmark16, WarningFilled16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
|
25
25
|
|
26
26
|
var blockClass = "".concat(pkg.prefix, "--inline-edit");
|
27
27
|
var componentName = 'InlineEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
@@ -57,8 +57,6 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
57
57
|
_ref$size = _ref.size,
|
58
58
|
size = _ref$size === void 0 ? defaults.size : _ref$size,
|
59
59
|
value = _ref.value,
|
60
|
-
warn = _ref.warn,
|
61
|
-
warnText = _ref.warnText,
|
62
60
|
rest = _objectWithoutProperties(_ref, _excluded);
|
63
61
|
|
64
62
|
var refInput = useRef(null);
|
@@ -75,9 +73,11 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
75
73
|
internalValue = _useState4[0],
|
76
74
|
setInternalValue = _useState4[1];
|
77
75
|
|
78
|
-
var showValidation = invalid || warn;
|
79
|
-
|
80
|
-
var
|
76
|
+
var showValidation = invalid; // || warn;
|
77
|
+
|
78
|
+
var validationText = invalidText; // || warnText;
|
79
|
+
|
80
|
+
var validationIcon = showValidation ? /*#__PURE__*/React.createElement(WarningFilled16, null) : null;
|
81
81
|
|
82
82
|
var doSetEditing = function doSetEditing(value) {
|
83
83
|
if (value === false) {
|
@@ -229,7 +229,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
229
229
|
React.createElement("div", {
|
230
230
|
className: cx(blockClass, // Apply the block class to the main HTML element
|
231
231
|
className, // Apply any supplied class names to the main HTML element.
|
232
|
-
"".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--disabled"), disabled), _defineProperty(_cx, "".concat(blockClass, "--editing"), editing), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--
|
232
|
+
"".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--disabled"), disabled), _defineProperty(_cx, "".concat(blockClass, "--editing"), editing), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--light"), light), _defineProperty(_cx, "".concat(blockClass, "--overflows"), refInput.current && refInput.current.scrollWidth > refInput.current.offsetWidth), _cx)),
|
233
233
|
onClick: handleEdit // disabled eslint for click handler
|
234
234
|
,
|
235
235
|
onBlur: handleBlur,
|
@@ -359,14 +359,14 @@ InlineEdit.propTypes = {
|
|
359
359
|
/**
|
360
360
|
* method called on input event (it's a React thing onChange behaves like on input).
|
361
361
|
*
|
362
|
-
* NOTE: caller to handle invalid
|
362
|
+
* NOTE: caller to handle invalid states and associated text
|
363
363
|
*/
|
364
364
|
onChange: PropTypes.func,
|
365
365
|
|
366
366
|
/**
|
367
367
|
* method called on change event
|
368
368
|
*
|
369
|
-
* NOTE: caller to handle invalid
|
369
|
+
* NOTE: caller to handle invalid states and associated text
|
370
370
|
*/
|
371
371
|
onSave: PropTypes.func,
|
372
372
|
|
@@ -388,15 +388,5 @@ InlineEdit.propTypes = {
|
|
388
388
|
/**
|
389
389
|
* initial/unedited value
|
390
390
|
*/
|
391
|
-
value: PropTypes.string
|
392
|
-
|
393
|
-
/**
|
394
|
-
* set warn state for input
|
395
|
-
*/
|
396
|
-
warn: PropTypes.bool,
|
397
|
-
|
398
|
-
/**
|
399
|
-
* text shown when warn true
|
400
|
-
*/
|
401
|
-
warnText: PropTypes.string
|
391
|
+
value: PropTypes.string
|
402
392
|
};
|
@@ -185,9 +185,19 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
185
185
|
} else if (locked) {
|
186
186
|
Icon = Locked16;
|
187
187
|
summaryClasses.push("".concat(blockClass, "__summary--locked"));
|
188
|
+
|
189
|
+
if (!text) {
|
190
|
+
text = lockedText;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
var hasValidationState = invalid || warn || locked;
|
195
|
+
var summaryHidden = !hasValidationState && enabled === false;
|
196
|
+
|
197
|
+
if (summaryHidden) {
|
198
|
+
summaryClasses.push("".concat(blockClass, "__summary--hidden"));
|
188
199
|
}
|
189
200
|
|
190
|
-
var summaryHidden = enabled === false;
|
191
201
|
return /*#__PURE__*/React.createElement("div", {
|
192
202
|
className: "".concat(blockClass, "__title")
|
193
203
|
}, /*#__PURE__*/React.createElement("h6", {
|