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