Skip to content

Commit

Permalink
Merge branch 'handsontable:develop' into feature/issue-8728
Browse files Browse the repository at this point in the history
  • Loading branch information
tonextone committed Apr 27, 2023
2 parents 3f3bd52 + ce9ed46 commit da570db
Show file tree
Hide file tree
Showing 26 changed files with 5,164 additions and 1,176 deletions.
8 changes: 8 additions & 0 deletions .changelogs/10215.json
@@ -0,0 +1,8 @@
{
"issuesOrigin": "private",
"title": "Added new afterColumnSequenceChange and afterRowSequenceChange hooks and synchronization of actions done on HOT with HF's engine",
"type": "added",
"issueOrPR": 10215,
"breaking": false,
"framework": "none"
}
5 changes: 5 additions & 0 deletions docs/content/guides/formulas/formula-calculation.md
Expand Up @@ -27,6 +27,11 @@ Perform calculations on cells' values, using a powerful calculation engine that

[[toc]]

::: warning
Moving using low-level functionality such as [index mapper's API](@/api/indexMapper.md) doesn't update dataset properly.
Please consider using [ManualRowMove](@/api/manualRowMove.md) and [ManualColumnMove](@/api/manualColumnMove.md) plugins.
:::

## Overview

The _Formulas_ plugin provides you an extensive calculation capabilities based on formulas using the spreadsheet notation. Under the hood, it uses an engine called [HyperFormula](https://hyperformula.handsontable.com/) created by the Handsontable team as an independent library to help developers build complex data management apps.
Expand Down
2 changes: 1 addition & 1 deletion handsontable/package.json
Expand Up @@ -84,7 +84,7 @@
"pikaday": "1.8.2"
},
"optionalDependencies": {
"hyperformula": "^2.0.0"
"hyperformula": "^2.4.0"
},
"devDependencies": {
"@babel/cli": "^7.8.3",
Expand Down
11 changes: 8 additions & 3 deletions handsontable/src/core.js
Expand Up @@ -239,6 +239,14 @@ export default function Core(rootElement, userSettings, rootInstanceSymbol = fal
*/
this.rowIndexMapper = new IndexMapper();

this.columnIndexMapper.addLocalHook('indexesSequenceChange', (source) => {
instance.runHooks('afterColumnSequenceChange', source);
});

this.rowIndexMapper.addLocalHook('indexesSequenceChange', (source) => {
instance.runHooks('afterRowSequenceChange', source);
});

dataSource = new DataSource(instance);

if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === 'ht_') {
Expand Down Expand Up @@ -4382,9 +4390,6 @@ export default function Core(rootElement, userSettings, rootInstanceSymbol = fal
datamap.destroy();
}

instance.rowIndexMapper = null;
instance.columnIndexMapper = null;

datamap = null;
grid = null;
selection = null;
Expand Down
10 changes: 5 additions & 5 deletions handsontable/src/dataMap/dataSource.js
Expand Up @@ -187,7 +187,7 @@ class DataSource {
if (this.hot.hasHook('modifySourceData')) {
const valueHolder = createObjectPropListener(value);

this.hot.runHooks('modifySourceData', row, this.propToCol(column), valueHolder, 'set');
this.hot.runHooks('modifySourceData', row, column, valueHolder, 'set');

if (valueHolder.isTouched()) {
value = valueHolder.value;
Expand Down Expand Up @@ -230,7 +230,7 @@ class DataSource {
if (this.hot.hasHook('modifySourceData')) {
const valueHolder = createObjectPropListener(result);

this.hot.runHooks('modifySourceData', row, this.colToProp(column), valueHolder, 'get');
this.hot.runHooks('modifySourceData', row, column, valueHolder, 'get');

if (valueHolder.isTouched()) {
result = valueHolder.value;
Expand All @@ -244,13 +244,13 @@ class DataSource {
* Returns a single value from the data.
*
* @param {number} row Physical row index.
* @param {number} column Visual column index.
* @param {number} columnOrProp Visual column index or property.
* @returns {*}
*/
getAtCell(row, column) {
getAtCell(row, columnOrProp) {
const dataRow = this.modifyRowData(row);

return this.getAtPhysicalCell(row, this.colToProp(column), dataRow);
return this.getAtPhysicalCell(row, this.colToProp(columnOrProp), dataRow);
}

/**
Expand Down
20 changes: 17 additions & 3 deletions handsontable/src/pluginHooks.js
Expand Up @@ -275,6 +275,13 @@ const REGISTERED_HOOKS = [
*/
'beforeCreateCol',

/**
* Fired after changing a column sequence. It populates every change on indexes captured by {@link IndexMapper}.
*
* @param {'init'|'remove'|'insert'|'move'|'update'} [source] String that identifies source of row sequence change.
*/
'afterColumnSequenceChange',

/**
* Fired after created a new column.
*
Expand Down Expand Up @@ -563,6 +570,13 @@ const REGISTERED_HOOKS = [
*/
'afterRenderer',

/**
* Fired after changing a row sequence. It populates every change on indexes captured by {@link IndexMapper}.
*
* @param {'init'|'remove'|'insert'|'move'|'update'} [source] String that identifies source of row sequence change.
*/
'afterRowSequenceChange',

/**
* Fired after the horizontal scroll event.
*
Expand Down Expand Up @@ -1260,8 +1274,8 @@ const REGISTERED_HOOKS = [
* Fired when a data was retrieved or modified.
*
* @event Hooks#modifyData
* @param {number} row Physical row height.
* @param {number} column Physical column index.
* @param {number} row Physical row index.
* @param {number} column Visual column index.
* @param {object} valueHolder Object which contains original value which can be modified by overwriting `.value` property.
* @param {string} ioMode String which indicates for what operation hook is fired (`get` or `set`).
*/
Expand All @@ -1273,7 +1287,7 @@ const REGISTERED_HOOKS = [
* @event Hooks#modifySourceData
* @since 8.0.0
* @param {number} row Physical row index.
* @param {number} column Physical column index.
* @param {number} column Physical column index or property name.
* @param {object} valueHolder Object which contains original value which can be modified by overwriting `.value` property.
* @param {string} ioMode String which indicates for what operation hook is fired (`get` or `set`).
*/
Expand Down

0 comments on commit da570db

Please sign in to comment.