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