@carbon/ibm-products 1.11.2 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -3
- package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css +47 -0
- package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css.map +1 -0
- package/css/components/Datagrid/styles/addons/RowSizeDropdown.css +20 -0
- package/css/components/Datagrid/styles/addons/RowSizeDropdown.css.map +1 -0
- package/css/components/Datagrid/styles/datagrid.css +264 -0
- package/css/components/Datagrid/styles/datagrid.css.map +1 -0
- package/css/components/Datagrid/styles/index.css +509 -0
- package/css/components/Datagrid/styles/index.css.map +1 -0
- package/css/components/Datagrid/styles/useActionsColumn.css +23 -0
- package/css/components/Datagrid/styles/useActionsColumn.css.map +1 -0
- package/css/components/Datagrid/styles/useColumnRightAlign.css +28 -0
- package/css/components/Datagrid/styles/useColumnRightAlign.css.map +1 -0
- package/css/components/Datagrid/styles/useNestedRows.css +15 -0
- package/css/components/Datagrid/styles/useNestedRows.css.map +1 -0
- package/css/components/Datagrid/styles/useNestedTable.css +25 -0
- package/css/components/Datagrid/styles/useNestedTable.css.map +1 -0
- package/css/components/Datagrid/styles/useSelectAllToggle.css +28 -0
- package/css/components/Datagrid/styles/useSelectAllToggle.css.map +1 -0
- package/css/components/Datagrid/styles/useSortableColumns.css +50 -0
- package/css/components/Datagrid/styles/useSortableColumns.css.map +1 -0
- package/css/components/Datagrid/styles/useStickyColumn.css +35 -0
- package/css/components/Datagrid/styles/useStickyColumn.css.map +1 -0
- package/css/index-full-carbon.css +2019 -376
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +6 -6
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +18 -6
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +2 -2
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +679 -19
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +5 -5
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +679 -19
- package/css/index.css.map +1 -1
- package/css/index.min.css +6 -6
- package/css/index.min.css.map +1 -1
- package/es/components/ActionBar/ActionBar.js +3 -1
- package/es/components/ActionBar/ActionBarOverflowItems.js +5 -3
- package/es/components/AddSelect/AddSelect.js +133 -30
- package/es/components/AddSelect/AddSelectColumn.js +0 -1
- package/es/components/AddSelect/AddSelectFilter.js +129 -0
- package/es/components/AddSelect/AddSelectList.js +59 -13
- package/es/components/AddSelect/AddSelectSidebar.js +15 -5
- package/es/components/AddSelect/add-select-utils.js +30 -0
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -0
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +262 -164
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +191 -51
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +65 -13
- package/es/components/DataSpreadsheet/hooks/index.js +10 -0
- package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +111 -0
- package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -6
- package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +3 -1
- package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +80 -6
- package/es/components/Datagrid/Datagrid/Datagrid.js +70 -0
- package/es/components/Datagrid/Datagrid/DatagridBody.js +36 -0
- package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -0
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -0
- package/es/components/Datagrid/Datagrid/DatagridHead.js +31 -0
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +57 -0
- package/es/components/Datagrid/Datagrid/DatagridRefBody.js +37 -0
- package/es/components/Datagrid/Datagrid/DatagridRow.js +50 -0
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +50 -0
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +122 -0
- package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +36 -0
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -0
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +87 -0
- package/es/components/Datagrid/Datagrid/DraggableElement.js +188 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +78 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +51 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +140 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +157 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +62 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +13 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +9 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +62 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +139 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/index.js +8 -0
- package/es/components/Datagrid/Datagrid/index.js +8 -0
- package/es/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +6 -0
- package/es/components/Datagrid/Datagrid.stories/LeftPanelStory.js +6 -0
- package/es/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +6 -0
- package/es/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +6 -0
- package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +92 -0
- package/es/components/Datagrid/Datagrid.stories/common.js +199 -0
- package/es/components/Datagrid/Datagrid.stories/index.js +5 -0
- package/es/components/Datagrid/common-column-ids.js +8 -0
- package/es/components/Datagrid/index.js +22 -0
- package/es/components/Datagrid/useActionsColumn.js +86 -0
- package/es/components/Datagrid/useColumnRightAlign.js +52 -0
- package/es/components/Datagrid/useCustomizeColumns.js +45 -0
- package/es/components/Datagrid/useDatagrid.js +44 -0
- package/es/components/Datagrid/useDefaultStringRenderer.js +48 -0
- package/es/components/Datagrid/useDisableSelectRows.js +84 -0
- package/es/components/Datagrid/useExpandedRow.js +52 -0
- package/es/components/Datagrid/useFlexResize.js +51 -0
- package/es/components/Datagrid/useFloatingScroll.js +88 -0
- package/es/components/Datagrid/useInfiniteScroll.js +54 -0
- package/es/components/Datagrid/useNestedRows.js +53 -0
- package/es/components/Datagrid/useOnRowClick.js +37 -0
- package/es/components/Datagrid/useParentDimensions.js +65 -0
- package/es/components/Datagrid/useResizeTable.js +40 -0
- package/es/components/Datagrid/useRowExpander.js +34 -0
- package/es/components/Datagrid/useRowIsMouseOver.js +61 -0
- package/es/components/Datagrid/useRowRenderer.js +30 -0
- package/es/components/Datagrid/useRowSize.js +56 -0
- package/es/components/Datagrid/useSelectAllToggle.js +74 -0
- package/es/components/Datagrid/useSelectRows.js +107 -0
- package/es/components/Datagrid/useSkeletonRows.js +32 -0
- package/es/components/Datagrid/useSortableColumns.js +110 -0
- package/es/components/Datagrid/useStickyColumn.js +183 -0
- package/es/components/HTTPErrors/assets/HTTPErrorSvg403.js +2 -3
- package/es/components/HTTPErrors/assets/HTTPErrorSvg404.js +2 -3
- package/es/components/HTTPErrors/assets/HTTPErrorSvgOther.js +2 -3
- package/es/components/ImportModal/ImportModal.js +2 -2
- package/es/components/TagSet/TagSet.js +12 -3
- package/es/components/UserProfileImage/UserProfileImage.js +38 -10
- package/es/components/index.js +2 -1
- package/es/global/js/package-settings.js +2 -1
- package/lib/components/ActionBar/ActionBar.js +3 -1
- package/lib/components/ActionBar/ActionBarOverflowItems.js +5 -3
- package/lib/components/AddSelect/AddSelect.js +132 -28
- package/lib/components/AddSelect/AddSelectColumn.js +0 -1
- package/lib/components/AddSelect/AddSelectFilter.js +147 -0
- package/lib/components/AddSelect/AddSelectList.js +61 -12
- package/lib/components/AddSelect/AddSelectSidebar.js +15 -11
- package/lib/components/AddSelect/add-select-utils.js +35 -2
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +267 -168
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +191 -57
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +67 -18
- package/lib/components/DataSpreadsheet/hooks/index.js +37 -0
- package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +123 -0
- package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -5
- package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +3 -1
- package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +83 -7
- package/lib/components/Datagrid/Datagrid/Datagrid.js +86 -0
- package/lib/components/Datagrid/Datagrid/DatagridBody.js +50 -0
- package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +31 -0
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +38 -0
- package/lib/components/Datagrid/Datagrid/DatagridHead.js +43 -0
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +73 -0
- package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +44 -0
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +56 -0
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +55 -0
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +139 -0
- package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +44 -0
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +35 -0
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +101 -0
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +210 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +92 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +65 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +166 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +173 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +73 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +25 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +23 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +80 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +160 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/index.js +15 -0
- package/lib/components/Datagrid/Datagrid/index.js +15 -0
- package/lib/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +13 -0
- package/lib/components/Datagrid/Datagrid.stories/LeftPanelStory.js +13 -0
- package/lib/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +13 -0
- package/lib/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +13 -0
- package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +112 -0
- package/lib/components/Datagrid/Datagrid.stories/common.js +215 -0
- package/lib/components/Datagrid/Datagrid.stories/index.js +47 -0
- package/lib/components/Datagrid/common-column-ids.js +16 -0
- package/lib/components/Datagrid/index.js +127 -0
- package/lib/components/Datagrid/useActionsColumn.js +94 -0
- package/lib/components/Datagrid/useColumnRightAlign.js +59 -0
- package/lib/components/Datagrid/useCustomizeColumns.js +55 -0
- package/lib/components/Datagrid/useDatagrid.js +58 -0
- package/lib/components/Datagrid/useDefaultStringRenderer.js +54 -0
- package/lib/components/Datagrid/useDisableSelectRows.js +92 -0
- package/lib/components/Datagrid/useExpandedRow.js +58 -0
- package/lib/components/Datagrid/useFlexResize.js +61 -0
- package/lib/components/Datagrid/useFloatingScroll.js +101 -0
- package/lib/components/Datagrid/useInfiniteScroll.js +67 -0
- package/lib/components/Datagrid/useNestedRows.js +65 -0
- package/lib/components/Datagrid/useOnRowClick.js +45 -0
- package/lib/components/Datagrid/useParentDimensions.js +75 -0
- package/lib/components/Datagrid/useResizeTable.js +48 -0
- package/lib/components/Datagrid/useRowExpander.js +45 -0
- package/lib/components/Datagrid/useRowIsMouseOver.js +66 -0
- package/lib/components/Datagrid/useRowRenderer.js +40 -0
- package/lib/components/Datagrid/useRowSize.js +67 -0
- package/lib/components/Datagrid/useSelectAllToggle.js +88 -0
- package/lib/components/Datagrid/useSelectRows.js +119 -0
- package/lib/components/Datagrid/useSkeletonRows.js +42 -0
- package/lib/components/Datagrid/useSortableColumns.js +117 -0
- package/lib/components/Datagrid/useStickyColumn.js +190 -0
- package/lib/components/HTTPErrors/assets/HTTPErrorSvg403.js +2 -3
- package/lib/components/HTTPErrors/assets/HTTPErrorSvg404.js +2 -3
- package/lib/components/HTTPErrors/assets/HTTPErrorSvgOther.js +2 -3
- package/lib/components/ImportModal/ImportModal.js +1 -1
- package/lib/components/TagSet/TagSet.js +12 -3
- package/lib/components/UserProfileImage/UserProfileImage.js +38 -10
- package/lib/components/index.js +9 -1
- package/lib/global/js/package-settings.js +2 -1
- package/package.json +19 -15
- package/scss/components/AboutModal/_about-modal.scss +2 -2
- package/scss/components/ActionSet/_action-set.scss +3 -1
- package/scss/components/AddSelect/_add-select.scss +87 -3
- package/scss/components/CreateModal/_create-modal.scss +7 -5
- package/scss/components/CreateModal/_storybook-styles.scss +8 -7
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +70 -10
- package/scss/components/Datagrid/_datagrid.scss +66 -0
- package/scss/components/Datagrid/_index.scss +8 -0
- package/scss/components/Datagrid/_storybook-styles.scss +26 -0
- package/scss/components/Datagrid/styles/_variables.scss +9 -0
- package/scss/components/Datagrid/styles/addons/CustomizeColumnsModal.scss +48 -0
- package/scss/components/Datagrid/styles/addons/RowSizeDropdown.scss +23 -0
- package/scss/components/Datagrid/styles/datagrid.scss +318 -0
- package/scss/components/Datagrid/styles/index.scss +17 -0
- package/scss/components/Datagrid/styles/useActionsColumn.scss +24 -0
- package/scss/components/Datagrid/styles/useColumnRightAlign.scss +29 -0
- package/scss/components/Datagrid/styles/useNestedRows.scss +17 -0
- package/scss/components/Datagrid/styles/useNestedTable.scss +28 -0
- package/scss/components/Datagrid/styles/useSelectAllToggle.scss +28 -0
- package/scss/components/Datagrid/styles/useSortableColumns.scss +55 -0
- package/scss/components/Datagrid/styles/useStickyColumn.scss +38 -0
- package/scss/components/ExportModal/_export-modal.scss +3 -3
- package/scss/components/HTTPErrors/_http-errors.scss +16 -16
- package/scss/components/InlineEdit/_inline-edit.scss +0 -1
- package/scss/components/ModifiedTabs/_modified-tabs.scss +0 -10
- package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -3
- package/scss/components/OptionsTile/_options-tile.scss +0 -1
- package/scss/components/PageHeader/_page-header.scss +4 -0
- package/scss/components/RemoveModal/_remove-modal.scss +3 -3
- package/scss/components/TagSet/_tag-set.scss +2 -1
- package/scss/components/Tearsheet/_tearsheet.scss +5 -2
- package/scss/components/_index.scss +1 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
var _excluded = ["onChange"];
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Licensed Materials - Property of IBM
|
|
8
|
+
* 5724-Q36
|
|
9
|
+
* (c) Copyright IBM Corp. 2020, 2021
|
|
10
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
11
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
12
|
+
*/
|
|
13
|
+
// @flow
|
|
14
|
+
import React, { useEffect, useState } from 'react';
|
|
15
|
+
import PropTypes from 'prop-types';
|
|
16
|
+
import InlineCheckbox from 'carbon-components-react/lib/components/InlineCheckbox';
|
|
17
|
+
import { OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
|
18
|
+
import { CaretDown16 } from '@carbon/icons-react';
|
|
19
|
+
import { pkg } from '../../../settings'; // cspell:words columnheader
|
|
20
|
+
|
|
21
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
22
|
+
var SELECT_ALL_PAGE_ROWS = 'pageRows';
|
|
23
|
+
var SELECT_ALL_ROWS = 'allRows';
|
|
24
|
+
|
|
25
|
+
var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
26
|
+
var tableId = _ref.tableId,
|
|
27
|
+
isFetching = _ref.isFetching,
|
|
28
|
+
isAllRowsSelected = _ref.isAllRowsSelected,
|
|
29
|
+
selectAllToggle = _ref.selectAllToggle,
|
|
30
|
+
getToggleAllPageRowsSelectedProps = _ref.getToggleAllPageRowsSelectedProps,
|
|
31
|
+
getToggleAllRowsSelectedProps = _ref.getToggleAllRowsSelectedProps,
|
|
32
|
+
_ref$allPageRowsLabel = _ref.allPageRowsLabel,
|
|
33
|
+
allPageRowsLabel = _ref$allPageRowsLabel === void 0 ? 'Select all on page' : _ref$allPageRowsLabel,
|
|
34
|
+
_ref$allRowsLabel = _ref.allRowsLabel,
|
|
35
|
+
allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel;
|
|
36
|
+
|
|
37
|
+
var _useState = useState(SELECT_ALL_PAGE_ROWS),
|
|
38
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
39
|
+
selectAllMode = _useState2[0],
|
|
40
|
+
setSelectAllMode = _useState2[1];
|
|
41
|
+
|
|
42
|
+
useEffect(function () {
|
|
43
|
+
if (onSelectAllRows) {
|
|
44
|
+
onSelectAllRows(isAllRowsSelected && selectAllMode === SELECT_ALL_ROWS);
|
|
45
|
+
}
|
|
46
|
+
}, [isAllRowsSelected, selectAllMode, onSelectAllRows]);
|
|
47
|
+
|
|
48
|
+
var _ref2 = selectAllToggle || {},
|
|
49
|
+
onSelectAllRows = _ref2.onSelectAllRows,
|
|
50
|
+
labels = _ref2.labels;
|
|
51
|
+
|
|
52
|
+
if (labels) {
|
|
53
|
+
allPageRowsLabel = labels.allPageRows || allPageRowsLabel;
|
|
54
|
+
allRowsLabel = labels.allRows || allRowsLabel;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var getProps = selectAllMode === SELECT_ALL_PAGE_ROWS ? getToggleAllPageRowsSelectedProps : getToggleAllRowsSelectedProps;
|
|
58
|
+
|
|
59
|
+
var _getProps = getProps(),
|
|
60
|
+
onChange = _getProps.onChange,
|
|
61
|
+
selectProps = _objectWithoutProperties(_getProps, _excluded);
|
|
62
|
+
|
|
63
|
+
var disabled = isFetching || selectProps.disabled;
|
|
64
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
65
|
+
role: "columnheader",
|
|
66
|
+
scope: "col",
|
|
67
|
+
className: "".concat(blockClass, "__select-all-toggle-on")
|
|
68
|
+
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(InlineCheckbox, _extends({}, selectProps, {
|
|
69
|
+
name: "".concat(tableId, "-select-all-checkbox-name"),
|
|
70
|
+
onClick: function onClick(e) {
|
|
71
|
+
onChange(e);
|
|
72
|
+
},
|
|
73
|
+
disabled: disabled,
|
|
74
|
+
id: "".concat(tableId, "-select-all-checkbox-id")
|
|
75
|
+
}))), /*#__PURE__*/React.createElement(OverflowMenu, {
|
|
76
|
+
renderIcon: CaretDown16,
|
|
77
|
+
size: "sm"
|
|
78
|
+
}, /*#__PURE__*/React.createElement(OverflowMenuItem, {
|
|
79
|
+
itemText: allPageRowsLabel,
|
|
80
|
+
requireTitle: true,
|
|
81
|
+
disabled: disabled,
|
|
82
|
+
onClick: function onClick() {
|
|
83
|
+
setSelectAllMode(SELECT_ALL_PAGE_ROWS); // deselect all rows first
|
|
84
|
+
|
|
85
|
+
getToggleAllRowsSelectedProps().onChange({
|
|
86
|
+
target: {
|
|
87
|
+
checked: false
|
|
88
|
+
}
|
|
89
|
+
}); // select all row on current page
|
|
90
|
+
|
|
91
|
+
getToggleAllPageRowsSelectedProps().onChange({
|
|
92
|
+
target: {
|
|
93
|
+
checked: true
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}), /*#__PURE__*/React.createElement(OverflowMenuItem, {
|
|
98
|
+
itemText: allRowsLabel,
|
|
99
|
+
requireTitle: true,
|
|
100
|
+
disabled: disabled,
|
|
101
|
+
onClick: function onClick() {
|
|
102
|
+
setSelectAllMode(SELECT_ALL_ROWS);
|
|
103
|
+
getToggleAllRowsSelectedProps().onChange({
|
|
104
|
+
target: {
|
|
105
|
+
checked: true
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
})));
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
SelectAllWithToggle.propTypes = {
|
|
113
|
+
allPageRowsLabel: PropTypes.string,
|
|
114
|
+
allRowsLabel: PropTypes.string,
|
|
115
|
+
getToggleAllPageRowsSelectedProps: PropTypes.func.isRequired,
|
|
116
|
+
getToggleAllRowsSelectedProps: PropTypes.func.isRequired,
|
|
117
|
+
isAllRowsSelected: PropTypes.bool.isRequired,
|
|
118
|
+
isFetching: PropTypes.bool,
|
|
119
|
+
selectAllToggle: PropTypes.object,
|
|
120
|
+
tableId: PropTypes.string.isRequired
|
|
121
|
+
};
|
|
122
|
+
export default SelectAllWithToggle;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
|
|
4
|
+
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; }
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Licensed Materials - Property of IBM
|
|
10
|
+
* 5724-Q36
|
|
11
|
+
* (c) Copyright IBM Corp. 2020
|
|
12
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
13
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
14
|
+
*/
|
|
15
|
+
import React from 'react';
|
|
16
|
+
import { DataTable } from 'carbon-components-react';
|
|
17
|
+
import cx from 'classnames';
|
|
18
|
+
import { pkg } from '../../../settings';
|
|
19
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
20
|
+
var TableBody = DataTable.TableBody;
|
|
21
|
+
|
|
22
|
+
var DatagridSimpleBody = function DatagridSimpleBody(datagridState) {
|
|
23
|
+
var getTableBodyProps = datagridState.getTableBodyProps,
|
|
24
|
+
rows = datagridState.rows,
|
|
25
|
+
prepareRow = datagridState.prepareRow;
|
|
26
|
+
return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
|
|
27
|
+
className: cx("".concat(blockClass, "__simple-body"), getTableBodyProps().className)
|
|
28
|
+
}), rows.map(function (row) {
|
|
29
|
+
prepareRow(row);
|
|
30
|
+
return row.RowRenderer(_objectSpread(_objectSpread({}, datagridState), {}, {
|
|
31
|
+
row: row
|
|
32
|
+
}));
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default DatagridSimpleBody;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed Materials - Property of IBM
|
|
3
|
+
* 5724-Q36
|
|
4
|
+
* (c) Copyright IBM Corp. 2020
|
|
5
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
6
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
7
|
+
*/
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { DataTable } from 'carbon-components-react';
|
|
10
|
+
import { pkg } from '../../../settings';
|
|
11
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
12
|
+
var TableToolbar = DataTable.TableToolbar;
|
|
13
|
+
|
|
14
|
+
var DatagridToolbar = function DatagridToolbar(datagridState) {
|
|
15
|
+
var DatagridActions = datagridState.DatagridActions,
|
|
16
|
+
DatagridBatchActions = datagridState.DatagridBatchActions;
|
|
17
|
+
return DatagridActions || DatagridBatchActions ? /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: "".concat(blockClass, "__table-toolbar")
|
|
19
|
+
}, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState))) : null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default DatagridToolbar;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
|
|
4
|
+
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; }
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Licensed Materials - Property of IBM
|
|
10
|
+
* 5724-Q36
|
|
11
|
+
* (c) Copyright IBM Corp. 2020 - 2021
|
|
12
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
13
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
14
|
+
*/
|
|
15
|
+
import React, { useEffect } from 'react';
|
|
16
|
+
import { VariableSizeList } from 'react-window';
|
|
17
|
+
import { DataTable } from 'carbon-components-react';
|
|
18
|
+
import { pkg } from '../../../settings';
|
|
19
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
20
|
+
var TableBody = DataTable.TableBody;
|
|
21
|
+
var rowSizeMap = {
|
|
22
|
+
xs: 24,
|
|
23
|
+
sm: 32,
|
|
24
|
+
md: 40,
|
|
25
|
+
lg: 48,
|
|
26
|
+
xl: 64,
|
|
27
|
+
// TODO: deprecate the below values in next major release (v8) on carbon-components-react
|
|
28
|
+
short: 32,
|
|
29
|
+
compact: 24,
|
|
30
|
+
normal: 48,
|
|
31
|
+
tall: 64
|
|
32
|
+
};
|
|
33
|
+
var defaultRowHeight = rowSizeMap.lg;
|
|
34
|
+
|
|
35
|
+
var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
36
|
+
var getTableBodyProps = datagridState.getTableBodyProps,
|
|
37
|
+
rows = datagridState.rows,
|
|
38
|
+
prepareRow = datagridState.prepareRow,
|
|
39
|
+
onScroll = datagridState.onScroll,
|
|
40
|
+
innerListRef = datagridState.innerListRef,
|
|
41
|
+
_datagridState$tableH = datagridState.tableHeight,
|
|
42
|
+
tableHeight = _datagridState$tableH === void 0 ? 400 : _datagridState$tableH,
|
|
43
|
+
listRef = datagridState.listRef,
|
|
44
|
+
rowSize = datagridState.rowSize,
|
|
45
|
+
DatagridPagination = datagridState.DatagridPagination,
|
|
46
|
+
page = datagridState.page,
|
|
47
|
+
handleResize = datagridState.handleResize,
|
|
48
|
+
withOverflowRow = datagridState.withOverflowRow;
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
handleResize();
|
|
51
|
+
}, [handleResize]);
|
|
52
|
+
var rowHeight = rowSize && rowSizeMap[rowSize] || defaultRowHeight;
|
|
53
|
+
|
|
54
|
+
if (listRef && listRef.current) {
|
|
55
|
+
listRef.current.resetAfterIndex(0);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var visibleRows = DatagridPagination && page || rows;
|
|
59
|
+
return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
|
|
60
|
+
onScroll: onScroll
|
|
61
|
+
}), /*#__PURE__*/React.createElement(VariableSizeList, {
|
|
62
|
+
height: tableHeight,
|
|
63
|
+
itemCount: visibleRows.length,
|
|
64
|
+
itemSize: function itemSize(index) {
|
|
65
|
+
return visibleRows[index].isExpanded ? (visibleRows[index].expandedContentHeight || 0) + rowHeight : rowHeight;
|
|
66
|
+
},
|
|
67
|
+
estimatedItemSize: rowHeight,
|
|
68
|
+
onScroll: onScroll,
|
|
69
|
+
innerRef: innerListRef,
|
|
70
|
+
ref: listRef,
|
|
71
|
+
className: "".concat(blockClass, "__virtual-scrollbar")
|
|
72
|
+
}, function (_ref) {
|
|
73
|
+
var index = _ref.index,
|
|
74
|
+
style = _ref.style;
|
|
75
|
+
var row = visibleRows[index];
|
|
76
|
+
prepareRow(row);
|
|
77
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
79
|
+
overflow: withOverflowRow ? 'visible' : 'hidden'
|
|
80
|
+
})
|
|
81
|
+
}, row.RowRenderer(_objectSpread(_objectSpread({}, datagridState), {}, {
|
|
82
|
+
row: row
|
|
83
|
+
})));
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default DatagridVirtualBody;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
// @flow
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Licensed Materials - Property of IBM
|
|
6
|
+
* 5724-Q36
|
|
7
|
+
* (c) Copyright IBM Corp. 2021
|
|
8
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
9
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
10
|
+
*/
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { Draggable16 } from '@carbon/icons-react';
|
|
14
|
+
import { useDrag, useDrop } from 'react-dnd';
|
|
15
|
+
import cx from 'classnames';
|
|
16
|
+
var useEffect = React.useEffect,
|
|
17
|
+
useRef = React.useRef,
|
|
18
|
+
useState = React.useState;
|
|
19
|
+
var DRAG_TYPE = 'wkc-shared-ui-draggable-element';
|
|
20
|
+
|
|
21
|
+
var DraggableElement = function DraggableElement(_ref) {
|
|
22
|
+
var id = _ref.id,
|
|
23
|
+
index = _ref.index,
|
|
24
|
+
listData = _ref.listData,
|
|
25
|
+
children = _ref.children,
|
|
26
|
+
type = _ref.type,
|
|
27
|
+
disabled = _ref.disabled,
|
|
28
|
+
ariaLabel = _ref.ariaLabel,
|
|
29
|
+
onGrab = _ref.onGrab,
|
|
30
|
+
onArrowKeyDown = _ref.onArrowKeyDown,
|
|
31
|
+
isFocused = _ref.isFocused,
|
|
32
|
+
moveElement = _ref.moveElement,
|
|
33
|
+
_ref$positionLabel = _ref.positionLabel,
|
|
34
|
+
positionLabel = _ref$positionLabel === void 0 ? 'Current position {index} of {total}' : _ref$positionLabel,
|
|
35
|
+
_ref$grabbedLabel = _ref.grabbedLabel,
|
|
36
|
+
grabbedLabel = _ref$grabbedLabel === void 0 ? '{itemName} grabbed.' : _ref$grabbedLabel,
|
|
37
|
+
_ref$droppedLabel = _ref.droppedLabel,
|
|
38
|
+
droppedLabel = _ref$droppedLabel === void 0 ? '{itemName} dropped.' : _ref$droppedLabel;
|
|
39
|
+
var ref = useRef();
|
|
40
|
+
|
|
41
|
+
var _useDrop = useDrop({
|
|
42
|
+
accept: DRAG_TYPE + type,
|
|
43
|
+
collect: function collect(monitor) {
|
|
44
|
+
return {
|
|
45
|
+
isOver: !!monitor.isOver()
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
drop: function drop(item) {
|
|
49
|
+
moveElement(item.index, index);
|
|
50
|
+
},
|
|
51
|
+
canDrop: function canDrop() {
|
|
52
|
+
return !disabled;
|
|
53
|
+
},
|
|
54
|
+
hover: function hover(item) {
|
|
55
|
+
var dragIndex = item.index;
|
|
56
|
+
var hoverIndex = index; // Don't replace items with themselves
|
|
57
|
+
|
|
58
|
+
// Don't replace items with themselves
|
|
59
|
+
if (dragIndex === hoverIndex || disabled) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
moveElement(dragIndex, hoverIndex); // Time to actually perform the action
|
|
64
|
+
// Note: we're mutating the monitor item here!
|
|
65
|
+
// Generally it's better to avoid mutations,
|
|
66
|
+
// but it's good here for the sake of performance
|
|
67
|
+
// to avoid expensive index searches.
|
|
68
|
+
// eslint-disable-next-line no-param-reassign
|
|
69
|
+
|
|
70
|
+
// Time to actually perform the action
|
|
71
|
+
// Note: we're mutating the monitor item here!
|
|
72
|
+
// Generally it's better to avoid mutations,
|
|
73
|
+
// but it's good here for the sake of performance
|
|
74
|
+
// to avoid expensive index searches.
|
|
75
|
+
// eslint-disable-next-line no-param-reassign
|
|
76
|
+
item.index = hoverIndex;
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
|
80
|
+
isOver = _useDrop2[0].isOver,
|
|
81
|
+
drop = _useDrop2[1];
|
|
82
|
+
|
|
83
|
+
var _useDrag = useDrag({
|
|
84
|
+
type: DRAG_TYPE + type,
|
|
85
|
+
item: {
|
|
86
|
+
id: id,
|
|
87
|
+
index: index
|
|
88
|
+
},
|
|
89
|
+
canDrag: function canDrag() {
|
|
90
|
+
return !disabled;
|
|
91
|
+
},
|
|
92
|
+
collect: function collect(monitor) {
|
|
93
|
+
return {
|
|
94
|
+
isDragging: monitor.isDragging()
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
_useDrag2 = _slicedToArray(_useDrag, 3),
|
|
99
|
+
isDragging = _useDrag2[0].isDragging,
|
|
100
|
+
drag = _useDrag2[1],
|
|
101
|
+
preview = _useDrag2[2];
|
|
102
|
+
|
|
103
|
+
useEffect(function () {
|
|
104
|
+
if (isFocused && ref && ref.current) {
|
|
105
|
+
ref.current.focus();
|
|
106
|
+
}
|
|
107
|
+
}, [isFocused]);
|
|
108
|
+
|
|
109
|
+
var _useState = useState(false),
|
|
110
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
111
|
+
isGrabbed = _useState2[0],
|
|
112
|
+
setIsGrabbed = _useState2[1];
|
|
113
|
+
|
|
114
|
+
var _useState3 = useState(isFocused),
|
|
115
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
116
|
+
isFocusedOnItem = _useState4[0],
|
|
117
|
+
setIsFocusedOnItem = _useState4[1];
|
|
118
|
+
|
|
119
|
+
drop(ref);
|
|
120
|
+
var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
121
|
+
className: cx({
|
|
122
|
+
disabled: disabled
|
|
123
|
+
}, 'wkc-draggable-handleStyle')
|
|
124
|
+
}, /*#__PURE__*/React.createElement(Draggable16, null)), children);
|
|
125
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
126
|
+
className: cx({
|
|
127
|
+
'wkc-draggable-handleHolder-isOver': isOver && !disabled
|
|
128
|
+
}, {
|
|
129
|
+
'wkc-draggable-handleHolder--grabbed': isGrabbed
|
|
130
|
+
}, 'wkc-draggable-handleHolder'),
|
|
131
|
+
ref: ref,
|
|
132
|
+
"aria-selected": isFocused,
|
|
133
|
+
role: "option",
|
|
134
|
+
tabIndex: isFocused ? 0 : -1,
|
|
135
|
+
onKeyPress: function onKeyPress(e) {
|
|
136
|
+
if (e.key === ' ' && e.target === e.currentTarget && !disabled) {
|
|
137
|
+
var positionText = positionLabel.replace('{index}', index + 1).replace('{total}', listData.length);
|
|
138
|
+
var grabAriaText = (isGrabbed ? droppedLabel : grabbedLabel).replace('{itemName}', ariaLabel);
|
|
139
|
+
onGrab(grabAriaText + positionText);
|
|
140
|
+
setIsGrabbed(!isGrabbed);
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
onKeyDown: function onKeyDown(e) {
|
|
145
|
+
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
146
|
+
onArrowKeyDown(e, isGrabbed, index);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
onBlur: function onBlur(e) {
|
|
150
|
+
// handle when focus move to inner elements
|
|
151
|
+
setIsFocusedOnItem(e.currentTarget === e.target);
|
|
152
|
+
},
|
|
153
|
+
onFocus: function onFocus(e) {
|
|
154
|
+
// handle when focus move to li element
|
|
155
|
+
setIsFocusedOnItem(e.currentTarget === e.target);
|
|
156
|
+
}
|
|
157
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
158
|
+
className: "wkc-shared-ui--assistive-text"
|
|
159
|
+
}, ariaLabel), isDragging && !isOver ? /*#__PURE__*/React.createElement("div", {
|
|
160
|
+
ref: preview,
|
|
161
|
+
className: "wkc-draggable-handleHolder-droppable"
|
|
162
|
+
}, content) : /*#__PURE__*/React.createElement("div", {
|
|
163
|
+
ref: drag,
|
|
164
|
+
"aria-hidden": isFocused && isFocusedOnItem // if focus on li, hide the children from aria
|
|
165
|
+
,
|
|
166
|
+
className: cx({
|
|
167
|
+
'wkc-draggable-handleStyle': !disabled
|
|
168
|
+
}, 'wkc-draggable-handleHolder-droppable')
|
|
169
|
+
}, (!isOver || disabled) && content));
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
DraggableElement.propTypes = {
|
|
173
|
+
ariaLabel: PropTypes.string.isRequired,
|
|
174
|
+
children: PropTypes.element.isRequired,
|
|
175
|
+
disabled: PropTypes.bool,
|
|
176
|
+
droppedLabel: PropTypes.string,
|
|
177
|
+
grabbedLabel: PropTypes.string,
|
|
178
|
+
id: PropTypes.string.isRequired,
|
|
179
|
+
index: PropTypes.number.isRequired,
|
|
180
|
+
isFocused: PropTypes.bool.isRequired,
|
|
181
|
+
listData: PropTypes.array.isRequired,
|
|
182
|
+
moveElement: PropTypes.func.isRequired,
|
|
183
|
+
onArrowKeyDown: PropTypes.func.isRequired,
|
|
184
|
+
onGrab: PropTypes.func.isRequired,
|
|
185
|
+
positionLabel: PropTypes.string,
|
|
186
|
+
type: PropTypes.string.isRequired
|
|
187
|
+
};
|
|
188
|
+
export default DraggableElement;
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
// @flow
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Licensed Materials - Property of IBM
|
|
11
|
+
* 5724-Q36
|
|
12
|
+
* (c) Copyright IBM Corp. 2021
|
|
13
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
14
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
15
|
+
*/
|
|
16
|
+
import { Reset16 } from '@carbon/icons-react';
|
|
17
|
+
import PropTypes from 'prop-types';
|
|
18
|
+
import { Button, Search } from 'carbon-components-react';
|
|
19
|
+
import * as React from 'react';
|
|
20
|
+
import keyBy from 'lodash/keyBy';
|
|
21
|
+
import { pkg } from '../../../../../settings';
|
|
22
|
+
import { isColumnVisible } from './common';
|
|
23
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
24
|
+
|
|
25
|
+
var Actions = function Actions(_ref) {
|
|
26
|
+
var searchText = _ref.searchText,
|
|
27
|
+
columns = _ref.columns,
|
|
28
|
+
originalColumnDefinitions = _ref.originalColumnDefinitions,
|
|
29
|
+
setColumnsObject = _ref.setColumnsObject,
|
|
30
|
+
setSearchText = _ref.setSearchText,
|
|
31
|
+
_ref$findColumnPlaceh = _ref.findColumnPlaceholderLabel,
|
|
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;
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "".concat(blockClass, "__customize-columns-modal--actions"),
|
|
37
|
+
"test-id": "".concat(blockClass, "__customize-columns-modal--actions")
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Search, {
|
|
39
|
+
placeholder: findColumnPlaceholderLabel,
|
|
40
|
+
value: searchText,
|
|
41
|
+
size: "sm",
|
|
42
|
+
labelText: findColumnPlaceholderLabel,
|
|
43
|
+
onChange: function onChange(e) {
|
|
44
|
+
// TODO: is it performant?
|
|
45
|
+
setSearchText(e.target.value);
|
|
46
|
+
},
|
|
47
|
+
"test-id": "".concat(blockClass, "__customize-columns-modal--search")
|
|
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
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
Actions.propTypes = {
|
|
70
|
+
columns: PropTypes.array.isRequired,
|
|
71
|
+
findColumnPlaceholderLabel: PropTypes.string,
|
|
72
|
+
originalColumnDefinitions: PropTypes.array.isRequired,
|
|
73
|
+
resetToDefaultLabel: PropTypes.string,
|
|
74
|
+
searchText: PropTypes.string.isRequired,
|
|
75
|
+
setColumnsObject: PropTypes.func.isRequired,
|
|
76
|
+
setSearchText: PropTypes.func.isRequired
|
|
77
|
+
};
|
|
78
|
+
export default Actions;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["onClick", "setIsModalOpen", "isModalOpen", "iconTooltipLabel"];
|
|
4
|
+
// @flow
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Licensed Materials - Property of IBM
|
|
8
|
+
* 5724-Q36
|
|
9
|
+
* (c) Copyright IBM Corp. 2021
|
|
10
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
|
11
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
12
|
+
*/
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import PropTypes from 'prop-types';
|
|
15
|
+
import { Column16 } from '@carbon/icons-react';
|
|
16
|
+
import { Button } from 'carbon-components-react';
|
|
17
|
+
import { pkg } from '../../../../../settings';
|
|
18
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
19
|
+
|
|
20
|
+
var ButtonWrapper = function ButtonWrapper(_ref) {
|
|
21
|
+
var _onClick = _ref.onClick,
|
|
22
|
+
setIsModalOpen = _ref.setIsModalOpen,
|
|
23
|
+
isModalOpen = _ref.isModalOpen,
|
|
24
|
+
_ref$iconTooltipLabel = _ref.iconTooltipLabel,
|
|
25
|
+
iconTooltipLabel = _ref$iconTooltipLabel === void 0 ? 'Customize columns' : _ref$iconTooltipLabel,
|
|
26
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
|
|
29
|
+
renderIcon: Column16,
|
|
30
|
+
iconDescription: iconTooltipLabel,
|
|
31
|
+
tooltipPosition: "left",
|
|
32
|
+
kind: "ghost",
|
|
33
|
+
hasIconOnly: true,
|
|
34
|
+
"test-id": "".concat(blockClass, "__customize-columns-trigger"),
|
|
35
|
+
onClick: function onClick() {
|
|
36
|
+
setIsModalOpen(!isModalOpen);
|
|
37
|
+
|
|
38
|
+
if (typeof _onClick === 'function') {
|
|
39
|
+
_onClick();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
ButtonWrapper.propTypes = {
|
|
46
|
+
iconTooltipLabel: PropTypes.string,
|
|
47
|
+
isModalOpen: PropTypes.bool.isRequired,
|
|
48
|
+
onClick: PropTypes.func.isRequired,
|
|
49
|
+
setIsModalOpen: PropTypes.func.isRequired
|
|
50
|
+
};
|
|
51
|
+
export default ButtonWrapper;
|