@carbon/ibm-products 2.43.2-canary.45 → 2.43.2-canary.46
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/css/index-full-carbon.css +5 -2
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +5 -2
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +5 -2
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.d.ts +8 -0
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +25 -7
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +8 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +13 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheet.d.ts +8 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +25 -7
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.d.ts +8 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +13 -3
- package/package.json +3 -3
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +9 -2
@@ -32,7 +32,7 @@ import { useSpreadsheetOutsideClick } from './hooks/useSpreadsheetOutsideClick.j
|
|
32
32
|
import { useMoveActiveCell } from './hooks/useMoveActiveCell.js';
|
33
33
|
import { useSpreadsheetEdit } from './hooks/useSpreadsheetEdit.js';
|
34
34
|
|
35
|
-
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "renderRowHeader", "renderRowHeaderDirection", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
|
35
|
+
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "renderRowHeader", "renderRowHeaderDirection", "disableColumnSwapping", "readOnlyTable", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
|
36
36
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
37
37
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
38
38
|
var componentName = 'DataSpreadsheet';
|
@@ -69,6 +69,10 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
69
69
|
onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
|
70
70
|
renderRowHeader = _ref.renderRowHeader,
|
71
71
|
renderRowHeaderDirection = _ref.renderRowHeaderDirection,
|
72
|
+
_ref$disableColumnSwa = _ref.disableColumnSwapping,
|
73
|
+
disableColumnSwapping = _ref$disableColumnSwa === void 0 ? false : _ref$disableColumnSwa,
|
74
|
+
_ref$readOnlyTable = _ref.readOnlyTable,
|
75
|
+
readOnlyTable = _ref$readOnlyTable === void 0 ? false : _ref$readOnlyTable,
|
72
76
|
selectAllAriaLabel = _ref.selectAllAriaLabel,
|
73
77
|
spreadsheetAriaLabel = _ref.spreadsheetAriaLabel,
|
74
78
|
theme = _ref.theme,
|
@@ -427,8 +431,8 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
427
431
|
}
|
428
432
|
}, [handleInitialArrowPress, updateActiveCellCoordinates, activeCellCoordinates, columns, rows]);
|
429
433
|
var handleKeyPressEvent = useCallback(function (event) {
|
430
|
-
handleKeyPress(event, activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress, setSelectionAreas, setSelectionAreaData, setCurrentMatcher, activeCellRef, setActiveCellCoordinates, setContainerHasFocus, setActiveCellContent);
|
431
|
-
}, [activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress]);
|
434
|
+
handleKeyPress(event, activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress, setSelectionAreas, setSelectionAreaData, setCurrentMatcher, activeCellRef, setActiveCellCoordinates, setContainerHasFocus, setActiveCellContent, readOnlyTable);
|
435
|
+
}, [activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress, readOnlyTable]);
|
432
436
|
var startEditMode = function startEditMode() {
|
433
437
|
setIsEditing(true);
|
434
438
|
setClickAndHoldActive(false);
|
@@ -499,7 +503,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
499
503
|
// Go into edit mode if 'Enter' key is pressed on activeCellRef
|
500
504
|
var handleActiveCellKeyDown = function handleActiveCellKeyDown(event) {
|
501
505
|
var key = event.key;
|
502
|
-
if (key === 'Enter' && !activeCellInsideSelectionArea) {
|
506
|
+
if (key === 'Enter' && !activeCellInsideSelectionArea && !readOnlyTable) {
|
503
507
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
|
504
508
|
startEditMode();
|
505
509
|
}
|
@@ -555,8 +559,10 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
555
559
|
};
|
556
560
|
|
557
561
|
// Go into edit mode if double click is detected on activeCellRef
|
558
|
-
var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
|
559
|
-
|
562
|
+
var handleActiveCellDoubleClick = function handleActiveCellDoubleClick(readOnlyTable) {
|
563
|
+
if (!readOnlyTable) {
|
564
|
+
startEditMode();
|
565
|
+
}
|
560
566
|
};
|
561
567
|
useSpreadsheetEdit({
|
562
568
|
isEditing: isEditing,
|
@@ -636,6 +642,8 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
636
642
|
setSelectionAreas: setSelectionAreas,
|
637
643
|
setCurrentMatcher: setCurrentMatcher,
|
638
644
|
setSelectionAreaData: setSelectionAreaData,
|
645
|
+
disableColumnSwapping: disableColumnSwapping,
|
646
|
+
readOnlyTable: readOnlyTable,
|
639
647
|
totalVisibleColumns: totalVisibleColumns,
|
640
648
|
updateActiveCellCoordinates: updateActiveCellCoordinates,
|
641
649
|
setHeaderCellHoldActive: setHeaderCellHoldActive,
|
@@ -684,7 +692,9 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
684
692
|
onMouseUp: handleActiveCellMouseUp,
|
685
693
|
onClick: handleActiveCellClick,
|
686
694
|
onKeyDown: handleActiveCellKeyDown,
|
687
|
-
onDoubleClick:
|
695
|
+
onDoubleClick: function onDoubleClick() {
|
696
|
+
return handleActiveCellDoubleClick(readOnlyTable);
|
697
|
+
},
|
688
698
|
onMouseEnter: handleActiveCellMouseEnter,
|
689
699
|
ref: activeCellRef,
|
690
700
|
className: cx("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight"), _defineProperty({}, "".concat(blockClass, "__active-cell--with-selection"), activeCellInsideSelectionArea)),
|
@@ -760,6 +770,10 @@ DataSpreadsheet.propTypes = {
|
|
760
770
|
* Sets the number of empty rows to be created when there is no data provided
|
761
771
|
*/
|
762
772
|
defaultEmptyRowCount: PropTypes.number,
|
773
|
+
/**
|
774
|
+
* Disable column swapping, default false
|
775
|
+
*/
|
776
|
+
disableColumnSwapping: PropTypes.bool,
|
763
777
|
/**
|
764
778
|
* Check if spreadsheet is using custom row header component attached
|
765
779
|
*/
|
@@ -780,6 +794,10 @@ DataSpreadsheet.propTypes = {
|
|
780
794
|
* The event handler that is called when the selection area values change
|
781
795
|
*/
|
782
796
|
onSelectionAreaChange: PropTypes.func,
|
797
|
+
/**
|
798
|
+
* Read-only table
|
799
|
+
*/
|
800
|
+
readOnlyTable: PropTypes.bool,
|
783
801
|
/**
|
784
802
|
* Component next to numbering rows
|
785
803
|
*/
|
@@ -16,6 +16,10 @@ interface DataSpreadsheetHeaderProps {
|
|
16
16
|
* Specifies the cell height
|
17
17
|
*/
|
18
18
|
cellSize?: Size;
|
19
|
+
/**
|
20
|
+
* Disable column swapping, default false
|
21
|
+
*/
|
22
|
+
disableColumnSwapping?: boolean;
|
19
23
|
/**
|
20
24
|
* All of the spreadsheet columns
|
21
25
|
*/
|
@@ -36,6 +40,10 @@ interface DataSpreadsheetHeaderProps {
|
|
36
40
|
* Headers provided from useTable hook
|
37
41
|
*/
|
38
42
|
headerGroups?: any[];
|
43
|
+
/**
|
44
|
+
* Read-only table
|
45
|
+
*/
|
46
|
+
readOnlyTable?: boolean;
|
39
47
|
/**
|
40
48
|
* All of the spreadsheet row data
|
41
49
|
*/
|
@@ -36,6 +36,8 @@ var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
36
36
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
37
37
|
setCurrentMatcher = _ref.setCurrentMatcher,
|
38
38
|
setSelectionAreas = _ref.setSelectionAreas,
|
39
|
+
readOnlyTable = _ref.readOnlyTable,
|
40
|
+
disableColumnSwapping = _ref.disableColumnSwapping,
|
39
41
|
setSelectionAreaData = _ref.setSelectionAreaData,
|
40
42
|
rows = _ref.rows,
|
41
43
|
totalVisibleColumns = _ref.totalVisibleColumns,
|
@@ -194,8 +196,8 @@ var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
194
196
|
"data-row-index": "header",
|
195
197
|
"data-column-index": index,
|
196
198
|
tabIndex: -1,
|
197
|
-
onMouseDown: selectedHeader ? handleHeaderMouseDown(index) : undefined,
|
198
|
-
onMouseUp: selectedHeader && typeof setSelectedHeaderReorderActive === 'function' ? function () {
|
199
|
+
onMouseDown: selectedHeader && !readOnlyTable && !disableColumnSwapping ? handleHeaderMouseDown(index) : undefined,
|
200
|
+
onMouseUp: selectedHeader && !readOnlyTable && !disableColumnSwapping && typeof setSelectedHeaderReorderActive === 'function' ? function () {
|
199
201
|
return setSelectedHeaderReorderActive(false);
|
200
202
|
} : undefined,
|
201
203
|
onClick: !selectedHeader ? handleColumnHeaderClick(index) : undefined,
|
@@ -203,7 +205,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
203
205
|
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
204
206
|
width: (column === null || column === void 0 ? void 0 : column.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width)
|
205
207
|
},
|
206
|
-
className: cx("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), _defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === index || checkActiveHeaderCell(index, selectionAreas, 'column')), "".concat(blockClass, "__th--selected-header"), selectedHeader), "".concat(blockClass, "__th--selected-header-reorder-active"), selectedHeaderReorderActive)),
|
208
|
+
className: cx("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === index || checkActiveHeaderCell(index, selectionAreas, 'column')), "".concat(blockClass, "__th--active-header-disabledSwapping"), disableColumnSwapping || readOnlyTable), "".concat(blockClass, "__th--selected-header"), selectedHeader), "".concat(blockClass, "__th--selected-header-reorder-active"), selectedHeaderReorderActive)),
|
207
209
|
type: "button"
|
208
210
|
}, column.render('Header')));
|
209
211
|
}));
|
@@ -239,6 +241,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
239
241
|
rowHeaderWidth: PropTypes.number,
|
240
242
|
width: PropTypes.number
|
241
243
|
}),
|
244
|
+
/**
|
245
|
+
* Disable column swapping, default false
|
246
|
+
*/
|
247
|
+
disableColumnSwapping: PropTypes.bool,
|
242
248
|
/**
|
243
249
|
* Whether or not a click/hold is active on a header cell
|
244
250
|
*/
|
@@ -247,6 +253,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
247
253
|
* Headers provided from useTable hook
|
248
254
|
*/
|
249
255
|
headerGroups: PropTypes.arrayOf(PropTypes.object),
|
256
|
+
/**
|
257
|
+
* Read-only table
|
258
|
+
*/
|
259
|
+
readOnlyTable: PropTypes.bool,
|
250
260
|
/**
|
251
261
|
* All of the spreadsheet row data
|
252
262
|
*/
|
@@ -20,6 +20,10 @@ interface DataSpreadsheetProps {
|
|
20
20
|
* The data that will build the column headers
|
21
21
|
*/
|
22
22
|
columns?: readonly Column<object>[];
|
23
|
+
/**
|
24
|
+
* Disable column swapping, default false
|
25
|
+
*/
|
26
|
+
disableColumnSwapping?: boolean;
|
23
27
|
/**
|
24
28
|
* The spreadsheet data that will be rendered in the body of the spreadsheet component
|
25
29
|
*/
|
@@ -50,6 +54,10 @@ interface DataSpreadsheetProps {
|
|
50
54
|
* The event handler that is called when the selection area values change
|
51
55
|
*/
|
52
56
|
onSelectionAreaChange?: () => void;
|
57
|
+
/**
|
58
|
+
* Read-only table
|
59
|
+
*/
|
60
|
+
readOnlyTable?: boolean;
|
53
61
|
/**
|
54
62
|
* Position of the custom row numbering component
|
55
63
|
*/
|
@@ -41,7 +41,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
41
41
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
42
42
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
43
43
|
|
44
|
-
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "renderRowHeader", "renderRowHeaderDirection", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
|
44
|
+
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "renderRowHeader", "renderRowHeaderDirection", "disableColumnSwapping", "readOnlyTable", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
|
45
45
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
46
46
|
var blockClass = "".concat(settings.pkg.prefix, "--data-spreadsheet");
|
47
47
|
var componentName = 'DataSpreadsheet';
|
@@ -78,6 +78,10 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
|
|
78
78
|
onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
|
79
79
|
renderRowHeader = _ref.renderRowHeader,
|
80
80
|
renderRowHeaderDirection = _ref.renderRowHeaderDirection,
|
81
|
+
_ref$disableColumnSwa = _ref.disableColumnSwapping,
|
82
|
+
disableColumnSwapping = _ref$disableColumnSwa === void 0 ? false : _ref$disableColumnSwa,
|
83
|
+
_ref$readOnlyTable = _ref.readOnlyTable,
|
84
|
+
readOnlyTable = _ref$readOnlyTable === void 0 ? false : _ref$readOnlyTable,
|
81
85
|
selectAllAriaLabel = _ref.selectAllAriaLabel,
|
82
86
|
spreadsheetAriaLabel = _ref.spreadsheetAriaLabel,
|
83
87
|
theme = _ref.theme,
|
@@ -436,8 +440,8 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
|
|
436
440
|
}
|
437
441
|
}, [handleInitialArrowPress, updateActiveCellCoordinates, activeCellCoordinates, columns, rows]);
|
438
442
|
var handleKeyPressEvent = React.useCallback(function (event) {
|
439
|
-
commonEventHandlers.handleKeyPress(event, activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress, setSelectionAreas, setSelectionAreaData, setCurrentMatcher, activeCellRef, setActiveCellCoordinates, setContainerHasFocus, setActiveCellContent);
|
440
|
-
}, [activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress]);
|
443
|
+
commonEventHandlers.handleKeyPress(event, activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress, setSelectionAreas, setSelectionAreaData, setCurrentMatcher, activeCellRef, setActiveCellCoordinates, setContainerHasFocus, setActiveCellContent, readOnlyTable);
|
444
|
+
}, [activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress, readOnlyTable]);
|
441
445
|
var startEditMode = function startEditMode() {
|
442
446
|
setIsEditing(true);
|
443
447
|
setClickAndHoldActive(false);
|
@@ -508,7 +512,7 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
|
|
508
512
|
// Go into edit mode if 'Enter' key is pressed on activeCellRef
|
509
513
|
var handleActiveCellKeyDown = function handleActiveCellKeyDown(event) {
|
510
514
|
var key = event.key;
|
511
|
-
if (key === 'Enter' && !activeCellInsideSelectionArea) {
|
515
|
+
if (key === 'Enter' && !activeCellInsideSelectionArea && !readOnlyTable) {
|
512
516
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
|
513
517
|
startEditMode();
|
514
518
|
}
|
@@ -564,8 +568,10 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
|
|
564
568
|
};
|
565
569
|
|
566
570
|
// Go into edit mode if double click is detected on activeCellRef
|
567
|
-
var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
|
568
|
-
|
571
|
+
var handleActiveCellDoubleClick = function handleActiveCellDoubleClick(readOnlyTable) {
|
572
|
+
if (!readOnlyTable) {
|
573
|
+
startEditMode();
|
574
|
+
}
|
569
575
|
};
|
570
576
|
useSpreadsheetEdit.useSpreadsheetEdit({
|
571
577
|
isEditing: isEditing,
|
@@ -645,6 +651,8 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
|
|
645
651
|
setSelectionAreas: setSelectionAreas,
|
646
652
|
setCurrentMatcher: setCurrentMatcher,
|
647
653
|
setSelectionAreaData: setSelectionAreaData,
|
654
|
+
disableColumnSwapping: disableColumnSwapping,
|
655
|
+
readOnlyTable: readOnlyTable,
|
648
656
|
totalVisibleColumns: totalVisibleColumns,
|
649
657
|
updateActiveCellCoordinates: updateActiveCellCoordinates,
|
650
658
|
setHeaderCellHoldActive: setHeaderCellHoldActive,
|
@@ -693,7 +701,9 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
|
|
693
701
|
onMouseUp: handleActiveCellMouseUp,
|
694
702
|
onClick: handleActiveCellClick,
|
695
703
|
onKeyDown: handleActiveCellKeyDown,
|
696
|
-
onDoubleClick:
|
704
|
+
onDoubleClick: function onDoubleClick() {
|
705
|
+
return handleActiveCellDoubleClick(readOnlyTable);
|
706
|
+
},
|
697
707
|
onMouseEnter: handleActiveCellMouseEnter,
|
698
708
|
ref: activeCellRef,
|
699
709
|
className: cx__default["default"]("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__active-cell--with-selection"), activeCellInsideSelectionArea)),
|
@@ -769,6 +779,10 @@ exports.DataSpreadsheet.propTypes = {
|
|
769
779
|
* Sets the number of empty rows to be created when there is no data provided
|
770
780
|
*/
|
771
781
|
defaultEmptyRowCount: index["default"].number,
|
782
|
+
/**
|
783
|
+
* Disable column swapping, default false
|
784
|
+
*/
|
785
|
+
disableColumnSwapping: index["default"].bool,
|
772
786
|
/**
|
773
787
|
* Check if spreadsheet is using custom row header component attached
|
774
788
|
*/
|
@@ -789,6 +803,10 @@ exports.DataSpreadsheet.propTypes = {
|
|
789
803
|
* The event handler that is called when the selection area values change
|
790
804
|
*/
|
791
805
|
onSelectionAreaChange: index["default"].func,
|
806
|
+
/**
|
807
|
+
* Read-only table
|
808
|
+
*/
|
809
|
+
readOnlyTable: index["default"].bool,
|
792
810
|
/**
|
793
811
|
* Component next to numbering rows
|
794
812
|
*/
|
@@ -16,6 +16,10 @@ interface DataSpreadsheetHeaderProps {
|
|
16
16
|
* Specifies the cell height
|
17
17
|
*/
|
18
18
|
cellSize?: Size;
|
19
|
+
/**
|
20
|
+
* Disable column swapping, default false
|
21
|
+
*/
|
22
|
+
disableColumnSwapping?: boolean;
|
19
23
|
/**
|
20
24
|
* All of the spreadsheet columns
|
21
25
|
*/
|
@@ -36,6 +40,10 @@ interface DataSpreadsheetHeaderProps {
|
|
36
40
|
* Headers provided from useTable hook
|
37
41
|
*/
|
38
42
|
headerGroups?: any[];
|
43
|
+
/**
|
44
|
+
* Read-only table
|
45
|
+
*/
|
46
|
+
readOnlyTable?: boolean;
|
39
47
|
/**
|
40
48
|
* All of the spreadsheet row data
|
41
49
|
*/
|
@@ -45,6 +45,8 @@ var DataSpreadsheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
45
45
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
46
46
|
setCurrentMatcher = _ref.setCurrentMatcher,
|
47
47
|
setSelectionAreas = _ref.setSelectionAreas,
|
48
|
+
readOnlyTable = _ref.readOnlyTable,
|
49
|
+
disableColumnSwapping = _ref.disableColumnSwapping,
|
48
50
|
setSelectionAreaData = _ref.setSelectionAreaData,
|
49
51
|
rows = _ref.rows,
|
50
52
|
totalVisibleColumns = _ref.totalVisibleColumns,
|
@@ -203,8 +205,8 @@ var DataSpreadsheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
203
205
|
"data-row-index": "header",
|
204
206
|
"data-column-index": index,
|
205
207
|
tabIndex: -1,
|
206
|
-
onMouseDown: selectedHeader ? handleHeaderMouseDown(index) : undefined,
|
207
|
-
onMouseUp: selectedHeader && typeof setSelectedHeaderReorderActive === 'function' ? function () {
|
208
|
+
onMouseDown: selectedHeader && !readOnlyTable && !disableColumnSwapping ? handleHeaderMouseDown(index) : undefined,
|
209
|
+
onMouseUp: selectedHeader && !readOnlyTable && !disableColumnSwapping && typeof setSelectedHeaderReorderActive === 'function' ? function () {
|
208
210
|
return setSelectedHeaderReorderActive(false);
|
209
211
|
} : undefined,
|
210
212
|
onClick: !selectedHeader ? handleColumnHeaderClick(index) : undefined,
|
@@ -212,7 +214,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
212
214
|
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
213
215
|
width: (column === null || column === void 0 ? void 0 : column.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width)
|
214
216
|
},
|
215
|
-
className: cx__default["default"]("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === index || checkActiveHeaderCell.checkActiveHeaderCell(index, selectionAreas, 'column')), "".concat(blockClass, "__th--selected-header"), selectedHeader), "".concat(blockClass, "__th--selected-header-reorder-active"), selectedHeaderReorderActive)),
|
217
|
+
className: cx__default["default"]("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === index || checkActiveHeaderCell.checkActiveHeaderCell(index, selectionAreas, 'column')), "".concat(blockClass, "__th--active-header-disabledSwapping"), disableColumnSwapping || readOnlyTable), "".concat(blockClass, "__th--selected-header"), selectedHeader), "".concat(blockClass, "__th--selected-header-reorder-active"), selectedHeaderReorderActive)),
|
216
218
|
type: "button"
|
217
219
|
}, column.render('Header')));
|
218
220
|
}));
|
@@ -248,6 +250,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
248
250
|
rowHeaderWidth: index["default"].number,
|
249
251
|
width: index["default"].number
|
250
252
|
}),
|
253
|
+
/**
|
254
|
+
* Disable column swapping, default false
|
255
|
+
*/
|
256
|
+
disableColumnSwapping: index["default"].bool,
|
251
257
|
/**
|
252
258
|
* Whether or not a click/hold is active on a header cell
|
253
259
|
*/
|
@@ -256,6 +262,10 @@ DataSpreadsheetHeader.propTypes = {
|
|
256
262
|
* Headers provided from useTable hook
|
257
263
|
*/
|
258
264
|
headerGroups: index["default"].arrayOf(index["default"].object),
|
265
|
+
/**
|
266
|
+
* Read-only table
|
267
|
+
*/
|
268
|
+
readOnlyTable: index["default"].bool,
|
259
269
|
/**
|
260
270
|
* All of the spreadsheet row data
|
261
271
|
*/
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "2.43.2-canary.
|
4
|
+
"version": "2.43.2-canary.46+93c82ccc9",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"dependencies": {
|
97
97
|
"@babel/runtime": "^7.23.9",
|
98
98
|
"@carbon/feature-flags": "^0.20.0",
|
99
|
-
"@carbon/ibm-products-styles": "^2.39.1-canary.
|
99
|
+
"@carbon/ibm-products-styles": "^2.39.1-canary.56+93c82ccc9",
|
100
100
|
"@carbon/telemetry": "^0.1.0",
|
101
101
|
"@dnd-kit/core": "^6.0.8",
|
102
102
|
"@dnd-kit/modifiers": "^7.0.0",
|
@@ -120,5 +120,5 @@
|
|
120
120
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
121
121
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
122
122
|
},
|
123
|
-
"gitHead": "
|
123
|
+
"gitHead": "93c82ccc9e7609074653ac762a24a134cc4d2f73"
|
124
124
|
}
|
@@ -259,7 +259,9 @@ $header-cell-background: $layer-accent-01;
|
|
259
259
|
background-color: $background-inverse;
|
260
260
|
}
|
261
261
|
}
|
262
|
-
.#{$block-class}__th--selected-header.#{$block-class}__th
|
262
|
+
.#{$block-class}__th--selected-header.#{$block-class}__th:not(
|
263
|
+
.#{$block-class}__th--active-header-disabledSwapping
|
264
|
+
) {
|
263
265
|
cursor: grab;
|
264
266
|
}
|
265
267
|
.#{$block-class}__th--selected-header-reorder-active.#{$block-class}__th {
|
@@ -275,6 +277,9 @@ $header-cell-background: $layer-accent-01;
|
|
275
277
|
width: $spacing-01;
|
276
278
|
background-color: $background-brand;
|
277
279
|
}
|
280
|
+
.#{$block-class}__th--active-header-disabledSwapping {
|
281
|
+
cursor: pointer;
|
282
|
+
}
|
278
283
|
.#{$block-class}__th--active-header,
|
279
284
|
.#{$block-class}__td-th--active-header.#{$block-class}__td {
|
280
285
|
background-color: $background-selected-hover;
|
@@ -290,7 +295,9 @@ $header-cell-background: $layer-accent-01;
|
|
290
295
|
background-color: $background-inverse;
|
291
296
|
}
|
292
297
|
}
|
293
|
-
.#{$block-class}__th--selected-header.#{$block-class}__th
|
298
|
+
.#{$block-class}__th--selected-header.#{$block-class}__th:not(
|
299
|
+
.#{$block-class}__th--active-header-disabledSwapping
|
300
|
+
) {
|
294
301
|
cursor: grab;
|
295
302
|
}
|
296
303
|
.#{$block-class}__th--selected-header-reorder-active.#{$block-class}__th {
|