@carbon/ibm-products 2.0.0-rc.1 → 2.0.0-rc.3
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +952 -143
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +4 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +783 -19
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +4 -2
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +678 -77
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +4 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +757 -92
- package/css/index.css.map +1 -1
- package/css/index.min.css +4 -2
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyModal.js +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 +5 -5
- package/es/components/AddSelect/AddSelectFilter.js +5 -4
- package/es/components/AddSelect/AddSelectList.js +61 -27
- package/es/components/AddSelect/AddSelectMetaPanel.js +1 -1
- package/es/components/AddSelect/AddSelectSort.js +1 -1
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +4 -6
- 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/ComboButton/ComboButton.js +1 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +63 -11
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
- package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
- 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 +149 -0
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +10 -2
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +10 -3
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +13 -4
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +5 -4
- package/es/components/Datagrid/Datagrid/DraggableElement.js +6 -2
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -45
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +1 -1
- 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 +60 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +534 -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 +39 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +263 -0
- package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +87 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -14
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -36
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/LeftPanelStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
- package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -0
- package/es/components/Datagrid/index.js +3 -1
- package/es/components/Datagrid/useActionsColumn.js +28 -12
- package/es/components/Datagrid/useColumnOrder.js +8 -0
- package/es/components/Datagrid/useCustomizeColumns.js +5 -0
- package/es/components/Datagrid/useDefaultStringRenderer.js +4 -1
- package/es/components/Datagrid/useDisableSelectRows.js +6 -2
- package/es/components/Datagrid/useExpandedRow.js +0 -1
- package/es/components/Datagrid/useInlineEdit.js +71 -0
- package/es/components/Datagrid/useNestedRowExpander.js +42 -0
- package/es/components/Datagrid/useNestedRows.js +2 -2
- package/es/components/Datagrid/useRowExpander.js +1 -1
- package/es/components/Datagrid/useRowSize.js +17 -6
- package/es/components/Datagrid/useSelectAllToggle.js +17 -4
- package/es/components/Datagrid/useSelectRows.js +12 -2
- package/es/components/Datagrid/useSortableColumns.js +1 -1
- package/es/components/Datagrid/useStickyColumn.js +11 -0
- package/es/components/Datagrid/utils/DatagridActions.js +152 -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/getInlineEditColumns.js +153 -0
- package/es/components/Datagrid/utils/makeData.js +47 -2
- package/es/components/ExportModal/ExportModal.js +1 -1
- package/es/components/ImportModal/ImportModal.js +3 -3
- package/es/components/InlineEdit/InlineEdit.js +11 -9
- package/es/components/ModifiedTabs/ModifiedTabLabelNew.js +1 -1
- package/es/components/ModifiedTabs/ModifiedTabLabelWithClose.js +1 -1
- package/es/components/NotificationsPanel/NotificationsPanel.js +1 -1
- package/es/components/OptionsTile/OptionsTile.js +1 -1
- package/es/components/PageHeader/PageHeader.js +1 -1
- package/es/components/ProductiveCard/ProductiveCard.js +5 -0
- package/es/components/Saving/Saving.js +1 -1
- package/es/components/SidePanel/SidePanel.js +1 -1
- package/es/components/StatusIcon/StatusIcon.js +1 -1
- package/es/components/UserProfileImage/UserProfileImage.js +1 -1
- package/es/components/WebTerminal/WebTerminal.js +2 -2
- package/es/components/WebTerminal/WebTerminalContentWrapper.js +1 -1
- package/es/components/WebTerminal/hooks/index.js +6 -0
- package/es/components/WebTerminal/index.js +6 -0
- package/es/components/WebTerminal/preview-components/Navigation.js +7 -1
- package/es/components/WebTerminal/preview-components/documentationLinks.js +6 -0
- package/es/components/WebTerminal/preview-components/index.js +7 -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/story-helper.js +5 -1
- package/es/global/js/utils/uuidv4.spec.js +4 -0
- package/lib/components/APIKeyModal/APIKeyModal.js +4 -4
- 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 +5 -5
- package/lib/components/AddSelect/AddSelectFilter.js +5 -4
- package/lib/components/AddSelect/AddSelectList.js +62 -28
- package/lib/components/AddSelect/AddSelectMetaPanel.js +2 -2
- package/lib/components/AddSelect/AddSelectSort.js +4 -4
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +6 -6
- 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/ComboButton/ComboButton.js +3 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +63 -10
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
- package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
- 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 +183 -0
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +19 -2
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +16 -5
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +6 -5
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +7 -3
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -47
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +2 -2
- 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 +76 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +558 -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 +45 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +272 -0
- package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +100 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -13
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -35
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/LeftPanelStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
- package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -0
- package/lib/components/Datagrid/index.js +17 -1
- package/lib/components/Datagrid/useActionsColumn.js +28 -13
- package/lib/components/Datagrid/useColumnOrder.js +17 -0
- package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
- package/lib/components/Datagrid/useDefaultStringRenderer.js +5 -1
- package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
- package/lib/components/Datagrid/useExpandedRow.js +0 -1
- package/lib/components/Datagrid/useInlineEdit.js +85 -0
- package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
- package/lib/components/Datagrid/useNestedRows.js +3 -3
- package/lib/components/Datagrid/useRowExpander.js +3 -3
- package/lib/components/Datagrid/useRowSize.js +18 -13
- package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
- package/lib/components/Datagrid/useSelectRows.js +12 -2
- package/lib/components/Datagrid/useSortableColumns.js +5 -5
- package/lib/components/Datagrid/useStickyColumn.js +11 -0
- package/lib/components/Datagrid/utils/DatagridActions.js +170 -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/getInlineEditColumns.js +168 -0
- package/lib/components/Datagrid/utils/makeData.js +48 -2
- package/lib/components/ExportModal/ExportModal.js +3 -3
- package/lib/components/ImportModal/ImportModal.js +4 -4
- package/lib/components/InlineEdit/InlineEdit.js +16 -14
- package/lib/components/ModifiedTabs/ModifiedTabLabelNew.js +2 -2
- package/lib/components/ModifiedTabs/ModifiedTabLabelWithClose.js +3 -3
- package/lib/components/NotificationsPanel/NotificationsPanel.js +8 -8
- package/lib/components/OptionsTile/OptionsTile.js +6 -6
- package/lib/components/PageHeader/PageHeader.js +2 -2
- package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
- package/lib/components/Saving/Saving.js +5 -5
- package/lib/components/SidePanel/SidePanel.js +3 -3
- package/lib/components/StatusIcon/StatusIcon.js +45 -45
- package/lib/components/UserProfileImage/UserProfileImage.js +7 -7
- package/lib/components/WebTerminal/WebTerminal.js +3 -3
- package/lib/components/WebTerminal/hooks/index.js +6 -0
- package/lib/components/WebTerminal/preview-components/Navigation.js +10 -4
- package/lib/components/WebTerminal/preview-components/documentationLinks.js +6 -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/story-helper.js +5 -1
- package/lib/global/js/utils/uuidv4.spec.js +4 -0
- package/package.json +15 -15
- package/scss/components/AddSelect/_add-select.scss +127 -28
- package/scss/components/Card/_card.scss +1 -0
- package/scss/components/Cascade/_cascade.scss +1 -1
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -0
- package/scss/components/Datagrid/_datagrid.scss +7 -0
- package/scss/components/Datagrid/_storybook-styles.scss +8 -5
- package/scss/components/Datagrid/styles/_datagrid.scss +38 -14
- package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
- package/scss/components/Datagrid/styles/_index.scss +1 -0
- package/scss/components/Datagrid/styles/_useActionsColumn.scss +14 -0
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +37 -9
- package/scss/components/Datagrid/styles/_useInlineEdit.scss +404 -0
- package/scss/components/Datagrid/styles/_useNestedRows.scss +16 -1
- package/scss/components/Datagrid/styles/_useStickyColumn.scss +31 -2
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +45 -6
- package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -1
- package/scss/components/InlineEdit/_inline-edit.scss +4 -2
- package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -6
- package/scss/components/RemoveModal/_remove-modal.scss +0 -4
- package/scss/components/SidePanel/_side-panel.scss +3 -6
- package/scss/components/Tearsheet/_tearsheet.scss +2 -2
- package/scss/components/WebTerminal/_carbon-imports.scss +6 -0
- package/scss/components/WebTerminal/_index.scss +7 -0
- package/scss/components/WebTerminal/_storybook-styles.scss +7 -0
- package/scss/components/_index-released-only.scss +1 -0
@@ -66,6 +66,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
66
66
|
updateActiveCellCoordinates = _ref.updateActiveCellCoordinates,
|
67
67
|
setHeaderCellHoldActive = _ref.setHeaderCellHoldActive,
|
68
68
|
headerCellHoldActive = _ref.headerCellHoldActive,
|
69
|
+
selectAllAriaLabel = _ref.selectAllAriaLabel,
|
69
70
|
visibleColumns = _ref.visibleColumns;
|
70
71
|
|
71
72
|
var _useState = (0, _react.useState)(0),
|
@@ -198,6 +199,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
198
199
|
"data-column-index": "header",
|
199
200
|
type: "button",
|
200
201
|
tabIndex: -1,
|
202
|
+
"aria-label": selectAllAriaLabel,
|
201
203
|
onClick: handleSelectAllClick,
|
202
204
|
className: (0, _classnames.default)("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__th--select-all"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header'))
|
203
205
|
}, "\xA0")), headerGroup.headers.map(function (column, index) {
|
@@ -282,6 +284,11 @@ DataSpreadsheetHeader.propTypes = {
|
|
282
284
|
*/
|
283
285
|
scrollBarSize: _propTypes.default.number,
|
284
286
|
|
287
|
+
/**
|
288
|
+
* The aria label applied to the Select all button
|
289
|
+
*/
|
290
|
+
selectAllAriaLabel: _propTypes.default.string.isRequired,
|
291
|
+
|
285
292
|
/**
|
286
293
|
* All of the cell selection area items
|
287
294
|
*/
|
@@ -49,7 +49,8 @@ var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
|
|
49
49
|
|
50
50
|
var previousState = (0, _hooks.usePreviousValue)({
|
51
51
|
isEditing: isEditing,
|
52
|
-
windowFocused: windowFocused
|
52
|
+
windowFocused: windowFocused,
|
53
|
+
containerHasFocus: containerHasFocus
|
53
54
|
}); // useEffect to check for window focus, if window loses focus
|
54
55
|
// we need to clear out the keysPressedList
|
55
56
|
|
@@ -80,7 +81,7 @@ var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
|
|
80
81
|
};
|
81
82
|
}, []);
|
82
83
|
(0, _react.useEffect)(function () {
|
83
|
-
if (containerHasFocus && !isEditing) {
|
84
|
+
if (ref && containerHasFocus && !isEditing) {
|
84
85
|
ref.current.onkeydown = ref.current.onkeyup = function (event) {
|
85
86
|
// If keydown, we will add the new key to the keysPressedList array
|
86
87
|
if (event.type === 'keydown') {
|
@@ -132,15 +133,15 @@ var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
|
|
132
133
|
// or is currently in edit mode
|
133
134
|
|
134
135
|
|
135
|
-
if (!containerHasFocus || isEditing) {
|
136
|
+
if (ref && !containerHasFocus || isEditing) {
|
136
137
|
ref.current.onkeydown = undefined;
|
137
138
|
ref.current.onkeyup = undefined;
|
138
139
|
|
139
|
-
if (!(previousState !== null && previousState !== void 0 && previousState.isEditing) && isEditing) {
|
140
|
+
if (!(previousState !== null && previousState !== void 0 && previousState.isEditing) && isEditing || previousState !== null && previousState !== void 0 && previousState.containerHasFocus && !containerHasFocus) {
|
140
141
|
setKeysPressedList([]);
|
141
142
|
}
|
142
143
|
}
|
143
|
-
}, [keysPressedList, containerHasFocus, ref, isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing, windowFocused, previousState === null || previousState === void 0 ? void 0 : previousState.windowFocused, usingMac]);
|
144
|
+
}, [keysPressedList, containerHasFocus, ref, isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.containerHasFocus, windowFocused, previousState === null || previousState === void 0 ? void 0 : previousState.windowFocused, usingMac]);
|
144
145
|
return {
|
145
146
|
keysPressedList: keysPressedList,
|
146
147
|
windowFocused: windowFocused,
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.handleCellDeletion = void 0;
|
7
|
+
|
8
|
+
var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
|
9
|
+
|
10
|
+
var _rangeWithCallback = require("../../../global/js/utils/rangeWithCallback");
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Copyright IBM Corp. 2022, 2022
|
14
|
+
*
|
15
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
17
|
+
*/
|
18
|
+
var handleCellDeletion = function handleCellDeletion(_ref) {
|
19
|
+
var selectionAreas = _ref.selectionAreas,
|
20
|
+
currentMatcher = _ref.currentMatcher,
|
21
|
+
rows = _ref.rows,
|
22
|
+
setActiveCellContent = _ref.setActiveCellContent,
|
23
|
+
updateData = _ref.updateData;
|
24
|
+
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
|
25
|
+
var indexOfCurrentSelectionArea = selectionAreaClone.findIndex(function (item) {
|
26
|
+
return item.matcher === currentMatcher;
|
27
|
+
});
|
28
|
+
var selectionAreaToEmptyContents = selectionAreaClone[indexOfCurrentSelectionArea];
|
29
|
+
var lowestColumnIndex = Math.min(selectionAreaToEmptyContents.point1.column, selectionAreaToEmptyContents.point2.column);
|
30
|
+
var greatestColumnIndex = Math.max(selectionAreaToEmptyContents.point1.column, selectionAreaToEmptyContents.point2.column);
|
31
|
+
var lowestRowIndex = Math.min(selectionAreaToEmptyContents.point1.row, selectionAreaToEmptyContents.point2.row);
|
32
|
+
var greatestRowIndex = Math.max(selectionAreaToEmptyContents.point1.row, selectionAreaToEmptyContents.point2.row);
|
33
|
+
(0, _rangeWithCallback.rangeWithCallback)(lowestColumnIndex, greatestColumnIndex, function (columnIndex) {
|
34
|
+
(0, _rangeWithCallback.rangeWithCallback)(lowestRowIndex, greatestRowIndex, function (rowIndex) {
|
35
|
+
var cellProps = rows[rowIndex].cells[columnIndex];
|
36
|
+
updateData(rowIndex, cellProps === null || cellProps === void 0 ? void 0 : cellProps.column.id, '');
|
37
|
+
});
|
38
|
+
});
|
39
|
+
setActiveCellContent(null);
|
40
|
+
};
|
41
|
+
|
42
|
+
exports.handleCellDeletion = handleCellDeletion;
|
@@ -9,39 +9,29 @@ exports.Datagrid = void 0;
|
|
9
9
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11
11
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
-
|
14
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15
13
|
|
16
14
|
var _react = _interopRequireDefault(require("react"));
|
17
15
|
|
18
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
19
17
|
|
20
|
-
var _react2 = require("@carbon/react");
|
21
|
-
|
22
18
|
var _classnames = _interopRequireDefault(require("classnames"));
|
23
19
|
|
24
|
-
var _DatagridHead = _interopRequireDefault(require("./DatagridHead"));
|
25
|
-
|
26
|
-
var _DatagridBody = _interopRequireDefault(require("./DatagridBody"));
|
27
|
-
|
28
|
-
var _DatagridToolbar = _interopRequireDefault(require("./DatagridToolbar"));
|
29
|
-
|
30
20
|
var _devtools = require("../../../global/js/utils/devtools");
|
31
21
|
|
32
22
|
var _settings = require("../../../settings");
|
33
23
|
|
34
24
|
var _pconsole = _interopRequireDefault(require("../../../global/js/utils/pconsole"));
|
35
25
|
|
26
|
+
var _InlineEditContext = require("./addons/InlineEdit/InlineEditContext");
|
27
|
+
|
28
|
+
var _DatagridContent = require("./DatagridContent");
|
29
|
+
|
36
30
|
var _excluded = ["datagridState"];
|
37
31
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
38
32
|
var componentName = 'Datagrid';
|
39
|
-
var TableContainer = _react2.DataTable.TableContainer,
|
40
|
-
Table = _react2.DataTable.Table;
|
41
33
|
|
42
34
|
var Datagrid = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
43
|
-
var _getTableProps;
|
44
|
-
|
45
35
|
var datagridState = _ref.datagridState,
|
46
36
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
47
37
|
|
@@ -51,47 +41,24 @@ var Datagrid = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
51
41
|
return null;
|
52
42
|
}
|
53
43
|
|
54
|
-
var
|
55
|
-
getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
|
56
|
-
withVirtualScroll = datagridState.withVirtualScroll,
|
44
|
+
var withVirtualScroll = datagridState.withVirtualScroll,
|
57
45
|
DatagridPagination = datagridState.DatagridPagination,
|
58
46
|
isFetching = datagridState.isFetching,
|
59
47
|
tableId = datagridState.tableId,
|
60
|
-
CustomizeColumnsModal = datagridState.CustomizeColumnsModal,
|
61
48
|
leftPanel = datagridState.leftPanel,
|
62
|
-
|
63
|
-
_datagridState$vertic = datagridState.verticalAlign,
|
64
|
-
verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
|
65
|
-
variableRowHeight = datagridState.variableRowHeight,
|
66
|
-
className = datagridState.className,
|
67
|
-
gridTitle = datagridState.gridTitle,
|
68
|
-
gridDescription = datagridState.gridDescription,
|
69
|
-
useDenseHeader = datagridState.useDenseHeader;
|
49
|
+
className = datagridState.className;
|
70
50
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
71
|
-
|
72
|
-
var dataGrid = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TableContainer, {
|
73
|
-
className: (0, _classnames.default)("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : ''),
|
74
|
-
title: gridTitle,
|
75
|
-
description: gridDescription
|
76
|
-
}, /*#__PURE__*/_react.default.createElement(_DatagridToolbar.default, datagridState), /*#__PURE__*/_react.default.createElement("div", {
|
77
|
-
className: "".concat(blockClass, "__table-container")
|
78
|
-
}, leftPanel && leftPanel.isOpen && /*#__PURE__*/_react.default.createElement("div", {
|
79
|
-
className: "".concat(blockClass, "__datagridLeftPanel")
|
80
|
-
}, leftPanel.panelContent), /*#__PURE__*/_react.default.createElement(Table, (0, _extends2.default)({}, getTableProps(), {
|
81
|
-
className: (0, _classnames.default)(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), (0, _defineProperty2.default)({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className)
|
82
|
-
}), /*#__PURE__*/_react.default.createElement(_DatagridHead.default, datagridState), /*#__PURE__*/_react.default.createElement(_DatagridBody.default, (0, _extends2.default)({}, datagridState, {
|
83
|
-
rows: rows
|
84
|
-
}))))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/_react.default.createElement(CustomizeColumnsModal, {
|
85
|
-
instance: datagridState
|
86
|
-
}));
|
87
|
-
|
88
|
-
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
|
51
|
+
return /*#__PURE__*/_react.default.createElement(_InlineEditContext.InlineEditProvider, null, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
|
89
52
|
id: tableId,
|
90
53
|
ref: ref,
|
91
54
|
className: (0, _classnames.default)(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"), !isFetching && rows.length === 0 ? "".concat(blockClass, "__empty-state") : '')
|
92
55
|
}, (0, _devtools.getDevtoolsProps)(componentName)), leftPanel && /*#__PURE__*/_react.default.createElement("div", {
|
93
56
|
className: "".concat(blockClass, "__datagridWithPanel ").concat(blockClass, "__displayFlex ").concat(blockClass, "__leftPanel-position")
|
94
|
-
},
|
57
|
+
}, /*#__PURE__*/_react.default.createElement(_DatagridContent.DatagridContent, {
|
58
|
+
datagridState: datagridState
|
59
|
+
})), leftPanel === undefined && /*#__PURE__*/_react.default.createElement(_DatagridContent.DatagridContent, {
|
60
|
+
datagridState: datagridState
|
61
|
+
})));
|
95
62
|
}); // Return a placeholder if not released and not enabled by feature flag
|
96
63
|
|
97
64
|
|
@@ -0,0 +1,183 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
+
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
8
|
+
value: true
|
9
|
+
});
|
10
|
+
exports.DatagridContent = void 0;
|
11
|
+
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13
|
+
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
|
+
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
17
|
+
|
18
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
19
|
+
|
20
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
21
|
+
|
22
|
+
var _react2 = require("@carbon/react");
|
23
|
+
|
24
|
+
var _layout = require("@carbon/layout");
|
25
|
+
|
26
|
+
var _DatagridHead = _interopRequireDefault(require("./DatagridHead"));
|
27
|
+
|
28
|
+
var _DatagridBody = _interopRequireDefault(require("./DatagridBody"));
|
29
|
+
|
30
|
+
var _DatagridToolbar = _interopRequireDefault(require("./DatagridToolbar"));
|
31
|
+
|
32
|
+
var _handleGridKeyPress = require("./addons/InlineEdit/handleGridKeyPress");
|
33
|
+
|
34
|
+
var _settings = require("../../../settings");
|
35
|
+
|
36
|
+
var _InlineEditContext = require("./addons/InlineEdit/InlineEditContext");
|
37
|
+
|
38
|
+
var _handleGridFocus = require("./addons/InlineEdit/handleGridFocus");
|
39
|
+
|
40
|
+
var _hooks = require("../../../global/js/hooks");
|
41
|
+
|
42
|
+
var _hooks2 = require("../../DataSpreadsheet/hooks");
|
43
|
+
|
44
|
+
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); }
|
45
|
+
|
46
|
+
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; }
|
47
|
+
|
48
|
+
var TableContainer = _react2.DataTable.TableContainer,
|
49
|
+
Table = _react2.DataTable.Table;
|
50
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
51
|
+
|
52
|
+
var DatagridContent = function DatagridContent(_ref) {
|
53
|
+
var _cx4;
|
54
|
+
|
55
|
+
var datagridState = _ref.datagridState;
|
56
|
+
|
57
|
+
var _useContext = (0, _react.useContext)(_InlineEditContext.InlineEditContext),
|
58
|
+
state = _useContext.state,
|
59
|
+
dispatch = _useContext.dispatch;
|
60
|
+
|
61
|
+
var activeCellId = state.activeCellId;
|
62
|
+
var _datagridState$getTab = datagridState.getTableProps,
|
63
|
+
getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
|
64
|
+
withVirtualScroll = datagridState.withVirtualScroll,
|
65
|
+
DatagridPagination = datagridState.DatagridPagination,
|
66
|
+
isFetching = datagridState.isFetching,
|
67
|
+
CustomizeColumnsModal = datagridState.CustomizeColumnsModal,
|
68
|
+
leftPanel = datagridState.leftPanel,
|
69
|
+
fullHeightDatagrid = datagridState.fullHeightDatagrid,
|
70
|
+
_datagridState$vertic = datagridState.verticalAlign,
|
71
|
+
verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
|
72
|
+
variableRowHeight = datagridState.variableRowHeight,
|
73
|
+
gridTitle = datagridState.gridTitle,
|
74
|
+
gridDescription = datagridState.gridDescription,
|
75
|
+
useDenseHeader = datagridState.useDenseHeader,
|
76
|
+
withInlineEdit = datagridState.withInlineEdit,
|
77
|
+
tableId = datagridState.tableId,
|
78
|
+
DatagridActions = datagridState.DatagridActions,
|
79
|
+
totalColumnsWidth = datagridState.totalColumnsWidth;
|
80
|
+
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
81
|
+
var gridActive = state.gridActive,
|
82
|
+
editId = state.editId;
|
83
|
+
var gridAreaRef = (0, _react.useRef)();
|
84
|
+
var multiKeyTrackingRef = (0, _react.useRef)();
|
85
|
+
(0, _hooks.useClickOutside)(gridAreaRef, function (target) {
|
86
|
+
if (!withInlineEdit) {
|
87
|
+
return;
|
88
|
+
} // We return from here if we find a parent element with the selector below
|
89
|
+
// because that element was initially part of the grid area but was removed
|
90
|
+
// and swapped out with an input, i.e. text, number, selection, or date picker
|
91
|
+
|
92
|
+
|
93
|
+
if (target.closest(".".concat(blockClass, "__inline-edit-button")) || target.closest(".".concat(blockClass, "__inline-edit--select"))) {
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
|
97
|
+
dispatch({
|
98
|
+
type: 'REMOVE_GRID_ACTIVE_FOCUS',
|
99
|
+
payload: activeCellId
|
100
|
+
});
|
101
|
+
});
|
102
|
+
|
103
|
+
var renderTable = function renderTable() {
|
104
|
+
var _getTableProps;
|
105
|
+
|
106
|
+
return /*#__PURE__*/_react.default.createElement(Table, (0, _extends2.default)({}, getTableProps(), {
|
107
|
+
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),
|
108
|
+
role: withInlineEdit && 'grid',
|
109
|
+
tabIndex: withInlineEdit && 0,
|
110
|
+
onKeyDown: withInlineEdit ? function (event) {
|
111
|
+
return (0, _handleGridKeyPress.handleGridKeyPress)({
|
112
|
+
event: event,
|
113
|
+
dispatch: dispatch,
|
114
|
+
state: state,
|
115
|
+
instance: datagridState,
|
116
|
+
keysPressedList: keysPressedList,
|
117
|
+
usingMac: usingMac
|
118
|
+
});
|
119
|
+
} : null,
|
120
|
+
onFocus: withInlineEdit ? function () {
|
121
|
+
return (0, _handleGridFocus.handleGridFocus)(state, dispatch);
|
122
|
+
} : null
|
123
|
+
}), /*#__PURE__*/_react.default.createElement(_DatagridHead.default, datagridState), /*#__PURE__*/_react.default.createElement(_DatagridBody.default, (0, _extends2.default)({}, datagridState, {
|
124
|
+
rows: rows
|
125
|
+
})));
|
126
|
+
};
|
127
|
+
|
128
|
+
var _useMultipleKeyTracki = (0, _hooks2.useMultipleKeyTracking)({
|
129
|
+
ref: withInlineEdit ? multiKeyTrackingRef : null,
|
130
|
+
containerHasFocus: gridActive,
|
131
|
+
isEditing: !!editId
|
132
|
+
}),
|
133
|
+
keysPressedList = _useMultipleKeyTracki.keysPressedList,
|
134
|
+
usingMac = _useMultipleKeyTracki.usingMac; // Provides a width for the region outline for useInlineEdit
|
135
|
+
|
136
|
+
|
137
|
+
(0, _react.useEffect)(function () {
|
138
|
+
if (!withInlineEdit) {
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
|
142
|
+
var gridElement = document.querySelector("#".concat(tableId));
|
143
|
+
gridElement.style.setProperty("--".concat(blockClass, "--grid-width"), (0, _layout.px)(totalColumnsWidth + 32));
|
144
|
+
}, [withInlineEdit, tableId, totalColumnsWidth, datagridState]);
|
145
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TableContainer, {
|
146
|
+
className: (0, _classnames.default)("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : '', (_cx4 = {}, (0, _defineProperty2.default)(_cx4, "".concat(blockClass, "__grid-container-grid-active"), gridActive), (0, _defineProperty2.default)(_cx4, "".concat(blockClass, "__grid-container-grid-active--without-toolbar"), withInlineEdit && !DatagridActions), _cx4)),
|
147
|
+
title: gridTitle,
|
148
|
+
description: gridDescription
|
149
|
+
}, /*#__PURE__*/_react.default.createElement(_DatagridToolbar.default, datagridState), /*#__PURE__*/_react.default.createElement("div", {
|
150
|
+
className: "".concat(blockClass, "__table-container"),
|
151
|
+
ref: gridAreaRef
|
152
|
+
}, leftPanel && leftPanel.isOpen && /*#__PURE__*/_react.default.createElement("div", {
|
153
|
+
className: "".concat(blockClass, "__datagridLeftPanel")
|
154
|
+
}, leftPanel.panelContent), withInlineEdit ? /*#__PURE__*/_react.default.createElement("div", {
|
155
|
+
ref: multiKeyTrackingRef
|
156
|
+
}, renderTable()) : renderTable())), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/_react.default.createElement(CustomizeColumnsModal, {
|
157
|
+
instance: datagridState
|
158
|
+
}));
|
159
|
+
};
|
160
|
+
|
161
|
+
exports.DatagridContent = DatagridContent;
|
162
|
+
DatagridContent.propTypes = {
|
163
|
+
datagridState: _propTypes.default.shape({
|
164
|
+
getTableProps: _propTypes.default.func,
|
165
|
+
withVirtualScroll: _propTypes.default.bool,
|
166
|
+
DatagridActions: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
|
167
|
+
DatagridPagination: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
|
168
|
+
CustomizeColumnsModal: _propTypes.default.element,
|
169
|
+
isFetching: _propTypes.default.bool,
|
170
|
+
leftPanel: _propTypes.default.object,
|
171
|
+
fullHeightDatagrid: _propTypes.default.bool,
|
172
|
+
variableRowHeight: _propTypes.default.bool,
|
173
|
+
useDenseHeader: _propTypes.default.bool,
|
174
|
+
withInlineEdit: _propTypes.default.bool,
|
175
|
+
verticalAlign: _propTypes.default.string,
|
176
|
+
gridTitle: _propTypes.default.node,
|
177
|
+
gridDescription: _propTypes.default.node,
|
178
|
+
page: _propTypes.default.arrayOf(_propTypes.default.object),
|
179
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object),
|
180
|
+
tableId: _propTypes.default.string,
|
181
|
+
totalColumnsWidth: _propTypes.default.number
|
182
|
+
})
|
183
|
+
};
|
@@ -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 _react2 = require("@carbon/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 = _react2.DataTable.TableRow,
|
29
40
|
TableCell = _react2.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,27 +11,36 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
11
11
|
|
12
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13
13
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
15
|
+
|
14
16
|
var _react = _interopRequireDefault(require("react"));
|
15
17
|
|
16
18
|
var _react2 = require("@carbon/react");
|
17
19
|
|
20
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
21
|
+
|
18
22
|
var _settings = require("../../../settings");
|
19
23
|
|
20
24
|
var _excluded = ["onChange"];
|
21
25
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
22
26
|
|
23
27
|
var SelectAll = function SelectAll(datagridState) {
|
28
|
+
var _columns$;
|
29
|
+
|
24
30
|
var isFetching = datagridState.isFetching,
|
25
31
|
getToggleAllRowsSelectedProps = datagridState.getToggleAllRowsSelectedProps,
|
26
32
|
getToggleAllPageRowsSelectedProps = datagridState.getToggleAllPageRowsSelectedProps,
|
27
33
|
tableId = datagridState.tableId,
|
28
34
|
hideSelectAll = datagridState.hideSelectAll,
|
29
35
|
DatagridPagination = datagridState.DatagridPagination,
|
30
|
-
radio = datagridState.radio
|
36
|
+
radio = datagridState.radio,
|
37
|
+
columns = datagridState.columns,
|
38
|
+
withStickyColumn = datagridState.withStickyColumn;
|
39
|
+
var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
|
31
40
|
|
32
41
|
if (hideSelectAll || radio) {
|
33
42
|
return /*#__PURE__*/_react.default.createElement("div", {
|
34
|
-
className: "".concat(blockClass, "__head-hidden-select-all")
|
43
|
+
className: (0, _classnames.default)("".concat(blockClass, "__head-hidden-select-all"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft))
|
35
44
|
});
|
36
45
|
}
|
37
46
|
|
@@ -42,7 +51,7 @@ var SelectAll = function SelectAll(datagridState) {
|
|
42
51
|
selectProps = (0, _objectWithoutProperties2.default)(_getProps, _excluded);
|
43
52
|
|
44
53
|
return /*#__PURE__*/_react.default.createElement("div", {
|
45
|
-
className: "".concat(blockClass, "__head-select-all ").concat(blockClass, "__checkbox-cell")
|
54
|
+
className: (0, _classnames.default)("".concat(blockClass, "__head-select-all"), "".concat(blockClass, "__checkbox-cell"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), isFirstColumnStickyLeft))
|
46
55
|
}, /*#__PURE__*/_react.default.createElement(TableSelectAll, (0, _extends2.default)({}, selectProps, {
|
47
56
|
name: "".concat(tableId, "-select-all-checkbox-name"),
|
48
57
|
onSelect: onChange,
|
@@ -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,9 +21,11 @@ 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 _react2 = require("@carbon/react");
|
23
27
|
|
24
|
-
var
|
28
|
+
var _icons = require("@carbon/react/icons");
|
25
29
|
|
26
30
|
var _settings = require("../../../settings");
|
27
31
|
|
@@ -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(_react2.Checkbox, (0, _extends2.default)({}, selectProps, {
|
83
92
|
name: "".concat(tableId, "-select-all-checkbox-name"),
|
84
93
|
onClick: function onClick(e) {
|
@@ -90,7 +99,7 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
90
99
|
hideLabel: true
|
91
100
|
}))), /*#__PURE__*/_react.default.createElement(_react2.OverflowMenu, {
|
92
101
|
renderIcon: function renderIcon(props) {
|
93
|
-
return /*#__PURE__*/_react.default.createElement(
|
102
|
+
return /*#__PURE__*/_react.default.createElement(_icons.CaretDown, (0, _extends2.default)({
|
94
103
|
size: 16
|
95
104
|
}, props));
|
96
105
|
},
|
@@ -133,12 +142,14 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
133
142
|
SelectAllWithToggle.propTypes = {
|
134
143
|
allPageRowsLabel: _propTypes.default.string,
|
135
144
|
allRowsLabel: _propTypes.default.string,
|
145
|
+
columns: _propTypes.default.arrayOf(_propTypes.default.object),
|
136
146
|
getToggleAllPageRowsSelectedProps: _propTypes.default.func.isRequired,
|
137
147
|
getToggleAllRowsSelectedProps: _propTypes.default.func.isRequired,
|
138
148
|
isAllRowsSelected: _propTypes.default.bool.isRequired,
|
139
149
|
isFetching: _propTypes.default.bool,
|
140
150
|
selectAllToggle: _propTypes.default.object,
|
141
|
-
tableId: _propTypes.default.string.isRequired
|
151
|
+
tableId: _propTypes.default.string.isRequired,
|
152
|
+
withStickyColumn: _propTypes.default.bool
|
142
153
|
};
|
143
154
|
var _default = SelectAllWithToggle;
|
144
155
|
exports.default = _default;
|
@@ -15,7 +15,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
15
15
|
|
16
16
|
var _react = _interopRequireWildcard(require("react"));
|
17
17
|
|
18
|
-
var
|
18
|
+
var _icons = require("@carbon/react/icons");
|
19
19
|
|
20
20
|
var _react2 = require("@carbon/react");
|
21
21
|
|
@@ -90,10 +90,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
90
90
|
|
91
91
|
return /*#__PURE__*/_react.default.createElement(_ButtonMenu.ButtonMenu, {
|
92
92
|
label: width > minWidthBeforeOverflowIcon ? 'More' : null,
|
93
|
-
renderIcon: width > minWidthBeforeOverflowIcon ?
|
93
|
+
renderIcon: width > minWidthBeforeOverflowIcon ? _icons.Add : _icons.OverflowMenuVertical,
|
94
94
|
className: (0, _classnames.default)("".concat(blockClass, "__button-menu"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__button-menu--icon-only"), width <= minWidthBeforeOverflowIcon)),
|
95
95
|
menuOptionsClass: "".concat(blockClass, "__button-menu-options"),
|
96
|
-
flipped: true
|
96
|
+
flipped: true,
|
97
|
+
menuAriaLabel: 'Batch actions'
|
97
98
|
}, toolbarBatchActions && toolbarBatchActions.map(function (batchAction, index) {
|
98
99
|
if (index < 2) {
|
99
100
|
if (displayAllInMenu) {
|
@@ -165,9 +166,9 @@ var DatagridToolbar = function DatagridToolbar(datagridState) {
|
|
165
166
|
return batchActions && DatagridActions ? /*#__PURE__*/_react.default.createElement("div", {
|
166
167
|
ref: ref,
|
167
168
|
className: "".concat(blockClass, "__table-toolbar")
|
168
|
-
}, /*#__PURE__*/_react.default.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActionsToolbar && DatagridBatchActionsToolbar(datagridState, width, ref))) : /*#__PURE__*/_react.default.createElement("div", {
|
169
|
+
}, /*#__PURE__*/_react.default.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActionsToolbar && DatagridBatchActionsToolbar(datagridState, width, ref))) : DatagridActions ? /*#__PURE__*/_react.default.createElement("div", {
|
169
170
|
className: "".concat(blockClass, "__table-toolbar")
|
170
|
-
}, /*#__PURE__*/_react.default.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState)));
|
171
|
+
}, /*#__PURE__*/_react.default.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState))) : null;
|
171
172
|
};
|
172
173
|
|
173
174
|
var _default = DatagridToolbar;
|