@revolist/revogrid 4.9.37 → 4.9.40
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/dist/cjs/{column.drag.plugin-ffe1918f.js → column.drag.plugin-fcd892ec.js} +18 -18
- package/dist/cjs/column.drag.plugin-fcd892ec.js.map +1 -0
- package/dist/cjs/{index-947f3534.js → column.service-26c61ed6.js} +1256 -469
- package/dist/cjs/column.service-26c61ed6.js.map +1 -0
- package/dist/cjs/{edit.utils-68a4f1c4.js → edit.utils-179c0800.js} +2 -2
- package/dist/cjs/{edit.utils-68a4f1c4.js.map → edit.utils-179c0800.js.map} +1 -1
- package/dist/cjs/{header-cell-renderer-57fb8f18.js → header-cell-renderer-d879d95e.js} +2 -2
- package/dist/cjs/{header-cell-renderer-57fb8f18.js.map → header-cell-renderer-d879d95e.js.map} +1 -1
- package/dist/cjs/index-3ab26ab9.js +513 -0
- package/dist/cjs/index-3ab26ab9.js.map +1 -0
- package/dist/cjs/index.cjs.js +21 -20
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/{key.utils-da2ead49.js → key.utils-f49d7bee.js} +2 -2
- package/dist/cjs/{key.utils-da2ead49.js.map → key.utils-f49d7bee.js.map} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/revo-grid.cjs.entry.js +87 -55
- package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/revo-grid.cjs.js +1 -1
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +13 -13
- package/dist/cjs/revogr-attribution_7.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +21 -18
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-data_4.cjs.entry.js +9 -9
- package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
- package/dist/cjs/{row-header-utils-fe2264e7.js → row-header-utils-c37f76e4.js} +6 -5
- package/dist/cjs/row-header-utils-c37f76e4.js.map +1 -0
- package/dist/cjs/{text-editor-55511a6a.js → text-editor-b756d6b3.js} +3 -3
- package/dist/cjs/{text-editor-55511a6a.js.map → text-editor-b756d6b3.js.map} +1 -1
- package/dist/cjs/{throttle-2ae258fb.js → throttle-a57f51f9.js} +2 -2
- package/dist/cjs/{throttle-2ae258fb.js.map → throttle-a57f51f9.js.map} +1 -1
- package/dist/collection/components/order/revogr-order-editor.js +99 -27
- package/dist/collection/components/order/revogr-order-editor.js.map +1 -1
- package/dist/collection/components/overlay/revogr-overlay-selection.js +2 -2
- package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
- package/dist/collection/components/revoGrid/revo-grid.js +10 -0
- package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
- package/dist/collection/plugins/sorting/sorting.plugin.js +25 -27
- package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
- package/dist/collection/services/data.provider.js +12 -5
- package/dist/collection/services/data.provider.js.map +1 -1
- package/dist/collection/services/dimension.provider.js +22 -0
- package/dist/collection/services/dimension.provider.js.map +1 -1
- package/dist/collection/store/dataSource/data.proxy.js +19 -6
- package/dist/collection/store/dataSource/data.proxy.js.map +1 -1
- package/dist/collection/store/dataSource/data.store.js +3 -0
- package/dist/collection/store/dataSource/data.store.js.map +1 -1
- package/dist/collection/types/events.js +1 -0
- package/dist/collection/types/events.js.map +1 -1
- package/dist/esm/{column.drag.plugin-bbd79520.js → column.drag.plugin-3cc77986.js} +6 -6
- package/dist/esm/{column.drag.plugin-bbd79520.js.map → column.drag.plugin-3cc77986.js.map} +1 -1
- package/dist/esm/{index-8eeaa30d.js → column.service-751345b2.js} +1216 -427
- package/dist/esm/column.service-751345b2.js.map +1 -0
- package/dist/esm/{debounce-7b511afc.js → debounce-72878ced.js} +2 -2
- package/dist/esm/{debounce-7b511afc.js.map → debounce-72878ced.js.map} +1 -1
- package/dist/esm/{edit.utils-aeb2dc7c.js → edit.utils-6fc686b9.js} +2 -2
- package/dist/esm/{edit.utils-aeb2dc7c.js.map → edit.utils-6fc686b9.js.map} +1 -1
- package/dist/esm/{header-cell-renderer-1aec2328.js → header-cell-renderer-32d2ed96.js} +2 -2
- package/dist/esm/{header-cell-renderer-1aec2328.js.map → header-cell-renderer-32d2ed96.js.map} +1 -1
- package/dist/esm/index-1dcad6ef.js +476 -0
- package/dist/esm/index-1dcad6ef.js.map +1 -0
- package/dist/esm/index.js +9 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{key.utils-9ee5fa40.js → key.utils-17273f42.js} +2 -2
- package/dist/esm/{key.utils-9ee5fa40.js.map → key.utils-17273f42.js.map} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/revo-grid.entry.js +67 -35
- package/dist/esm/revo-grid.entry.js.map +1 -1
- package/dist/esm/revo-grid.js +1 -1
- package/dist/esm/revogr-attribution_7.entry.js +9 -9
- package/dist/esm/revogr-attribution_7.entry.js.map +1 -1
- package/dist/esm/revogr-clipboard_3.entry.js +22 -19
- package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/esm/revogr-data_4.entry.js +5 -5
- package/dist/esm/revogr-filter-panel.entry.js +1 -1
- package/dist/esm/{row-header-utils-3220f80d.js → row-header-utils-3dfbb81f.js} +3 -2
- package/dist/esm/row-header-utils-3dfbb81f.js.map +1 -0
- package/dist/esm/{text-editor-d9dcf56d.js → text-editor-901c3eb8.js} +3 -3
- package/dist/esm/{text-editor-d9dcf56d.js.map → text-editor-901c3eb8.js.map} +1 -1
- package/dist/esm/{throttle-ce8e57c9.js → throttle-138d69c3.js} +3 -3
- package/dist/esm/{throttle-ce8e57c9.js.map → throttle-138d69c3.js.map} +1 -1
- package/dist/revo-grid/column.drag.plugin-3cc77986.js +5 -0
- package/dist/revo-grid/{column.drag.plugin-bbd79520.js.map → column.drag.plugin-3cc77986.js.map} +1 -1
- package/dist/revo-grid/column.service-751345b2.js +5 -0
- package/dist/revo-grid/column.service-751345b2.js.map +1 -0
- package/dist/revo-grid/{debounce-7b511afc.js → debounce-72878ced.js} +2 -2
- package/dist/revo-grid/{edit.utils-aeb2dc7c.js → edit.utils-6fc686b9.js} +2 -2
- package/dist/revo-grid/{header-cell-renderer-1aec2328.js → header-cell-renderer-32d2ed96.js} +2 -2
- package/dist/revo-grid/index-1dcad6ef.js +5 -0
- package/dist/revo-grid/index-1dcad6ef.js.map +1 -0
- package/dist/revo-grid/index.esm.js +1 -1
- package/dist/revo-grid/index.esm.js.map +1 -1
- package/dist/revo-grid/key.utils-17273f42.js +5 -0
- package/dist/revo-grid/{key.utils-9ee5fa40.js.map → key.utils-17273f42.js.map} +1 -1
- package/dist/revo-grid/revo-grid.entry.js +1 -1
- package/dist/revo-grid/revo-grid.entry.js.map +1 -1
- package/dist/revo-grid/revo-grid.esm.js +1 -1
- package/dist/revo-grid/revo-grid.esm.js.map +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js.map +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
- package/dist/revo-grid/revogr-filter-panel.entry.js +1 -1
- package/dist/revo-grid/row-header-utils-3dfbb81f.js +5 -0
- package/dist/revo-grid/{row-header-utils-3220f80d.js.map → row-header-utils-3dfbb81f.js.map} +1 -1
- package/dist/revo-grid/text-editor-901c3eb8.js +5 -0
- package/dist/revo-grid/{throttle-ce8e57c9.js → throttle-138d69c3.js} +2 -2
- package/dist/types/components/order/revogr-order-editor.d.ts +18 -4
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +2 -4
- package/dist/types/components/revoGrid/revo-grid.d.ts +1 -0
- package/dist/types/components.d.ts +25 -6
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +4 -4
- package/dist/types/services/data.provider.d.ts +5 -0
- package/dist/types/services/dimension.provider.d.ts +1 -0
- package/dist/types/store/dataSource/data.proxy.d.ts +9 -3
- package/dist/types/store/dataSource/data.store.d.ts +1 -0
- package/dist/types/types/events.d.ts +1 -1
- package/hydrate/index.js +127 -75
- package/hydrate/index.mjs +127 -75
- package/package.json +1 -1
- package/standalone/column.service.js +1 -1
- package/standalone/data.store.js +28 -31
- package/standalone/data.store.js.map +1 -1
- package/standalone/dimension.helpers.js +1 -1
- package/standalone/identity.js +26 -0
- package/standalone/identity.js.map +1 -0
- package/standalone/index.js +2 -1
- package/standalone/index.js.map +1 -1
- package/standalone/revo-grid.js +64 -31
- package/standalone/revo-grid.js.map +1 -1
- package/standalone/revogr-header2.js +1 -1
- package/standalone/revogr-order-editor2.js +18 -15
- package/standalone/revogr-order-editor2.js.map +1 -1
- package/standalone/revogr-overlay-selection2.js +2 -2
- package/standalone/revogr-overlay-selection2.js.map +1 -1
- package/dist/cjs/column.drag.plugin-ffe1918f.js.map +0 -1
- package/dist/cjs/column.service-e9ab1aa3.js +0 -1286
- package/dist/cjs/column.service-e9ab1aa3.js.map +0 -1
- package/dist/cjs/index-947f3534.js.map +0 -1
- package/dist/cjs/row-header-utils-fe2264e7.js.map +0 -1
- package/dist/esm/column.service-397b7249.js +0 -1249
- package/dist/esm/column.service-397b7249.js.map +0 -1
- package/dist/esm/index-8eeaa30d.js.map +0 -1
- package/dist/esm/row-header-utils-3220f80d.js.map +0 -1
- package/dist/revo-grid/column.drag.plugin-bbd79520.js +0 -5
- package/dist/revo-grid/column.service-397b7249.js +0 -5
- package/dist/revo-grid/column.service-397b7249.js.map +0 -1
- package/dist/revo-grid/index-8eeaa30d.js +0 -5
- package/dist/revo-grid/index-8eeaa30d.js.map +0 -1
- package/dist/revo-grid/key.utils-9ee5fa40.js +0 -5
- package/dist/revo-grid/row-header-utils-3220f80d.js +0 -5
- package/dist/revo-grid/text-editor-d9dcf56d.js +0 -5
- /package/dist/revo-grid/{debounce-7b511afc.js.map → debounce-72878ced.js.map} +0 -0
- /package/dist/revo-grid/{edit.utils-aeb2dc7c.js.map → edit.utils-6fc686b9.js.map} +0 -0
- /package/dist/revo-grid/{header-cell-renderer-1aec2328.js.map → header-cell-renderer-32d2ed96.js.map} +0 -0
- /package/dist/revo-grid/{text-editor-d9dcf56d.js.map → text-editor-901c3eb8.js.map} +0 -0
- /package/dist/revo-grid/{throttle-ce8e57c9.js.map → throttle-138d69c3.js.map} +0 -0
|
@@ -4,14 +4,28 @@
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
const debounce$1 = require('./debounce-ec7a04b4.js');
|
|
7
|
-
const index = require('./index-
|
|
7
|
+
const index = require('./index-3ab26ab9.js');
|
|
8
|
+
const index$1 = require('./index-10d10c55.js');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Proxy plugin for data source.
|
|
12
|
+
* This plugin is used to sort the data source.
|
|
13
|
+
* It keeps the order of the items but does not modify the final source.
|
|
14
|
+
* It is also used to filter the items in the data source.
|
|
15
|
+
* The `set` method takes a key and a new value as arguments.
|
|
16
|
+
* If the key is 'proxyItems' it will filter the items in the data source according to the new value.
|
|
17
|
+
* The new value should be an array of numbers representing the indexes of the items that should be visible.
|
|
18
|
+
* The method will return a new array of numbers with the indexes of the items that should be visible.
|
|
19
|
+
* The method will also update the 'items' property of the store with the new array.
|
|
13
20
|
*/
|
|
14
21
|
const proxyPlugin = (store) => ({
|
|
22
|
+
/**
|
|
23
|
+
* Set the value of a property in the store.
|
|
24
|
+
* If the key is 'proxyItems' it will filter the items in the data source according to the new value.
|
|
25
|
+
* The new value should be an array of numbers representing the indexes of the items that should be visible.
|
|
26
|
+
* The method will return a new array of numbers with the indexes of the items that should be visible.
|
|
27
|
+
* The method will also update the 'items' property of the store with the new array.
|
|
28
|
+
*/
|
|
15
29
|
set(k, newVal) {
|
|
16
30
|
if (!isProxy(k)) {
|
|
17
31
|
return;
|
|
@@ -21,15 +35,15 @@ const proxyPlugin = (store) => ({
|
|
|
21
35
|
* Mark indexes as visible
|
|
22
36
|
*/
|
|
23
37
|
const oldItems = store.get('items').reduce((r, v) => {
|
|
24
|
-
r
|
|
38
|
+
r.add(v);
|
|
25
39
|
return r;
|
|
26
|
-
},
|
|
40
|
+
}, new Set());
|
|
27
41
|
/**
|
|
28
42
|
* Check if new values where present in items
|
|
29
43
|
* Filter item collection according presense
|
|
30
44
|
*/
|
|
31
45
|
const newItems = newVal.reduce((r, i) => {
|
|
32
|
-
if (oldItems
|
|
46
|
+
if (oldItems.has(i)) {
|
|
33
47
|
r.push(i);
|
|
34
48
|
}
|
|
35
49
|
return r;
|
|
@@ -1765,9 +1779,9 @@ var Promise$1 = getNative(debounce$1.root, 'Promise');
|
|
|
1765
1779
|
const Promise$2 = Promise$1;
|
|
1766
1780
|
|
|
1767
1781
|
/* Built-in method references that are verified to be native. */
|
|
1768
|
-
var Set = getNative(debounce$1.root, 'Set');
|
|
1782
|
+
var Set$1 = getNative(debounce$1.root, 'Set');
|
|
1769
1783
|
|
|
1770
|
-
const Set$
|
|
1784
|
+
const Set$2 = Set$1;
|
|
1771
1785
|
|
|
1772
1786
|
/* Built-in method references that are verified to be native. */
|
|
1773
1787
|
var WeakMap = getNative(debounce$1.root, 'WeakMap');
|
|
@@ -1787,7 +1801,7 @@ var dataViewTag = '[object DataView]';
|
|
|
1787
1801
|
var dataViewCtorString = toSource(DataView$1),
|
|
1788
1802
|
mapCtorString = toSource(Map$2),
|
|
1789
1803
|
promiseCtorString = toSource(Promise$2),
|
|
1790
|
-
setCtorString = toSource(Set$
|
|
1804
|
+
setCtorString = toSource(Set$2),
|
|
1791
1805
|
weakMapCtorString = toSource(WeakMap$1);
|
|
1792
1806
|
|
|
1793
1807
|
/**
|
|
@@ -1803,7 +1817,7 @@ var getTag = debounce$1.baseGetTag;
|
|
|
1803
1817
|
if ((DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag) ||
|
|
1804
1818
|
(Map$2 && getTag(new Map$2) != mapTag) ||
|
|
1805
1819
|
(Promise$2 && getTag(Promise$2.resolve()) != promiseTag) ||
|
|
1806
|
-
(Set$
|
|
1820
|
+
(Set$2 && getTag(new Set$2) != setTag) ||
|
|
1807
1821
|
(WeakMap$1 && getTag(new WeakMap$1) != weakMapTag)) {
|
|
1808
1822
|
getTag = function(value) {
|
|
1809
1823
|
var result = debounce$1.baseGetTag(value),
|
|
@@ -2448,26 +2462,6 @@ function baseMatchesProperty(path, srcValue) {
|
|
|
2448
2462
|
};
|
|
2449
2463
|
}
|
|
2450
2464
|
|
|
2451
|
-
/**
|
|
2452
|
-
* This method returns the first argument it receives.
|
|
2453
|
-
*
|
|
2454
|
-
* @static
|
|
2455
|
-
* @since 0.1.0
|
|
2456
|
-
* @memberOf _
|
|
2457
|
-
* @category Util
|
|
2458
|
-
* @param {*} value Any value.
|
|
2459
|
-
* @returns {*} Returns `value`.
|
|
2460
|
-
* @example
|
|
2461
|
-
*
|
|
2462
|
-
* var object = { 'a': 1 };
|
|
2463
|
-
*
|
|
2464
|
-
* console.log(_.identity(object) === object);
|
|
2465
|
-
* // => true
|
|
2466
|
-
*/
|
|
2467
|
-
function identity(value) {
|
|
2468
|
-
return value;
|
|
2469
|
-
}
|
|
2470
|
-
|
|
2471
2465
|
/**
|
|
2472
2466
|
* The base implementation of `_.property` without support for deep paths.
|
|
2473
2467
|
*
|
|
@@ -2534,7 +2528,7 @@ function baseIteratee(value) {
|
|
|
2534
2528
|
return value;
|
|
2535
2529
|
}
|
|
2536
2530
|
if (value == null) {
|
|
2537
|
-
return identity;
|
|
2531
|
+
return index.identity;
|
|
2538
2532
|
}
|
|
2539
2533
|
if (typeof value == 'object') {
|
|
2540
2534
|
return isArray$1(value)
|
|
@@ -2783,9 +2777,9 @@ function createRange(fromRight) {
|
|
|
2783
2777
|
* _.range(0);
|
|
2784
2778
|
* // => []
|
|
2785
2779
|
*/
|
|
2786
|
-
var range
|
|
2780
|
+
var range = createRange();
|
|
2787
2781
|
|
|
2788
|
-
const range$
|
|
2782
|
+
const range$1 = range;
|
|
2789
2783
|
|
|
2790
2784
|
const appendToMap = (map, propName, value) => {
|
|
2791
2785
|
const items = map.get(propName);
|
|
@@ -2825,7 +2819,7 @@ const cleanupElements = debounce((map) => {
|
|
|
2825
2819
|
}
|
|
2826
2820
|
}, 2000);
|
|
2827
2821
|
const stencilSubscription = () => {
|
|
2828
|
-
if (typeof index.getRenderingRef !== 'function') {
|
|
2822
|
+
if (typeof index$1.getRenderingRef !== 'function') {
|
|
2829
2823
|
// If we are not in a stencil project, we do nothing.
|
|
2830
2824
|
// This function is not really exported by @stencil/core.
|
|
2831
2825
|
return {};
|
|
@@ -2834,7 +2828,7 @@ const stencilSubscription = () => {
|
|
|
2834
2828
|
return {
|
|
2835
2829
|
dispose: () => elmsToUpdate.clear(),
|
|
2836
2830
|
get: (propName) => {
|
|
2837
|
-
const elm = index.getRenderingRef();
|
|
2831
|
+
const elm = index$1.getRenderingRef();
|
|
2838
2832
|
if (elm) {
|
|
2839
2833
|
appendToMap(elmsToUpdate, propName, elm);
|
|
2840
2834
|
}
|
|
@@ -2842,12 +2836,12 @@ const stencilSubscription = () => {
|
|
|
2842
2836
|
set: (propName) => {
|
|
2843
2837
|
const elements = elmsToUpdate.get(propName);
|
|
2844
2838
|
if (elements) {
|
|
2845
|
-
elmsToUpdate.set(propName, elements.filter(index.forceUpdate));
|
|
2839
|
+
elmsToUpdate.set(propName, elements.filter(index$1.forceUpdate));
|
|
2846
2840
|
}
|
|
2847
2841
|
cleanupElements(elmsToUpdate);
|
|
2848
2842
|
},
|
|
2849
2843
|
reset: () => {
|
|
2850
|
-
elmsToUpdate.forEach((elms) => elms.forEach(index.forceUpdate));
|
|
2844
|
+
elmsToUpdate.forEach((elms) => elms.forEach(index$1.forceUpdate));
|
|
2851
2845
|
cleanupElements(elmsToUpdate);
|
|
2852
2846
|
},
|
|
2853
2847
|
};
|
|
@@ -3048,7 +3042,7 @@ class DataStore {
|
|
|
3048
3042
|
}
|
|
3049
3043
|
// clear items
|
|
3050
3044
|
this.store.set('items', []);
|
|
3051
|
-
const items = range$
|
|
3045
|
+
const items = range$1(0, (source === null || source === void 0 ? void 0 : source.length) || 0);
|
|
3052
3046
|
// set proxy first
|
|
3053
3047
|
setStore(this.store, {
|
|
3054
3048
|
source,
|
|
@@ -3070,6 +3064,9 @@ class DataStore {
|
|
|
3070
3064
|
trimmed = Object.assign(Object.assign({}, trimmed), some);
|
|
3071
3065
|
setStore(this.store, { trimmed });
|
|
3072
3066
|
}
|
|
3067
|
+
setSourceData(items, mutate = true) {
|
|
3068
|
+
setSourceByVirtualIndex(this.store, items, mutate);
|
|
3069
|
+
}
|
|
3073
3070
|
// local data update
|
|
3074
3071
|
setData(input) {
|
|
3075
3072
|
const data = Object.assign({}, input);
|
|
@@ -3155,515 +3152,1305 @@ function getSourceItemVirtualIndexByProp(store, prop) {
|
|
|
3155
3152
|
return items.indexOf(physicalIndex);
|
|
3156
3153
|
}
|
|
3157
3154
|
|
|
3158
|
-
/**
|
|
3159
|
-
|
|
3160
|
-
|
|
3155
|
+
/**
|
|
3156
|
+
* A specialized version of `_.reduce` for arrays without support for
|
|
3157
|
+
* iteratee shorthands.
|
|
3158
|
+
*
|
|
3159
|
+
* @private
|
|
3160
|
+
* @param {Array} [array] The array to iterate over.
|
|
3161
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
3162
|
+
* @param {*} [accumulator] The initial value.
|
|
3163
|
+
* @param {boolean} [initAccum] Specify using the first element of `array` as
|
|
3164
|
+
* the initial value.
|
|
3165
|
+
* @returns {*} Returns the accumulated value.
|
|
3166
|
+
*/
|
|
3167
|
+
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
|
3168
|
+
var index = -1,
|
|
3169
|
+
length = array == null ? 0 : array.length;
|
|
3170
|
+
|
|
3171
|
+
if (initAccum && length) {
|
|
3172
|
+
accumulator = array[++index];
|
|
3173
|
+
}
|
|
3174
|
+
while (++index < length) {
|
|
3175
|
+
accumulator = iteratee(accumulator, array[index], index, array);
|
|
3176
|
+
}
|
|
3177
|
+
return accumulator;
|
|
3178
|
+
}
|
|
3161
3179
|
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
*
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
high = array == null ? 0 : array.length;
|
|
3182
|
-
if (high === 0) {
|
|
3183
|
-
return 0;
|
|
3184
|
-
}
|
|
3185
|
-
|
|
3186
|
-
value = iteratee(value);
|
|
3187
|
-
var valIsNaN = value !== value,
|
|
3188
|
-
valIsNull = value === null,
|
|
3189
|
-
valIsSymbol = debounce$1.isSymbol(value),
|
|
3190
|
-
valIsUndefined = value === undefined;
|
|
3191
|
-
|
|
3192
|
-
while (low < high) {
|
|
3193
|
-
var mid = nativeFloor((low + high) / 2),
|
|
3194
|
-
computed = iteratee(array[mid]),
|
|
3195
|
-
othIsDefined = computed !== undefined,
|
|
3196
|
-
othIsNull = computed === null,
|
|
3197
|
-
othIsReflexive = computed === computed,
|
|
3198
|
-
othIsSymbol = debounce$1.isSymbol(computed);
|
|
3199
|
-
|
|
3200
|
-
if (valIsNaN) {
|
|
3201
|
-
var setLow = retHighest || othIsReflexive;
|
|
3202
|
-
} else if (valIsUndefined) {
|
|
3203
|
-
setLow = othIsReflexive && (retHighest || othIsDefined);
|
|
3204
|
-
} else if (valIsNull) {
|
|
3205
|
-
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
|
|
3206
|
-
} else if (valIsSymbol) {
|
|
3207
|
-
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
|
|
3208
|
-
} else if (othIsNull || othIsSymbol) {
|
|
3209
|
-
setLow = false;
|
|
3210
|
-
} else {
|
|
3211
|
-
setLow = retHighest ? (computed <= value) : (computed < value);
|
|
3212
|
-
}
|
|
3213
|
-
if (setLow) {
|
|
3214
|
-
low = mid + 1;
|
|
3215
|
-
} else {
|
|
3216
|
-
high = mid;
|
|
3180
|
+
/**
|
|
3181
|
+
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
|
3182
|
+
*
|
|
3183
|
+
* @private
|
|
3184
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
3185
|
+
* @returns {Function} Returns the new base function.
|
|
3186
|
+
*/
|
|
3187
|
+
function createBaseFor(fromRight) {
|
|
3188
|
+
return function(object, iteratee, keysFunc) {
|
|
3189
|
+
var index = -1,
|
|
3190
|
+
iterable = Object(object),
|
|
3191
|
+
props = keysFunc(object),
|
|
3192
|
+
length = props.length;
|
|
3193
|
+
|
|
3194
|
+
while (length--) {
|
|
3195
|
+
var key = props[fromRight ? length : ++index];
|
|
3196
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
3197
|
+
break;
|
|
3198
|
+
}
|
|
3217
3199
|
}
|
|
3218
|
-
|
|
3219
|
-
|
|
3200
|
+
return object;
|
|
3201
|
+
};
|
|
3220
3202
|
}
|
|
3221
3203
|
|
|
3222
|
-
/**
|
|
3223
|
-
|
|
3224
|
-
|
|
3204
|
+
/**
|
|
3205
|
+
* The base implementation of `baseForOwn` which iterates over `object`
|
|
3206
|
+
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
|
3207
|
+
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|
3208
|
+
*
|
|
3209
|
+
* @private
|
|
3210
|
+
* @param {Object} object The object to iterate over.
|
|
3211
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
3212
|
+
* @param {Function} keysFunc The function to get the keys of `object`.
|
|
3213
|
+
* @returns {Object} Returns `object`.
|
|
3214
|
+
*/
|
|
3215
|
+
var baseFor = createBaseFor();
|
|
3216
|
+
|
|
3217
|
+
const baseFor$1 = baseFor;
|
|
3225
3218
|
|
|
3226
3219
|
/**
|
|
3227
|
-
* The base implementation of `_.
|
|
3228
|
-
* performs a binary search of `array` to determine the index at which `value`
|
|
3229
|
-
* should be inserted into `array` in order to maintain its sort order.
|
|
3220
|
+
* The base implementation of `_.forOwn` without support for iteratee shorthands.
|
|
3230
3221
|
*
|
|
3231
3222
|
* @private
|
|
3232
|
-
* @param {
|
|
3233
|
-
* @param {
|
|
3234
|
-
* @
|
|
3235
|
-
* @returns {number} Returns the index at which `value` should be inserted
|
|
3236
|
-
* into `array`.
|
|
3223
|
+
* @param {Object} object The object to iterate over.
|
|
3224
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
3225
|
+
* @returns {Object} Returns `object`.
|
|
3237
3226
|
*/
|
|
3238
|
-
function
|
|
3239
|
-
|
|
3240
|
-
|
|
3227
|
+
function baseForOwn(object, iteratee) {
|
|
3228
|
+
return object && baseFor$1(object, iteratee, keys);
|
|
3229
|
+
}
|
|
3241
3230
|
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3231
|
+
/**
|
|
3232
|
+
* Creates a `baseEach` or `baseEachRight` function.
|
|
3233
|
+
*
|
|
3234
|
+
* @private
|
|
3235
|
+
* @param {Function} eachFunc The function to iterate over a collection.
|
|
3236
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
3237
|
+
* @returns {Function} Returns the new base function.
|
|
3238
|
+
*/
|
|
3239
|
+
function createBaseEach(eachFunc, fromRight) {
|
|
3240
|
+
return function(collection, iteratee) {
|
|
3241
|
+
if (collection == null) {
|
|
3242
|
+
return collection;
|
|
3243
|
+
}
|
|
3244
|
+
if (!isArrayLike(collection)) {
|
|
3245
|
+
return eachFunc(collection, iteratee);
|
|
3246
|
+
}
|
|
3247
|
+
var length = collection.length,
|
|
3248
|
+
index = fromRight ? length : -1,
|
|
3249
|
+
iterable = Object(collection);
|
|
3246
3250
|
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
} else {
|
|
3251
|
-
high = mid;
|
|
3251
|
+
while ((fromRight ? index-- : ++index < length)) {
|
|
3252
|
+
if (iteratee(iterable[index], index, iterable) === false) {
|
|
3253
|
+
break;
|
|
3252
3254
|
}
|
|
3253
3255
|
}
|
|
3254
|
-
return
|
|
3255
|
-
}
|
|
3256
|
-
|
|
3256
|
+
return collection;
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
/**
|
|
3261
|
+
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
|
3262
|
+
*
|
|
3263
|
+
* @private
|
|
3264
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
3265
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
3266
|
+
* @returns {Array|Object} Returns `collection`.
|
|
3267
|
+
*/
|
|
3268
|
+
var baseEach = createBaseEach(baseForOwn);
|
|
3269
|
+
|
|
3270
|
+
const baseEach$1 = baseEach;
|
|
3271
|
+
|
|
3272
|
+
/**
|
|
3273
|
+
* The base implementation of `_.reduce` and `_.reduceRight`, without support
|
|
3274
|
+
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
|
|
3275
|
+
*
|
|
3276
|
+
* @private
|
|
3277
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
3278
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
3279
|
+
* @param {*} accumulator The initial value.
|
|
3280
|
+
* @param {boolean} initAccum Specify using the first or last element of
|
|
3281
|
+
* `collection` as the initial value.
|
|
3282
|
+
* @param {Function} eachFunc The function to iterate over `collection`.
|
|
3283
|
+
* @returns {*} Returns the accumulated value.
|
|
3284
|
+
*/
|
|
3285
|
+
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
|
|
3286
|
+
eachFunc(collection, function(value, index, collection) {
|
|
3287
|
+
accumulator = initAccum
|
|
3288
|
+
? (initAccum = false, value)
|
|
3289
|
+
: iteratee(accumulator, value, index, collection);
|
|
3290
|
+
});
|
|
3291
|
+
return accumulator;
|
|
3257
3292
|
}
|
|
3258
3293
|
|
|
3259
3294
|
/**
|
|
3260
|
-
*
|
|
3261
|
-
*
|
|
3295
|
+
* Reduces `collection` to a value which is the accumulated result of running
|
|
3296
|
+
* each element in `collection` thru `iteratee`, where each successive
|
|
3297
|
+
* invocation is supplied the return value of the previous. If `accumulator`
|
|
3298
|
+
* is not given, the first element of `collection` is used as the initial
|
|
3299
|
+
* value. The iteratee is invoked with four arguments:
|
|
3300
|
+
* (accumulator, value, index|key, collection).
|
|
3301
|
+
*
|
|
3302
|
+
* Many lodash methods are guarded to work as iteratees for methods like
|
|
3303
|
+
* `_.reduce`, `_.reduceRight`, and `_.transform`.
|
|
3304
|
+
*
|
|
3305
|
+
* The guarded methods are:
|
|
3306
|
+
* `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
|
|
3307
|
+
* and `sortBy`
|
|
3262
3308
|
*
|
|
3263
3309
|
* @static
|
|
3264
3310
|
* @memberOf _
|
|
3265
3311
|
* @since 0.1.0
|
|
3266
|
-
* @category
|
|
3267
|
-
* @param {Array}
|
|
3268
|
-
* @param {
|
|
3269
|
-
* @
|
|
3270
|
-
*
|
|
3312
|
+
* @category Collection
|
|
3313
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
3314
|
+
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
3315
|
+
* @param {*} [accumulator] The initial value.
|
|
3316
|
+
* @returns {*} Returns the accumulated value.
|
|
3317
|
+
* @see _.reduceRight
|
|
3271
3318
|
* @example
|
|
3272
3319
|
*
|
|
3273
|
-
* _.
|
|
3274
|
-
*
|
|
3320
|
+
* _.reduce([1, 2], function(sum, n) {
|
|
3321
|
+
* return sum + n;
|
|
3322
|
+
* }, 0);
|
|
3323
|
+
* // => 3
|
|
3324
|
+
*
|
|
3325
|
+
* _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
|
|
3326
|
+
* (result[value] || (result[value] = [])).push(key);
|
|
3327
|
+
* return result;
|
|
3328
|
+
* }, {});
|
|
3329
|
+
* // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
|
|
3275
3330
|
*/
|
|
3276
|
-
function
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
* Pre-calculation
|
|
3282
|
-
* Dimension custom sizes for each cell
|
|
3283
|
-
* Keeps only changed sizes, skips origin size
|
|
3284
|
-
*/
|
|
3285
|
-
function calculateDimensionData(originItemSize, newSizes = {}) {
|
|
3286
|
-
const positionIndexes = [];
|
|
3287
|
-
const positionIndexToItem = {};
|
|
3288
|
-
const indexToItem = {};
|
|
3289
|
-
// combine all new sizes
|
|
3290
|
-
const sizes = Object.assign({}, newSizes);
|
|
3291
|
-
// prepare order sorted new sizes and calculate changed real size
|
|
3292
|
-
const newIndexes = Object.keys(sizes).map(Number).sort((a, b) => a - b);
|
|
3293
|
-
// fill new coordinates based on what is changed
|
|
3294
|
-
newIndexes.reduce((previous, itemIndex, i) => {
|
|
3295
|
-
const newItem = {
|
|
3296
|
-
itemIndex,
|
|
3297
|
-
start: 0,
|
|
3298
|
-
end: 0,
|
|
3299
|
-
};
|
|
3300
|
-
// if previous item was changed too
|
|
3301
|
-
if (previous) {
|
|
3302
|
-
const itemsBetween = (itemIndex - previous.itemIndex - 1) * originItemSize;
|
|
3303
|
-
newItem.start = itemsBetween + previous.end;
|
|
3304
|
-
}
|
|
3305
|
-
else {
|
|
3306
|
-
newItem.start = itemIndex * originItemSize;
|
|
3307
|
-
}
|
|
3308
|
-
newItem.end = newItem.start + sizes[itemIndex];
|
|
3309
|
-
positionIndexes.push(newItem.start);
|
|
3310
|
-
indexToItem[itemIndex] = positionIndexToItem[i] = newItem;
|
|
3311
|
-
return newItem;
|
|
3312
|
-
}, undefined);
|
|
3313
|
-
return {
|
|
3314
|
-
indexes: newIndexes,
|
|
3315
|
-
positionIndexes: [...positionIndexes],
|
|
3316
|
-
positionIndexToItem: Object.assign({}, positionIndexToItem),
|
|
3317
|
-
indexToItem,
|
|
3318
|
-
sizes,
|
|
3319
|
-
};
|
|
3331
|
+
function reduce(collection, iteratee, accumulator) {
|
|
3332
|
+
var func = isArray$1(collection) ? arrayReduce : baseReduce,
|
|
3333
|
+
initAccum = arguments.length < 3;
|
|
3334
|
+
|
|
3335
|
+
return func(collection, baseIteratee(iteratee), accumulator, initAccum, baseEach$1);
|
|
3320
3336
|
}
|
|
3337
|
+
|
|
3321
3338
|
/**
|
|
3322
|
-
*
|
|
3339
|
+
* Selection store
|
|
3323
3340
|
*/
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
item.itemIndex = Math.floor(pos / originItemSize);
|
|
3334
|
-
item.start = item.itemIndex * originItemSize;
|
|
3335
|
-
item.end = item.start + originItemSize;
|
|
3336
|
-
return item;
|
|
3337
|
-
}
|
|
3338
|
-
const positionItem = positionIndexToItem[currentPlace - 1];
|
|
3339
|
-
// if item has specified size
|
|
3340
|
-
if (positionItem.end > pos) {
|
|
3341
|
-
return positionItem;
|
|
3342
|
-
}
|
|
3343
|
-
// special size item was present before
|
|
3344
|
-
const relativePos = pos - positionItem.end;
|
|
3345
|
-
const relativeIndex = Math.floor(relativePos / originItemSize);
|
|
3346
|
-
item.itemIndex = positionItem.itemIndex + 1 + relativeIndex;
|
|
3347
|
-
item.start = positionItem.end + relativeIndex * originItemSize;
|
|
3348
|
-
item.end = item.start + originItemSize;
|
|
3349
|
-
return item;
|
|
3350
|
-
};
|
|
3351
|
-
function getItemByIndex(dimension, index) {
|
|
3352
|
-
let item = {
|
|
3353
|
-
itemIndex: index,
|
|
3354
|
-
start: 0,
|
|
3355
|
-
end: 0,
|
|
3341
|
+
function defaultState() {
|
|
3342
|
+
return {
|
|
3343
|
+
range: null,
|
|
3344
|
+
tempRange: null,
|
|
3345
|
+
tempRangeType: null,
|
|
3346
|
+
focus: null,
|
|
3347
|
+
edit: null,
|
|
3348
|
+
lastCell: null,
|
|
3349
|
+
nextFocus: null,
|
|
3356
3350
|
};
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
}
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
codes[codes["PAGE_DOWN"] = 34] = "PAGE_DOWN";
|
|
3421
|
-
codes[codes["PAGE_UP"] = 33] = "PAGE_UP";
|
|
3422
|
-
codes[codes["PERIOD"] = 190] = "PERIOD";
|
|
3423
|
-
codes[codes["SPACE"] = 32] = "SPACE";
|
|
3424
|
-
codes[codes["SHIFT"] = 16] = "SHIFT";
|
|
3425
|
-
codes[codes["CAPS_LOCK"] = 20] = "CAPS_LOCK";
|
|
3426
|
-
codes[codes["TAB"] = 9] = "TAB";
|
|
3427
|
-
codes[codes["ARROW_RIGHT"] = 39] = "ARROW_RIGHT";
|
|
3428
|
-
codes[codes["ARROW_LEFT"] = 37] = "ARROW_LEFT";
|
|
3429
|
-
codes[codes["ARROW_UP"] = 38] = "ARROW_UP";
|
|
3430
|
-
codes[codes["ARROW_DOWN"] = 40] = "ARROW_DOWN";
|
|
3431
|
-
codes[codes["F1"] = 112] = "F1";
|
|
3432
|
-
codes[codes["F2"] = 113] = "F2";
|
|
3433
|
-
codes[codes["F3"] = 114] = "F3";
|
|
3434
|
-
codes[codes["F4"] = 115] = "F4";
|
|
3435
|
-
codes[codes["F5"] = 116] = "F5";
|
|
3436
|
-
codes[codes["F6"] = 117] = "F6";
|
|
3437
|
-
codes[codes["F7"] = 118] = "F7";
|
|
3438
|
-
codes[codes["F8"] = 119] = "F8";
|
|
3439
|
-
codes[codes["F9"] = 120] = "F9";
|
|
3440
|
-
codes[codes["F10"] = 121] = "F10";
|
|
3441
|
-
codes[codes["F11"] = 122] = "F11";
|
|
3442
|
-
codes[codes["F12"] = 123] = "F12";
|
|
3443
|
-
codes[codes["A"] = 65] = "A";
|
|
3444
|
-
codes[codes["C"] = 67] = "C";
|
|
3445
|
-
codes[codes["D"] = 68] = "D";
|
|
3446
|
-
codes[codes["F"] = 70] = "F";
|
|
3447
|
-
codes[codes["L"] = 76] = "L";
|
|
3448
|
-
codes[codes["O"] = 79] = "O";
|
|
3449
|
-
codes[codes["P"] = 80] = "P";
|
|
3450
|
-
codes[codes["S"] = 83] = "S";
|
|
3451
|
-
codes[codes["V"] = 86] = "V";
|
|
3452
|
-
codes[codes["X"] = 88] = "X";
|
|
3453
|
-
})(codes || (codes = {}));
|
|
3454
|
-
exports.codesLetter = void 0;
|
|
3455
|
-
(function (codesLetter) {
|
|
3456
|
-
codesLetter["ENTER"] = "Enter";
|
|
3457
|
-
codesLetter["ENTER_NUM"] = "NumpadEnter";
|
|
3458
|
-
codesLetter["A"] = "KeyA";
|
|
3459
|
-
codesLetter["C"] = "KeyC";
|
|
3460
|
-
codesLetter["X"] = "KeyX";
|
|
3461
|
-
codesLetter["V"] = "KeyV";
|
|
3462
|
-
codesLetter["ESCAPE"] = "Escape";
|
|
3463
|
-
codesLetter["TAB"] = "Tab";
|
|
3464
|
-
codesLetter["BACKSPACE"] = "Backspace";
|
|
3465
|
-
codesLetter["DELETE"] = "Delete";
|
|
3466
|
-
codesLetter["ARROW_RIGHT"] = "ArrowRight";
|
|
3467
|
-
codesLetter["ARROW_LEFT"] = "ArrowLeft";
|
|
3468
|
-
codesLetter["ARROW_UP"] = "ArrowUp";
|
|
3469
|
-
codesLetter["ARROW_DOWN"] = "ArrowDown";
|
|
3470
|
-
codesLetter["SHIFT"] = "Shift";
|
|
3471
|
-
})(exports.codesLetter || (exports.codesLetter = {}));
|
|
3472
|
-
exports.keyValues = void 0;
|
|
3473
|
-
(function (keyValues) {
|
|
3474
|
-
keyValues["ENTER"] = "Enter";
|
|
3475
|
-
keyValues["TAB"] = "Tab";
|
|
3476
|
-
})(exports.keyValues || (exports.keyValues = {}));
|
|
3477
|
-
const KeyCodesEnum = codes;
|
|
3478
|
-
|
|
3479
|
-
var osPlatform;
|
|
3480
|
-
(function (osPlatform) {
|
|
3481
|
-
osPlatform["mac"] = "Mac";
|
|
3482
|
-
})(osPlatform || (osPlatform = {}));
|
|
3483
|
-
const OsPlatform = osPlatform;
|
|
3484
|
-
|
|
3485
|
-
/* Generate range on size
|
|
3486
|
-
*/
|
|
3487
|
-
function range(size, startAt = 0) {
|
|
3488
|
-
const res = [];
|
|
3489
|
-
const end = startAt + size;
|
|
3490
|
-
for (let i = startAt; i < end; i++) {
|
|
3491
|
-
res.push(i);
|
|
3351
|
+
}
|
|
3352
|
+
class SelectionStore {
|
|
3353
|
+
constructor() {
|
|
3354
|
+
this.unsubscribe = [];
|
|
3355
|
+
this.store = createStore(defaultState());
|
|
3356
|
+
this.store.on('set', (key, newVal) => {
|
|
3357
|
+
if (key === 'tempRange' && !newVal) {
|
|
3358
|
+
this.store.set('tempRangeType', null);
|
|
3359
|
+
}
|
|
3360
|
+
});
|
|
3361
|
+
}
|
|
3362
|
+
onChange(propName, cb) {
|
|
3363
|
+
this.unsubscribe.push(this.store.onChange(propName, cb));
|
|
3364
|
+
}
|
|
3365
|
+
clearFocus() {
|
|
3366
|
+
setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });
|
|
3367
|
+
}
|
|
3368
|
+
setFocus(focus, end) {
|
|
3369
|
+
if (!end) {
|
|
3370
|
+
setStore(this.store, { focus });
|
|
3371
|
+
}
|
|
3372
|
+
else {
|
|
3373
|
+
setStore(this.store, {
|
|
3374
|
+
focus,
|
|
3375
|
+
range: getRange(focus, end),
|
|
3376
|
+
edit: null,
|
|
3377
|
+
tempRange: null,
|
|
3378
|
+
});
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
setNextFocus(focus) {
|
|
3382
|
+
setStore(this.store, { nextFocus: focus });
|
|
3383
|
+
}
|
|
3384
|
+
setTempArea(range) {
|
|
3385
|
+
setStore(this.store, { tempRange: range === null || range === void 0 ? void 0 : range.area, tempRangeType: range === null || range === void 0 ? void 0 : range.type, edit: null });
|
|
3386
|
+
}
|
|
3387
|
+
clearTemp() {
|
|
3388
|
+
setStore(this.store, { tempRange: null });
|
|
3389
|
+
}
|
|
3390
|
+
/** Can be applied from selection change or from simple keyboard change clicks */
|
|
3391
|
+
setRangeArea(range) {
|
|
3392
|
+
setStore(this.store, { range, edit: null, tempRange: null });
|
|
3393
|
+
}
|
|
3394
|
+
setRange(start, end) {
|
|
3395
|
+
const range = getRange(start, end);
|
|
3396
|
+
this.setRangeArea(range);
|
|
3397
|
+
}
|
|
3398
|
+
setLastCell(lastCell) {
|
|
3399
|
+
setStore(this.store, { lastCell });
|
|
3400
|
+
}
|
|
3401
|
+
setEdit(val) {
|
|
3402
|
+
const focus = this.store.get('focus');
|
|
3403
|
+
if (focus && typeof val === 'string') {
|
|
3404
|
+
setStore(this.store, {
|
|
3405
|
+
edit: { x: focus.x, y: focus.y, val },
|
|
3406
|
+
});
|
|
3407
|
+
return;
|
|
3408
|
+
}
|
|
3409
|
+
setStore(this.store, { edit: null });
|
|
3410
|
+
}
|
|
3411
|
+
dispose() {
|
|
3412
|
+
this.unsubscribe.forEach(f => f());
|
|
3413
|
+
this.store.dispose();
|
|
3492
3414
|
}
|
|
3493
|
-
return res;
|
|
3494
3415
|
}
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3416
|
+
|
|
3417
|
+
const EMPTY_INDEX = -1;
|
|
3418
|
+
class SelectionStoreConnector {
|
|
3419
|
+
constructor() {
|
|
3420
|
+
// dirty flag required to cleanup whole store in case visibility of panels changed
|
|
3421
|
+
this.dirty = false;
|
|
3422
|
+
this.stores = {};
|
|
3423
|
+
this.columnStores = {};
|
|
3424
|
+
this.rowStores = {};
|
|
3425
|
+
/**
|
|
3426
|
+
* Helpers for data conversion
|
|
3427
|
+
*/
|
|
3428
|
+
this.storesByType = {};
|
|
3429
|
+
this.storesXToType = {};
|
|
3430
|
+
this.storesYToType = {};
|
|
3431
|
+
this.sections = [];
|
|
3432
|
+
}
|
|
3433
|
+
get focusedStore() {
|
|
3434
|
+
var _a;
|
|
3435
|
+
for (let y in this.stores) {
|
|
3436
|
+
for (let x in this.stores[y]) {
|
|
3437
|
+
const focused = (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.store.get('focus');
|
|
3438
|
+
if (focused) {
|
|
3439
|
+
return {
|
|
3440
|
+
entity: this.stores[y][x],
|
|
3441
|
+
cell: focused,
|
|
3442
|
+
position: {
|
|
3443
|
+
x: parseInt(x, 10),
|
|
3444
|
+
y: parseInt(y, 10),
|
|
3445
|
+
},
|
|
3446
|
+
};
|
|
3447
|
+
}
|
|
3505
3448
|
}
|
|
3506
|
-
|
|
3507
|
-
|
|
3449
|
+
}
|
|
3450
|
+
return null;
|
|
3451
|
+
}
|
|
3452
|
+
get edit() {
|
|
3453
|
+
var _a;
|
|
3454
|
+
return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('edit');
|
|
3455
|
+
}
|
|
3456
|
+
get focused() {
|
|
3457
|
+
var _a;
|
|
3458
|
+
return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('focus');
|
|
3459
|
+
}
|
|
3460
|
+
get selectedRange() {
|
|
3461
|
+
var _a;
|
|
3462
|
+
return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('range');
|
|
3463
|
+
}
|
|
3464
|
+
registerSection(e) {
|
|
3465
|
+
if (!e) {
|
|
3466
|
+
this.sections.length = 0;
|
|
3467
|
+
// some elements removed, rebuild stores
|
|
3468
|
+
this.dirty = true;
|
|
3469
|
+
return;
|
|
3470
|
+
}
|
|
3471
|
+
if (this.sections.indexOf(e) === -1) {
|
|
3472
|
+
this.sections.push(e);
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
// check if require to cleanup all stores
|
|
3476
|
+
beforeUpdate() {
|
|
3477
|
+
if (this.dirty) {
|
|
3478
|
+
for (let y in this.stores) {
|
|
3479
|
+
for (let x in this.stores[y]) {
|
|
3480
|
+
this.stores[y][x].dispose();
|
|
3481
|
+
}
|
|
3508
3482
|
}
|
|
3509
|
-
|
|
3510
|
-
|
|
3483
|
+
this.dirty = false;
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
registerColumn(x, type) {
|
|
3487
|
+
// if hidden just create store but no operations needed
|
|
3488
|
+
if (isHiddenStore(x)) {
|
|
3489
|
+
return new SelectionStore();
|
|
3490
|
+
}
|
|
3491
|
+
if (this.columnStores[x]) {
|
|
3492
|
+
return this.columnStores[x];
|
|
3493
|
+
}
|
|
3494
|
+
this.columnStores[x] = new SelectionStore();
|
|
3495
|
+
// build cross-linking type to position
|
|
3496
|
+
this.storesByType[type] = x;
|
|
3497
|
+
this.storesXToType[x] = type;
|
|
3498
|
+
return this.columnStores[x];
|
|
3499
|
+
}
|
|
3500
|
+
registerRow(y, type) {
|
|
3501
|
+
// if hidden just create store
|
|
3502
|
+
if (isHiddenStore(y)) {
|
|
3503
|
+
return new SelectionStore();
|
|
3504
|
+
}
|
|
3505
|
+
if (this.rowStores[y]) {
|
|
3506
|
+
return this.rowStores[y];
|
|
3507
|
+
}
|
|
3508
|
+
this.rowStores[y] = new SelectionStore();
|
|
3509
|
+
// build cross linking type to position
|
|
3510
|
+
this.storesByType[type] = y;
|
|
3511
|
+
this.storesYToType[y] = type;
|
|
3512
|
+
return this.rowStores[y];
|
|
3513
|
+
}
|
|
3514
|
+
/**
|
|
3515
|
+
* Cross store proxy, based on multiple dimensions
|
|
3516
|
+
*/
|
|
3517
|
+
register({ x, y }) {
|
|
3518
|
+
var _a, _b;
|
|
3519
|
+
// if hidden just create store
|
|
3520
|
+
if (isHiddenStore(x) || isHiddenStore(y)) {
|
|
3521
|
+
return new SelectionStore();
|
|
3522
|
+
}
|
|
3523
|
+
if (!this.stores[y]) {
|
|
3524
|
+
this.stores[y] = {};
|
|
3525
|
+
}
|
|
3526
|
+
if (this.stores[y][x]) {
|
|
3527
|
+
// Store already registered. Do not register twice
|
|
3528
|
+
return this.stores[y][x];
|
|
3529
|
+
}
|
|
3530
|
+
this.stores[y][x] = new SelectionStore();
|
|
3531
|
+
// proxy update, column store trigger only range area
|
|
3532
|
+
(_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.onChange('range', c => {
|
|
3533
|
+
this.columnStores[x].setRangeArea(c);
|
|
3534
|
+
this.rowStores[y].setRangeArea(c);
|
|
3535
|
+
});
|
|
3536
|
+
// clean up on remove
|
|
3537
|
+
(_b = this.stores[y][x]) === null || _b === void 0 ? void 0 : _b.store.on('dispose', () => this.destroy(x, y));
|
|
3538
|
+
return this.stores[y][x];
|
|
3539
|
+
}
|
|
3540
|
+
destroy(x, y) {
|
|
3541
|
+
var _a, _b;
|
|
3542
|
+
(_a = this.columnStores[x]) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
3543
|
+
(_b = this.rowStores[y]) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
3544
|
+
delete this.rowStores[y];
|
|
3545
|
+
delete this.columnStores[x];
|
|
3546
|
+
// clear x cross-link
|
|
3547
|
+
if (this.storesXToType[x]) {
|
|
3548
|
+
const type = this.storesXToType[x];
|
|
3549
|
+
delete this.storesXToType[x];
|
|
3550
|
+
delete this.storesByType[type];
|
|
3551
|
+
}
|
|
3552
|
+
// clear y cross-link
|
|
3553
|
+
if (this.storesYToType[y]) {
|
|
3554
|
+
const type = this.storesYToType[y];
|
|
3555
|
+
delete this.storesYToType[y];
|
|
3556
|
+
delete this.storesByType[type];
|
|
3557
|
+
}
|
|
3558
|
+
if (this.stores[y]) {
|
|
3559
|
+
delete this.stores[y][x];
|
|
3560
|
+
}
|
|
3561
|
+
// clear empty rows
|
|
3562
|
+
if (!Object.keys(this.stores[y] || {}).length) {
|
|
3563
|
+
delete this.stores[y];
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
setEditByCell(storePos, editCell) {
|
|
3567
|
+
this.focusByCell(storePos, editCell, editCell);
|
|
3568
|
+
this.setEdit('');
|
|
3569
|
+
}
|
|
3570
|
+
/**
|
|
3571
|
+
* Sets the next focus cell before the current one.
|
|
3572
|
+
*
|
|
3573
|
+
* @param focus - The cell to set as the next focus.
|
|
3574
|
+
*/
|
|
3575
|
+
beforeNextFocusCell(focus) {
|
|
3576
|
+
var _a;
|
|
3577
|
+
// If there is no focused store, return early.
|
|
3578
|
+
if (!this.focusedStore) {
|
|
3579
|
+
return;
|
|
3580
|
+
}
|
|
3581
|
+
// Get the next store based on the current focus and the last cell.
|
|
3582
|
+
const lastCell = this.focusedStore.entity.store.get('lastCell');
|
|
3583
|
+
const next = lastCell && this.getNextStore(focus, this.focusedStore.position, lastCell);
|
|
3584
|
+
// Set the next focus cell in the store.
|
|
3585
|
+
(_a = next === null || next === void 0 ? void 0 : next.store) === null || _a === void 0 ? void 0 : _a.setNextFocus(Object.assign(Object.assign({}, focus), next.item));
|
|
3586
|
+
}
|
|
3587
|
+
focusByCell(storePos, start, end) {
|
|
3588
|
+
const store = this.stores[storePos.y][storePos.x];
|
|
3589
|
+
this.focus(store, { focus: start, end });
|
|
3590
|
+
}
|
|
3591
|
+
focus(store, { focus, end }) {
|
|
3592
|
+
const currentStorePointer = this.getCurrentStorePointer(store);
|
|
3593
|
+
if (!currentStorePointer) {
|
|
3594
|
+
return null;
|
|
3595
|
+
}
|
|
3596
|
+
// check for the focus in nearby store/viewport
|
|
3597
|
+
const lastCell = store.store.get('lastCell');
|
|
3598
|
+
const next = lastCell && this.getNextStore(focus, currentStorePointer, lastCell);
|
|
3599
|
+
// if next store present - update
|
|
3600
|
+
if (next === null || next === void 0 ? void 0 : next.store) {
|
|
3601
|
+
const item = Object.assign(Object.assign({}, focus), next.item);
|
|
3602
|
+
this.focus(next.store, { focus: item, end: item });
|
|
3603
|
+
return null;
|
|
3604
|
+
}
|
|
3605
|
+
if (lastCell) {
|
|
3606
|
+
focus = cropCellToMax(focus, lastCell);
|
|
3607
|
+
end = cropCellToMax(end, lastCell);
|
|
3608
|
+
}
|
|
3609
|
+
store.setFocus(focus, end);
|
|
3610
|
+
return focus;
|
|
3611
|
+
}
|
|
3612
|
+
/**
|
|
3613
|
+
* Retrieves the current store pointer based on the active store.
|
|
3614
|
+
* Clears focus from all stores except the active one.
|
|
3615
|
+
*/
|
|
3616
|
+
getCurrentStorePointer(store) {
|
|
3617
|
+
let currentStorePointer;
|
|
3618
|
+
// Iterate through all stores
|
|
3619
|
+
for (let y in this.stores) {
|
|
3620
|
+
for (let x in this.stores[y]) {
|
|
3621
|
+
const s = this.stores[y][x];
|
|
3622
|
+
// Clear focus from stores other than the active one
|
|
3623
|
+
if (s !== store) {
|
|
3624
|
+
s.clearFocus();
|
|
3625
|
+
}
|
|
3626
|
+
else {
|
|
3627
|
+
// Update the current store pointer with the active store coordinates
|
|
3628
|
+
currentStorePointer = {
|
|
3629
|
+
x: parseInt(x, 10),
|
|
3630
|
+
y: parseInt(y, 10)
|
|
3631
|
+
};
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
return currentStorePointer;
|
|
3636
|
+
}
|
|
3637
|
+
/**
|
|
3638
|
+
* Retrieves the next store based on the focus cell and current store pointer.
|
|
3639
|
+
* If the next store exists, returns an object with the next store and the item in the new store.
|
|
3640
|
+
* If the next store does not exist, returns null.
|
|
3641
|
+
*/
|
|
3642
|
+
getNextStore(focus, currentStorePointer, lastCell) {
|
|
3643
|
+
// item in new store
|
|
3644
|
+
const nextItem = nextCell(focus, lastCell);
|
|
3645
|
+
let nextStore;
|
|
3646
|
+
if (nextItem) {
|
|
3647
|
+
Object.entries(nextItem).forEach(([type, nextItemCoord]) => {
|
|
3648
|
+
let stores;
|
|
3649
|
+
switch (type) {
|
|
3650
|
+
case 'x':
|
|
3651
|
+
// Get the X stores for the current Y coordinate of the current store pointer
|
|
3652
|
+
stores = this.getXStores(currentStorePointer.y);
|
|
3653
|
+
break;
|
|
3654
|
+
case 'y':
|
|
3655
|
+
// Get the Y stores for the current X coordinate of the current store pointer
|
|
3656
|
+
stores = this.getYStores(currentStorePointer.x);
|
|
3657
|
+
break;
|
|
3658
|
+
}
|
|
3659
|
+
// Get the next store based on the item in the new store
|
|
3660
|
+
if (nextItemCoord >= 0) {
|
|
3661
|
+
nextStore = stores[++currentStorePointer[type]];
|
|
3662
|
+
}
|
|
3663
|
+
else {
|
|
3664
|
+
nextStore = stores[--currentStorePointer[type]];
|
|
3665
|
+
const nextLastCell = nextStore === null || nextStore === void 0 ? void 0 : nextStore.store.get('lastCell');
|
|
3666
|
+
if (nextLastCell) {
|
|
3667
|
+
nextItem[type] = nextLastCell[type] + nextItemCoord;
|
|
3668
|
+
}
|
|
3669
|
+
}
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3672
|
+
return {
|
|
3673
|
+
store: nextStore,
|
|
3674
|
+
item: nextItem,
|
|
3675
|
+
};
|
|
3676
|
+
}
|
|
3677
|
+
clearAll() {
|
|
3678
|
+
var _a;
|
|
3679
|
+
for (let y in this.stores) {
|
|
3680
|
+
for (let x in this.stores[y]) {
|
|
3681
|
+
(_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.clearFocus();
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
setEdit(val) {
|
|
3686
|
+
if (!this.focusedStore) {
|
|
3687
|
+
return;
|
|
3688
|
+
}
|
|
3689
|
+
this.focusedStore.entity.setEdit(val);
|
|
3690
|
+
}
|
|
3691
|
+
/**
|
|
3692
|
+
* Select all cells across all stores
|
|
3693
|
+
*/
|
|
3694
|
+
selectAll() {
|
|
3695
|
+
for (let y in this.stores) {
|
|
3696
|
+
for (let x in this.stores[y]) {
|
|
3697
|
+
const store = this.stores[y][x];
|
|
3698
|
+
if (!store) {
|
|
3699
|
+
continue;
|
|
3700
|
+
}
|
|
3701
|
+
const lastCell = store.store.get('lastCell');
|
|
3702
|
+
if (lastCell) {
|
|
3703
|
+
store.setRange({ x: 0, y: 0 }, { x: lastCell.x - 1, y: lastCell.y - 1 });
|
|
3704
|
+
}
|
|
3511
3705
|
}
|
|
3512
3706
|
}
|
|
3513
|
-
|
|
3514
|
-
|
|
3707
|
+
}
|
|
3708
|
+
getXStores(y) {
|
|
3709
|
+
return this.stores[y];
|
|
3710
|
+
}
|
|
3711
|
+
getYStores(x) {
|
|
3712
|
+
const stores = {};
|
|
3713
|
+
for (let i in this.stores) {
|
|
3714
|
+
stores[i] = this.stores[i][x];
|
|
3715
|
+
}
|
|
3716
|
+
return stores;
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
|
|
3720
|
+
function isHiddenStore(pos) {
|
|
3721
|
+
return pos === EMPTY_INDEX;
|
|
3722
|
+
}
|
|
3723
|
+
function nextCell(cell, lastCell) {
|
|
3724
|
+
const nextItem = {};
|
|
3725
|
+
let types = ['x', 'y'];
|
|
3726
|
+
// previous item check
|
|
3727
|
+
for (let t of types) {
|
|
3728
|
+
if (cell[t] < 0) {
|
|
3729
|
+
nextItem[t] = cell[t];
|
|
3730
|
+
return nextItem;
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
// next item check
|
|
3734
|
+
for (let t of types) {
|
|
3735
|
+
if (cell[t] >= lastCell[t]) {
|
|
3736
|
+
nextItem[t] = cell[t] - lastCell[t];
|
|
3737
|
+
return nextItem;
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
return null;
|
|
3741
|
+
}
|
|
3742
|
+
function cropCellToMax(cell, lastCell) {
|
|
3743
|
+
const croppedCell = Object.assign({}, cell);
|
|
3744
|
+
const cellCoordinates = ['x', 'y'];
|
|
3745
|
+
for (const coordinate of cellCoordinates) {
|
|
3746
|
+
if (cell[coordinate] < 0) {
|
|
3747
|
+
croppedCell[coordinate] = 0;
|
|
3748
|
+
}
|
|
3749
|
+
else if (cell[coordinate] >= lastCell[coordinate]) {
|
|
3750
|
+
croppedCell[coordinate] = lastCell[coordinate] - 1;
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
return croppedCell;
|
|
3754
|
+
}
|
|
3755
|
+
function getRange(start, end) {
|
|
3756
|
+
return start && end
|
|
3757
|
+
? {
|
|
3758
|
+
x: Math.min(start.x, end.x),
|
|
3759
|
+
y: Math.min(start.y, end.y),
|
|
3760
|
+
x1: Math.max(start.x, end.x),
|
|
3761
|
+
y1: Math.max(start.y, end.y),
|
|
3762
|
+
}
|
|
3763
|
+
: null;
|
|
3764
|
+
}
|
|
3765
|
+
function isRangeSingleCell(a) {
|
|
3766
|
+
return a.x === a.x1 && a.y === a.y1;
|
|
3767
|
+
}
|
|
3768
|
+
|
|
3769
|
+
function getCellData(val) {
|
|
3770
|
+
if (typeof val === 'undefined' || val === null) {
|
|
3771
|
+
return '';
|
|
3772
|
+
}
|
|
3773
|
+
return val;
|
|
3774
|
+
}
|
|
3775
|
+
function getCellDataParsed(model, column) {
|
|
3776
|
+
const val = column.cellParser ? column.cellParser(model, column) : model[column.prop];
|
|
3777
|
+
return getCellData(val);
|
|
3515
3778
|
}
|
|
3516
3779
|
/**
|
|
3517
|
-
*
|
|
3780
|
+
* Get column type from column data
|
|
3518
3781
|
*/
|
|
3519
|
-
function
|
|
3520
|
-
|
|
3521
|
-
|
|
3782
|
+
function getColumnType(rgCol) {
|
|
3783
|
+
if (rgCol.pin) {
|
|
3784
|
+
return rgCol.pin;
|
|
3785
|
+
}
|
|
3786
|
+
return 'rgCol';
|
|
3522
3787
|
}
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3788
|
+
function getColumnSizes(cols) {
|
|
3789
|
+
const res = {};
|
|
3790
|
+
for (const [i, c] of cols.entries()) {
|
|
3791
|
+
if (c.size) {
|
|
3792
|
+
res[i] = c.size;
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
return res;
|
|
3526
3796
|
}
|
|
3527
3797
|
/**
|
|
3528
|
-
*
|
|
3798
|
+
* Check if column is grouping column
|
|
3529
3799
|
*/
|
|
3530
|
-
function
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3800
|
+
function isColGrouping(colData) {
|
|
3801
|
+
return !!colData.children;
|
|
3802
|
+
}
|
|
3803
|
+
/**
|
|
3804
|
+
* This function is used to create a collection of columns.
|
|
3805
|
+
*/
|
|
3806
|
+
function getColumns(columns, level = 0, types) {
|
|
3807
|
+
const collection = {
|
|
3808
|
+
// columns as they are in stores per type
|
|
3809
|
+
columns: {
|
|
3810
|
+
rgCol: [],
|
|
3811
|
+
colPinStart: [],
|
|
3812
|
+
colPinEnd: [],
|
|
3813
|
+
},
|
|
3814
|
+
// columns indexed by prop for quick access
|
|
3815
|
+
columnByProp: {},
|
|
3816
|
+
// column grouping
|
|
3817
|
+
columnGrouping: {
|
|
3818
|
+
rgCol: [],
|
|
3819
|
+
colPinStart: [],
|
|
3820
|
+
colPinEnd: [],
|
|
3821
|
+
},
|
|
3822
|
+
// max depth level for column grouping
|
|
3823
|
+
maxLevel: level,
|
|
3824
|
+
// sorting
|
|
3825
|
+
sort: {},
|
|
3826
|
+
};
|
|
3827
|
+
return reduce(columns, (res, colData) => {
|
|
3828
|
+
// Grouped column
|
|
3829
|
+
if (isColGrouping(colData)) {
|
|
3830
|
+
return gatherGroup(res, colData, getColumns(colData.children, level + 1, types), level);
|
|
3831
|
+
}
|
|
3832
|
+
// Column type
|
|
3833
|
+
const columnDefinitionFromType = colData.columnType && (types === null || types === void 0 ? void 0 : types[colData.columnType]);
|
|
3834
|
+
// Regular column
|
|
3835
|
+
const regularColumn = Object.assign(Object.assign({}, columnDefinitionFromType), colData);
|
|
3836
|
+
// Regular column, no Pin
|
|
3837
|
+
if (!regularColumn.pin) {
|
|
3838
|
+
res.columns.rgCol.push(regularColumn);
|
|
3839
|
+
// Pin
|
|
3541
3840
|
}
|
|
3542
3841
|
else {
|
|
3543
|
-
|
|
3544
|
-
|
|
3842
|
+
res.columns[regularColumn.pin].push(regularColumn);
|
|
3843
|
+
}
|
|
3844
|
+
if (regularColumn.order) {
|
|
3845
|
+
res.sort[regularColumn.prop] = regularColumn;
|
|
3846
|
+
}
|
|
3847
|
+
// it's possible that some columns have same prop, but better to avoid it
|
|
3848
|
+
if (!res.columnByProp[regularColumn.prop]) {
|
|
3849
|
+
res.columnByProp[regularColumn.prop] = [];
|
|
3850
|
+
}
|
|
3851
|
+
res.columnByProp[regularColumn.prop].push(regularColumn);
|
|
3852
|
+
// trigger setup hook if present
|
|
3853
|
+
regularColumn.beforeSetup && regularColumn.beforeSetup(regularColumn);
|
|
3854
|
+
return res;
|
|
3855
|
+
}, collection);
|
|
3856
|
+
}
|
|
3857
|
+
function gatherGroup(res, colData, collection, level = 0) {
|
|
3858
|
+
// group template
|
|
3859
|
+
const group = Object.assign(Object.assign({}, colData), { level, ids: [] });
|
|
3860
|
+
// check columns for update
|
|
3861
|
+
for (let k in collection.columns) {
|
|
3862
|
+
const key = k;
|
|
3863
|
+
const resultItem = res.columns[key];
|
|
3864
|
+
const collectionItem = collection.columns[key];
|
|
3865
|
+
// if column data
|
|
3866
|
+
if (isArray$1(resultItem) && isArray$1(collectionItem)) {
|
|
3867
|
+
// fill columns
|
|
3868
|
+
resultItem.push(...collectionItem);
|
|
3869
|
+
// fill grouping
|
|
3870
|
+
if (collectionItem.length) {
|
|
3871
|
+
res.columnGrouping[key].push(Object.assign(Object.assign({}, group), { ids: collectionItem.map(item => item.prop) }));
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
// merge column groupings
|
|
3876
|
+
for (let k in collection.columnGrouping) {
|
|
3877
|
+
const key = k;
|
|
3878
|
+
const collectionItem = collection.columnGrouping[key];
|
|
3879
|
+
res.columnGrouping[key].push(...collectionItem);
|
|
3880
|
+
}
|
|
3881
|
+
res.maxLevel = Math.max(res.maxLevel, collection.maxLevel);
|
|
3882
|
+
res.sort = Object.assign(Object.assign({}, res.sort), collection.sort);
|
|
3883
|
+
return res;
|
|
3884
|
+
}
|
|
3885
|
+
function findColumn(columns, prop) {
|
|
3886
|
+
for (const c of columns) {
|
|
3887
|
+
if (isColGrouping(c)) {
|
|
3888
|
+
const found = findColumn(c.children, prop);
|
|
3889
|
+
if (found) {
|
|
3890
|
+
return found;
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
else if (c.prop === prop) {
|
|
3894
|
+
return c;
|
|
3545
3895
|
}
|
|
3546
|
-
current++;
|
|
3547
3896
|
}
|
|
3548
|
-
return
|
|
3897
|
+
return undefined;
|
|
3898
|
+
}
|
|
3899
|
+
function getColumnByProp(columns, prop) {
|
|
3900
|
+
return findColumn(columns, prop);
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
const GROUP_DEPTH = `${index.GRID_INTERNALS}-depth`;
|
|
3904
|
+
const PSEUDO_GROUP_ITEM = `${index.GRID_INTERNALS}-name`;
|
|
3905
|
+
const PSEUDO_GROUP_ITEM_ID = `${index.GRID_INTERNALS}-id`;
|
|
3906
|
+
const PSEUDO_GROUP_ITEM_VALUE = `${index.GRID_INTERNALS}-value`;
|
|
3907
|
+
const PSEUDO_GROUP_COLUMN = `${index.GRID_INTERNALS}-column`;
|
|
3908
|
+
const GROUP_EXPANDED = `${index.GRID_INTERNALS}-expanded`;
|
|
3909
|
+
const GROUP_ORIGINAL_INDEX = `${index.GRID_INTERNALS}-original-index`;
|
|
3910
|
+
const GROUP_EXPAND_BTN = `group-expand`;
|
|
3911
|
+
const GROUP_EXPAND_EVENT = `groupexpandclick`;
|
|
3912
|
+
const GROUPING_ROW_TYPE = 'rgRow';
|
|
3913
|
+
|
|
3914
|
+
function getGroupValueDefault(item, prop) {
|
|
3915
|
+
return item[prop] || null;
|
|
3549
3916
|
}
|
|
3550
3917
|
/**
|
|
3551
|
-
*
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3918
|
+
* Gather data for grouping
|
|
3919
|
+
* @param array - flat data array
|
|
3920
|
+
* @param groupIds - ids of groups
|
|
3921
|
+
* @param expanded - potentially expanded items if present
|
|
3922
|
+
*/
|
|
3923
|
+
function gatherGrouping(array, groupIds, { prevExpanded, expandedAll, getGroupValue = getGroupValueDefault, }) {
|
|
3924
|
+
const groupedItems = new Map();
|
|
3925
|
+
array.forEach((item, originalIndex) => {
|
|
3926
|
+
const groupLevelValues = groupIds.map(groupId => getGroupValue(item, groupId));
|
|
3927
|
+
const lastLevelValue = groupLevelValues.pop();
|
|
3928
|
+
let currentGroupLevel = groupedItems;
|
|
3929
|
+
groupLevelValues.forEach(value => {
|
|
3930
|
+
if (!currentGroupLevel.has(value)) {
|
|
3931
|
+
currentGroupLevel.set(value, new Map());
|
|
3932
|
+
}
|
|
3933
|
+
currentGroupLevel = currentGroupLevel.get(value);
|
|
3934
|
+
});
|
|
3935
|
+
if (!currentGroupLevel.has(lastLevelValue)) {
|
|
3936
|
+
currentGroupLevel.set(lastLevelValue, []);
|
|
3937
|
+
}
|
|
3938
|
+
const lastLevelItems = currentGroupLevel.get(lastLevelValue);
|
|
3939
|
+
lastLevelItems.push(Object.assign(Object.assign({}, item), { [GROUP_ORIGINAL_INDEX]: originalIndex }));
|
|
3940
|
+
});
|
|
3941
|
+
let itemIndex = -1;
|
|
3942
|
+
const groupingDepth = groupIds.length;
|
|
3943
|
+
// collapse all groups in the beginning
|
|
3944
|
+
const trimmed = {};
|
|
3945
|
+
// index mapping
|
|
3946
|
+
const oldNewIndexMap = {};
|
|
3947
|
+
// check if group header exists
|
|
3948
|
+
const pseudoGroupTest = {};
|
|
3949
|
+
const sourceWithGroups = [];
|
|
3950
|
+
function flattenGroupMaps(groupedValues, parentIds, isExpanded) {
|
|
3951
|
+
const depth = parentIds.length;
|
|
3952
|
+
groupedValues.forEach((innerGroupedValues, groupId) => {
|
|
3953
|
+
const levelIds = [...parentIds, groupId];
|
|
3954
|
+
const mergedIds = levelIds.join(',');
|
|
3955
|
+
const isGroupExpanded = isExpanded && (!!expandedAll || !!(prevExpanded === null || prevExpanded === void 0 ? void 0 : prevExpanded[mergedIds]));
|
|
3956
|
+
sourceWithGroups.push({
|
|
3957
|
+
[PSEUDO_GROUP_ITEM]: groupId,
|
|
3958
|
+
[GROUP_DEPTH]: depth,
|
|
3959
|
+
[PSEUDO_GROUP_ITEM_ID]: JSON.stringify(levelIds),
|
|
3960
|
+
[PSEUDO_GROUP_ITEM_VALUE]: mergedIds,
|
|
3961
|
+
[GROUP_EXPANDED]: isGroupExpanded,
|
|
3962
|
+
});
|
|
3963
|
+
itemIndex += 1;
|
|
3964
|
+
if (!isGroupExpanded && depth) {
|
|
3965
|
+
trimmed[itemIndex] = true;
|
|
3966
|
+
}
|
|
3967
|
+
if (Array.isArray(innerGroupedValues)) {
|
|
3968
|
+
innerGroupedValues.forEach(value => {
|
|
3969
|
+
itemIndex += 1;
|
|
3970
|
+
if (!isGroupExpanded) {
|
|
3971
|
+
trimmed[itemIndex] = true;
|
|
3972
|
+
}
|
|
3973
|
+
oldNewIndexMap[value[GROUP_ORIGINAL_INDEX]] = itemIndex;
|
|
3974
|
+
const pseudoGroupTestIds = levelIds.map((_value, index) => levelIds.slice(0, index + 1).join(','));
|
|
3975
|
+
pseudoGroupTestIds.forEach(pseudoGroupTestId => {
|
|
3976
|
+
if (!pseudoGroupTest[pseudoGroupTestId]) {
|
|
3977
|
+
pseudoGroupTest[pseudoGroupTestId] = [];
|
|
3978
|
+
}
|
|
3979
|
+
pseudoGroupTest[pseudoGroupTestId].push(itemIndex);
|
|
3980
|
+
});
|
|
3981
|
+
});
|
|
3982
|
+
sourceWithGroups.push(...innerGroupedValues);
|
|
3983
|
+
}
|
|
3984
|
+
else {
|
|
3985
|
+
flattenGroupMaps(innerGroupedValues, levelIds, isGroupExpanded);
|
|
3986
|
+
}
|
|
3987
|
+
});
|
|
3988
|
+
}
|
|
3989
|
+
flattenGroupMaps(groupedItems, [], true);
|
|
3990
|
+
return {
|
|
3991
|
+
sourceWithGroups, // updates source mirror
|
|
3992
|
+
depth: groupingDepth, // largest depth for grouping
|
|
3993
|
+
trimmed, // used for expand/collapse grouping values
|
|
3994
|
+
oldNewIndexMap, // used for mapping old values to new
|
|
3995
|
+
childrenByGroup: pseudoGroupTest, // used to get child items in group
|
|
3996
|
+
};
|
|
3571
3997
|
}
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3998
|
+
function getGroupingName(rgRow) {
|
|
3999
|
+
return rgRow && rgRow[PSEUDO_GROUP_ITEM];
|
|
4000
|
+
}
|
|
4001
|
+
function isGrouping(rgRow) {
|
|
4002
|
+
return typeof (rgRow === null || rgRow === void 0 ? void 0 : rgRow[PSEUDO_GROUP_ITEM]) !== 'undefined';
|
|
4003
|
+
}
|
|
4004
|
+
function isGroupingColumn(column) {
|
|
4005
|
+
return column && typeof column[PSEUDO_GROUP_COLUMN] !== 'undefined';
|
|
4006
|
+
}
|
|
4007
|
+
function measureEqualDepth(groupA, groupB) {
|
|
4008
|
+
const ln = groupA.length;
|
|
4009
|
+
let i = 0;
|
|
4010
|
+
for (; i < ln; i++) {
|
|
4011
|
+
if (groupA[i] !== groupB[i]) {
|
|
4012
|
+
return i;
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
return i;
|
|
4016
|
+
}
|
|
4017
|
+
function getParsedGroup(id) {
|
|
4018
|
+
const parseGroup = JSON.parse(id);
|
|
4019
|
+
// extra precaution and type safeguard
|
|
4020
|
+
if (!Array.isArray(parseGroup)) {
|
|
4021
|
+
return null;
|
|
4022
|
+
}
|
|
4023
|
+
return parseGroup;
|
|
4024
|
+
}
|
|
4025
|
+
// check if items is child of current clicked group
|
|
4026
|
+
function isSameGroup(currentGroup, currentModel, nextModel) {
|
|
4027
|
+
const nextGroup = getParsedGroup(nextModel[PSEUDO_GROUP_ITEM_ID]);
|
|
4028
|
+
if (!nextGroup) {
|
|
4029
|
+
return false;
|
|
4030
|
+
}
|
|
4031
|
+
const depth = measureEqualDepth(currentGroup, nextGroup);
|
|
4032
|
+
return currentModel[GROUP_DEPTH] < depth;
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
/**
|
|
4036
|
+
* The base implementation of `_.slice` without an iteratee call guard.
|
|
3581
4037
|
*
|
|
3582
|
-
*
|
|
4038
|
+
* @private
|
|
4039
|
+
* @param {Array} array The array to slice.
|
|
4040
|
+
* @param {number} [start=0] The start position.
|
|
4041
|
+
* @param {number} [end=array.length] The end position.
|
|
4042
|
+
* @returns {Array} Returns the slice of `array`.
|
|
3583
4043
|
*/
|
|
3584
|
-
function
|
|
3585
|
-
|
|
4044
|
+
function baseSlice(array, start, end) {
|
|
4045
|
+
var index = -1,
|
|
4046
|
+
length = array.length;
|
|
4047
|
+
|
|
4048
|
+
if (start < 0) {
|
|
4049
|
+
start = -start > length ? 0 : (length + start);
|
|
4050
|
+
}
|
|
4051
|
+
end = end > length ? length : end;
|
|
4052
|
+
if (end < 0) {
|
|
4053
|
+
end += length;
|
|
4054
|
+
}
|
|
4055
|
+
length = start > end ? 0 : ((end - start) >>> 0);
|
|
4056
|
+
start >>>= 0;
|
|
4057
|
+
|
|
4058
|
+
var result = Array(length);
|
|
4059
|
+
while (++index < length) {
|
|
4060
|
+
result[index] = array[index + start];
|
|
4061
|
+
}
|
|
4062
|
+
return result;
|
|
3586
4063
|
}
|
|
4064
|
+
|
|
3587
4065
|
/**
|
|
3588
|
-
*
|
|
4066
|
+
* Creates a slice of `array` from `start` up to, but not including, `end`.
|
|
4067
|
+
*
|
|
4068
|
+
* **Note:** This method is used instead of
|
|
4069
|
+
* [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
|
|
4070
|
+
* returned.
|
|
4071
|
+
*
|
|
4072
|
+
* @static
|
|
4073
|
+
* @memberOf _
|
|
4074
|
+
* @since 3.0.0
|
|
4075
|
+
* @category Array
|
|
4076
|
+
* @param {Array} array The array to slice.
|
|
4077
|
+
* @param {number} [start=0] The start position.
|
|
4078
|
+
* @param {number} [end=array.length] The end position.
|
|
4079
|
+
* @returns {Array} Returns the slice of `array`.
|
|
3589
4080
|
*/
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
4081
|
+
function slice(array, start, end) {
|
|
4082
|
+
var length = array == null ? 0 : array.length;
|
|
4083
|
+
if (!length) {
|
|
4084
|
+
return [];
|
|
4085
|
+
}
|
|
4086
|
+
if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
|
|
4087
|
+
start = 0;
|
|
4088
|
+
end = length;
|
|
4089
|
+
}
|
|
4090
|
+
else {
|
|
4091
|
+
start = start == null ? 0 : toInteger(start);
|
|
4092
|
+
end = end === undefined ? length : toInteger(end);
|
|
4093
|
+
}
|
|
4094
|
+
return baseSlice(array, start, end);
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
class ColumnService {
|
|
4098
|
+
get columns() {
|
|
4099
|
+
return getVisibleSourceItem(this.source);
|
|
4100
|
+
}
|
|
4101
|
+
constructor(dataStore, source) {
|
|
4102
|
+
this.dataStore = dataStore;
|
|
4103
|
+
this.source = source;
|
|
4104
|
+
this.unsubscribe = [];
|
|
4105
|
+
this.hasGrouping = false;
|
|
4106
|
+
this.unsubscribe.push(source.onChange('source', s => this.checkGrouping(s)));
|
|
4107
|
+
this.checkGrouping(source.get('source'));
|
|
4108
|
+
this.type = source.get('type');
|
|
4109
|
+
}
|
|
4110
|
+
checkGrouping(cols) {
|
|
4111
|
+
for (let rgCol of cols) {
|
|
4112
|
+
if (isGroupingColumn(rgCol)) {
|
|
4113
|
+
this.hasGrouping = true;
|
|
4114
|
+
return;
|
|
4115
|
+
}
|
|
4116
|
+
this.hasGrouping = false;
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
isReadOnly(r, c) {
|
|
4120
|
+
var _a;
|
|
4121
|
+
const readOnly = (_a = this.columns[c]) === null || _a === void 0 ? void 0 : _a.readonly;
|
|
4122
|
+
if (typeof readOnly === 'function') {
|
|
4123
|
+
const data = this.rowDataModel(r, c);
|
|
4124
|
+
return readOnly(data);
|
|
4125
|
+
}
|
|
4126
|
+
return !!readOnly;
|
|
4127
|
+
}
|
|
4128
|
+
mergeProperties(r, c, defaultProps, model, extraPropsFunc) {
|
|
4129
|
+
const props = Object.assign({}, defaultProps);
|
|
4130
|
+
props.class = Object.assign(Object.assign({}, (typeof props.class === 'string'
|
|
4131
|
+
? { [props.class]: true }
|
|
4132
|
+
: props.class)), { [index.CELL_CLASS]: true, [index.DISABLED_CLASS]: this.isReadOnly(r, c) });
|
|
4133
|
+
const extra = extraPropsFunc === null || extraPropsFunc === void 0 ? void 0 : extraPropsFunc(model);
|
|
4134
|
+
if (!extra) {
|
|
4135
|
+
return props;
|
|
4136
|
+
}
|
|
4137
|
+
return doPropMerge(props, extra);
|
|
4138
|
+
}
|
|
4139
|
+
getRowClass(r, prop) {
|
|
4140
|
+
const model = getSourceItem(this.dataStore, r) || {};
|
|
4141
|
+
return model[prop] || '';
|
|
4142
|
+
}
|
|
4143
|
+
getCellData(r, c) {
|
|
4144
|
+
const data = this.rowDataModel(r, c);
|
|
4145
|
+
return getCellData(data.model[data.prop]);
|
|
4146
|
+
}
|
|
4147
|
+
getSaveData(rowIndex, colIndex, val) {
|
|
4148
|
+
const data = this.rowDataModel(rowIndex, colIndex);
|
|
4149
|
+
if (typeof val === 'undefined') {
|
|
4150
|
+
val = getCellData(data.model[data.prop]);
|
|
4151
|
+
}
|
|
4152
|
+
return {
|
|
4153
|
+
prop: data.prop,
|
|
4154
|
+
rowIndex,
|
|
4155
|
+
colIndex,
|
|
4156
|
+
val,
|
|
4157
|
+
model: data.model,
|
|
4158
|
+
colType: this.type,
|
|
4159
|
+
type: this.dataStore.get('type'),
|
|
4160
|
+
};
|
|
4161
|
+
}
|
|
4162
|
+
getCellEditor(_r, c, editors) {
|
|
4163
|
+
var _a;
|
|
4164
|
+
const editor = (_a = this.columns[c]) === null || _a === void 0 ? void 0 : _a.editor;
|
|
4165
|
+
if (!editor) {
|
|
4166
|
+
return undefined;
|
|
4167
|
+
}
|
|
4168
|
+
// reference
|
|
4169
|
+
if (typeof editor === 'string') {
|
|
4170
|
+
return editors[editor];
|
|
4171
|
+
}
|
|
4172
|
+
return editor;
|
|
4173
|
+
}
|
|
4174
|
+
/**
|
|
4175
|
+
* Get cell data model for given rowIndex and colIndex
|
|
4176
|
+
* Used to pass data to editor/renderer
|
|
4177
|
+
*/
|
|
4178
|
+
rowDataModel(rowIndex, colIndex) {
|
|
4179
|
+
const column = this.columns[colIndex];
|
|
4180
|
+
const prop = column === null || column === void 0 ? void 0 : column.prop;
|
|
4181
|
+
const model = getSourceItem(this.dataStore, rowIndex) || {};
|
|
4182
|
+
const value = model[prop];
|
|
4183
|
+
const type = this.dataStore.get('type');
|
|
4184
|
+
return {
|
|
4185
|
+
prop,
|
|
4186
|
+
model,
|
|
4187
|
+
data: this.dataStore.get('source'),
|
|
4188
|
+
column,
|
|
4189
|
+
rowIndex,
|
|
4190
|
+
colIndex,
|
|
4191
|
+
colType: this.type,
|
|
4192
|
+
type,
|
|
4193
|
+
value,
|
|
4194
|
+
};
|
|
4195
|
+
}
|
|
4196
|
+
getRangeData(d, columns) {
|
|
4197
|
+
var _a;
|
|
4198
|
+
const changed = {};
|
|
4199
|
+
// get original length sizes
|
|
4200
|
+
const copyColLength = d.oldRange.x1 - d.oldRange.x + 1;
|
|
4201
|
+
const copyRowLength = d.oldRange.y1 - d.oldRange.y + 1;
|
|
4202
|
+
const mapping = {};
|
|
4203
|
+
// rows
|
|
4204
|
+
for (let rowIndex = d.newRange.y, i = 0; rowIndex < d.newRange.y1 + 1; rowIndex++, i++) {
|
|
4205
|
+
// copy original data link
|
|
4206
|
+
const oldRowIndex = d.oldRange.y + (i % copyRowLength);
|
|
4207
|
+
const copyRow = getSourceItem(this.dataStore, oldRowIndex) || {};
|
|
4208
|
+
// columns
|
|
4209
|
+
for (let colIndex = d.newRange.x, j = 0; colIndex < d.newRange.x1 + 1; colIndex++, j++) {
|
|
4210
|
+
// check if old range area
|
|
4211
|
+
if (rowIndex >= d.oldRange.y &&
|
|
4212
|
+
rowIndex <= d.oldRange.y1 &&
|
|
4213
|
+
colIndex >= d.oldRange.x &&
|
|
4214
|
+
colIndex <= d.oldRange.x1) {
|
|
4215
|
+
continue;
|
|
4216
|
+
}
|
|
4217
|
+
// requested column beyond range
|
|
4218
|
+
if (!this.columns[colIndex]) {
|
|
4219
|
+
continue;
|
|
4220
|
+
}
|
|
4221
|
+
const prop = (_a = this.columns[colIndex]) === null || _a === void 0 ? void 0 : _a.prop;
|
|
4222
|
+
const copyColIndex = d.oldRange.x + (j % copyColLength);
|
|
4223
|
+
const copyColumnProp = columns[copyColIndex].prop;
|
|
4224
|
+
/** if can write */
|
|
4225
|
+
if (!this.isReadOnly(rowIndex, colIndex)) {
|
|
4226
|
+
/** to show before save */
|
|
4227
|
+
if (!changed[rowIndex]) {
|
|
4228
|
+
changed[rowIndex] = {};
|
|
4229
|
+
}
|
|
4230
|
+
changed[rowIndex][prop] = copyRow[copyColumnProp];
|
|
4231
|
+
/** Generate mapping object */
|
|
4232
|
+
if (!mapping[rowIndex]) {
|
|
4233
|
+
mapping[rowIndex] = {};
|
|
4234
|
+
}
|
|
4235
|
+
mapping[rowIndex][prop] = {
|
|
4236
|
+
colIndex: copyColIndex,
|
|
4237
|
+
colProp: copyColumnProp,
|
|
4238
|
+
rowIndex: oldRowIndex,
|
|
4239
|
+
};
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
return {
|
|
4244
|
+
changed,
|
|
4245
|
+
mapping,
|
|
4246
|
+
};
|
|
4247
|
+
}
|
|
4248
|
+
getTransformedDataToApply(start, data) {
|
|
4249
|
+
const changed = {};
|
|
4250
|
+
const copyRowLength = data.length;
|
|
4251
|
+
const colLength = this.columns.length;
|
|
4252
|
+
const rowLength = this.dataStore.get('items').length;
|
|
4253
|
+
// rows
|
|
4254
|
+
let rowIndex = start.y;
|
|
4255
|
+
let maxCol = 0;
|
|
4256
|
+
for (let i = 0; rowIndex < rowLength && i < copyRowLength; rowIndex++, i++) {
|
|
4257
|
+
// copy original data link
|
|
4258
|
+
const copyRow = data[i % copyRowLength];
|
|
4259
|
+
const copyColLength = (copyRow === null || copyRow === void 0 ? void 0 : copyRow.length) || 0;
|
|
4260
|
+
// columns
|
|
4261
|
+
let colIndex = start.x;
|
|
4262
|
+
for (let j = 0; colIndex < colLength && j < copyColLength; colIndex++, j++) {
|
|
4263
|
+
const p = this.columns[colIndex].prop;
|
|
4264
|
+
const currentCol = j % colLength;
|
|
4265
|
+
/** if can write */
|
|
4266
|
+
if (!this.isReadOnly(rowIndex, colIndex)) {
|
|
4267
|
+
/** to show before save */
|
|
4268
|
+
if (!changed[rowIndex]) {
|
|
4269
|
+
changed[rowIndex] = {};
|
|
4270
|
+
}
|
|
4271
|
+
changed[rowIndex][p] = copyRow[currentCol];
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
maxCol = Math.max(maxCol, colIndex - 1);
|
|
4275
|
+
}
|
|
4276
|
+
const range = getRange(start, {
|
|
4277
|
+
y: rowIndex - 1,
|
|
4278
|
+
x: maxCol,
|
|
4279
|
+
});
|
|
4280
|
+
return {
|
|
4281
|
+
changed,
|
|
4282
|
+
range,
|
|
4283
|
+
};
|
|
4284
|
+
}
|
|
4285
|
+
getRangeStaticData(d, value) {
|
|
4286
|
+
const changed = {};
|
|
4287
|
+
// rows
|
|
4288
|
+
for (let rowIndex = d.y, i = 0; rowIndex < d.y1 + 1; rowIndex++, i++) {
|
|
4289
|
+
// columns
|
|
4290
|
+
for (let colIndex = d.x, j = 0; colIndex < d.x1 + 1; colIndex++, j++) {
|
|
4291
|
+
// requested column beyond range
|
|
4292
|
+
if (!this.columns[colIndex]) {
|
|
4293
|
+
continue;
|
|
4294
|
+
}
|
|
4295
|
+
const p = this.columns[colIndex].prop;
|
|
4296
|
+
/** if can write */
|
|
4297
|
+
if (!this.isReadOnly(rowIndex, colIndex)) {
|
|
4298
|
+
/** to show before save */
|
|
4299
|
+
if (!changed[rowIndex]) {
|
|
4300
|
+
changed[rowIndex] = {};
|
|
4301
|
+
}
|
|
4302
|
+
changed[rowIndex][p] = value;
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
return changed;
|
|
4307
|
+
}
|
|
4308
|
+
getRangeTransformedToProps(d, store) {
|
|
4309
|
+
var _a;
|
|
4310
|
+
const area = [];
|
|
4311
|
+
const type = this.dataStore.get('type');
|
|
4312
|
+
// rows
|
|
4313
|
+
for (let rowIndex = d.y, i = 0; rowIndex < d.y1 + 1; rowIndex++, i++) {
|
|
4314
|
+
// columns
|
|
4315
|
+
for (let colIndex = d.x, j = 0; colIndex < d.x1 + 1; colIndex++, j++) {
|
|
4316
|
+
const prop = (_a = this.columns[colIndex]) === null || _a === void 0 ? void 0 : _a.prop;
|
|
4317
|
+
area.push({
|
|
4318
|
+
prop,
|
|
4319
|
+
rowIndex,
|
|
4320
|
+
colIndex,
|
|
4321
|
+
model: getSourceItem(store, rowIndex),
|
|
4322
|
+
type,
|
|
4323
|
+
colType: this.type,
|
|
4324
|
+
});
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
return area;
|
|
4328
|
+
}
|
|
4329
|
+
copyRangeArray(range, store) {
|
|
4330
|
+
const cols = [...this.columns];
|
|
4331
|
+
const props = slice(cols, range.x, range.x1 + 1).map(v => v.prop);
|
|
4332
|
+
const toCopy = [];
|
|
4333
|
+
const mapping = {};
|
|
4334
|
+
// rows indexes
|
|
4335
|
+
for (let i = range.y; i <= range.y1; i++) {
|
|
4336
|
+
const rgRow = [];
|
|
4337
|
+
mapping[i] = {};
|
|
4338
|
+
// columns indexes
|
|
4339
|
+
for (let prop of props) {
|
|
4340
|
+
const item = getSourceItem(store, i);
|
|
4341
|
+
// if no item - skip
|
|
4342
|
+
if (!item) {
|
|
4343
|
+
continue;
|
|
4344
|
+
}
|
|
4345
|
+
const val = item[prop];
|
|
4346
|
+
rgRow.push(val);
|
|
4347
|
+
mapping[i][prop] = val;
|
|
4348
|
+
}
|
|
4349
|
+
toCopy.push(rgRow);
|
|
4350
|
+
}
|
|
4351
|
+
return {
|
|
4352
|
+
data: toCopy,
|
|
4353
|
+
mapping,
|
|
4354
|
+
};
|
|
4355
|
+
}
|
|
4356
|
+
destroy() {
|
|
4357
|
+
this.unsubscribe.forEach(f => f());
|
|
4358
|
+
}
|
|
3594
4359
|
}
|
|
3595
4360
|
/**
|
|
3596
|
-
*
|
|
4361
|
+
* Checks if the given rowDrag is a service for dragging rows.
|
|
3597
4362
|
*/
|
|
3598
|
-
function
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
4363
|
+
function isRowDragService(rowDrag, model) {
|
|
4364
|
+
if (typeof rowDrag === 'function') {
|
|
4365
|
+
return rowDrag(model);
|
|
4366
|
+
}
|
|
4367
|
+
return !!rowDrag;
|
|
4368
|
+
}
|
|
4369
|
+
function mergeClasses(class1 = {}, class2 = {}) {
|
|
4370
|
+
if (typeof class1 === 'string') {
|
|
4371
|
+
class1 = { [class1]: true };
|
|
4372
|
+
}
|
|
4373
|
+
if (typeof class2 === 'string') {
|
|
4374
|
+
class2 = { [class2]: true };
|
|
4375
|
+
}
|
|
4376
|
+
return Object.assign(Object.assign({}, class1), class2);
|
|
4377
|
+
}
|
|
4378
|
+
function doPropMerge(existing, extra) {
|
|
4379
|
+
// if className is provided - remove it from props it messing with stencil
|
|
4380
|
+
if (extra.className) {
|
|
4381
|
+
extra.class = mergeClasses(extra.class, extra.className);
|
|
4382
|
+
delete extra.className;
|
|
4383
|
+
}
|
|
4384
|
+
let props = Object.assign(Object.assign({}, extra), existing);
|
|
4385
|
+
// extend existing props
|
|
4386
|
+
if (extra.class) {
|
|
4387
|
+
props.class = mergeClasses(props.class, extra.class);
|
|
4388
|
+
}
|
|
4389
|
+
if (extra.style) {
|
|
4390
|
+
props.style = Object.assign(Object.assign({}, extra.style), props.style);
|
|
4391
|
+
}
|
|
4392
|
+
return props;
|
|
3604
4393
|
}
|
|
3605
4394
|
|
|
3606
|
-
exports.
|
|
3607
|
-
exports.CELL_HANDLER_CLASS = CELL_HANDLER_CLASS;
|
|
3608
|
-
exports.DATA_COL = DATA_COL;
|
|
3609
|
-
exports.DATA_ROW = DATA_ROW;
|
|
3610
|
-
exports.DISABLED_CLASS = DISABLED_CLASS;
|
|
3611
|
-
exports.DRAGGABLE_CLASS = DRAGGABLE_CLASS;
|
|
3612
|
-
exports.DRAGG_TEXT = DRAGG_TEXT;
|
|
3613
|
-
exports.DRAG_ICON_CLASS = DRAG_ICON_CLASS;
|
|
4395
|
+
exports.ColumnService = ColumnService;
|
|
3614
4396
|
exports.DataStore = DataStore;
|
|
3615
|
-
exports.
|
|
3616
|
-
exports.
|
|
3617
|
-
exports.
|
|
3618
|
-
exports.
|
|
3619
|
-
exports.
|
|
3620
|
-
exports.
|
|
3621
|
-
exports.
|
|
3622
|
-
exports.
|
|
3623
|
-
exports.
|
|
3624
|
-
exports.
|
|
3625
|
-
exports.
|
|
3626
|
-
exports.
|
|
3627
|
-
exports.
|
|
3628
|
-
exports.ROW_HEADER_TYPE = ROW_HEADER_TYPE;
|
|
3629
|
-
exports.SELECTION_BORDER_CLASS = SELECTION_BORDER_CLASS;
|
|
3630
|
-
exports.TMP_SELECTION_BG_CLASS = TMP_SELECTION_BG_CLASS;
|
|
3631
|
-
exports.applyMixins = applyMixins;
|
|
4397
|
+
exports.EMPTY_INDEX = EMPTY_INDEX;
|
|
4398
|
+
exports.GROUPING_ROW_TYPE = GROUPING_ROW_TYPE;
|
|
4399
|
+
exports.GROUP_DEPTH = GROUP_DEPTH;
|
|
4400
|
+
exports.GROUP_EXPANDED = GROUP_EXPANDED;
|
|
4401
|
+
exports.GROUP_EXPAND_BTN = GROUP_EXPAND_BTN;
|
|
4402
|
+
exports.GROUP_EXPAND_EVENT = GROUP_EXPAND_EVENT;
|
|
4403
|
+
exports.PSEUDO_GROUP_COLUMN = PSEUDO_GROUP_COLUMN;
|
|
4404
|
+
exports.PSEUDO_GROUP_ITEM = PSEUDO_GROUP_ITEM;
|
|
4405
|
+
exports.PSEUDO_GROUP_ITEM_ID = PSEUDO_GROUP_ITEM_ID;
|
|
4406
|
+
exports.PSEUDO_GROUP_ITEM_VALUE = PSEUDO_GROUP_ITEM_VALUE;
|
|
4407
|
+
exports.SelectionStore = SelectionStore;
|
|
4408
|
+
exports.SelectionStoreConnector = SelectionStoreConnector;
|
|
4409
|
+
exports.baseEach = baseEach$1;
|
|
3632
4410
|
exports.baseIteratee = baseIteratee;
|
|
3633
4411
|
exports.baseKeys = baseKeys;
|
|
3634
4412
|
exports.baseProperty = baseProperty;
|
|
3635
|
-
exports.calculateDimensionData = calculateDimensionData;
|
|
3636
4413
|
exports.createStore = createStore;
|
|
4414
|
+
exports.cropCellToMax = cropCellToMax;
|
|
4415
|
+
exports.doPropMerge = doPropMerge;
|
|
3637
4416
|
exports.findIndex = findIndex;
|
|
3638
|
-
exports.
|
|
4417
|
+
exports.gatherGroup = gatherGroup;
|
|
4418
|
+
exports.gatherGrouping = gatherGrouping;
|
|
3639
4419
|
exports.gatherTrimmedItems = gatherTrimmedItems;
|
|
3640
|
-
exports.
|
|
3641
|
-
exports.
|
|
4420
|
+
exports.getCellData = getCellData;
|
|
4421
|
+
exports.getCellDataParsed = getCellDataParsed;
|
|
4422
|
+
exports.getColumnByProp = getColumnByProp;
|
|
4423
|
+
exports.getColumnSizes = getColumnSizes;
|
|
4424
|
+
exports.getColumnType = getColumnType;
|
|
4425
|
+
exports.getColumns = getColumns;
|
|
4426
|
+
exports.getGroupingName = getGroupingName;
|
|
3642
4427
|
exports.getNative = getNative;
|
|
4428
|
+
exports.getParsedGroup = getParsedGroup;
|
|
3643
4429
|
exports.getPhysical = getPhysical;
|
|
3644
|
-
exports.
|
|
4430
|
+
exports.getRange = getRange;
|
|
3645
4431
|
exports.getSourceItem = getSourceItem;
|
|
3646
4432
|
exports.getSourceItemVirtualIndexByProp = getSourceItemVirtualIndexByProp;
|
|
3647
4433
|
exports.getSourcePhysicalIndex = getSourcePhysicalIndex;
|
|
3648
4434
|
exports.getTag = getTag$1;
|
|
3649
4435
|
exports.getVisibleSourceItem = getVisibleSourceItem;
|
|
3650
|
-
exports.identity = identity;
|
|
3651
4436
|
exports.isArray = isArray$1;
|
|
3652
4437
|
exports.isArrayLike = isArrayLike;
|
|
4438
|
+
exports.isColGrouping = isColGrouping;
|
|
4439
|
+
exports.isGrouping = isGrouping;
|
|
4440
|
+
exports.isGroupingColumn = isGroupingColumn;
|
|
4441
|
+
exports.isHiddenStore = isHiddenStore;
|
|
3653
4442
|
exports.isIterateeCall = isIterateeCall;
|
|
3654
|
-
exports.
|
|
3655
|
-
exports.
|
|
4443
|
+
exports.isRangeSingleCell = isRangeSingleCell;
|
|
4444
|
+
exports.isRowDragService = isRowDragService;
|
|
4445
|
+
exports.isSameGroup = isSameGroup;
|
|
4446
|
+
exports.nextCell = nextCell;
|
|
3656
4447
|
exports.proxyPlugin = proxyPlugin;
|
|
3657
|
-
exports.
|
|
3658
|
-
exports.range = range;
|
|
3659
|
-
exports.range$1 = range$2;
|
|
3660
|
-
exports.scaleValue = scaleValue;
|
|
4448
|
+
exports.reduce = reduce;
|
|
3661
4449
|
exports.setItems = setItems;
|
|
3662
4450
|
exports.setSourceByPhysicalIndex = setSourceByPhysicalIndex;
|
|
3663
4451
|
exports.setSourceByVirtualIndex = setSourceByVirtualIndex;
|
|
3664
4452
|
exports.setStore = setStore;
|
|
3665
|
-
exports.timeout = timeout;
|
|
3666
4453
|
exports.toInteger = toInteger;
|
|
3667
4454
|
exports.trimmedPlugin = trimmedPlugin;
|
|
3668
4455
|
|
|
3669
|
-
//# sourceMappingURL=
|
|
4456
|
+
//# sourceMappingURL=column.service-26c61ed6.js.map
|