handsontable 15.0.1-next-ab94a4c-20250207 → 15.1.0-next-5e493ee-20250207
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/3rdparty/walkontable/src/index.js +2 -0
- package/3rdparty/walkontable/src/index.mjs +2 -1
- package/3rdparty/walkontable/src/overlays.js +2 -39
- package/3rdparty/walkontable/src/overlays.mjs +2 -39
- package/3rdparty/walkontable/src/renderer/_base.js +3 -4
- package/3rdparty/walkontable/src/renderer/_base.mjs +2 -2
- package/3rdparty/walkontable/src/renderer/cells.js +7 -11
- package/3rdparty/walkontable/src/renderer/cells.mjs +6 -9
- package/3rdparty/walkontable/src/renderer/colGroup.js +6 -7
- package/3rdparty/walkontable/src/renderer/colGroup.mjs +5 -5
- package/3rdparty/walkontable/src/renderer/columnHeaders.js +4 -5
- package/3rdparty/walkontable/src/renderer/columnHeaders.mjs +3 -3
- package/3rdparty/walkontable/src/renderer/index.js +18 -19
- package/3rdparty/walkontable/src/renderer/index.mjs +6 -6
- package/3rdparty/walkontable/src/renderer/rowHeaders.js +6 -7
- package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +5 -5
- package/3rdparty/walkontable/src/renderer/rows.js +23 -11
- package/3rdparty/walkontable/src/renderer/rows.mjs +23 -10
- package/3rdparty/walkontable/src/renderer/table.js +1 -1
- package/3rdparty/walkontable/src/renderer/table.mjs +1 -1
- package/3rdparty/walkontable/src/selection/border/border.js +10 -2
- package/3rdparty/walkontable/src/selection/border/border.mjs +10 -2
- package/3rdparty/walkontable/src/utils/nodesPool.js +21 -6
- package/3rdparty/walkontable/src/utils/nodesPool.mjs +21 -6
- package/3rdparty/walkontable/src/utils/orderView/index.js +4 -5
- package/3rdparty/walkontable/src/utils/orderView/index.mjs +2 -2
- package/3rdparty/walkontable/src/utils/orderView/sharedView.js +3 -4
- package/3rdparty/walkontable/src/utils/orderView/sharedView.mjs +2 -2
- package/3rdparty/walkontable/src/utils/orderView/view.js +60 -76
- package/3rdparty/walkontable/src/utils/orderView/view.mjs +59 -74
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.js +138 -0
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.mjs +135 -0
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.js +72 -0
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.mjs +68 -0
- package/3rdparty/walkontable/src/utils/orderView/viewSize.js +1 -1
- package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +1 -1
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.js +4 -5
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.mjs +3 -3
- package/CHANGELOG.md +48 -2
- package/README.md +3 -3
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/cellTypes/dropdownType/dropdownType.js +4 -2
- package/cellTypes/dropdownType/dropdownType.mjs +4 -2
- package/core.js +39 -38
- package/core.mjs +36 -35
- package/dataMap/dataMap.js +8 -0
- package/dataMap/dataMap.mjs +8 -0
- package/dataMap/dataSource.js +4 -0
- package/dataMap/dataSource.mjs +4 -0
- package/dataMap/metaManager/lazyFactoryMap.js +8 -5
- package/dataMap/metaManager/lazyFactoryMap.mjs +8 -5
- package/dataMap/metaManager/metaSchema.js +24 -9
- package/dataMap/metaManager/metaSchema.mjs +24 -9
- package/dist/handsontable.css +6 -2
- package/dist/handsontable.full.css +6 -2
- package/dist/handsontable.full.js +8026 -6927
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +530 -528
- package/dist/handsontable.js +3833 -2914
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +35 -33
- package/editors/autocompleteEditor/autocompleteEditor.js +1 -3
- package/editors/autocompleteEditor/autocompleteEditor.mjs +1 -3
- package/editors/dateEditor/dateEditor.js +4 -0
- package/editors/dateEditor/dateEditor.mjs +4 -0
- package/editors/dropdownEditor/dropdownEditor.js +3 -16
- package/editors/dropdownEditor/dropdownEditor.mjs +3 -16
- package/editors/handsontableEditor/handsontableEditor.js +4 -4
- package/editors/handsontableEditor/handsontableEditor.mjs +4 -4
- package/focusManager.js +1 -1
- package/focusManager.mjs +1 -1
- package/helpers/dom/element.d.ts +0 -1
- package/helpers/mixed.js +2 -2
- package/helpers/mixed.mjs +2 -2
- package/helpers/object.js +4 -0
- package/helpers/object.mjs +4 -0
- package/package.json +2 -2
- package/plugins/base/base.js +0 -7
- package/plugins/base/base.mjs +0 -7
- package/plugins/comments/comments.js +12 -3
- package/plugins/comments/comments.mjs +12 -3
- package/plugins/contextMenu/contextMenu.js +2 -7
- package/plugins/contextMenu/contextMenu.mjs +2 -7
- package/plugins/contextMenu/menu/menu.js +2 -2
- package/plugins/contextMenu/menu/menu.mjs +2 -2
- package/plugins/contextMenu/predefinedItems/clearColumn.js +15 -4
- package/plugins/contextMenu/predefinedItems/clearColumn.mjs +15 -4
- package/plugins/copyPaste/copyPaste.js +6 -12
- package/plugins/copyPaste/copyPaste.mjs +6 -12
- package/plugins/filters/conditionCollection.js +8 -7
- package/plugins/filters/conditionCollection.mjs +8 -7
- package/plugins/filters/filters.js +26 -16
- package/plugins/filters/filters.mjs +26 -16
- package/plugins/filters/utils.js +7 -24
- package/plugins/filters/utils.mjs +7 -24
- package/plugins/hiddenColumns/hiddenColumns.js +1 -3
- package/plugins/hiddenColumns/hiddenColumns.mjs +1 -3
- package/plugins/hiddenRows/hiddenRows.js +1 -3
- package/plugins/hiddenRows/hiddenRows.mjs +1 -3
- package/plugins/manualRowMove/manualRowMove.js +1 -1
- package/plugins/manualRowMove/manualRowMove.mjs +1 -1
- package/plugins/mergeCells/calculations/autofill.js +60 -44
- package/plugins/mergeCells/calculations/autofill.mjs +60 -44
- package/plugins/mergeCells/cellsCollection.js +25 -8
- package/plugins/mergeCells/cellsCollection.mjs +25 -8
- package/plugins/mergeCells/mergeCells.js +15 -16
- package/plugins/mergeCells/mergeCells.mjs +15 -16
- package/plugins/nestedHeaders/nestedHeaders.js +6 -1
- package/plugins/nestedHeaders/nestedHeaders.mjs +6 -1
- package/plugins/nestedHeaders/stateManager/index.js +1 -2
- package/plugins/nestedHeaders/stateManager/index.mjs +1 -2
- package/plugins/nestedHeaders/utils/ghostTable.js +4 -0
- package/plugins/nestedHeaders/utils/ghostTable.mjs +4 -0
- package/plugins/nestedRows/utils/rowMoveController.js +1 -6
- package/plugins/nestedRows/utils/rowMoveController.mjs +1 -6
- package/plugins/undoRedo/actions/_base.js +19 -0
- package/plugins/undoRedo/actions/_base.mjs +15 -0
- package/plugins/undoRedo/actions/cellAlignment.js +85 -0
- package/plugins/undoRedo/actions/cellAlignment.mjs +81 -0
- package/plugins/undoRedo/actions/columnMove.js +84 -0
- package/plugins/undoRedo/actions/columnMove.mjs +80 -0
- package/plugins/undoRedo/actions/columnSort.js +73 -0
- package/plugins/undoRedo/actions/columnSort.mjs +69 -0
- package/plugins/undoRedo/actions/createColumn.js +60 -0
- package/plugins/undoRedo/actions/createColumn.mjs +56 -0
- package/plugins/undoRedo/actions/createRow.js +65 -0
- package/plugins/undoRedo/actions/createRow.mjs +61 -0
- package/plugins/undoRedo/actions/dataChange.js +123 -0
- package/plugins/undoRedo/actions/dataChange.mjs +119 -0
- package/plugins/undoRedo/actions/filters.js +66 -0
- package/plugins/undoRedo/actions/filters.mjs +62 -0
- package/plugins/undoRedo/actions/index.js +27 -0
- package/plugins/undoRedo/actions/index.mjs +23 -0
- package/plugins/undoRedo/actions/mergeCells.js +63 -0
- package/plugins/undoRedo/actions/mergeCells.mjs +59 -0
- package/plugins/undoRedo/actions/removeColumn.js +176 -0
- package/plugins/undoRedo/actions/removeColumn.mjs +172 -0
- package/plugins/undoRedo/actions/removeRow.js +119 -0
- package/plugins/undoRedo/actions/removeRow.mjs +115 -0
- package/plugins/undoRedo/actions/rowMove.js +84 -0
- package/plugins/undoRedo/actions/rowMove.mjs +80 -0
- package/plugins/undoRedo/actions/unmergeCells.js +56 -0
- package/plugins/undoRedo/actions/unmergeCells.mjs +52 -0
- package/plugins/undoRedo/index.js +3 -4
- package/plugins/undoRedo/index.mjs +1 -2
- package/plugins/undoRedo/undoRedo.js +277 -879
- package/plugins/undoRedo/undoRedo.mjs +277 -880
- package/plugins/undoRedo/utils.js +37 -0
- package/plugins/undoRedo/utils.mjs +33 -0
- package/renderers/checkboxRenderer/checkboxRenderer.js +8 -1
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +8 -1
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +1 -0
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +1 -0
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +2 -1
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +2 -1
- package/styles/handsontable.css +75 -103
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-theme-horizon.css +2 -2
- package/styles/ht-theme-horizon.min.css +2 -2
- package/styles/ht-theme-main.css +2 -2
- package/styles/ht-theme-main.min.css +2 -2
- package/tableView.js +17 -1
- package/tableView.mjs +17 -1
- package/utils/autoResize.js +1 -1
- package/utils/autoResize.mjs +1 -1
- package/utils/parseTable.js +1 -1
- package/utils/parseTable.mjs +1 -1
- package/validators/dateValidator/dateValidator.js +1 -1
- package/validators/dateValidator/dateValidator.mjs +1 -1
@@ -2,11 +2,11 @@ import "core-js/modules/es.error.cause.js";
|
|
2
2
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
3
3
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
4
4
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
5
|
-
import BaseRenderer from "./_base.mjs";
|
6
|
-
import { warn } from "
|
7
|
-
import { toSingleLine } from "
|
8
|
-
import { OrderView } from "
|
9
|
-
import { addClass, removeClass, setAttribute } from "../../../../helpers/dom/element.mjs";
|
5
|
+
import { BaseRenderer } from "./_base.mjs";
|
6
|
+
import { warn } from "../../../../helpers/console.mjs";
|
7
|
+
import { toSingleLine } from "../../../../helpers/templateLiteralTag.mjs";
|
8
|
+
import { OrderView } from "../utils/orderView/index.mjs";
|
9
|
+
import { addClass, hasClass, removeClass, setAttribute } from "../../../../helpers/dom/element.mjs";
|
10
10
|
import { A11Y_ROW, A11Y_ROWGROUP, A11Y_ROWINDEX } from "../../../../helpers/a11y.mjs";
|
11
11
|
const ROW_CLASSNAMES = {
|
12
12
|
rowEven: 'ht__row_even',
|
@@ -26,7 +26,7 @@ let performanceWarningAppeared = false;
|
|
26
26
|
*
|
27
27
|
* @class {RowsRenderer}
|
28
28
|
*/
|
29
|
-
export
|
29
|
+
export class RowsRenderer extends BaseRenderer {
|
30
30
|
constructor(rootNode) {
|
31
31
|
super('TR', rootNode);
|
32
32
|
/**
|
@@ -35,7 +35,7 @@ export default class RowsRenderer extends BaseRenderer {
|
|
35
35
|
* @type {WeakMap}
|
36
36
|
*/
|
37
37
|
_defineProperty(this, "orderView", void 0);
|
38
|
-
this.orderView = new OrderView(rootNode, sourceRowIndex => this.nodesPool.obtain(sourceRowIndex)
|
38
|
+
this.orderView = new OrderView(rootNode, sourceRowIndex => this.nodesPool.obtain(sourceRowIndex));
|
39
39
|
}
|
40
40
|
|
41
41
|
/**
|
@@ -48,6 +48,16 @@ export default class RowsRenderer extends BaseRenderer {
|
|
48
48
|
return this.orderView.getNode(visualIndex);
|
49
49
|
}
|
50
50
|
|
51
|
+
/**
|
52
|
+
* Checks if the the row is marked as "stale" and has to be rerendered.
|
53
|
+
*
|
54
|
+
* @param {number} visualIndex Visual index of the rendered node (it always goeas from 0 to N).
|
55
|
+
* @returns {boolean}
|
56
|
+
*/
|
57
|
+
hasStaleContent(visualIndex) {
|
58
|
+
return this.orderView.hasStaleContent(visualIndex);
|
59
|
+
}
|
60
|
+
|
51
61
|
/**
|
52
62
|
* Renders the cells.
|
53
63
|
*/
|
@@ -75,10 +85,13 @@ export default class RowsRenderer extends BaseRenderer {
|
|
75
85
|
// `aria-rowindex` is incremented by both tbody and thead rows.
|
76
86
|
A11Y_ROWINDEX(sourceRowIndex + ((_this$table$rowUtils$ = (_this$table$rowUtils = this.table.rowUtils) === null || _this$table$rowUtils === void 0 || (_this$table$rowUtils = _this$table$rowUtils.dataAccessObject) === null || _this$table$rowUtils === void 0 ? void 0 : _this$table$rowUtils.columnHeaders.length) !== null && _this$table$rowUtils$ !== void 0 ? _this$table$rowUtils$ : 0) + 1)]);
|
77
87
|
}
|
78
|
-
removeClass(TR, [ROW_CLASSNAMES.rowEven, ROW_CLASSNAMES.rowOdd]);
|
79
88
|
if ((sourceRowIndex + 1) % 2 === 0) {
|
80
|
-
|
81
|
-
|
89
|
+
if (!hasClass(TR, ROW_CLASSNAMES.rowEven)) {
|
90
|
+
removeClass(TR, ROW_CLASSNAMES.rowOdd);
|
91
|
+
addClass(TR, ROW_CLASSNAMES.rowEven);
|
92
|
+
}
|
93
|
+
} else if (!hasClass(TR, ROW_CLASSNAMES.rowOdd)) {
|
94
|
+
removeClass(TR, ROW_CLASSNAMES.rowEven);
|
82
95
|
addClass(TR, ROW_CLASSNAMES.rowOdd);
|
83
96
|
}
|
84
97
|
}
|
@@ -477,9 +477,17 @@ class Border {
|
|
477
477
|
const toTdOffsetTop = trimToWindow ? toTD.getBoundingClientRect().top : toTD.offsetTop;
|
478
478
|
const cornerBottomEdge = toTdOffsetTop + (0, _element.outerHeight)(toTD) + parseInt(this.cornerDefaultStyle.height, 10) / 2;
|
479
479
|
const cornerOverlappingContainer = cornerBottomEdge >= (0, _element.innerHeight)(trimmingContainer);
|
480
|
+
const isClassicTheme = this.wot.stylesHandler.isClassicTheme();
|
480
481
|
if (cornerOverlappingContainer) {
|
481
|
-
|
482
|
-
|
482
|
+
const cornerTopPosition = Math.floor(top + height + this.cornerCenterPointOffset - cornerHalfHeight - cornerBorderCompensation);
|
483
|
+
if (isClassicTheme) {
|
484
|
+
// styles for classic theme
|
485
|
+
this.cornerStyle.top = `${cornerTopPosition}px`;
|
486
|
+
this.cornerStyle.borderBottomWidth = 0;
|
487
|
+
} else {
|
488
|
+
// styles for ht-theme
|
489
|
+
this.cornerStyle.top = `${cornerTopPosition - 1}px`;
|
490
|
+
}
|
483
491
|
}
|
484
492
|
}
|
485
493
|
this.cornerStyle.display = 'block';
|
@@ -474,9 +474,17 @@ class Border {
|
|
474
474
|
const toTdOffsetTop = trimToWindow ? toTD.getBoundingClientRect().top : toTD.offsetTop;
|
475
475
|
const cornerBottomEdge = toTdOffsetTop + outerHeight(toTD) + parseInt(this.cornerDefaultStyle.height, 10) / 2;
|
476
476
|
const cornerOverlappingContainer = cornerBottomEdge >= innerHeight(trimmingContainer);
|
477
|
+
const isClassicTheme = this.wot.stylesHandler.isClassicTheme();
|
477
478
|
if (cornerOverlappingContainer) {
|
478
|
-
|
479
|
-
|
479
|
+
const cornerTopPosition = Math.floor(top + height + this.cornerCenterPointOffset - cornerHalfHeight - cornerBorderCompensation);
|
480
|
+
if (isClassicTheme) {
|
481
|
+
// styles for classic theme
|
482
|
+
this.cornerStyle.top = `${cornerTopPosition}px`;
|
483
|
+
this.cornerStyle.borderBottomWidth = 0;
|
484
|
+
} else {
|
485
|
+
// styles for ht-theme
|
486
|
+
this.cornerStyle.top = `${cornerTopPosition - 1}px`;
|
487
|
+
}
|
480
488
|
}
|
481
489
|
}
|
482
490
|
this.cornerStyle.display = 'block';
|
@@ -13,30 +13,45 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
13
13
|
class NodesPool {
|
14
14
|
constructor(nodeType) {
|
15
15
|
/**
|
16
|
-
* Node type to generate (
|
16
|
+
* Node type to generate (e.g. 'TH', 'TD').
|
17
17
|
*
|
18
18
|
* @type {string}
|
19
19
|
*/
|
20
20
|
_defineProperty(this, "nodeType", void 0);
|
21
|
+
/**
|
22
|
+
* The holder for all created DOM nodes (THs, TDs).
|
23
|
+
*
|
24
|
+
* @type {Map<string, HTMLElement>}
|
25
|
+
*/
|
26
|
+
_defineProperty(this, "pool", new Map());
|
21
27
|
this.nodeType = nodeType.toUpperCase();
|
22
28
|
}
|
23
29
|
|
24
30
|
/**
|
25
31
|
* Set document owner for this instance.
|
26
32
|
*
|
27
|
-
* @param {
|
33
|
+
* @param {Document} rootDocument The document window owner.
|
28
34
|
*/
|
29
35
|
setRootDocument(rootDocument) {
|
30
36
|
this.rootDocument = rootDocument;
|
31
37
|
}
|
32
38
|
|
33
39
|
/**
|
34
|
-
* Obtains an element.
|
40
|
+
* Obtains an element.
|
35
41
|
*
|
42
|
+
* @param {number} rowIndex The row index.
|
43
|
+
* @param {number} [columnIndex] The column index.
|
36
44
|
* @returns {HTMLElement}
|
37
45
|
*/
|
38
|
-
obtain() {
|
39
|
-
|
46
|
+
obtain(rowIndex, columnIndex) {
|
47
|
+
const hasColumnIndex = typeof columnIndex === 'number';
|
48
|
+
const key = hasColumnIndex ? `${rowIndex}x${columnIndex}` : rowIndex.toString();
|
49
|
+
if (this.pool.has(key)) {
|
50
|
+
return this.pool.get(key);
|
51
|
+
}
|
52
|
+
const node = this.rootDocument.createElement(this.nodeType);
|
53
|
+
this.pool.set(key, node);
|
54
|
+
return node;
|
40
55
|
}
|
41
56
|
}
|
42
|
-
exports.
|
57
|
+
exports.NodesPool = NodesPool;
|
@@ -7,32 +7,47 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
7
7
|
*
|
8
8
|
* @class {NodesPool}
|
9
9
|
*/
|
10
|
-
export
|
10
|
+
export class NodesPool {
|
11
11
|
constructor(nodeType) {
|
12
12
|
/**
|
13
|
-
* Node type to generate (
|
13
|
+
* Node type to generate (e.g. 'TH', 'TD').
|
14
14
|
*
|
15
15
|
* @type {string}
|
16
16
|
*/
|
17
17
|
_defineProperty(this, "nodeType", void 0);
|
18
|
+
/**
|
19
|
+
* The holder for all created DOM nodes (THs, TDs).
|
20
|
+
*
|
21
|
+
* @type {Map<string, HTMLElement>}
|
22
|
+
*/
|
23
|
+
_defineProperty(this, "pool", new Map());
|
18
24
|
this.nodeType = nodeType.toUpperCase();
|
19
25
|
}
|
20
26
|
|
21
27
|
/**
|
22
28
|
* Set document owner for this instance.
|
23
29
|
*
|
24
|
-
* @param {
|
30
|
+
* @param {Document} rootDocument The document window owner.
|
25
31
|
*/
|
26
32
|
setRootDocument(rootDocument) {
|
27
33
|
this.rootDocument = rootDocument;
|
28
34
|
}
|
29
35
|
|
30
36
|
/**
|
31
|
-
* Obtains an element.
|
37
|
+
* Obtains an element.
|
32
38
|
*
|
39
|
+
* @param {number} rowIndex The row index.
|
40
|
+
* @param {number} [columnIndex] The column index.
|
33
41
|
* @returns {HTMLElement}
|
34
42
|
*/
|
35
|
-
obtain() {
|
36
|
-
|
43
|
+
obtain(rowIndex, columnIndex) {
|
44
|
+
const hasColumnIndex = typeof columnIndex === 'number';
|
45
|
+
const key = hasColumnIndex ? `${rowIndex}x${columnIndex}` : rowIndex.toString();
|
46
|
+
if (this.pool.has(key)) {
|
47
|
+
return this.pool.get(key);
|
48
|
+
}
|
49
|
+
const node = this.rootDocument.createElement(this.nodeType);
|
50
|
+
this.pool.set(key, node);
|
51
|
+
return node;
|
37
52
|
}
|
38
53
|
}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
|
-
var _view =
|
5
|
-
exports.OrderView = _view.
|
6
|
-
var _sharedView =
|
7
|
-
exports.SharedOrderView = _sharedView.
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
4
|
+
var _view = require("./view");
|
5
|
+
exports.OrderView = _view.OrderView;
|
6
|
+
var _sharedView = require("./sharedView");
|
7
|
+
exports.SharedOrderView = _sharedView.SharedOrderView;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import OrderView from "./view.mjs";
|
2
|
-
import SharedOrderView from "./sharedView.mjs";
|
1
|
+
import { OrderView } from "./view.mjs";
|
2
|
+
import { SharedOrderView } from "./sharedView.mjs";
|
3
3
|
export { OrderView, SharedOrderView };
|
@@ -1,14 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
|
-
var _view =
|
5
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
4
|
+
var _view = require("./view");
|
6
5
|
/**
|
7
6
|
* Executive model for TR root nodes.
|
8
7
|
*
|
9
8
|
* @class {SharedOrderView}
|
10
9
|
*/
|
11
|
-
class SharedOrderView extends _view.
|
10
|
+
class SharedOrderView extends _view.OrderView {
|
12
11
|
/**
|
13
12
|
* The method results in merging external order view into the current order. This happens only for order views which
|
14
13
|
* operate on the same root node.
|
@@ -43,4 +42,4 @@ class SharedOrderView extends _view.default {
|
|
43
42
|
return this;
|
44
43
|
}
|
45
44
|
}
|
46
|
-
exports.
|
45
|
+
exports.SharedOrderView = SharedOrderView;
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import OrderView from "./view.mjs";
|
1
|
+
import { OrderView } from "./view.mjs";
|
2
2
|
/**
|
3
3
|
* Executive model for TR root nodes.
|
4
4
|
*
|
5
5
|
* @class {SharedOrderView}
|
6
6
|
*/
|
7
|
-
export
|
7
|
+
export class SharedOrderView extends OrderView {
|
8
8
|
/**
|
9
9
|
* The method results in merging external order view into the current order. This happens only for order views which
|
10
10
|
* operate on the same root node.
|
@@ -3,9 +3,8 @@
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
5
5
|
require("core-js/modules/es.array.push.js");
|
6
|
-
var
|
7
|
-
var
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
6
|
+
var _viewSizeSet = require("./viewSizeSet");
|
7
|
+
var _viewDiffer = require("./viewDiffer");
|
9
8
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
10
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
11
10
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
@@ -18,7 +17,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
18
17
|
* @class {OrderView}
|
19
18
|
*/
|
20
19
|
class OrderView {
|
21
|
-
constructor(rootNode, nodesPool
|
20
|
+
constructor(rootNode, nodesPool) {
|
22
21
|
/**
|
23
22
|
* The root node to manage with.
|
24
23
|
*
|
@@ -28,7 +27,7 @@ class OrderView {
|
|
28
27
|
/**
|
29
28
|
* Factory for newly created DOM elements.
|
30
29
|
*
|
31
|
-
* @type {
|
30
|
+
* @type {function(number): HTMLElement}
|
32
31
|
*/
|
33
32
|
_defineProperty(this, "nodesPool", void 0);
|
34
33
|
/**
|
@@ -36,28 +35,37 @@ class OrderView {
|
|
36
35
|
*
|
37
36
|
* @type {ViewSizeSet}
|
38
37
|
*/
|
39
|
-
_defineProperty(this, "sizeSet", new _viewSizeSet.
|
38
|
+
_defineProperty(this, "sizeSet", new _viewSizeSet.ViewSizeSet());
|
40
39
|
/**
|
41
|
-
*
|
40
|
+
* The list of DOM elements which are rendered for this render cycle.
|
42
41
|
*
|
43
|
-
* @type {
|
42
|
+
* @type {HTMLElement[]}
|
44
43
|
*/
|
45
|
-
_defineProperty(this, "
|
44
|
+
_defineProperty(this, "collectedNodes", []);
|
46
45
|
/**
|
47
|
-
* The
|
46
|
+
* The differ which calculates the differences between current and next view. It generates
|
47
|
+
* commands that are processed by the OrderView (see `applyCommand` method).
|
48
48
|
*
|
49
|
-
* @type {
|
49
|
+
* @type {ViewDiffer}
|
50
50
|
*/
|
51
|
-
_defineProperty(this, "
|
51
|
+
_defineProperty(this, "viewDiffer", new _viewDiffer.ViewDiffer(this.sizeSet));
|
52
52
|
/**
|
53
|
-
* The list of
|
53
|
+
* The list of render commands to execute. The command is an array with the following
|
54
|
+
* structure: [
|
55
|
+
* [
|
56
|
+
* 'prepend' | 'append' | 'insert_before' | 'replace' | 'remove', // command name
|
57
|
+
* 10, // processed node index
|
58
|
+
* 9, // previous node index (only for 'insert_before' and 'replace' commands)
|
59
|
+
* 8 // node index to remove (only for 'insert_before' command)
|
60
|
+
* ],
|
61
|
+
* ...
|
62
|
+
* ].
|
54
63
|
*
|
55
|
-
* @type {
|
64
|
+
* @type {Array[]}
|
56
65
|
*/
|
57
|
-
_defineProperty(this, "
|
66
|
+
_defineProperty(this, "leads", []);
|
58
67
|
this.rootNode = rootNode;
|
59
68
|
this.nodesPool = nodesPool;
|
60
|
-
this.childNodeType = childNodeType.toUpperCase();
|
61
69
|
}
|
62
70
|
|
63
71
|
/**
|
@@ -116,30 +124,38 @@ class OrderView {
|
|
116
124
|
}
|
117
125
|
|
118
126
|
/**
|
119
|
-
*
|
127
|
+
* Applies the commands generated by the differ into the specific DOM operations.
|
120
128
|
*
|
121
|
-
* @
|
129
|
+
* @param {Array} command The command to apply.
|
122
130
|
*/
|
123
|
-
|
131
|
+
applyCommand(command) {
|
124
132
|
const {
|
125
|
-
rootNode
|
126
|
-
sizeSet
|
133
|
+
rootNode
|
127
134
|
} = this;
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
135
|
+
const [name, nodeIndex, nodePrevIndex, nodeIndexToRemove] = command;
|
136
|
+
const node = this.nodesPool(nodeIndex);
|
137
|
+
this.collectedNodes.push(node);
|
138
|
+
switch (name) {
|
139
|
+
case 'prepend':
|
140
|
+
rootNode.insertBefore(node, rootNode.firstChild);
|
141
|
+
break;
|
142
|
+
case 'append':
|
143
|
+
rootNode.appendChild(node);
|
144
|
+
break;
|
145
|
+
case 'insert_before':
|
146
|
+
rootNode.insertBefore(node, this.nodesPool(nodePrevIndex));
|
147
|
+
// To keep the constant length of child nodes (after inserting a node) remove the last child.
|
148
|
+
rootNode.removeChild(this.nodesPool(nodeIndexToRemove));
|
149
|
+
break;
|
150
|
+
case 'replace':
|
151
|
+
rootNode.replaceChild(node, this.nodesPool(nodePrevIndex));
|
152
|
+
break;
|
153
|
+
case 'remove':
|
154
|
+
rootNode.removeChild(node);
|
155
|
+
break;
|
156
|
+
default:
|
157
|
+
break;
|
141
158
|
}
|
142
|
-
return childElementCount;
|
143
159
|
}
|
144
160
|
|
145
161
|
/**
|
@@ -148,30 +164,7 @@ class OrderView {
|
|
148
164
|
*/
|
149
165
|
start() {
|
150
166
|
this.collectedNodes.length = 0;
|
151
|
-
this.
|
152
|
-
const {
|
153
|
-
rootNode,
|
154
|
-
sizeSet
|
155
|
-
} = this;
|
156
|
-
const isShared = this.isSharedViewSet();
|
157
|
-
const {
|
158
|
-
nextSize
|
159
|
-
} = sizeSet.getViewSize();
|
160
|
-
let childElementCount = this.getRenderedChildCount();
|
161
|
-
while (childElementCount < nextSize) {
|
162
|
-
const newNode = this.nodesPool();
|
163
|
-
if (!isShared || isShared && sizeSet.isPlaceOn(_constants.WORKING_SPACE_BOTTOM)) {
|
164
|
-
rootNode.appendChild(newNode);
|
165
|
-
} else {
|
166
|
-
rootNode.insertBefore(newNode, rootNode.firstChild);
|
167
|
-
}
|
168
|
-
childElementCount += 1;
|
169
|
-
}
|
170
|
-
const isSharedPlacedOnTop = isShared && sizeSet.isPlaceOn(_constants.WORKING_SPACE_TOP);
|
171
|
-
while (childElementCount > nextSize) {
|
172
|
-
rootNode.removeChild(isSharedPlacedOnTop ? rootNode.firstChild : rootNode.lastChild);
|
173
|
-
childElementCount -= 1;
|
174
|
-
}
|
167
|
+
this.leads = this.viewDiffer.diff();
|
175
168
|
}
|
176
169
|
|
177
170
|
/**
|
@@ -179,28 +172,19 @@ class OrderView {
|
|
179
172
|
* This method has to be called as many times as the size count is met (to cover all previously rendered DOM elements).
|
180
173
|
*/
|
181
174
|
render() {
|
182
|
-
|
183
|
-
|
184
|
-
sizeSet
|
185
|
-
} = this;
|
186
|
-
let visualIndex = this.visualIndex;
|
187
|
-
if (this.isSharedViewSet() && sizeSet.isPlaceOn(_constants.WORKING_SPACE_BOTTOM)) {
|
188
|
-
visualIndex += sizeSet.sharedSize.nextSize;
|
175
|
+
if (this.leads.length > 0) {
|
176
|
+
this.applyCommand(this.leads.shift());
|
189
177
|
}
|
190
|
-
let node = rootNode.childNodes[visualIndex];
|
191
|
-
if (node.tagName !== this.childNodeType) {
|
192
|
-
const newNode = this.nodesPool();
|
193
|
-
rootNode.replaceChild(newNode, node);
|
194
|
-
node = newNode;
|
195
|
-
}
|
196
|
-
this.collectedNodes.push(node);
|
197
|
-
this.visualIndex += 1;
|
198
178
|
}
|
199
179
|
|
200
180
|
/**
|
201
181
|
* Ends the render process.
|
202
182
|
* This method has to be called only once (at the end) for the render cycle.
|
203
183
|
*/
|
204
|
-
end() {
|
184
|
+
end() {
|
185
|
+
while (this.leads.length > 0) {
|
186
|
+
this.applyCommand(this.leads.shift());
|
187
|
+
}
|
188
|
+
}
|
205
189
|
}
|
206
|
-
exports.
|
190
|
+
exports.OrderView = OrderView;
|