@carbon/ibm-products 1.11.2 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,123 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.useMultipleKeyTracking = void 0;
|
9
|
+
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
11
|
+
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
|
+
|
14
|
+
var _react = require("react");
|
15
|
+
|
16
|
+
var _hooks = require("../../../global/js/hooks");
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Copyright IBM Corp. 2022, 2022
|
20
|
+
*
|
21
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
23
|
+
*/
|
24
|
+
var hasFocus = function hasFocus() {
|
25
|
+
return typeof document !== 'undefined' && document.hasFocus();
|
26
|
+
};
|
27
|
+
|
28
|
+
var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
|
29
|
+
var ref = _ref.ref,
|
30
|
+
containerHasFocus = _ref.containerHasFocus,
|
31
|
+
isEditing = _ref.isEditing;
|
32
|
+
|
33
|
+
var _useState = (0, _react.useState)(hasFocus),
|
34
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
35
|
+
windowFocused = _useState2[0],
|
36
|
+
setWindowFocused = _useState2[1];
|
37
|
+
|
38
|
+
var _useState3 = (0, _react.useState)([]),
|
39
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
40
|
+
keysPressedList = _useState4[0],
|
41
|
+
setKeysPressedList = _useState4[1];
|
42
|
+
|
43
|
+
var previousState = (0, _hooks.usePreviousValue)({
|
44
|
+
isEditing: isEditing,
|
45
|
+
windowFocused: windowFocused
|
46
|
+
}); // useEffect to check for window focus, if window loses focus
|
47
|
+
// we need to clear out the keysPressedList
|
48
|
+
|
49
|
+
(0, _react.useEffect)(function () {
|
50
|
+
setWindowFocused(hasFocus());
|
51
|
+
|
52
|
+
var onWindowFocus = function onWindowFocus() {
|
53
|
+
return setWindowFocused(true);
|
54
|
+
};
|
55
|
+
|
56
|
+
var onWindowBlur = function onWindowBlur() {
|
57
|
+
return setWindowFocused(false);
|
58
|
+
};
|
59
|
+
|
60
|
+
window.addEventListener('focus', onWindowFocus);
|
61
|
+
window.addEventListener('blur', onWindowBlur);
|
62
|
+
return function () {
|
63
|
+
window.removeEventListener('focus', onWindowFocus);
|
64
|
+
window.removeEventListener('blur', onWindowBlur);
|
65
|
+
};
|
66
|
+
}, []);
|
67
|
+
(0, _react.useEffect)(function () {
|
68
|
+
if (containerHasFocus && !isEditing) {
|
69
|
+
ref.current.onkeydown = ref.current.onkeyup = function (event) {
|
70
|
+
// If keydown, we will add the new key to the keysPressedList array
|
71
|
+
if (event.type === 'keydown') {
|
72
|
+
// Prevent multiple keys of the same type being added to our keysPressedList array
|
73
|
+
if (keysPressedList.includes(event.code)) {
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
|
77
|
+
var tempKeys = (0, _toConsumableArray2.default)(keysPressedList);
|
78
|
+
tempKeys.push(event.code);
|
79
|
+
setKeysPressedList((0, _toConsumableArray2.default)(new Set(tempKeys)));
|
80
|
+
} // If keyup, we will remove the key from the keysPressedList array
|
81
|
+
|
82
|
+
|
83
|
+
if (event.type === 'keyup') {
|
84
|
+
var _tempKeys = (0, _toConsumableArray2.default)(keysPressedList);
|
85
|
+
|
86
|
+
var filteredClone = _tempKeys.filter(function (item) {
|
87
|
+
return item !== event.code;
|
88
|
+
}); // Keyup events are lost on all other keys if a Meta key is used
|
89
|
+
// so to work around this behavior, we empty out all other keys
|
90
|
+
// from the keysPressedList array if we detect a Meta keyup event
|
91
|
+
|
92
|
+
|
93
|
+
if (event.code === 'MetaLeft' || event.code === 'MetaRight') {
|
94
|
+
return setKeysPressedList([]);
|
95
|
+
}
|
96
|
+
|
97
|
+
setKeysPressedList((0, _toConsumableArray2.default)(new Set(filteredClone)));
|
98
|
+
}
|
99
|
+
};
|
100
|
+
}
|
101
|
+
|
102
|
+
if (previousState !== null && previousState !== void 0 && previousState.windowFocused && !windowFocused) {
|
103
|
+
setKeysPressedList([]);
|
104
|
+
} // Remove handlers if the spreadsheet container loses focus
|
105
|
+
// or is currently in edit mode
|
106
|
+
|
107
|
+
|
108
|
+
if (!containerHasFocus || isEditing) {
|
109
|
+
ref.current.onkeydown = undefined;
|
110
|
+
ref.current.onkeyup = undefined;
|
111
|
+
|
112
|
+
if (!(previousState !== null && previousState !== void 0 && previousState.isEditing) && isEditing) {
|
113
|
+
setKeysPressedList([]);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}, [keysPressedList, containerHasFocus, ref, isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing, windowFocused, previousState === null || previousState === void 0 ? void 0 : previousState.windowFocused]);
|
117
|
+
return {
|
118
|
+
keysPressedList: keysPressedList,
|
119
|
+
windowFocused: windowFocused
|
120
|
+
};
|
121
|
+
};
|
122
|
+
|
123
|
+
exports.useMultipleKeyTracking = useMultipleKeyTracking;
|
@@ -16,8 +16,7 @@ var _settings = require("../../../settings");
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
17
17
|
*/
|
18
18
|
var useResetSpreadsheetFocus = function useResetSpreadsheetFocus(_ref) {
|
19
|
-
var
|
20
|
-
_ref$blockClass = _ref.blockClass,
|
19
|
+
var _ref$blockClass = _ref.blockClass,
|
21
20
|
blockClass = _ref$blockClass === void 0 ? "".concat(_settings.pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
|
22
21
|
focusedElement = _ref.focusedElement,
|
23
22
|
removeActiveCell = _ref.removeActiveCell,
|
@@ -27,13 +26,12 @@ var useResetSpreadsheetFocus = function useResetSpreadsheetFocus(_ref) {
|
|
27
26
|
if (!focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
|
28
27
|
setContainerHasFocus(false);
|
29
28
|
removeActiveCell();
|
30
|
-
activeKeys.current = [];
|
31
29
|
}
|
32
30
|
|
33
31
|
if (focusedElement.classList.contains(blockClass) || focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
|
34
32
|
setContainerHasFocus(true);
|
35
33
|
}
|
36
|
-
}, [focusedElement, removeActiveCell,
|
34
|
+
}, [focusedElement, removeActiveCell, blockClass, setContainerHasFocus]);
|
37
35
|
};
|
38
36
|
|
39
37
|
exports.useResetSpreadsheetFocus = useResetSpreadsheetFocus;
|
@@ -9,6 +9,8 @@ var _react = require("react");
|
|
9
9
|
|
10
10
|
var _settings = require("../../../settings");
|
11
11
|
|
12
|
+
var _removeCellSelections = require("../utils/removeCellSelections");
|
13
|
+
|
12
14
|
/**
|
13
15
|
* Copyright IBM Corp. 2022, 2022
|
14
16
|
*
|
@@ -23,9 +25,7 @@ var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref) {
|
|
23
25
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
24
26
|
setSelectionAreas = _ref.setSelectionAreas,
|
25
27
|
removeActiveCell = _ref.removeActiveCell,
|
26
|
-
removeCellSelections = _ref.removeCellSelections,
|
27
28
|
setContainerHasFocus = _ref.setContainerHasFocus,
|
28
|
-
activeKeys = _ref.activeKeys,
|
29
29
|
removeCellEditor = _ref.removeCellEditor;
|
30
30
|
(0, _react.useEffect)(function () {
|
31
31
|
var handleOutsideClick = function handleOutsideClick(event) {
|
@@ -36,17 +36,18 @@ var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref) {
|
|
36
36
|
setActiveCellCoordinates(null);
|
37
37
|
setSelectionAreas([]);
|
38
38
|
removeActiveCell();
|
39
|
-
removeCellSelections(
|
39
|
+
(0, _removeCellSelections.removeCellSelections)({
|
40
|
+
spreadsheetRef: spreadsheetRef
|
41
|
+
});
|
40
42
|
setContainerHasFocus(false);
|
41
43
|
removeCellEditor();
|
42
|
-
activeKeys.current = [];
|
43
44
|
};
|
44
45
|
|
45
46
|
document.addEventListener('click', handleOutsideClick);
|
46
47
|
return function () {
|
47
48
|
document.removeEventListener('click', handleOutsideClick);
|
48
49
|
};
|
49
|
-
}, [spreadsheetRef, removeActiveCell,
|
50
|
+
}, [spreadsheetRef, removeActiveCell, blockClass, setActiveCellCoordinates, setContainerHasFocus, setSelectionAreas, removeCellEditor]);
|
50
51
|
};
|
51
52
|
|
52
53
|
exports.useSpreadsheetOutsideClick = useSpreadsheetOutsideClick;
|
@@ -27,7 +27,9 @@ var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
|
|
27
27
|
setSelectionAreas = _ref.setSelectionAreas,
|
28
28
|
spreadsheetRef = _ref.spreadsheetRef,
|
29
29
|
index = _ref.index,
|
30
|
-
isKeyboard = _ref.isKeyboard
|
30
|
+
isKeyboard = _ref.isKeyboard,
|
31
|
+
setSelectionAreaData = _ref.setSelectionAreaData;
|
32
|
+
setSelectionAreaData([]);
|
31
33
|
var rowValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row : index;
|
32
34
|
var columnValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column : index;
|
33
35
|
var point1 = {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.handleMultipleKeys = void 0;
|
6
|
+
exports.includesShift = exports.handleMultipleKeys = void 0;
|
7
7
|
|
8
8
|
var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
|
9
9
|
|
@@ -13,23 +13,50 @@ var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
|
|
13
13
|
* This source code is licensed under the Apache-2.0 license found in the
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
15
15
|
*/
|
16
|
+
var includesShift = function includesShift(arr) {
|
17
|
+
if (arr.includes('ShiftLeft') || arr.includes('ShiftRight')) {
|
18
|
+
return true;
|
19
|
+
}
|
20
|
+
|
21
|
+
return false;
|
22
|
+
};
|
23
|
+
|
24
|
+
exports.includesShift = includesShift;
|
25
|
+
|
26
|
+
var includesMeta = function includesMeta(arr) {
|
27
|
+
if (arr.includes('MetaLeft') || arr.includes('MetaRight')) {
|
28
|
+
return true;
|
29
|
+
}
|
30
|
+
|
31
|
+
return false;
|
32
|
+
};
|
33
|
+
|
34
|
+
var includesControl = function includesControl(arr) {
|
35
|
+
if (arr.includes('ControlLeft') || arr.includes('ControlRight')) {
|
36
|
+
return true;
|
37
|
+
}
|
38
|
+
|
39
|
+
return false;
|
40
|
+
};
|
41
|
+
|
16
42
|
var handleMultipleKeys = function handleMultipleKeys(_ref) {
|
17
43
|
var _selectionAreasClone$;
|
18
44
|
|
19
|
-
var
|
45
|
+
var activeCellCoordinates = _ref.activeCellCoordinates,
|
46
|
+
event = _ref.event,
|
47
|
+
keysPressedList = _ref.keysPressedList,
|
20
48
|
selectionAreas = _ref.selectionAreas,
|
21
49
|
currentMatcher = _ref.currentMatcher,
|
22
50
|
rows = _ref.rows,
|
23
51
|
setSelectionAreas = _ref.setSelectionAreas,
|
24
52
|
columns = _ref.columns;
|
25
|
-
var activeKeyValues = activeKeys.current;
|
26
53
|
var selectionAreasClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
|
27
54
|
var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
|
28
55
|
return item.matcher === currentMatcher;
|
29
56
|
});
|
30
57
|
var pointToUpdate = (_selectionAreasClone$ = selectionAreasClone[indexOfCurrentArea]) !== null && _selectionAreasClone$ !== void 0 && _selectionAreasClone$.point2 ? selectionAreasClone[indexOfCurrentArea].point2 : selectionAreasClone[indexOfCurrentArea].point1; // Down + Shift
|
31
58
|
|
32
|
-
if (
|
59
|
+
if (includesShift(keysPressedList) && keysPressedList.includes('ArrowDown') && keysPressedList.length === 2) {
|
33
60
|
if (rows.length - 1 === pointToUpdate.row) {
|
34
61
|
return;
|
35
62
|
}
|
@@ -44,7 +71,7 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
|
|
44
71
|
} // Right + Shift
|
45
72
|
|
46
73
|
|
47
|
-
if (
|
74
|
+
if (includesShift(keysPressedList) && keysPressedList.includes('ArrowRight') && keysPressedList.length === 2) {
|
48
75
|
if (columns.length - 1 === pointToUpdate.column) {
|
49
76
|
return;
|
50
77
|
}
|
@@ -59,7 +86,7 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
|
|
59
86
|
} // Up + Shift
|
60
87
|
|
61
88
|
|
62
|
-
if (
|
89
|
+
if (includesShift(keysPressedList) && keysPressedList.includes('ArrowUp') && keysPressedList.length === 2) {
|
63
90
|
if (pointToUpdate.row === 0) {
|
64
91
|
return;
|
65
92
|
}
|
@@ -74,7 +101,7 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
|
|
74
101
|
} // Left + Shift
|
75
102
|
|
76
103
|
|
77
|
-
if (
|
104
|
+
if (includesShift(keysPressedList) && keysPressedList.includes('ArrowLeft') && keysPressedList.length === 2) {
|
78
105
|
if (pointToUpdate.column === 0) {
|
79
106
|
return;
|
80
107
|
}
|
@@ -86,6 +113,55 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
|
|
86
113
|
selectionAreasClone[indexOfCurrentArea].point2 = _newPoint3;
|
87
114
|
selectionAreasClone[indexOfCurrentArea].areaCreated = false;
|
88
115
|
setSelectionAreas(selectionAreasClone);
|
116
|
+
} // CMD + a (select all)
|
117
|
+
|
118
|
+
|
119
|
+
if (includesMeta(keysPressedList) && keysPressedList.includes('KeyA')) {
|
120
|
+
event.preventDefault();
|
121
|
+
var selectionPoint1 = {
|
122
|
+
row: 0,
|
123
|
+
column: 0
|
124
|
+
};
|
125
|
+
var selectionPoint2 = {
|
126
|
+
row: rows.length - 1,
|
127
|
+
column: columns.length - 1
|
128
|
+
};
|
129
|
+
selectionAreasClone[indexOfCurrentArea].point1 = selectionPoint1;
|
130
|
+
selectionAreasClone[indexOfCurrentArea].point2 = selectionPoint2;
|
131
|
+
selectionAreasClone[indexOfCurrentArea].areaCreated = false;
|
132
|
+
setSelectionAreas(selectionAreasClone);
|
133
|
+
} // CONTROL + SPACE (Select current column)
|
134
|
+
|
135
|
+
|
136
|
+
if (includesControl(keysPressedList) && keysPressedList.includes('Space')) {
|
137
|
+
var _selectionPoint = {
|
138
|
+
row: 0,
|
139
|
+
column: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column
|
140
|
+
};
|
141
|
+
var _selectionPoint2 = {
|
142
|
+
row: rows.length - 1,
|
143
|
+
column: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column
|
144
|
+
};
|
145
|
+
selectionAreasClone[indexOfCurrentArea].point1 = _selectionPoint;
|
146
|
+
selectionAreasClone[indexOfCurrentArea].point2 = _selectionPoint2;
|
147
|
+
selectionAreasClone[indexOfCurrentArea].areaCreated = false;
|
148
|
+
setSelectionAreas(selectionAreasClone);
|
149
|
+
} // Shift + SPACE (Select current row)
|
150
|
+
|
151
|
+
|
152
|
+
if (includesShift(keysPressedList) && keysPressedList.includes('Space')) {
|
153
|
+
var _selectionPoint3 = {
|
154
|
+
row: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row,
|
155
|
+
column: 0
|
156
|
+
};
|
157
|
+
var _selectionPoint4 = {
|
158
|
+
row: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row,
|
159
|
+
column: columns.length - 1
|
160
|
+
};
|
161
|
+
selectionAreasClone[indexOfCurrentArea].point1 = _selectionPoint3;
|
162
|
+
selectionAreasClone[indexOfCurrentArea].point2 = _selectionPoint4;
|
163
|
+
selectionAreasClone[indexOfCurrentArea].areaCreated = false;
|
164
|
+
setSelectionAreas(selectionAreasClone);
|
89
165
|
}
|
90
166
|
};
|
91
167
|
|
@@ -0,0 +1,86 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.default = void 0;
|
9
|
+
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11
|
+
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
+
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15
|
+
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
17
|
+
|
18
|
+
var _carbonComponentsReact = require("carbon-components-react");
|
19
|
+
|
20
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
21
|
+
|
22
|
+
var _DatagridHead = _interopRequireDefault(require("./DatagridHead"));
|
23
|
+
|
24
|
+
var _DatagridBody = _interopRequireDefault(require("./DatagridBody"));
|
25
|
+
|
26
|
+
var _DatagridToolbar = _interopRequireDefault(require("./DatagridToolbar"));
|
27
|
+
|
28
|
+
var _devtools = require("../../../global/js/utils/devtools");
|
29
|
+
|
30
|
+
var _settings = require("../../../settings");
|
31
|
+
|
32
|
+
var _excluded = ["getTableProps", "withVirtualScroll", "DatagridPagination", "isFetching", "tableId", "CustomizeColumnsModal", "leftPanel", "fullHeightDatagrid", "verticalAlign", "variableRowHeight", "className"];
|
33
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
34
|
+
var componentName = 'Datagrid';
|
35
|
+
var TableContainer = _carbonComponentsReact.DataTable.TableContainer,
|
36
|
+
Table = _carbonComponentsReact.DataTable.Table;
|
37
|
+
|
38
|
+
var Datagrid = /*#__PURE__*/_react.default.forwardRef(function (datagridState, ref) {
|
39
|
+
var _getTableProps;
|
40
|
+
|
41
|
+
var _datagridState$getTab = datagridState.getTableProps,
|
42
|
+
getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
|
43
|
+
withVirtualScroll = datagridState.withVirtualScroll,
|
44
|
+
DatagridPagination = datagridState.DatagridPagination,
|
45
|
+
isFetching = datagridState.isFetching,
|
46
|
+
tableId = datagridState.tableId,
|
47
|
+
CustomizeColumnsModal = datagridState.CustomizeColumnsModal,
|
48
|
+
leftPanel = datagridState.leftPanel,
|
49
|
+
fullHeightDatagrid = datagridState.fullHeightDatagrid,
|
50
|
+
_datagridState$vertic = datagridState.verticalAlign,
|
51
|
+
verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
|
52
|
+
variableRowHeight = datagridState.variableRowHeight,
|
53
|
+
className = datagridState.className,
|
54
|
+
rest = (0, _objectWithoutProperties2.default)(datagridState, _excluded);
|
55
|
+
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
56
|
+
|
57
|
+
var dataGrid = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TableContainer, {
|
58
|
+
className: (0, _classnames.default)("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '')
|
59
|
+
}, /*#__PURE__*/_react.default.createElement(Table, (0, _extends2.default)({}, getTableProps(), {
|
60
|
+
className: (0, _classnames.default)(DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), (0, _defineProperty2.default)({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className)
|
61
|
+
}), /*#__PURE__*/_react.default.createElement(_DatagridHead.default, datagridState), /*#__PURE__*/_react.default.createElement(_DatagridBody.default, (0, _extends2.default)({}, datagridState, {
|
62
|
+
rows: rows
|
63
|
+
})))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/_react.default.createElement(CustomizeColumnsModal, {
|
64
|
+
instance: datagridState
|
65
|
+
}));
|
66
|
+
|
67
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, {
|
68
|
+
id: tableId,
|
69
|
+
ref: ref,
|
70
|
+
className: (0, _classnames.default)(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"))
|
71
|
+
}, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement(_DatagridToolbar.default, datagridState), leftPanel && /*#__PURE__*/_react.default.createElement("div", {
|
72
|
+
className: "".concat(blockClass, "__grid-container ").concat(blockClass, "__displayFlex")
|
73
|
+
}, leftPanel && leftPanel.isOpen && /*#__PURE__*/_react.default.createElement("div", {
|
74
|
+
className: "".concat(blockClass, "__datagridLeftPanel")
|
75
|
+
}, leftPanel.panelContent), /*#__PURE__*/_react.default.createElement("div", {
|
76
|
+
className: "".concat(blockClass, "__datagridWithPanel")
|
77
|
+
}, dataGrid)), leftPanel === undefined && dataGrid);
|
78
|
+
}); // Return a placeholder if not released and not enabled by feature flag
|
79
|
+
|
80
|
+
|
81
|
+
Datagrid = _settings.pkg.checkComponentEnabled(Datagrid, componentName); // The display name of the component, used by React. Note that displayName
|
82
|
+
// is used in preference to relying on function.name.
|
83
|
+
|
84
|
+
Datagrid.displayName = componentName;
|
85
|
+
var _default = Datagrid;
|
86
|
+
exports.default = _default;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.default = void 0;
|
9
|
+
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
11
|
+
|
12
|
+
var _DatagridEmptyBody = _interopRequireDefault(require("./DatagridEmptyBody"));
|
13
|
+
|
14
|
+
var _DatagridVirtualBody = _interopRequireDefault(require("./DatagridVirtualBody"));
|
15
|
+
|
16
|
+
var _DatagridSimpleBody = _interopRequireDefault(require("./DatagridSimpleBody"));
|
17
|
+
|
18
|
+
var _DatagridRefBody = _interopRequireDefault(require("./DatagridRefBody"));
|
19
|
+
|
20
|
+
/*
|
21
|
+
* Licensed Materials - Property of IBM
|
22
|
+
* 5724-Q36
|
23
|
+
* (c) Copyright IBM Corp. 2021
|
24
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
25
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
26
|
+
*/
|
27
|
+
var DatagridBody = function DatagridBody(datagridState) {
|
28
|
+
var isFetching = datagridState.isFetching,
|
29
|
+
_datagridState$rows = datagridState.rows,
|
30
|
+
rows = _datagridState$rows === void 0 ? [] : _datagridState$rows,
|
31
|
+
withVirtualScroll = datagridState.withVirtualScroll,
|
32
|
+
withStickyColumn = datagridState.withStickyColumn;
|
33
|
+
|
34
|
+
if (!isFetching && rows.length === 0) {
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_DatagridEmptyBody.default, datagridState);
|
36
|
+
}
|
37
|
+
|
38
|
+
if (withVirtualScroll) {
|
39
|
+
return /*#__PURE__*/_react.default.createElement(_DatagridVirtualBody.default, datagridState);
|
40
|
+
}
|
41
|
+
|
42
|
+
if (withStickyColumn) {
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_DatagridRefBody.default, datagridState);
|
44
|
+
}
|
45
|
+
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_DatagridSimpleBody.default, datagridState);
|
47
|
+
};
|
48
|
+
|
49
|
+
var _default = DatagridBody;
|
50
|
+
exports.default = _default;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.default = void 0;
|
9
|
+
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
11
|
+
|
12
|
+
var _settings = require("../../../settings");
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Licensed Materials - Property of IBM
|
16
|
+
* 5724-Q36
|
17
|
+
* (c) Copyright IBM Corp. 2020
|
18
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
19
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
20
|
+
*/
|
21
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
22
|
+
|
23
|
+
var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
|
24
|
+
var EmptyState = datagridState.EmptyState;
|
25
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
26
|
+
className: "".concat(blockClass, "__empty-state-body")
|
27
|
+
}, EmptyState);
|
28
|
+
};
|
29
|
+
|
30
|
+
var _default = DatagridEmptyBody;
|
31
|
+
exports.default = _default;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.default = void 0;
|
9
|
+
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
11
|
+
|
12
|
+
var _settings = require("../../../settings");
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Licensed Materials - Property of IBM
|
16
|
+
* 5724-Q36
|
17
|
+
* (c) Copyright IBM Corp. 2020
|
18
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
19
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
20
|
+
*/
|
21
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid"); // eslint-disable-next-line react/prop-types
|
22
|
+
|
23
|
+
var DatagridExpandedRow = function DatagridExpandedRow(PreviousRowRenderer, ExpandedRowContentComponent) {
|
24
|
+
return function (datagridState) {
|
25
|
+
var row = datagridState.row;
|
26
|
+
|
27
|
+
if (!row.isExpanded) {
|
28
|
+
return PreviousRowRenderer(datagridState);
|
29
|
+
}
|
30
|
+
|
31
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
32
|
+
className: "".concat(blockClass, "__expanded-row")
|
33
|
+
}, PreviousRowRenderer(datagridState), ExpandedRowContentComponent(datagridState));
|
34
|
+
};
|
35
|
+
};
|
36
|
+
|
37
|
+
var _default = DatagridExpandedRow;
|
38
|
+
exports.default = _default;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.default = void 0;
|
9
|
+
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11
|
+
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
13
|
+
|
14
|
+
var _carbonComponentsReact = require("carbon-components-react");
|
15
|
+
|
16
|
+
/*
|
17
|
+
* Licensed Materials - Property of IBM
|
18
|
+
* 5724-Q36
|
19
|
+
* (c) Copyright IBM Corp. 2020, 2021
|
20
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
21
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
22
|
+
*/
|
23
|
+
var TableHead = _carbonComponentsReact.DataTable.TableHead;
|
24
|
+
|
25
|
+
var DatagridHead = function DatagridHead(datagridState) {
|
26
|
+
var _datagridState$header = datagridState.headerGroups,
|
27
|
+
headerGroups = _datagridState$header === void 0 ? [] : _datagridState$header,
|
28
|
+
headRef = datagridState.headRef,
|
29
|
+
HeaderRow = datagridState.HeaderRow;
|
30
|
+
return /*#__PURE__*/_react.default.createElement(TableHead, null, headerGroups.map(function (headerGroup, index) {
|
31
|
+
return (
|
32
|
+
/*#__PURE__*/
|
33
|
+
// doesn't support header grouping.
|
34
|
+
_react.default.createElement("div", (0, _extends2.default)({}, headerGroup.getHeaderGroupProps(), {
|
35
|
+
ref: headRef,
|
36
|
+
key: "header_".concat(index)
|
37
|
+
}), HeaderRow(datagridState))
|
38
|
+
);
|
39
|
+
}));
|
40
|
+
};
|
41
|
+
|
42
|
+
var _default = DatagridHead;
|
43
|
+
exports.default = _default;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.default = void 0;
|
9
|
+
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11
|
+
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
+
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
15
|
+
|
16
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
17
|
+
|
18
|
+
var _carbonComponentsReact = require("carbon-components-react");
|
19
|
+
|
20
|
+
var _commonColumnIds = require("../common-column-ids");
|
21
|
+
|
22
|
+
var _settings = require("../../../settings");
|
23
|
+
|
24
|
+
/*
|
25
|
+
* Licensed Materials - Property of IBM
|
26
|
+
* 5724-Q36
|
27
|
+
* (c) Copyright IBM Corp. 2020, 2021
|
28
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
29
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
30
|
+
*/
|
31
|
+
// @flow
|
32
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
33
|
+
|
34
|
+
var HeaderRow = function HeaderRow(datagridState) {
|
35
|
+
return /*#__PURE__*/_react.default.createElement(TableRow, {
|
36
|
+
className: "".concat(blockClass, "__head")
|
37
|
+
}, datagridState.headers.filter(function (_ref) {
|
38
|
+
var isVisible = _ref.isVisible;
|
39
|
+
return isVisible;
|
40
|
+
}).map(function (header) {
|
41
|
+
var _cx;
|
42
|
+
|
43
|
+
if (header.id === _commonColumnIds.selectionColumnId) {
|
44
|
+
// render directly without the wrapper TableHeader
|
45
|
+
return header.render('Header', {
|
46
|
+
key: header.id
|
47
|
+
});
|
48
|
+
}
|
49
|
+
|
50
|
+
return /*#__PURE__*/_react.default.createElement(TableHeader, (0, _extends2.default)({}, header.getHeaderProps(), {
|
51
|
+
className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__sortableColumn"), header.canSort), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
|
52
|
+
key: header.id
|
53
|
+
}), header.render('Header'), header.getResizerProps && /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, header.getResizerProps(), {
|
54
|
+
className: "".concat(blockClass, "__resizer")
|
55
|
+
})));
|
56
|
+
}));
|
57
|
+
};
|
58
|
+
|
59
|
+
var TableHeader = _carbonComponentsReact.DataTable.TableHeader,
|
60
|
+
TableRow = _carbonComponentsReact.DataTable.TableRow;
|
61
|
+
|
62
|
+
var useHeaderRow = function useHeaderRow(hooks) {
|
63
|
+
var useInstance = function useInstance(instance) {
|
64
|
+
Object.assign(instance, {
|
65
|
+
HeaderRow: HeaderRow
|
66
|
+
});
|
67
|
+
};
|
68
|
+
|
69
|
+
hooks.useInstance.push(useInstance);
|
70
|
+
};
|
71
|
+
|
72
|
+
var _default = useHeaderRow;
|
73
|
+
exports.default = _default;
|