@carbon/ibm-products 1.31.0 → 1.32.1
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +71 -5
- 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 +67 -5
- 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 +67 -5
- 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.js +1 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
- package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +2 -2
- package/es/components/Datagrid/Datagrid/DatagridContent.js +43 -18
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +10 -2
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +12 -3
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +1 -4
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -8
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +9 -1
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +153 -87
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +66 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
- package/es/components/Datagrid/useActionsColumn.js +28 -12
- package/es/components/Datagrid/useExpandedRow.js +0 -1
- package/es/components/Datagrid/useNestedRowExpander.js +42 -0
- package/es/components/Datagrid/useNestedRows.js +2 -2
- package/es/components/Datagrid/useSelectAllToggle.js +17 -4
- package/es/components/Datagrid/utils/DatagridActions.js +121 -0
- package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
- package/es/components/Datagrid/utils/Wrapper.js +21 -0
- package/es/components/Datagrid/utils/getArgTypes.js +85 -0
- package/es/components/Datagrid/utils/makeData.js +25 -5
- package/es/components/InlineEdit/InlineEdit.js +7 -7
- package/es/components/OptionsTile/OptionsTile.js +4 -2
- package/es/global/js/utils/story-helper.js +5 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
- package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +2 -2
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +44 -18
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +19 -2
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +14 -3
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +1 -4
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -8
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +10 -7
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +155 -87
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +78 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
- package/lib/components/Datagrid/useActionsColumn.js +28 -13
- package/lib/components/Datagrid/useExpandedRow.js +0 -1
- package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
- package/lib/components/Datagrid/useNestedRows.js +3 -3
- package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
- package/lib/components/Datagrid/utils/DatagridActions.js +139 -0
- package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
- package/lib/components/Datagrid/utils/Wrapper.js +33 -0
- package/lib/components/Datagrid/utils/getArgTypes.js +93 -0
- package/lib/components/Datagrid/utils/makeData.js +26 -5
- package/lib/components/InlineEdit/InlineEdit.js +7 -7
- package/lib/components/OptionsTile/OptionsTile.js +4 -2
- package/lib/global/js/utils/story-helper.js +5 -1
- package/package.json +12 -12
- package/scss/components/Datagrid/styles/_datagrid.scss +0 -4
- package/scss/components/Datagrid/styles/_useActionsColumn.scss +12 -0
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +30 -0
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +6 -0
- package/scss/components/Datagrid/styles/_useNestedRows.scss +15 -1
- package/scss/components/Datagrid/styles/_useStickyColumn.scss +6 -0
- package/scss/components/OptionsTile/_options-tile.scss +4 -0
@@ -37,6 +37,8 @@ var _handleGridFocus = require("./addons/InlineEdit/handleGridFocus");
|
|
37
37
|
|
38
38
|
var _hooks = require("../../../global/js/hooks");
|
39
39
|
|
40
|
+
var _hooks2 = require("../../DataSpreadsheet/hooks");
|
41
|
+
|
40
42
|
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); }
|
41
43
|
|
42
44
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -46,8 +48,6 @@ var TableContainer = _carbonComponentsReact.DataTable.TableContainer,
|
|
46
48
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
47
49
|
|
48
50
|
var DatagridContent = function DatagridContent(_ref) {
|
49
|
-
var _getTableProps;
|
50
|
-
|
51
51
|
var datagridState = _ref.datagridState;
|
52
52
|
|
53
53
|
var _useContext = (0, _react.useContext)(_InlineEditContext.InlineEditContext),
|
@@ -71,8 +71,10 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
71
71
|
useDenseHeader = datagridState.useDenseHeader,
|
72
72
|
withInlineEdit = datagridState.withInlineEdit;
|
73
73
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
74
|
-
var gridActive = state.gridActive
|
74
|
+
var gridActive = state.gridActive,
|
75
|
+
editId = state.editId;
|
75
76
|
var gridAreaRef = (0, _react.useRef)();
|
77
|
+
var multiKeyTrackingRef = (0, _react.useRef)();
|
76
78
|
(0, _hooks.useClickOutside)(gridAreaRef, function (target) {
|
77
79
|
if (!withInlineEdit) {
|
78
80
|
return;
|
@@ -81,7 +83,7 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
81
83
|
// and swapped out with an input, i.e. text, number, selection, or date picker
|
82
84
|
|
83
85
|
|
84
|
-
if (target.closest(".".concat(blockClass, "__inline-edit-button")) || target.closest(".".concat(blockClass, "__inline-edit--select"))) {
|
86
|
+
if (target.closest(".".concat(blockClass, "__inline-edit-button")) || target.closest(".".concat(blockClass, "__inline-edit--select")) || target.closest(".".concat(blockClass, "__row-size-button"))) {
|
85
87
|
return;
|
86
88
|
}
|
87
89
|
|
@@ -90,6 +92,40 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
90
92
|
payload: activeCellId
|
91
93
|
});
|
92
94
|
});
|
95
|
+
|
96
|
+
var renderTable = function renderTable() {
|
97
|
+
var _getTableProps;
|
98
|
+
|
99
|
+
return /*#__PURE__*/_react.default.createElement(Table, (0, _extends2.default)({}, getTableProps(), {
|
100
|
+
className: (0, _classnames.default)(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), (0, _defineProperty2.default)({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-grid-active"), gridActive), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
|
101
|
+
role: withInlineEdit && 'grid',
|
102
|
+
tabIndex: withInlineEdit && 0,
|
103
|
+
onKeyDown: withInlineEdit ? function (event) {
|
104
|
+
return (0, _handleGridKeyPress.handleGridKeyPress)({
|
105
|
+
event: event,
|
106
|
+
dispatch: dispatch,
|
107
|
+
state: state,
|
108
|
+
instance: datagridState,
|
109
|
+
keysPressedList: keysPressedList,
|
110
|
+
usingMac: usingMac
|
111
|
+
});
|
112
|
+
} : null,
|
113
|
+
onFocus: withInlineEdit ? function () {
|
114
|
+
return (0, _handleGridFocus.handleGridFocus)(state, dispatch);
|
115
|
+
} : null
|
116
|
+
}), /*#__PURE__*/_react.default.createElement(_DatagridHead.default, datagridState), /*#__PURE__*/_react.default.createElement(_DatagridBody.default, (0, _extends2.default)({}, datagridState, {
|
117
|
+
rows: rows
|
118
|
+
})));
|
119
|
+
};
|
120
|
+
|
121
|
+
var _useMultipleKeyTracki = (0, _hooks2.useMultipleKeyTracking)({
|
122
|
+
ref: withInlineEdit ? multiKeyTrackingRef : null,
|
123
|
+
containerHasFocus: gridActive,
|
124
|
+
isEditing: !!editId
|
125
|
+
}),
|
126
|
+
keysPressedList = _useMultipleKeyTracki.keysPressedList,
|
127
|
+
usingMac = _useMultipleKeyTracki.usingMac;
|
128
|
+
|
93
129
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TableContainer, {
|
94
130
|
className: (0, _classnames.default)("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : ''),
|
95
131
|
title: gridTitle,
|
@@ -99,19 +135,9 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
99
135
|
ref: gridAreaRef
|
100
136
|
}, leftPanel && leftPanel.isOpen && /*#__PURE__*/_react.default.createElement("div", {
|
101
137
|
className: "".concat(blockClass, "__datagridLeftPanel")
|
102
|
-
}, leftPanel.panelContent), /*#__PURE__*/_react.default.createElement(
|
103
|
-
|
104
|
-
|
105
|
-
tabIndex: withInlineEdit && 0,
|
106
|
-
onKeyDown: withInlineEdit ? function (event) {
|
107
|
-
return (0, _handleGridKeyPress.handleGridKeyPress)(event, dispatch, state, datagridState);
|
108
|
-
} : null,
|
109
|
-
onFocus: withInlineEdit ? function () {
|
110
|
-
return (0, _handleGridFocus.handleGridFocus)(state, dispatch);
|
111
|
-
} : null
|
112
|
-
}), /*#__PURE__*/_react.default.createElement(_DatagridHead.default, datagridState), /*#__PURE__*/_react.default.createElement(_DatagridBody.default, (0, _extends2.default)({}, datagridState, {
|
113
|
-
rows: rows
|
114
|
-
}))))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/_react.default.createElement(CustomizeColumnsModal, {
|
138
|
+
}, leftPanel.panelContent), withInlineEdit ? /*#__PURE__*/_react.default.createElement("div", {
|
139
|
+
ref: multiKeyTrackingRef
|
140
|
+
}, renderTable()) : renderTable())), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/_react.default.createElement(CustomizeColumnsModal, {
|
115
141
|
instance: datagridState
|
116
142
|
}));
|
117
143
|
};
|
@@ -121,7 +147,7 @@ DatagridContent.propTypes = {
|
|
121
147
|
datagridState: _propTypes.default.shape({
|
122
148
|
getTableProps: _propTypes.default.func,
|
123
149
|
withVirtualScroll: _propTypes.default.bool,
|
124
|
-
DatagridPagination: _propTypes.default.element,
|
150
|
+
DatagridPagination: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
|
125
151
|
CustomizeColumnsModal: _propTypes.default.element,
|
126
152
|
isFetching: _propTypes.default.bool,
|
127
153
|
leftPanel: _propTypes.default.object,
|
@@ -24,13 +24,21 @@ var DatagridExpandedRow = function DatagridExpandedRow(PreviousRowRenderer, Expa
|
|
24
24
|
return function (datagridState) {
|
25
25
|
var row = datagridState.row;
|
26
26
|
|
27
|
+
var _ref = row || {},
|
28
|
+
expandedContentHeight = _ref.expandedContentHeight;
|
29
|
+
|
27
30
|
if (!row.isExpanded) {
|
28
31
|
return PreviousRowRenderer(datagridState);
|
29
32
|
}
|
30
33
|
|
31
34
|
return /*#__PURE__*/_react.default.createElement("div", {
|
32
35
|
className: "".concat(blockClass, "__expanded-row")
|
33
|
-
}, PreviousRowRenderer(datagridState),
|
36
|
+
}, PreviousRowRenderer(datagridState), /*#__PURE__*/_react.default.createElement("div", {
|
37
|
+
className: "".concat(blockClass, "__expanded-row-content"),
|
38
|
+
style: {
|
39
|
+
height: expandedContentHeight ? expandedContentHeight : null
|
40
|
+
}
|
41
|
+
}, ExpandedRowContentComponent(datagridState)));
|
34
42
|
};
|
35
43
|
};
|
36
44
|
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
4
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
+
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
6
8
|
value: true
|
7
9
|
});
|
@@ -13,7 +15,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
13
15
|
|
14
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
17
|
|
16
|
-
var _react =
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
17
19
|
|
18
20
|
var _carbonComponentsReact = require("carbon-components-react");
|
19
21
|
|
@@ -23,7 +25,16 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
23
25
|
|
24
26
|
var _settings = require("../../../settings");
|
25
27
|
|
28
|
+
var _InlineEditContext = require("./addons/InlineEdit/InlineEditContext/InlineEditContext");
|
29
|
+
|
30
|
+
var _getCellIdAsObject = require("./addons/InlineEdit/InlineEditContext/getCellIdAsObject");
|
31
|
+
|
26
32
|
var _excluded = ["children"];
|
33
|
+
|
34
|
+
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); }
|
35
|
+
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
37
|
+
|
27
38
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
28
39
|
var TableRow = _carbonComponentsReact.DataTable.TableRow,
|
29
40
|
TableCell = _carbonComponentsReact.DataTable.TableCell; // eslint-disable-next-line react/prop-types
|
@@ -32,8 +43,14 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
32
43
|
var _cx;
|
33
44
|
|
34
45
|
var row = datagridState.row;
|
46
|
+
|
47
|
+
var _useContext = (0, _react.useContext)(_InlineEditContext.InlineEditContext),
|
48
|
+
state = _useContext.state;
|
49
|
+
|
50
|
+
var activeCellId = state.activeCellId;
|
51
|
+
var activeCellObject = activeCellId && (0, _getCellIdAsObject.getCellIdAsObject)(activeCellId);
|
35
52
|
return /*#__PURE__*/_react.default.createElement(TableRow, (0, _extends2.default)({
|
36
|
-
className: (0, _classnames.default)("".concat(blockClass, "__carbon-row"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), (0, _defineProperty2.default)(_cx, "".concat(_settings.carbon.prefix, "--data-table--selected"), row.isSelected), _cx))
|
53
|
+
className: (0, _classnames.default)("".concat(blockClass, "__carbon-row"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), (0, _defineProperty2.default)(_cx, "".concat(_settings.carbon.prefix, "--data-table--selected"), row.isSelected), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-hover-active"), activeCellObject && row.index === activeCellObject.row), _cx))
|
37
54
|
}, row.getRowProps(), {
|
38
55
|
key: row.id,
|
39
56
|
onMouseEnter: function onMouseEnter(event) {
|
@@ -11,6 +11,8 @@ exports.default = void 0;
|
|
11
11
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13
13
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
|
+
|
14
16
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15
17
|
|
16
18
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
@@ -19,6 +21,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
19
21
|
|
20
22
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
21
23
|
|
24
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
25
|
+
|
22
26
|
var _carbonComponentsReact = require("carbon-components-react");
|
23
27
|
|
24
28
|
var _iconsReact = require("@carbon/icons-react");
|
@@ -37,6 +41,8 @@ var SELECT_ALL_PAGE_ROWS = 'pageRows';
|
|
37
41
|
var SELECT_ALL_ROWS = 'allRows';
|
38
42
|
|
39
43
|
var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
44
|
+
var _columns$;
|
45
|
+
|
40
46
|
var tableId = _ref.tableId,
|
41
47
|
isFetching = _ref.isFetching,
|
42
48
|
isAllRowsSelected = _ref.isAllRowsSelected,
|
@@ -46,7 +52,9 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
46
52
|
_ref$allPageRowsLabel = _ref.allPageRowsLabel,
|
47
53
|
allPageRowsLabel = _ref$allPageRowsLabel === void 0 ? 'Select all on page' : _ref$allPageRowsLabel,
|
48
54
|
_ref$allRowsLabel = _ref.allRowsLabel,
|
49
|
-
allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel
|
55
|
+
allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel,
|
56
|
+
columns = _ref.columns,
|
57
|
+
withStickyColumn = _ref.withStickyColumn;
|
50
58
|
|
51
59
|
var _useState = (0, _react.useState)(SELECT_ALL_PAGE_ROWS),
|
52
60
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
@@ -75,10 +83,11 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
75
83
|
selectProps = (0, _objectWithoutProperties2.default)(_getProps, _excluded);
|
76
84
|
|
77
85
|
var disabled = isFetching || selectProps.disabled;
|
86
|
+
var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
|
78
87
|
return /*#__PURE__*/_react.default.createElement("th", {
|
79
88
|
role: "columnheader",
|
80
89
|
scope: "col",
|
81
|
-
className: "".concat(blockClass, "__select-all-toggle-on")
|
90
|
+
className: (0, _classnames.default)("".concat(blockClass, "__select-all-toggle-on"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft))
|
82
91
|
}, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Checkbox, (0, _extends2.default)({}, selectProps, {
|
83
92
|
name: "".concat(tableId, "-select-all-checkbox-name"),
|
84
93
|
onClick: function onClick(e) {
|
@@ -126,12 +135,14 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
126
135
|
SelectAllWithToggle.propTypes = {
|
127
136
|
allPageRowsLabel: _propTypes.default.string,
|
128
137
|
allRowsLabel: _propTypes.default.string,
|
138
|
+
columns: _propTypes.default.arrayOf(_propTypes.default.object),
|
129
139
|
getToggleAllPageRowsSelectedProps: _propTypes.default.func.isRequired,
|
130
140
|
getToggleAllRowsSelectedProps: _propTypes.default.func.isRequired,
|
131
141
|
isAllRowsSelected: _propTypes.default.bool.isRequired,
|
132
142
|
isFetching: _propTypes.default.bool,
|
133
143
|
selectAllToggle: _propTypes.default.object,
|
134
|
-
tableId: _propTypes.default.string.isRequired
|
144
|
+
tableId: _propTypes.default.string.isRequired,
|
145
|
+
withStickyColumn: _propTypes.default.bool
|
135
146
|
};
|
136
147
|
var _default = SelectAllWithToggle;
|
137
148
|
exports.default = _default;
|
package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js
CHANGED
@@ -34,8 +34,6 @@ var InlineEditButton = function InlineEditButton(_ref) {
|
|
34
34
|
disabled = _ref.disabled,
|
35
35
|
LabelIcon = _ref.labelIcon,
|
36
36
|
placeholder = _ref.placeholder,
|
37
|
-
_ref$tabIndex = _ref.tabIndex,
|
38
|
-
tabIndex = _ref$tabIndex === void 0 ? -1 : _ref$tabIndex,
|
39
37
|
nonEditCell = _ref.nonEditCell,
|
40
38
|
isActiveCell = _ref.isActiveCell,
|
41
39
|
columnConfig = _ref.columnConfig,
|
@@ -45,7 +43,7 @@ var InlineEditButton = function InlineEditButton(_ref) {
|
|
45
43
|
var inlineEditColsLessThanHalfOfTotal = totalInlineEditColumns < totalColumns / 2;
|
46
44
|
return /*#__PURE__*/_react.default.createElement("div", {
|
47
45
|
className: (0, _classnames.default)("".concat(blockClass, "__inline-edit-button"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--edit-less-than-half-of-total-cols"), inlineEditColsLessThanHalfOfTotal), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
|
48
|
-
tabIndex:
|
46
|
+
tabIndex: isActiveCell ? 0 : -1,
|
49
47
|
"data-disabled": disabled || nonEditCell,
|
50
48
|
"aria-disabled": disabled || nonEditCell,
|
51
49
|
role: "button",
|
@@ -71,7 +69,6 @@ InlineEditButton.propTypes = {
|
|
71
69
|
nonEditCell: _propTypes.default.bool,
|
72
70
|
placeholder: _propTypes.default.string,
|
73
71
|
renderIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
74
|
-
tabIndex: _propTypes.default.number,
|
75
72
|
totalColumns: _propTypes.default.number,
|
76
73
|
totalInlineEditColumns: _propTypes.default.number,
|
77
74
|
type: _propTypes.default.oneOf(['text', 'number', 'selection', 'date']),
|
@@ -55,8 +55,6 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
55
55
|
placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
|
56
56
|
tabIndex = _ref.tabIndex,
|
57
57
|
value = _ref.value,
|
58
|
-
_ref$label = _ref.label,
|
59
|
-
label = _ref$label === void 0 ? 'Inline edit type text label' : _ref$label,
|
60
58
|
nonEditCell = _ref.nonEditCell,
|
61
59
|
totalInlineEditColumns = _ref.totalInlineEditColumns,
|
62
60
|
type = _ref.type;
|
@@ -86,6 +84,11 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
86
84
|
initialValue = _useState6[0],
|
87
85
|
setInitialValue = _useState6[1];
|
88
86
|
|
87
|
+
var _useState7 = (0, _react.useState)(),
|
88
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
89
|
+
cellLabel = _useState8[0],
|
90
|
+
setCellLabel = _useState8[1];
|
91
|
+
|
89
92
|
var activeCellId = state.activeCellId,
|
90
93
|
editId = state.editId;
|
91
94
|
var previousState = (0, _hooks.usePreviousValue)({
|
@@ -102,7 +105,12 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
102
105
|
var datePickerRef = (0, _react.useRef)();
|
103
106
|
var outerButtonElement = (0, _react.useRef)();
|
104
107
|
(0, _react.useEffect)(function () {
|
105
|
-
setInitialValue(value);
|
108
|
+
setInitialValue(value);
|
109
|
+
var columnId = cell.column.id;
|
110
|
+
var columnLabel = instance.columns.find(function (item) {
|
111
|
+
return item.id === columnId;
|
112
|
+
});
|
113
|
+
setCellLabel(typeof columnLabel.Header === 'string' ? columnLabel.Header : 'Inline edit cell label'); // eslint-disable-next-line react-hooks/exhaustive-deps
|
106
114
|
}, []); // If you are in edit mode and click outside of the cell,
|
107
115
|
// this changes the cell back to the InlineEditButton
|
108
116
|
|
@@ -270,7 +278,8 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
270
278
|
|
271
279
|
return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Dropdown, (0, _extends2.default)({
|
272
280
|
id: cellId,
|
273
|
-
label:
|
281
|
+
label: cellLabel || 'Dropdown menu options',
|
282
|
+
ariaLabel: cellLabel || 'Dropdown menu options'
|
274
283
|
}, inputProps, {
|
275
284
|
hideLabel: true,
|
276
285
|
style: {
|
@@ -372,7 +381,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
372
381
|
position: 'static'
|
373
382
|
},
|
374
383
|
placeholder: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.placeholder) || 'mm/dd/yyyy',
|
375
|
-
labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || 'Set date',
|
384
|
+
labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || cellLabel || 'Set date',
|
376
385
|
id: datePickerInputProps.id || "".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index),
|
377
386
|
hideLabel: true
|
378
387
|
})));
|
@@ -429,7 +438,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
429
438
|
totalColumns: totalColumns,
|
430
439
|
type: type
|
431
440
|
}), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, type === 'text' && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextInput, (0, _extends2.default)({
|
432
|
-
labelText:
|
441
|
+
labelText: cellLabel,
|
433
442
|
placeholder: placeholder
|
434
443
|
}, inputProps, {
|
435
444
|
id: cellId,
|
@@ -445,7 +454,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
|
|
445
454
|
ref: textInputRef
|
446
455
|
})), type === 'number' && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.NumberInput, (0, _extends2.default)({
|
447
456
|
placeholder: placeholder,
|
448
|
-
label:
|
457
|
+
label: cellLabel
|
449
458
|
}, inputProps, {
|
450
459
|
id: cellId,
|
451
460
|
hideLabel: true,
|
@@ -473,7 +482,6 @@ InlineEditCell.propTypes = {
|
|
473
482
|
rowSize: _propTypes.default.string,
|
474
483
|
tableId: _propTypes.default.string
|
475
484
|
}),
|
476
|
-
label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
477
485
|
nonEditCell: _propTypes.default.bool,
|
478
486
|
placeholder: _propTypes.default.string,
|
479
487
|
tabIndex: _propTypes.default.number,
|
@@ -9,18 +9,15 @@ exports.returnUpdatedActiveCell = void 0;
|
|
9
9
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
11
|
|
12
|
+
var _settings = require("../../../../../../settings");
|
13
|
+
|
12
14
|
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; }
|
13
15
|
|
14
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
17
|
|
16
|
-
|
17
|
-
* Copyright IBM Corp. 2022, 2022
|
18
|
-
*
|
19
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
20
|
-
* LICENSE file in the root directory of this source tree.
|
21
|
-
*/
|
22
|
-
// This function returns the state back to the reducer after
|
18
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid"); // This function returns the state back to the reducer after
|
23
19
|
// determining the new active cell value
|
20
|
+
|
24
21
|
var returnUpdatedActiveCell = function returnUpdatedActiveCell(_ref) {
|
25
22
|
var activeCellCoords = _ref.activeCellCoords,
|
26
23
|
direction = _ref.direction,
|
@@ -34,6 +31,12 @@ var returnUpdatedActiveCell = function returnUpdatedActiveCell(_ref) {
|
|
34
31
|
});
|
35
32
|
|
36
33
|
var newActiveCellId = "column-".concat(newActiveCoords.column, "-row-").concat(newActiveCoords.row);
|
34
|
+
var newCellIdButton = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit [data-cell-id=\"").concat(newActiveCellId, "\"] .").concat(blockClass, "__inline-edit-button")); // Allows scrollable area to keep focused/active cell id visible
|
35
|
+
|
36
|
+
if (newCellIdButton) {
|
37
|
+
newCellIdButton === null || newCellIdButton === void 0 ? void 0 : newCellIdButton.focus();
|
38
|
+
}
|
39
|
+
|
37
40
|
return _objectSpread(_objectSpread({}, state), {}, {
|
38
41
|
activeCellId: newActiveCellId
|
39
42
|
});
|