@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
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
4
|
|
5
|
-
var
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
6
6
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
8
8
|
value: true
|
@@ -11,7 +11,7 @@ exports.DataSpreadsheet = void 0;
|
|
11
11
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13
13
|
|
14
|
-
var
|
14
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
15
15
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
17
17
|
|
@@ -43,11 +43,9 @@ var _hooks = require("../../global/js/hooks");
|
|
43
43
|
|
44
44
|
var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
|
45
45
|
|
46
|
-
var
|
46
|
+
var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
|
47
47
|
|
48
|
-
var
|
49
|
-
|
50
|
-
var _useMoveActiveCell = require("./hooks/useMoveActiveCell");
|
48
|
+
var _hooks2 = require("./hooks");
|
51
49
|
|
52
50
|
var _createActiveCellFn = require("./utils/createActiveCellFn");
|
53
51
|
|
@@ -57,11 +55,21 @@ var _handleMultipleKeys = require("./utils/handleMultipleKeys");
|
|
57
55
|
|
58
56
|
var _handleHeaderCellSelection = require("./utils/handleHeaderCellSelection");
|
59
57
|
|
60
|
-
var
|
58
|
+
var _removeCellSelections = require("./utils/removeCellSelections");
|
59
|
+
|
60
|
+
var _selectAllCells = require("./utils/selectAllCells");
|
61
|
+
|
62
|
+
var _handleEditSubmit = require("./utils/handleEditSubmit");
|
63
|
+
|
64
|
+
var _handleActiveCellInSelectionEnter = require("./utils/handleActiveCellInSelectionEnter");
|
65
|
+
|
66
|
+
var _handleActiveCellInSelectionTab = require("./utils/handleActiveCellInSelectionTab");
|
67
|
+
|
68
|
+
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
|
61
69
|
|
62
70
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
63
71
|
|
64
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
72
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
65
73
|
|
66
74
|
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; }
|
67
75
|
|
@@ -76,6 +84,7 @@ var defaults = {
|
|
76
84
|
cellSize: 'standard',
|
77
85
|
columns: Object.freeze([]),
|
78
86
|
data: Object.freeze([]),
|
87
|
+
defaultEmptyRowCount: 16,
|
79
88
|
onDataUpdate: Object.freeze(function () {}),
|
80
89
|
onActiveCellChange: Object.freeze(function () {}),
|
81
90
|
onSelectionAreaChange: Object.freeze(function () {})
|
@@ -92,6 +101,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
92
101
|
columns = _ref$columns === void 0 ? defaults.columns : _ref$columns,
|
93
102
|
_ref$data = _ref.data,
|
94
103
|
data = _ref$data === void 0 ? defaults.data : _ref$data,
|
104
|
+
_ref$defaultEmptyRowC = _ref.defaultEmptyRowCount,
|
105
|
+
defaultEmptyRowCount = _ref$defaultEmptyRowC === void 0 ? defaults.defaultEmptyRowCount : _ref$defaultEmptyRowC,
|
95
106
|
_ref$onDataUpdate = _ref.onDataUpdate,
|
96
107
|
onDataUpdate = _ref$onDataUpdate === void 0 ? defaults.onDataUpdate : _ref$onDataUpdate,
|
97
108
|
id = _ref.id,
|
@@ -100,6 +111,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
100
111
|
_ref$onSelectionAreaC = _ref.onSelectionAreaChange,
|
101
112
|
onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
|
102
113
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
114
|
+
var multiKeyTrackingRef = (0, _react.useRef)();
|
103
115
|
var localRef = (0, _react.useRef)();
|
104
116
|
var spreadsheetRef = ref || localRef;
|
105
117
|
var focusedElement = (0, _hooks.useActiveElement)();
|
@@ -144,19 +156,25 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
144
156
|
cellEditorValue = _useState16[0],
|
145
157
|
setCellEditorValue = _useState16[1];
|
146
158
|
|
159
|
+
var _useState17 = (0, _react.useState)(false),
|
160
|
+
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
161
|
+
activeCellInsideSelectionArea = _useState18[0],
|
162
|
+
setActiveCellInsideSelectionArea = _useState18[1];
|
163
|
+
|
147
164
|
var previousState = (0, _hooks.usePreviousValue)({
|
148
|
-
activeCellCoordinates: activeCellCoordinates
|
165
|
+
activeCellCoordinates: activeCellCoordinates,
|
166
|
+
isEditing: isEditing
|
149
167
|
});
|
150
168
|
var cellSizeValue = (0, _getCellSize.getCellSize)(cellSize);
|
151
169
|
var cellEditorRef = (0, _react.useRef)();
|
152
170
|
|
153
|
-
var
|
154
|
-
|
155
|
-
activeCellContent =
|
156
|
-
setActiveCellContent =
|
171
|
+
var _useState19 = (0, _react.useState)(),
|
172
|
+
_useState20 = (0, _slicedToArray2.default)(_useState19, 2),
|
173
|
+
activeCellContent = _useState20[0],
|
174
|
+
setActiveCellContent = _useState20[1];
|
157
175
|
|
158
|
-
var activeKeys = (0, _react.useRef)([]);
|
159
176
|
var activeCellRef = (0, _react.useRef)();
|
177
|
+
var cellEditorRulerRef = (0, _react.useRef)();
|
160
178
|
var defaultColumn = (0, _react.useMemo)(function () {
|
161
179
|
return {
|
162
180
|
width: 150,
|
@@ -164,6 +182,15 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
164
182
|
rowHeight: cellSizeValue
|
165
183
|
};
|
166
184
|
}, [cellSizeValue]);
|
185
|
+
|
186
|
+
var _useMultipleKeyTracki = (0, _hooks2.useMultipleKeyTracking)({
|
187
|
+
ref: multiKeyTrackingRef,
|
188
|
+
containerHasFocus: containerHasFocus,
|
189
|
+
isEditing: isEditing
|
190
|
+
}),
|
191
|
+
keysPressedList = _useMultipleKeyTracki.keysPressedList,
|
192
|
+
usingMac = _useMultipleKeyTracki.usingMac;
|
193
|
+
|
167
194
|
var scrollBarSize = (0, _react.useMemo)(function () {
|
168
195
|
return (0, _getScrollbarWidth.getScrollbarWidth)();
|
169
196
|
}, []);
|
@@ -204,22 +231,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
204
231
|
setCellEditorValue('');
|
205
232
|
setIsEditing(false);
|
206
233
|
cellEditorRef.current.style.display = 'none';
|
207
|
-
}, []); //
|
208
|
-
|
209
|
-
var removeCellSelections = (0, _react.useCallback)(function (matcher) {
|
210
|
-
if (matcher && typeof matcher === 'string') {
|
211
|
-
var selectionToRemove = spreadsheetRef.current.querySelector("[data-matcher-id=\"".concat(matcher, "\"]"));
|
212
|
-
|
213
|
-
if (selectionToRemove) {
|
214
|
-
selectionToRemove.remove();
|
215
|
-
}
|
216
|
-
} else {
|
217
|
-
var cellSelections = spreadsheetRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
|
218
|
-
(0, _toConsumableArray2.default)(cellSelections).forEach(function (element) {
|
219
|
-
return element.remove();
|
220
|
-
});
|
221
|
-
}
|
222
|
-
}, [spreadsheetRef]); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
|
234
|
+
}, []); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
|
223
235
|
// happen if you click on another cell while isEditing is true
|
224
236
|
|
225
237
|
(0, _react.useEffect)(function () {
|
@@ -229,6 +241,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
229
241
|
var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
|
230
242
|
removeCellEditor();
|
231
243
|
updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
|
244
|
+
cellEditorRulerRef.current.textContent = '';
|
232
245
|
}
|
233
246
|
|
234
247
|
if ((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column)) {
|
@@ -266,23 +279,21 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
266
279
|
});
|
267
280
|
}
|
268
281
|
}, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
|
269
|
-
(0,
|
270
|
-
activeKeys: activeKeys,
|
282
|
+
(0, _hooks2.useResetSpreadsheetFocus)({
|
271
283
|
focusedElement: focusedElement,
|
272
284
|
removeActiveCell: removeActiveCell,
|
273
285
|
setContainerHasFocus: setContainerHasFocus
|
274
286
|
});
|
275
|
-
(0,
|
287
|
+
(0, _hooks2.useSpreadsheetOutsideClick)({
|
276
288
|
spreadsheetRef: spreadsheetRef,
|
277
289
|
setActiveCellCoordinates: setActiveCellCoordinates,
|
278
290
|
setSelectionAreas: setSelectionAreas,
|
279
291
|
removeActiveCell: removeActiveCell,
|
280
|
-
removeCellSelections: removeCellSelections,
|
292
|
+
removeCellSelections: _removeCellSelections.removeCellSelections,
|
281
293
|
setContainerHasFocus: setContainerHasFocus,
|
282
|
-
activeKeys: activeKeys,
|
283
294
|
removeCellEditor: removeCellEditor
|
284
295
|
});
|
285
|
-
(0,
|
296
|
+
(0, _hooks2.useMoveActiveCell)({
|
286
297
|
spreadsheetRef: spreadsheetRef,
|
287
298
|
activeCellCoordinates: activeCellCoordinates,
|
288
299
|
containerHasFocus: containerHasFocus,
|
@@ -291,6 +302,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
291
302
|
var handleInitialArrowPress = (0, _react.useCallback)(function () {
|
292
303
|
// If activeCellCoordinates is null then we need to set an initial value
|
293
304
|
// which will place the activeCell on the select all cell/button
|
305
|
+
setActiveCellInsideSelectionArea(false);
|
306
|
+
|
294
307
|
if (!activeCellCoordinates) {
|
295
308
|
setActiveCellCoordinates({
|
296
309
|
column: 'header',
|
@@ -301,16 +314,20 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
301
314
|
return;
|
302
315
|
}, [activeCellCoordinates]);
|
303
316
|
var updateActiveCellCoordinates = (0, _react.useCallback)(function (_ref3) {
|
304
|
-
var coords = _ref3.coords,
|
305
|
-
|
317
|
+
var _ref3$coords = _ref3.coords,
|
318
|
+
coords = _ref3$coords === void 0 ? _objectSpread({}, activeCellCoordinates) : _ref3$coords,
|
319
|
+
updatedValue = _ref3.updatedValue,
|
320
|
+
_ref3$optOutOfSelecti = _ref3.optOutOfSelectionAreaUpdate,
|
321
|
+
optOutOfSelectionAreaUpdate = _ref3$optOutOfSelecti === void 0 ? false : _ref3$optOutOfSelecti;
|
306
322
|
|
307
323
|
var newActiveCell = _objectSpread(_objectSpread({}, coords), updatedValue);
|
308
324
|
|
309
325
|
setActiveCellCoordinates(newActiveCell); // Only run if the active cell is _not_ a header cell. This will add a point1 object
|
310
326
|
// to selectionAreas every time the active cell changes, allowing us to create cell
|
311
|
-
// selections using keyboard
|
327
|
+
// selections using keyboard. Opting out of the selection area updates here means
|
328
|
+
// that the active cell is being moved within a selection area
|
312
329
|
|
313
|
-
if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header') {
|
330
|
+
if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header' && !optOutOfSelectionAreaUpdate) {
|
314
331
|
var tempMatcher = (0, _uuidv.default)();
|
315
332
|
setSelectionAreas([{
|
316
333
|
point1: newActiveCell,
|
@@ -318,11 +335,29 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
318
335
|
}]);
|
319
336
|
setCurrentMatcher(tempMatcher);
|
320
337
|
}
|
321
|
-
}, []);
|
338
|
+
}, [activeCellCoordinates]);
|
339
|
+
var handleHomeEndKey = (0, _react.useCallback)(function (_ref4) {
|
340
|
+
var type = _ref4.type;
|
341
|
+
|
342
|
+
var coordinatesClone = _objectSpread({}, activeCellCoordinates);
|
343
|
+
|
344
|
+
updateActiveCellCoordinates({
|
345
|
+
coords: coordinatesClone,
|
346
|
+
updatedValue: {
|
347
|
+
column: type === 'home' ? 0 : columns.length - 1
|
348
|
+
}
|
349
|
+
});
|
350
|
+
(0, _removeCellSelections.removeCellSelections)({
|
351
|
+
spreadsheetRef: spreadsheetRef
|
352
|
+
});
|
353
|
+
}, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
|
322
354
|
var handleKeyPress = (0, _react.useCallback)(function (event) {
|
323
|
-
var
|
355
|
+
var key = event.key;
|
356
|
+
|
357
|
+
if (isEditing) {
|
358
|
+
return;
|
359
|
+
} // Command keys need to be returned as there is default browser behavior with these keys
|
324
360
|
|
325
|
-
var key = event.key; // Command keys need to be returned as there is default browser behavior with these keys
|
326
361
|
|
327
362
|
if (key === 'Meta' || key === 'Control') {
|
328
363
|
return;
|
@@ -339,43 +374,90 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
339
374
|
|
340
375
|
|
341
376
|
if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
|
342
|
-
if (
|
343
|
-
return;
|
344
|
-
}
|
345
|
-
|
346
|
-
if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && key !== 'Shift' && !activeKeys.current.includes('Shift')) {
|
377
|
+
if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && keysPressedList.length < 2 && !(0, _handleMultipleKeys.includesShift)(keysPressedList)) {
|
347
378
|
setSelectionAreas([]);
|
348
379
|
setSelectionAreaData([]);
|
349
|
-
removeCellSelections({
|
380
|
+
(0, _removeCellSelections.removeCellSelections)({
|
350
381
|
spreadsheetRef: spreadsheetRef
|
351
382
|
});
|
352
383
|
}
|
353
|
-
} // Update list of activeKeys
|
354
|
-
|
355
|
-
|
356
|
-
if (!((_activeKeys$current = activeKeys.current) !== null && _activeKeys$current !== void 0 && _activeKeys$current.includes(key))) {
|
357
|
-
var activeClone = (0, _toConsumableArray2.default)(activeKeys.current);
|
358
|
-
activeKeys.current = [].concat((0, _toConsumableArray2.default)(activeClone), [key]);
|
359
384
|
}
|
360
385
|
|
361
|
-
if (
|
386
|
+
if (!isEditing && (keysPressedList === null || keysPressedList === void 0 ? void 0 : keysPressedList.length) > 1) {
|
362
387
|
(0, _handleMultipleKeys.handleMultipleKeys)({
|
363
|
-
|
388
|
+
activeCellCoordinates: activeCellCoordinates,
|
389
|
+
event: event,
|
390
|
+
keysPressedList: keysPressedList,
|
364
391
|
selectionAreas: selectionAreas,
|
365
392
|
currentMatcher: currentMatcher,
|
366
393
|
rows: rows,
|
367
394
|
setSelectionAreas: setSelectionAreas,
|
368
|
-
columns: columns
|
395
|
+
columns: columns,
|
396
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates,
|
397
|
+
spreadsheetRef: spreadsheetRef,
|
398
|
+
removeCellSelections: _removeCellSelections.removeCellSelections,
|
399
|
+
blockClass: blockClass,
|
400
|
+
setCurrentMatcher: setCurrentMatcher,
|
401
|
+
usingMac: usingMac
|
369
402
|
});
|
370
403
|
} // Allow arrow key navigation if there are less than two activeKeys OR
|
371
404
|
// if one of the activeCellCoordinates is in a header position
|
372
405
|
|
373
406
|
|
374
|
-
if (!
|
407
|
+
if (keysPressedList.length < 2 && !(0, _handleMultipleKeys.includesShift)(keysPressedList) || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
|
375
408
|
switch (key) {
|
409
|
+
// Enter
|
410
|
+
case 'Enter':
|
411
|
+
{
|
412
|
+
(0, _handleActiveCellInSelectionEnter.handleActiveCellInSelectionEnter)({
|
413
|
+
activeCellInsideSelectionArea: activeCellInsideSelectionArea,
|
414
|
+
activeCellCoordinates: activeCellCoordinates,
|
415
|
+
activeCellRef: activeCellRef,
|
416
|
+
selectionAreas: selectionAreas,
|
417
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
418
|
+
});
|
419
|
+
break;
|
420
|
+
}
|
421
|
+
// HOME
|
422
|
+
|
423
|
+
case 'Home':
|
424
|
+
{
|
425
|
+
if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac)) {
|
426
|
+
return;
|
427
|
+
}
|
428
|
+
|
429
|
+
handleHomeEndKey({
|
430
|
+
type: 'home'
|
431
|
+
});
|
432
|
+
break;
|
433
|
+
}
|
434
|
+
|
435
|
+
case 'End':
|
436
|
+
{
|
437
|
+
if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac)) {
|
438
|
+
return;
|
439
|
+
}
|
440
|
+
|
441
|
+
handleHomeEndKey({
|
442
|
+
type: 'end'
|
443
|
+
});
|
444
|
+
break;
|
445
|
+
}
|
376
446
|
// Tab
|
447
|
+
|
377
448
|
case 'Tab':
|
378
449
|
{
|
450
|
+
if (activeCellInsideSelectionArea) {
|
451
|
+
event.preventDefault();
|
452
|
+
return (0, _handleActiveCellInSelectionTab.handleActiveCellInSelectionTab)({
|
453
|
+
activeCellInsideSelectionArea: activeCellInsideSelectionArea,
|
454
|
+
activeCellCoordinates: activeCellCoordinates,
|
455
|
+
activeCellRef: activeCellRef,
|
456
|
+
selectionAreas: selectionAreas,
|
457
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
458
|
+
});
|
459
|
+
}
|
460
|
+
|
379
461
|
setSelectionAreas([]);
|
380
462
|
removeActiveCell();
|
381
463
|
removeCellEditor();
|
@@ -522,24 +604,59 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
522
604
|
}
|
523
605
|
}
|
524
606
|
}
|
525
|
-
}, [updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor,
|
607
|
+
}, [activeCellInsideSelectionArea, updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac]);
|
526
608
|
|
527
609
|
var startEditMode = function startEditMode() {
|
528
610
|
setIsEditing(true);
|
529
611
|
var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
530
612
|
var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
531
613
|
setCellEditorValue(activeCellValue);
|
532
|
-
|
614
|
+
cellEditorRulerRef.current.textContent = activeCellValue;
|
615
|
+
}; // Sets the initial placement of the cell editor cursor at the end of the text area
|
616
|
+
// this is not done for us by default in Safari
|
617
|
+
|
618
|
+
|
619
|
+
(0, _react.useEffect)(function () {
|
620
|
+
if (isEditing && !(previousState !== null && previousState !== void 0 && previousState.isEditing)) {
|
621
|
+
cellEditorRef.current.setSelectionRange(cellEditorRulerRef.current.textContent.length, cellEditorRulerRef.current.textContent.length);
|
622
|
+
cellEditorRef.current.focus();
|
623
|
+
}
|
624
|
+
}, [isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing]);
|
533
625
|
|
534
626
|
var handleActiveCellClick = function handleActiveCellClick() {
|
535
627
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
536
628
|
var indexValue = (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row;
|
629
|
+
|
630
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
631
|
+
return;
|
632
|
+
}
|
633
|
+
|
537
634
|
handleRowColumnHeaderClick({
|
538
635
|
isKeyboard: false,
|
539
636
|
index: indexValue
|
540
637
|
});
|
541
638
|
}
|
542
639
|
|
640
|
+
return;
|
641
|
+
}; // Mouse down on active cell
|
642
|
+
|
643
|
+
|
644
|
+
var handleActiveCellMouseDown = function handleActiveCellMouseDown() {
|
645
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
646
|
+
var tempMatcher = (0, _uuidv.default)();
|
647
|
+
setClickAndHoldActive(true);
|
648
|
+
(0, _removeCellSelections.removeCellSelections)({
|
649
|
+
spreadsheetRef: spreadsheetRef
|
650
|
+
});
|
651
|
+
setSelectionAreas([{
|
652
|
+
point1: activeCellCoordinates,
|
653
|
+
matcher: tempMatcher
|
654
|
+
}]);
|
655
|
+
setCurrentMatcher(tempMatcher);
|
656
|
+
setSelectionAreaData([]);
|
657
|
+
setActiveCellInsideSelectionArea(false);
|
658
|
+
}
|
659
|
+
|
543
660
|
return;
|
544
661
|
}; // Go into edit mode if 'Enter' key is pressed on activeCellRef
|
545
662
|
|
@@ -547,7 +664,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
547
664
|
var handleActiveCellKeyDown = function handleActiveCellKeyDown(event) {
|
548
665
|
var key = event.key;
|
549
666
|
|
550
|
-
if (key === 'Enter') {
|
667
|
+
if (key === 'Enter' && !activeCellInsideSelectionArea) {
|
551
668
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
|
552
669
|
startEditMode();
|
553
670
|
}
|
@@ -560,10 +677,10 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
560
677
|
}
|
561
678
|
};
|
562
679
|
|
563
|
-
var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(
|
564
|
-
var isKeyboard =
|
565
|
-
|
566
|
-
index =
|
680
|
+
var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref5) {
|
681
|
+
var isKeyboard = _ref5.isKeyboard,
|
682
|
+
_ref5$index = _ref5.index,
|
683
|
+
index = _ref5$index === void 0 ? null : _ref5$index;
|
567
684
|
var handleHeaderCellProps = {
|
568
685
|
activeCellCoordinates: activeCellCoordinates,
|
569
686
|
rows: rows,
|
@@ -577,112 +694,100 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
577
694
|
index: index
|
578
695
|
}; // Select an entire column
|
579
696
|
|
580
|
-
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
|
697
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
581
698
|
(0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
|
582
699
|
type: 'column'
|
583
700
|
}, handleHeaderCellProps));
|
584
701
|
} // Select an entire row
|
585
702
|
|
586
703
|
|
587
|
-
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
704
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
|
588
705
|
(0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
|
589
706
|
type: 'row'
|
590
707
|
}, handleHeaderCellProps));
|
591
708
|
}
|
592
|
-
}; // Go into edit mode if double click is detected on activeCellRef
|
593
|
-
|
594
|
-
|
595
|
-
var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
|
596
|
-
startEditMode();
|
597
|
-
}; // Update the data
|
598
709
|
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
};
|
609
|
-
|
610
|
-
if (key === 'Enter') {
|
611
|
-
submitEditChanges();
|
612
|
-
setActiveCellCoordinates(function (prev) {
|
613
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
614
|
-
row: prev.row === rows.length - 1 ? prev.row : prev.row + 1 // do not move to next cell below if we're already in the last row
|
615
|
-
|
616
|
-
});
|
710
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
|
711
|
+
(0, _selectAllCells.selectAllCells)({
|
712
|
+
ref: spreadsheetRef,
|
713
|
+
setCurrentMatcher: setCurrentMatcher,
|
714
|
+
setSelectionAreas: setSelectionAreas,
|
715
|
+
rows: rows,
|
716
|
+
columns: columns,
|
717
|
+
activeCellCoordinates: activeCellCoordinates,
|
718
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
617
719
|
});
|
618
720
|
}
|
721
|
+
}; // Go into edit mode if double click is detected on activeCellRef
|
619
722
|
|
620
|
-
if (key === 'Tab') {
|
621
|
-
event.preventDefault();
|
622
|
-
submitEditChanges();
|
623
|
-
setActiveCellCoordinates(function (prev) {
|
624
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
625
|
-
column: prev.column === columns.length - 1 ? prev.column : prev.column + 1 // do not move to next cell below if we're already in the last column
|
626
723
|
|
627
|
-
|
628
|
-
|
629
|
-
}
|
630
|
-
|
631
|
-
return;
|
724
|
+
var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
|
725
|
+
startEditMode();
|
632
726
|
};
|
633
727
|
|
634
|
-
(0,
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
728
|
+
(0, _hooks2.useSpreadsheetEdit)({
|
729
|
+
isEditing: isEditing,
|
730
|
+
rows: rows,
|
731
|
+
activeCellCoordinates: activeCellCoordinates,
|
732
|
+
activeCellRef: activeCellRef,
|
733
|
+
cellEditorRef: cellEditorRef,
|
734
|
+
cellEditorRulerRef: cellEditorRulerRef,
|
735
|
+
columns: columns,
|
736
|
+
defaultColumn: defaultColumn,
|
737
|
+
cellEditorValue: cellEditorValue
|
738
|
+
});
|
739
|
+
var handleActiveCellMouseEnter = (0, _react.useCallback)(function () {
|
740
|
+
handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
|
741
|
+
}, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]); // Only update if there are cell selection areas
|
742
|
+
// Find point object that matches currentMatcher and remove the second point
|
743
|
+
// because hovering over the active cell while clicking and holding should
|
744
|
+
// remove the previously existing selection area
|
745
|
+
|
746
|
+
var handleActiveCellMouseEnterCallback = (0, _react.useCallback)(function (areas, clickHold) {
|
747
|
+
if (!currentMatcher) {
|
748
|
+
return;
|
650
749
|
}
|
651
750
|
|
652
|
-
if (
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
751
|
+
if (areas && areas.length && clickHold && currentMatcher) {
|
752
|
+
setSelectionAreas(function (prev) {
|
753
|
+
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
|
754
|
+
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
755
|
+
return item.matcher === currentMatcher;
|
756
|
+
});
|
658
757
|
|
659
|
-
|
660
|
-
|
758
|
+
if (indexOfItemToUpdate === -1) {
|
759
|
+
return prev;
|
760
|
+
}
|
661
761
|
|
662
|
-
|
762
|
+
if ((0, _typeof2.default)(selectionAreaClone[indexOfItemToUpdate].point2) === 'object' && selectionAreaClone[indexOfItemToUpdate].areaCreated) {
|
763
|
+
selectionAreaClone[indexOfItemToUpdate].point2 = selectionAreaClone[indexOfItemToUpdate].point1;
|
764
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
765
|
+
setActiveCellInsideSelectionArea(false);
|
766
|
+
(0, _removeCellSelections.removeCellSelections)({
|
767
|
+
matcher: currentMatcher,
|
768
|
+
spreadsheetRef: spreadsheetRef
|
769
|
+
});
|
770
|
+
return selectionAreaClone;
|
771
|
+
}
|
663
772
|
|
664
|
-
|
665
|
-
var activeKeysClone = (0, _toConsumableArray2.default)(activeKeys.current);
|
666
|
-
var filteredKeysClone = activeKeysClone.filter(function (item) {
|
667
|
-
return item !== key;
|
773
|
+
return prev;
|
668
774
|
});
|
669
|
-
activeKeys.current = filteredKeysClone;
|
670
775
|
}
|
671
|
-
};
|
672
|
-
|
776
|
+
}, [spreadsheetRef, currentMatcher]);
|
673
777
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, getTableProps(), (0, _devtools.getDevtoolsProps)(componentName), {
|
674
|
-
className: (0, _classnames.default)(blockClass, className, (0, _defineProperty2.default)({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
|
778
|
+
className: (0, _classnames.default)(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
|
675
779
|
ref: spreadsheetRef,
|
676
780
|
role: "grid",
|
677
781
|
tabIndex: 0,
|
678
782
|
"aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
|
679
783
|
"aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
|
680
784
|
onKeyDown: handleKeyPress,
|
681
|
-
onKeyUp: handleKeyUp,
|
682
785
|
onFocus: function onFocus() {
|
683
786
|
return setContainerHasFocus(true);
|
684
787
|
}
|
685
|
-
}), /*#__PURE__*/_react.default.createElement(
|
788
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
789
|
+
ref: multiKeyTrackingRef
|
790
|
+
}, /*#__PURE__*/_react.default.createElement(_DataSpreadsheetHeader.DataSpreadsheetHeader, {
|
686
791
|
ref: spreadsheetRef,
|
687
792
|
activeCellCoordinates: activeCellCoordinates,
|
688
793
|
cellSize: cellSize,
|
@@ -695,7 +800,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
695
800
|
setActiveCellCoordinates: setActiveCellCoordinates,
|
696
801
|
setSelectionAreas: setSelectionAreas,
|
697
802
|
setCurrentMatcher: setCurrentMatcher,
|
698
|
-
setSelectionAreaData: setSelectionAreaData
|
803
|
+
setSelectionAreaData: setSelectionAreaData,
|
804
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
699
805
|
}), /*#__PURE__*/_react.default.createElement(_DataSpreadsheetBody.DataSpreadsheetBody, {
|
700
806
|
activeCellCoordinates: activeCellCoordinates,
|
701
807
|
ref: spreadsheetRef,
|
@@ -707,8 +813,10 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
707
813
|
selectionAreas: selectionAreas,
|
708
814
|
setSelectionAreas: setSelectionAreas,
|
709
815
|
cellSize: cellSize,
|
816
|
+
headerGroups: headerGroups,
|
710
817
|
defaultColumn: defaultColumn,
|
711
818
|
getTableBodyProps: getTableBodyProps,
|
819
|
+
onDataUpdate: onDataUpdate,
|
712
820
|
onActiveCellChange: onActiveCellChange,
|
713
821
|
onSelectionAreaChange: onSelectionAreaChange,
|
714
822
|
prepareRow: prepareRow,
|
@@ -719,25 +827,46 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
719
827
|
scrollBarSize: scrollBarSize,
|
720
828
|
totalColumnsWidth: totalColumnsWidth,
|
721
829
|
id: id,
|
722
|
-
columns: columns
|
830
|
+
columns: columns,
|
831
|
+
defaultEmptyRowCount: defaultEmptyRowCount,
|
832
|
+
setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea
|
723
833
|
}), /*#__PURE__*/_react.default.createElement("button", {
|
834
|
+
onMouseDown: handleActiveCellMouseDown,
|
724
835
|
onClick: handleActiveCellClick,
|
725
836
|
onKeyDown: handleActiveCellKeyDown,
|
726
837
|
onDoubleClick: handleActiveCellDoubleClick,
|
838
|
+
onMouseEnter: handleActiveCellMouseEnter,
|
727
839
|
ref: activeCellRef,
|
728
|
-
className: (0, _classnames.default)("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight")),
|
840
|
+
className: (0, _classnames.default)("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__active-cell--with-selection"), activeCellInsideSelectionArea)),
|
729
841
|
type: "button"
|
730
842
|
}, activeCellContent), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextArea, {
|
731
843
|
value: cellEditorValue,
|
732
|
-
onKeyDown: handleEditSubmit
|
844
|
+
onKeyDown: (0, _handleEditSubmit.handleEditSubmit)({
|
845
|
+
activeCellCoordinates: activeCellCoordinates,
|
846
|
+
cellEditorRulerRef: cellEditorRulerRef,
|
847
|
+
columns: columns,
|
848
|
+
previousState: previousState,
|
849
|
+
removeCellEditor: removeCellEditor,
|
850
|
+
rows: rows,
|
851
|
+
setActiveCellCoordinates: setActiveCellCoordinates,
|
852
|
+
setCurrentMatcher: setCurrentMatcher,
|
853
|
+
setSelectionAreas: setSelectionAreas,
|
854
|
+
spreadsheetRef: spreadsheetRef,
|
855
|
+
updateData: updateData
|
856
|
+
}),
|
733
857
|
onChange: function onChange(event) {
|
734
|
-
|
858
|
+
setCellEditorValue(event.target.value);
|
859
|
+
cellEditorRulerRef.current.textContent = event.target.value;
|
735
860
|
},
|
736
861
|
ref: cellEditorRef,
|
737
862
|
labelText: "",
|
738
|
-
"aria-labelledby": activeCellCoordinates ? "
|
863
|
+
"aria-labelledby": activeCellCoordinates ? "#".concat(blockClass, "__cell--").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, "--").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) : null,
|
739
864
|
className: (0, _classnames.default)("".concat(blockClass, "__cell-editor"), "".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__cell-editor--").concat(cellSize), (0, _defineProperty2.default)({}, "".concat(blockClass, "__cell-editor--active"), isEditing))
|
740
|
-
})
|
865
|
+
}), /*#__PURE__*/_react.default.createElement("pre", {
|
866
|
+
"aria-hidden": true,
|
867
|
+
ref: cellEditorRulerRef,
|
868
|
+
className: "".concat(blockClass, "__cell-editor-ruler")
|
869
|
+
})));
|
741
870
|
}); // Return a placeholder if not released and not enabled by feature flag
|
742
871
|
|
743
872
|
|
@@ -775,6 +904,11 @@ DataSpreadsheet.propTypes = {
|
|
775
904
|
*/
|
776
905
|
data: _propTypes.default.arrayOf(_propTypes.default.shape),
|
777
906
|
|
907
|
+
/**
|
908
|
+
* Sets the number of empty rows to be created when there is no data provided
|
909
|
+
*/
|
910
|
+
defaultEmptyRowCount: _propTypes.default.number,
|
911
|
+
|
778
912
|
/**
|
779
913
|
* The spreadsheet id
|
780
914
|
*/
|