@carbon/ibm-products 1.12.0 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +653 -21
- 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 +21 -10
- 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 +653 -21
- 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 +653 -21
- 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 +98 -40
- package/es/components/AddSelect/AddSelectFilter.js +129 -0
- package/es/components/AddSelect/AddSelectList.js +27 -1
- 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 +269 -142
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +122 -39
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +46 -17
- package/es/components/DataSpreadsheet/hooks/index.js +11 -0
- package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +139 -0
- package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +68 -0
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -6
- package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +20 -8
- package/es/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +18 -0
- package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +121 -0
- package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +108 -0
- package/es/components/DataSpreadsheet/utils/handleEditSubmit.js +87 -0
- package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +42 -8
- package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +225 -13
- package/es/components/DataSpreadsheet/utils/selectAllCells.js +53 -0
- 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/MultiAddSelect/MultiAddSelect.js +150 -3
- package/es/components/PageHeader/PageHeader.js +3 -1
- package/es/components/SingleAddSelect/SingleAddSelect.js +90 -4
- package/es/components/TagSet/TagSet.js +22 -6
- package/es/components/Tearsheet/TearsheetShell.js +34 -10
- package/es/components/UserProfileImage/UserProfileImage.js +37 -9
- package/es/components/index.js +2 -1
- package/es/global/js/package-settings.js +4 -2
- package/lib/components/ActionBar/ActionBar.js +3 -1
- package/lib/components/ActionBar/ActionBarOverflowItems.js +5 -3
- package/lib/components/AddSelect/AddSelect.js +97 -38
- package/lib/components/AddSelect/AddSelectFilter.js +147 -0
- package/lib/components/AddSelect/AddSelectList.js +28 -1
- 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 +279 -145
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +121 -45
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +47 -17
- package/lib/components/DataSpreadsheet/hooks/index.js +45 -0
- package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +151 -0
- package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +79 -0
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -5
- package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +21 -8
- package/lib/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +27 -0
- package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +127 -0
- package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +118 -0
- package/lib/components/DataSpreadsheet/utils/handleEditSubmit.js +94 -0
- package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +44 -8
- package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +235 -20
- package/lib/components/DataSpreadsheet/utils/selectAllCells.js +60 -0
- 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/MultiAddSelect/MultiAddSelect.js +150 -2
- package/lib/components/PageHeader/PageHeader.js +3 -1
- package/lib/components/SingleAddSelect/SingleAddSelect.js +91 -3
- package/lib/components/TagSet/TagSet.js +22 -6
- package/lib/components/Tearsheet/TearsheetShell.js +36 -10
- package/lib/components/UserProfileImage/UserProfileImage.js +37 -9
- package/lib/components/index.js +9 -1
- package/lib/global/js/package-settings.js +4 -2
- package/package.json +20 -16
- package/scss/components/AboutModal/_about-modal.scss +4 -0
- package/scss/components/AddSelect/_add-select.scss +51 -2
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +72 -9
- 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 +0 -4
- package/scss/components/HTTPErrors/_http-errors.scss +16 -16
- package/scss/components/PageHeader/_page-header.scss +4 -0
- package/scss/components/Tearsheet/_tearsheet.scss +4 -0
- package/scss/components/_index.scss +1 -0
@@ -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;
|
@@ -0,0 +1,140 @@
|
|
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 { DndProvider } from 'react-dnd';
|
14
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
15
|
+
import { Checkbox } from 'carbon-components-react';
|
16
|
+
import update from 'immutability-helper';
|
17
|
+
import { pkg } from '../../../../../settings';
|
18
|
+
import DraggableElement from '../../DraggableElement';
|
19
|
+
import { isColumnVisible } from './common';
|
20
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
21
|
+
|
22
|
+
var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
23
|
+
var newIndex = -1;
|
24
|
+
|
25
|
+
if (key === 'ArrowUp') {
|
26
|
+
newIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : array.length - 1;
|
27
|
+
}
|
28
|
+
|
29
|
+
if (key === 'ArrowDown') {
|
30
|
+
newIndex = currentIndex + 1 < array.length ? currentIndex + 1 : 0;
|
31
|
+
}
|
32
|
+
|
33
|
+
return newIndex;
|
34
|
+
};
|
35
|
+
|
36
|
+
var Columns = function Columns(_ref) {
|
37
|
+
var filterString = _ref.filterString,
|
38
|
+
columns = _ref.columns,
|
39
|
+
setColumnsObject = _ref.setColumnsObject,
|
40
|
+
onSelectColumn = _ref.onSelectColumn,
|
41
|
+
_ref$instructionsLabe = _ref.instructionsLabel,
|
42
|
+
instructionsLabel = _ref$instructionsLabe === void 0 ? 'Press space bar to toggle drag drop mode, use arrow keys to move selected elements.' : _ref$instructionsLabe,
|
43
|
+
_ref$disabledInstruct = _ref.disabledInstructionsLabel,
|
44
|
+
disabledInstructionsLabel = _ref$disabledInstruct === void 0 ? 'Reordering columns are disabled because they are filtered currently.' : _ref$disabledInstruct;
|
45
|
+
|
46
|
+
var _React$useState = React.useState(''),
|
47
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
48
|
+
ariaRegionText = _React$useState2[0],
|
49
|
+
setAriaRegionText = _React$useState2[1];
|
50
|
+
|
51
|
+
var _React$useState3 = React.useState(-1),
|
52
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
53
|
+
focusIndex = _React$useState4[0],
|
54
|
+
setFocusIndex = _React$useState4[1];
|
55
|
+
|
56
|
+
var moveElement = React.useCallback(function (dragIndex, hoverIndex) {
|
57
|
+
var dragCard = columns[dragIndex];
|
58
|
+
setColumnsObject(update(columns, {
|
59
|
+
$splice: [[dragIndex, 1], [hoverIndex, 0, dragCard]]
|
60
|
+
}));
|
61
|
+
}, [columns, setColumnsObject]);
|
62
|
+
return /*#__PURE__*/React.createElement("div", {
|
63
|
+
className: "".concat(blockClass, "__customize-columns-column-list")
|
64
|
+
}, /*#__PURE__*/React.createElement(DndProvider, {
|
65
|
+
backend: HTML5Backend
|
66
|
+
}, /*#__PURE__*/React.createElement("ol", {
|
67
|
+
className: "".concat(blockClass, "__customize-columns-column-list--focus"),
|
68
|
+
role: "listbox",
|
69
|
+
"aria-describedby": "".concat(blockClass, "__customize-columns--instructions"),
|
70
|
+
onKeyDown: function onKeyDown(e) {
|
71
|
+
var nextIndex = getNextIndex(columns, focusIndex, e.key);
|
72
|
+
|
73
|
+
if (nextIndex >= 0) {
|
74
|
+
setFocusIndex(nextIndex);
|
75
|
+
e.preventDefault();
|
76
|
+
e.stopPropagation();
|
77
|
+
}
|
78
|
+
},
|
79
|
+
tabIndex: 0,
|
80
|
+
onFocus: function onFocus(e) {
|
81
|
+
if (e.target === e.currentTarget) {
|
82
|
+
setFocusIndex(0);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}, /*#__PURE__*/React.createElement("span", {
|
86
|
+
"aria-live": "assertive",
|
87
|
+
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
88
|
+
}, ariaRegionText), /*#__PURE__*/React.createElement("span", {
|
89
|
+
id: "".concat(blockClass, "__customize-columns--instructions"),
|
90
|
+
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
91
|
+
}, filterString.length === 0 ? instructionsLabel : disabledInstructionsLabel), columns.filter(function (colDef) {
|
92
|
+
return filterString.length === 0 || colDef.Header.props.title.toLowerCase().includes(filterString);
|
93
|
+
}).map(function (colDef, i) {
|
94
|
+
return /*#__PURE__*/React.createElement(DraggableElement, {
|
95
|
+
key: colDef.id,
|
96
|
+
index: i,
|
97
|
+
listData: columns,
|
98
|
+
setListData: setColumnsObject,
|
99
|
+
id: "dnd-datagrid-columns-".concat(colDef.id),
|
100
|
+
type: "column-customization",
|
101
|
+
disabled: filterString.length > 0,
|
102
|
+
ariaLabel: colDef.Header.props.title,
|
103
|
+
onGrab: setAriaRegionText,
|
104
|
+
isFocused: focusIndex === i,
|
105
|
+
moveElement: moveElement,
|
106
|
+
onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
|
107
|
+
if (isGrabbed) {
|
108
|
+
var nextIndex = getNextIndex(columns, currentIndex, e.key);
|
109
|
+
e.preventDefault();
|
110
|
+
e.stopPropagation();
|
111
|
+
|
112
|
+
if (nextIndex >= 0) {
|
113
|
+
setFocusIndex(nextIndex);
|
114
|
+
moveElement(currentIndex, nextIndex);
|
115
|
+
e.target.scrollIntoView({
|
116
|
+
block: 'center'
|
117
|
+
});
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}, /*#__PURE__*/React.createElement(Checkbox, {
|
122
|
+
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox"),
|
123
|
+
checked: isColumnVisible(colDef),
|
124
|
+
onChange: onSelectColumn.bind(null, colDef),
|
125
|
+
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
126
|
+
labelText: colDef.Header.props.title,
|
127
|
+
title: colDef.Header.props.title
|
128
|
+
}));
|
129
|
+
}))));
|
130
|
+
};
|
131
|
+
|
132
|
+
Columns.propTypes = {
|
133
|
+
columns: PropTypes.array.isRequired,
|
134
|
+
disabledInstructionsLabel: PropTypes.string,
|
135
|
+
filterString: PropTypes.string.isRequired,
|
136
|
+
instructionsLabel: PropTypes.string,
|
137
|
+
onSelectColumn: PropTypes.func.isRequired,
|
138
|
+
setColumnsObject: PropTypes.func.isRequired
|
139
|
+
};
|
140
|
+
export default Columns;
|
@@ -0,0 +1,157 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
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. 2021
|
12
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
13
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
14
|
+
*/
|
15
|
+
// @flow
|
16
|
+
import React, { useState } from 'react';
|
17
|
+
import PropTypes from 'prop-types';
|
18
|
+
import { Modal } from 'carbon-components-react';
|
19
|
+
import { isColumnVisible } from './common';
|
20
|
+
import Columns from './Columns';
|
21
|
+
import Actions from './Actions';
|
22
|
+
import { pkg } from '../../../../../settings';
|
23
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
24
|
+
|
25
|
+
var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
26
|
+
var isOpen = _ref.isOpen,
|
27
|
+
setIsModalOpen = _ref.setIsModalOpen,
|
28
|
+
onSaveColumnPrefs = _ref.onSaveColumnPrefs,
|
29
|
+
columnDefinitions = _ref.columnDefinitions,
|
30
|
+
originalColumnDefinitions = _ref.originalColumnDefinitions,
|
31
|
+
_ref$customizeModalHe = _ref.customizeModalHeadingLabel,
|
32
|
+
customizeModalHeadingLabel = _ref$customizeModalHe === void 0 ? 'Customize display' : _ref$customizeModalHe,
|
33
|
+
_ref$primaryButtonTex = _ref.primaryButtonTextLabel,
|
34
|
+
primaryButtonTextLabel = _ref$primaryButtonTex === void 0 ? 'Save' : _ref$primaryButtonTex,
|
35
|
+
_ref$secondaryButtonT = _ref.secondaryButtonTextLabel,
|
36
|
+
secondaryButtonTextLabel = _ref$secondaryButtonT === void 0 ? 'Cancel' : _ref$secondaryButtonT,
|
37
|
+
_ref$instructionsLabe = _ref.instructionsLabel,
|
38
|
+
instructionsLabel = _ref$instructionsLabe === void 0 ? 'Deselect columns to hide them. Click and drag the white box to reorder the columns. These specifications will be saved and persist if you leave and return to the data table.' : _ref$instructionsLabe;
|
39
|
+
|
40
|
+
var _useState = useState(''),
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
42
|
+
searchText = _useState2[0],
|
43
|
+
setSearchText = _useState2[1];
|
44
|
+
|
45
|
+
var _useState3 = useState(columnDefinitions // hide the columns without Header, e.g the sticky actions, spacer
|
46
|
+
.filter(function (colDef) {
|
47
|
+
return !!colDef.Header.props;
|
48
|
+
}) // only sort the hidden column to the end when modal reopen
|
49
|
+
.sort(function (defA, defB) {
|
50
|
+
var isVisibleA = isColumnVisible(defA);
|
51
|
+
var isVisibleB = isColumnVisible(defB);
|
52
|
+
|
53
|
+
if (isVisibleA && !isVisibleB) {
|
54
|
+
return -1;
|
55
|
+
}
|
56
|
+
|
57
|
+
if (!isVisibleA && isVisibleB) {
|
58
|
+
return 1;
|
59
|
+
}
|
60
|
+
|
61
|
+
return 0;
|
62
|
+
})),
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
64
|
+
columnObjects = _useState4[0],
|
65
|
+
_setColumnsObject = _useState4[1];
|
66
|
+
|
67
|
+
var _useState5 = useState(false),
|
68
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
69
|
+
isDirty = _useState6[0],
|
70
|
+
setIsDirty = _useState6[1];
|
71
|
+
|
72
|
+
var onRequestClose = function onRequestClose() {
|
73
|
+
setIsModalOpen(false);
|
74
|
+
};
|
75
|
+
|
76
|
+
var onRequestSubmit = function onRequestSubmit() {
|
77
|
+
setIsModalOpen(false);
|
78
|
+
var updatedColumns = columnObjects.map(function (colDef) {
|
79
|
+
return {
|
80
|
+
id: colDef.id,
|
81
|
+
isVisible: colDef.isVisible
|
82
|
+
};
|
83
|
+
});
|
84
|
+
onSaveColumnPrefs(updatedColumns);
|
85
|
+
};
|
86
|
+
|
87
|
+
var onCheckboxCheck = function onCheckboxCheck(col, value) {
|
88
|
+
var changedDefinitions = columnObjects.map(function (definition) {
|
89
|
+
if (definition.id === col.id) {
|
90
|
+
return _objectSpread(_objectSpread({}, definition), {}, {
|
91
|
+
isVisible: value
|
92
|
+
});
|
93
|
+
}
|
94
|
+
|
95
|
+
return definition;
|
96
|
+
});
|
97
|
+
|
98
|
+
_setColumnsObject(changedDefinitions);
|
99
|
+
|
100
|
+
setDirty();
|
101
|
+
};
|
102
|
+
|
103
|
+
var setDirty = function setDirty() {
|
104
|
+
if (!isDirty) {
|
105
|
+
setIsDirty(true);
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
109
|
+
var string = searchText.trim().toLowerCase();
|
110
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
111
|
+
className: "".concat(blockClass, "__customize-columns-modal"),
|
112
|
+
open: isOpen,
|
113
|
+
modalHeading: customizeModalHeadingLabel,
|
114
|
+
primaryButtonText: primaryButtonTextLabel,
|
115
|
+
secondaryButtonText: secondaryButtonTextLabel,
|
116
|
+
selectorPrimaryFocus: ".".concat(blockClass, "__customize-columns-column-list--focus"),
|
117
|
+
primaryButtonDisabled: !isDirty,
|
118
|
+
onRequestClose: onRequestClose,
|
119
|
+
onRequestSubmit: onRequestSubmit,
|
120
|
+
size: "sm",
|
121
|
+
hasForm: true
|
122
|
+
}, /*#__PURE__*/React.createElement("div", {
|
123
|
+
className: "".concat(blockClass, "__customize-columns-instructions")
|
124
|
+
}, instructionsLabel), /*#__PURE__*/React.createElement(Actions, {
|
125
|
+
columns: columnObjects,
|
126
|
+
originalColumnDefinitions: originalColumnDefinitions,
|
127
|
+
searchText: searchText,
|
128
|
+
setColumnsObject: function setColumnsObject(cols) {
|
129
|
+
_setColumnsObject(cols);
|
130
|
+
|
131
|
+
setDirty();
|
132
|
+
},
|
133
|
+
setSearchText: setSearchText
|
134
|
+
}), isOpen && /*#__PURE__*/React.createElement(Columns, {
|
135
|
+
columns: columnObjects,
|
136
|
+
filterString: string,
|
137
|
+
onSelectColumn: onCheckboxCheck,
|
138
|
+
setColumnsObject: function setColumnsObject(cols) {
|
139
|
+
_setColumnsObject(cols);
|
140
|
+
|
141
|
+
setDirty();
|
142
|
+
}
|
143
|
+
}));
|
144
|
+
};
|
145
|
+
|
146
|
+
CustomizeColumnsModal.propTypes = {
|
147
|
+
columnDefinitions: PropTypes.array.isRequired,
|
148
|
+
customizeModalHeadingLabel: PropTypes.string,
|
149
|
+
instructionsLabel: PropTypes.string,
|
150
|
+
isOpen: PropTypes.bool.isRequired,
|
151
|
+
onSaveColumnPrefs: PropTypes.func.isRequired,
|
152
|
+
originalColumnDefinitions: PropTypes.array.isRequired,
|
153
|
+
primaryButtonTextLabel: PropTypes.string,
|
154
|
+
secondaryButtonTextLabel: PropTypes.string,
|
155
|
+
setIsModalOpen: PropTypes.func.isRequired
|
156
|
+
};
|
157
|
+
export default CustomizeColumnsModal;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
var _excluded = ["onSaveColumnPrefs", "isModalOpen", "setIsModalOpen"];
|
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 CustomizeColumnsModal from './CustomizeColumnsModal';
|
16
|
+
|
17
|
+
var ModalWrapper = function ModalWrapper(_ref) {
|
18
|
+
var instance = _ref.instance;
|
19
|
+
|
20
|
+
var _instance$customizeCo = instance.customizeColumnsProps,
|
21
|
+
_onSaveColumnPrefs = _instance$customizeCo.onSaveColumnPrefs,
|
22
|
+
isModalOpen = _instance$customizeCo.isModalOpen,
|
23
|
+
setIsModalOpen = _instance$customizeCo.setIsModalOpen,
|
24
|
+
rest = _objectWithoutProperties(_instance$customizeCo, _excluded);
|
25
|
+
|
26
|
+
if (isModalOpen) {
|
27
|
+
return /*#__PURE__*/React.createElement(CustomizeColumnsModal, _extends({}, rest, {
|
28
|
+
isOpen: isModalOpen,
|
29
|
+
setIsModalOpen: setIsModalOpen,
|
30
|
+
columnDefinitions: instance.allColumns,
|
31
|
+
originalColumnDefinitions: instance.columns,
|
32
|
+
onSaveColumnPrefs: function onSaveColumnPrefs(updatedColDefs) {
|
33
|
+
var hiddenIds = updatedColDefs.filter(function (colDef) {
|
34
|
+
return !colDef.isVisible;
|
35
|
+
}).map(function (colDef) {
|
36
|
+
return colDef.id;
|
37
|
+
});
|
38
|
+
instance.setHiddenColumns(hiddenIds);
|
39
|
+
|
40
|
+
if (typeof instance.setColumnOrder === 'function') {
|
41
|
+
instance.setColumnOrder(updatedColDefs.map(function (colDef) {
|
42
|
+
return colDef.id;
|
43
|
+
}));
|
44
|
+
} else {
|
45
|
+
// eslint-disable-next-line no-console
|
46
|
+
console.warn("Column order can not be updated. Did you forget to add 'useColumnOrder' in 'useDatagrid'");
|
47
|
+
}
|
48
|
+
|
49
|
+
if (typeof _onSaveColumnPrefs === 'function') {
|
50
|
+
_onSaveColumnPrefs(updatedColDefs);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}));
|
54
|
+
}
|
55
|
+
|
56
|
+
return null;
|
57
|
+
};
|
58
|
+
|
59
|
+
ModalWrapper.propTypes = {
|
60
|
+
instance: PropTypes.object.isRequired
|
61
|
+
};
|
62
|
+
export default ModalWrapper;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// @flow
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Licensed Materials - Property of IBM
|
5
|
+
* 5724-Q36
|
6
|
+
* (c) Copyright IBM Corp. 2021
|
7
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
8
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
9
|
+
*/
|
10
|
+
import isBoolean from 'lodash/isBoolean';
|
11
|
+
export var isColumnVisible = function isColumnVisible(colDef) {
|
12
|
+
return isBoolean(colDef.isVisible) ? colDef.isVisible : true;
|
13
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed Materials - Property of IBM
|
3
|
+
* 5724-Q36
|
4
|
+
* (c) Copyright IBM Corp. 2021
|
5
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
6
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
7
|
+
*/
|
8
|
+
export { default as CustomizeColumnsModalWrapper } from './ModalWrapper';
|
9
|
+
export { default as ToggleButtonWrapper } from './ButtonWrapper';
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
|
+
var _excluded = ["buttonLabel"];
|
6
|
+
// @flow
|
7
|
+
|
8
|
+
/*
|
9
|
+
* Licensed Materials - Property of IBM
|
10
|
+
* 5724-Q36
|
11
|
+
* (c) Copyright IBM Corp. 2021
|
12
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
13
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
14
|
+
*/
|
15
|
+
import * as React from 'react';
|
16
|
+
import PropTypes from 'prop-types';
|
17
|
+
import { Settings16 } from '@carbon/icons-react';
|
18
|
+
import { Button } from 'carbon-components-react';
|
19
|
+
import cx from 'classnames';
|
20
|
+
import RowSizeRadioGroup from './RowSizeRadioGroup';
|
21
|
+
import { pkg } from '../../../../../settings';
|
22
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
23
|
+
|
24
|
+
var RowSizeDropdown = function RowSizeDropdown(_ref) {
|
25
|
+
var _ref$buttonLabel = _ref.buttonLabel,
|
26
|
+
buttonLabel = _ref$buttonLabel === void 0 ? 'Row height' : _ref$buttonLabel,
|
27
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
28
|
+
|
29
|
+
var buttonRef = React.useRef({});
|
30
|
+
|
31
|
+
var _React$useState = React.useState(false),
|
32
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
33
|
+
isOpen = _React$useState2[0],
|
34
|
+
setIsOpen = _React$useState2[1];
|
35
|
+
|
36
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
37
|
+
hasIconOnly: true,
|
38
|
+
ref: buttonRef,
|
39
|
+
kind: "ghost",
|
40
|
+
tooltipPosition: "left",
|
41
|
+
renderIcon: Settings16,
|
42
|
+
onClick: function onClick() {
|
43
|
+
return setIsOpen(!isOpen);
|
44
|
+
},
|
45
|
+
iconDescription: buttonLabel,
|
46
|
+
className: cx(_defineProperty({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
|
47
|
+
}), isOpen && /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({}, props, {
|
48
|
+
buttonRef: buttonRef,
|
49
|
+
hideRadioGroup: function hideRadioGroup() {
|
50
|
+
setIsOpen(false);
|
51
|
+
}
|
52
|
+
})));
|
53
|
+
};
|
54
|
+
|
55
|
+
RowSizeDropdown.propTypes = {
|
56
|
+
buttonLabel: PropTypes.string,
|
57
|
+
datagridName: PropTypes.string.isRequired,
|
58
|
+
light: PropTypes.bool.isRequired,
|
59
|
+
onChange: PropTypes.func.isRequired,
|
60
|
+
selectedOption: PropTypes.string.isRequired
|
61
|
+
};
|
62
|
+
export default RowSizeDropdown;
|
@@ -0,0 +1,139 @@
|
|
1
|
+
/* eslint-disable react/default-props-match-prop-types */
|
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 React, { useEffect } from 'react';
|
12
|
+
import PropTypes from 'prop-types';
|
13
|
+
import { RadioButtonGroup, RadioButton } from 'carbon-components-react';
|
14
|
+
import isArray from 'lodash/isArray';
|
15
|
+
import { pkg } from '../../../../../settings';
|
16
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
17
|
+
|
18
|
+
var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
|
19
|
+
var rowSizes = _ref.rowSizes,
|
20
|
+
selectedOption = _ref.selectedOption,
|
21
|
+
datagridName = _ref.datagridName,
|
22
|
+
buttonRef = _ref.buttonRef,
|
23
|
+
onChange = _ref.onChange,
|
24
|
+
hideRadioGroup = _ref.hideRadioGroup,
|
25
|
+
_ref$legendText = _ref.legendText,
|
26
|
+
legendText = _ref$legendText === void 0 ? 'Row height' : _ref$legendText,
|
27
|
+
_ref$rowSizeLabels = _ref.rowSizeLabels,
|
28
|
+
rowSizeLabels = _ref$rowSizeLabels === void 0 ? {
|
29
|
+
xl: 'Extra large',
|
30
|
+
lg: 'Large (default)',
|
31
|
+
md: 'Medium',
|
32
|
+
sm: 'Small',
|
33
|
+
xs: 'Extra small'
|
34
|
+
} : _ref$rowSizeLabels;
|
35
|
+
|
36
|
+
var _getDropdownPosition = getDropdownPosition(buttonRef.current),
|
37
|
+
top = _getDropdownPosition.top,
|
38
|
+
right = _getDropdownPosition.right;
|
39
|
+
|
40
|
+
useEffect(function () {
|
41
|
+
window.addEventListener('click', hideRadioGroup);
|
42
|
+
return function () {
|
43
|
+
window.removeEventListener('click', hideRadioGroup);
|
44
|
+
};
|
45
|
+
}, [hideRadioGroup]);
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
47
|
+
className: "".concat(blockClass, "__row-size-dropdown"),
|
48
|
+
style: {
|
49
|
+
top: top,
|
50
|
+
right: right
|
51
|
+
},
|
52
|
+
role: "presentation",
|
53
|
+
onClick: function onClick(e) {
|
54
|
+
e.stopPropagation();
|
55
|
+
}
|
56
|
+
}, /*#__PURE__*/React.createElement(RadioButtonGroup, {
|
57
|
+
legendText: legendText,
|
58
|
+
name: "row-height-group",
|
59
|
+
orientation: "vertical",
|
60
|
+
defaultSelected: getBackwardCompatibleRowSize(selectedOption),
|
61
|
+
onChange: onChange
|
62
|
+
}, rowSizes && isArray(rowSizes) && rowSizes.map(function (option) {
|
63
|
+
var labelText;
|
64
|
+
|
65
|
+
try {
|
66
|
+
labelText = option.labelText || rowSizeLabels[option.value];
|
67
|
+
} catch (e) {
|
68
|
+
labelText = option.value;
|
69
|
+
}
|
70
|
+
|
71
|
+
return /*#__PURE__*/React.createElement(RadioButton, {
|
72
|
+
key: option.value,
|
73
|
+
labelText: labelText,
|
74
|
+
value: option.value,
|
75
|
+
id: "".concat(datagridName || 'datagrid', "--row-density--").concat(option.value)
|
76
|
+
});
|
77
|
+
})));
|
78
|
+
};
|
79
|
+
|
80
|
+
var getBackwardCompatibleRowSize = function getBackwardCompatibleRowSize(rowSize) {
|
81
|
+
// TODO: deprecate this function in next major release (v8) on carbon-components-react
|
82
|
+
var rowSizeMap = {
|
83
|
+
tall: 'xl',
|
84
|
+
normal: 'lg',
|
85
|
+
short: 'sm',
|
86
|
+
compact: 'xs' // md is a new value
|
87
|
+
|
88
|
+
};
|
89
|
+
return rowSizeMap[rowSize] || rowSize;
|
90
|
+
};
|
91
|
+
|
92
|
+
var getDropdownPosition = function getDropdownPosition(buttonEle) {
|
93
|
+
var parent = buttonEle.parentElement;
|
94
|
+
|
95
|
+
if (parent instanceof HTMLElement) {
|
96
|
+
var top = buttonEle.offsetTop + buttonEle.offsetHeight;
|
97
|
+
var right = parent.offsetWidth - parent.offsetLeft - (buttonEle.offsetLeft + buttonEle.offsetWidth);
|
98
|
+
return {
|
99
|
+
top: top,
|
100
|
+
right: right
|
101
|
+
};
|
102
|
+
}
|
103
|
+
|
104
|
+
return {
|
105
|
+
top: 0,
|
106
|
+
right: 0
|
107
|
+
};
|
108
|
+
};
|
109
|
+
|
110
|
+
RowSizeRadioGroup.defaultProps = {
|
111
|
+
rowSizes: [{
|
112
|
+
value: 'xl' // 64
|
113
|
+
|
114
|
+
}, {
|
115
|
+
value: 'lg' // 48
|
116
|
+
|
117
|
+
}, {
|
118
|
+
value: 'md' // 40
|
119
|
+
|
120
|
+
}, {
|
121
|
+
value: 'sm' // 32
|
122
|
+
|
123
|
+
}, {
|
124
|
+
value: 'xs' // 24
|
125
|
+
|
126
|
+
}],
|
127
|
+
selectedOption: 'lg'
|
128
|
+
};
|
129
|
+
RowSizeRadioGroup.propTypes = {
|
130
|
+
buttonRef: PropTypes.any.isRequired,
|
131
|
+
datagridName: PropTypes.string.isRequired,
|
132
|
+
hideRadioGroup: PropTypes.func.isRequired,
|
133
|
+
legendText: PropTypes.string,
|
134
|
+
onChange: PropTypes.func.isRequired,
|
135
|
+
rowSizeLabels: PropTypes.object,
|
136
|
+
rowSizes: PropTypes.array.isRequired,
|
137
|
+
selectedOption: PropTypes.string.isRequired
|
138
|
+
};
|
139
|
+
export default RowSizeRadioGroup;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/*
|
2
|
+
* Licensed Materials - Property of IBM
|
3
|
+
* 5724-Q36
|
4
|
+
* (c) Copyright IBM Corp. 2021
|
5
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
6
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
7
|
+
*/
|
8
|
+
export { default as RowSizeDropdown } from './RowSizeDropdown';
|
@@ -0,0 +1,8 @@
|
|
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
|
+
export { default } from './Datagrid';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
var notes = "\n # Customizing columns\n Customizing columns allows user to reorder and hide certain columns of the datagrid. Consuming component can use the provided callback to save/update according to their persistent strategy.\n\n ## Documentation:\n\n - (required) Add following plugins to `useDatagrid` hook\n - `useCustomizeColumns`\n - `useColumnOrder`\n - (required) Implement `options.DatagridActions` component\n - this component will have props: `datagridState`\n - render `datagridState.CustomizeColumnsButton` component wherever makes sense.\n - `CustomizeColumnsButton` props can be overridden. Available props: [carbon-components-react doc](https://react.carbondesignsystem.com/?path=/docs/components-button--default)\n - (optional) Preserve and apply the user preference\n - `options.initialState.hiddenColumns: Array<ColumnId: String>`\n - Array of column ids that will be hidden after initial render\n - [react-table doc](https://react-table.tanstack.com/docs/api/useTable#table-options)\n - `options.initialState.columnOrder: Array<ColumnId: String>`\n - Order of the columns. Any column ids not in this array will be ordered by their position in the `options.columns`\n - [react-table doc](https://react-table.tanstack.com/docs/api/useColumnOrder#table-options)\n - `options.customizeColumnsProps.onSaveColumnPrefs`\n - type: `Function(Columns: Array<{ColumnId: String, isVisible: Boolean}>) => void`\n - It's a callback function when 'Save' button clicked on the modal. It allows consumer to preserve the updated column preference. This output can also be used to compute the `hiddenColumns` and `columnOrder`\n - (optional) Reset to default\n - There is a reset to default button on the modal. It will use the `options.columns` as the default. If there are columns should be hidden by default, denote them with property: `isVisible: false` (undefined will be treated as `true`)\n\n code snippet:\n\n ```js\n const columns = React.useMemo(() => defaultHeader, []);\n const [data] = useState(makeData(10));\n const DatagridActions = (datagridState) => (\n <TableToolbarContent>\n <TableToolbarSearch ... />\n <Button ... />\n <datagridState.CustomizeColumnsButton />\n </TableToolbarContent>\n )\n const datagridState = useDatagrid(\n {\n columns,\n data,\n initialState: {\n hiddenColumns: ['age'],\n columnOrder: [],\n },\n customizeColumnsProps: {\n onSaveColumnPrefs: (newColDefs) => {\n console.log(newColDefs);\n },\n },\n DatagridActions,\n },\n useCustomizeColumns,\n useColumnOrder,\n );\n\n return (\n <Wrapper>\n <IntlProvider locale=\"en\">\n <Datagrid {...datagridState} />\n <div>\n Hidden column ids: \n <pre>{JSON.stringify(datagridState.state.hiddenColumns, null, 2)}</pre>\n </div>\n </IntlProvider>\n </Wrapper>\n );\n ```\n";
|
2
|
+
export var story = {
|
3
|
+
parameters: {
|
4
|
+
notes: notes
|
5
|
+
}
|
6
|
+
};
|
@@ -0,0 +1,6 @@
|
|
1
|
+
var notes = "\n# Access left side panel in data grid\nAllow users to access left panel in datagrid.\n\n## Documentation:\n\n- (required) Implement `options.leftPanel` which has the following props\n - `options.leftPanel.isOpen` value is toggled by the Button onClick from DatagridActions\n - render `options.leftPanel.panelContent` inside the panel container of data grid when isOpen is true\n\ncode snippet:\n\n```js\nconst columns = React.useMemo(() => defaultHeader, []);\n const [data] = useState(makeData(10));\n const [isPanelOpen, setIsPanelOpen] = useState(false);\n const DatagridActions = (datagridState) => (\n <TableToolbarContent>\n <Button onClick={() => { setIsPanelOpen(!isPanelOpen); }}>Click to toggle left panel</Button>\n <TableToolbarSearch ... />\n <Button ... />\n <datagridState.CustomizeColumnsButton />\n </TableToolbarContent>\n )\n const datagridState = useDatagrid(\n {\n columns,\n data,\n leftPanel: {\n isOpen: isPanelOpen,\n panelContent: <div>Panel content will go here along with any button interactions</div>,\n },\n initialState: {\n hiddenColumns: ['age'],\n columnOrder: [],\n },\n customizeColumnsProps: {\n onSaveColumnPrefs: (newColDefs) => {\n console.log(newColDefs);\n },\n },\n DatagridActions,\n },\n );\n\nreturn (\n <Wrapper>\n <IntlProvider locale=\"en\">\n <Datagrid {...datagridState} />\n </IntlProvider>\n </Wrapper>\n);\n```\n";
|
2
|
+
export var story = {
|
3
|
+
parameters: {
|
4
|
+
notes: notes
|
5
|
+
}
|
6
|
+
};
|