@carbon/ibm-products 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/components/Datagrid/styles/datagrid.css +4 -0
- package/css/components/Datagrid/styles/datagrid.css.map +1 -1
- package/css/components/Datagrid/styles/index.css +5 -1
- package/css/components/Datagrid/styles/index.css.map +1 -1
- package/css/components/Datagrid/styles/useNestedRows.css +1 -1
- package/css/index-full-carbon.css +20 -4
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +20 -4
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +20 -4
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +10 -5
- package/es/components/AddSelect/AddSelectFilter.js +47 -4
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +12 -3
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +39 -7
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +20 -4
- package/es/components/DataSpreadsheet/utils/generateData.js +17 -9
- package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +30 -0
- package/es/components/Datagrid/Datagrid/DatagridRow.js +12 -2
- package/es/components/Datagrid/useNestedRows.js +3 -3
- package/es/components/Datagrid/useRowExpander.js +1 -1
- package/lib/components/AddSelect/AddSelect.js +10 -5
- package/lib/components/AddSelect/AddSelectFilter.js +46 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +12 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +40 -7
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +21 -5
- package/lib/components/DataSpreadsheet/utils/generateData.js +17 -9
- package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +40 -0
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +14 -2
- package/lib/components/Datagrid/useNestedRows.js +3 -3
- package/lib/components/Datagrid/useRowExpander.js +1 -1
- package/package.json +7 -7
- package/scss/components/AddSelect/_add-select.scss +9 -2
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +7 -1
- package/scss/components/Datagrid/styles/datagrid.scss +8 -0
- package/scss/components/Datagrid/styles/useNestedRows.scss +1 -1
@@ -3,7 +3,7 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
5
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
6
|
-
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
|
6
|
+
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "totalVisibleColumns"];
|
7
7
|
|
8
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
9
9
|
|
@@ -75,6 +75,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
75
75
|
onActiveCellChange = _ref$onActiveCellChan === void 0 ? defaults.onActiveCellChange : _ref$onActiveCellChan,
|
76
76
|
_ref$onSelectionAreaC = _ref.onSelectionAreaChange,
|
77
77
|
onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
|
78
|
+
totalVisibleColumns = _ref.totalVisibleColumns,
|
78
79
|
rest = _objectWithoutProperties(_ref, _excluded);
|
79
80
|
|
80
81
|
var multiKeyTrackingRef = useRef();
|
@@ -767,6 +768,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
767
768
|
setSelectionAreas: setSelectionAreas,
|
768
769
|
setCurrentMatcher: setCurrentMatcher,
|
769
770
|
setSelectionAreaData: setSelectionAreaData,
|
771
|
+
totalVisibleColumns: totalVisibleColumns,
|
770
772
|
updateActiveCellCoordinates: updateActiveCellCoordinates
|
771
773
|
}), /*#__PURE__*/React.createElement(DataSpreadsheetBody, {
|
772
774
|
activeCellCoordinates: activeCellCoordinates,
|
@@ -795,7 +797,8 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
795
797
|
id: id,
|
796
798
|
columns: columns,
|
797
799
|
defaultEmptyRowCount: defaultEmptyRowCount,
|
798
|
-
setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea
|
800
|
+
setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea,
|
801
|
+
totalVisibleColumns: totalVisibleColumns
|
799
802
|
}), /*#__PURE__*/React.createElement("button", {
|
800
803
|
onMouseDown: handleActiveCellMouseDown,
|
801
804
|
onClick: handleActiveCellClick,
|
@@ -891,7 +894,13 @@ DataSpreadsheet.propTypes = {
|
|
891
894
|
/**
|
892
895
|
* The event handler that is called when the selection area values change
|
893
896
|
*/
|
894
|
-
onSelectionAreaChange: PropTypes.func
|
897
|
+
onSelectionAreaChange: PropTypes.func,
|
898
|
+
|
899
|
+
/**
|
900
|
+
* The total number of columns to be initially visible, additional columns will be rendered and
|
901
|
+
* visible via horizontal scrollbar
|
902
|
+
*/
|
903
|
+
totalVisibleColumns: PropTypes.number
|
895
904
|
/* TODO: add types and DocGen for all props. */
|
896
905
|
|
897
906
|
};
|
@@ -25,6 +25,7 @@ import { removeCellSelections } from './utils/removeCellSelections';
|
|
25
25
|
import { createCellSelectionArea } from './utils/createCellSelectionArea';
|
26
26
|
import { checkActiveHeaderCell } from './utils/checkActiveHeaderCell';
|
27
27
|
import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection';
|
28
|
+
import { getSpreadsheetWidth } from './utils/getSpreadsheetWidth';
|
28
29
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
29
30
|
export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
30
31
|
var columns = _ref.columns,
|
@@ -50,7 +51,9 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
50
51
|
currentMatcher = _ref.currentMatcher,
|
51
52
|
setCurrentMatcher = _ref.setCurrentMatcher,
|
52
53
|
onSelectionAreaChange = _ref.onSelectionAreaChange,
|
53
|
-
setActiveCellInsideSelectionArea = _ref.setActiveCellInsideSelectionArea
|
54
|
+
setActiveCellInsideSelectionArea = _ref.setActiveCellInsideSelectionArea,
|
55
|
+
totalVisibleColumns = _ref.totalVisibleColumns;
|
56
|
+
var contentScrollRef = useRef();
|
54
57
|
var previousState = usePreviousValue({
|
55
58
|
selectionAreaData: selectionAreaData,
|
56
59
|
clickAndHoldActive: clickAndHoldActive
|
@@ -247,6 +250,21 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
247
250
|
}
|
248
251
|
};
|
249
252
|
}, [currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher, ref, setSelectionAreaData, setActiveCellInsideSelectionArea]);
|
253
|
+
|
254
|
+
var handleBodyScroll = function handleBodyScroll() {
|
255
|
+
var headerRowElement = ref.current.querySelector("\n .".concat(blockClass, "__header--container .").concat(blockClass, "__tr"));
|
256
|
+
headerRowElement.scrollLeft = contentScrollRef.current.scrollLeft;
|
257
|
+
};
|
258
|
+
|
259
|
+
useEffect(function () {
|
260
|
+
contentScrollRef.current.addEventListener('scroll', function (event) {
|
261
|
+
return handleBodyScroll(event);
|
262
|
+
});
|
263
|
+
var contentScrollElementRef = contentScrollRef.current;
|
264
|
+
return function () {
|
265
|
+
contentScrollElementRef.removeEventListener('scroll', handleBodyScroll);
|
266
|
+
};
|
267
|
+
});
|
250
268
|
var handleBodyCellHover = useCallback(function (cell, columnIndex) {
|
251
269
|
return function () {
|
252
270
|
if (clickAndHoldActive) {
|
@@ -339,7 +357,8 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
339
357
|
"data-row-index": index,
|
340
358
|
"aria-rowindex": index + 1
|
341
359
|
}), /*#__PURE__*/React.createElement("div", {
|
342
|
-
role: "rowheader"
|
360
|
+
role: "rowheader",
|
361
|
+
className: "".concat(blockClass, "__td-th--cell-container")
|
343
362
|
}, /*#__PURE__*/React.createElement("button", {
|
344
363
|
id: "".concat(blockClass, "__cell--").concat(index, "--header"),
|
345
364
|
tabIndex: -1,
|
@@ -349,7 +368,7 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
349
368
|
onClick: handleRowHeaderClick(index),
|
350
369
|
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'))),
|
351
370
|
style: {
|
352
|
-
width:
|
371
|
+
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
|
353
372
|
}
|
354
373
|
}, index + 1)), row.cells.map(function (cell, index) {
|
355
374
|
return /*#__PURE__*/React.createElement("div", _extends({
|
@@ -358,7 +377,8 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
358
377
|
}, cell.getCellProps(), {
|
359
378
|
role: "gridcell",
|
360
379
|
style: _objectSpread(_objectSpread({}, cell.getCellProps().style), {}, {
|
361
|
-
display: 'grid'
|
380
|
+
display: 'grid',
|
381
|
+
minWidth: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width
|
362
382
|
})
|
363
383
|
}), /*#__PURE__*/React.createElement("button", {
|
364
384
|
id: "".concat(blockClass, "__cell--").concat(cell.row.index, "--").concat(index),
|
@@ -373,7 +393,7 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
373
393
|
}, cell.render('Cell')));
|
374
394
|
}));
|
375
395
|
}
|
376
|
-
}, [prepareRow, rows,
|
396
|
+
}, [prepareRow, rows, activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, selectionAreas, handleRowHeaderClick, handleBodyCellClick, handleBodyCellHover, defaultColumn]);
|
377
397
|
var spreadsheetBodyRef = useRef();
|
378
398
|
return /*#__PURE__*/React.createElement("div", _extends({
|
379
399
|
ref: spreadsheetBodyRef,
|
@@ -383,7 +403,13 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
383
403
|
height: 400,
|
384
404
|
itemCount: rows.length || defaultEmptyRowCount,
|
385
405
|
itemSize: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
386
|
-
width:
|
406
|
+
width: getSpreadsheetWidth({
|
407
|
+
scrollBarSizeValue: scrollBarSize,
|
408
|
+
totalVisibleColumns: totalVisibleColumns,
|
409
|
+
defaultColumn: defaultColumn,
|
410
|
+
totalColumnsWidth: totalColumnsWidth
|
411
|
+
}),
|
412
|
+
outerRef: contentScrollRef
|
387
413
|
}, rows !== null && rows !== void 0 && rows.length ? RenderRow : RenderEmptyRows));
|
388
414
|
});
|
389
415
|
DataSpreadsheetBody.propTypes = {
|
@@ -517,5 +543,11 @@ DataSpreadsheetBody.propTypes = {
|
|
517
543
|
/**
|
518
544
|
* The total columns width
|
519
545
|
*/
|
520
|
-
totalColumnsWidth: PropTypes.number
|
546
|
+
totalColumnsWidth: PropTypes.number,
|
547
|
+
|
548
|
+
/**
|
549
|
+
* The total number of columns to be initially visible, additional columns will be rendered and
|
550
|
+
* visible via horizontal scrollbar
|
551
|
+
*/
|
552
|
+
totalVisibleColumns: PropTypes.number
|
521
553
|
};
|
@@ -15,12 +15,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
15
15
|
import React, { forwardRef, useEffect, useState } from 'react';
|
16
16
|
import PropTypes from 'prop-types';
|
17
17
|
import cx from 'classnames';
|
18
|
-
import { px } from '@carbon/layout';
|
19
18
|
import { pkg } from '../../settings';
|
20
19
|
import { usePreviousValue } from '../../global/js/hooks';
|
21
20
|
import { checkActiveHeaderCell } from './utils/checkActiveHeaderCell';
|
22
21
|
import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection';
|
23
22
|
import { selectAllCells } from './utils/selectAllCells';
|
23
|
+
import { getSpreadsheetWidth } from './utils/getSpreadsheetWidth';
|
24
24
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
25
25
|
export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
26
26
|
var activeCellCoordinates = _ref.activeCellCoordinates,
|
@@ -35,6 +35,7 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
|
|
35
35
|
setSelectionAreas = _ref.setSelectionAreas,
|
36
36
|
setSelectionAreaData = _ref.setSelectionAreaData,
|
37
37
|
rows = _ref.rows,
|
38
|
+
totalVisibleColumns = _ref.totalVisibleColumns,
|
38
39
|
updateActiveCellCoordinates = _ref.updateActiveCellCoordinates;
|
39
40
|
|
40
41
|
var _useState = useState(0),
|
@@ -95,13 +96,21 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
|
|
95
96
|
key: "header_".concat(index)
|
96
97
|
}, headerGroup.getHeaderGroupProps(), {
|
97
98
|
style: _objectSpread(_objectSpread({}, headerGroup.getHeaderGroupProps().style), {}, {
|
98
|
-
width:
|
99
|
+
width: getSpreadsheetWidth({
|
100
|
+
type: 'header',
|
101
|
+
headerGroup: headerGroup,
|
102
|
+
scrollBarSizeValue: scrollBarSizeValue,
|
103
|
+
totalVisibleColumns: totalVisibleColumns,
|
104
|
+
defaultColumn: defaultColumn
|
105
|
+
}),
|
106
|
+
overflow: 'hidden'
|
99
107
|
}),
|
100
108
|
className: "".concat(blockClass, "__tr")
|
101
109
|
}), /*#__PURE__*/React.createElement("div", {
|
102
110
|
role: "columnheader",
|
111
|
+
className: "".concat(blockClass, "__select-all-cell-container"),
|
103
112
|
style: {
|
104
|
-
width:
|
113
|
+
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth,
|
105
114
|
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
106
115
|
}
|
107
116
|
}, /*#__PURE__*/React.createElement("button", {
|
@@ -124,7 +133,8 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
|
|
124
133
|
tabIndex: -1,
|
125
134
|
onClick: handleColumnHeaderClick(index),
|
126
135
|
style: {
|
127
|
-
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
136
|
+
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
137
|
+
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width
|
128
138
|
},
|
129
139
|
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'))),
|
130
140
|
type: "button"
|
@@ -200,6 +210,12 @@ DataSpreadsheetHeader.propTypes = {
|
|
200
210
|
*/
|
201
211
|
setSelectionAreas: PropTypes.func,
|
202
212
|
|
213
|
+
/**
|
214
|
+
* The total number of columns to be initially visible, additional columns will be rendered and
|
215
|
+
* visible via horizontal scrollbar
|
216
|
+
*/
|
217
|
+
totalVisibleColumns: PropTypes.number,
|
218
|
+
|
203
219
|
/**
|
204
220
|
* Function used to update the active cell coordinates
|
205
221
|
*/
|
@@ -24,28 +24,36 @@ var range = function range(len) {
|
|
24
24
|
return arr;
|
25
25
|
};
|
26
26
|
|
27
|
-
var newPet = function newPet() {
|
28
|
-
|
27
|
+
var newPet = function newPet(extraColumns) {
|
28
|
+
var extraDataProps = extraColumns && {
|
29
|
+
ownerName: petNames[Math.floor(Math.random() * petNames.length)],
|
30
|
+
weight: Math.floor(Math.random() * 40)
|
31
|
+
};
|
32
|
+
var defaultPet = {
|
29
33
|
petType: pets[Math.floor(Math.random() * pets.length)],
|
30
34
|
firstName: petNames[Math.floor(Math.random() * petNames.length)],
|
31
35
|
age: Math.floor(Math.random() * 30),
|
32
36
|
visits: Math.floor(Math.random() * 40),
|
33
37
|
health: Math.floor(Math.random() * 100)
|
34
38
|
};
|
35
|
-
};
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
lens[_key] = arguments[_key];
|
40
|
+
if (extraColumns) {
|
41
|
+
return _objectSpread(_objectSpread({}, defaultPet), extraDataProps);
|
40
42
|
}
|
41
43
|
|
44
|
+
return defaultPet;
|
45
|
+
};
|
46
|
+
|
47
|
+
export var generateData = function generateData(_ref) {
|
48
|
+
var rows = _ref.rows,
|
49
|
+
extraColumns = _ref.extraColumns;
|
50
|
+
|
42
51
|
var makeDataLevel = function makeDataLevel() {
|
43
52
|
var depth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
53
|
+
var lens = [rows];
|
44
54
|
var len = lens[depth];
|
45
55
|
return range(len).map(function () {
|
46
|
-
return _objectSpread(
|
47
|
-
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined
|
48
|
-
});
|
56
|
+
return _objectSpread({}, newPet(extraColumns));
|
49
57
|
});
|
50
58
|
};
|
51
59
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
3
|
+
*
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import { px } from '@carbon/layout';
|
8
|
+
export var getSpreadsheetWidth = function getSpreadsheetWidth(_ref) {
|
9
|
+
var type = _ref.type,
|
10
|
+
headerGroup = _ref.headerGroup,
|
11
|
+
scrollBarSizeValue = _ref.scrollBarSizeValue,
|
12
|
+
totalVisibleColumns = _ref.totalVisibleColumns,
|
13
|
+
defaultColumn = _ref.defaultColumn,
|
14
|
+
totalColumnsWidth = _ref.totalColumnsWidth;
|
15
|
+
var additionalWidth = scrollBarSizeValue + defaultColumn.rowHeaderWidth;
|
16
|
+
|
17
|
+
if (!totalVisibleColumns) {
|
18
|
+
if (type === 'header') {
|
19
|
+
return px(parseInt(headerGroup.getHeaderGroupProps().style.width) + additionalWidth);
|
20
|
+
}
|
21
|
+
|
22
|
+
if (type !== 'header') {
|
23
|
+
return totalColumnsWidth + additionalWidth;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
if (totalVisibleColumns) {
|
28
|
+
return totalVisibleColumns * (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width) + additionalWidth;
|
29
|
+
}
|
30
|
+
};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
4
|
var _excluded = ["children"];
|
4
5
|
|
5
6
|
/*
|
@@ -13,6 +14,7 @@ var _excluded = ["children"];
|
|
13
14
|
import React from 'react';
|
14
15
|
import { DataTable, SkeletonText } from 'carbon-components-react';
|
15
16
|
import { selectionColumnId } from '../common-column-ids';
|
17
|
+
import cx from 'classnames';
|
16
18
|
import { pkg } from '../../../settings';
|
17
19
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
20
|
var TableRow = DataTable.TableRow,
|
@@ -21,9 +23,17 @@ var TableRow = DataTable.TableRow,
|
|
21
23
|
var DatagridRow = function DatagridRow(datagridState) {
|
22
24
|
var row = datagridState.row;
|
23
25
|
return /*#__PURE__*/React.createElement(TableRow, _extends({
|
24
|
-
className: "".concat(blockClass, "__carbon-row")
|
26
|
+
className: cx("".concat(blockClass, "__carbon-row"), _defineProperty({}, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded))
|
25
27
|
}, row.getRowProps(), {
|
26
|
-
key: row.id
|
28
|
+
key: row.id,
|
29
|
+
onMouseEnter: function onMouseEnter(event) {
|
30
|
+
var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
|
31
|
+
hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.add("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
32
|
+
},
|
33
|
+
onMouseLeave: function onMouseLeave(event) {
|
34
|
+
var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
|
35
|
+
hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
36
|
+
}
|
27
37
|
}), row.cells.map(function (cell) {
|
28
38
|
var cellProps = cell.getCellProps();
|
29
39
|
|
@@ -11,7 +11,7 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
11
11
|
|
12
12
|
var useNestedRows = function useNestedRows(hooks) {
|
13
13
|
useRowExpander(hooks);
|
14
|
-
var marginLeft =
|
14
|
+
var marginLeft = 24;
|
15
15
|
|
16
16
|
var getRowProps = function getRowProps(props, _ref) {
|
17
17
|
var row = _ref.row;
|
@@ -25,7 +25,7 @@ var useNestedRows = function useNestedRows(hooks) {
|
|
25
25
|
return [props, {
|
26
26
|
style: {
|
27
27
|
marginLeft: "".concat(row.depth > 0 ? marginLeft : 0, "px"),
|
28
|
-
paddingLeft: "".concat(row.depth > 1 ? marginLeft * (row.depth - 1) : 0, "px"),
|
28
|
+
paddingLeft: "".concat(row.depth > 1 ? marginLeft * (row.depth - 1) + marginLeft : row.depth === 1 ? marginLeft : 0, "px"),
|
29
29
|
maxWidth: "calc(100% - ".concat(marginLeft * row.depth, "px)")
|
30
30
|
}
|
31
31
|
}];
|
@@ -40,7 +40,7 @@ var useNestedRows = function useNestedRows(hooks) {
|
|
40
40
|
}) === 0;
|
41
41
|
return [props, {
|
42
42
|
style: {
|
43
|
-
marginRight: isFirstCell ? "-".concat(marginLeft * cell.row.depth, "px") : ''
|
43
|
+
marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "-".concat(marginLeft * (cell.row.depth + 1), "px") : '')
|
44
44
|
}
|
45
45
|
}];
|
46
46
|
};
|
@@ -20,7 +20,7 @@ var useRowExpander = function useRowExpander(hooks) {
|
|
20
20
|
var row = _ref.row;
|
21
21
|
return row.canExpand && /*#__PURE__*/React.createElement("span", row.getToggleRowExpandedProps(), row.isExpanded ? /*#__PURE__*/React.createElement(ChevronUp16, null) : /*#__PURE__*/React.createElement(ChevronDown16, null));
|
22
22
|
},
|
23
|
-
width:
|
23
|
+
width: 48,
|
24
24
|
disableResizing: true,
|
25
25
|
disableSortBy: true,
|
26
26
|
Header: ''
|
@@ -43,7 +43,7 @@ var _addSelectUtils = require("./add-select-utils");
|
|
43
43
|
|
44
44
|
var _AddSelectFilter = require("./AddSelectFilter");
|
45
45
|
|
46
|
-
var _excluded = ["className", "columnInputPlaceholder", "description", "globalFilters", "globalFiltersIconDescription", "globalFiltersPlaceholderText", "globalFiltersPrimaryButtonText", "globalFiltersSecondaryButtonText", "globalSearchLabel", "globalSearchPlaceholder", "influencerTitle", "items", "itemsLabel", "multi", "noResultsDescription", "noResultsTitle", "noSelectionDescription", "noSelectionTitle", "onClose", "onCloseButtonText", "onSubmit", "onSubmitButtonText", "open", "portalTarget", "removeIconDescription", "searchResultsLabel", "title"];
|
46
|
+
var _excluded = ["className", "clearFiltersText", "columnInputPlaceholder", "description", "globalFilters", "globalFiltersIconDescription", "globalFiltersPlaceholderText", "globalFiltersPrimaryButtonText", "globalFiltersSecondaryButtonText", "globalSearchLabel", "globalSearchPlaceholder", "influencerTitle", "items", "itemsLabel", "multi", "noResultsDescription", "noResultsTitle", "noSelectionDescription", "noSelectionTitle", "onClose", "onCloseButtonText", "onSubmit", "onSubmitButtonText", "open", "portalTarget", "removeIconDescription", "searchResultsLabel", "title"];
|
47
47
|
|
48
48
|
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); }
|
49
49
|
|
@@ -54,6 +54,7 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
54
54
|
var _cx;
|
55
55
|
|
56
56
|
var className = _ref.className,
|
57
|
+
clearFiltersText = _ref.clearFiltersText,
|
57
58
|
columnInputPlaceholder = _ref.columnInputPlaceholder,
|
58
59
|
description = _ref.description,
|
59
60
|
globalFilters = _ref.globalFilters,
|
@@ -263,7 +264,9 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
263
264
|
onSubmit(multi ? multiSelection : singleSelection);
|
264
265
|
};
|
265
266
|
|
267
|
+
var classNames = (0, _classnames.default)(className, blockClass, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__single"), !multi), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__multi"), multi), _cx));
|
266
268
|
var commonTearsheetProps = {
|
269
|
+
className: classNames,
|
267
270
|
open: open,
|
268
271
|
title: title,
|
269
272
|
description: description,
|
@@ -289,7 +292,6 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
289
292
|
removeIconDescription: removeIconDescription,
|
290
293
|
setMultiSelection: setMultiSelection
|
291
294
|
};
|
292
|
-
var classNames = (0, _classnames.default)(className, blockClass, (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__single"), !multi), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__multi"), multi), _cx));
|
293
295
|
|
294
296
|
var setShowBreadsCrumbs = function setShowBreadsCrumbs() {
|
295
297
|
if (searchTerm) {
|
@@ -332,7 +334,10 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
332
334
|
primaryButtonText: globalFiltersPrimaryButtonText,
|
333
335
|
secondaryButtonText: globalFiltersSecondaryButtonText,
|
334
336
|
placeholder: globalFiltersPlaceholderText,
|
335
|
-
iconDescription: globalFiltersIconDescription
|
337
|
+
iconDescription: globalFiltersIconDescription,
|
338
|
+
appliedFilters: appliedGlobalFilters,
|
339
|
+
hasFiltersApplied: globalFiltersApplied,
|
340
|
+
clearFiltersText: clearFiltersText
|
336
341
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
337
342
|
className: "".concat(blockClass, "__tag-container")
|
338
343
|
}, showBreadsCrumbs ? /*#__PURE__*/_react.default.createElement(_AddSelectBreadcrumbs.AddSelectBreadcrumbs, {
|
@@ -366,8 +371,7 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
366
371
|
}))));
|
367
372
|
|
368
373
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
369
|
-
ref: ref
|
370
|
-
className: classNames
|
374
|
+
ref: ref
|
371
375
|
}, rest), multi ? /*#__PURE__*/_react.default.createElement(_Tearsheet.Tearsheet, (0, _extends2.default)({}, commonTearsheetProps, {
|
372
376
|
influencer: multi && /*#__PURE__*/_react.default.createElement(_AddSelectSidebar.AddSelectSidebar, sidebarProps),
|
373
377
|
influencerPosition: "right"
|
@@ -376,6 +380,7 @@ var AddSelect = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
376
380
|
exports.AddSelect = AddSelect;
|
377
381
|
AddSelect.propTypes = {
|
378
382
|
className: _propTypes.default.string,
|
383
|
+
clearFiltersText: _propTypes.default.string,
|
379
384
|
columnInputPlaceholder: _propTypes.default.string,
|
380
385
|
description: _propTypes.default.string,
|
381
386
|
globalFilters: _propTypes.default.arrayOf(_propTypes.default.shape({
|
@@ -34,9 +34,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
34
34
|
var componentName = 'AddSelectFilter';
|
35
35
|
|
36
36
|
var AddSelectFilter = function AddSelectFilter(_ref) {
|
37
|
-
var
|
37
|
+
var appliedFilters = _ref.appliedFilters,
|
38
|
+
clearFiltersText = _ref.clearFiltersText,
|
39
|
+
filterOpts = _ref.filterOpts,
|
38
40
|
handleFilter = _ref.handleFilter,
|
39
41
|
handleSearch = _ref.handleSearch,
|
42
|
+
hasFiltersApplied = _ref.hasFiltersApplied,
|
40
43
|
iconDescription = _ref.iconDescription,
|
41
44
|
inputLabel = _ref.inputLabel,
|
42
45
|
inputPlaceholder = _ref.inputPlaceholder,
|
@@ -66,6 +69,14 @@ var AddSelectFilter = function AddSelectFilter(_ref) {
|
|
66
69
|
var selectedItem = _ref2.selectedItem;
|
67
70
|
setFilters(_objectSpread(_objectSpread({}, filters), {}, (0, _defineProperty2.default)({}, id, selectedItem)));
|
68
71
|
};
|
72
|
+
/**
|
73
|
+
* this component needs to manage it's own internal state of filters before they're applied
|
74
|
+
* setFilters manages the local filter state
|
75
|
+
* applyFilters adds the filter state to the parent
|
76
|
+
* resetFilters resets the local state
|
77
|
+
* clearFilters resets both
|
78
|
+
*/
|
79
|
+
|
69
80
|
|
70
81
|
var applyFilters = function applyFilters() {
|
71
82
|
handleFilter(filters);
|
@@ -75,12 +86,25 @@ var AddSelectFilter = function AddSelectFilter(_ref) {
|
|
75
86
|
setFilters({});
|
76
87
|
};
|
77
88
|
|
89
|
+
var clearFilters = function clearFilters() {
|
90
|
+
resetFilters();
|
91
|
+
handleFilter({});
|
92
|
+
};
|
93
|
+
|
94
|
+
var removeTag = function removeTag(key) {
|
95
|
+
var newFilters = _objectSpread({}, filters);
|
96
|
+
|
97
|
+
delete newFilters[key];
|
98
|
+
setFilters(newFilters);
|
99
|
+
handleFilter(newFilters);
|
100
|
+
};
|
101
|
+
|
78
102
|
var getSelectedItem = function getSelectedItem(id) {
|
79
103
|
return filters[id] || '';
|
80
104
|
};
|
81
105
|
|
82
106
|
var showFilter = multi && (filterOpts === null || filterOpts === void 0 ? void 0 : filterOpts.length) > 0;
|
83
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
107
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
84
108
|
className: "".concat(blockClass, "-search")
|
85
109
|
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextInput, {
|
86
110
|
id: "temp-id",
|
@@ -127,14 +151,33 @@ var AddSelectFilter = function AddSelectFilter(_ref) {
|
|
127
151
|
kind: "primary",
|
128
152
|
onClick: applyFilters,
|
129
153
|
className: "".concat(blockClass, "-button")
|
130
|
-
}, primaryButtonText))))
|
154
|
+
}, primaryButtonText)))), hasFiltersApplied && /*#__PURE__*/_react.default.createElement("div", {
|
155
|
+
className: "".concat(blockClass, "-applied")
|
156
|
+
}, Object.keys(appliedFilters).map(function (filterType) {
|
157
|
+
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Tag, {
|
158
|
+
key: filterType,
|
159
|
+
type: "gray",
|
160
|
+
size: "sm",
|
161
|
+
onClose: function onClose() {
|
162
|
+
return removeTag(filterType);
|
163
|
+
},
|
164
|
+
filter: true
|
165
|
+
}, "".concat(filterType, ": ").concat(appliedFilters[filterType]));
|
166
|
+
}), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
167
|
+
kind: "ghost",
|
168
|
+
size: "sm",
|
169
|
+
onClick: clearFilters
|
170
|
+
}, clearFiltersText)));
|
131
171
|
};
|
132
172
|
|
133
173
|
exports.AddSelectFilter = AddSelectFilter;
|
134
174
|
AddSelectFilter.propTypes = {
|
175
|
+
appliedFilters: _propTypes.default.object,
|
176
|
+
clearFiltersText: _propTypes.default.string,
|
135
177
|
filterOpts: _propTypes.default.array,
|
136
178
|
handleFilter: _propTypes.default.func,
|
137
179
|
handleSearch: _propTypes.default.func,
|
180
|
+
hasFiltersApplied: _propTypes.default.bool,
|
138
181
|
iconDescription: _propTypes.default.string,
|
139
182
|
inputLabel: _propTypes.default.string,
|
140
183
|
inputPlaceholder: _propTypes.default.string,
|
@@ -65,7 +65,7 @@ var _handleActiveCellInSelectionEnter = require("./utils/handleActiveCellInSelec
|
|
65
65
|
|
66
66
|
var _handleActiveCellInSelectionTab = require("./utils/handleActiveCellInSelectionTab");
|
67
67
|
|
68
|
-
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
|
68
|
+
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "totalVisibleColumns"];
|
69
69
|
|
70
70
|
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); }
|
71
71
|
|
@@ -110,6 +110,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
110
110
|
onActiveCellChange = _ref$onActiveCellChan === void 0 ? defaults.onActiveCellChange : _ref$onActiveCellChan,
|
111
111
|
_ref$onSelectionAreaC = _ref.onSelectionAreaChange,
|
112
112
|
onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
|
113
|
+
totalVisibleColumns = _ref.totalVisibleColumns,
|
113
114
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
114
115
|
var multiKeyTrackingRef = (0, _react.useRef)();
|
115
116
|
var localRef = (0, _react.useRef)();
|
@@ -801,6 +802,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
801
802
|
setSelectionAreas: setSelectionAreas,
|
802
803
|
setCurrentMatcher: setCurrentMatcher,
|
803
804
|
setSelectionAreaData: setSelectionAreaData,
|
805
|
+
totalVisibleColumns: totalVisibleColumns,
|
804
806
|
updateActiveCellCoordinates: updateActiveCellCoordinates
|
805
807
|
}), /*#__PURE__*/_react.default.createElement(_DataSpreadsheetBody.DataSpreadsheetBody, {
|
806
808
|
activeCellCoordinates: activeCellCoordinates,
|
@@ -829,7 +831,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
829
831
|
id: id,
|
830
832
|
columns: columns,
|
831
833
|
defaultEmptyRowCount: defaultEmptyRowCount,
|
832
|
-
setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea
|
834
|
+
setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea,
|
835
|
+
totalVisibleColumns: totalVisibleColumns
|
833
836
|
}), /*#__PURE__*/_react.default.createElement("button", {
|
834
837
|
onMouseDown: handleActiveCellMouseDown,
|
835
838
|
onClick: handleActiveCellClick,
|
@@ -927,7 +930,13 @@ DataSpreadsheet.propTypes = {
|
|
927
930
|
/**
|
928
931
|
* The event handler that is called when the selection area values change
|
929
932
|
*/
|
930
|
-
onSelectionAreaChange: _propTypes.default.func
|
933
|
+
onSelectionAreaChange: _propTypes.default.func,
|
934
|
+
|
935
|
+
/**
|
936
|
+
* The total number of columns to be initially visible, additional columns will be rendered and
|
937
|
+
* visible via horizontal scrollbar
|
938
|
+
*/
|
939
|
+
totalVisibleColumns: _propTypes.default.number
|
931
940
|
/* TODO: add types and DocGen for all props. */
|
932
941
|
|
933
942
|
};
|