@carbon/ibm-products 1.16.0 → 1.17.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/index-full-carbon.css +32 -7
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +6 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +9 -3
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +4 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +32 -7
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +6 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +32 -7
- package/css/index.css.map +1 -1
- package/css/index.min.css +6 -3
- package/css/index.min.css.map +1 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +1 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +6 -2
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +5 -2
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +57 -12
- package/es/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +16 -0
- package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +10 -5
- package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +6 -2
- package/es/components/Datagrid/Datagrid/Datagrid.js +24 -12
- package/es/components/Datagrid/Datagrid/DatagridHead.js +8 -16
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -10
- package/es/components/Datagrid/Datagrid/index.js +6 -7
- package/es/components/Datagrid/index.js +1 -1
- package/es/components/ExportModal/ExportModal.js +10 -5
- package/es/components/SidePanel/SidePanel.js +5 -1
- package/es/components/WebTerminal/WebTerminal.js +36 -11
- package/es/components/WebTerminal/WebTerminalContentWrapper.js +49 -0
- package/es/components/WebTerminal/index.js +2 -1
- package/es/components/index.js +1 -1
- package/es/global/js/package-settings.js +1 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +7 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +6 -2
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +61 -11
- package/lib/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +26 -0
- package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +10 -5
- package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +6 -2
- package/lib/components/Datagrid/Datagrid/Datagrid.js +25 -8
- package/lib/components/Datagrid/Datagrid/DatagridHead.js +8 -16
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -10
- package/lib/components/Datagrid/Datagrid/index.js +3 -5
- package/lib/components/Datagrid/index.js +2 -2
- package/lib/components/ExportModal/ExportModal.js +9 -4
- package/lib/components/SidePanel/SidePanel.js +5 -1
- package/lib/components/WebTerminal/WebTerminal.js +36 -10
- package/lib/components/WebTerminal/WebTerminalContentWrapper.js +58 -0
- package/lib/components/WebTerminal/index.js +9 -1
- package/lib/components/index.js +6 -0
- package/lib/global/js/package-settings.js +1 -0
- package/package.json +9 -9
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +10 -0
- package/scss/components/SidePanel/_side-panel.scss +22 -3
- package/scss/components/WebTerminal/_storybook-styles.scss +5 -0
- package/scss/components/WebTerminal/_web-terminal.scss +14 -4
@@ -1,11 +1,14 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
1
2
|
// /**
|
2
3
|
// * Copyright IBM Corp. 2022, 2022
|
3
4
|
// *
|
4
5
|
// * This source code is licensed under the Apache-2.0 license found in the
|
5
6
|
// * LICENSE file in the root directory of this source tree.
|
6
7
|
// */
|
7
|
-
import { useEffect } from 'react';
|
8
|
+
import { useEffect, useState } from 'react';
|
8
9
|
import { px } from '@carbon/layout';
|
10
|
+
import { pkg } from '../../../settings';
|
11
|
+
import { usePreviousValue } from '../../../global/js/hooks';
|
9
12
|
export var useSpreadsheetEdit = function useSpreadsheetEdit(_ref) {
|
10
13
|
var isEditing = _ref.isEditing,
|
11
14
|
rows = _ref.rows,
|
@@ -15,8 +18,27 @@ export var useSpreadsheetEdit = function useSpreadsheetEdit(_ref) {
|
|
15
18
|
cellEditorRulerRef = _ref.cellEditorRulerRef,
|
16
19
|
columns = _ref.columns,
|
17
20
|
defaultColumn = _ref.defaultColumn,
|
18
|
-
cellEditorValue = _ref.cellEditorValue
|
21
|
+
cellEditorValue = _ref.cellEditorValue,
|
22
|
+
_ref$blockClass = _ref.blockClass,
|
23
|
+
blockClass = _ref$blockClass === void 0 ? "".concat(pkg.prefix, "--data-spreadsheet") : _ref$blockClass;
|
24
|
+
|
25
|
+
var _useState = useState(null),
|
26
|
+
_useState2 = _slicedToArray(_useState, 2),
|
27
|
+
nextIndex = _useState2[0],
|
28
|
+
setNextIndex = _useState2[1];
|
29
|
+
|
30
|
+
var previousState = usePreviousValue({
|
31
|
+
nextIndex: nextIndex
|
32
|
+
});
|
33
|
+
useEffect(function () {
|
34
|
+
if (!(previousState !== null && previousState !== void 0 && previousState.nextIndex)) {
|
35
|
+
setNextIndex(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column);
|
36
|
+
}
|
37
|
+
}, [previousState === null || previousState === void 0 ? void 0 : previousState.nextIndex, activeCellCoordinates]);
|
19
38
|
useEffect(function () {
|
39
|
+
var rulerWidth = cellEditorRulerRef.current.offsetWidth;
|
40
|
+
var cellEditorCurrentWidth = parseInt(cellEditorRef.current.style.width);
|
41
|
+
|
20
42
|
if (isEditing) {
|
21
43
|
var _rows$activeCellCoord, _cellProps$column, _cellEditorRef$curren;
|
22
44
|
|
@@ -26,25 +48,47 @@ export var useSpreadsheetEdit = function useSpreadsheetEdit(_ref) {
|
|
26
48
|
cellEditorRef.current.style.left = activeCellLeftPosition;
|
27
49
|
cellEditorRef.current.style.top = activeCellTopPosition;
|
28
50
|
cellEditorRef.current.style.display = 'block';
|
29
|
-
cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.width;
|
30
51
|
cellEditorRef.current.style.height = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height;
|
31
52
|
cellEditorRef.current.style.paddingTop = "".concat((parseInt(activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height) - 16) / 2 - 1, "px"); // calculate paddingTop based on cellHeight which could be variable depending on the cellSize prop
|
32
53
|
|
33
54
|
cellEditorRef.current.style.textAlign = (cellProps === null || cellProps === void 0 ? void 0 : (_cellProps$column = cellProps.column) === null || _cellProps$column === void 0 ? void 0 : _cellProps$column.placement) === 'right' ? 'right' : 'left';
|
34
55
|
(_cellEditorRef$curren = cellEditorRef.current) === null || _cellEditorRef$curren === void 0 ? void 0 : _cellEditorRef$curren.focus();
|
35
|
-
var rulerWidth = cellEditorRulerRef.current.offsetWidth;
|
36
|
-
var cellWidth = activeCellRef.current.offsetWidth;
|
37
56
|
|
38
|
-
if (rulerWidth
|
39
|
-
var
|
40
|
-
|
57
|
+
if (rulerWidth < cellEditorCurrentWidth) {
|
58
|
+
var _columns$nextIndex;
|
59
|
+
|
60
|
+
var currentColumnWidth = ((_columns$nextIndex = columns[nextIndex]) === null || _columns$nextIndex === void 0 ? void 0 : _columns$nextIndex.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width); // If the contents of the cell editor is deleted past the point of the next column
|
61
|
+
|
62
|
+
if (rulerWidth < cellEditorCurrentWidth - currentColumnWidth) {
|
63
|
+
cellEditorRef.current.style.width = px(parseInt(cellEditorRef.current.style.width) - currentColumnWidth);
|
64
|
+
setNextIndex(function (prev) {
|
65
|
+
if (prev === 0) {
|
66
|
+
return prev;
|
67
|
+
}
|
68
|
+
|
69
|
+
return prev - 1;
|
70
|
+
});
|
71
|
+
} // Decrease cell editor width by increment of current column width
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
if (rulerWidth >= cellEditorCurrentWidth) {
|
76
|
+
var _columns;
|
77
|
+
|
78
|
+
setNextIndex(function (prev) {
|
79
|
+
if (prev === columns.length - 1) {
|
80
|
+
return prev;
|
81
|
+
}
|
82
|
+
|
83
|
+
return prev + 1;
|
84
|
+
});
|
85
|
+
var onLastColumnIndex = nextIndex + 1 === columns.length;
|
86
|
+
var nextColumnWidth = onLastColumnIndex ? 0 : ((_columns = columns[nextIndex + 1]) === null || _columns === void 0 ? void 0 : _columns.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width);
|
41
87
|
var startingRowPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row;
|
42
|
-
var totalColumns = columns.length;
|
43
88
|
var totalRows = rows.length;
|
44
|
-
var totalMultiplierPossible = totalColumns - startingColumnPosition;
|
45
89
|
var totalCellEditorMaxHeight = (totalRows - startingRowPosition) * defaultColumn.rowHeight;
|
46
90
|
cellEditorRef.current.style.maxHeight = px(totalCellEditorMaxHeight);
|
47
|
-
cellEditorRef.current.style.width = px(
|
91
|
+
cellEditorRef.current.style.width = px(nextColumnWidth + cellEditorCurrentWidth);
|
48
92
|
cellEditorRef.current.style.height = px(cellEditorRef.current.scrollHeight); // adds dynamic height to cell editor
|
49
93
|
// Cell editor has reached max height, we need to add the scrolling back.
|
50
94
|
// We also need to subtract 1 to account for the fact that the cell editor
|
@@ -63,6 +107,7 @@ export var useSpreadsheetEdit = function useSpreadsheetEdit(_ref) {
|
|
63
107
|
cellEditorRef.current.style.display = 'none';
|
64
108
|
cellEditorRef.current.blur();
|
65
109
|
activeCellRef.current.focus();
|
110
|
+
setNextIndex(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column);
|
66
111
|
}
|
67
|
-
}, [isEditing, activeCellCoordinates, rows, cellEditorValue, columns.length, defaultColumn,
|
112
|
+
}, [isEditing, activeCellCoordinates, rows, cellEditorValue, columns.length, defaultColumn, activeCellRef, cellEditorRef, cellEditorRulerRef, columns, blockClass, previousState === null || previousState === void 0 ? void 0 : previousState.cellEditorValue, nextIndex]);
|
68
113
|
};
|
@@ -0,0 +1,16 @@
|
|
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 { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
|
8
|
+
export var checkSelectedHeaderCell = function checkSelectedHeaderCell(headerIndex, selectionAreas, headerType) {
|
9
|
+
var areasCloned = deepCloneObject(selectionAreas);
|
10
|
+
var isSelectedHeader = areasCloned.some(function (area) {
|
11
|
+
var _area$header, _area$header2;
|
12
|
+
|
13
|
+
return (area === null || area === void 0 ? void 0 : (_area$header = area.header) === null || _area$header === void 0 ? void 0 : _area$header.type) === headerType && headerIndex === (area === null || area === void 0 ? void 0 : (_area$header2 = area.header) === null || _area$header2 === void 0 ? void 0 : _area$header2.index);
|
14
|
+
});
|
15
|
+
return isSelectedHeader;
|
16
|
+
};
|
@@ -11,6 +11,7 @@ export var createCellSelectionArea = function createCellSelectionArea(_ref) {
|
|
11
11
|
var ref = _ref.ref,
|
12
12
|
area = _ref.area,
|
13
13
|
blockClass = _ref.blockClass,
|
14
|
+
columns = _ref.columns,
|
14
15
|
defaultColumn = _ref.defaultColumn,
|
15
16
|
selectionAreas = _ref.selectionAreas,
|
16
17
|
setSelectionAreas = _ref.setSelectionAreas,
|
@@ -28,24 +29,28 @@ export var createCellSelectionArea = function createCellSelectionArea(_ref) {
|
|
28
29
|
activeCellElement.setAttribute('data-selection-id', area.matcher);
|
29
30
|
}
|
30
31
|
|
31
|
-
var
|
32
|
+
var selectionAreaVariableWidth = 0;
|
33
|
+
columns.forEach(function (item, index) {
|
34
|
+
if (index >= lowestColumnIndex && index <= greatestColumnIndex) {
|
35
|
+
selectionAreaVariableWidth += (item === null || item === void 0 ? void 0 : item.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width);
|
36
|
+
}
|
37
|
+
});
|
38
|
+
var point1Element = document.querySelector("[data-row-index=\"".concat(area.point1.row, "\"][data-column-index=\"").concat(area.point1.column, "\"]")) || document.querySelector(".".concat(blockClass, "__body--td")); // if we can't find the point1 element (this can happen in the case where a virtualized row is not present anymore in the DOM), we get the default height of the first body cell we find
|
32
39
|
|
33
|
-
var selectionAreaCellWidth = point1Element.offsetWidth;
|
34
40
|
var selectionAreaCellHeight = point1Element.offsetHeight;
|
35
|
-
var selectionAreaTotalWidth = selectionAreaCellWidth * (greatestColumnIndex - lowestColumnIndex + 1);
|
36
41
|
var selectionAreaTotalHeight = selectionAreaCellHeight * (greatestRowIndex - lowestRowIndex + 1);
|
37
42
|
var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
|
38
43
|
var placementElement = bodyContainer.querySelector("[data-row-index=\"".concat(lowestRowIndex, "\"][data-column-index=\"").concat(lowestColumnIndex, "\"]"));
|
39
44
|
var relativePosition = {
|
40
45
|
top: placementElement ? placementElement.getBoundingClientRect().top - bodyContainer.getBoundingClientRect().top : lowestRowIndex === 0 ? 0 : selectionAreaCellHeight * lowestRowIndex,
|
41
46
|
// calculate top value here if virtualized row is not in DOM
|
42
|
-
left: placementElement ? placementElement.getBoundingClientRect().left - bodyContainer.getBoundingClientRect().left : lowestColumnIndex === 0 ? 0 + (defaultColumn.rowHeaderWidth - 4) :
|
47
|
+
left: placementElement ? placementElement.getBoundingClientRect().left - bodyContainer.getBoundingClientRect().left : lowestColumnIndex === 0 ? 0 + (defaultColumn.rowHeaderWidth - 4) : defaultColumn.width * lowestColumnIndex + (defaultColumn.rowHeaderWidth - 4) // calculate left value here if virtualized row is not in DOM, accounting for row header cell width (including borders)
|
43
48
|
|
44
49
|
};
|
45
50
|
var selectionAreaElement = document.querySelector("[data-matcher-id=\"".concat(area.matcher, "\"]")) || document.createElement('div');
|
46
51
|
selectionAreaElement.classList.add("".concat(blockClass, "__selection-area--element"));
|
47
52
|
selectionAreaElement.setAttribute('data-matcher-id', area.matcher);
|
48
|
-
selectionAreaElement.style.width = px(
|
53
|
+
selectionAreaElement.style.width = px(selectionAreaVariableWidth);
|
49
54
|
selectionAreaElement.style.height = px(selectionAreaTotalHeight);
|
50
55
|
selectionAreaElement.style.left = px(relativePosition.left);
|
51
56
|
selectionAreaElement.style.top = px(relativePosition.top);
|
@@ -63,10 +63,14 @@ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref)
|
|
63
63
|
|
64
64
|
if (isHoldingCommandKey) {
|
65
65
|
var selectionsFromHeaderCell = selectionsClone.filter(function (item) {
|
66
|
-
|
66
|
+
var _item$header;
|
67
|
+
|
68
|
+
return (_item$header = item.header) === null || _item$header === void 0 ? void 0 : _item$header.type;
|
67
69
|
});
|
68
70
|
var previouslyCreatedHeaderSelection = selectionsFromHeaderCell.filter(function (item) {
|
69
|
-
|
71
|
+
var _item$header2;
|
72
|
+
|
73
|
+
return ((_item$header2 = item.header) === null || _item$header2 === void 0 ? void 0 : _item$header2.type) === type;
|
70
74
|
});
|
71
75
|
var isHeaderPartOfPreviousSelection = checkActiveHeaderCell(index, previouslyCreatedHeaderSelection, type); // Prevents row/column header selections from being created multiple times
|
72
76
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
-
var _excluded = ["
|
4
|
+
var _excluded = ["datagridState"];
|
5
5
|
|
6
|
-
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
6
|
+
/**
|
7
|
+
* Copyright IBM Corp. 2020, 2022
|
8
|
+
*
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
12
11
|
*/
|
13
12
|
import React from 'react';
|
13
|
+
import PropTypes from 'prop-types';
|
14
14
|
import { DataTable } from 'carbon-components-react';
|
15
15
|
import cx from 'classnames';
|
16
16
|
import DatagridHead from './DatagridHead';
|
@@ -18,13 +18,22 @@ import DatagridBody from './DatagridBody';
|
|
18
18
|
import DatagridToolbar from './DatagridToolbar';
|
19
19
|
import { getDevtoolsProps } from '../../../global/js/utils/devtools';
|
20
20
|
import { pkg } from '../../../settings';
|
21
|
+
import pconsole from '../../../global/js/utils/pconsole';
|
21
22
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
22
23
|
var componentName = 'Datagrid';
|
23
24
|
var TableContainer = DataTable.TableContainer,
|
24
25
|
Table = DataTable.Table;
|
25
|
-
var Datagrid = /*#__PURE__*/React.forwardRef(function (
|
26
|
+
export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
26
27
|
var _getTableProps;
|
27
28
|
|
29
|
+
var datagridState = _ref.datagridState,
|
30
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
31
|
+
|
32
|
+
if (!datagridState) {
|
33
|
+
pconsole.warn('Datagrid was not passed datagridState which is required to render this component.');
|
34
|
+
return null;
|
35
|
+
}
|
36
|
+
|
28
37
|
var _datagridState$getTab = datagridState.getTableProps,
|
29
38
|
getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
|
30
39
|
withVirtualScroll = datagridState.withVirtualScroll,
|
@@ -37,9 +46,7 @@ var Datagrid = /*#__PURE__*/React.forwardRef(function (datagridState, ref) {
|
|
37
46
|
_datagridState$vertic = datagridState.verticalAlign,
|
38
47
|
verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
|
39
48
|
variableRowHeight = datagridState.variableRowHeight,
|
40
|
-
className = datagridState.className
|
41
|
-
rest = _objectWithoutProperties(datagridState, _excluded);
|
42
|
-
|
49
|
+
className = datagridState.className;
|
43
50
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
44
51
|
var dataGrid = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContainer, {
|
45
52
|
className: cx("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '')
|
@@ -67,4 +74,9 @@ Datagrid = pkg.checkComponentEnabled(Datagrid, componentName); // The display na
|
|
67
74
|
// is used in preference to relying on function.name.
|
68
75
|
|
69
76
|
Datagrid.displayName = componentName;
|
70
|
-
|
77
|
+
Datagrid.propTypes = {
|
78
|
+
/**
|
79
|
+
* The data grid state, much of it being supplied by the useDatagrid hook
|
80
|
+
*/
|
81
|
+
datagridState: PropTypes.object.isRequired
|
82
|
+
};
|
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* (c) Copyright IBM Corp. 2020, 2021
|
7
|
-
* US Government Users Restricted Rights - Use, duplication or disclosure
|
8
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 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.
|
9
6
|
*/
|
10
7
|
import React from 'react';
|
11
8
|
import { DataTable } from 'carbon-components-react';
|
@@ -16,14 +13,9 @@ var DatagridHead = function DatagridHead(datagridState) {
|
|
16
13
|
headerGroups = _datagridState$header === void 0 ? [] : _datagridState$header,
|
17
14
|
headRef = datagridState.headRef,
|
18
15
|
HeaderRow = datagridState.HeaderRow;
|
19
|
-
return /*#__PURE__*/React.createElement(TableHead, null, headerGroups.map(function (headerGroup
|
20
|
-
return (
|
21
|
-
|
22
|
-
// doesn't support header grouping.
|
23
|
-
React.createElement("div", _extends({}, headerGroup.getHeaderGroupProps(), {
|
24
|
-
ref: headRef,
|
25
|
-
key: "header_".concat(index)
|
26
|
-
}), HeaderRow(datagridState))
|
16
|
+
return /*#__PURE__*/React.createElement(TableHead, null, headerGroups.map(function (headerGroup) {
|
17
|
+
return (// doesn't support header grouping.
|
18
|
+
HeaderRow(datagridState, headRef, headerGroup)
|
27
19
|
);
|
28
20
|
}));
|
29
21
|
};
|
@@ -1,12 +1,11 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
|
4
|
-
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
4
|
+
/**
|
5
|
+
* Copyright IBM Corp. 2020, 2022
|
6
|
+
*
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
10
9
|
*/
|
11
10
|
// @flow
|
12
11
|
import React from 'react';
|
@@ -16,10 +15,11 @@ import { selectionColumnId } from '../common-column-ids';
|
|
16
15
|
import { pkg } from '../../../settings';
|
17
16
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
17
|
|
19
|
-
var HeaderRow = function HeaderRow(datagridState) {
|
20
|
-
return /*#__PURE__*/React.createElement(TableRow, {
|
21
|
-
className: "".concat(blockClass, "__head")
|
22
|
-
|
18
|
+
var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
19
|
+
return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps(), {
|
20
|
+
className: cx("".concat(blockClass, "__head"), headerGroup.getHeaderGroupProps().className),
|
21
|
+
ref: headRef
|
22
|
+
}), datagridState.headers.filter(function (_ref) {
|
23
23
|
var isVisible = _ref.isVisible;
|
24
24
|
return isVisible;
|
25
25
|
}).map(function (header) {
|
@@ -1,8 +1,7 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2020, 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.
|
7
6
|
*/
|
8
|
-
export {
|
7
|
+
export { Datagrid } from './Datagrid';
|
@@ -5,7 +5,7 @@
|
|
5
5
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
6
6
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
7
7
|
*/
|
8
|
-
export {
|
8
|
+
export { Datagrid } from './Datagrid';
|
9
9
|
export { default as useDatagrid } from './useDatagrid';
|
10
10
|
export { default as useInfiniteScroll } from './useInfiniteScroll';
|
11
11
|
export { default as useNestedRows } from './useNestedRows';
|
@@ -14,7 +14,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
14
14
|
// This source code is licensed under the Apache-2.0 license found in the
|
15
15
|
// LICENSE file in the root directory of this source tree.
|
16
16
|
//
|
17
|
-
import React, { useState, useRef, forwardRef } from 'react';
|
17
|
+
import React, { useState, useRef, forwardRef, useEffect } from 'react';
|
18
18
|
import { Button, ComposedModal, ModalHeader, ModalFooter, ModalBody, TextInput, RadioButton, RadioButtonGroup, FormGroup, Loading, PasswordInput } from 'carbon-components-react';
|
19
19
|
import cx from 'classnames';
|
20
20
|
import { ErrorFilled16, CheckmarkFilled16 } from '@carbon/icons-react';
|
@@ -30,8 +30,6 @@ var defaults = {
|
|
30
30
|
validExtensions: Object.freeze([])
|
31
31
|
};
|
32
32
|
export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
33
|
-
var _preformattedExtensio;
|
34
|
-
|
35
33
|
var body = _ref.body,
|
36
34
|
className = _ref.className,
|
37
35
|
error = _ref.error,
|
@@ -60,7 +58,7 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
60
58
|
validExtensions = _ref$validExtensions === void 0 ? defaults.validExtensions : _ref$validExtensions,
|
61
59
|
rest = _objectWithoutProperties(_ref, _excluded);
|
62
60
|
|
63
|
-
var _useState = useState(
|
61
|
+
var _useState = useState(''),
|
64
62
|
_useState2 = _slicedToArray(_useState, 2),
|
65
63
|
name = _useState2[0],
|
66
64
|
setName = _useState2[1];
|
@@ -71,11 +69,18 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
71
69
|
setDirtyInput = _useState4[1]; // by default (if it exists) use the first extension in the extension array
|
72
70
|
|
73
71
|
|
74
|
-
var _useState5 = useState(
|
72
|
+
var _useState5 = useState(''),
|
75
73
|
_useState6 = _slicedToArray(_useState5, 2),
|
76
74
|
extension = _useState6[0],
|
77
75
|
setExtension = _useState6[1];
|
78
76
|
|
77
|
+
useEffect(function () {
|
78
|
+
var _preformattedExtensio;
|
79
|
+
|
80
|
+
setName(filename);
|
81
|
+
setExtension(preformattedExtensions === null || preformattedExtensions === void 0 ? void 0 : (_preformattedExtensio = preformattedExtensions[0]) === null || _preformattedExtensio === void 0 ? void 0 : _preformattedExtensio.extension);
|
82
|
+
}, [filename, preformattedExtensions]);
|
83
|
+
|
79
84
|
var onNameChangeHandler = function onNameChangeHandler(evt) {
|
80
85
|
setName(evt.target.value);
|
81
86
|
};
|
@@ -272,13 +272,17 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
272
272
|
|
273
273
|
var actionToolbarElement = document.querySelector(".".concat(blockClass, "__action-toolbar"));
|
274
274
|
|
275
|
+
var _labelText = document.querySelector(".".concat(blockClass, "__label-text"));
|
276
|
+
|
275
277
|
var _sidePanelSubtitleElementHeight = (_sidePanelSubtitleElement === null || _sidePanelSubtitleElement === void 0 ? void 0 : _sidePanelSubtitleElement.offsetHeight) || 0;
|
276
278
|
|
277
279
|
var sidePanelActionBarElementHeight = (actionToolbarElement === null || actionToolbarElement === void 0 ? void 0 : actionToolbarElement.offsetHeight) || 0;
|
278
280
|
var titleHeight = (_sidePanelTitleElement === null || _sidePanelTitleElement === void 0 ? void 0 : _sidePanelTitleElement.offsetHeight) + 24;
|
281
|
+
var labelHeight = (_labelText === null || _labelText === void 0 ? void 0 : _labelText.offsetHeight) || 0;
|
279
282
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-text-height"), "".concat(titleHeight, "px"));
|
280
283
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--subtitle-container-height"), "".concat(_sidePanelSubtitleElementHeight, "px"));
|
281
284
|
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--action-bar-container-height"), "".concat(sidePanelActionBarElementHeight, "px"));
|
285
|
+
_sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--label-text-height"), "".concat(labelHeight, "px"));
|
282
286
|
}
|
283
287
|
}, [open, animateTitle, animationComplete, shouldRender, panelHeight, title, size, reducedMotion.matches]); // click outside functionality if `includeOverlay` prop is set
|
284
288
|
|
@@ -492,7 +496,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
492
496
|
className: "".concat(blockClass, "__visually-hidden")
|
493
497
|
}, "Focus sentinel"), !animateTitle && renderHeader(), /*#__PURE__*/React.createElement("div", {
|
494
498
|
ref: sidePanelInnerRef,
|
495
|
-
className: cx("".concat(blockClass, "__inner-content"), (_cx4 = {}, _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content"), !animateTitle), _defineProperty(_cx4, "".concat(blockClass, "__inner-content-with-actions"), actions && actions.length), _cx4))
|
499
|
+
className: cx("".concat(blockClass, "__inner-content"), (_cx4 = {}, _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content"), !animateTitle), _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content-no-actions"), !animateTitle && !(actions !== null && actions !== void 0 && actions.length)), _defineProperty(_cx4, "".concat(blockClass, "__inner-content-with-actions"), actions && actions.length), _cx4))
|
496
500
|
}, animateTitle && renderHeader(), /*#__PURE__*/React.createElement("div", {
|
497
501
|
className: "".concat(blockClass, "__body-content")
|
498
502
|
}, children), /*#__PURE__*/React.createElement(ActionSet, {
|
@@ -22,7 +22,8 @@ import cx from 'classnames';
|
|
22
22
|
import { pkg } from '../../settings'; // Carbon and package components we use.
|
23
23
|
|
24
24
|
import { Close16 as Close, Help16 as Help } from '@carbon/icons-react';
|
25
|
-
import { Button, OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
25
|
+
import { Button, OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
26
|
+
import { moderate02 } from '@carbon/motion'; // The block part of our conventional BEM class names (blockClass__E--M).
|
26
27
|
|
27
28
|
var componentName = 'WebTerminal';
|
28
29
|
var blockClass = "".concat(pkg.prefix, "--web-terminal"); // Default values for props
|
@@ -33,7 +34,7 @@ var defaults = {
|
|
33
34
|
documentationLinksIconDescription: 'Show documentation links'
|
34
35
|
};
|
35
36
|
export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
36
|
-
var
|
37
|
+
var _ref3;
|
37
38
|
|
38
39
|
var _ref$actions = _ref.actions,
|
39
40
|
actions = _ref$actions === void 0 ? defaults.actions : _ref$actions,
|
@@ -53,6 +54,12 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
53
54
|
shouldRender = _useState2[0],
|
54
55
|
setRender = _useState2[1];
|
55
56
|
|
57
|
+
var _ref2 = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
|
58
|
+
matches: true
|
59
|
+
},
|
60
|
+
prefersReducedMotion = _ref2.matches;
|
61
|
+
|
62
|
+
var webTerminalAnimationName = "".concat(open ? 'web-terminal-entrance' : 'web-terminal-exit', " ").concat(moderate02);
|
56
63
|
var showDocumentationLinks = useMemo(function () {
|
57
64
|
return documentationLinks.length > 0;
|
58
65
|
}, [documentationLinks]);
|
@@ -61,6 +68,9 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
61
68
|
setRender(true);
|
62
69
|
}
|
63
70
|
}, [open]);
|
71
|
+
/**
|
72
|
+
When the web terminal slide in animation is complete, sets render to false.
|
73
|
+
*/
|
64
74
|
|
65
75
|
var onAnimationEnd = function onAnimationEnd() {
|
66
76
|
if (!open) {
|
@@ -68,11 +78,23 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
68
78
|
}
|
69
79
|
};
|
70
80
|
|
81
|
+
var handleCloseTerminal = function handleCloseTerminal() {
|
82
|
+
/**
|
83
|
+
If the user prefers reduced motion, we have to manually set render to false
|
84
|
+
because onAnimationEnd will never be called.
|
85
|
+
*/
|
86
|
+
if (prefersReducedMotion) {
|
87
|
+
setRender(false);
|
88
|
+
}
|
89
|
+
|
90
|
+
closeTerminal();
|
91
|
+
};
|
92
|
+
|
71
93
|
return shouldRender ? /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
72
94
|
ref: ref,
|
73
|
-
className: cx([className, blockClass, (
|
95
|
+
className: cx([className, blockClass, (_ref3 = {}, _defineProperty(_ref3, "".concat(blockClass, "--open"), open), _defineProperty(_ref3, "".concat(blockClass, "--closed"), !open), _ref3)]),
|
74
96
|
style: {
|
75
|
-
animation:
|
97
|
+
animation: !prefersReducedMotion && webTerminalAnimationName
|
76
98
|
},
|
77
99
|
onAnimationEnd: onAnimationEnd
|
78
100
|
}), /*#__PURE__*/React.createElement("header", {
|
@@ -84,16 +106,16 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
84
106
|
iconDescription: documentationLinksIconDescription,
|
85
107
|
menuOptionsClass: "".concat(blockClass, "__documentation-overflow"),
|
86
108
|
size: "lg"
|
87
|
-
}, documentationLinks.map(function (
|
88
|
-
var rest = _extends({},
|
109
|
+
}, documentationLinks.map(function (_ref4, i) {
|
110
|
+
var rest = _extends({}, _ref4);
|
89
111
|
|
90
112
|
return /*#__PURE__*/React.createElement(OverflowMenuItem, _extends({
|
91
113
|
key: i
|
92
114
|
}, rest));
|
93
|
-
})), actions.map(function (
|
94
|
-
var renderIcon =
|
95
|
-
onClick =
|
96
|
-
iconDescription =
|
115
|
+
})), actions.map(function (_ref5) {
|
116
|
+
var renderIcon = _ref5.renderIcon,
|
117
|
+
onClick = _ref5.onClick,
|
118
|
+
iconDescription = _ref5.iconDescription;
|
97
119
|
return /*#__PURE__*/React.createElement(Button, {
|
98
120
|
key: iconDescription,
|
99
121
|
hasIconOnly: true,
|
@@ -107,7 +129,10 @@ export var WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
107
129
|
renderIcon: Close,
|
108
130
|
kind: "ghost",
|
109
131
|
iconDescription: closeIconDescription,
|
110
|
-
onClick:
|
132
|
+
onClick: handleCloseTerminal,
|
133
|
+
onAnimationEnd: function onAnimationEnd(event) {
|
134
|
+
return event.stopPropagation();
|
135
|
+
}
|
111
136
|
})), /*#__PURE__*/React.createElement("div", {
|
112
137
|
className: "".concat(blockClass, "__body")
|
113
138
|
}, children)) : null;
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
var _excluded = ["children", "isTerminalOpen"];
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Copyright IBM Corp. 2020, 2021
|
8
|
+
*
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
11
|
+
*/
|
12
|
+
// Import portions of React that are needed.
|
13
|
+
import React from 'react'; // Other standard imports.
|
14
|
+
|
15
|
+
import PropTypes from 'prop-types';
|
16
|
+
import cx from 'classnames';
|
17
|
+
import { pkg } from '../../settings'; // The block part of our conventional BEM class names (blockClass__E--M).
|
18
|
+
|
19
|
+
var componentName = 'WebTerminalContentWrapper';
|
20
|
+
var blockClass = "".concat(pkg.prefix, "--web-terminal-content-wrapper");
|
21
|
+
export var WebTerminalContentWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
22
|
+
var children = _ref.children,
|
23
|
+
isTerminalOpen = _ref.isTerminalOpen,
|
24
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
25
|
+
|
26
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
27
|
+
ref: ref,
|
28
|
+
className: cx([blockClass, _defineProperty({}, "".concat(blockClass, "--open"), isTerminalOpen)])
|
29
|
+
}, rest), children);
|
30
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
31
|
+
|
32
|
+
WebTerminalContentWrapper = pkg.checkComponentEnabled(WebTerminalContentWrapper, componentName); // The display name of the component, used by React. Note that displayName
|
33
|
+
// is used in preference to relying on function.name.
|
34
|
+
|
35
|
+
WebTerminalContentWrapper.displayName = componentName; // The types and DocGen commentary for the component props,
|
36
|
+
// in alphabetical order (for consistency).
|
37
|
+
// See https://www.npmjs.com/package/prop-types#usage.
|
38
|
+
|
39
|
+
WebTerminalContentWrapper.propTypes = {
|
40
|
+
/**
|
41
|
+
* Pass in content as children.
|
42
|
+
*/
|
43
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
44
|
+
|
45
|
+
/**
|
46
|
+
* A boolean to determine if the terminal is open.
|
47
|
+
*/
|
48
|
+
isTerminalOpen: PropTypes.bool.isRequired
|
49
|
+
};
|
@@ -1 +1,2 @@
|
|
1
|
-
export { WebTerminal } from './WebTerminal';
|
1
|
+
export { WebTerminal } from './WebTerminal';
|
2
|
+
export { WebTerminalContentWrapper } from './WebTerminalContentWrapper';
|
package/es/components/index.js
CHANGED
@@ -32,7 +32,7 @@ export { TagSet } from './TagSet';
|
|
32
32
|
export { Tearsheet, TearsheetNarrow } from './Tearsheet';
|
33
33
|
export { Toolbar, ToolbarButton, ToolbarGroup } from './Toolbar';
|
34
34
|
export { UserProfileImage } from './UserProfileImage';
|
35
|
-
export { WebTerminal } from './WebTerminal';
|
35
|
+
export { WebTerminal, WebTerminalContentWrapper } from './WebTerminal';
|
36
36
|
export { EditSidePanel } from './EditSidePanel';
|
37
37
|
export { OptionsTile } from './OptionsTile';
|
38
38
|
export { InlineEdit } from './InlineEdit';
|
@@ -613,6 +613,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
613
613
|
var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
614
614
|
setCellEditorValue(activeCellValue);
|
615
615
|
cellEditorRulerRef.current.textContent = activeCellValue;
|
616
|
+
cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.width;
|
616
617
|
}; // Sets the initial placement of the cell editor cursor at the end of the text area
|
617
618
|
// this is not done for us by default in Safari
|
618
619
|
|