@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
@@ -1,9 +1,9 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import
|
2
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
5
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
6
|
-
var _excluded = ["cellSize", "className", "columns", "data", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
|
6
|
+
var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
|
7
7
|
|
8
8
|
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; }
|
9
9
|
|
@@ -29,13 +29,17 @@ import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
|
29
29
|
import { getScrollbarWidth } from '../../global/js/utils/getScrollbarWidth';
|
30
30
|
import { useActiveElement, usePreviousValue } from '../../global/js/hooks';
|
31
31
|
import uuidv4 from '../../global/js/utils/uuidv4';
|
32
|
-
import {
|
33
|
-
import { useSpreadsheetOutsideClick } from './hooks
|
34
|
-
import { useMoveActiveCell } from './hooks/useMoveActiveCell';
|
32
|
+
import { deepCloneObject } from '../../global/js/utils/deepCloneObject';
|
33
|
+
import { useResetSpreadsheetFocus, useSpreadsheetOutsideClick, useMoveActiveCell, useMultipleKeyTracking, useSpreadsheetEdit } from './hooks';
|
35
34
|
import { createActiveCellFn } from './utils/createActiveCellFn';
|
36
35
|
import { getCellSize } from './utils/getCellSize';
|
37
|
-
import { handleMultipleKeys } from './utils/handleMultipleKeys';
|
38
|
-
import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection';
|
36
|
+
import { handleMultipleKeys, includesResourceKey, includesShift } from './utils/handleMultipleKeys';
|
37
|
+
import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection';
|
38
|
+
import { removeCellSelections } from './utils/removeCellSelections';
|
39
|
+
import { selectAllCells } from './utils/selectAllCells';
|
40
|
+
import { handleEditSubmit } from './utils/handleEditSubmit';
|
41
|
+
import { handleActiveCellInSelectionEnter } from './utils/handleActiveCellInSelectionEnter';
|
42
|
+
import { handleActiveCellInSelectionTab } from './utils/handleActiveCellInSelectionTab'; // cspell:words rowcount colcount
|
39
43
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
40
44
|
|
41
45
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
@@ -45,6 +49,7 @@ var defaults = {
|
|
45
49
|
cellSize: 'standard',
|
46
50
|
columns: Object.freeze([]),
|
47
51
|
data: Object.freeze([]),
|
52
|
+
defaultEmptyRowCount: 16,
|
48
53
|
onDataUpdate: Object.freeze(function () {}),
|
49
54
|
onActiveCellChange: Object.freeze(function () {}),
|
50
55
|
onSelectionAreaChange: Object.freeze(function () {})
|
@@ -61,6 +66,8 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
61
66
|
columns = _ref$columns === void 0 ? defaults.columns : _ref$columns,
|
62
67
|
_ref$data = _ref.data,
|
63
68
|
data = _ref$data === void 0 ? defaults.data : _ref$data,
|
69
|
+
_ref$defaultEmptyRowC = _ref.defaultEmptyRowCount,
|
70
|
+
defaultEmptyRowCount = _ref$defaultEmptyRowC === void 0 ? defaults.defaultEmptyRowCount : _ref$defaultEmptyRowC,
|
64
71
|
_ref$onDataUpdate = _ref.onDataUpdate,
|
65
72
|
onDataUpdate = _ref$onDataUpdate === void 0 ? defaults.onDataUpdate : _ref$onDataUpdate,
|
66
73
|
id = _ref.id,
|
@@ -70,6 +77,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
70
77
|
onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
|
71
78
|
rest = _objectWithoutProperties(_ref, _excluded);
|
72
79
|
|
80
|
+
var multiKeyTrackingRef = useRef();
|
73
81
|
var localRef = useRef();
|
74
82
|
var spreadsheetRef = ref || localRef;
|
75
83
|
var focusedElement = useActiveElement();
|
@@ -114,19 +122,25 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
114
122
|
cellEditorValue = _useState16[0],
|
115
123
|
setCellEditorValue = _useState16[1];
|
116
124
|
|
125
|
+
var _useState17 = useState(false),
|
126
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
127
|
+
activeCellInsideSelectionArea = _useState18[0],
|
128
|
+
setActiveCellInsideSelectionArea = _useState18[1];
|
129
|
+
|
117
130
|
var previousState = usePreviousValue({
|
118
|
-
activeCellCoordinates: activeCellCoordinates
|
131
|
+
activeCellCoordinates: activeCellCoordinates,
|
132
|
+
isEditing: isEditing
|
119
133
|
});
|
120
134
|
var cellSizeValue = getCellSize(cellSize);
|
121
135
|
var cellEditorRef = useRef();
|
122
136
|
|
123
|
-
var
|
124
|
-
|
125
|
-
activeCellContent =
|
126
|
-
setActiveCellContent =
|
137
|
+
var _useState19 = useState(),
|
138
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
139
|
+
activeCellContent = _useState20[0],
|
140
|
+
setActiveCellContent = _useState20[1];
|
127
141
|
|
128
|
-
var activeKeys = useRef([]);
|
129
142
|
var activeCellRef = useRef();
|
143
|
+
var cellEditorRulerRef = useRef();
|
130
144
|
var defaultColumn = useMemo(function () {
|
131
145
|
return {
|
132
146
|
width: 150,
|
@@ -134,6 +148,15 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
134
148
|
rowHeight: cellSizeValue
|
135
149
|
};
|
136
150
|
}, [cellSizeValue]);
|
151
|
+
|
152
|
+
var _useMultipleKeyTracki = useMultipleKeyTracking({
|
153
|
+
ref: multiKeyTrackingRef,
|
154
|
+
containerHasFocus: containerHasFocus,
|
155
|
+
isEditing: isEditing
|
156
|
+
}),
|
157
|
+
keysPressedList = _useMultipleKeyTracki.keysPressedList,
|
158
|
+
usingMac = _useMultipleKeyTracki.usingMac;
|
159
|
+
|
137
160
|
var scrollBarSize = useMemo(function () {
|
138
161
|
return getScrollbarWidth();
|
139
162
|
}, []);
|
@@ -174,23 +197,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
174
197
|
setCellEditorValue('');
|
175
198
|
setIsEditing(false);
|
176
199
|
cellEditorRef.current.style.display = 'none';
|
177
|
-
}, []); //
|
178
|
-
|
179
|
-
var removeCellSelections = useCallback(function (matcher) {
|
180
|
-
if (matcher && typeof matcher === 'string') {
|
181
|
-
var selectionToRemove = spreadsheetRef.current.querySelector("[data-matcher-id=\"".concat(matcher, "\"]"));
|
182
|
-
|
183
|
-
if (selectionToRemove) {
|
184
|
-
selectionToRemove.remove();
|
185
|
-
}
|
186
|
-
} else {
|
187
|
-
var cellSelections = spreadsheetRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
|
188
|
-
|
189
|
-
_toConsumableArray(cellSelections).forEach(function (element) {
|
190
|
-
return element.remove();
|
191
|
-
});
|
192
|
-
}
|
193
|
-
}, [spreadsheetRef]); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
|
200
|
+
}, []); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
|
194
201
|
// happen if you click on another cell while isEditing is true
|
195
202
|
|
196
203
|
useEffect(function () {
|
@@ -200,6 +207,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
200
207
|
var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
|
201
208
|
removeCellEditor();
|
202
209
|
updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
|
210
|
+
cellEditorRulerRef.current.textContent = '';
|
203
211
|
}
|
204
212
|
|
205
213
|
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)) {
|
@@ -238,7 +246,6 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
238
246
|
}
|
239
247
|
}, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
|
240
248
|
useResetSpreadsheetFocus({
|
241
|
-
activeKeys: activeKeys,
|
242
249
|
focusedElement: focusedElement,
|
243
250
|
removeActiveCell: removeActiveCell,
|
244
251
|
setContainerHasFocus: setContainerHasFocus
|
@@ -250,7 +257,6 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
250
257
|
removeActiveCell: removeActiveCell,
|
251
258
|
removeCellSelections: removeCellSelections,
|
252
259
|
setContainerHasFocus: setContainerHasFocus,
|
253
|
-
activeKeys: activeKeys,
|
254
260
|
removeCellEditor: removeCellEditor
|
255
261
|
});
|
256
262
|
useMoveActiveCell({
|
@@ -262,6 +268,8 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
262
268
|
var handleInitialArrowPress = useCallback(function () {
|
263
269
|
// If activeCellCoordinates is null then we need to set an initial value
|
264
270
|
// which will place the activeCell on the select all cell/button
|
271
|
+
setActiveCellInsideSelectionArea(false);
|
272
|
+
|
265
273
|
if (!activeCellCoordinates) {
|
266
274
|
setActiveCellCoordinates({
|
267
275
|
column: 'header',
|
@@ -272,16 +280,20 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
272
280
|
return;
|
273
281
|
}, [activeCellCoordinates]);
|
274
282
|
var updateActiveCellCoordinates = useCallback(function (_ref3) {
|
275
|
-
var coords = _ref3.coords,
|
276
|
-
|
283
|
+
var _ref3$coords = _ref3.coords,
|
284
|
+
coords = _ref3$coords === void 0 ? _objectSpread({}, activeCellCoordinates) : _ref3$coords,
|
285
|
+
updatedValue = _ref3.updatedValue,
|
286
|
+
_ref3$optOutOfSelecti = _ref3.optOutOfSelectionAreaUpdate,
|
287
|
+
optOutOfSelectionAreaUpdate = _ref3$optOutOfSelecti === void 0 ? false : _ref3$optOutOfSelecti;
|
277
288
|
|
278
289
|
var newActiveCell = _objectSpread(_objectSpread({}, coords), updatedValue);
|
279
290
|
|
280
291
|
setActiveCellCoordinates(newActiveCell); // Only run if the active cell is _not_ a header cell. This will add a point1 object
|
281
292
|
// to selectionAreas every time the active cell changes, allowing us to create cell
|
282
|
-
// selections using keyboard
|
293
|
+
// selections using keyboard. Opting out of the selection area updates here means
|
294
|
+
// that the active cell is being moved within a selection area
|
283
295
|
|
284
|
-
if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header') {
|
296
|
+
if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header' && !optOutOfSelectionAreaUpdate) {
|
285
297
|
var tempMatcher = uuidv4();
|
286
298
|
setSelectionAreas([{
|
287
299
|
point1: newActiveCell,
|
@@ -289,11 +301,29 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
289
301
|
}]);
|
290
302
|
setCurrentMatcher(tempMatcher);
|
291
303
|
}
|
292
|
-
}, []);
|
304
|
+
}, [activeCellCoordinates]);
|
305
|
+
var handleHomeEndKey = useCallback(function (_ref4) {
|
306
|
+
var type = _ref4.type;
|
307
|
+
|
308
|
+
var coordinatesClone = _objectSpread({}, activeCellCoordinates);
|
309
|
+
|
310
|
+
updateActiveCellCoordinates({
|
311
|
+
coords: coordinatesClone,
|
312
|
+
updatedValue: {
|
313
|
+
column: type === 'home' ? 0 : columns.length - 1
|
314
|
+
}
|
315
|
+
});
|
316
|
+
removeCellSelections({
|
317
|
+
spreadsheetRef: spreadsheetRef
|
318
|
+
});
|
319
|
+
}, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
|
293
320
|
var handleKeyPress = useCallback(function (event) {
|
294
|
-
var
|
321
|
+
var key = event.key;
|
322
|
+
|
323
|
+
if (isEditing) {
|
324
|
+
return;
|
325
|
+
} // Command keys need to be returned as there is default browser behavior with these keys
|
295
326
|
|
296
|
-
var key = event.key; // Command keys need to be returned as there is default browser behavior with these keys
|
297
327
|
|
298
328
|
if (key === 'Meta' || key === 'Control') {
|
299
329
|
return;
|
@@ -310,44 +340,90 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
310
340
|
|
311
341
|
|
312
342
|
if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
|
313
|
-
if (
|
314
|
-
return;
|
315
|
-
}
|
316
|
-
|
317
|
-
if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && key !== 'Shift' && !activeKeys.current.includes('Shift')) {
|
343
|
+
if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && keysPressedList.length < 2 && !includesShift(keysPressedList)) {
|
318
344
|
setSelectionAreas([]);
|
319
345
|
setSelectionAreaData([]);
|
320
346
|
removeCellSelections({
|
321
347
|
spreadsheetRef: spreadsheetRef
|
322
348
|
});
|
323
349
|
}
|
324
|
-
} // Update list of activeKeys
|
325
|
-
|
326
|
-
|
327
|
-
if (!((_activeKeys$current = activeKeys.current) !== null && _activeKeys$current !== void 0 && _activeKeys$current.includes(key))) {
|
328
|
-
var activeClone = _toConsumableArray(activeKeys.current);
|
329
|
-
|
330
|
-
activeKeys.current = [].concat(_toConsumableArray(activeClone), [key]);
|
331
350
|
}
|
332
351
|
|
333
|
-
if (
|
352
|
+
if (!isEditing && (keysPressedList === null || keysPressedList === void 0 ? void 0 : keysPressedList.length) > 1) {
|
334
353
|
handleMultipleKeys({
|
335
|
-
|
354
|
+
activeCellCoordinates: activeCellCoordinates,
|
355
|
+
event: event,
|
356
|
+
keysPressedList: keysPressedList,
|
336
357
|
selectionAreas: selectionAreas,
|
337
358
|
currentMatcher: currentMatcher,
|
338
359
|
rows: rows,
|
339
360
|
setSelectionAreas: setSelectionAreas,
|
340
|
-
columns: columns
|
361
|
+
columns: columns,
|
362
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates,
|
363
|
+
spreadsheetRef: spreadsheetRef,
|
364
|
+
removeCellSelections: removeCellSelections,
|
365
|
+
blockClass: blockClass,
|
366
|
+
setCurrentMatcher: setCurrentMatcher,
|
367
|
+
usingMac: usingMac
|
341
368
|
});
|
342
369
|
} // Allow arrow key navigation if there are less than two activeKeys OR
|
343
370
|
// if one of the activeCellCoordinates is in a header position
|
344
371
|
|
345
372
|
|
346
|
-
if (!
|
373
|
+
if (keysPressedList.length < 2 && !includesShift(keysPressedList) || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
|
347
374
|
switch (key) {
|
375
|
+
// Enter
|
376
|
+
case 'Enter':
|
377
|
+
{
|
378
|
+
handleActiveCellInSelectionEnter({
|
379
|
+
activeCellInsideSelectionArea: activeCellInsideSelectionArea,
|
380
|
+
activeCellCoordinates: activeCellCoordinates,
|
381
|
+
activeCellRef: activeCellRef,
|
382
|
+
selectionAreas: selectionAreas,
|
383
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
384
|
+
});
|
385
|
+
break;
|
386
|
+
}
|
387
|
+
// HOME
|
388
|
+
|
389
|
+
case 'Home':
|
390
|
+
{
|
391
|
+
if (includesResourceKey(keysPressedList, usingMac)) {
|
392
|
+
return;
|
393
|
+
}
|
394
|
+
|
395
|
+
handleHomeEndKey({
|
396
|
+
type: 'home'
|
397
|
+
});
|
398
|
+
break;
|
399
|
+
}
|
400
|
+
|
401
|
+
case 'End':
|
402
|
+
{
|
403
|
+
if (includesResourceKey(keysPressedList, usingMac)) {
|
404
|
+
return;
|
405
|
+
}
|
406
|
+
|
407
|
+
handleHomeEndKey({
|
408
|
+
type: 'end'
|
409
|
+
});
|
410
|
+
break;
|
411
|
+
}
|
348
412
|
// Tab
|
413
|
+
|
349
414
|
case 'Tab':
|
350
415
|
{
|
416
|
+
if (activeCellInsideSelectionArea) {
|
417
|
+
event.preventDefault();
|
418
|
+
return handleActiveCellInSelectionTab({
|
419
|
+
activeCellInsideSelectionArea: activeCellInsideSelectionArea,
|
420
|
+
activeCellCoordinates: activeCellCoordinates,
|
421
|
+
activeCellRef: activeCellRef,
|
422
|
+
selectionAreas: selectionAreas,
|
423
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
424
|
+
});
|
425
|
+
}
|
426
|
+
|
351
427
|
setSelectionAreas([]);
|
352
428
|
removeActiveCell();
|
353
429
|
removeCellEditor();
|
@@ -494,24 +570,59 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
494
570
|
}
|
495
571
|
}
|
496
572
|
}
|
497
|
-
}, [updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor,
|
573
|
+
}, [activeCellInsideSelectionArea, updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac]);
|
498
574
|
|
499
575
|
var startEditMode = function startEditMode() {
|
500
576
|
setIsEditing(true);
|
501
577
|
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;
|
502
578
|
var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
503
579
|
setCellEditorValue(activeCellValue);
|
504
|
-
|
580
|
+
cellEditorRulerRef.current.textContent = activeCellValue;
|
581
|
+
}; // Sets the initial placement of the cell editor cursor at the end of the text area
|
582
|
+
// this is not done for us by default in Safari
|
583
|
+
|
584
|
+
|
585
|
+
useEffect(function () {
|
586
|
+
if (isEditing && !(previousState !== null && previousState !== void 0 && previousState.isEditing)) {
|
587
|
+
cellEditorRef.current.setSelectionRange(cellEditorRulerRef.current.textContent.length, cellEditorRulerRef.current.textContent.length);
|
588
|
+
cellEditorRef.current.focus();
|
589
|
+
}
|
590
|
+
}, [isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing]);
|
505
591
|
|
506
592
|
var handleActiveCellClick = function handleActiveCellClick() {
|
507
593
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
508
594
|
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;
|
595
|
+
|
596
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
597
|
+
return;
|
598
|
+
}
|
599
|
+
|
509
600
|
handleRowColumnHeaderClick({
|
510
601
|
isKeyboard: false,
|
511
602
|
index: indexValue
|
512
603
|
});
|
513
604
|
}
|
514
605
|
|
606
|
+
return;
|
607
|
+
}; // Mouse down on active cell
|
608
|
+
|
609
|
+
|
610
|
+
var handleActiveCellMouseDown = function handleActiveCellMouseDown() {
|
611
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
612
|
+
var tempMatcher = uuidv4();
|
613
|
+
setClickAndHoldActive(true);
|
614
|
+
removeCellSelections({
|
615
|
+
spreadsheetRef: spreadsheetRef
|
616
|
+
});
|
617
|
+
setSelectionAreas([{
|
618
|
+
point1: activeCellCoordinates,
|
619
|
+
matcher: tempMatcher
|
620
|
+
}]);
|
621
|
+
setCurrentMatcher(tempMatcher);
|
622
|
+
setSelectionAreaData([]);
|
623
|
+
setActiveCellInsideSelectionArea(false);
|
624
|
+
}
|
625
|
+
|
515
626
|
return;
|
516
627
|
}; // Go into edit mode if 'Enter' key is pressed on activeCellRef
|
517
628
|
|
@@ -519,7 +630,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
519
630
|
var handleActiveCellKeyDown = function handleActiveCellKeyDown(event) {
|
520
631
|
var key = event.key;
|
521
632
|
|
522
|
-
if (key === 'Enter') {
|
633
|
+
if (key === 'Enter' && !activeCellInsideSelectionArea) {
|
523
634
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
|
524
635
|
startEditMode();
|
525
636
|
}
|
@@ -532,10 +643,10 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
532
643
|
}
|
533
644
|
};
|
534
645
|
|
535
|
-
var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(
|
536
|
-
var isKeyboard =
|
537
|
-
|
538
|
-
index =
|
646
|
+
var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref5) {
|
647
|
+
var isKeyboard = _ref5.isKeyboard,
|
648
|
+
_ref5$index = _ref5.index,
|
649
|
+
index = _ref5$index === void 0 ? null : _ref5$index;
|
539
650
|
var handleHeaderCellProps = {
|
540
651
|
activeCellCoordinates: activeCellCoordinates,
|
541
652
|
rows: rows,
|
@@ -549,113 +660,100 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
549
660
|
index: index
|
550
661
|
}; // Select an entire column
|
551
662
|
|
552
|
-
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
|
663
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
553
664
|
handleHeaderCellSelection(_objectSpread({
|
554
665
|
type: 'column'
|
555
666
|
}, handleHeaderCellProps));
|
556
667
|
} // Select an entire row
|
557
668
|
|
558
669
|
|
559
|
-
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
670
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
|
560
671
|
handleHeaderCellSelection(_objectSpread({
|
561
672
|
type: 'row'
|
562
673
|
}, handleHeaderCellProps));
|
563
674
|
}
|
564
|
-
}; // Go into edit mode if double click is detected on activeCellRef
|
565
|
-
|
566
|
-
|
567
|
-
var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
|
568
|
-
startEditMode();
|
569
|
-
}; // Update the data
|
570
|
-
|
571
|
-
|
572
|
-
var handleEditSubmit = function handleEditSubmit(event) {
|
573
|
-
var key = event.key;
|
574
|
-
|
575
|
-
var submitEditChanges = function submitEditChanges() {
|
576
|
-
var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
|
577
|
-
var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
|
578
|
-
removeCellEditor();
|
579
|
-
updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
|
580
|
-
};
|
581
675
|
|
582
|
-
if (
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
676
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
|
677
|
+
selectAllCells({
|
678
|
+
ref: spreadsheetRef,
|
679
|
+
setCurrentMatcher: setCurrentMatcher,
|
680
|
+
setSelectionAreas: setSelectionAreas,
|
681
|
+
rows: rows,
|
682
|
+
columns: columns,
|
683
|
+
activeCellCoordinates: activeCellCoordinates,
|
684
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
589
685
|
});
|
590
686
|
}
|
687
|
+
}; // Go into edit mode if double click is detected on activeCellRef
|
591
688
|
|
592
|
-
if (key === 'Tab') {
|
593
|
-
event.preventDefault();
|
594
|
-
submitEditChanges();
|
595
|
-
setActiveCellCoordinates(function (prev) {
|
596
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
597
|
-
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
|
598
|
-
|
599
|
-
});
|
600
|
-
});
|
601
|
-
}
|
602
689
|
|
603
|
-
|
690
|
+
var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
|
691
|
+
startEditMode();
|
604
692
|
};
|
605
693
|
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
activeCellRef.current.focus();
|
694
|
+
useSpreadsheetEdit({
|
695
|
+
isEditing: isEditing,
|
696
|
+
rows: rows,
|
697
|
+
activeCellCoordinates: activeCellCoordinates,
|
698
|
+
activeCellRef: activeCellRef,
|
699
|
+
cellEditorRef: cellEditorRef,
|
700
|
+
cellEditorRulerRef: cellEditorRulerRef,
|
701
|
+
columns: columns,
|
702
|
+
defaultColumn: defaultColumn,
|
703
|
+
cellEditorValue: cellEditorValue
|
704
|
+
});
|
705
|
+
var handleActiveCellMouseEnter = useCallback(function () {
|
706
|
+
handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
|
707
|
+
}, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]); // Only update if there are cell selection areas
|
708
|
+
// Find point object that matches currentMatcher and remove the second point
|
709
|
+
// because hovering over the active cell while clicking and holding should
|
710
|
+
// remove the previously existing selection area
|
711
|
+
|
712
|
+
var handleActiveCellMouseEnterCallback = useCallback(function (areas, clickHold) {
|
713
|
+
if (!currentMatcher) {
|
714
|
+
return;
|
628
715
|
}
|
629
|
-
}, [isEditing, activeCellCoordinates, rows]);
|
630
716
|
|
631
|
-
|
632
|
-
|
717
|
+
if (areas && areas.length && clickHold && currentMatcher) {
|
718
|
+
setSelectionAreas(function (prev) {
|
719
|
+
var selectionAreaClone = deepCloneObject(prev);
|
720
|
+
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
721
|
+
return item.matcher === currentMatcher;
|
722
|
+
});
|
633
723
|
|
634
|
-
|
724
|
+
if (indexOfItemToUpdate === -1) {
|
725
|
+
return prev;
|
726
|
+
}
|
635
727
|
|
636
|
-
|
637
|
-
|
728
|
+
if (_typeof(selectionAreaClone[indexOfItemToUpdate].point2) === 'object' && selectionAreaClone[indexOfItemToUpdate].areaCreated) {
|
729
|
+
selectionAreaClone[indexOfItemToUpdate].point2 = selectionAreaClone[indexOfItemToUpdate].point1;
|
730
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
731
|
+
setActiveCellInsideSelectionArea(false);
|
732
|
+
removeCellSelections({
|
733
|
+
matcher: currentMatcher,
|
734
|
+
spreadsheetRef: spreadsheetRef
|
735
|
+
});
|
736
|
+
return selectionAreaClone;
|
737
|
+
}
|
638
738
|
|
639
|
-
|
640
|
-
return item !== key;
|
739
|
+
return prev;
|
641
740
|
});
|
642
|
-
activeKeys.current = filteredKeysClone;
|
643
741
|
}
|
644
|
-
};
|
645
|
-
|
742
|
+
}, [spreadsheetRef, currentMatcher]);
|
646
743
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, getTableProps(), getDevtoolsProps(componentName), {
|
647
|
-
className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
|
744
|
+
className: cx(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), _defineProperty({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
|
648
745
|
ref: spreadsheetRef,
|
649
746
|
role: "grid",
|
650
747
|
tabIndex: 0,
|
651
748
|
"aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
|
652
749
|
"aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
|
653
750
|
onKeyDown: handleKeyPress,
|
654
|
-
onKeyUp: handleKeyUp,
|
655
751
|
onFocus: function onFocus() {
|
656
752
|
return setContainerHasFocus(true);
|
657
753
|
}
|
658
|
-
}), /*#__PURE__*/React.createElement(
|
754
|
+
}), /*#__PURE__*/React.createElement("div", {
|
755
|
+
ref: multiKeyTrackingRef
|
756
|
+
}, /*#__PURE__*/React.createElement(DataSpreadsheetHeader, {
|
659
757
|
ref: spreadsheetRef,
|
660
758
|
activeCellCoordinates: activeCellCoordinates,
|
661
759
|
cellSize: cellSize,
|
@@ -668,7 +766,8 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
668
766
|
setActiveCellCoordinates: setActiveCellCoordinates,
|
669
767
|
setSelectionAreas: setSelectionAreas,
|
670
768
|
setCurrentMatcher: setCurrentMatcher,
|
671
|
-
setSelectionAreaData: setSelectionAreaData
|
769
|
+
setSelectionAreaData: setSelectionAreaData,
|
770
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
672
771
|
}), /*#__PURE__*/React.createElement(DataSpreadsheetBody, {
|
673
772
|
activeCellCoordinates: activeCellCoordinates,
|
674
773
|
ref: spreadsheetRef,
|
@@ -680,8 +779,10 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
680
779
|
selectionAreas: selectionAreas,
|
681
780
|
setSelectionAreas: setSelectionAreas,
|
682
781
|
cellSize: cellSize,
|
782
|
+
headerGroups: headerGroups,
|
683
783
|
defaultColumn: defaultColumn,
|
684
784
|
getTableBodyProps: getTableBodyProps,
|
785
|
+
onDataUpdate: onDataUpdate,
|
685
786
|
onActiveCellChange: onActiveCellChange,
|
686
787
|
onSelectionAreaChange: onSelectionAreaChange,
|
687
788
|
prepareRow: prepareRow,
|
@@ -692,25 +793,46 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
692
793
|
scrollBarSize: scrollBarSize,
|
693
794
|
totalColumnsWidth: totalColumnsWidth,
|
694
795
|
id: id,
|
695
|
-
columns: columns
|
796
|
+
columns: columns,
|
797
|
+
defaultEmptyRowCount: defaultEmptyRowCount,
|
798
|
+
setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea
|
696
799
|
}), /*#__PURE__*/React.createElement("button", {
|
800
|
+
onMouseDown: handleActiveCellMouseDown,
|
697
801
|
onClick: handleActiveCellClick,
|
698
802
|
onKeyDown: handleActiveCellKeyDown,
|
699
803
|
onDoubleClick: handleActiveCellDoubleClick,
|
804
|
+
onMouseEnter: handleActiveCellMouseEnter,
|
700
805
|
ref: activeCellRef,
|
701
|
-
className: cx("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight")),
|
806
|
+
className: cx("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight"), _defineProperty({}, "".concat(blockClass, "__active-cell--with-selection"), activeCellInsideSelectionArea)),
|
702
807
|
type: "button"
|
703
808
|
}, activeCellContent), /*#__PURE__*/React.createElement(TextArea, {
|
704
809
|
value: cellEditorValue,
|
705
|
-
onKeyDown: handleEditSubmit
|
810
|
+
onKeyDown: handleEditSubmit({
|
811
|
+
activeCellCoordinates: activeCellCoordinates,
|
812
|
+
cellEditorRulerRef: cellEditorRulerRef,
|
813
|
+
columns: columns,
|
814
|
+
previousState: previousState,
|
815
|
+
removeCellEditor: removeCellEditor,
|
816
|
+
rows: rows,
|
817
|
+
setActiveCellCoordinates: setActiveCellCoordinates,
|
818
|
+
setCurrentMatcher: setCurrentMatcher,
|
819
|
+
setSelectionAreas: setSelectionAreas,
|
820
|
+
spreadsheetRef: spreadsheetRef,
|
821
|
+
updateData: updateData
|
822
|
+
}),
|
706
823
|
onChange: function onChange(event) {
|
707
|
-
|
824
|
+
setCellEditorValue(event.target.value);
|
825
|
+
cellEditorRulerRef.current.textContent = event.target.value;
|
708
826
|
},
|
709
827
|
ref: cellEditorRef,
|
710
828
|
labelText: "",
|
711
|
-
"aria-labelledby": activeCellCoordinates ? "
|
829
|
+
"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,
|
712
830
|
className: cx("".concat(blockClass, "__cell-editor"), "".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__cell-editor--").concat(cellSize), _defineProperty({}, "".concat(blockClass, "__cell-editor--active"), isEditing))
|
713
|
-
})
|
831
|
+
}), /*#__PURE__*/React.createElement("pre", {
|
832
|
+
"aria-hidden": true,
|
833
|
+
ref: cellEditorRulerRef,
|
834
|
+
className: "".concat(blockClass, "__cell-editor-ruler")
|
835
|
+
})));
|
714
836
|
}); // Return a placeholder if not released and not enabled by feature flag
|
715
837
|
|
716
838
|
DataSpreadsheet = pkg.checkComponentEnabled(DataSpreadsheet, componentName); // The display name of the component, used by React. Note that displayName
|
@@ -746,6 +868,11 @@ DataSpreadsheet.propTypes = {
|
|
746
868
|
*/
|
747
869
|
data: PropTypes.arrayOf(PropTypes.shape),
|
748
870
|
|
871
|
+
/**
|
872
|
+
* Sets the number of empty rows to be created when there is no data provided
|
873
|
+
*/
|
874
|
+
defaultEmptyRowCount: PropTypes.number,
|
875
|
+
|
749
876
|
/**
|
750
877
|
* The spreadsheet id
|
751
878
|
*/
|