@revolist/revogrid 4.10.0 → 4.10.2

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 (122) hide show
  1. package/dist/cjs/{column.drag.plugin-7098477f.js → column.drag.plugin-08ca04f4.js} +18 -18
  2. package/dist/cjs/column.drag.plugin-08ca04f4.js.map +1 -0
  3. package/dist/cjs/column.service-2670e6e7.js +1286 -0
  4. package/dist/cjs/column.service-2670e6e7.js.map +1 -0
  5. package/dist/cjs/{edit.utils-75fa1cab.js → edit.utils-4a790cf8.js} +2 -2
  6. package/dist/cjs/{edit.utils-75fa1cab.js.map → edit.utils-4a790cf8.js.map} +1 -1
  7. package/dist/cjs/{header-cell-renderer-aaaad4c8.js → header-cell-renderer-db089f54.js} +2 -2
  8. package/dist/cjs/{header-cell-renderer-aaaad4c8.js.map → header-cell-renderer-db089f54.js.map} +1 -1
  9. package/dist/cjs/{column.service-f1d5d924.js → index-91e92bea.js} +452 -1227
  10. package/dist/cjs/index-91e92bea.js.map +1 -0
  11. package/dist/cjs/index.cjs.js +20 -20
  12. package/dist/cjs/{key.utils-8f1105f3.js → key.utils-e65c24e6.js} +2 -2
  13. package/dist/cjs/{key.utils-8f1105f3.js.map → key.utils-e65c24e6.js.map} +1 -1
  14. package/dist/cjs/revo-grid.cjs.entry.js +26 -26
  15. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  16. package/dist/cjs/revogr-attribution_7.cjs.entry.js +11 -11
  17. package/dist/cjs/revogr-attribution_7.cjs.entry.js.map +1 -1
  18. package/dist/cjs/revogr-clipboard_3.cjs.entry.js +5 -4
  19. package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
  20. package/dist/cjs/revogr-data_4.cjs.entry.js +9 -9
  21. package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
  22. package/dist/cjs/{row-header-utils-208e4026.js → row-header-utils-dc3d3185.js} +5 -6
  23. package/dist/cjs/row-header-utils-dc3d3185.js.map +1 -0
  24. package/dist/cjs/{text-editor-b64a080e.js → text-editor-a32a3993.js} +3 -3
  25. package/dist/cjs/{text-editor-b64a080e.js.map → text-editor-a32a3993.js.map} +1 -1
  26. package/dist/cjs/{throttle-3b362440.js → throttle-da92b75d.js} +2 -2
  27. package/dist/cjs/{throttle-3b362440.js.map → throttle-da92b75d.js.map} +1 -1
  28. package/dist/collection/components/order/revogr-order-editor.js +4 -2
  29. package/dist/collection/components/order/revogr-order-editor.js.map +1 -1
  30. package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
  31. package/dist/esm/{column.drag.plugin-813698d2.js → column.drag.plugin-b7bba0da.js} +6 -6
  32. package/dist/esm/{column.drag.plugin-813698d2.js.map → column.drag.plugin-b7bba0da.js.map} +1 -1
  33. package/dist/esm/column.service-9b0603f4.js +1249 -0
  34. package/dist/esm/column.service-9b0603f4.js.map +1 -0
  35. package/dist/esm/{debounce-72878ced.js → debounce-7b511afc.js} +2 -2
  36. package/dist/esm/{debounce-72878ced.js.map → debounce-7b511afc.js.map} +1 -1
  37. package/dist/esm/{edit.utils-cd6a3224.js → edit.utils-abcd0152.js} +2 -2
  38. package/dist/esm/{edit.utils-cd6a3224.js.map → edit.utils-abcd0152.js.map} +1 -1
  39. package/dist/esm/{header-cell-renderer-5939221a.js → header-cell-renderer-fce020c3.js} +2 -2
  40. package/dist/esm/{header-cell-renderer-5939221a.js.map → header-cell-renderer-fce020c3.js.map} +1 -1
  41. package/dist/esm/{column.service-aa142672.js → index-b1e05212.js} +411 -1187
  42. package/dist/esm/index-b1e05212.js.map +1 -0
  43. package/dist/esm/index.js +8 -8
  44. package/dist/esm/{key.utils-5ff2ec82.js → key.utils-ea9aec31.js} +2 -2
  45. package/dist/esm/{key.utils-5ff2ec82.js.map → key.utils-ea9aec31.js.map} +1 -1
  46. package/dist/esm/revo-grid.entry.js +6 -6
  47. package/dist/esm/revo-grid.entry.js.map +1 -1
  48. package/dist/esm/revogr-attribution_7.entry.js +7 -7
  49. package/dist/esm/revogr-clipboard_3.entry.js +6 -5
  50. package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
  51. package/dist/esm/revogr-data_4.entry.js +5 -5
  52. package/dist/esm/revogr-filter-panel.entry.js +1 -1
  53. package/dist/esm/{row-header-utils-5511678e.js → row-header-utils-7af8fcbf.js} +2 -3
  54. package/dist/esm/row-header-utils-7af8fcbf.js.map +1 -0
  55. package/dist/esm/{text-editor-81767dcb.js → text-editor-fb3f24fe.js} +3 -3
  56. package/dist/esm/{text-editor-81767dcb.js.map → text-editor-fb3f24fe.js.map} +1 -1
  57. package/dist/esm/{throttle-4eff5b3c.js → throttle-1f5772ef.js} +3 -3
  58. package/dist/esm/{throttle-4eff5b3c.js.map → throttle-1f5772ef.js.map} +1 -1
  59. package/dist/revo-grid/column.drag.plugin-b7bba0da.js +5 -0
  60. package/dist/revo-grid/{column.drag.plugin-813698d2.js.map → column.drag.plugin-b7bba0da.js.map} +1 -1
  61. package/dist/revo-grid/column.service-9b0603f4.js +5 -0
  62. package/dist/revo-grid/column.service-9b0603f4.js.map +1 -0
  63. package/dist/revo-grid/{debounce-72878ced.js → debounce-7b511afc.js} +2 -2
  64. package/dist/revo-grid/{edit.utils-cd6a3224.js → edit.utils-abcd0152.js} +2 -2
  65. package/dist/revo-grid/{header-cell-renderer-5939221a.js → header-cell-renderer-fce020c3.js} +2 -2
  66. package/dist/revo-grid/index-b1e05212.js +5 -0
  67. package/dist/revo-grid/index-b1e05212.js.map +1 -0
  68. package/dist/revo-grid/index.esm.js +1 -1
  69. package/dist/revo-grid/key.utils-ea9aec31.js +5 -0
  70. package/dist/revo-grid/{key.utils-5ff2ec82.js.map → key.utils-ea9aec31.js.map} +1 -1
  71. package/dist/revo-grid/revo-grid.entry.js +1 -1
  72. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  73. package/dist/revo-grid/revogr-attribution_7.entry.js +1 -1
  74. package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
  75. package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
  76. package/dist/revo-grid/revogr-data_4.entry.js +1 -1
  77. package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
  78. package/dist/revo-grid/revogr-filter-panel.entry.js +1 -1
  79. package/dist/revo-grid/row-header-utils-7af8fcbf.js +5 -0
  80. package/dist/revo-grid/{row-header-utils-5511678e.js.map → row-header-utils-7af8fcbf.js.map} +1 -1
  81. package/dist/revo-grid/text-editor-fb3f24fe.js +5 -0
  82. package/dist/revo-grid/{throttle-4eff5b3c.js → throttle-1f5772ef.js} +2 -2
  83. package/dist/types/components/order/revogr-order-editor.d.ts +1 -0
  84. package/dist/types/components/revoGrid/revo-grid.d.ts +1 -5
  85. package/dist/types/components.d.ts +2 -0
  86. package/hydrate/index.js +24 -23
  87. package/hydrate/index.mjs +24 -23
  88. package/package.json +1 -1
  89. package/readme.md +10 -12
  90. package/standalone/column.service.js +1 -1
  91. package/standalone/data.store.js +21 -2
  92. package/standalone/data.store.js.map +1 -1
  93. package/standalone/dimension.helpers.js +1 -1
  94. package/standalone/revo-grid.js +1 -2
  95. package/standalone/revo-grid.js.map +1 -1
  96. package/standalone/revogr-header2.js +1 -1
  97. package/standalone/revogr-order-editor2.js +2 -0
  98. package/standalone/revogr-order-editor2.js.map +1 -1
  99. package/dist/cjs/column.drag.plugin-7098477f.js.map +0 -1
  100. package/dist/cjs/column.service-f1d5d924.js.map +0 -1
  101. package/dist/cjs/index-aecb871a.js +0 -510
  102. package/dist/cjs/index-aecb871a.js.map +0 -1
  103. package/dist/cjs/row-header-utils-208e4026.js.map +0 -1
  104. package/dist/esm/column.service-aa142672.js.map +0 -1
  105. package/dist/esm/index-dbd1c020.js +0 -473
  106. package/dist/esm/index-dbd1c020.js.map +0 -1
  107. package/dist/esm/row-header-utils-5511678e.js.map +0 -1
  108. package/dist/revo-grid/column.drag.plugin-813698d2.js +0 -5
  109. package/dist/revo-grid/column.service-aa142672.js +0 -5
  110. package/dist/revo-grid/column.service-aa142672.js.map +0 -1
  111. package/dist/revo-grid/index-dbd1c020.js +0 -5
  112. package/dist/revo-grid/index-dbd1c020.js.map +0 -1
  113. package/dist/revo-grid/key.utils-5ff2ec82.js +0 -5
  114. package/dist/revo-grid/row-header-utils-5511678e.js +0 -5
  115. package/dist/revo-grid/text-editor-81767dcb.js +0 -5
  116. package/standalone/identity.js +0 -26
  117. package/standalone/identity.js.map +0 -1
  118. /package/dist/revo-grid/{debounce-72878ced.js.map → debounce-7b511afc.js.map} +0 -0
  119. /package/dist/revo-grid/{edit.utils-cd6a3224.js.map → edit.utils-abcd0152.js.map} +0 -0
  120. /package/dist/revo-grid/{header-cell-renderer-5939221a.js.map → header-cell-renderer-fce020c3.js.map} +0 -0
  121. /package/dist/revo-grid/{text-editor-81767dcb.js.map → text-editor-fb3f24fe.js.map} +0 -0
  122. /package/dist/revo-grid/{throttle-4eff5b3c.js.map → throttle-1f5772ef.js.map} +0 -0
@@ -0,0 +1,1286 @@
1
+ /*!
2
+ * Built by Revolist OU ❤️
3
+ */
4
+ 'use strict';
5
+
6
+ const index = require('./index-91e92bea.js');
7
+ require('./index-10d10c55.js');
8
+
9
+ /**
10
+ * A specialized version of `_.reduce` for arrays without support for
11
+ * iteratee shorthands.
12
+ *
13
+ * @private
14
+ * @param {Array} [array] The array to iterate over.
15
+ * @param {Function} iteratee The function invoked per iteration.
16
+ * @param {*} [accumulator] The initial value.
17
+ * @param {boolean} [initAccum] Specify using the first element of `array` as
18
+ * the initial value.
19
+ * @returns {*} Returns the accumulated value.
20
+ */
21
+ function arrayReduce(array, iteratee, accumulator, initAccum) {
22
+ var index = -1,
23
+ length = array == null ? 0 : array.length;
24
+
25
+ if (initAccum && length) {
26
+ accumulator = array[++index];
27
+ }
28
+ while (++index < length) {
29
+ accumulator = iteratee(accumulator, array[index], index, array);
30
+ }
31
+ return accumulator;
32
+ }
33
+
34
+ /**
35
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
36
+ *
37
+ * @private
38
+ * @param {boolean} [fromRight] Specify iterating from right to left.
39
+ * @returns {Function} Returns the new base function.
40
+ */
41
+ function createBaseFor(fromRight) {
42
+ return function(object, iteratee, keysFunc) {
43
+ var index = -1,
44
+ iterable = Object(object),
45
+ props = keysFunc(object),
46
+ length = props.length;
47
+
48
+ while (length--) {
49
+ var key = props[fromRight ? length : ++index];
50
+ if (iteratee(iterable[key], key, iterable) === false) {
51
+ break;
52
+ }
53
+ }
54
+ return object;
55
+ };
56
+ }
57
+
58
+ /**
59
+ * The base implementation of `baseForOwn` which iterates over `object`
60
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
61
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
62
+ *
63
+ * @private
64
+ * @param {Object} object The object to iterate over.
65
+ * @param {Function} iteratee The function invoked per iteration.
66
+ * @param {Function} keysFunc The function to get the keys of `object`.
67
+ * @returns {Object} Returns `object`.
68
+ */
69
+ var baseFor = createBaseFor();
70
+
71
+ const baseFor$1 = baseFor;
72
+
73
+ /**
74
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
75
+ *
76
+ * @private
77
+ * @param {Object} object The object to iterate over.
78
+ * @param {Function} iteratee The function invoked per iteration.
79
+ * @returns {Object} Returns `object`.
80
+ */
81
+ function baseForOwn(object, iteratee) {
82
+ return object && baseFor$1(object, iteratee, index.keys);
83
+ }
84
+
85
+ /**
86
+ * Creates a `baseEach` or `baseEachRight` function.
87
+ *
88
+ * @private
89
+ * @param {Function} eachFunc The function to iterate over a collection.
90
+ * @param {boolean} [fromRight] Specify iterating from right to left.
91
+ * @returns {Function} Returns the new base function.
92
+ */
93
+ function createBaseEach(eachFunc, fromRight) {
94
+ return function(collection, iteratee) {
95
+ if (collection == null) {
96
+ return collection;
97
+ }
98
+ if (!index.isArrayLike(collection)) {
99
+ return eachFunc(collection, iteratee);
100
+ }
101
+ var length = collection.length,
102
+ index$1 = fromRight ? length : -1,
103
+ iterable = Object(collection);
104
+
105
+ while ((fromRight ? index$1-- : ++index$1 < length)) {
106
+ if (iteratee(iterable[index$1], index$1, iterable) === false) {
107
+ break;
108
+ }
109
+ }
110
+ return collection;
111
+ };
112
+ }
113
+
114
+ /**
115
+ * The base implementation of `_.forEach` without support for iteratee shorthands.
116
+ *
117
+ * @private
118
+ * @param {Array|Object} collection The collection to iterate over.
119
+ * @param {Function} iteratee The function invoked per iteration.
120
+ * @returns {Array|Object} Returns `collection`.
121
+ */
122
+ var baseEach = createBaseEach(baseForOwn);
123
+
124
+ const baseEach$1 = baseEach;
125
+
126
+ /**
127
+ * The base implementation of `_.reduce` and `_.reduceRight`, without support
128
+ * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
129
+ *
130
+ * @private
131
+ * @param {Array|Object} collection The collection to iterate over.
132
+ * @param {Function} iteratee The function invoked per iteration.
133
+ * @param {*} accumulator The initial value.
134
+ * @param {boolean} initAccum Specify using the first or last element of
135
+ * `collection` as the initial value.
136
+ * @param {Function} eachFunc The function to iterate over `collection`.
137
+ * @returns {*} Returns the accumulated value.
138
+ */
139
+ function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
140
+ eachFunc(collection, function(value, index, collection) {
141
+ accumulator = initAccum
142
+ ? (initAccum = false, value)
143
+ : iteratee(accumulator, value, index, collection);
144
+ });
145
+ return accumulator;
146
+ }
147
+
148
+ /**
149
+ * Reduces `collection` to a value which is the accumulated result of running
150
+ * each element in `collection` thru `iteratee`, where each successive
151
+ * invocation is supplied the return value of the previous. If `accumulator`
152
+ * is not given, the first element of `collection` is used as the initial
153
+ * value. The iteratee is invoked with four arguments:
154
+ * (accumulator, value, index|key, collection).
155
+ *
156
+ * Many lodash methods are guarded to work as iteratees for methods like
157
+ * `_.reduce`, `_.reduceRight`, and `_.transform`.
158
+ *
159
+ * The guarded methods are:
160
+ * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
161
+ * and `sortBy`
162
+ *
163
+ * @static
164
+ * @memberOf _
165
+ * @since 0.1.0
166
+ * @category Collection
167
+ * @param {Array|Object} collection The collection to iterate over.
168
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
169
+ * @param {*} [accumulator] The initial value.
170
+ * @returns {*} Returns the accumulated value.
171
+ * @see _.reduceRight
172
+ * @example
173
+ *
174
+ * _.reduce([1, 2], function(sum, n) {
175
+ * return sum + n;
176
+ * }, 0);
177
+ * // => 3
178
+ *
179
+ * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
180
+ * (result[value] || (result[value] = [])).push(key);
181
+ * return result;
182
+ * }, {});
183
+ * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
184
+ */
185
+ function reduce(collection, iteratee, accumulator) {
186
+ var func = index.isArray(collection) ? arrayReduce : baseReduce,
187
+ initAccum = arguments.length < 3;
188
+
189
+ return func(collection, index.baseIteratee(iteratee), accumulator, initAccum, baseEach$1);
190
+ }
191
+
192
+ /**
193
+ * Selection store
194
+ */
195
+ function defaultState() {
196
+ return {
197
+ range: null,
198
+ tempRange: null,
199
+ tempRangeType: null,
200
+ focus: null,
201
+ edit: null,
202
+ lastCell: null,
203
+ nextFocus: null,
204
+ };
205
+ }
206
+ class SelectionStore {
207
+ constructor() {
208
+ this.unsubscribe = [];
209
+ this.store = index.createStore(defaultState());
210
+ this.store.on('set', (key, newVal) => {
211
+ if (key === 'tempRange' && !newVal) {
212
+ this.store.set('tempRangeType', null);
213
+ }
214
+ });
215
+ }
216
+ onChange(propName, cb) {
217
+ this.unsubscribe.push(this.store.onChange(propName, cb));
218
+ }
219
+ clearFocus() {
220
+ index.setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });
221
+ }
222
+ setFocus(focus, end) {
223
+ if (!end) {
224
+ index.setStore(this.store, { focus });
225
+ }
226
+ else {
227
+ index.setStore(this.store, {
228
+ focus,
229
+ range: getRange(focus, end),
230
+ edit: null,
231
+ tempRange: null,
232
+ });
233
+ }
234
+ }
235
+ setNextFocus(focus) {
236
+ index.setStore(this.store, { nextFocus: focus });
237
+ }
238
+ setTempArea(range) {
239
+ index.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 });
240
+ }
241
+ clearTemp() {
242
+ index.setStore(this.store, { tempRange: null });
243
+ }
244
+ /** Can be applied from selection change or from simple keyboard change clicks */
245
+ setRangeArea(range) {
246
+ index.setStore(this.store, { range, edit: null, tempRange: null });
247
+ }
248
+ setRange(start, end) {
249
+ const range = getRange(start, end);
250
+ this.setRangeArea(range);
251
+ }
252
+ setLastCell(lastCell) {
253
+ index.setStore(this.store, { lastCell });
254
+ }
255
+ setEdit(val) {
256
+ const focus = this.store.get('focus');
257
+ if (focus && typeof val === 'string') {
258
+ index.setStore(this.store, {
259
+ edit: { x: focus.x, y: focus.y, val },
260
+ });
261
+ return;
262
+ }
263
+ index.setStore(this.store, { edit: null });
264
+ }
265
+ dispose() {
266
+ this.unsubscribe.forEach(f => f());
267
+ this.store.dispose();
268
+ }
269
+ }
270
+
271
+ const EMPTY_INDEX = -1;
272
+ class SelectionStoreConnector {
273
+ constructor() {
274
+ // dirty flag required to cleanup whole store in case visibility of panels changed
275
+ this.dirty = false;
276
+ this.stores = {};
277
+ this.columnStores = {};
278
+ this.rowStores = {};
279
+ /**
280
+ * Helpers for data conversion
281
+ */
282
+ this.storesByType = {};
283
+ this.storesXToType = {};
284
+ this.storesYToType = {};
285
+ this.sections = [];
286
+ }
287
+ get focusedStore() {
288
+ var _a;
289
+ for (let y in this.stores) {
290
+ for (let x in this.stores[y]) {
291
+ const focused = (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.store.get('focus');
292
+ if (focused) {
293
+ return {
294
+ entity: this.stores[y][x],
295
+ cell: focused,
296
+ position: {
297
+ x: parseInt(x, 10),
298
+ y: parseInt(y, 10),
299
+ },
300
+ };
301
+ }
302
+ }
303
+ }
304
+ return null;
305
+ }
306
+ get edit() {
307
+ var _a;
308
+ return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('edit');
309
+ }
310
+ get focused() {
311
+ var _a;
312
+ return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('focus');
313
+ }
314
+ get selectedRange() {
315
+ var _a;
316
+ return (_a = this.focusedStore) === null || _a === void 0 ? void 0 : _a.entity.store.get('range');
317
+ }
318
+ registerSection(e) {
319
+ if (!e) {
320
+ this.sections.length = 0;
321
+ // some elements removed, rebuild stores
322
+ this.dirty = true;
323
+ return;
324
+ }
325
+ if (this.sections.indexOf(e) === -1) {
326
+ this.sections.push(e);
327
+ }
328
+ }
329
+ // check if require to cleanup all stores
330
+ beforeUpdate() {
331
+ if (this.dirty) {
332
+ for (let y in this.stores) {
333
+ for (let x in this.stores[y]) {
334
+ this.stores[y][x].dispose();
335
+ }
336
+ }
337
+ this.dirty = false;
338
+ }
339
+ }
340
+ registerColumn(x, type) {
341
+ // if hidden just create store but no operations needed
342
+ if (isHiddenStore(x)) {
343
+ return new SelectionStore();
344
+ }
345
+ if (this.columnStores[x]) {
346
+ return this.columnStores[x];
347
+ }
348
+ this.columnStores[x] = new SelectionStore();
349
+ // build cross-linking type to position
350
+ this.storesByType[type] = x;
351
+ this.storesXToType[x] = type;
352
+ return this.columnStores[x];
353
+ }
354
+ registerRow(y, type) {
355
+ // if hidden just create store
356
+ if (isHiddenStore(y)) {
357
+ return new SelectionStore();
358
+ }
359
+ if (this.rowStores[y]) {
360
+ return this.rowStores[y];
361
+ }
362
+ this.rowStores[y] = new SelectionStore();
363
+ // build cross linking type to position
364
+ this.storesByType[type] = y;
365
+ this.storesYToType[y] = type;
366
+ return this.rowStores[y];
367
+ }
368
+ /**
369
+ * Cross store proxy, based on multiple dimensions
370
+ */
371
+ register({ x, y }) {
372
+ var _a, _b;
373
+ // if hidden just create store
374
+ if (isHiddenStore(x) || isHiddenStore(y)) {
375
+ return new SelectionStore();
376
+ }
377
+ if (!this.stores[y]) {
378
+ this.stores[y] = {};
379
+ }
380
+ if (this.stores[y][x]) {
381
+ // Store already registered. Do not register twice
382
+ return this.stores[y][x];
383
+ }
384
+ this.stores[y][x] = new SelectionStore();
385
+ // proxy update, column store trigger only range area
386
+ (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.onChange('range', c => {
387
+ this.columnStores[x].setRangeArea(c);
388
+ this.rowStores[y].setRangeArea(c);
389
+ });
390
+ // clean up on remove
391
+ (_b = this.stores[y][x]) === null || _b === void 0 ? void 0 : _b.store.on('dispose', () => this.destroy(x, y));
392
+ return this.stores[y][x];
393
+ }
394
+ destroy(x, y) {
395
+ var _a, _b;
396
+ (_a = this.columnStores[x]) === null || _a === void 0 ? void 0 : _a.dispose();
397
+ (_b = this.rowStores[y]) === null || _b === void 0 ? void 0 : _b.dispose();
398
+ delete this.rowStores[y];
399
+ delete this.columnStores[x];
400
+ // clear x cross-link
401
+ if (this.storesXToType[x]) {
402
+ const type = this.storesXToType[x];
403
+ delete this.storesXToType[x];
404
+ delete this.storesByType[type];
405
+ }
406
+ // clear y cross-link
407
+ if (this.storesYToType[y]) {
408
+ const type = this.storesYToType[y];
409
+ delete this.storesYToType[y];
410
+ delete this.storesByType[type];
411
+ }
412
+ if (this.stores[y]) {
413
+ delete this.stores[y][x];
414
+ }
415
+ // clear empty rows
416
+ if (!Object.keys(this.stores[y] || {}).length) {
417
+ delete this.stores[y];
418
+ }
419
+ }
420
+ setEditByCell(storePos, editCell) {
421
+ this.focusByCell(storePos, editCell, editCell);
422
+ this.setEdit('');
423
+ }
424
+ /**
425
+ * Sets the next focus cell before the current one.
426
+ *
427
+ * @param focus - The cell to set as the next focus.
428
+ */
429
+ beforeNextFocusCell(focus) {
430
+ var _a;
431
+ // If there is no focused store, return early.
432
+ if (!this.focusedStore) {
433
+ return;
434
+ }
435
+ // Get the next store based on the current focus and the last cell.
436
+ const lastCell = this.focusedStore.entity.store.get('lastCell');
437
+ const next = lastCell && this.getNextStore(focus, this.focusedStore.position, lastCell);
438
+ // Set the next focus cell in the store.
439
+ (_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));
440
+ }
441
+ focusByCell(storePos, start, end) {
442
+ const store = this.stores[storePos.y][storePos.x];
443
+ this.focus(store, { focus: start, end });
444
+ }
445
+ focus(store, { focus, end }) {
446
+ const currentStorePointer = this.getCurrentStorePointer(store);
447
+ if (!currentStorePointer) {
448
+ return null;
449
+ }
450
+ // check for the focus in nearby store/viewport
451
+ const lastCell = store.store.get('lastCell');
452
+ const next = lastCell && this.getNextStore(focus, currentStorePointer, lastCell);
453
+ // if next store present - update
454
+ if (next === null || next === void 0 ? void 0 : next.store) {
455
+ const item = Object.assign(Object.assign({}, focus), next.item);
456
+ this.focus(next.store, { focus: item, end: item });
457
+ return null;
458
+ }
459
+ if (lastCell) {
460
+ focus = cropCellToMax(focus, lastCell);
461
+ end = cropCellToMax(end, lastCell);
462
+ }
463
+ store.setFocus(focus, end);
464
+ return focus;
465
+ }
466
+ /**
467
+ * Retrieves the current store pointer based on the active store.
468
+ * Clears focus from all stores except the active one.
469
+ */
470
+ getCurrentStorePointer(store) {
471
+ let currentStorePointer;
472
+ // Iterate through all stores
473
+ for (let y in this.stores) {
474
+ for (let x in this.stores[y]) {
475
+ const s = this.stores[y][x];
476
+ // Clear focus from stores other than the active one
477
+ if (s !== store) {
478
+ s.clearFocus();
479
+ }
480
+ else {
481
+ // Update the current store pointer with the active store coordinates
482
+ currentStorePointer = {
483
+ x: parseInt(x, 10),
484
+ y: parseInt(y, 10)
485
+ };
486
+ }
487
+ }
488
+ }
489
+ return currentStorePointer;
490
+ }
491
+ /**
492
+ * Retrieves the next store based on the focus cell and current store pointer.
493
+ * If the next store exists, returns an object with the next store and the item in the new store.
494
+ * If the next store does not exist, returns null.
495
+ */
496
+ getNextStore(focus, currentStorePointer, lastCell) {
497
+ // item in new store
498
+ const nextItem = nextCell(focus, lastCell);
499
+ let nextStore;
500
+ if (nextItem) {
501
+ Object.entries(nextItem).forEach(([type, nextItemCoord]) => {
502
+ let stores;
503
+ switch (type) {
504
+ case 'x':
505
+ // Get the X stores for the current Y coordinate of the current store pointer
506
+ stores = this.getXStores(currentStorePointer.y);
507
+ break;
508
+ case 'y':
509
+ // Get the Y stores for the current X coordinate of the current store pointer
510
+ stores = this.getYStores(currentStorePointer.x);
511
+ break;
512
+ }
513
+ // Get the next store based on the item in the new store
514
+ if (nextItemCoord >= 0) {
515
+ nextStore = stores[++currentStorePointer[type]];
516
+ }
517
+ else {
518
+ nextStore = stores[--currentStorePointer[type]];
519
+ const nextLastCell = nextStore === null || nextStore === void 0 ? void 0 : nextStore.store.get('lastCell');
520
+ if (nextLastCell) {
521
+ nextItem[type] = nextLastCell[type] + nextItemCoord;
522
+ }
523
+ }
524
+ });
525
+ }
526
+ return {
527
+ store: nextStore,
528
+ item: nextItem,
529
+ };
530
+ }
531
+ clearAll() {
532
+ var _a;
533
+ for (let y in this.stores) {
534
+ for (let x in this.stores[y]) {
535
+ (_a = this.stores[y][x]) === null || _a === void 0 ? void 0 : _a.clearFocus();
536
+ }
537
+ }
538
+ }
539
+ setEdit(val) {
540
+ if (!this.focusedStore) {
541
+ return;
542
+ }
543
+ this.focusedStore.entity.setEdit(val);
544
+ }
545
+ /**
546
+ * Select all cells across all stores
547
+ */
548
+ selectAll() {
549
+ for (let y in this.stores) {
550
+ for (let x in this.stores[y]) {
551
+ const store = this.stores[y][x];
552
+ if (!store) {
553
+ continue;
554
+ }
555
+ const lastCell = store.store.get('lastCell');
556
+ if (lastCell) {
557
+ store.setRange({ x: 0, y: 0 }, { x: lastCell.x - 1, y: lastCell.y - 1 });
558
+ }
559
+ }
560
+ }
561
+ }
562
+ getXStores(y) {
563
+ return this.stores[y];
564
+ }
565
+ getYStores(x) {
566
+ const stores = {};
567
+ for (let i in this.stores) {
568
+ stores[i] = this.stores[i][x];
569
+ }
570
+ return stores;
571
+ }
572
+ }
573
+
574
+ function isHiddenStore(pos) {
575
+ return pos === EMPTY_INDEX;
576
+ }
577
+ function nextCell(cell, lastCell) {
578
+ const nextItem = {};
579
+ let types = ['x', 'y'];
580
+ // previous item check
581
+ for (let t of types) {
582
+ if (cell[t] < 0) {
583
+ nextItem[t] = cell[t];
584
+ return nextItem;
585
+ }
586
+ }
587
+ // next item check
588
+ for (let t of types) {
589
+ if (cell[t] >= lastCell[t]) {
590
+ nextItem[t] = cell[t] - lastCell[t];
591
+ return nextItem;
592
+ }
593
+ }
594
+ return null;
595
+ }
596
+ function cropCellToMax(cell, lastCell) {
597
+ const croppedCell = Object.assign({}, cell);
598
+ const cellCoordinates = ['x', 'y'];
599
+ for (const coordinate of cellCoordinates) {
600
+ if (cell[coordinate] < 0) {
601
+ croppedCell[coordinate] = 0;
602
+ }
603
+ else if (cell[coordinate] >= lastCell[coordinate]) {
604
+ croppedCell[coordinate] = lastCell[coordinate] - 1;
605
+ }
606
+ }
607
+ return croppedCell;
608
+ }
609
+ function getRange(start, end) {
610
+ return start && end
611
+ ? {
612
+ x: Math.min(start.x, end.x),
613
+ y: Math.min(start.y, end.y),
614
+ x1: Math.max(start.x, end.x),
615
+ y1: Math.max(start.y, end.y),
616
+ }
617
+ : null;
618
+ }
619
+ function isRangeSingleCell(a) {
620
+ return a.x === a.x1 && a.y === a.y1;
621
+ }
622
+
623
+ function getCellData(val) {
624
+ if (typeof val === 'undefined' || val === null) {
625
+ return '';
626
+ }
627
+ return val;
628
+ }
629
+ function getCellDataParsed(model, column) {
630
+ const val = column.cellParser ? column.cellParser(model, column) : model[column.prop];
631
+ return getCellData(val);
632
+ }
633
+ /**
634
+ * Get column type from column data
635
+ */
636
+ function getColumnType(rgCol) {
637
+ if (rgCol.pin) {
638
+ return rgCol.pin;
639
+ }
640
+ return 'rgCol';
641
+ }
642
+ function getColumnSizes(cols) {
643
+ const res = {};
644
+ for (const [i, c] of cols.entries()) {
645
+ if (c.size) {
646
+ res[i] = c.size;
647
+ }
648
+ }
649
+ return res;
650
+ }
651
+ /**
652
+ * Check if column is grouping column
653
+ */
654
+ function isColGrouping(colData) {
655
+ return !!colData.children;
656
+ }
657
+ /**
658
+ * This function is used to create a collection of columns.
659
+ */
660
+ function getColumns(columns, level = 0, types) {
661
+ const collection = {
662
+ // columns as they are in stores per type
663
+ columns: {
664
+ rgCol: [],
665
+ colPinStart: [],
666
+ colPinEnd: [],
667
+ },
668
+ // columns indexed by prop for quick access
669
+ columnByProp: {},
670
+ // column grouping
671
+ columnGrouping: {
672
+ rgCol: [],
673
+ colPinStart: [],
674
+ colPinEnd: [],
675
+ },
676
+ // max depth level for column grouping
677
+ maxLevel: level,
678
+ // sorting
679
+ sort: {},
680
+ };
681
+ return reduce(columns, (res, colData) => {
682
+ // Grouped column
683
+ if (isColGrouping(colData)) {
684
+ return gatherGroup(res, colData, getColumns(colData.children, level + 1, types), level);
685
+ }
686
+ // Column type
687
+ const columnDefinitionFromType = colData.columnType && (types === null || types === void 0 ? void 0 : types[colData.columnType]);
688
+ // Regular column
689
+ const regularColumn = Object.assign(Object.assign({}, columnDefinitionFromType), colData);
690
+ // Regular column, no Pin
691
+ if (!regularColumn.pin) {
692
+ res.columns.rgCol.push(regularColumn);
693
+ // Pin
694
+ }
695
+ else {
696
+ res.columns[regularColumn.pin].push(regularColumn);
697
+ }
698
+ if (regularColumn.order) {
699
+ res.sort[regularColumn.prop] = regularColumn;
700
+ }
701
+ // it's possible that some columns have same prop, but better to avoid it
702
+ if (!res.columnByProp[regularColumn.prop]) {
703
+ res.columnByProp[regularColumn.prop] = [];
704
+ }
705
+ res.columnByProp[regularColumn.prop].push(regularColumn);
706
+ // trigger setup hook if present
707
+ regularColumn.beforeSetup && regularColumn.beforeSetup(regularColumn);
708
+ return res;
709
+ }, collection);
710
+ }
711
+ function gatherGroup(res, colData, collection, level = 0) {
712
+ // group template
713
+ const group = Object.assign(Object.assign({}, colData), { level, ids: [] });
714
+ // check columns for update
715
+ for (let k in collection.columns) {
716
+ const key = k;
717
+ const resultItem = res.columns[key];
718
+ const collectionItem = collection.columns[key];
719
+ // if column data
720
+ if (index.isArray(resultItem) && index.isArray(collectionItem)) {
721
+ // fill columns
722
+ resultItem.push(...collectionItem);
723
+ // fill grouping
724
+ if (collectionItem.length) {
725
+ res.columnGrouping[key].push(Object.assign(Object.assign({}, group), { ids: collectionItem.map(item => item.prop) }));
726
+ }
727
+ }
728
+ }
729
+ // merge column groupings
730
+ for (let k in collection.columnGrouping) {
731
+ const key = k;
732
+ const collectionItem = collection.columnGrouping[key];
733
+ res.columnGrouping[key].push(...collectionItem);
734
+ }
735
+ res.maxLevel = Math.max(res.maxLevel, collection.maxLevel);
736
+ res.sort = Object.assign(Object.assign({}, res.sort), collection.sort);
737
+ return res;
738
+ }
739
+ function findColumn(columns, prop) {
740
+ for (const c of columns) {
741
+ if (isColGrouping(c)) {
742
+ const found = findColumn(c.children, prop);
743
+ if (found) {
744
+ return found;
745
+ }
746
+ }
747
+ else if (c.prop === prop) {
748
+ return c;
749
+ }
750
+ }
751
+ return undefined;
752
+ }
753
+ function getColumnByProp(columns, prop) {
754
+ return findColumn(columns, prop);
755
+ }
756
+
757
+ const GROUP_DEPTH = `${index.GRID_INTERNALS}-depth`;
758
+ const PSEUDO_GROUP_ITEM = `${index.GRID_INTERNALS}-name`;
759
+ const PSEUDO_GROUP_ITEM_ID = `${index.GRID_INTERNALS}-id`;
760
+ const PSEUDO_GROUP_ITEM_VALUE = `${index.GRID_INTERNALS}-value`;
761
+ const PSEUDO_GROUP_COLUMN = `${index.GRID_INTERNALS}-column`;
762
+ const GROUP_EXPANDED = `${index.GRID_INTERNALS}-expanded`;
763
+ const GROUP_ORIGINAL_INDEX = `${index.GRID_INTERNALS}-original-index`;
764
+ const GROUP_EXPAND_BTN = `group-expand`;
765
+ const GROUP_EXPAND_EVENT = `groupexpandclick`;
766
+ const GROUPING_ROW_TYPE = 'rgRow';
767
+
768
+ function getGroupValueDefault(item, prop) {
769
+ return item[prop] || null;
770
+ }
771
+ /**
772
+ * Gather data for grouping
773
+ * @param array - flat data array
774
+ * @param groupIds - ids of groups
775
+ * @param expanded - potentially expanded items if present
776
+ */
777
+ function gatherGrouping(array, groupIds, { prevExpanded, expandedAll, getGroupValue = getGroupValueDefault, }) {
778
+ const groupedItems = new Map();
779
+ array.forEach((item, originalIndex) => {
780
+ const groupLevelValues = groupIds.map(groupId => getGroupValue(item, groupId));
781
+ const lastLevelValue = groupLevelValues.pop();
782
+ let currentGroupLevel = groupedItems;
783
+ groupLevelValues.forEach(value => {
784
+ if (!currentGroupLevel.has(value)) {
785
+ currentGroupLevel.set(value, new Map());
786
+ }
787
+ currentGroupLevel = currentGroupLevel.get(value);
788
+ });
789
+ if (!currentGroupLevel.has(lastLevelValue)) {
790
+ currentGroupLevel.set(lastLevelValue, []);
791
+ }
792
+ const lastLevelItems = currentGroupLevel.get(lastLevelValue);
793
+ lastLevelItems.push(Object.assign(Object.assign({}, item), { [GROUP_ORIGINAL_INDEX]: originalIndex }));
794
+ });
795
+ let itemIndex = -1;
796
+ const groupingDepth = groupIds.length;
797
+ // collapse all groups in the beginning
798
+ const trimmed = {};
799
+ // index mapping
800
+ const oldNewIndexMap = {};
801
+ // check if group header exists
802
+ const pseudoGroupTest = {};
803
+ const sourceWithGroups = [];
804
+ function flattenGroupMaps(groupedValues, parentIds, isExpanded) {
805
+ const depth = parentIds.length;
806
+ groupedValues.forEach((innerGroupedValues, groupId) => {
807
+ const levelIds = [...parentIds, groupId];
808
+ const mergedIds = levelIds.join(',');
809
+ const isGroupExpanded = isExpanded && (!!expandedAll || !!(prevExpanded === null || prevExpanded === void 0 ? void 0 : prevExpanded[mergedIds]));
810
+ sourceWithGroups.push({
811
+ [PSEUDO_GROUP_ITEM]: groupId,
812
+ [GROUP_DEPTH]: depth,
813
+ [PSEUDO_GROUP_ITEM_ID]: JSON.stringify(levelIds),
814
+ [PSEUDO_GROUP_ITEM_VALUE]: mergedIds,
815
+ [GROUP_EXPANDED]: isGroupExpanded,
816
+ });
817
+ itemIndex += 1;
818
+ if (!isGroupExpanded && depth) {
819
+ trimmed[itemIndex] = true;
820
+ }
821
+ if (Array.isArray(innerGroupedValues)) {
822
+ innerGroupedValues.forEach(value => {
823
+ itemIndex += 1;
824
+ if (!isGroupExpanded) {
825
+ trimmed[itemIndex] = true;
826
+ }
827
+ oldNewIndexMap[value[GROUP_ORIGINAL_INDEX]] = itemIndex;
828
+ const pseudoGroupTestIds = levelIds.map((_value, index) => levelIds.slice(0, index + 1).join(','));
829
+ pseudoGroupTestIds.forEach(pseudoGroupTestId => {
830
+ if (!pseudoGroupTest[pseudoGroupTestId]) {
831
+ pseudoGroupTest[pseudoGroupTestId] = [];
832
+ }
833
+ pseudoGroupTest[pseudoGroupTestId].push(itemIndex);
834
+ });
835
+ });
836
+ sourceWithGroups.push(...innerGroupedValues);
837
+ }
838
+ else {
839
+ flattenGroupMaps(innerGroupedValues, levelIds, isGroupExpanded);
840
+ }
841
+ });
842
+ }
843
+ flattenGroupMaps(groupedItems, [], true);
844
+ return {
845
+ sourceWithGroups, // updates source mirror
846
+ depth: groupingDepth, // largest depth for grouping
847
+ trimmed, // used for expand/collapse grouping values
848
+ oldNewIndexMap, // used for mapping old values to new
849
+ childrenByGroup: pseudoGroupTest, // used to get child items in group
850
+ };
851
+ }
852
+ function getGroupingName(rgRow) {
853
+ return rgRow && rgRow[PSEUDO_GROUP_ITEM];
854
+ }
855
+ function isGrouping(rgRow) {
856
+ return typeof (rgRow === null || rgRow === void 0 ? void 0 : rgRow[PSEUDO_GROUP_ITEM]) !== 'undefined';
857
+ }
858
+ function isGroupingColumn(column) {
859
+ return column && typeof column[PSEUDO_GROUP_COLUMN] !== 'undefined';
860
+ }
861
+ function measureEqualDepth(groupA, groupB) {
862
+ const ln = groupA.length;
863
+ let i = 0;
864
+ for (; i < ln; i++) {
865
+ if (groupA[i] !== groupB[i]) {
866
+ return i;
867
+ }
868
+ }
869
+ return i;
870
+ }
871
+ function getParsedGroup(id) {
872
+ const parseGroup = JSON.parse(id);
873
+ // extra precaution and type safeguard
874
+ if (!Array.isArray(parseGroup)) {
875
+ return null;
876
+ }
877
+ return parseGroup;
878
+ }
879
+ // check if items is child of current clicked group
880
+ function isSameGroup(currentGroup, currentModel, nextModel) {
881
+ const nextGroup = getParsedGroup(nextModel[PSEUDO_GROUP_ITEM_ID]);
882
+ if (!nextGroup) {
883
+ return false;
884
+ }
885
+ const depth = measureEqualDepth(currentGroup, nextGroup);
886
+ return currentModel[GROUP_DEPTH] < depth;
887
+ }
888
+
889
+ /**
890
+ * The base implementation of `_.slice` without an iteratee call guard.
891
+ *
892
+ * @private
893
+ * @param {Array} array The array to slice.
894
+ * @param {number} [start=0] The start position.
895
+ * @param {number} [end=array.length] The end position.
896
+ * @returns {Array} Returns the slice of `array`.
897
+ */
898
+ function baseSlice(array, start, end) {
899
+ var index = -1,
900
+ length = array.length;
901
+
902
+ if (start < 0) {
903
+ start = -start > length ? 0 : (length + start);
904
+ }
905
+ end = end > length ? length : end;
906
+ if (end < 0) {
907
+ end += length;
908
+ }
909
+ length = start > end ? 0 : ((end - start) >>> 0);
910
+ start >>>= 0;
911
+
912
+ var result = Array(length);
913
+ while (++index < length) {
914
+ result[index] = array[index + start];
915
+ }
916
+ return result;
917
+ }
918
+
919
+ /**
920
+ * Creates a slice of `array` from `start` up to, but not including, `end`.
921
+ *
922
+ * **Note:** This method is used instead of
923
+ * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
924
+ * returned.
925
+ *
926
+ * @static
927
+ * @memberOf _
928
+ * @since 3.0.0
929
+ * @category Array
930
+ * @param {Array} array The array to slice.
931
+ * @param {number} [start=0] The start position.
932
+ * @param {number} [end=array.length] The end position.
933
+ * @returns {Array} Returns the slice of `array`.
934
+ */
935
+ function slice(array, start, end) {
936
+ var length = array == null ? 0 : array.length;
937
+ if (!length) {
938
+ return [];
939
+ }
940
+ if (end && typeof end != 'number' && index.isIterateeCall(array, start, end)) {
941
+ start = 0;
942
+ end = length;
943
+ }
944
+ else {
945
+ start = start == null ? 0 : index.toInteger(start);
946
+ end = end === undefined ? length : index.toInteger(end);
947
+ }
948
+ return baseSlice(array, start, end);
949
+ }
950
+
951
+ class ColumnService {
952
+ get columns() {
953
+ return index.getVisibleSourceItem(this.source);
954
+ }
955
+ constructor(dataStore, source) {
956
+ this.dataStore = dataStore;
957
+ this.source = source;
958
+ this.unsubscribe = [];
959
+ this.hasGrouping = false;
960
+ this.unsubscribe.push(source.onChange('source', s => this.checkGrouping(s)));
961
+ this.checkGrouping(source.get('source'));
962
+ this.type = source.get('type');
963
+ }
964
+ checkGrouping(cols) {
965
+ for (let rgCol of cols) {
966
+ if (isGroupingColumn(rgCol)) {
967
+ this.hasGrouping = true;
968
+ return;
969
+ }
970
+ this.hasGrouping = false;
971
+ }
972
+ }
973
+ isReadOnly(r, c) {
974
+ var _a;
975
+ const readOnly = (_a = this.columns[c]) === null || _a === void 0 ? void 0 : _a.readonly;
976
+ if (typeof readOnly === 'function') {
977
+ const data = this.rowDataModel(r, c);
978
+ return readOnly(data);
979
+ }
980
+ return !!readOnly;
981
+ }
982
+ mergeProperties(r, c, defaultProps, model, extraPropsFunc) {
983
+ const props = Object.assign({}, defaultProps);
984
+ props.class = Object.assign(Object.assign({}, (typeof props.class === 'string'
985
+ ? { [props.class]: true }
986
+ : props.class)), { [index.CELL_CLASS]: true, [index.DISABLED_CLASS]: this.isReadOnly(r, c) });
987
+ const extra = extraPropsFunc === null || extraPropsFunc === void 0 ? void 0 : extraPropsFunc(model);
988
+ if (!extra) {
989
+ return props;
990
+ }
991
+ return doPropMerge(props, extra);
992
+ }
993
+ getRowClass(r, prop) {
994
+ const model = index.getSourceItem(this.dataStore, r) || {};
995
+ return model[prop] || '';
996
+ }
997
+ getCellData(r, c) {
998
+ const data = this.rowDataModel(r, c);
999
+ return getCellData(data.model[data.prop]);
1000
+ }
1001
+ getSaveData(rowIndex, colIndex, val) {
1002
+ const data = this.rowDataModel(rowIndex, colIndex);
1003
+ if (typeof val === 'undefined') {
1004
+ val = getCellData(data.model[data.prop]);
1005
+ }
1006
+ return {
1007
+ prop: data.prop,
1008
+ rowIndex,
1009
+ colIndex,
1010
+ val,
1011
+ model: data.model,
1012
+ colType: this.type,
1013
+ type: this.dataStore.get('type'),
1014
+ };
1015
+ }
1016
+ getCellEditor(_r, c, editors) {
1017
+ var _a;
1018
+ const editor = (_a = this.columns[c]) === null || _a === void 0 ? void 0 : _a.editor;
1019
+ if (!editor) {
1020
+ return undefined;
1021
+ }
1022
+ // reference
1023
+ if (typeof editor === 'string') {
1024
+ return editors[editor];
1025
+ }
1026
+ return editor;
1027
+ }
1028
+ /**
1029
+ * Get cell data model for given rowIndex and colIndex
1030
+ * Used to pass data to editor/renderer
1031
+ */
1032
+ rowDataModel(rowIndex, colIndex) {
1033
+ const column = this.columns[colIndex];
1034
+ const prop = column === null || column === void 0 ? void 0 : column.prop;
1035
+ const model = index.getSourceItem(this.dataStore, rowIndex) || {};
1036
+ const value = model[prop];
1037
+ const type = this.dataStore.get('type');
1038
+ return {
1039
+ prop,
1040
+ model,
1041
+ data: this.dataStore.get('source'),
1042
+ column,
1043
+ rowIndex,
1044
+ colIndex,
1045
+ colType: this.type,
1046
+ type,
1047
+ value,
1048
+ };
1049
+ }
1050
+ getRangeData(d, columns) {
1051
+ var _a;
1052
+ const changed = {};
1053
+ // get original length sizes
1054
+ const copyColLength = d.oldRange.x1 - d.oldRange.x + 1;
1055
+ const copyRowLength = d.oldRange.y1 - d.oldRange.y + 1;
1056
+ const mapping = {};
1057
+ // rows
1058
+ for (let rowIndex = d.newRange.y, i = 0; rowIndex < d.newRange.y1 + 1; rowIndex++, i++) {
1059
+ // copy original data link
1060
+ const oldRowIndex = d.oldRange.y + (i % copyRowLength);
1061
+ const copyRow = index.getSourceItem(this.dataStore, oldRowIndex) || {};
1062
+ // columns
1063
+ for (let colIndex = d.newRange.x, j = 0; colIndex < d.newRange.x1 + 1; colIndex++, j++) {
1064
+ // check if old range area
1065
+ if (rowIndex >= d.oldRange.y &&
1066
+ rowIndex <= d.oldRange.y1 &&
1067
+ colIndex >= d.oldRange.x &&
1068
+ colIndex <= d.oldRange.x1) {
1069
+ continue;
1070
+ }
1071
+ // requested column beyond range
1072
+ if (!this.columns[colIndex]) {
1073
+ continue;
1074
+ }
1075
+ const prop = (_a = this.columns[colIndex]) === null || _a === void 0 ? void 0 : _a.prop;
1076
+ const copyColIndex = d.oldRange.x + (j % copyColLength);
1077
+ const copyColumnProp = columns[copyColIndex].prop;
1078
+ /** if can write */
1079
+ if (!this.isReadOnly(rowIndex, colIndex)) {
1080
+ /** to show before save */
1081
+ if (!changed[rowIndex]) {
1082
+ changed[rowIndex] = {};
1083
+ }
1084
+ changed[rowIndex][prop] = copyRow[copyColumnProp];
1085
+ /** Generate mapping object */
1086
+ if (!mapping[rowIndex]) {
1087
+ mapping[rowIndex] = {};
1088
+ }
1089
+ mapping[rowIndex][prop] = {
1090
+ colIndex: copyColIndex,
1091
+ colProp: copyColumnProp,
1092
+ rowIndex: oldRowIndex,
1093
+ };
1094
+ }
1095
+ }
1096
+ }
1097
+ return {
1098
+ changed,
1099
+ mapping,
1100
+ };
1101
+ }
1102
+ getTransformedDataToApply(start, data) {
1103
+ const changed = {};
1104
+ const copyRowLength = data.length;
1105
+ const colLength = this.columns.length;
1106
+ const rowLength = this.dataStore.get('items').length;
1107
+ // rows
1108
+ let rowIndex = start.y;
1109
+ let maxCol = 0;
1110
+ for (let i = 0; rowIndex < rowLength && i < copyRowLength; rowIndex++, i++) {
1111
+ // copy original data link
1112
+ const copyRow = data[i % copyRowLength];
1113
+ const copyColLength = (copyRow === null || copyRow === void 0 ? void 0 : copyRow.length) || 0;
1114
+ // columns
1115
+ let colIndex = start.x;
1116
+ for (let j = 0; colIndex < colLength && j < copyColLength; colIndex++, j++) {
1117
+ const p = this.columns[colIndex].prop;
1118
+ const currentCol = j % colLength;
1119
+ /** if can write */
1120
+ if (!this.isReadOnly(rowIndex, colIndex)) {
1121
+ /** to show before save */
1122
+ if (!changed[rowIndex]) {
1123
+ changed[rowIndex] = {};
1124
+ }
1125
+ changed[rowIndex][p] = copyRow[currentCol];
1126
+ }
1127
+ }
1128
+ maxCol = Math.max(maxCol, colIndex - 1);
1129
+ }
1130
+ const range = getRange(start, {
1131
+ y: rowIndex - 1,
1132
+ x: maxCol,
1133
+ });
1134
+ return {
1135
+ changed,
1136
+ range,
1137
+ };
1138
+ }
1139
+ getRangeStaticData(d, value) {
1140
+ const changed = {};
1141
+ // rows
1142
+ for (let rowIndex = d.y, i = 0; rowIndex < d.y1 + 1; rowIndex++, i++) {
1143
+ // columns
1144
+ for (let colIndex = d.x, j = 0; colIndex < d.x1 + 1; colIndex++, j++) {
1145
+ // requested column beyond range
1146
+ if (!this.columns[colIndex]) {
1147
+ continue;
1148
+ }
1149
+ const p = this.columns[colIndex].prop;
1150
+ /** if can write */
1151
+ if (!this.isReadOnly(rowIndex, colIndex)) {
1152
+ /** to show before save */
1153
+ if (!changed[rowIndex]) {
1154
+ changed[rowIndex] = {};
1155
+ }
1156
+ changed[rowIndex][p] = value;
1157
+ }
1158
+ }
1159
+ }
1160
+ return changed;
1161
+ }
1162
+ getRangeTransformedToProps(d, store) {
1163
+ var _a;
1164
+ const area = [];
1165
+ const type = this.dataStore.get('type');
1166
+ // rows
1167
+ for (let rowIndex = d.y, i = 0; rowIndex < d.y1 + 1; rowIndex++, i++) {
1168
+ // columns
1169
+ for (let colIndex = d.x, j = 0; colIndex < d.x1 + 1; colIndex++, j++) {
1170
+ const prop = (_a = this.columns[colIndex]) === null || _a === void 0 ? void 0 : _a.prop;
1171
+ area.push({
1172
+ prop,
1173
+ rowIndex,
1174
+ colIndex,
1175
+ model: index.getSourceItem(store, rowIndex),
1176
+ type,
1177
+ colType: this.type,
1178
+ });
1179
+ }
1180
+ }
1181
+ return area;
1182
+ }
1183
+ copyRangeArray(range, store) {
1184
+ const cols = [...this.columns];
1185
+ const props = slice(cols, range.x, range.x1 + 1).map(v => v.prop);
1186
+ const toCopy = [];
1187
+ const mapping = {};
1188
+ // rows indexes
1189
+ for (let i = range.y; i <= range.y1; i++) {
1190
+ const rgRow = [];
1191
+ mapping[i] = {};
1192
+ // columns indexes
1193
+ for (let prop of props) {
1194
+ const item = index.getSourceItem(store, i);
1195
+ // if no item - skip
1196
+ if (!item) {
1197
+ continue;
1198
+ }
1199
+ const val = item[prop];
1200
+ rgRow.push(val);
1201
+ mapping[i][prop] = val;
1202
+ }
1203
+ toCopy.push(rgRow);
1204
+ }
1205
+ return {
1206
+ data: toCopy,
1207
+ mapping,
1208
+ };
1209
+ }
1210
+ destroy() {
1211
+ this.unsubscribe.forEach(f => f());
1212
+ }
1213
+ }
1214
+ /**
1215
+ * Checks if the given rowDrag is a service for dragging rows.
1216
+ */
1217
+ function isRowDragService(rowDrag, model) {
1218
+ if (typeof rowDrag === 'function') {
1219
+ return rowDrag(model);
1220
+ }
1221
+ return !!rowDrag;
1222
+ }
1223
+ function mergeClasses(class1 = {}, class2 = {}) {
1224
+ if (typeof class1 === 'string') {
1225
+ class1 = { [class1]: true };
1226
+ }
1227
+ if (typeof class2 === 'string') {
1228
+ class2 = { [class2]: true };
1229
+ }
1230
+ return Object.assign(Object.assign({}, class1), class2);
1231
+ }
1232
+ function doPropMerge(existing, extra) {
1233
+ // if className is provided - remove it from props it messing with stencil
1234
+ if (extra.className) {
1235
+ extra.class = mergeClasses(extra.class, extra.className);
1236
+ delete extra.className;
1237
+ }
1238
+ let props = Object.assign(Object.assign({}, extra), existing);
1239
+ // extend existing props
1240
+ if (extra.class) {
1241
+ props.class = mergeClasses(props.class, extra.class);
1242
+ }
1243
+ if (extra.style) {
1244
+ props.style = Object.assign(Object.assign({}, extra.style), props.style);
1245
+ }
1246
+ return props;
1247
+ }
1248
+
1249
+ exports.ColumnService = ColumnService;
1250
+ exports.EMPTY_INDEX = EMPTY_INDEX;
1251
+ exports.GROUPING_ROW_TYPE = GROUPING_ROW_TYPE;
1252
+ exports.GROUP_DEPTH = GROUP_DEPTH;
1253
+ exports.GROUP_EXPANDED = GROUP_EXPANDED;
1254
+ exports.GROUP_EXPAND_BTN = GROUP_EXPAND_BTN;
1255
+ exports.GROUP_EXPAND_EVENT = GROUP_EXPAND_EVENT;
1256
+ exports.PSEUDO_GROUP_COLUMN = PSEUDO_GROUP_COLUMN;
1257
+ exports.PSEUDO_GROUP_ITEM = PSEUDO_GROUP_ITEM;
1258
+ exports.PSEUDO_GROUP_ITEM_ID = PSEUDO_GROUP_ITEM_ID;
1259
+ exports.PSEUDO_GROUP_ITEM_VALUE = PSEUDO_GROUP_ITEM_VALUE;
1260
+ exports.SelectionStore = SelectionStore;
1261
+ exports.SelectionStoreConnector = SelectionStoreConnector;
1262
+ exports.baseEach = baseEach$1;
1263
+ exports.cropCellToMax = cropCellToMax;
1264
+ exports.doPropMerge = doPropMerge;
1265
+ exports.gatherGroup = gatherGroup;
1266
+ exports.gatherGrouping = gatherGrouping;
1267
+ exports.getCellData = getCellData;
1268
+ exports.getCellDataParsed = getCellDataParsed;
1269
+ exports.getColumnByProp = getColumnByProp;
1270
+ exports.getColumnSizes = getColumnSizes;
1271
+ exports.getColumnType = getColumnType;
1272
+ exports.getColumns = getColumns;
1273
+ exports.getGroupingName = getGroupingName;
1274
+ exports.getParsedGroup = getParsedGroup;
1275
+ exports.getRange = getRange;
1276
+ exports.isColGrouping = isColGrouping;
1277
+ exports.isGrouping = isGrouping;
1278
+ exports.isGroupingColumn = isGroupingColumn;
1279
+ exports.isHiddenStore = isHiddenStore;
1280
+ exports.isRangeSingleCell = isRangeSingleCell;
1281
+ exports.isRowDragService = isRowDragService;
1282
+ exports.isSameGroup = isSameGroup;
1283
+ exports.nextCell = nextCell;
1284
+ exports.reduce = reduce;
1285
+
1286
+ //# sourceMappingURL=column.service-2670e6e7.js.map