handsontable 18.0.0-rc4 → 18.0.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/3rdparty/walkontable/src/renderer/cells.d.ts +0 -6
- package/3rdparty/walkontable/src/renderer/cells.js +2 -7
- package/3rdparty/walkontable/src/renderer/cells.mjs +2 -7
- package/3rdparty/walkontable/src/renderer/colGroup.js +1 -1
- package/3rdparty/walkontable/src/renderer/colGroup.mjs +1 -1
- package/3rdparty/walkontable/src/renderer/columnHeaderRows.js +1 -1
- package/3rdparty/walkontable/src/renderer/columnHeaderRows.mjs +1 -1
- package/3rdparty/walkontable/src/renderer/columnHeaders.d.ts +0 -6
- package/3rdparty/walkontable/src/renderer/columnHeaders.js +2 -7
- package/3rdparty/walkontable/src/renderer/columnHeaders.mjs +2 -7
- package/3rdparty/walkontable/src/renderer/rowHeaders.d.ts +0 -6
- package/3rdparty/walkontable/src/renderer/rowHeaders.js +5 -10
- package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +5 -10
- package/3rdparty/walkontable/src/renderer/rows.js +1 -1
- package/3rdparty/walkontable/src/renderer/rows.mjs +1 -1
- package/3rdparty/walkontable/src/utils/nodesPool.d.ts +10 -10
- package/3rdparty/walkontable/src/utils/nodesPool.js +16 -32
- package/3rdparty/walkontable/src/utils/nodesPool.mjs +11 -31
- package/3rdparty/walkontable/src/utils/orderView/constants.d.ts +0 -36
- package/3rdparty/walkontable/src/utils/orderView/constants.js +0 -24
- package/3rdparty/walkontable/src/utils/orderView/constants.mjs +0 -30
- package/3rdparty/walkontable/src/utils/orderView/view.d.ts +27 -20
- package/3rdparty/walkontable/src/utils/orderView/view.js +79 -16
- package/3rdparty/walkontable/src/utils/orderView/view.mjs +86 -17
- package/3rdparty/walkontable/src/utils/orderView/viewSize.d.ts +2 -14
- package/3rdparty/walkontable/src/utils/orderView/viewSize.js +2 -14
- package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +2 -14
- package/CHANGELOG.md +4 -1
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core/types.d.ts +4 -0
- package/core.js +25 -4
- package/core.mjs +25 -4
- package/dataMap/metaManager/index.d.ts +22 -0
- package/dataMap/metaManager/index.js +20 -0
- package/dataMap/metaManager/index.mjs +20 -0
- package/dataMap/metaManager/metaLayers/cellMeta.d.ts +30 -0
- package/dataMap/metaManager/metaLayers/cellMeta.js +110 -0
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +111 -1
- package/dataMap/metaManager/metaSchema.js +9 -0
- package/dataMap/metaManager/metaSchema.mjs +9 -0
- package/dataMap/sourceDataValidator.d.ts +25 -2
- package/dataMap/sourceDataValidator.js +163 -29
- package/dataMap/sourceDataValidator.mjs +178 -30
- package/dist/handsontable.full.js +2182 -2392
- package/dist/handsontable.full.min.js +95 -95
- package/dist/handsontable.js +2182 -2387
- package/dist/handsontable.min.js +95 -95
- package/dist/themes/classic.js +2 -2
- package/dist/themes/classic.min.js +2 -2
- package/dist/themes/horizon.js +2 -2
- package/dist/themes/horizon.min.js +2 -2
- package/dist/themes/main.js +2 -2
- package/dist/themes/main.min.js +2 -2
- package/dist/themes/static/variables/colors/ant.js +2 -2
- package/dist/themes/static/variables/colors/ant.min.js +2 -2
- package/dist/themes/static/variables/colors/classic.js +2 -2
- package/dist/themes/static/variables/colors/classic.min.js +2 -2
- package/dist/themes/static/variables/colors/horizon.js +2 -2
- package/dist/themes/static/variables/colors/horizon.min.js +2 -2
- package/dist/themes/static/variables/colors/main.js +2 -2
- package/dist/themes/static/variables/colors/main.min.js +2 -2
- package/dist/themes/static/variables/colors/material.js +2 -2
- package/dist/themes/static/variables/colors/material.min.js +2 -2
- package/dist/themes/static/variables/colors/shadcn.js +2 -2
- package/dist/themes/static/variables/colors/shadcn.min.js +2 -2
- package/dist/themes/static/variables/density.js +2 -2
- package/dist/themes/static/variables/density.min.js +2 -2
- package/dist/themes/static/variables/helpers/iconsMap.js +2 -2
- package/dist/themes/static/variables/helpers/iconsMap.min.js +2 -2
- package/dist/themes/static/variables/icons/horizon.js +2 -2
- package/dist/themes/static/variables/icons/horizon.min.js +2 -2
- package/dist/themes/static/variables/icons/main.js +2 -2
- package/dist/themes/static/variables/icons/main.min.js +2 -2
- package/dist/themes/static/variables/sizing.js +2 -2
- package/dist/themes/static/variables/sizing.min.js +2 -2
- package/dist/themes/static/variables/tokens/classic.js +2 -2
- package/dist/themes/static/variables/tokens/classic.min.js +2 -2
- package/dist/themes/static/variables/tokens/horizon.js +2 -2
- package/dist/themes/static/variables/tokens/horizon.min.js +2 -2
- package/dist/themes/static/variables/tokens/main.js +2 -2
- package/dist/themes/static/variables/tokens/main.min.js +2 -2
- package/helpers/dom/element.js +13 -6
- package/helpers/dom/element.mjs +13 -6
- package/helpers/mixed.js +2 -2
- package/helpers/mixed.mjs +2 -2
- package/package.json +1 -1
- package/styles/handsontable.css +2 -2
- package/styles/handsontable.min.css +2 -2
- package/styles/handsontableStyles.js +1 -1
- package/styles/handsontableStyles.mjs +1 -1
- package/styles/ht-icons-horizon.min.css +2 -2
- package/styles/ht-icons-main.min.css +2 -2
- package/styles/ht-theme-classic-no-icons.min.css +2 -2
- package/styles/ht-theme-classic.min.css +2 -2
- package/styles/ht-theme-horizon-no-icons.min.css +2 -2
- package/styles/ht-theme-horizon.min.css +2 -2
- package/styles/ht-theme-main-no-icons.min.css +2 -2
- package/styles/ht-theme-main.min.css +2 -2
- package/utils/licenseNotification.js +1 -1
- package/utils/licenseNotification.mjs +1 -1
- package/validators/dateValidator/dateValidator.d.ts +3 -0
- package/validators/dateValidator/dateValidator.js +4 -0
- package/validators/dateValidator/dateValidator.mjs +4 -0
- package/validators/timeValidator/timeValidator.d.ts +3 -0
- package/validators/timeValidator/timeValidator.js +4 -0
- package/validators/timeValidator/timeValidator.mjs +4 -0
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/differBasedRendererAdapter.d.mts +0 -1
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/differBasedRendererAdapter.d.ts +0 -60
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/differBasedRendererAdapter.js +0 -96
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/differBasedRendererAdapter.mjs +0 -91
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.d.mts +0 -1
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.d.ts +0 -45
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.js +0 -97
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.mjs +0 -91
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/index.d.mts +0 -1
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/index.d.ts +0 -10
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/index.js +0 -19
- package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/index.mjs +0 -14
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.d.mts +0 -1
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.d.ts +0 -44
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.js +0 -138
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.mjs +0 -133
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.d.mts +0 -1
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.d.ts +0 -57
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.js +0 -137
- package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.mjs +0 -127
package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.mjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { WORKING_SPACE_TOP, WORKING_SPACE_BOTTOM } from '../constants.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Direct DOM renderer adapter that uses direct DOM manipulation.
|
|
4
|
-
*
|
|
5
|
-
* @class {DirectDomRendererAdapter}
|
|
6
|
-
*/ export class DirectDomRendererAdapter {
|
|
7
|
-
/**
|
|
8
|
-
* Returns rendered child count for this instance.
|
|
9
|
-
*
|
|
10
|
-
* @returns {number}
|
|
11
|
-
*/ getRenderedChildCount() {
|
|
12
|
-
const { rootNode, sizeSet } = this.orderView;
|
|
13
|
-
let childElementCount = 0;
|
|
14
|
-
if (this.orderView.isSharedViewSet()) {
|
|
15
|
-
let element = rootNode.firstElementChild;
|
|
16
|
-
while(element){
|
|
17
|
-
if (element.tagName === this.orderView.childNodeType) {
|
|
18
|
-
childElementCount += 1;
|
|
19
|
-
} else if (sizeSet.isPlaceOn(WORKING_SPACE_TOP)) {
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
element = element.nextElementSibling;
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
childElementCount = rootNode.childElementCount;
|
|
26
|
-
}
|
|
27
|
-
return childElementCount;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Sets up and prepares all necessary properties and starts the rendering process.
|
|
31
|
-
* This method has to be called only once (at the start) for the render cycle.
|
|
32
|
-
*/ start() {
|
|
33
|
-
this.orderView.collectedNodes.length = 0;
|
|
34
|
-
this.visualIndex = 0;
|
|
35
|
-
const { rootNode, sizeSet } = this.orderView;
|
|
36
|
-
const isShared = this.orderView.isSharedViewSet();
|
|
37
|
-
const { nextSize } = sizeSet.getViewSize();
|
|
38
|
-
let childElementCount = this.getRenderedChildCount();
|
|
39
|
-
while(childElementCount < nextSize){
|
|
40
|
-
const newNode = this.orderView.nodesPool();
|
|
41
|
-
if (!isShared || isShared && sizeSet.isPlaceOn(WORKING_SPACE_BOTTOM)) {
|
|
42
|
-
rootNode.appendChild(newNode);
|
|
43
|
-
} else {
|
|
44
|
-
rootNode.insertBefore(newNode, rootNode.firstChild);
|
|
45
|
-
}
|
|
46
|
-
childElementCount += 1;
|
|
47
|
-
}
|
|
48
|
-
const isSharedPlacedOnTop = isShared && sizeSet.isPlaceOn(WORKING_SPACE_TOP);
|
|
49
|
-
while(childElementCount > nextSize){
|
|
50
|
-
const childToRemove = isSharedPlacedOnTop ? rootNode.firstChild : rootNode.lastChild;
|
|
51
|
-
if (childToRemove) {
|
|
52
|
-
rootNode.removeChild(childToRemove);
|
|
53
|
-
}
|
|
54
|
-
childElementCount -= 1;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Renders the DOM element based on visual index (which is calculated internally).
|
|
59
|
-
* This method has to be called as many times as the size count is met (to cover all previously rendered DOM elements).
|
|
60
|
-
*/ render() {
|
|
61
|
-
const { rootNode, sizeSet } = this.orderView;
|
|
62
|
-
let visualIndex = this.visualIndex;
|
|
63
|
-
if (this.orderView.isSharedViewSet() && sizeSet.isPlaceOn(WORKING_SPACE_BOTTOM) && sizeSet.sharedSize) {
|
|
64
|
-
visualIndex += sizeSet.sharedSize.nextSize;
|
|
65
|
-
}
|
|
66
|
-
let node = rootNode.childNodes[visualIndex];
|
|
67
|
-
if (node.tagName !== this.orderView.childNodeType) {
|
|
68
|
-
const newNode = this.orderView.nodesPool();
|
|
69
|
-
node.replaceWith(newNode);
|
|
70
|
-
node = newNode;
|
|
71
|
-
}
|
|
72
|
-
this.orderView.collectedNodes.push(node);
|
|
73
|
-
this.visualIndex += 1;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Ends the render process.
|
|
77
|
-
* This method has to be called only once (at the end) for the render cycle.
|
|
78
|
-
*/ end() {
|
|
79
|
-
// Firefox doesn't need cleanup - all work is done in start() and render()
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @param {OrderView} orderView The OrderView instance.
|
|
83
|
-
*/ constructor(orderView){
|
|
84
|
-
/**
|
|
85
|
-
* The visual index of currently processed row.
|
|
86
|
-
*
|
|
87
|
-
* @type {number}
|
|
88
|
-
*/ this.visualIndex = 0;
|
|
89
|
-
this.orderView = orderView;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './index.js';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { OrderView } from '../view';
|
|
2
|
-
import { DifferBasedRendererAdapter } from './differBasedRendererAdapter';
|
|
3
|
-
import { DirectDomRendererAdapter } from './directDomRendererAdapter';
|
|
4
|
-
/**
|
|
5
|
-
* Factory function to create the appropriate renderer adapter based on the browser.
|
|
6
|
-
*
|
|
7
|
-
* @param {OrderView} orderView The OrderView instance.
|
|
8
|
-
* @returns {DifferBasedRendererAdapter|DirectDomRendererAdapter}
|
|
9
|
-
*/
|
|
10
|
-
export declare function createRendererAdapter(orderView: OrderView): DifferBasedRendererAdapter | DirectDomRendererAdapter;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createRendererAdapter", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return createRendererAdapter;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _browser = require("../../../../../../helpers/browser");
|
|
12
|
-
const _differBasedRendererAdapter = require("./differBasedRendererAdapter");
|
|
13
|
-
const _directDomRendererAdapter = require("./directDomRendererAdapter");
|
|
14
|
-
function createRendererAdapter(orderView) {
|
|
15
|
-
if ((0, _browser.isFirefox)()) {
|
|
16
|
-
return new _directDomRendererAdapter.DirectDomRendererAdapter(orderView);
|
|
17
|
-
}
|
|
18
|
-
return new _differBasedRendererAdapter.DifferBasedRendererAdapter(orderView);
|
|
19
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { isFirefox } from '../../../../../../helpers/browser.mjs';
|
|
2
|
-
import { DifferBasedRendererAdapter } from './differBasedRendererAdapter.mjs';
|
|
3
|
-
import { DirectDomRendererAdapter } from './directDomRendererAdapter.mjs';
|
|
4
|
-
/**
|
|
5
|
-
* Factory function to create the appropriate renderer adapter based on the browser.
|
|
6
|
-
*
|
|
7
|
-
* @param {OrderView} orderView The OrderView instance.
|
|
8
|
-
* @returns {DifferBasedRendererAdapter|DirectDomRendererAdapter}
|
|
9
|
-
*/ export function createRendererAdapter(orderView) {
|
|
10
|
-
if (isFirefox()) {
|
|
11
|
-
return new DirectDomRendererAdapter(orderView);
|
|
12
|
-
}
|
|
13
|
-
return new DifferBasedRendererAdapter(orderView);
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './index.js';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { ViewSizeSet } from '../viewSizeSet';
|
|
2
|
-
/**
|
|
3
|
-
* A class which is responsible for generating commands/leads which has to be executed
|
|
4
|
-
* to achieve new DOM nodes order.
|
|
5
|
-
*
|
|
6
|
-
* @class {ViewDiffer}
|
|
7
|
-
*/
|
|
8
|
-
export declare class ViewDiffer {
|
|
9
|
-
/**
|
|
10
|
-
* @type {ViewSizeSet}
|
|
11
|
-
*/
|
|
12
|
-
sizeSet: ViewSizeSet;
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new ViewDiffer instance.
|
|
15
|
-
*
|
|
16
|
-
* @param {ViewSizeSet} sizeSet - The view size configuration to use for generating commands.
|
|
17
|
-
*/
|
|
18
|
-
constructor(sizeSet: ViewSizeSet);
|
|
19
|
-
/**
|
|
20
|
-
* A method which generates commands/leads which has to be executed to achieve new DOM
|
|
21
|
-
* nodes order based on new offset and view size.
|
|
22
|
-
*
|
|
23
|
-
* For example, if current order looks like this (offset = 0, viewSize = 1):
|
|
24
|
-
* <body> (root node)
|
|
25
|
-
* └ <tr> (row 0)
|
|
26
|
-
* and next order should look like this (offset: 0, viewSize = 5):
|
|
27
|
-
* <body> (root node)
|
|
28
|
-
* ├ <tr> (row 0)
|
|
29
|
-
* ├ <tr> (row 1)
|
|
30
|
-
* ├ <tr> (row 2)
|
|
31
|
-
* ├ <tr> (row 3)
|
|
32
|
-
* └ <tr> (row 4)
|
|
33
|
-
* the generated commands/leads will look like this:
|
|
34
|
-
* <body> (root node)
|
|
35
|
-
* ├ <tr> (none, do nothing, leave as it is)
|
|
36
|
-
* ├ <tr> (append this element at index 1)
|
|
37
|
-
* ├ <tr> (append this element at index 2)
|
|
38
|
-
* ├ <tr> (append this element at index 3)
|
|
39
|
-
* └ <tr> (append this element at index 4)
|
|
40
|
-
*
|
|
41
|
-
* @returns {Array[]} Returns an array with generated commands/leads.
|
|
42
|
-
*/
|
|
43
|
-
diff(): number[][];
|
|
44
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ViewDiffer", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ViewDiffer;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _constants = require("../constants");
|
|
12
|
-
const _viewOrder = require("./viewOrder");
|
|
13
|
-
class ViewDiffer {
|
|
14
|
-
/**
|
|
15
|
-
* A method which generates commands/leads which has to be executed to achieve new DOM
|
|
16
|
-
* nodes order based on new offset and view size.
|
|
17
|
-
*
|
|
18
|
-
* For example, if current order looks like this (offset = 0, viewSize = 1):
|
|
19
|
-
* <body> (root node)
|
|
20
|
-
* └ <tr> (row 0)
|
|
21
|
-
* and next order should look like this (offset: 0, viewSize = 5):
|
|
22
|
-
* <body> (root node)
|
|
23
|
-
* ├ <tr> (row 0)
|
|
24
|
-
* ├ <tr> (row 1)
|
|
25
|
-
* ├ <tr> (row 2)
|
|
26
|
-
* ├ <tr> (row 3)
|
|
27
|
-
* └ <tr> (row 4)
|
|
28
|
-
* the generated commands/leads will look like this:
|
|
29
|
-
* <body> (root node)
|
|
30
|
-
* ├ <tr> (none, do nothing, leave as it is)
|
|
31
|
-
* ├ <tr> (append this element at index 1)
|
|
32
|
-
* ├ <tr> (append this element at index 2)
|
|
33
|
-
* ├ <tr> (append this element at index 3)
|
|
34
|
-
* └ <tr> (append this element at index 4)
|
|
35
|
-
*
|
|
36
|
-
* @returns {Array[]} Returns an array with generated commands/leads.
|
|
37
|
-
*/ diff() {
|
|
38
|
-
const { sizeSet } = this;
|
|
39
|
-
const { currentSize: currentViewSize, nextSize: nextViewSize, currentOffset, nextOffset } = sizeSet.getViewSize();
|
|
40
|
-
let maxSize = Math.max(nextViewSize, currentViewSize);
|
|
41
|
-
if (maxSize === 0) {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
const currentViewOrder = new _viewOrder.ViewOrder(currentOffset, currentViewSize);
|
|
45
|
-
const isShared = sizeSet.isShared();
|
|
46
|
-
const useAppend = !isShared || sizeSet.isPlaceOn(_constants.WORKING_SPACE_BOTTOM);
|
|
47
|
-
const leads = [];
|
|
48
|
-
for(let i = 0; i < maxSize; i++){
|
|
49
|
-
const currentIndex = currentViewOrder.get(i);
|
|
50
|
-
const nextIndex = i < nextViewSize ? nextOffset + i : -1;
|
|
51
|
-
// Current index exceeds the next DOM index so it is necessary to generate a "remove" command
|
|
52
|
-
// to achieve new order.
|
|
53
|
-
if (nextIndex === -1) {
|
|
54
|
-
leads.push([
|
|
55
|
-
_constants.CMD_REMOVE,
|
|
56
|
-
currentIndex
|
|
57
|
-
]);
|
|
58
|
-
// Next index exceeds the current DOM index so it is necessary to generate a "append" command
|
|
59
|
-
// to achieve new order.
|
|
60
|
-
} else if (currentIndex === -1) {
|
|
61
|
-
// Check what command should be generated (depends on if this work as a shared root node
|
|
62
|
-
// and in what position or not)
|
|
63
|
-
if (useAppend) {
|
|
64
|
-
/**
|
|
65
|
-
* If the differ has only one root node to manage with, the "append" command is generated.
|
|
66
|
-
*
|
|
67
|
-
* For example:
|
|
68
|
-
* ┌─────────── <body> (root node)
|
|
69
|
-
* │ <tr>
|
|
70
|
-
* │ <tr>
|
|
71
|
-
* (managed by one <tr>
|
|
72
|
-
* differ - TRs) <tr>
|
|
73
|
-
* │ <tr>
|
|
74
|
-
* └─────────── <tr> <--- Generates "append" command (which later executes `rootNode.appendChild(node)`)
|
|
75
|
-
*/ leads.push([
|
|
76
|
-
_constants.CMD_APPEND,
|
|
77
|
-
nextIndex
|
|
78
|
-
]);
|
|
79
|
-
} else {
|
|
80
|
-
/**
|
|
81
|
-
* If the differ is sharing root node, the "prepend" command is generated.
|
|
82
|
-
*
|
|
83
|
-
* For example:
|
|
84
|
-
* ┌─────────── <tr> (root node, shared between two differs)
|
|
85
|
-
* (first differ) <th> <--- Generates "prepend" command (which later executes `rootNode.insertBefore(...)`)
|
|
86
|
-
* ├─────────── <td>
|
|
87
|
-
* │ <td>
|
|
88
|
-
* (second differ <td>
|
|
89
|
-
* - TDs) <td>
|
|
90
|
-
* │ <td>
|
|
91
|
-
* └─────────── <td>
|
|
92
|
-
*/ leads.push([
|
|
93
|
-
_constants.CMD_PREPEND,
|
|
94
|
-
nextIndex
|
|
95
|
-
]);
|
|
96
|
-
}
|
|
97
|
-
} else if (nextIndex > currentIndex) {
|
|
98
|
-
// This emulates DOM behavior when we try to append (or replace) an element which is already
|
|
99
|
-
// mounted. The old index in the array has to be popped out indicating that an element was
|
|
100
|
-
// moved to a different position.
|
|
101
|
-
if (currentViewOrder.has(nextIndex)) {
|
|
102
|
-
currentViewOrder.remove(nextIndex);
|
|
103
|
-
// Decrease loop size to prevent generating "remove" leads. "remove" leads are necessary only for nodes
|
|
104
|
-
// which are not mounted in current DOM order.
|
|
105
|
-
if (nextViewSize <= currentViewOrder.length) {
|
|
106
|
-
maxSize -= 1;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
leads.push([
|
|
110
|
-
_constants.CMD_REPLACE,
|
|
111
|
-
nextIndex,
|
|
112
|
-
currentIndex
|
|
113
|
-
]);
|
|
114
|
-
} else if (nextIndex < currentIndex) {
|
|
115
|
-
const indexToRemove = currentViewOrder.prepend(nextIndex);
|
|
116
|
-
leads.push([
|
|
117
|
-
_constants.CMD_INSERT_BEFORE,
|
|
118
|
-
nextIndex,
|
|
119
|
-
currentIndex,
|
|
120
|
-
indexToRemove
|
|
121
|
-
]);
|
|
122
|
-
} else {
|
|
123
|
-
leads.push([
|
|
124
|
-
_constants.CMD_NONE,
|
|
125
|
-
nextIndex
|
|
126
|
-
]);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return leads;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Creates a new ViewDiffer instance.
|
|
133
|
-
*
|
|
134
|
-
* @param {ViewSizeSet} sizeSet - The view size configuration to use for generating commands.
|
|
135
|
-
*/ constructor(sizeSet){
|
|
136
|
-
this.sizeSet = sizeSet;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { WORKING_SPACE_BOTTOM, CMD_NONE, CMD_REMOVE, CMD_APPEND, CMD_PREPEND, CMD_INSERT_BEFORE, CMD_REPLACE } from '../constants.mjs';
|
|
2
|
-
import { ViewOrder } from './viewOrder.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* A class which is responsible for generating commands/leads which has to be executed
|
|
5
|
-
* to achieve new DOM nodes order.
|
|
6
|
-
*
|
|
7
|
-
* @class {ViewDiffer}
|
|
8
|
-
*/ export class ViewDiffer {
|
|
9
|
-
/**
|
|
10
|
-
* A method which generates commands/leads which has to be executed to achieve new DOM
|
|
11
|
-
* nodes order based on new offset and view size.
|
|
12
|
-
*
|
|
13
|
-
* For example, if current order looks like this (offset = 0, viewSize = 1):
|
|
14
|
-
* <body> (root node)
|
|
15
|
-
* └ <tr> (row 0)
|
|
16
|
-
* and next order should look like this (offset: 0, viewSize = 5):
|
|
17
|
-
* <body> (root node)
|
|
18
|
-
* ├ <tr> (row 0)
|
|
19
|
-
* ├ <tr> (row 1)
|
|
20
|
-
* ├ <tr> (row 2)
|
|
21
|
-
* ├ <tr> (row 3)
|
|
22
|
-
* └ <tr> (row 4)
|
|
23
|
-
* the generated commands/leads will look like this:
|
|
24
|
-
* <body> (root node)
|
|
25
|
-
* ├ <tr> (none, do nothing, leave as it is)
|
|
26
|
-
* ├ <tr> (append this element at index 1)
|
|
27
|
-
* ├ <tr> (append this element at index 2)
|
|
28
|
-
* ├ <tr> (append this element at index 3)
|
|
29
|
-
* └ <tr> (append this element at index 4)
|
|
30
|
-
*
|
|
31
|
-
* @returns {Array[]} Returns an array with generated commands/leads.
|
|
32
|
-
*/ diff() {
|
|
33
|
-
const { sizeSet } = this;
|
|
34
|
-
const { currentSize: currentViewSize, nextSize: nextViewSize, currentOffset, nextOffset } = sizeSet.getViewSize();
|
|
35
|
-
let maxSize = Math.max(nextViewSize, currentViewSize);
|
|
36
|
-
if (maxSize === 0) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
const currentViewOrder = new ViewOrder(currentOffset, currentViewSize);
|
|
40
|
-
const isShared = sizeSet.isShared();
|
|
41
|
-
const useAppend = !isShared || sizeSet.isPlaceOn(WORKING_SPACE_BOTTOM);
|
|
42
|
-
const leads = [];
|
|
43
|
-
for(let i = 0; i < maxSize; i++){
|
|
44
|
-
const currentIndex = currentViewOrder.get(i);
|
|
45
|
-
const nextIndex = i < nextViewSize ? nextOffset + i : -1;
|
|
46
|
-
// Current index exceeds the next DOM index so it is necessary to generate a "remove" command
|
|
47
|
-
// to achieve new order.
|
|
48
|
-
if (nextIndex === -1) {
|
|
49
|
-
leads.push([
|
|
50
|
-
CMD_REMOVE,
|
|
51
|
-
currentIndex
|
|
52
|
-
]);
|
|
53
|
-
// Next index exceeds the current DOM index so it is necessary to generate a "append" command
|
|
54
|
-
// to achieve new order.
|
|
55
|
-
} else if (currentIndex === -1) {
|
|
56
|
-
// Check what command should be generated (depends on if this work as a shared root node
|
|
57
|
-
// and in what position or not)
|
|
58
|
-
if (useAppend) {
|
|
59
|
-
/**
|
|
60
|
-
* If the differ has only one root node to manage with, the "append" command is generated.
|
|
61
|
-
*
|
|
62
|
-
* For example:
|
|
63
|
-
* ┌─────────── <body> (root node)
|
|
64
|
-
* │ <tr>
|
|
65
|
-
* │ <tr>
|
|
66
|
-
* (managed by one <tr>
|
|
67
|
-
* differ - TRs) <tr>
|
|
68
|
-
* │ <tr>
|
|
69
|
-
* └─────────── <tr> <--- Generates "append" command (which later executes `rootNode.appendChild(node)`)
|
|
70
|
-
*/ leads.push([
|
|
71
|
-
CMD_APPEND,
|
|
72
|
-
nextIndex
|
|
73
|
-
]);
|
|
74
|
-
} else {
|
|
75
|
-
/**
|
|
76
|
-
* If the differ is sharing root node, the "prepend" command is generated.
|
|
77
|
-
*
|
|
78
|
-
* For example:
|
|
79
|
-
* ┌─────────── <tr> (root node, shared between two differs)
|
|
80
|
-
* (first differ) <th> <--- Generates "prepend" command (which later executes `rootNode.insertBefore(...)`)
|
|
81
|
-
* ├─────────── <td>
|
|
82
|
-
* │ <td>
|
|
83
|
-
* (second differ <td>
|
|
84
|
-
* - TDs) <td>
|
|
85
|
-
* │ <td>
|
|
86
|
-
* └─────────── <td>
|
|
87
|
-
*/ leads.push([
|
|
88
|
-
CMD_PREPEND,
|
|
89
|
-
nextIndex
|
|
90
|
-
]);
|
|
91
|
-
}
|
|
92
|
-
} else if (nextIndex > currentIndex) {
|
|
93
|
-
// This emulates DOM behavior when we try to append (or replace) an element which is already
|
|
94
|
-
// mounted. The old index in the array has to be popped out indicating that an element was
|
|
95
|
-
// moved to a different position.
|
|
96
|
-
if (currentViewOrder.has(nextIndex)) {
|
|
97
|
-
currentViewOrder.remove(nextIndex);
|
|
98
|
-
// Decrease loop size to prevent generating "remove" leads. "remove" leads are necessary only for nodes
|
|
99
|
-
// which are not mounted in current DOM order.
|
|
100
|
-
if (nextViewSize <= currentViewOrder.length) {
|
|
101
|
-
maxSize -= 1;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
leads.push([
|
|
105
|
-
CMD_REPLACE,
|
|
106
|
-
nextIndex,
|
|
107
|
-
currentIndex
|
|
108
|
-
]);
|
|
109
|
-
} else if (nextIndex < currentIndex) {
|
|
110
|
-
const indexToRemove = currentViewOrder.prepend(nextIndex);
|
|
111
|
-
leads.push([
|
|
112
|
-
CMD_INSERT_BEFORE,
|
|
113
|
-
nextIndex,
|
|
114
|
-
currentIndex,
|
|
115
|
-
indexToRemove
|
|
116
|
-
]);
|
|
117
|
-
} else {
|
|
118
|
-
leads.push([
|
|
119
|
-
CMD_NONE,
|
|
120
|
-
nextIndex
|
|
121
|
-
]);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return leads;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Creates a new ViewDiffer instance.
|
|
128
|
-
*
|
|
129
|
-
* @param {ViewSizeSet} sizeSet - The view size configuration to use for generating commands.
|
|
130
|
-
*/ constructor(sizeSet){
|
|
131
|
-
this.sizeSet = sizeSet;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './viewOrder.js';
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The view order is a list of indexes that represent the order of the rendered elements.
|
|
3
|
-
* Uses a Set alongside the array for O(1) membership checks.
|
|
4
|
-
*
|
|
5
|
-
* @class {ViewOrder}
|
|
6
|
-
*/
|
|
7
|
-
export declare class ViewOrder {
|
|
8
|
-
#private;
|
|
9
|
-
/**
|
|
10
|
-
* Array of offset indexes representing the order of rendered elements.
|
|
11
|
-
*
|
|
12
|
-
* @type {number[]}
|
|
13
|
-
*/
|
|
14
|
-
order: number[];
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new ViewOrder instance with offset indexes from viewOffset to viewOffset + viewSize.
|
|
17
|
-
*
|
|
18
|
-
* @param {number} viewOffset The starting offset index.
|
|
19
|
-
* @param {number} viewSize The number of elements in the view.
|
|
20
|
-
*/
|
|
21
|
-
constructor(viewOffset: number, viewSize: number);
|
|
22
|
-
/**
|
|
23
|
-
* The length of the view order.
|
|
24
|
-
*
|
|
25
|
-
* @returns {number}
|
|
26
|
-
*/
|
|
27
|
-
get length(): number;
|
|
28
|
-
/**
|
|
29
|
-
* Checks if the view order contains the offset index.
|
|
30
|
-
*
|
|
31
|
-
* @param {number} offsetIndex The offset index.
|
|
32
|
-
* @returns {boolean}
|
|
33
|
-
*/
|
|
34
|
-
has(offsetIndex: number): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Gets the offset index at the given zero-based index. If the index
|
|
37
|
-
* is out of bounds, -1 is returned.
|
|
38
|
-
*
|
|
39
|
-
* @param {number} zeroBasedIndex The zero-based index.
|
|
40
|
-
* @returns {number}
|
|
41
|
-
*/
|
|
42
|
-
get(zeroBasedIndex: number): number;
|
|
43
|
-
/**
|
|
44
|
-
* Removes the offset index from the view order.
|
|
45
|
-
*
|
|
46
|
-
* @param {number} offsetIndex The offset index.
|
|
47
|
-
*/
|
|
48
|
-
remove(offsetIndex: number): void;
|
|
49
|
-
/**
|
|
50
|
-
* Prepends the offset index to the view order. To keep the order length constant,
|
|
51
|
-
* the last offset index is removed.
|
|
52
|
-
*
|
|
53
|
-
* @param {number} offsetIndex The offset index.
|
|
54
|
-
* @returns {number}
|
|
55
|
-
*/
|
|
56
|
-
prepend(offsetIndex: number): number;
|
|
57
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The view order is a list of indexes that represent the order of the rendered elements.
|
|
3
|
-
* Uses a Set alongside the array for O(1) membership checks.
|
|
4
|
-
*
|
|
5
|
-
* @class {ViewOrder}
|
|
6
|
-
*/ "use strict";
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
Object.defineProperty(exports, "ViewOrder", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function() {
|
|
13
|
-
return ViewOrder;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
17
|
-
if (privateCollection.has(obj)) {
|
|
18
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
22
|
-
if (descriptor.get) {
|
|
23
|
-
return descriptor.get.call(receiver);
|
|
24
|
-
}
|
|
25
|
-
return descriptor.value;
|
|
26
|
-
}
|
|
27
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
28
|
-
if (descriptor.set) {
|
|
29
|
-
descriptor.set.call(receiver, value);
|
|
30
|
-
} else {
|
|
31
|
-
if (!descriptor.writable) {
|
|
32
|
-
throw new TypeError("attempted to set read only private field");
|
|
33
|
-
}
|
|
34
|
-
descriptor.value = value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
38
|
-
if (!privateMap.has(receiver)) {
|
|
39
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
40
|
-
}
|
|
41
|
-
return privateMap.get(receiver);
|
|
42
|
-
}
|
|
43
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
44
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
45
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
46
|
-
}
|
|
47
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
48
|
-
_check_private_redeclaration(obj, privateMap);
|
|
49
|
-
privateMap.set(obj, value);
|
|
50
|
-
}
|
|
51
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
52
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
53
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
var /**
|
|
57
|
-
* Set of offset indexes for O(1) membership checks.
|
|
58
|
-
*
|
|
59
|
-
* @type {Set<number>}
|
|
60
|
-
*/ _indexSet = /*#__PURE__*/ new WeakMap();
|
|
61
|
-
class ViewOrder {
|
|
62
|
-
/**
|
|
63
|
-
* The length of the view order.
|
|
64
|
-
*
|
|
65
|
-
* @returns {number}
|
|
66
|
-
*/ get length() {
|
|
67
|
-
return this.order.length;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks if the view order contains the offset index.
|
|
71
|
-
*
|
|
72
|
-
* @param {number} offsetIndex The offset index.
|
|
73
|
-
* @returns {boolean}
|
|
74
|
-
*/ has(offsetIndex) {
|
|
75
|
-
return _class_private_field_get(this, _indexSet).has(offsetIndex);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Gets the offset index at the given zero-based index. If the index
|
|
79
|
-
* is out of bounds, -1 is returned.
|
|
80
|
-
*
|
|
81
|
-
* @param {number} zeroBasedIndex The zero-based index.
|
|
82
|
-
* @returns {number}
|
|
83
|
-
*/ get(zeroBasedIndex) {
|
|
84
|
-
return zeroBasedIndex < this.order.length ? this.order[zeroBasedIndex] ?? -1 : -1;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Removes the offset index from the view order.
|
|
88
|
-
*
|
|
89
|
-
* @param {number} offsetIndex The offset index.
|
|
90
|
-
*/ remove(offsetIndex) {
|
|
91
|
-
const idx = this.order.indexOf(offsetIndex);
|
|
92
|
-
if (idx > -1) {
|
|
93
|
-
this.order.splice(idx, 1);
|
|
94
|
-
_class_private_field_get(this, _indexSet).delete(offsetIndex);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Prepends the offset index to the view order. To keep the order length constant,
|
|
99
|
-
* the last offset index is removed.
|
|
100
|
-
*
|
|
101
|
-
* @param {number} offsetIndex The offset index.
|
|
102
|
-
* @returns {number}
|
|
103
|
-
*/ prepend(offsetIndex) {
|
|
104
|
-
this.order.unshift(offsetIndex);
|
|
105
|
-
_class_private_field_get(this, _indexSet).add(offsetIndex);
|
|
106
|
-
const removed = this.order.pop();
|
|
107
|
-
if (removed !== undefined) {
|
|
108
|
-
_class_private_field_get(this, _indexSet).delete(removed);
|
|
109
|
-
}
|
|
110
|
-
return removed ?? -1;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Creates a new ViewOrder instance with offset indexes from viewOffset to viewOffset + viewSize.
|
|
114
|
-
*
|
|
115
|
-
* @param {number} viewOffset The starting offset index.
|
|
116
|
-
* @param {number} viewSize The number of elements in the view.
|
|
117
|
-
*/ constructor(viewOffset, viewSize){
|
|
118
|
-
_class_private_field_init(this, _indexSet, {
|
|
119
|
-
writable: true,
|
|
120
|
-
value: void 0
|
|
121
|
-
});
|
|
122
|
-
/**
|
|
123
|
-
* Array of offset indexes representing the order of rendered elements.
|
|
124
|
-
*
|
|
125
|
-
* @type {number[]}
|
|
126
|
-
*/ this.order = [];
|
|
127
|
-
_class_private_field_set(this, _indexSet, new Set());
|
|
128
|
-
const order = new Array(viewSize);
|
|
129
|
-
const indexSet = _class_private_field_get(this, _indexSet);
|
|
130
|
-
for(let i = 0; i < viewSize; i++){
|
|
131
|
-
const value = viewOffset + i;
|
|
132
|
-
order[i] = value;
|
|
133
|
-
indexSet.add(value);
|
|
134
|
-
}
|
|
135
|
-
this.order = order;
|
|
136
|
-
}
|
|
137
|
-
}
|