@carbon/ibm-products 1.27.0 → 1.31.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +513 -75
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +942 -23
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +3 -3
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +512 -74
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +513 -75
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +0 -3
- package/es/components/AddSelect/AddSelectBody.js +20 -3
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -3
- package/es/components/AddSelect/AddSelectColumn.js +4 -3
- package/es/components/AddSelect/AddSelectFilter.js +4 -3
- package/es/components/AddSelect/AddSelectList.js +40 -14
- package/es/components/Card/Card.js +16 -6
- package/es/components/Card/CardFooter.js +3 -1
- package/es/components/Card/CardHeader.js +20 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +62 -11
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
- package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +31 -0
- package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
- package/es/components/Datagrid/Datagrid/Datagrid.js +10 -38
- package/es/components/Datagrid/Datagrid/DatagridContent.js +106 -0
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +10 -3
- package/es/components/Datagrid/Datagrid/DraggableElement.js +5 -1
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -40
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +35 -10
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +61 -24
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +63 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +459 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +31 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +197 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
- package/es/components/Datagrid/index.js +3 -1
- package/es/components/Datagrid/useColumnOrder.js +8 -0
- package/es/components/Datagrid/useCustomizeColumns.js +5 -0
- package/es/components/Datagrid/useDisableSelectRows.js +6 -2
- package/es/components/Datagrid/useInlineEdit.js +71 -0
- package/es/components/Datagrid/useRowSize.js +17 -6
- package/es/components/Datagrid/useSelectRows.js +12 -2
- package/es/components/Datagrid/useStickyColumn.js +11 -0
- package/es/components/Datagrid/utils/getInlineEditColumns.js +121 -0
- package/es/components/Datagrid/utils/makeData.js +17 -1
- package/es/components/ImportModal/ImportModal.js +2 -2
- package/es/components/InlineEdit/InlineEdit.js +4 -2
- package/es/components/ProductiveCard/ProductiveCard.js +5 -0
- package/es/components/index.js +1 -1
- package/es/global/js/hooks/useClickOutside.js +1 -1
- package/es/global/js/package-settings.js +3 -3
- package/es/global/js/utils/rangeWithCallback.js +13 -0
- package/es/global/js/utils/uuidv4.spec.js +4 -0
- package/lib/components/AddSelect/AddSelect.js +0 -4
- package/lib/components/AddSelect/AddSelectBody.js +20 -3
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +14 -3
- package/lib/components/AddSelect/AddSelectColumn.js +3 -2
- package/lib/components/AddSelect/AddSelectFilter.js +3 -2
- package/lib/components/AddSelect/AddSelectList.js +39 -13
- package/lib/components/Card/Card.js +16 -6
- package/lib/components/Card/CardFooter.js +3 -1
- package/lib/components/Card/CardHeader.js +21 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +62 -10
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
- package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
- package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
- package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -45
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +138 -0
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +5 -1
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -41
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +47 -25
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +59 -23
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +79 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +483 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +42 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +204 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
- package/lib/components/Datagrid/index.js +17 -1
- package/lib/components/Datagrid/useColumnOrder.js +17 -0
- package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
- package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
- package/lib/components/Datagrid/useInlineEdit.js +85 -0
- package/lib/components/Datagrid/useRowSize.js +18 -13
- package/lib/components/Datagrid/useSelectRows.js +12 -2
- package/lib/components/Datagrid/useStickyColumn.js +11 -0
- package/lib/components/Datagrid/utils/getInlineEditColumns.js +133 -0
- package/lib/components/Datagrid/utils/makeData.js +17 -1
- package/lib/components/ImportModal/ImportModal.js +2 -2
- package/lib/components/InlineEdit/InlineEdit.js +4 -2
- package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
- package/lib/components/index.js +12 -0
- package/lib/global/js/hooks/useClickOutside.js +1 -1
- package/lib/global/js/package-settings.js +3 -3
- package/lib/global/js/utils/rangeWithCallback.js +22 -0
- package/lib/global/js/utils/uuidv4.spec.js +4 -0
- package/package.json +13 -13
- package/scss/components/AddSelect/_add-select.scss +126 -28
- package/scss/components/Card/_card.scss +1 -0
- package/scss/components/Cascade/_cascade.scss +1 -1
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +18 -1
- package/scss/components/Datagrid/_storybook-styles.scss +1 -1
- package/scss/components/Datagrid/styles/_datagrid.scss +27 -0
- package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
- package/scss/components/Datagrid/styles/_index.scss +1 -0
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +211 -0
- package/scss/components/Datagrid/styles/_useStickyColumn.scss +24 -2
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +44 -6
- package/scss/components/NotificationsPanel/_notifications-panel.scss +5 -6
- package/scss/components/ProductiveCard/_productive-card.scss +39 -0
- package/scss/components/RemoveModal/_remove-modal.scss +0 -4
- package/scss/components/SidePanel/_side-panel.scss +4 -6
- package/scss/components/_index-released-only.scss +1 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import React, { useContext, useRef } from 'react';
|
4
|
+
import cx from 'classnames';
|
5
|
+
import PropTypes from 'prop-types';
|
6
|
+
import { DataTable } from 'carbon-components-react';
|
7
|
+
import DatagridHead from './DatagridHead';
|
8
|
+
import DatagridBody from './DatagridBody';
|
9
|
+
import DatagridToolbar from './DatagridToolbar';
|
10
|
+
import { handleGridKeyPress } from './addons/InlineEdit/handleGridKeyPress';
|
11
|
+
import { pkg } from '../../../settings';
|
12
|
+
import { InlineEditContext } from './addons/InlineEdit/InlineEditContext';
|
13
|
+
import { handleGridFocus } from './addons/InlineEdit/handleGridFocus';
|
14
|
+
import { useClickOutside } from '../../../global/js/hooks';
|
15
|
+
var TableContainer = DataTable.TableContainer,
|
16
|
+
Table = DataTable.Table;
|
17
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
|
+
export var DatagridContent = function DatagridContent(_ref) {
|
19
|
+
var _getTableProps;
|
20
|
+
|
21
|
+
var datagridState = _ref.datagridState;
|
22
|
+
|
23
|
+
var _useContext = useContext(InlineEditContext),
|
24
|
+
state = _useContext.state,
|
25
|
+
dispatch = _useContext.dispatch;
|
26
|
+
|
27
|
+
var activeCellId = state.activeCellId;
|
28
|
+
var _datagridState$getTab = datagridState.getTableProps,
|
29
|
+
getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
|
30
|
+
withVirtualScroll = datagridState.withVirtualScroll,
|
31
|
+
DatagridPagination = datagridState.DatagridPagination,
|
32
|
+
isFetching = datagridState.isFetching,
|
33
|
+
CustomizeColumnsModal = datagridState.CustomizeColumnsModal,
|
34
|
+
leftPanel = datagridState.leftPanel,
|
35
|
+
fullHeightDatagrid = datagridState.fullHeightDatagrid,
|
36
|
+
_datagridState$vertic = datagridState.verticalAlign,
|
37
|
+
verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
|
38
|
+
variableRowHeight = datagridState.variableRowHeight,
|
39
|
+
gridTitle = datagridState.gridTitle,
|
40
|
+
gridDescription = datagridState.gridDescription,
|
41
|
+
useDenseHeader = datagridState.useDenseHeader,
|
42
|
+
withInlineEdit = datagridState.withInlineEdit;
|
43
|
+
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
44
|
+
var gridActive = state.gridActive;
|
45
|
+
var gridAreaRef = useRef();
|
46
|
+
useClickOutside(gridAreaRef, function (target) {
|
47
|
+
if (!withInlineEdit) {
|
48
|
+
return;
|
49
|
+
} // We return from here if we find a parent element with the selector below
|
50
|
+
// because that element was initially part of the grid area but was removed
|
51
|
+
// and swapped out with an input, i.e. text, number, selection, or date picker
|
52
|
+
|
53
|
+
|
54
|
+
if (target.closest(".".concat(blockClass, "__inline-edit-button")) || target.closest(".".concat(blockClass, "__inline-edit--select"))) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
|
58
|
+
dispatch({
|
59
|
+
type: 'REMOVE_GRID_ACTIVE_FOCUS',
|
60
|
+
payload: activeCellId
|
61
|
+
});
|
62
|
+
});
|
63
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContainer, {
|
64
|
+
className: cx("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : ''),
|
65
|
+
title: gridTitle,
|
66
|
+
description: gridDescription
|
67
|
+
}, /*#__PURE__*/React.createElement(DatagridToolbar, datagridState), /*#__PURE__*/React.createElement("div", {
|
68
|
+
className: "".concat(blockClass, "__table-container"),
|
69
|
+
ref: gridAreaRef
|
70
|
+
}, leftPanel && leftPanel.isOpen && /*#__PURE__*/React.createElement("div", {
|
71
|
+
className: "".concat(blockClass, "__datagridLeftPanel")
|
72
|
+
}, leftPanel.panelContent), /*#__PURE__*/React.createElement(Table, _extends({}, getTableProps(), {
|
73
|
+
className: cx(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), _defineProperty({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), _defineProperty({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), _defineProperty({}, "".concat(blockClass, "__table-grid-active"), gridActive), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
|
74
|
+
role: withInlineEdit && 'grid',
|
75
|
+
tabIndex: withInlineEdit && 0,
|
76
|
+
onKeyDown: withInlineEdit ? function (event) {
|
77
|
+
return handleGridKeyPress(event, dispatch, state, datagridState);
|
78
|
+
} : null,
|
79
|
+
onFocus: withInlineEdit ? function () {
|
80
|
+
return handleGridFocus(state, dispatch);
|
81
|
+
} : null
|
82
|
+
}), /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
83
|
+
rows: rows
|
84
|
+
}))))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/React.createElement(CustomizeColumnsModal, {
|
85
|
+
instance: datagridState
|
86
|
+
}));
|
87
|
+
};
|
88
|
+
DatagridContent.propTypes = {
|
89
|
+
datagridState: PropTypes.shape({
|
90
|
+
getTableProps: PropTypes.func,
|
91
|
+
withVirtualScroll: PropTypes.bool,
|
92
|
+
DatagridPagination: PropTypes.element,
|
93
|
+
CustomizeColumnsModal: PropTypes.element,
|
94
|
+
isFetching: PropTypes.bool,
|
95
|
+
leftPanel: PropTypes.object,
|
96
|
+
fullHeightDatagrid: PropTypes.bool,
|
97
|
+
variableRowHeight: PropTypes.bool,
|
98
|
+
useDenseHeader: PropTypes.bool,
|
99
|
+
withInlineEdit: PropTypes.bool,
|
100
|
+
verticalAlign: PropTypes.string,
|
101
|
+
gridTitle: PropTypes.node,
|
102
|
+
gridDescription: PropTypes.node,
|
103
|
+
page: PropTypes.arrayOf(PropTypes.object),
|
104
|
+
rows: PropTypes.arrayOf(PropTypes.object)
|
105
|
+
})
|
106
|
+
};
|
@@ -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 = ["onChange"];
|
4
5
|
|
5
6
|
/*
|
@@ -12,21 +13,27 @@ var _excluded = ["onChange"];
|
|
12
13
|
// @flow
|
13
14
|
import React from 'react';
|
14
15
|
import { DataTable } from 'carbon-components-react';
|
16
|
+
import cx from 'classnames';
|
15
17
|
import { pkg } from '../../../settings';
|
16
18
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
17
19
|
|
18
20
|
var SelectAll = function SelectAll(datagridState) {
|
21
|
+
var _columns$;
|
22
|
+
|
19
23
|
var isFetching = datagridState.isFetching,
|
20
24
|
getToggleAllRowsSelectedProps = datagridState.getToggleAllRowsSelectedProps,
|
21
25
|
getToggleAllPageRowsSelectedProps = datagridState.getToggleAllPageRowsSelectedProps,
|
22
26
|
tableId = datagridState.tableId,
|
23
27
|
hideSelectAll = datagridState.hideSelectAll,
|
24
28
|
DatagridPagination = datagridState.DatagridPagination,
|
25
|
-
radio = datagridState.radio
|
29
|
+
radio = datagridState.radio,
|
30
|
+
columns = datagridState.columns,
|
31
|
+
withStickyColumn = datagridState.withStickyColumn;
|
32
|
+
var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
|
26
33
|
|
27
34
|
if (hideSelectAll || radio) {
|
28
35
|
return /*#__PURE__*/React.createElement("div", {
|
29
|
-
className: "".concat(blockClass, "__head-hidden-select-all")
|
36
|
+
className: cx("".concat(blockClass, "__head-hidden-select-all"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft))
|
30
37
|
});
|
31
38
|
}
|
32
39
|
|
@@ -37,7 +44,7 @@ var SelectAll = function SelectAll(datagridState) {
|
|
37
44
|
selectProps = _objectWithoutProperties(_getProps, _excluded);
|
38
45
|
|
39
46
|
return /*#__PURE__*/React.createElement("div", {
|
40
|
-
className: "".concat(blockClass, "__head-select-all ").concat(blockClass, "__checkbox-cell")
|
47
|
+
className: cx("".concat(blockClass, "__head-select-all"), "".concat(blockClass, "__checkbox-cell"), _defineProperty({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), isFirstColumnStickyLeft))
|
41
48
|
}, /*#__PURE__*/React.createElement(TableSelectAll, _extends({}, selectProps, {
|
42
49
|
name: "".concat(tableId, "-select-all-checkbox-name"),
|
43
50
|
onSelect: onChange,
|
@@ -22,6 +22,8 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
22
22
|
var DRAG_TYPE = "".concat(blockClass, "__shared-ui-draggable-element");
|
23
23
|
|
24
24
|
var DraggableElement = function DraggableElement(_ref) {
|
25
|
+
var _cx;
|
26
|
+
|
25
27
|
var id = _ref.id,
|
26
28
|
index = _ref.index,
|
27
29
|
listData = _ref.listData,
|
@@ -33,6 +35,7 @@ var DraggableElement = function DraggableElement(_ref) {
|
|
33
35
|
onArrowKeyDown = _ref.onArrowKeyDown,
|
34
36
|
isFocused = _ref.isFocused,
|
35
37
|
moveElement = _ref.moveElement,
|
38
|
+
selected = _ref.selected,
|
36
39
|
_ref$positionLabel = _ref.positionLabel,
|
37
40
|
positionLabel = _ref$positionLabel === void 0 ? 'Current position {index} of {total}' : _ref$positionLabel,
|
38
41
|
_ref$grabbedLabel = _ref.grabbedLabel,
|
@@ -119,7 +122,7 @@ var DraggableElement = function DraggableElement(_ref) {
|
|
119
122
|
}, "".concat(blockClass, "__draggable-handleStyle"))
|
120
123
|
}, /*#__PURE__*/React.createElement(Draggable16, null)), children);
|
121
124
|
return /*#__PURE__*/React.createElement("li", {
|
122
|
-
className: cx(
|
125
|
+
className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-isOver"), isOver && !disabled), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-grabbed"), isGrabbed), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-selected"), selected), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder"), !selected), _cx)),
|
123
126
|
ref: ref,
|
124
127
|
"aria-selected": isFocused,
|
125
128
|
role: "option",
|
@@ -173,6 +176,7 @@ DraggableElement.propTypes = {
|
|
173
176
|
onArrowKeyDown: PropTypes.func.isRequired,
|
174
177
|
onGrab: PropTypes.func.isRequired,
|
175
178
|
positionLabel: PropTypes.string,
|
179
|
+
selected: PropTypes.bool,
|
176
180
|
type: PropTypes.string.isRequired
|
177
181
|
};
|
178
182
|
export default DraggableElement;
|
@@ -1,9 +1,3 @@
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
-
|
3
|
-
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; }
|
4
|
-
|
5
|
-
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) { _defineProperty(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; }
|
6
|
-
|
7
1
|
// @flow
|
8
2
|
|
9
3
|
/*
|
@@ -13,28 +7,18 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
13
7
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
14
8
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
15
9
|
*/
|
16
|
-
import { Reset16 } from '@carbon/icons-react';
|
17
10
|
import PropTypes from 'prop-types';
|
18
|
-
import {
|
11
|
+
import { Search } from 'carbon-components-react';
|
19
12
|
import * as React from 'react';
|
20
|
-
import keyBy from 'lodash/keyBy';
|
21
13
|
import { pkg } from '../../../../../settings';
|
22
|
-
import { isColumnVisible } from './common';
|
23
14
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
24
15
|
|
25
16
|
var Actions = function Actions(_ref) {
|
26
17
|
var searchText = _ref.searchText,
|
27
|
-
columns = _ref.columns,
|
28
|
-
originalColumnDefinitions = _ref.originalColumnDefinitions,
|
29
|
-
setColumnsObject = _ref.setColumnsObject,
|
30
18
|
setSearchText = _ref.setSearchText,
|
31
|
-
|
32
|
-
findColumnPlaceholderLabel = _ref$findColumnPlaceh === void 0 ? 'Find column' : _ref$findColumnPlaceh,
|
33
|
-
_ref$resetToDefaultLa = _ref.resetToDefaultLabel,
|
34
|
-
resetToDefaultLabel = _ref$resetToDefaultLa === void 0 ? 'Reset to default' : _ref$resetToDefaultLa;
|
19
|
+
findColumnPlaceholderLabel = _ref.findColumnPlaceholderLabel;
|
35
20
|
return /*#__PURE__*/React.createElement("div", {
|
36
|
-
className: "".concat(blockClass, "__customize-columns-modal--actions")
|
37
|
-
"test-id": "".concat(blockClass, "__customize-columns-modal--actions")
|
21
|
+
className: "".concat(blockClass, "__customize-columns-modal--actions")
|
38
22
|
}, /*#__PURE__*/React.createElement(Search, {
|
39
23
|
placeholder: findColumnPlaceholderLabel,
|
40
24
|
value: searchText,
|
@@ -43,27 +27,8 @@ var Actions = function Actions(_ref) {
|
|
43
27
|
onChange: function onChange(e) {
|
44
28
|
// TODO: is it performant?
|
45
29
|
setSearchText(e.target.value);
|
46
|
-
}
|
47
|
-
|
48
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
49
|
-
onClick: function onClick() {
|
50
|
-
var reset = resetToOriginal(columns, originalColumnDefinitions);
|
51
|
-
setColumnsObject(reset);
|
52
|
-
},
|
53
|
-
size: "sm",
|
54
|
-
kind: "ghost",
|
55
|
-
renderIcon: Reset16,
|
56
|
-
"test-id": "".concat(blockClass, "__customize-columns-modal--reset")
|
57
|
-
}, resetToDefaultLabel));
|
58
|
-
};
|
59
|
-
|
60
|
-
var resetToOriginal = function resetToOriginal(columnDefinitions, originalColumnDefinitions) {
|
61
|
-
var keyedDefs = keyBy(columnDefinitions, 'id');
|
62
|
-
return originalColumnDefinitions.map(function (colDef) {
|
63
|
-
return _objectSpread(_objectSpread({}, keyedDefs[colDef.id]), {}, {
|
64
|
-
isVisible: isColumnVisible(colDef)
|
65
|
-
});
|
66
|
-
});
|
30
|
+
}
|
31
|
+
}));
|
67
32
|
};
|
68
33
|
|
69
34
|
Actions.propTypes = {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
3
|
// @flow
|
3
4
|
|
@@ -8,7 +9,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
8
9
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
9
10
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
10
11
|
*/
|
11
|
-
import
|
12
|
+
import React from 'react';
|
12
13
|
import PropTypes from 'prop-types';
|
13
14
|
import { DndProvider } from 'react-dnd';
|
14
15
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
@@ -17,6 +18,7 @@ import update from 'immutability-helper';
|
|
17
18
|
import { pkg } from '../../../../../settings';
|
18
19
|
import DraggableElement from '../../DraggableElement';
|
19
20
|
import { isColumnVisible } from './common';
|
21
|
+
import classNames from 'classnames';
|
20
22
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
21
23
|
|
22
24
|
var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
@@ -34,14 +36,16 @@ var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
|
34
36
|
};
|
35
37
|
|
36
38
|
var Columns = function Columns(_ref) {
|
37
|
-
var
|
39
|
+
var _classNames;
|
40
|
+
|
41
|
+
var getVisibleColumnsCount = _ref.getVisibleColumnsCount,
|
42
|
+
filterString = _ref.filterString,
|
38
43
|
columns = _ref.columns,
|
39
44
|
setColumnsObject = _ref.setColumnsObject,
|
40
45
|
onSelectColumn = _ref.onSelectColumn,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
disabledInstructionsLabel = _ref$disabledInstruct === void 0 ? 'Reordering columns are disabled because they are filtered currently.' : _ref$disabledInstruct;
|
46
|
+
assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
|
47
|
+
assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
|
48
|
+
selectAllLabel = _ref.selectAllLabel;
|
45
49
|
|
46
50
|
var _React$useState = React.useState(''),
|
47
51
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
@@ -88,7 +92,21 @@ var Columns = function Columns(_ref) {
|
|
88
92
|
}, ariaRegionText), /*#__PURE__*/React.createElement("span", {
|
89
93
|
id: "".concat(blockClass, "__customize-columns--instructions"),
|
90
94
|
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
91
|
-
}, filterString.length === 0 ?
|
95
|
+
}, filterString.length === 0 ? assistiveTextInstructionsLabel : assistiveTextDisabledInstructionsLabel), /*#__PURE__*/React.createElement("div", {
|
96
|
+
id: "".concat(blockClass, "__customize-columns-select-all"),
|
97
|
+
className: classNames((_classNames = {}, _defineProperty(_classNames, "".concat(blockClass, "__customize-columns-select-all"), getVisibleColumnsCount() === 0), _defineProperty(_classNames, "".concat(blockClass, "__customize-columns-select-all-selected"), getVisibleColumnsCount() > 0), _classNames)),
|
98
|
+
selected: getVisibleColumnsCount() > 0
|
99
|
+
}, /*#__PURE__*/React.createElement(Checkbox, {
|
100
|
+
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
101
|
+
checked: getVisibleColumnsCount() === columns.length,
|
102
|
+
empty: !!getVisibleColumnsCount() === 0,
|
103
|
+
indeterminate: getVisibleColumnsCount() < columns.length && getVisibleColumnsCount() > 0,
|
104
|
+
onChange: function onChange() {
|
105
|
+
onSelectColumn(columns, getVisibleColumnsCount() !== columns.length);
|
106
|
+
},
|
107
|
+
id: "".concat(blockClass, "__customization-column-select-all"),
|
108
|
+
labelText: selectAllLabel
|
109
|
+
})), columns.filter(function (colDef) {
|
92
110
|
return filterString.length === 0 || colDef.Header.props.title.toLowerCase().includes(filterString);
|
93
111
|
}).map(function (colDef, i) {
|
94
112
|
return /*#__PURE__*/React.createElement(DraggableElement, {
|
@@ -117,24 +135,31 @@ var Columns = function Columns(_ref) {
|
|
117
135
|
});
|
118
136
|
}
|
119
137
|
}
|
120
|
-
}
|
138
|
+
},
|
139
|
+
selected: isColumnVisible(colDef)
|
121
140
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
122
|
-
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox"),
|
141
|
+
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
123
142
|
checked: isColumnVisible(colDef),
|
124
143
|
onChange: onSelectColumn.bind(null, colDef),
|
125
144
|
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
126
145
|
labelText: colDef.Header.props.title,
|
127
|
-
title: colDef.Header.props.title
|
146
|
+
title: colDef.Header.props.title,
|
147
|
+
className: "".concat(blockClass, "__customize-columns-checkbox")
|
128
148
|
}));
|
129
149
|
}))));
|
130
150
|
};
|
131
151
|
|
132
152
|
Columns.propTypes = {
|
153
|
+
assistiveTextDisabledInstructionsLabel: PropTypes.string,
|
154
|
+
assistiveTextInstructionsLabel: PropTypes.string,
|
133
155
|
columns: PropTypes.array.isRequired,
|
134
156
|
disabledInstructionsLabel: PropTypes.string,
|
135
157
|
filterString: PropTypes.string.isRequired,
|
158
|
+
getVisibleColumnsCount: PropTypes.func.isRequired,
|
136
159
|
instructionsLabel: PropTypes.string,
|
137
160
|
onSelectColumn: PropTypes.func.isRequired,
|
161
|
+
selectAllLabel: PropTypes.string,
|
162
|
+
setColumnStatus: PropTypes.func,
|
138
163
|
setColumnsObject: PropTypes.func.isRequired
|
139
164
|
};
|
140
165
|
export default Columns;
|
@@ -13,13 +13,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
13
13
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
14
14
|
*/
|
15
15
|
// @flow
|
16
|
-
import React, { useState } from 'react';
|
16
|
+
import React, { useEffect, useState } from 'react';
|
17
17
|
import PropTypes from 'prop-types';
|
18
18
|
import { Modal } from 'carbon-components-react';
|
19
19
|
import { isColumnVisible } from './common';
|
20
20
|
import Columns from './Columns';
|
21
21
|
import Actions from './Actions';
|
22
22
|
import { pkg } from '../../../../../settings';
|
23
|
+
import { useCallback } from 'react';
|
23
24
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
24
25
|
|
25
26
|
var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
@@ -29,20 +30,40 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
29
30
|
columnDefinitions = _ref.columnDefinitions,
|
30
31
|
originalColumnDefinitions = _ref.originalColumnDefinitions,
|
31
32
|
_ref$customizeModalHe = _ref.customizeModalHeadingLabel,
|
32
|
-
customizeModalHeadingLabel = _ref$customizeModalHe === void 0 ? 'Customize
|
33
|
+
customizeModalHeadingLabel = _ref$customizeModalHe === void 0 ? 'Customize Columns' : _ref$customizeModalHe,
|
33
34
|
_ref$primaryButtonTex = _ref.primaryButtonTextLabel,
|
34
35
|
primaryButtonTextLabel = _ref$primaryButtonTex === void 0 ? 'Save' : _ref$primaryButtonTex,
|
35
36
|
_ref$secondaryButtonT = _ref.secondaryButtonTextLabel,
|
36
37
|
secondaryButtonTextLabel = _ref$secondaryButtonT === void 0 ? 'Cancel' : _ref$secondaryButtonT,
|
37
38
|
_ref$instructionsLabe = _ref.instructionsLabel,
|
38
|
-
instructionsLabel = _ref$instructionsLabe === void 0 ? '
|
39
|
+
instructionsLabel = _ref$instructionsLabe === void 0 ? 'Select columns to display them. Click and drag the box to reorder the columns. These specifications will be saved and persist if you leave and return to the data table.' : _ref$instructionsLabe,
|
40
|
+
_ref$findColumnPlaceh = _ref.findColumnPlaceholderLabel,
|
41
|
+
findColumnPlaceholderLabel = _ref$findColumnPlaceh === void 0 ? 'Find column' : _ref$findColumnPlaceh,
|
42
|
+
_ref$resetToDefaultLa = _ref.resetToDefaultLabel,
|
43
|
+
resetToDefaultLabel = _ref$resetToDefaultLa === void 0 ? 'Reset to default' : _ref$resetToDefaultLa,
|
44
|
+
_ref$assistiveTextIns = _ref.assistiveTextInstructionsLabel,
|
45
|
+
assistiveTextInstructionsLabel = _ref$assistiveTextIns === void 0 ? 'Press space bar to toggle drag drop mode, use arrow keys to move selected elements.' : _ref$assistiveTextIns,
|
46
|
+
_ref$assistiveTextDis = _ref.assistiveTextDisabledInstructionsLabel,
|
47
|
+
assistiveTextDisabledInstructionsLabel = _ref$assistiveTextDis === void 0 ? 'Reordering columns are disabled because they are filtered currently.' : _ref$assistiveTextDis,
|
48
|
+
_ref$selectAllLabel = _ref.selectAllLabel,
|
49
|
+
selectAllLabel = _ref$selectAllLabel === void 0 ? 'Column name' : _ref$selectAllLabel;
|
39
50
|
|
40
51
|
var _useState = useState(''),
|
41
52
|
_useState2 = _slicedToArray(_useState, 2),
|
42
|
-
|
43
|
-
|
53
|
+
visibleColumnsCount = _useState2[0],
|
54
|
+
setVisibleColumnsCount = _useState2[1];
|
44
55
|
|
45
|
-
var _useState3 = useState(
|
56
|
+
var _useState3 = useState(''),
|
57
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
58
|
+
totalColumns = _useState4[0],
|
59
|
+
setTotalColumns = _useState4[1];
|
60
|
+
|
61
|
+
var _useState5 = useState(''),
|
62
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
63
|
+
searchText = _useState6[0],
|
64
|
+
setSearchText = _useState6[1];
|
65
|
+
|
66
|
+
var _useState7 = useState(columnDefinitions // hide the columns without Header, e.g the sticky actions, spacer
|
46
67
|
.filter(function (colDef) {
|
47
68
|
return !!colDef.Header.props;
|
48
69
|
}) // only sort the hidden column to the end when modal reopen
|
@@ -60,14 +81,14 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
60
81
|
|
61
82
|
return 0;
|
62
83
|
})),
|
63
|
-
|
64
|
-
columnObjects =
|
65
|
-
|
84
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
85
|
+
columnObjects = _useState8[0],
|
86
|
+
setColumnObjects = _useState8[1];
|
66
87
|
|
67
|
-
var
|
68
|
-
|
69
|
-
isDirty =
|
70
|
-
setIsDirty =
|
88
|
+
var _useState9 = useState(false),
|
89
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
90
|
+
isDirty = _useState10[0],
|
91
|
+
setIsDirty = _useState10[1];
|
71
92
|
|
72
93
|
var onRequestClose = function onRequestClose() {
|
73
94
|
setIsModalOpen(false);
|
@@ -86,7 +107,7 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
86
107
|
|
87
108
|
var onCheckboxCheck = function onCheckboxCheck(col, value) {
|
88
109
|
var changedDefinitions = columnObjects.map(function (definition) {
|
89
|
-
if (definition.id === col.id) {
|
110
|
+
if (Array.isArray(col) && col.indexOf(definition) != null || definition.id === col.id) {
|
90
111
|
return _objectSpread(_objectSpread({}, definition), {}, {
|
91
112
|
isVisible: value
|
92
113
|
});
|
@@ -94,9 +115,7 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
94
115
|
|
95
116
|
return definition;
|
96
117
|
});
|
97
|
-
|
98
|
-
_setColumnsObject(changedDefinitions);
|
99
|
-
|
118
|
+
setColumnObjects(changedDefinitions);
|
100
119
|
setDirty();
|
101
120
|
};
|
102
121
|
|
@@ -106,11 +125,20 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
106
125
|
}
|
107
126
|
};
|
108
127
|
|
128
|
+
var getVisibleColumnsCount = useCallback(function () {
|
129
|
+
return columnObjects.filter(function (col) {
|
130
|
+
return col.isVisible;
|
131
|
+
}).length;
|
132
|
+
}, [columnObjects]);
|
109
133
|
var string = searchText.trim().toLowerCase();
|
134
|
+
useEffect(function () {
|
135
|
+
setVisibleColumnsCount(getVisibleColumnsCount());
|
136
|
+
setTotalColumns(columnObjects.length);
|
137
|
+
}, [getVisibleColumnsCount, columnObjects.length]);
|
110
138
|
return /*#__PURE__*/React.createElement(Modal, {
|
111
139
|
className: "".concat(blockClass, "__customize-columns-modal"),
|
112
140
|
open: isOpen,
|
113
|
-
modalHeading: customizeModalHeadingLabel,
|
141
|
+
modalHeading: "".concat(customizeModalHeadingLabel, " (").concat(visibleColumnsCount, "/").concat(totalColumns, ")"),
|
114
142
|
primaryButtonText: primaryButtonTextLabel,
|
115
143
|
secondaryButtonText: secondaryButtonTextLabel,
|
116
144
|
selectorPrimaryFocus: ".".concat(blockClass, "__customize-columns-column-list--focus"),
|
@@ -126,32 +154,41 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
126
154
|
originalColumnDefinitions: originalColumnDefinitions,
|
127
155
|
searchText: searchText,
|
128
156
|
setColumnsObject: function setColumnsObject(cols) {
|
129
|
-
|
130
|
-
|
157
|
+
setColumnObjects(cols);
|
131
158
|
setDirty();
|
132
159
|
},
|
133
|
-
setSearchText: setSearchText
|
160
|
+
setSearchText: setSearchText,
|
161
|
+
findColumnPlaceholderLabel: findColumnPlaceholderLabel,
|
162
|
+
resetToDefaultLabel: resetToDefaultLabel
|
134
163
|
}), isOpen && /*#__PURE__*/React.createElement(Columns, {
|
164
|
+
assistiveTextInstructionsLabel: assistiveTextInstructionsLabel,
|
165
|
+
assistiveTextDisabledInstructionsLabel: assistiveTextDisabledInstructionsLabel,
|
166
|
+
getVisibleColumnsCount: getVisibleColumnsCount,
|
135
167
|
columns: columnObjects,
|
136
168
|
filterString: string,
|
137
169
|
onSelectColumn: onCheckboxCheck,
|
138
170
|
setColumnsObject: function setColumnsObject(cols) {
|
139
|
-
|
140
|
-
|
171
|
+
setColumnObjects(cols);
|
141
172
|
setDirty();
|
142
|
-
}
|
173
|
+
},
|
174
|
+
selectAllLabel: selectAllLabel
|
143
175
|
}));
|
144
176
|
};
|
145
177
|
|
146
178
|
CustomizeColumnsModal.propTypes = {
|
179
|
+
assistiveTextDisabledInstructionsLabel: PropTypes.string,
|
180
|
+
assistiveTextInstructionsLabel: PropTypes.string,
|
147
181
|
columnDefinitions: PropTypes.array.isRequired,
|
148
182
|
customizeModalHeadingLabel: PropTypes.string,
|
183
|
+
findColumnPlaceholderLabel: PropTypes.string,
|
149
184
|
instructionsLabel: PropTypes.string,
|
150
185
|
isOpen: PropTypes.bool.isRequired,
|
151
186
|
onSaveColumnPrefs: PropTypes.func.isRequired,
|
152
187
|
originalColumnDefinitions: PropTypes.array.isRequired,
|
153
188
|
primaryButtonTextLabel: PropTypes.string,
|
189
|
+
resetToDefaultLabel: PropTypes.string,
|
154
190
|
secondaryButtonTextLabel: PropTypes.string,
|
191
|
+
selectAllLabel: PropTypes.string,
|
155
192
|
setIsModalOpen: PropTypes.func.isRequired
|
156
193
|
};
|
157
194
|
export default CustomizeColumnsModal;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
var _excluded = ["onSaveColumnPrefs", "isModalOpen", "setIsModalOpen"];
|
3
|
+
var _excluded = ["onSaveColumnPrefs", "isModalOpen", "setIsModalOpen", "labels"];
|
4
4
|
// @flow
|
5
5
|
|
6
6
|
/*
|
@@ -21,10 +21,11 @@ var ModalWrapper = function ModalWrapper(_ref) {
|
|
21
21
|
_onSaveColumnPrefs = _instance$customizeCo.onSaveColumnPrefs,
|
22
22
|
isModalOpen = _instance$customizeCo.isModalOpen,
|
23
23
|
setIsModalOpen = _instance$customizeCo.setIsModalOpen,
|
24
|
+
labels = _instance$customizeCo.labels,
|
24
25
|
rest = _objectWithoutProperties(_instance$customizeCo, _excluded);
|
25
26
|
|
26
27
|
if (isModalOpen) {
|
27
|
-
return /*#__PURE__*/React.createElement(CustomizeColumnsModal, _extends({}, rest, {
|
28
|
+
return /*#__PURE__*/React.createElement(CustomizeColumnsModal, _extends({}, rest, labels, {
|
28
29
|
isOpen: isModalOpen,
|
29
30
|
setIsModalOpen: setIsModalOpen,
|
30
31
|
columnDefinitions: instance.allColumns,
|
package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Licensed Materials - Property of IBM
|
5
|
+
* 5724-Q36
|
6
|
+
* (c) Copyright IBM Corp. 2022
|
7
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
8
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
9
|
+
*/
|
10
|
+
import React from 'react';
|
11
|
+
import cx from 'classnames';
|
12
|
+
import PropTypes from 'prop-types';
|
13
|
+
import { pkg } from '../../../../../../settings';
|
14
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
15
|
+
export var InlineEditButton = function InlineEditButton(_ref) {
|
16
|
+
var _cx, _cx2;
|
17
|
+
|
18
|
+
var label = _ref.label,
|
19
|
+
Icon = _ref.renderIcon,
|
20
|
+
disabled = _ref.disabled,
|
21
|
+
LabelIcon = _ref.labelIcon,
|
22
|
+
placeholder = _ref.placeholder,
|
23
|
+
_ref$tabIndex = _ref.tabIndex,
|
24
|
+
tabIndex = _ref$tabIndex === void 0 ? -1 : _ref$tabIndex,
|
25
|
+
nonEditCell = _ref.nonEditCell,
|
26
|
+
isActiveCell = _ref.isActiveCell,
|
27
|
+
columnConfig = _ref.columnConfig,
|
28
|
+
totalInlineEditColumns = _ref.totalInlineEditColumns,
|
29
|
+
totalColumns = _ref.totalColumns,
|
30
|
+
type = _ref.type;
|
31
|
+
var inlineEditColsLessThanHalfOfTotal = totalInlineEditColumns < totalColumns / 2;
|
32
|
+
return /*#__PURE__*/React.createElement("div", {
|
33
|
+
className: cx("".concat(blockClass, "__inline-edit-button"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--edit-less-than-half-of-total-cols"), inlineEditColsLessThanHalfOfTotal), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
|
34
|
+
tabIndex: tabIndex,
|
35
|
+
"data-disabled": disabled || nonEditCell,
|
36
|
+
"aria-disabled": disabled || nonEditCell,
|
37
|
+
role: "button",
|
38
|
+
title: label
|
39
|
+
}, LabelIcon && /*#__PURE__*/React.createElement("div", {
|
40
|
+
className: "".concat(blockClass, "__label-icon")
|
41
|
+
}, /*#__PURE__*/React.createElement(LabelIcon, null)), label !== '' ? /*#__PURE__*/React.createElement("span", {
|
42
|
+
className: cx("".concat(blockClass, "__inline-edit-button-label"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__inline-edit-button-label-with-icon"), !nonEditCell), _defineProperty(_cx2, "".concat(blockClass, "__defaultStringRenderer--multiline"), columnConfig === null || columnConfig === void 0 ? void 0 : columnConfig.multiLineWrap), _cx2))
|
43
|
+
}, label) : /*#__PURE__*/React.createElement("span", {
|
44
|
+
className: "".concat(blockClass, "__placeholder")
|
45
|
+
}, placeholder), !nonEditCell && Icon && /*#__PURE__*/React.createElement("div", {
|
46
|
+
className: "".concat(blockClass, "__inline-edit-button-icon")
|
47
|
+
}, /*#__PURE__*/React.createElement(Icon, null)));
|
48
|
+
};
|
49
|
+
InlineEditButton.propTypes = {
|
50
|
+
columnConfig: PropTypes.object,
|
51
|
+
disabled: PropTypes.bool,
|
52
|
+
isActiveCell: PropTypes.bool,
|
53
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
54
|
+
labelIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
55
|
+
nonEditCell: PropTypes.bool,
|
56
|
+
placeholder: PropTypes.string,
|
57
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
58
|
+
tabIndex: PropTypes.number,
|
59
|
+
totalColumns: PropTypes.number,
|
60
|
+
totalInlineEditColumns: PropTypes.number,
|
61
|
+
type: PropTypes.oneOf(['text', 'number', 'selection', 'date']),
|
62
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
63
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { InlineEditButton } from './InlineEditButton';
|