@carbon/ibm-products 1.13.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +268 -0
- package/css/components/Datagrid/styles/datagrid.css.map +1 -0
- package/css/components/Datagrid/styles/index.css +513 -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 +611 -10
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +7 -4
- 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 +611 -10
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +611 -10
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +106 -43
- package/es/components/AddSelect/AddSelectFilter.js +172 -0
- package/es/components/AddSelect/add-select-utils.js +30 -0
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +255 -175
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +78 -17
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +65 -20
- 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 +1 -3
- package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +20 -8
- package/es/components/DataSpreadsheet/utils/generateData.js +17 -9
- package/es/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +18 -0
- package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +30 -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 +60 -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/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 +13 -6
- package/es/components/Tearsheet/TearsheetShell.js +34 -10
- package/es/components/index.js +2 -1
- package/es/global/js/package-settings.js +4 -2
- package/lib/components/AddSelect/AddSelect.js +105 -41
- package/lib/components/AddSelect/AddSelectFilter.js +190 -0
- package/lib/components/AddSelect/add-select-utils.js +35 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +261 -177
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +79 -23
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +67 -21
- 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 +1 -3
- package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +21 -8
- package/lib/components/DataSpreadsheet/utils/generateData.js +17 -9
- package/lib/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +27 -0
- package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +40 -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 +68 -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/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 +13 -6
- package/lib/components/Tearsheet/TearsheetShell.js +36 -10
- package/lib/components/index.js +9 -1
- package/lib/global/js/package-settings.js +4 -2
- package/package.json +16 -12
- package/scss/components/AboutModal/_about-modal.scss +4 -0
- package/scss/components/AddSelect/_add-select.scss +46 -2
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +41 -4
- 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 +326 -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/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
|
|
|
@@ -23,8 +23,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
23
23
|
|
|
24
24
|
var _reactTable = require("react-table");
|
|
25
25
|
|
|
26
|
-
var _layout = require("@carbon/layout");
|
|
27
|
-
|
|
28
26
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
27
|
|
|
30
28
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -45,11 +43,9 @@ var _hooks = require("../../global/js/hooks");
|
|
|
45
43
|
|
|
46
44
|
var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
|
|
47
45
|
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
var _useSpreadsheetOutsideClick = require("./hooks/useSpreadsheetOutsideClick");
|
|
46
|
+
var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
|
|
51
47
|
|
|
52
|
-
var
|
|
48
|
+
var _hooks2 = require("./hooks");
|
|
53
49
|
|
|
54
50
|
var _createActiveCellFn = require("./utils/createActiveCellFn");
|
|
55
51
|
|
|
@@ -61,11 +57,19 @@ var _handleHeaderCellSelection = require("./utils/handleHeaderCellSelection");
|
|
|
61
57
|
|
|
62
58
|
var _removeCellSelections = require("./utils/removeCellSelections");
|
|
63
59
|
|
|
64
|
-
var
|
|
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", "totalVisibleColumns"];
|
|
65
69
|
|
|
66
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); }
|
|
67
71
|
|
|
68
|
-
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; }
|
|
69
73
|
|
|
70
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; }
|
|
71
75
|
|
|
@@ -106,7 +110,9 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
106
110
|
onActiveCellChange = _ref$onActiveCellChan === void 0 ? defaults.onActiveCellChange : _ref$onActiveCellChan,
|
|
107
111
|
_ref$onSelectionAreaC = _ref.onSelectionAreaChange,
|
|
108
112
|
onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
|
|
113
|
+
totalVisibleColumns = _ref.totalVisibleColumns,
|
|
109
114
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
115
|
+
var multiKeyTrackingRef = (0, _react.useRef)();
|
|
110
116
|
var localRef = (0, _react.useRef)();
|
|
111
117
|
var spreadsheetRef = ref || localRef;
|
|
112
118
|
var focusedElement = (0, _hooks.useActiveElement)();
|
|
@@ -151,18 +157,23 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
151
157
|
cellEditorValue = _useState16[0],
|
|
152
158
|
setCellEditorValue = _useState16[1];
|
|
153
159
|
|
|
160
|
+
var _useState17 = (0, _react.useState)(false),
|
|
161
|
+
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
|
162
|
+
activeCellInsideSelectionArea = _useState18[0],
|
|
163
|
+
setActiveCellInsideSelectionArea = _useState18[1];
|
|
164
|
+
|
|
154
165
|
var previousState = (0, _hooks.usePreviousValue)({
|
|
155
|
-
activeCellCoordinates: activeCellCoordinates
|
|
166
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
167
|
+
isEditing: isEditing
|
|
156
168
|
});
|
|
157
169
|
var cellSizeValue = (0, _getCellSize.getCellSize)(cellSize);
|
|
158
170
|
var cellEditorRef = (0, _react.useRef)();
|
|
159
171
|
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
activeCellContent =
|
|
163
|
-
setActiveCellContent =
|
|
172
|
+
var _useState19 = (0, _react.useState)(),
|
|
173
|
+
_useState20 = (0, _slicedToArray2.default)(_useState19, 2),
|
|
174
|
+
activeCellContent = _useState20[0],
|
|
175
|
+
setActiveCellContent = _useState20[1];
|
|
164
176
|
|
|
165
|
-
var activeKeys = (0, _react.useRef)([]);
|
|
166
177
|
var activeCellRef = (0, _react.useRef)();
|
|
167
178
|
var cellEditorRulerRef = (0, _react.useRef)();
|
|
168
179
|
var defaultColumn = (0, _react.useMemo)(function () {
|
|
@@ -172,6 +183,15 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
172
183
|
rowHeight: cellSizeValue
|
|
173
184
|
};
|
|
174
185
|
}, [cellSizeValue]);
|
|
186
|
+
|
|
187
|
+
var _useMultipleKeyTracki = (0, _hooks2.useMultipleKeyTracking)({
|
|
188
|
+
ref: multiKeyTrackingRef,
|
|
189
|
+
containerHasFocus: containerHasFocus,
|
|
190
|
+
isEditing: isEditing
|
|
191
|
+
}),
|
|
192
|
+
keysPressedList = _useMultipleKeyTracki.keysPressedList,
|
|
193
|
+
usingMac = _useMultipleKeyTracki.usingMac;
|
|
194
|
+
|
|
175
195
|
var scrollBarSize = (0, _react.useMemo)(function () {
|
|
176
196
|
return (0, _getScrollbarWidth.getScrollbarWidth)();
|
|
177
197
|
}, []);
|
|
@@ -260,23 +280,21 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
260
280
|
});
|
|
261
281
|
}
|
|
262
282
|
}, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
|
|
263
|
-
(0,
|
|
264
|
-
activeKeys: activeKeys,
|
|
283
|
+
(0, _hooks2.useResetSpreadsheetFocus)({
|
|
265
284
|
focusedElement: focusedElement,
|
|
266
285
|
removeActiveCell: removeActiveCell,
|
|
267
286
|
setContainerHasFocus: setContainerHasFocus
|
|
268
287
|
});
|
|
269
|
-
(0,
|
|
288
|
+
(0, _hooks2.useSpreadsheetOutsideClick)({
|
|
270
289
|
spreadsheetRef: spreadsheetRef,
|
|
271
290
|
setActiveCellCoordinates: setActiveCellCoordinates,
|
|
272
291
|
setSelectionAreas: setSelectionAreas,
|
|
273
292
|
removeActiveCell: removeActiveCell,
|
|
274
293
|
removeCellSelections: _removeCellSelections.removeCellSelections,
|
|
275
294
|
setContainerHasFocus: setContainerHasFocus,
|
|
276
|
-
activeKeys: activeKeys,
|
|
277
295
|
removeCellEditor: removeCellEditor
|
|
278
296
|
});
|
|
279
|
-
(0,
|
|
297
|
+
(0, _hooks2.useMoveActiveCell)({
|
|
280
298
|
spreadsheetRef: spreadsheetRef,
|
|
281
299
|
activeCellCoordinates: activeCellCoordinates,
|
|
282
300
|
containerHasFocus: containerHasFocus,
|
|
@@ -285,6 +303,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
285
303
|
var handleInitialArrowPress = (0, _react.useCallback)(function () {
|
|
286
304
|
// If activeCellCoordinates is null then we need to set an initial value
|
|
287
305
|
// which will place the activeCell on the select all cell/button
|
|
306
|
+
setActiveCellInsideSelectionArea(false);
|
|
307
|
+
|
|
288
308
|
if (!activeCellCoordinates) {
|
|
289
309
|
setActiveCellCoordinates({
|
|
290
310
|
column: 'header',
|
|
@@ -295,16 +315,20 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
295
315
|
return;
|
|
296
316
|
}, [activeCellCoordinates]);
|
|
297
317
|
var updateActiveCellCoordinates = (0, _react.useCallback)(function (_ref3) {
|
|
298
|
-
var coords = _ref3.coords,
|
|
299
|
-
|
|
318
|
+
var _ref3$coords = _ref3.coords,
|
|
319
|
+
coords = _ref3$coords === void 0 ? _objectSpread({}, activeCellCoordinates) : _ref3$coords,
|
|
320
|
+
updatedValue = _ref3.updatedValue,
|
|
321
|
+
_ref3$optOutOfSelecti = _ref3.optOutOfSelectionAreaUpdate,
|
|
322
|
+
optOutOfSelectionAreaUpdate = _ref3$optOutOfSelecti === void 0 ? false : _ref3$optOutOfSelecti;
|
|
300
323
|
|
|
301
324
|
var newActiveCell = _objectSpread(_objectSpread({}, coords), updatedValue);
|
|
302
325
|
|
|
303
326
|
setActiveCellCoordinates(newActiveCell); // Only run if the active cell is _not_ a header cell. This will add a point1 object
|
|
304
327
|
// to selectionAreas every time the active cell changes, allowing us to create cell
|
|
305
|
-
// selections using keyboard
|
|
328
|
+
// selections using keyboard. Opting out of the selection area updates here means
|
|
329
|
+
// that the active cell is being moved within a selection area
|
|
306
330
|
|
|
307
|
-
if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header') {
|
|
331
|
+
if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header' && !optOutOfSelectionAreaUpdate) {
|
|
308
332
|
var tempMatcher = (0, _uuidv.default)();
|
|
309
333
|
setSelectionAreas([{
|
|
310
334
|
point1: newActiveCell,
|
|
@@ -312,11 +336,29 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
312
336
|
}]);
|
|
313
337
|
setCurrentMatcher(tempMatcher);
|
|
314
338
|
}
|
|
315
|
-
}, []);
|
|
339
|
+
}, [activeCellCoordinates]);
|
|
340
|
+
var handleHomeEndKey = (0, _react.useCallback)(function (_ref4) {
|
|
341
|
+
var type = _ref4.type;
|
|
342
|
+
|
|
343
|
+
var coordinatesClone = _objectSpread({}, activeCellCoordinates);
|
|
344
|
+
|
|
345
|
+
updateActiveCellCoordinates({
|
|
346
|
+
coords: coordinatesClone,
|
|
347
|
+
updatedValue: {
|
|
348
|
+
column: type === 'home' ? 0 : columns.length - 1
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
(0, _removeCellSelections.removeCellSelections)({
|
|
352
|
+
spreadsheetRef: spreadsheetRef
|
|
353
|
+
});
|
|
354
|
+
}, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
|
|
316
355
|
var handleKeyPress = (0, _react.useCallback)(function (event) {
|
|
317
|
-
var
|
|
356
|
+
var key = event.key;
|
|
357
|
+
|
|
358
|
+
if (isEditing) {
|
|
359
|
+
return;
|
|
360
|
+
} // Command keys need to be returned as there is default browser behavior with these keys
|
|
318
361
|
|
|
319
|
-
var key = event.key; // Command keys need to be returned as there is default browser behavior with these keys
|
|
320
362
|
|
|
321
363
|
if (key === 'Meta' || key === 'Control') {
|
|
322
364
|
return;
|
|
@@ -333,43 +375,90 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
333
375
|
|
|
334
376
|
|
|
335
377
|
if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
|
|
336
|
-
if (
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && key !== 'Shift' && !activeKeys.current.includes('Shift')) {
|
|
378
|
+
if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && keysPressedList.length < 2 && !(0, _handleMultipleKeys.includesShift)(keysPressedList)) {
|
|
341
379
|
setSelectionAreas([]);
|
|
342
380
|
setSelectionAreaData([]);
|
|
343
381
|
(0, _removeCellSelections.removeCellSelections)({
|
|
344
382
|
spreadsheetRef: spreadsheetRef
|
|
345
383
|
});
|
|
346
384
|
}
|
|
347
|
-
} // Update list of activeKeys
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (!((_activeKeys$current = activeKeys.current) !== null && _activeKeys$current !== void 0 && _activeKeys$current.includes(key))) {
|
|
351
|
-
var activeClone = (0, _toConsumableArray2.default)(activeKeys.current);
|
|
352
|
-
activeKeys.current = [].concat((0, _toConsumableArray2.default)(activeClone), [key]);
|
|
353
385
|
}
|
|
354
386
|
|
|
355
|
-
if (
|
|
387
|
+
if (!isEditing && (keysPressedList === null || keysPressedList === void 0 ? void 0 : keysPressedList.length) > 1) {
|
|
356
388
|
(0, _handleMultipleKeys.handleMultipleKeys)({
|
|
357
|
-
|
|
389
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
390
|
+
event: event,
|
|
391
|
+
keysPressedList: keysPressedList,
|
|
358
392
|
selectionAreas: selectionAreas,
|
|
359
393
|
currentMatcher: currentMatcher,
|
|
360
394
|
rows: rows,
|
|
361
395
|
setSelectionAreas: setSelectionAreas,
|
|
362
|
-
columns: columns
|
|
396
|
+
columns: columns,
|
|
397
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates,
|
|
398
|
+
spreadsheetRef: spreadsheetRef,
|
|
399
|
+
removeCellSelections: _removeCellSelections.removeCellSelections,
|
|
400
|
+
blockClass: blockClass,
|
|
401
|
+
setCurrentMatcher: setCurrentMatcher,
|
|
402
|
+
usingMac: usingMac
|
|
363
403
|
});
|
|
364
404
|
} // Allow arrow key navigation if there are less than two activeKeys OR
|
|
365
405
|
// if one of the activeCellCoordinates is in a header position
|
|
366
406
|
|
|
367
407
|
|
|
368
|
-
if (!
|
|
408
|
+
if (keysPressedList.length < 2 && !(0, _handleMultipleKeys.includesShift)(keysPressedList) || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
|
|
369
409
|
switch (key) {
|
|
410
|
+
// Enter
|
|
411
|
+
case 'Enter':
|
|
412
|
+
{
|
|
413
|
+
(0, _handleActiveCellInSelectionEnter.handleActiveCellInSelectionEnter)({
|
|
414
|
+
activeCellInsideSelectionArea: activeCellInsideSelectionArea,
|
|
415
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
416
|
+
activeCellRef: activeCellRef,
|
|
417
|
+
selectionAreas: selectionAreas,
|
|
418
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
|
419
|
+
});
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
// HOME
|
|
423
|
+
|
|
424
|
+
case 'Home':
|
|
425
|
+
{
|
|
426
|
+
if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac)) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
handleHomeEndKey({
|
|
431
|
+
type: 'home'
|
|
432
|
+
});
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
case 'End':
|
|
437
|
+
{
|
|
438
|
+
if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac)) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
handleHomeEndKey({
|
|
443
|
+
type: 'end'
|
|
444
|
+
});
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
370
447
|
// Tab
|
|
448
|
+
|
|
371
449
|
case 'Tab':
|
|
372
450
|
{
|
|
451
|
+
if (activeCellInsideSelectionArea) {
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
return (0, _handleActiveCellInSelectionTab.handleActiveCellInSelectionTab)({
|
|
454
|
+
activeCellInsideSelectionArea: activeCellInsideSelectionArea,
|
|
455
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
456
|
+
activeCellRef: activeCellRef,
|
|
457
|
+
selectionAreas: selectionAreas,
|
|
458
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
|
|
373
462
|
setSelectionAreas([]);
|
|
374
463
|
removeActiveCell();
|
|
375
464
|
removeCellEditor();
|
|
@@ -516,7 +605,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
516
605
|
}
|
|
517
606
|
}
|
|
518
607
|
}
|
|
519
|
-
}, [updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, selectionAreas]);
|
|
608
|
+
}, [activeCellInsideSelectionArea, updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac]);
|
|
520
609
|
|
|
521
610
|
var startEditMode = function startEditMode() {
|
|
522
611
|
setIsEditing(true);
|
|
@@ -524,17 +613,51 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
524
613
|
var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
|
525
614
|
setCellEditorValue(activeCellValue);
|
|
526
615
|
cellEditorRulerRef.current.textContent = activeCellValue;
|
|
527
|
-
};
|
|
616
|
+
}; // Sets the initial placement of the cell editor cursor at the end of the text area
|
|
617
|
+
// this is not done for us by default in Safari
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
(0, _react.useEffect)(function () {
|
|
621
|
+
if (isEditing && !(previousState !== null && previousState !== void 0 && previousState.isEditing)) {
|
|
622
|
+
cellEditorRef.current.setSelectionRange(cellEditorRulerRef.current.textContent.length, cellEditorRulerRef.current.textContent.length);
|
|
623
|
+
cellEditorRef.current.focus();
|
|
624
|
+
}
|
|
625
|
+
}, [isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing]);
|
|
528
626
|
|
|
529
627
|
var handleActiveCellClick = function handleActiveCellClick() {
|
|
530
628
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
|
531
629
|
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;
|
|
630
|
+
|
|
631
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
|
|
532
635
|
handleRowColumnHeaderClick({
|
|
533
636
|
isKeyboard: false,
|
|
534
637
|
index: indexValue
|
|
535
638
|
});
|
|
536
639
|
}
|
|
537
640
|
|
|
641
|
+
return;
|
|
642
|
+
}; // Mouse down on active cell
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
var handleActiveCellMouseDown = function handleActiveCellMouseDown() {
|
|
646
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
|
647
|
+
var tempMatcher = (0, _uuidv.default)();
|
|
648
|
+
setClickAndHoldActive(true);
|
|
649
|
+
(0, _removeCellSelections.removeCellSelections)({
|
|
650
|
+
spreadsheetRef: spreadsheetRef
|
|
651
|
+
});
|
|
652
|
+
setSelectionAreas([{
|
|
653
|
+
point1: activeCellCoordinates,
|
|
654
|
+
matcher: tempMatcher
|
|
655
|
+
}]);
|
|
656
|
+
setCurrentMatcher(tempMatcher);
|
|
657
|
+
setSelectionAreaData([]);
|
|
658
|
+
setActiveCellInsideSelectionArea(false);
|
|
659
|
+
}
|
|
660
|
+
|
|
538
661
|
return;
|
|
539
662
|
}; // Go into edit mode if 'Enter' key is pressed on activeCellRef
|
|
540
663
|
|
|
@@ -542,7 +665,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
542
665
|
var handleActiveCellKeyDown = function handleActiveCellKeyDown(event) {
|
|
543
666
|
var key = event.key;
|
|
544
667
|
|
|
545
|
-
if (key === 'Enter') {
|
|
668
|
+
if (key === 'Enter' && !activeCellInsideSelectionArea) {
|
|
546
669
|
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
|
|
547
670
|
startEditMode();
|
|
548
671
|
}
|
|
@@ -555,10 +678,10 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
555
678
|
}
|
|
556
679
|
};
|
|
557
680
|
|
|
558
|
-
var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(
|
|
559
|
-
var isKeyboard =
|
|
560
|
-
|
|
561
|
-
index =
|
|
681
|
+
var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref5) {
|
|
682
|
+
var isKeyboard = _ref5.isKeyboard,
|
|
683
|
+
_ref5$index = _ref5.index,
|
|
684
|
+
index = _ref5$index === void 0 ? null : _ref5$index;
|
|
562
685
|
var handleHeaderCellProps = {
|
|
563
686
|
activeCellCoordinates: activeCellCoordinates,
|
|
564
687
|
rows: rows,
|
|
@@ -572,18 +695,30 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
572
695
|
index: index
|
|
573
696
|
}; // Select an entire column
|
|
574
697
|
|
|
575
|
-
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
|
|
698
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
|
576
699
|
(0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
|
|
577
700
|
type: 'column'
|
|
578
701
|
}, handleHeaderCellProps));
|
|
579
702
|
} // Select an entire row
|
|
580
703
|
|
|
581
704
|
|
|
582
|
-
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
|
705
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
|
|
583
706
|
(0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
|
|
584
707
|
type: 'row'
|
|
585
708
|
}, handleHeaderCellProps));
|
|
586
709
|
}
|
|
710
|
+
|
|
711
|
+
if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
|
|
712
|
+
(0, _selectAllCells.selectAllCells)({
|
|
713
|
+
ref: spreadsheetRef,
|
|
714
|
+
setCurrentMatcher: setCurrentMatcher,
|
|
715
|
+
setSelectionAreas: setSelectionAreas,
|
|
716
|
+
rows: rows,
|
|
717
|
+
columns: columns,
|
|
718
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
719
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
|
720
|
+
});
|
|
721
|
+
}
|
|
587
722
|
}; // Go into edit mode if double click is detected on activeCellRef
|
|
588
723
|
|
|
589
724
|
|
|
@@ -591,131 +726,55 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
591
726
|
startEditMode();
|
|
592
727
|
};
|
|
593
728
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
point2: newSelectionArea,
|
|
616
|
-
matcher: tempMatcher,
|
|
617
|
-
areaCreated: false
|
|
618
|
-
}]);
|
|
619
|
-
setCurrentMatcher(tempMatcher);
|
|
620
|
-
cellEditorRulerRef.current.textContent = '';
|
|
621
|
-
}; // Update the data
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
var handleEditSubmit = function handleEditSubmit(event) {
|
|
625
|
-
var key = event.key;
|
|
626
|
-
|
|
627
|
-
if (key === 'Enter') {
|
|
628
|
-
updateSelectionAreaOnCellEditSubmit({
|
|
629
|
-
type: 'Enter'
|
|
630
|
-
});
|
|
631
|
-
setActiveCellCoordinates(function (prev) {
|
|
632
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
633
|
-
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
|
|
634
|
-
|
|
635
|
-
});
|
|
636
|
-
});
|
|
729
|
+
(0, _hooks2.useSpreadsheetEdit)({
|
|
730
|
+
isEditing: isEditing,
|
|
731
|
+
rows: rows,
|
|
732
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
733
|
+
activeCellRef: activeCellRef,
|
|
734
|
+
cellEditorRef: cellEditorRef,
|
|
735
|
+
cellEditorRulerRef: cellEditorRulerRef,
|
|
736
|
+
columns: columns,
|
|
737
|
+
defaultColumn: defaultColumn,
|
|
738
|
+
cellEditorValue: cellEditorValue
|
|
739
|
+
});
|
|
740
|
+
var handleActiveCellMouseEnter = (0, _react.useCallback)(function () {
|
|
741
|
+
handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
|
|
742
|
+
}, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]); // Only update if there are cell selection areas
|
|
743
|
+
// Find point object that matches currentMatcher and remove the second point
|
|
744
|
+
// because hovering over the active cell while clicking and holding should
|
|
745
|
+
// remove the previously existing selection area
|
|
746
|
+
|
|
747
|
+
var handleActiveCellMouseEnterCallback = (0, _react.useCallback)(function (areas, clickHold) {
|
|
748
|
+
if (!currentMatcher) {
|
|
749
|
+
return;
|
|
637
750
|
}
|
|
638
751
|
|
|
639
|
-
if (
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
setActiveCellCoordinates(function (prev) {
|
|
645
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
646
|
-
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
|
|
647
|
-
|
|
752
|
+
if (areas && areas.length && clickHold && currentMatcher) {
|
|
753
|
+
setSelectionAreas(function (prev) {
|
|
754
|
+
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
|
|
755
|
+
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
|
756
|
+
return item.matcher === currentMatcher;
|
|
648
757
|
});
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
758
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
(0, _react.useEffect)(function () {
|
|
656
|
-
if (isEditing) {
|
|
657
|
-
var _rows$activeCellCoord, _cellProps$column, _cellEditorRef$curren;
|
|
658
|
-
|
|
659
|
-
var cellProps = (_rows$activeCellCoord = rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row]) === null || _rows$activeCellCoord === void 0 ? void 0 : _rows$activeCellCoord.cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column];
|
|
660
|
-
var activeCellLeftPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.left;
|
|
661
|
-
var activeCellTopPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.top;
|
|
662
|
-
cellEditorRef.current.style.left = activeCellLeftPosition;
|
|
663
|
-
cellEditorRef.current.style.top = activeCellTopPosition;
|
|
664
|
-
cellEditorRef.current.style.display = 'block';
|
|
665
|
-
cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.width;
|
|
666
|
-
cellEditorRef.current.style.height = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height;
|
|
667
|
-
cellEditorRef.current.style.paddingTop = "".concat((parseInt(activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height) - 16) / 2 - 1, "px"); // calculate paddingTop based on cellHeight which could be variable depending on the cellSize prop
|
|
668
|
-
|
|
669
|
-
cellEditorRef.current.style.textAlign = (cellProps === null || cellProps === void 0 ? void 0 : (_cellProps$column = cellProps.column) === null || _cellProps$column === void 0 ? void 0 : _cellProps$column.placement) === 'right' ? 'right' : 'left';
|
|
670
|
-
(_cellEditorRef$curren = cellEditorRef.current) === null || _cellEditorRef$curren === void 0 ? void 0 : _cellEditorRef$curren.focus();
|
|
671
|
-
var rulerWidth = cellEditorRulerRef.current.offsetWidth;
|
|
672
|
-
var cellWidth = activeCellRef.current.offsetWidth;
|
|
673
|
-
|
|
674
|
-
if (rulerWidth >= cellWidth) {
|
|
675
|
-
var widthMultiplier = Math.floor(rulerWidth / cellWidth) + 1;
|
|
676
|
-
var startingColumnPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column;
|
|
677
|
-
var startingRowPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row;
|
|
678
|
-
var totalColumns = columns.length;
|
|
679
|
-
var totalRows = rows.length;
|
|
680
|
-
var totalMultiplierPossible = totalColumns - startingColumnPosition;
|
|
681
|
-
var totalCellEditorMaxHeight = (totalRows - startingRowPosition) * defaultColumn.rowHeight;
|
|
682
|
-
cellEditorRef.current.style.maxHeight = (0, _layout.px)(totalCellEditorMaxHeight);
|
|
683
|
-
cellEditorRef.current.style.width = (0, _layout.px)(cellWidth * (widthMultiplier <= totalMultiplierPossible ? widthMultiplier : totalMultiplierPossible));
|
|
684
|
-
cellEditorRef.current.style.height = (0, _layout.px)(cellEditorRef.current.scrollHeight); // adds dynamic height to cell editor
|
|
685
|
-
// Cell editor has reached max height, we need to add the scrolling back.
|
|
686
|
-
// We also need to subtract 1 to account for the fact that the cell editor
|
|
687
|
-
// is placed one pixel below the cell being edited to account for the border
|
|
688
|
-
|
|
689
|
-
if (cellEditorRef.current.clientHeight === totalCellEditorMaxHeight - 1) {
|
|
690
|
-
cellEditorRef.current.style.overflow = 'auto';
|
|
691
|
-
} else {
|
|
692
|
-
cellEditorRef.current.style.overflow = 'hidden';
|
|
759
|
+
if (indexOfItemToUpdate === -1) {
|
|
760
|
+
return prev;
|
|
693
761
|
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
if (!isEditing) {
|
|
698
|
-
cellEditorRef.current.style.overflow = 'hidden';
|
|
699
|
-
cellEditorRef.current.style.display = 'none';
|
|
700
|
-
cellEditorRef.current.blur();
|
|
701
|
-
activeCellRef.current.focus();
|
|
702
|
-
}
|
|
703
|
-
}, [isEditing, activeCellCoordinates, rows, cellEditorValue, columns.length, defaultColumn]);
|
|
704
|
-
|
|
705
|
-
var handleKeyUp = function handleKeyUp(event) {
|
|
706
|
-
var _activeKeys$current3;
|
|
707
762
|
|
|
708
|
-
|
|
763
|
+
if ((0, _typeof2.default)(selectionAreaClone[indexOfItemToUpdate].point2) === 'object' && selectionAreaClone[indexOfItemToUpdate].areaCreated) {
|
|
764
|
+
selectionAreaClone[indexOfItemToUpdate].point2 = selectionAreaClone[indexOfItemToUpdate].point1;
|
|
765
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
|
766
|
+
setActiveCellInsideSelectionArea(false);
|
|
767
|
+
(0, _removeCellSelections.removeCellSelections)({
|
|
768
|
+
matcher: currentMatcher,
|
|
769
|
+
spreadsheetRef: spreadsheetRef
|
|
770
|
+
});
|
|
771
|
+
return selectionAreaClone;
|
|
772
|
+
}
|
|
709
773
|
|
|
710
|
-
|
|
711
|
-
var activeKeysClone = (0, _toConsumableArray2.default)(activeKeys.current);
|
|
712
|
-
var filteredKeysClone = activeKeysClone.filter(function (item) {
|
|
713
|
-
return item !== key;
|
|
774
|
+
return prev;
|
|
714
775
|
});
|
|
715
|
-
activeKeys.current = filteredKeysClone;
|
|
716
776
|
}
|
|
717
|
-
};
|
|
718
|
-
|
|
777
|
+
}, [spreadsheetRef, currentMatcher]);
|
|
719
778
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, getTableProps(), (0, _devtools.getDevtoolsProps)(componentName), {
|
|
720
779
|
className: (0, _classnames.default)(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
|
|
721
780
|
ref: spreadsheetRef,
|
|
@@ -724,11 +783,12 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
724
783
|
"aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
|
|
725
784
|
"aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
|
|
726
785
|
onKeyDown: handleKeyPress,
|
|
727
|
-
onKeyUp: handleKeyUp,
|
|
728
786
|
onFocus: function onFocus() {
|
|
729
787
|
return setContainerHasFocus(true);
|
|
730
788
|
}
|
|
731
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
789
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
790
|
+
ref: multiKeyTrackingRef
|
|
791
|
+
}, /*#__PURE__*/_react.default.createElement(_DataSpreadsheetHeader.DataSpreadsheetHeader, {
|
|
732
792
|
ref: spreadsheetRef,
|
|
733
793
|
activeCellCoordinates: activeCellCoordinates,
|
|
734
794
|
cellSize: cellSize,
|
|
@@ -741,7 +801,9 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
741
801
|
setActiveCellCoordinates: setActiveCellCoordinates,
|
|
742
802
|
setSelectionAreas: setSelectionAreas,
|
|
743
803
|
setCurrentMatcher: setCurrentMatcher,
|
|
744
|
-
setSelectionAreaData: setSelectionAreaData
|
|
804
|
+
setSelectionAreaData: setSelectionAreaData,
|
|
805
|
+
totalVisibleColumns: totalVisibleColumns,
|
|
806
|
+
updateActiveCellCoordinates: updateActiveCellCoordinates
|
|
745
807
|
}), /*#__PURE__*/_react.default.createElement(_DataSpreadsheetBody.DataSpreadsheetBody, {
|
|
746
808
|
activeCellCoordinates: activeCellCoordinates,
|
|
747
809
|
ref: spreadsheetRef,
|
|
@@ -768,30 +830,46 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
|
|
|
768
830
|
totalColumnsWidth: totalColumnsWidth,
|
|
769
831
|
id: id,
|
|
770
832
|
columns: columns,
|
|
771
|
-
defaultEmptyRowCount: defaultEmptyRowCount
|
|
833
|
+
defaultEmptyRowCount: defaultEmptyRowCount,
|
|
834
|
+
setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea,
|
|
835
|
+
totalVisibleColumns: totalVisibleColumns
|
|
772
836
|
}), /*#__PURE__*/_react.default.createElement("button", {
|
|
837
|
+
onMouseDown: handleActiveCellMouseDown,
|
|
773
838
|
onClick: handleActiveCellClick,
|
|
774
839
|
onKeyDown: handleActiveCellKeyDown,
|
|
775
840
|
onDoubleClick: handleActiveCellDoubleClick,
|
|
841
|
+
onMouseEnter: handleActiveCellMouseEnter,
|
|
776
842
|
ref: activeCellRef,
|
|
777
|
-
className: (0, _classnames.default)("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight")),
|
|
843
|
+
className: (0, _classnames.default)("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__active-cell--with-selection"), activeCellInsideSelectionArea)),
|
|
778
844
|
type: "button"
|
|
779
845
|
}, activeCellContent), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextArea, {
|
|
780
846
|
value: cellEditorValue,
|
|
781
|
-
onKeyDown: handleEditSubmit
|
|
847
|
+
onKeyDown: (0, _handleEditSubmit.handleEditSubmit)({
|
|
848
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
849
|
+
cellEditorRulerRef: cellEditorRulerRef,
|
|
850
|
+
columns: columns,
|
|
851
|
+
previousState: previousState,
|
|
852
|
+
removeCellEditor: removeCellEditor,
|
|
853
|
+
rows: rows,
|
|
854
|
+
setActiveCellCoordinates: setActiveCellCoordinates,
|
|
855
|
+
setCurrentMatcher: setCurrentMatcher,
|
|
856
|
+
setSelectionAreas: setSelectionAreas,
|
|
857
|
+
spreadsheetRef: spreadsheetRef,
|
|
858
|
+
updateData: updateData
|
|
859
|
+
}),
|
|
782
860
|
onChange: function onChange(event) {
|
|
783
861
|
setCellEditorValue(event.target.value);
|
|
784
862
|
cellEditorRulerRef.current.textContent = event.target.value;
|
|
785
863
|
},
|
|
786
864
|
ref: cellEditorRef,
|
|
787
865
|
labelText: "",
|
|
788
|
-
"aria-labelledby": activeCellCoordinates ? "
|
|
866
|
+
"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,
|
|
789
867
|
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))
|
|
790
868
|
}), /*#__PURE__*/_react.default.createElement("pre", {
|
|
791
869
|
"aria-hidden": true,
|
|
792
870
|
ref: cellEditorRulerRef,
|
|
793
871
|
className: "".concat(blockClass, "__cell-editor-ruler")
|
|
794
|
-
}));
|
|
872
|
+
})));
|
|
795
873
|
}); // Return a placeholder if not released and not enabled by feature flag
|
|
796
874
|
|
|
797
875
|
|
|
@@ -852,7 +930,13 @@ DataSpreadsheet.propTypes = {
|
|
|
852
930
|
/**
|
|
853
931
|
* The event handler that is called when the selection area values change
|
|
854
932
|
*/
|
|
855
|
-
onSelectionAreaChange: _propTypes.default.func
|
|
933
|
+
onSelectionAreaChange: _propTypes.default.func,
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* The total number of columns to be initially visible, additional columns will be rendered and
|
|
937
|
+
* visible via horizontal scrollbar
|
|
938
|
+
*/
|
|
939
|
+
totalVisibleColumns: _propTypes.default.number
|
|
856
940
|
/* TODO: add types and DocGen for all props. */
|
|
857
941
|
|
|
858
942
|
};
|