@refinitiv-ui/efx-grid 6.0.41 → 6.0.42
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/core/dist/core.js +837 -871
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.d.ts +4 -0
- package/lib/core/es6/grid/Core.js +67 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +3 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +26 -26
- package/lib/core/es6/grid/util/util.js +25 -9
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +212 -44
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +22 -0
- package/lib/rt-grid/es6/Grid.js +91 -4
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +4 -0
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +34 -19
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +9 -3
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +290 -364
- package/lib/tr-grid-util/es6/DateTime.js +3 -3
- package/lib/tr-grid-util/es6/GridPlugin.js +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +4 -0
- package/lib/types/es6/ColumnStack.d.ts +9 -3
- package/lib/types/es6/Core/grid/Core.d.ts +4 -0
- package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +3 -2
- package/lib/versions.json +3 -3
- package/package.json +1 -1
package/lib/core/dist/core.js
CHANGED
@@ -1,644 +1,6 @@
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
2
2
|
/******/ "use strict";
|
3
|
-
/******/ var __webpack_modules__ = ({
|
4
|
-
|
5
|
-
/***/ 869:
|
6
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
7
|
-
|
8
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
9
|
-
/* harmony export */ "Qr": () => (/* binding */ isEmptyObject),
|
10
|
-
/* harmony export */ "kI": () => (/* binding */ cloneObject)
|
11
|
-
/* harmony export */ });
|
12
|
-
/* unused harmony exports Util, extendObject, deepEqual, arrayToObject, extendProperty, extendArrayProperty, parseCondition, prettifyCss, getShadowRoot, injectCss, isIE, isMac, isTouchDevice, nestedObjectToArray, rgb2Hex, prepareTSVContent */
|
13
|
-
/** @namespace */
|
14
|
-
var Util = {};
|
15
|
-
|
16
|
-
/** This is a shorthand for fetch() API by POST method and with json body <br>
|
17
|
-
* WARNING: fetch is not supported in IE (including IE11)
|
18
|
-
* @public
|
19
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch}
|
20
|
-
* @function
|
21
|
-
* @param {string} url
|
22
|
-
* @param {Object|string} obj
|
23
|
-
* @return {!Promise<Response>}
|
24
|
-
*/
|
25
|
-
Util.post = function(url, obj) { // Not supported in IE
|
26
|
-
return Util._post(url, obj).then(Util.toJSON);
|
27
|
-
};
|
28
|
-
/** Request a server response from server as text by POST method <br>
|
29
|
-
* WARNING: fetch is not supported in IE (including IE11)
|
30
|
-
* @public
|
31
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch}
|
32
|
-
* @function
|
33
|
-
* @param {string} url
|
34
|
-
* @param {Object|string} obj
|
35
|
-
* @return {!Promise<Response>}
|
36
|
-
*/
|
37
|
-
Util.requestText = function(url, obj) { // Not supported in IE
|
38
|
-
return Util._post(url, obj, "text/plain").then(Util.toText);
|
39
|
-
};
|
40
|
-
/** Request a server response from server by POST method and with url-encoded body <br>
|
41
|
-
* WARNING: fetch is not supported in IE (including IE11)
|
42
|
-
* @public
|
43
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch}
|
44
|
-
* @function
|
45
|
-
* @param {string} url
|
46
|
-
* @param {string} obj
|
47
|
-
* @return {!Promise<Response>}
|
48
|
-
*/
|
49
|
-
Util.requestByUrlEncoded = function(url, obj) { // Not supported in IE
|
50
|
-
return Util._post(url, obj, "application/x-www-form-urlencoded").then(Util.toJSON);
|
51
|
-
};
|
52
|
-
|
53
|
-
/** @public
|
54
|
-
* @function
|
55
|
-
* @param {Response} resp
|
56
|
-
* @return {!Promise<Object>}
|
57
|
-
*/
|
58
|
-
Util.toJSON = function (resp) {
|
59
|
-
if(Util._logError(resp)) {
|
60
|
-
return Promise.reject(resp);
|
61
|
-
}
|
62
|
-
return resp.json();
|
63
|
-
};
|
64
|
-
/** @public
|
65
|
-
* @function
|
66
|
-
* @param {Response} resp
|
67
|
-
* @return {!Promise<string>}
|
68
|
-
*/
|
69
|
-
Util.toText = function (resp) {
|
70
|
-
if(Util._logError(resp)) {
|
71
|
-
return Promise.reject(resp);
|
72
|
-
}
|
73
|
-
return resp.text();
|
74
|
-
};
|
75
|
-
|
76
|
-
/** @private
|
77
|
-
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
|
78
|
-
* @function
|
79
|
-
* @param {Response} resp
|
80
|
-
* @return {boolean}
|
81
|
-
*/
|
82
|
-
Util._logError = function(resp) {
|
83
|
-
if(resp && resp.status >= 300) {
|
84
|
-
console.log("Response " + resp.status + ": " + resp.statusText);
|
85
|
-
return true;
|
86
|
-
}
|
87
|
-
return false;
|
88
|
-
};
|
89
|
-
/** @private
|
90
|
-
* @function
|
91
|
-
* @param {string} url
|
92
|
-
* @param {Object|string} obj
|
93
|
-
* @param {string=} contentType
|
94
|
-
* @return {!Promise<Response>}
|
95
|
-
*/
|
96
|
-
Util._post = function(url, obj, contentType) {
|
97
|
-
var options = {
|
98
|
-
method: obj ? "POST" : "GET",
|
99
|
-
headers: { "Content-Type": contentType || "application/json" }
|
100
|
-
};
|
101
|
-
if(obj) {
|
102
|
-
options.body = typeof obj === "string" ? obj : JSON.stringify(obj);
|
103
|
-
}
|
104
|
-
|
105
|
-
return fetch(url, options);
|
106
|
-
};
|
107
|
-
|
108
|
-
/** WARNING: Only one level of property tree is affected (i.e. no recursive or nested operation). <br>
|
109
|
-
* Property with undefined or null value will not have an impact on the object. <br>
|
110
|
-
* Existing properties will be overridden.
|
111
|
-
* @public
|
112
|
-
* @function
|
113
|
-
* @param {Object} obj Object that is extended (new properties will be added to this object)
|
114
|
-
* @param {Object=} extender Master object (no modification will be made on the extender)
|
115
|
-
* @param {Array.<string>=} limiters Specify property to be extended
|
116
|
-
* @return {Object}
|
117
|
-
*/
|
118
|
-
var extendObject = function (obj, extender, limiters) {
|
119
|
-
if(!obj) { // null undefined NaN empty string and 0
|
120
|
-
return null;
|
121
|
-
}
|
122
|
-
if(!extender || obj === extender) {
|
123
|
-
return obj;
|
124
|
-
}
|
125
|
-
|
126
|
-
var key;
|
127
|
-
if(limiters) {
|
128
|
-
var len = limiters.length;
|
129
|
-
for(var i = 0; i < len; ++i) {
|
130
|
-
key = limiters[i];
|
131
|
-
if(key) {
|
132
|
-
extendProperty(obj, extender, key);
|
133
|
-
}
|
134
|
-
}
|
135
|
-
} else {
|
136
|
-
for(key in extender) {
|
137
|
-
extendProperty(obj, extender, key);
|
138
|
-
}
|
139
|
-
}
|
140
|
-
return obj;
|
141
|
-
};
|
142
|
-
/** WARNING: Only one level of property tree is affected (i.e. no recursive or nested operation). <br>
|
143
|
-
* Property with undefined or null value will not be cloned.
|
144
|
-
* @public
|
145
|
-
* @function
|
146
|
-
* @param {Object} obj
|
147
|
-
* @param {Array.<string>=} limiters
|
148
|
-
* @return {Object}
|
149
|
-
*/
|
150
|
-
var cloneObject = function (obj, limiters) {
|
151
|
-
return extendObject({}, obj, limiters);
|
152
|
-
};
|
153
|
-
|
154
|
-
/** Check empty object
|
155
|
-
* @public
|
156
|
-
* @function
|
157
|
-
* @param {Object} obj
|
158
|
-
* @return {boolean}=true, if the obj is empty
|
159
|
-
*/
|
160
|
-
var isEmptyObject = function (obj) {
|
161
|
-
for (var key in obj) {
|
162
|
-
return false;
|
163
|
-
}
|
164
|
-
return true;
|
165
|
-
};
|
166
|
-
|
167
|
-
/** @public
|
168
|
-
* @param {Array=} data
|
169
|
-
* @param {Array.<string>=} fields In case of the given data is an array, this param will be used for mapping index to field
|
170
|
-
* @return {Object|null}
|
171
|
-
*/
|
172
|
-
var arrayToObject = function(data, fields) {
|
173
|
-
if(!Array.isArray(data)) {
|
174
|
-
return data;
|
175
|
-
} else if(!fields) {
|
176
|
-
return null;
|
177
|
-
}
|
178
|
-
var ary = data;
|
179
|
-
data = {};
|
180
|
-
var len = ary.length;
|
181
|
-
for(var i = 0; i < len; ++i) {
|
182
|
-
var field = fields[i];
|
183
|
-
// eslint-disable-next-line no-undefined
|
184
|
-
if(field && ary[i] !== undefined) {
|
185
|
-
data[field] = ary[i];
|
186
|
-
}
|
187
|
-
}
|
188
|
-
return data;
|
189
|
-
};
|
190
|
-
/** Replace the specified property with the value from the extender. If the value is an array, the value will be added to the array instead of replacement
|
191
|
-
* @public
|
192
|
-
* @function
|
193
|
-
* @param {Object} obj
|
194
|
-
* @param {Object} extender
|
195
|
-
* @param {string} propName
|
196
|
-
* @example
|
197
|
-
* extendProperty({a: 0}, {a: 1}, "a"); // {a: 1}
|
198
|
-
* extendProperty({a: 0}, {b: 1}, "b"); // {a: 0, b: 1}
|
199
|
-
* extendProperty({a: [0]}, {a: 1}, "a"); // {a: [0, 1]}
|
200
|
-
* extendProperty({a: [0]}, {a: [1, 2]}, "a"); // {a: [0, 1, 2]}
|
201
|
-
*/
|
202
|
-
var extendProperty = function (obj, extender, propName) {
|
203
|
-
var val = extender[propName];
|
204
|
-
if(val != null) {
|
205
|
-
var objVal = obj[propName];
|
206
|
-
if(Array.isArray(objVal)) {
|
207
|
-
obj[propName] = objVal.concat(val);
|
208
|
-
} else if(Array.isArray(val) && objVal) {
|
209
|
-
obj[propName] = val.concat(objVal); // TODO: Preserve the order
|
210
|
-
} else {
|
211
|
-
obj[propName] = val; // WARNING: Overriding existing data
|
212
|
-
}
|
213
|
-
}
|
214
|
-
};
|
215
|
-
|
216
|
-
|
217
|
-
/** Compare the values of obj1 and obj2. if they are the same object or have the same value, the result will be true. Otherwise, it will return false.
|
218
|
-
* @public
|
219
|
-
* @param {*} obj1
|
220
|
-
* @param {*} obj2
|
221
|
-
* @return {boolean}
|
222
|
-
*/
|
223
|
-
var deepEqual = function (obj1, obj2) {
|
224
|
-
|
225
|
-
if(obj1 === obj2) {
|
226
|
-
return true;
|
227
|
-
}
|
228
|
-
|
229
|
-
if (typeof obj1 !== typeof obj2) {
|
230
|
-
return false;
|
231
|
-
}
|
232
|
-
|
233
|
-
if (typeof obj1 === "object") {
|
234
|
-
|
235
|
-
// We need to split array and object for performance reason
|
236
|
-
if(Array.isArray(obj1)) {
|
237
|
-
if(obj1.length !== obj2.length) {
|
238
|
-
return false;
|
239
|
-
}
|
240
|
-
|
241
|
-
for (var i = 0; i < obj1.length; i++) {
|
242
|
-
if (!deepEqual(obj1[i], obj2[i])) { // The array may not be a match if the elements are not sorted, so it will not be considered equal if there is a mismatch.
|
243
|
-
return false;
|
244
|
-
}
|
245
|
-
}
|
246
|
-
|
247
|
-
} else {
|
248
|
-
|
249
|
-
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
|
250
|
-
return false;
|
251
|
-
}
|
252
|
-
|
253
|
-
for (var key in obj1) {
|
254
|
-
if (!deepEqual(obj1[key], obj2[key])) {
|
255
|
-
return false;
|
256
|
-
}
|
257
|
-
}
|
258
|
-
}
|
259
|
-
|
260
|
-
|
261
|
-
return true;
|
262
|
-
}
|
263
|
-
|
264
|
-
return false;
|
265
|
-
|
266
|
-
};
|
267
|
-
/** Array.push() is much faster than Array.concat(). The downside is the parameters must be an array, whereas concat() has no such requirement. <br>
|
268
|
-
* This method excels in extending known array property in an object.
|
269
|
-
* @public
|
270
|
-
* @function
|
271
|
-
* @param {Object} obj
|
272
|
-
* @param {string} propName
|
273
|
-
* @param {*} ary
|
274
|
-
* @return {Array} Returns the result of the extended array
|
275
|
-
* @see {@link https://dev.to/uilicious/javascript-array-push-is-945x-faster-than-array-concat-1oki}
|
276
|
-
* @example
|
277
|
-
* var obj = {};
|
278
|
-
* extendArrayProperty(obj, "prop1", 1); // [1]
|
279
|
-
* extendArrayProperty(obj, "prop1", 2); // [1, 2]
|
280
|
-
* extendArrayProperty(obj, "prop1", [3, 4]); // [1, 2, 3, 4]
|
281
|
-
* obj.prop2 = 5;
|
282
|
-
* extendArrayProperty(obj, "prop2", 6); // [5, 6]
|
283
|
-
* extendArrayProperty(obj, "prop2", [7]); // [5, 6, 7]
|
284
|
-
* extendArrayProperty(obj, "prop2", null); // null
|
285
|
-
*/
|
286
|
-
var extendArrayProperty = function (obj, propName, ary) {
|
287
|
-
var objAry = null;
|
288
|
-
if(ary) {
|
289
|
-
var objVal = obj[propName];
|
290
|
-
if(objVal) {
|
291
|
-
if(Array.isArray(objVal)) {
|
292
|
-
objAry = objVal;
|
293
|
-
} else {
|
294
|
-
objAry = obj[propName] = [objVal];
|
295
|
-
}
|
296
|
-
} else {
|
297
|
-
objAry = obj[propName] = [];
|
298
|
-
}
|
299
|
-
// objAry is guaranteed to be an array at this point
|
300
|
-
|
301
|
-
if(Array.isArray(ary)) {
|
302
|
-
if(ary.length) {
|
303
|
-
if(ary.length > 1) {
|
304
|
-
Array.prototype.push.apply(objAry, ary);
|
305
|
-
} else {
|
306
|
-
objAry.push(ary[0]);
|
307
|
-
}
|
308
|
-
}
|
309
|
-
} else {
|
310
|
-
objAry.push(ary);
|
311
|
-
}
|
312
|
-
}
|
313
|
-
return objAry;
|
314
|
-
};
|
315
|
-
|
316
|
-
|
317
|
-
/** Regex for matching the field token E.g. '[CF_BID]'
|
318
|
-
* @type {!RegExp}
|
319
|
-
* @private
|
320
|
-
* @const
|
321
|
-
*/
|
322
|
-
var _bracketExp = (/* unused pure expression or super */ null && (new RegExp(/\[[^\[]*\]/g))); // eslint-disable-line no-useless-escape
|
323
|
-
/** @public
|
324
|
-
* @function
|
325
|
-
* @param {string|Function} expression
|
326
|
-
* @return {Function}
|
327
|
-
* @example
|
328
|
-
* var fn = parseCondition("[CF_BID] >= 10 && [CF_BID] <= 100");
|
329
|
-
* window.console.log(fn(25));
|
330
|
-
*/
|
331
|
-
var parseCondition = function(expression) {
|
332
|
-
if(!expression) {
|
333
|
-
return null;
|
334
|
-
}
|
335
|
-
if(typeof expression !== "string") {
|
336
|
-
return (typeof expression == "function") ? /** @type {Function} */(expression) : null;
|
337
|
-
}
|
338
|
-
|
339
|
-
var brackets = expression.match(_bracketExp); // Retrieving field tokens (anything in between brackets)
|
340
|
-
var map = {}; // For checking duplication
|
341
|
-
var fields = [];
|
342
|
-
var len = brackets ? brackets.length : 0;
|
343
|
-
for(var i = len; --i >= 0;) {
|
344
|
-
var field = brackets[i];
|
345
|
-
if(!map[field]) {
|
346
|
-
map[field] = "f[" + fields.length + "]"; // Create mapping of field token to array with index E.g. { "[CF_BID]": "f[0]" }
|
347
|
-
fields.push(field.substring(1, field.length - 1)); // Strip '[' and ']' of field token to get field name
|
348
|
-
}
|
349
|
-
}
|
350
|
-
|
351
|
-
// Replace the field tokens with rowData of array with index E.g. [CF_BID] ==> rowData[f[0]]
|
352
|
-
expression = expression.replace(_bracketExp, function(match) {
|
353
|
-
return "rowData[" + map[match] + "]";
|
354
|
-
});
|
355
|
-
var finalExp = "(function(f, rowData) { return (" + expression + "); })";
|
356
|
-
|
357
|
-
var fn = null;
|
358
|
-
try {
|
359
|
-
fn = eval(finalExp);
|
360
|
-
fn = fn.bind(null, fields); // Bind fields for matching field name
|
361
|
-
} catch(err) {
|
362
|
-
console.log(err.message);
|
363
|
-
}
|
364
|
-
return (fn) ? fn : null;
|
365
|
-
};
|
366
|
-
|
367
|
-
|
368
|
-
/** @private
|
369
|
-
* @param {string|Array.<string>} item
|
370
|
-
* @return {string}
|
371
|
-
*/
|
372
|
-
var _encloseBracket = function(item) {
|
373
|
-
return Array.isArray(item) ? "{\n" + item.join("\n") + "\n}" : item;
|
374
|
-
};
|
375
|
-
/** @private
|
376
|
-
* @param {string} str
|
377
|
-
* @return {string}
|
378
|
-
*/
|
379
|
-
var _indentBracketContent = function(str){
|
380
|
-
return str.replace(/\n+/g, "\n\t").replace(/\n\t}$/, "\n}");
|
381
|
-
};
|
382
|
-
/** @public
|
383
|
-
* @param {string|Array} css
|
384
|
-
* @return {string} prettified CSS string
|
385
|
-
* @example
|
386
|
-
* prettifyCss(["div", [
|
387
|
-
* "color: red;",
|
388
|
-
* "padding: 20px;"
|
389
|
-
* ],
|
390
|
-
* ".class", [
|
391
|
-
* "margin: 0;"
|
392
|
-
* ]
|
393
|
-
* ]);
|
394
|
-
*/
|
395
|
-
var prettifyCss = function(css) {
|
396
|
-
if(css) {
|
397
|
-
var cssStr = "";
|
398
|
-
if (Array.isArray(css)) {
|
399
|
-
var ary = css.map(_encloseBracket);
|
400
|
-
cssStr = ary.join("\n").replace(/{\s*{/g, "{").replace(/\s+{/g, " {");
|
401
|
-
} else {
|
402
|
-
cssStr = (typeof css === "string") ? css : css + "";
|
403
|
-
}
|
404
|
-
|
405
|
-
if(cssStr) {
|
406
|
-
return cssStr.replace(/{[\w\W]*?}/g, _indentBracketContent);
|
407
|
-
}
|
408
|
-
}
|
409
|
-
return "";
|
410
|
-
};
|
411
|
-
/** Get shadow root of the given element regardless of whether the element is in the DOM or not. The immediate shadow root parent is returned in case of nested shadow roots. Any other case return null.
|
412
|
-
* @public
|
413
|
-
* @param {Element} elem
|
414
|
-
* @return {DocumentFragment}
|
415
|
-
*/
|
416
|
-
var getShadowRoot = function(elem) {
|
417
|
-
if(elem) {
|
418
|
-
var rootNode;
|
419
|
-
if(elem.shadowRoot) {
|
420
|
-
rootNode = elem.shadowRoot;
|
421
|
-
} else if(elem.getRootNode) {
|
422
|
-
rootNode = elem.getRootNode();
|
423
|
-
}
|
424
|
-
if(rootNode) { // getRootNode does not supported in IE. It should be implemented by the polyfills
|
425
|
-
if(rootNode !== document) { // element that is in the DOM and not in the shadow has document as its root node
|
426
|
-
if(rootNode !== elem) { // element that is NOT in the DOM and not in the shadow has itself as its root node
|
427
|
-
return rootNode;
|
428
|
-
}
|
429
|
-
}
|
430
|
-
}
|
431
|
-
}
|
432
|
-
return null;
|
433
|
-
};
|
434
|
-
/** Attach style tag to the proper document (in case of element inside a shadow root)
|
435
|
-
* @public
|
436
|
-
* @param {string} cssStr Valid CSS string (e.g. "div {color: red;}")
|
437
|
-
* @param {Element=} targetContext Element that needs the CSS
|
438
|
-
* @return {Element} New style tag
|
439
|
-
*/
|
440
|
-
var injectCss = function(cssStr, targetContext) {
|
441
|
-
if(!cssStr) {
|
442
|
-
return null;
|
443
|
-
}
|
444
|
-
|
445
|
-
var styleTag = document.createElement("style");
|
446
|
-
styleTag.textContent = "\n" + cssStr + "\n";
|
447
|
-
|
448
|
-
var styleHost = getShadowRoot(targetContext);
|
449
|
-
var isInShadow = true;
|
450
|
-
if(!styleHost) {
|
451
|
-
isInShadow = false;
|
452
|
-
styleHost = document.head;
|
453
|
-
}
|
454
|
-
|
455
|
-
// Find a place to insert the style tag
|
456
|
-
var beforeElem;
|
457
|
-
if(isInShadow) {
|
458
|
-
if(styleHost.children && styleHost.children.length) {
|
459
|
-
beforeElem = styleHost.children[0];
|
460
|
-
}
|
461
|
-
}
|
462
|
-
if(beforeElem) {
|
463
|
-
styleHost.insertBefore(styleTag, beforeElem);
|
464
|
-
} else {
|
465
|
-
styleHost.appendChild(styleTag);
|
466
|
-
}
|
467
|
-
return styleTag;
|
468
|
-
};
|
469
|
-
|
470
|
-
/** return true if browser is IE or Edge
|
471
|
-
* @public
|
472
|
-
* @return {boolean}
|
473
|
-
*/
|
474
|
-
var isIE = function () {
|
475
|
-
var ua = window.navigator.userAgent;
|
476
|
-
return (ua.indexOf('MSIE ') > 0) || (ua.indexOf('Trident/') > 0) || (ua.indexOf('Edge/') > 0);
|
477
|
-
};
|
478
|
-
|
479
|
-
/** return true if device is mac
|
480
|
-
* @public
|
481
|
-
* @return {boolean}
|
482
|
-
*/
|
483
|
-
var isMac = function () {
|
484
|
-
return /Mac/.test(navigator.platform);
|
485
|
-
};
|
486
|
-
|
487
|
-
/** Return true if device is mac
|
488
|
-
* @public
|
489
|
-
* @return {boolean}
|
490
|
-
*/
|
491
|
-
var isTouchDevice = function () {
|
492
|
-
if ((navigator["maxTouchPoints"] && navigator["maxTouchPoints"] < 256) ||
|
493
|
-
(navigator["msMaxTouchPoints"] && navigator["msMaxTouchPoints"] < 256)) {
|
494
|
-
return true;
|
495
|
-
}
|
496
|
-
return false;
|
497
|
-
};
|
498
|
-
|
499
|
-
/** parse nested object in to array
|
500
|
-
* @public
|
501
|
-
* @param {Object} obj
|
502
|
-
* @param {Array=} ary
|
503
|
-
* @return {Array}
|
504
|
-
*/
|
505
|
-
var nestedObjectToArray = function (obj, ary) {
|
506
|
-
if (!ary) {
|
507
|
-
ary = [];
|
508
|
-
}
|
509
|
-
for (var key in obj) {
|
510
|
-
var element = obj[key];
|
511
|
-
if ('object' === typeof element) {
|
512
|
-
nestedObjectToArray(element, ary);
|
513
|
-
} else {
|
514
|
-
ary.push(element);
|
515
|
-
}
|
516
|
-
}
|
517
|
-
return ary;
|
518
|
-
};
|
519
|
-
|
520
|
-
/** Convert CSS rgb or rgba formats to CSS hex color string (# prefix)
|
521
|
-
* @public
|
522
|
-
* @param {string} rgbCode
|
523
|
-
* @return {string}
|
524
|
-
* @example
|
525
|
-
* rgb2Hex("rgb(255, 255, 0)"); // "#FFFF00"
|
526
|
-
* rgb2Hex("rgba(255, 255, 0, 1)"); // "#FFFF00"
|
527
|
-
* rgb2Hex("255 255.0"); // "#FFFF00"
|
528
|
-
* rgb2Hex("#FFFF00"); // "#FFFF00"
|
529
|
-
* rgb2Hex("#1a1a1a"); // "#1a1a1a"
|
530
|
-
* rgb2Hex("2552550"); // "2552550"
|
531
|
-
* rgb2Hex("invalid"); // "invalid"
|
532
|
-
* rgb2Hex(null); // ""
|
533
|
-
*/
|
534
|
-
var rgb2Hex = function (rgbCode) {
|
535
|
-
if(!rgbCode || typeof rgbCode !== "string") {
|
536
|
-
return "";
|
537
|
-
}
|
538
|
-
if(rgbCode.charAt(0) === "#") {
|
539
|
-
return rgbCode;
|
540
|
-
}
|
541
|
-
var rgb = rgbCode.match(/\d+/g);
|
542
|
-
if(!rgb || rgb.length < 3) {
|
543
|
-
return rgbCode;
|
544
|
-
}
|
545
|
-
|
546
|
-
var hex = "#";
|
547
|
-
for(var i = 0; i < 3; i++) {
|
548
|
-
var num = +rgb[i];
|
549
|
-
if(!(num >= 16)) { // Handle NaN case
|
550
|
-
hex += "0";
|
551
|
-
}
|
552
|
-
hex += (num) ? num.toString(16).toUpperCase() : "0";
|
553
|
-
}
|
554
|
-
return hex;
|
555
|
-
};
|
556
|
-
|
557
|
-
/** transform data to tab seperated value
|
558
|
-
* @public
|
559
|
-
* @param {*} data
|
560
|
-
* @return {string}
|
561
|
-
*/
|
562
|
-
var prepareTSVContent = function (data) {
|
563
|
-
if (data == null) {
|
564
|
-
return "";
|
565
|
-
}
|
566
|
-
|
567
|
-
var content = (typeof data === 'string') ? data : data.toString();
|
568
|
-
|
569
|
-
if (!content.length) { return ""; }
|
570
|
-
|
571
|
-
// Replace any new line and tab
|
572
|
-
if (content.indexOf("\n") >= 0) {
|
573
|
-
content = content.replace(/[\r\n]/g, " ");
|
574
|
-
}
|
575
|
-
|
576
|
-
if (content.indexOf("\t") >= 0) {
|
577
|
-
content = content.replace(/\t/g, " ");
|
578
|
-
}
|
579
|
-
|
580
|
-
// Trim front and back spaces
|
581
|
-
if (content.charAt(0) === " " || content.charAt(content.length - 1) === " ") {
|
582
|
-
content = content.trim();
|
583
|
-
}
|
584
|
-
|
585
|
-
return content;
|
586
|
-
};
|
587
|
-
|
588
|
-
/* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = ((/* unused pure expression or super */ null && (Util)));
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
/***/ })
|
593
|
-
|
594
|
-
/******/ });
|
595
|
-
/************************************************************************/
|
596
|
-
/******/ // The module cache
|
597
|
-
/******/ var __webpack_module_cache__ = {};
|
598
|
-
/******/
|
599
|
-
/******/ // The require function
|
600
|
-
/******/ function __webpack_require__(moduleId) {
|
601
|
-
/******/ // Check if module is in cache
|
602
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
603
|
-
/******/ if (cachedModule !== undefined) {
|
604
|
-
/******/ return cachedModule.exports;
|
605
|
-
/******/ }
|
606
|
-
/******/ // Create a new module (and put it into the cache)
|
607
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
608
|
-
/******/ // no module.id needed
|
609
|
-
/******/ // no module.loaded needed
|
610
|
-
/******/ exports: {}
|
611
|
-
/******/ };
|
612
|
-
/******/
|
613
|
-
/******/ // Execute the module function
|
614
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
615
|
-
/******/
|
616
|
-
/******/ // Return the exports of the module
|
617
|
-
/******/ return module.exports;
|
618
|
-
/******/ }
|
619
|
-
/******/
|
620
|
-
/************************************************************************/
|
621
|
-
/******/ /* webpack/runtime/define property getters */
|
622
|
-
/******/ (() => {
|
623
|
-
/******/ // define getter functions for harmony exports
|
624
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
625
|
-
/******/ for(var key in definition) {
|
626
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
627
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
628
|
-
/******/ }
|
629
|
-
/******/ }
|
630
|
-
/******/ };
|
631
|
-
/******/ })();
|
632
|
-
/******/
|
633
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
634
|
-
/******/ (() => {
|
635
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
636
|
-
/******/ })();
|
637
|
-
/******/
|
638
|
-
/************************************************************************/
|
639
3
|
var __webpack_exports__ = {};
|
640
|
-
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
641
|
-
(() => {
|
642
4
|
|
643
5
|
// UNUSED EXPORTS: Cell, CellFloatingPanel, CellSpan, CellSpans, Column, ColumnStats, Conflator, Core, DataCache, DataTable, DataView, ElementFrameWork, ElementWrapper, EventDispatcher, HScrollbar, ILayoutGrid, LayoutGrid, Reverter, Scrollbar, SectionSettings, SelectionList, SortableTitlePlugin, TrackLayout, VScrollbar, VirtualizedLayoutGrid, Virtualizer, default
|
644
6
|
|
@@ -647,23 +9,46 @@ var __webpack_exports__ = {};
|
|
647
9
|
* @namespace
|
648
10
|
*/
|
649
11
|
var Util = {};
|
12
|
+
|
13
|
+
// TODO: move to tr-grid-util
|
14
|
+
|
650
15
|
/** @const
|
651
16
|
* @type {boolean}
|
652
17
|
*/
|
653
|
-
Util.isIE =
|
18
|
+
Util.isIE = (function () {
|
654
19
|
var ua = window.navigator.userAgent;
|
655
20
|
return (ua.indexOf('MSIE ') > 0) || (ua.indexOf('Trident/') > 0) || (ua.indexOf('Edge/') > 0);
|
656
21
|
}());
|
657
22
|
/** @const
|
658
23
|
* @type {boolean}
|
659
24
|
*/
|
660
|
-
Util.isTouchDevice =
|
25
|
+
Util.isTouchDevice = (function () {
|
661
26
|
if ((navigator["maxTouchPoints"] && navigator["maxTouchPoints"] < 256) ||
|
662
27
|
(navigator["msMaxTouchPoints"] && navigator["msMaxTouchPoints"] < 256)) {
|
663
28
|
return true;
|
664
29
|
}
|
665
30
|
return false;
|
666
31
|
}());
|
32
|
+
/** @const
|
33
|
+
* @type {boolean}
|
34
|
+
*/
|
35
|
+
Util.isSafari = (function () {
|
36
|
+
var rejectedExpression = /Chrome|Android|CriOS|FxiOS|EdgiOS/i;
|
37
|
+
var safariExpression = /Safari/i;
|
38
|
+
var agent = navigator.userAgent;
|
39
|
+
if (rejectedExpression.test(agent)) {
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
return safariExpression.test(agent);
|
43
|
+
}());
|
44
|
+
|
45
|
+
/** @public
|
46
|
+
* @type {boolean}
|
47
|
+
*/
|
48
|
+
Util.isMobile = (function () {
|
49
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
50
|
+
}());
|
51
|
+
|
667
52
|
/** Retrieve an element from Novakit control or any object that has "getElement" method.
|
668
53
|
* @public
|
669
54
|
* @ignore
|
@@ -1009,13 +394,6 @@ Util._preventDefault = function (e) {
|
|
1009
394
|
e.stopPropagation();
|
1010
395
|
};
|
1011
396
|
|
1012
|
-
/** @public
|
1013
|
-
* @type {boolean}
|
1014
|
-
*/
|
1015
|
-
Util.isMobile = Util.isMobile || (function () {
|
1016
|
-
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
1017
|
-
}());
|
1018
|
-
|
1019
397
|
/* harmony default export */ const util = (Util);
|
1020
398
|
|
1021
399
|
|
@@ -11213,252 +10591,777 @@ LayoutGrid.prototype._syncLayoutToRows = function (indexY, toY) {
|
|
11213
10591
|
} else {
|
11214
10592
|
this._updateCellSpans(this._cellSpans.getAllSpans(), true); // Re-collapsing cells when spans are set before setting row count
|
11215
10593
|
}
|
11216
|
-
this._updateViewHeight();
|
10594
|
+
this._updateViewHeight();
|
10595
|
+
};
|
10596
|
+
|
10597
|
+
/**
|
10598
|
+
* @private
|
10599
|
+
* @param {number} from
|
10600
|
+
* @param {number} to
|
10601
|
+
*/
|
10602
|
+
LayoutGrid.prototype._dispatchRowHeightChangedEvent = function (from, to) {
|
10603
|
+
if (!this._hasListener("rowHeightChanged")) {
|
10604
|
+
return;
|
10605
|
+
}
|
10606
|
+
|
10607
|
+
if (from >= to) {
|
10608
|
+
return;
|
10609
|
+
}
|
10610
|
+
|
10611
|
+
var e = {};
|
10612
|
+
|
10613
|
+
e["rowIndex"] = from;
|
10614
|
+
e["changeLength"] = to - from;
|
10615
|
+
this._dispatch("rowHeightChanged", e);
|
10616
|
+
};
|
10617
|
+
|
10618
|
+
/**
|
10619
|
+
* @private
|
10620
|
+
* @param {number} indexX
|
10621
|
+
* @param {number} indexY
|
10622
|
+
* @param {CellSpan} cellSpan
|
10623
|
+
*/
|
10624
|
+
LayoutGrid.prototype._updateCellSpanSize = function (indexX, indexY, cellSpan) {
|
10625
|
+
var cell = this._getCell(indexX, indexY);
|
10626
|
+
|
10627
|
+
if (cell == null) {
|
10628
|
+
return;
|
10629
|
+
}
|
10630
|
+
|
10631
|
+
if (cellSpan && cellSpan.colSpan > 1) {
|
10632
|
+
cell.setWidth(this.getCellWidth(indexX, indexY));
|
10633
|
+
this._columns[indexX].disableDeactivation(); // HACK: If a cell has column span, the column cannot be virtualized
|
10634
|
+
} else {
|
10635
|
+
cell.setWidth(-1);
|
10636
|
+
}
|
10637
|
+
|
10638
|
+
if (cellSpan && cellSpan.rowSpan > 1) {
|
10639
|
+
cell.setHeight(this.getCellHeight(indexX, indexY)); /////
|
10640
|
+
} else {
|
10641
|
+
var height = this._trackY.isAtDefaultSize(indexY) ? -1 : this._trackY.getLaneSize(indexY);
|
10642
|
+
|
10643
|
+
cell.setHeight(height);
|
10644
|
+
}
|
10645
|
+
};
|
10646
|
+
|
10647
|
+
/**
|
10648
|
+
* @private
|
10649
|
+
* @param {Array.<CellSpan>} cellSpans
|
10650
|
+
*/
|
10651
|
+
LayoutGrid.prototype._updateCellSpanLayout = function (cellSpans) {
|
10652
|
+
if (cellSpans == null) { return; }
|
10653
|
+
|
10654
|
+
for (var i = cellSpans.length; --i >= 0; ) {
|
10655
|
+
var cellSpan = cellSpans[i];
|
10656
|
+
|
10657
|
+
this._updateCellSpanSize(cellSpan.indexX, cellSpan.indexY, cellSpan);
|
10658
|
+
}
|
10659
|
+
};
|
10660
|
+
|
10661
|
+
/**
|
10662
|
+
* @private
|
10663
|
+
* @param {number} indexX
|
10664
|
+
* @param {number} indexY
|
10665
|
+
* @param {!CellSpan} cellSpan
|
10666
|
+
* @param {boolean} adding
|
10667
|
+
*/
|
10668
|
+
LayoutGrid.prototype._updateCellSpan = function (indexX, indexY, cellSpan, adding) {
|
10669
|
+
this._updateCellSpanSize(indexX, indexY, adding ? cellSpan : null);
|
10670
|
+
this._updateCellSpanClass(indexX, indexY, cellSpan.colSpan, cellSpan.rowSpan, adding);
|
10671
|
+
};
|
10672
|
+
|
10673
|
+
/**
|
10674
|
+
* @private
|
10675
|
+
* @param {number} indexX
|
10676
|
+
* @param {number} indexY
|
10677
|
+
* @param {number} colSpan
|
10678
|
+
* @param {number} rowSpan
|
10679
|
+
* @param {boolean} adding
|
10680
|
+
*/
|
10681
|
+
LayoutGrid.prototype._updateCellSpanClass = function (indexX, indexY, colSpan, rowSpan, adding) {
|
10682
|
+
var column;
|
10683
|
+
|
10684
|
+
for (var c = 0; c < colSpan; ++c) {
|
10685
|
+
column = this._columns[indexX + c];
|
10686
|
+
|
10687
|
+
if (!column) {
|
10688
|
+
break;
|
10689
|
+
}
|
10690
|
+
|
10691
|
+
column.collapseCells(indexY, rowSpan, adding, (c === 0), (c > 0));
|
10692
|
+
}
|
10693
|
+
|
10694
|
+
var cell = this._getCell(indexX, indexY);
|
10695
|
+
|
10696
|
+
if (cell) {
|
10697
|
+
cell._colSpan = (adding) ? colSpan : 1;
|
10698
|
+
cell._rowSpan = (adding) ? rowSpan : 1; // For quick rendering
|
10699
|
+
}
|
10700
|
+
};
|
10701
|
+
|
10702
|
+
/**
|
10703
|
+
* @private
|
10704
|
+
* @param {Array.<CellSpan>} cellSpans
|
10705
|
+
* @param {boolean} adding
|
10706
|
+
*/
|
10707
|
+
LayoutGrid.prototype._updateCellSpans = function (cellSpans, adding) {
|
10708
|
+
if (cellSpans == null) { return; }
|
10709
|
+
|
10710
|
+
for (var i = cellSpans.length; --i >= 0; ) {
|
10711
|
+
var cellSpan = cellSpans[i];
|
10712
|
+
|
10713
|
+
this._updateCellSpan(cellSpan.indexX, cellSpan.indexY, cellSpan, adding);
|
10714
|
+
}
|
10715
|
+
};
|
10716
|
+
|
10717
|
+
/**
|
10718
|
+
* @private
|
10719
|
+
* @param {Object} e
|
10720
|
+
*/
|
10721
|
+
LayoutGrid.prototype._onMouseMove = function (e) {
|
10722
|
+
var target = e["target"];
|
10723
|
+
|
10724
|
+
var cellElement = util.closestElement(target, "cell");
|
10725
|
+
var colIndex = this._stretchedCells.getColumnIndex(cellElement);
|
10726
|
+
if(colIndex < 0) { // Not found colIndex in stretching cell, then get from normal row
|
10727
|
+
var colElement = util.closestElement(target, "column");
|
10728
|
+
colIndex = this.getColumnIndex(colElement);
|
10729
|
+
}
|
10730
|
+
var rowIndex = this.getCellIndex(colIndex, cellElement);
|
10731
|
+
|
10732
|
+
this.setRowHighlight(rowIndex);
|
10733
|
+
};
|
10734
|
+
|
10735
|
+
/**
|
10736
|
+
* @private
|
10737
|
+
* @param {Object} e
|
10738
|
+
*/
|
10739
|
+
LayoutGrid.prototype._onMouseOut = function (e) {
|
10740
|
+
var rel = e.relatedTarget;
|
10741
|
+
|
10742
|
+
if (rel) {
|
10743
|
+
var thisElem = this._element;
|
10744
|
+
|
10745
|
+
while (rel.parentNode !== null) {
|
10746
|
+
rel = rel.parentNode;
|
10747
|
+
|
10748
|
+
if (rel === thisElem) {
|
10749
|
+
return;
|
10750
|
+
}
|
10751
|
+
}
|
10752
|
+
}
|
10753
|
+
|
10754
|
+
this.setRowHighlight(-1);
|
10755
|
+
};
|
10756
|
+
|
10757
|
+
/**
|
10758
|
+
* @private
|
10759
|
+
* @param {number} rowIndex
|
10760
|
+
*/
|
10761
|
+
LayoutGrid.prototype._updateSelectionUI = function (rowIndex) { // Update UI of the specified row index
|
10762
|
+
var selected = this._selectionList.getSelection(rowIndex);
|
10763
|
+
this._enableStretchCellClass(rowIndex, "selected-row", selected);
|
10764
|
+
this.enableRowClass(rowIndex, "selected-row", selected);
|
10765
|
+
};
|
10766
|
+
|
10767
|
+
/** @private
|
10768
|
+
* @param {number} rowIndex
|
10769
|
+
*/
|
10770
|
+
LayoutGrid.prototype._addSelectionUI = function (rowIndex) {
|
10771
|
+
this._enableStretchCellClass(rowIndex, "selected-row", true);
|
10772
|
+
this.enableRowClass(rowIndex, "selected-row", true);
|
10773
|
+
};
|
10774
|
+
|
10775
|
+
/**
|
10776
|
+
* @private
|
10777
|
+
* @param {number} rowIndex
|
10778
|
+
*/
|
10779
|
+
LayoutGrid.prototype._removeSelectionUI = function (rowIndex) {
|
10780
|
+
this._enableStretchCellClass(rowIndex, "selected-row", false);
|
10781
|
+
this.enableRowClass(rowIndex, "selected-row", false);
|
10782
|
+
};
|
10783
|
+
|
10784
|
+
/**
|
10785
|
+
* @public
|
10786
|
+
* @ignore
|
10787
|
+
*/
|
10788
|
+
LayoutGrid.prototype._onEnterDocument = function () {
|
10789
|
+
if (!this._initialized && this.getParent()) {
|
10790
|
+
for (var c = 0; c < this._colCount; ++c) {
|
10791
|
+
this._columns[c].enableAutoStyleUpdating();
|
10792
|
+
}
|
10793
|
+
|
10794
|
+
this._syncLayoutToColumns(0);
|
10795
|
+
this._initialized = true;
|
10796
|
+
}
|
10797
|
+
};
|
10798
|
+
|
10799
|
+
/** @public
|
10800
|
+
* @ignore
|
10801
|
+
* @param {*} ctx
|
10802
|
+
*/
|
10803
|
+
LayoutGrid.prototype._setContext = function(ctx) {
|
10804
|
+
this._ctx = ctx;
|
10805
|
+
};
|
10806
|
+
|
10807
|
+
/** @public
|
10808
|
+
* @ignore
|
10809
|
+
* @return {*} ctx
|
10810
|
+
*/
|
10811
|
+
LayoutGrid.prototype._getContext = function () {
|
10812
|
+
return this._ctx;
|
10813
|
+
};
|
10814
|
+
|
10815
|
+
/** This is a WORKAROUND to fix Internet Explorer couldn't render top 50% with translateX -50% correctly
|
10816
|
+
* @private
|
10817
|
+
*/
|
10818
|
+
LayoutGrid.prototype._resetTransformIETimer = function () {
|
10819
|
+
if (util.isIE) {
|
10820
|
+
if(!this._transformIETimer) {
|
10821
|
+
this.enableClass("reset-transform");
|
10822
|
+
this._transformIETimer = setTimeout(this._onResetTransformIE, 20);
|
10823
|
+
}
|
10824
|
+
}
|
10825
|
+
};
|
10826
|
+
/** @private
|
10827
|
+
*/
|
10828
|
+
LayoutGrid.prototype._onResetTransformIE = function () {
|
10829
|
+
this._transformIETimer = 0;
|
10830
|
+
this.enableClass("reset-transform", false);
|
10831
|
+
};
|
10832
|
+
|
10833
|
+
LayoutGrid._proto = LayoutGrid.prototype;
|
10834
|
+
|
10835
|
+
/* harmony default export */ const grid_LayoutGrid = (LayoutGrid);
|
10836
|
+
|
10837
|
+
|
10838
|
+
;// CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/Util.js
|
10839
|
+
/** @namespace */
|
10840
|
+
var Util_Util = {};
|
10841
|
+
|
10842
|
+
/** This is a shorthand for fetch() API by POST method and with json body <br>
|
10843
|
+
* WARNING: fetch is not supported in IE (including IE11)
|
10844
|
+
* @public
|
10845
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch}
|
10846
|
+
* @function
|
10847
|
+
* @param {string} url
|
10848
|
+
* @param {Object|string} obj
|
10849
|
+
* @return {!Promise<Response>}
|
10850
|
+
*/
|
10851
|
+
Util_Util.post = function(url, obj) { // Not supported in IE
|
10852
|
+
return Util_Util._post(url, obj).then(Util_Util.toJSON);
|
10853
|
+
};
|
10854
|
+
/** Request a server response from server as text by POST method <br>
|
10855
|
+
* WARNING: fetch is not supported in IE (including IE11)
|
10856
|
+
* @public
|
10857
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch}
|
10858
|
+
* @function
|
10859
|
+
* @param {string} url
|
10860
|
+
* @param {Object|string} obj
|
10861
|
+
* @return {!Promise<Response>}
|
10862
|
+
*/
|
10863
|
+
Util_Util.requestText = function(url, obj) { // Not supported in IE
|
10864
|
+
return Util_Util._post(url, obj, "text/plain").then(Util_Util.toText);
|
10865
|
+
};
|
10866
|
+
/** Request a server response from server by POST method and with url-encoded body <br>
|
10867
|
+
* WARNING: fetch is not supported in IE (including IE11)
|
10868
|
+
* @public
|
10869
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch}
|
10870
|
+
* @function
|
10871
|
+
* @param {string} url
|
10872
|
+
* @param {string} obj
|
10873
|
+
* @return {!Promise<Response>}
|
10874
|
+
*/
|
10875
|
+
Util_Util.requestByUrlEncoded = function(url, obj) { // Not supported in IE
|
10876
|
+
return Util_Util._post(url, obj, "application/x-www-form-urlencoded").then(Util_Util.toJSON);
|
10877
|
+
};
|
10878
|
+
|
10879
|
+
/** @public
|
10880
|
+
* @function
|
10881
|
+
* @param {Response} resp
|
10882
|
+
* @return {!Promise<Object>}
|
10883
|
+
*/
|
10884
|
+
Util_Util.toJSON = function (resp) {
|
10885
|
+
if(Util_Util._logError(resp)) {
|
10886
|
+
return Promise.reject(resp);
|
10887
|
+
}
|
10888
|
+
return resp.json();
|
10889
|
+
};
|
10890
|
+
/** @public
|
10891
|
+
* @function
|
10892
|
+
* @param {Response} resp
|
10893
|
+
* @return {!Promise<string>}
|
10894
|
+
*/
|
10895
|
+
Util_Util.toText = function (resp) {
|
10896
|
+
if(Util_Util._logError(resp)) {
|
10897
|
+
return Promise.reject(resp);
|
10898
|
+
}
|
10899
|
+
return resp.text();
|
10900
|
+
};
|
10901
|
+
|
10902
|
+
/** @private
|
10903
|
+
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
|
10904
|
+
* @function
|
10905
|
+
* @param {Response} resp
|
10906
|
+
* @return {boolean}
|
10907
|
+
*/
|
10908
|
+
Util_Util._logError = function(resp) {
|
10909
|
+
if(resp && resp.status >= 300) {
|
10910
|
+
console.log("Response " + resp.status + ": " + resp.statusText);
|
10911
|
+
return true;
|
10912
|
+
}
|
10913
|
+
return false;
|
10914
|
+
};
|
10915
|
+
/** @private
|
10916
|
+
* @function
|
10917
|
+
* @param {string} url
|
10918
|
+
* @param {Object|string} obj
|
10919
|
+
* @param {string=} contentType
|
10920
|
+
* @return {!Promise<Response>}
|
10921
|
+
*/
|
10922
|
+
Util_Util._post = function(url, obj, contentType) {
|
10923
|
+
var options = {
|
10924
|
+
method: obj ? "POST" : "GET",
|
10925
|
+
headers: { "Content-Type": contentType || "application/json" }
|
10926
|
+
};
|
10927
|
+
if(obj) {
|
10928
|
+
options.body = typeof obj === "string" ? obj : JSON.stringify(obj);
|
10929
|
+
}
|
10930
|
+
|
10931
|
+
return fetch(url, options);
|
10932
|
+
};
|
10933
|
+
|
10934
|
+
/** WARNING: Only one level of property tree is affected (i.e. no recursive or nested operation). <br>
|
10935
|
+
* Property with undefined or null value will not have an impact on the object. <br>
|
10936
|
+
* Existing properties will be overridden.
|
10937
|
+
* @public
|
10938
|
+
* @function
|
10939
|
+
* @param {Object} obj Object that is extended (new properties will be added to this object)
|
10940
|
+
* @param {Object=} extender Master object (no modification will be made on the extender)
|
10941
|
+
* @param {Array.<string>=} limiters Specify property to be extended
|
10942
|
+
* @return {Object}
|
10943
|
+
*/
|
10944
|
+
var extendObject = function (obj, extender, limiters) {
|
10945
|
+
if(!obj) { // null undefined NaN empty string and 0
|
10946
|
+
return null;
|
10947
|
+
}
|
10948
|
+
if(!extender || obj === extender) {
|
10949
|
+
return obj;
|
10950
|
+
}
|
10951
|
+
|
10952
|
+
var key;
|
10953
|
+
if(limiters) {
|
10954
|
+
var len = limiters.length;
|
10955
|
+
for(var i = 0; i < len; ++i) {
|
10956
|
+
key = limiters[i];
|
10957
|
+
if(key) {
|
10958
|
+
extendProperty(obj, extender, key);
|
10959
|
+
}
|
10960
|
+
}
|
10961
|
+
} else {
|
10962
|
+
for(key in extender) {
|
10963
|
+
extendProperty(obj, extender, key);
|
10964
|
+
}
|
10965
|
+
}
|
10966
|
+
return obj;
|
10967
|
+
};
|
10968
|
+
/** WARNING: Only one level of property tree is affected (i.e. no recursive or nested operation). <br>
|
10969
|
+
* Property with undefined or null value will not be cloned.
|
10970
|
+
* @public
|
10971
|
+
* @function
|
10972
|
+
* @param {Object} obj
|
10973
|
+
* @param {Array.<string>=} limiters
|
10974
|
+
* @return {Object}
|
10975
|
+
*/
|
10976
|
+
var cloneObject = function (obj, limiters) {
|
10977
|
+
return extendObject({}, obj, limiters);
|
10978
|
+
};
|
10979
|
+
|
10980
|
+
/** Check empty object
|
10981
|
+
* @public
|
10982
|
+
* @function
|
10983
|
+
* @param {Object} obj
|
10984
|
+
* @return {boolean}=true, if the obj is empty
|
10985
|
+
*/
|
10986
|
+
var isEmptyObject = function (obj) {
|
10987
|
+
for (var key in obj) {
|
10988
|
+
return false;
|
10989
|
+
}
|
10990
|
+
return true;
|
10991
|
+
};
|
10992
|
+
|
10993
|
+
/** @public
|
10994
|
+
* @param {Array=} data
|
10995
|
+
* @param {Array.<string>=} fields In case of the given data is an array, this param will be used for mapping index to field
|
10996
|
+
* @return {Object|null}
|
10997
|
+
*/
|
10998
|
+
var arrayToObject = function(data, fields) {
|
10999
|
+
if(!Array.isArray(data)) {
|
11000
|
+
return data;
|
11001
|
+
} else if(!fields) {
|
11002
|
+
return null;
|
11003
|
+
}
|
11004
|
+
var ary = data;
|
11005
|
+
data = {};
|
11006
|
+
var len = ary.length;
|
11007
|
+
for(var i = 0; i < len; ++i) {
|
11008
|
+
var field = fields[i];
|
11009
|
+
// eslint-disable-next-line no-undefined
|
11010
|
+
if(field && ary[i] !== undefined) {
|
11011
|
+
data[field] = ary[i];
|
11012
|
+
}
|
11013
|
+
}
|
11014
|
+
return data;
|
11015
|
+
};
|
11016
|
+
/** Replace the specified property with the value from the extender. If the value is an array, the value will be added to the array instead of replacement
|
11017
|
+
* @public
|
11018
|
+
* @function
|
11019
|
+
* @param {Object} obj
|
11020
|
+
* @param {Object} extender
|
11021
|
+
* @param {string} propName
|
11022
|
+
* @example
|
11023
|
+
* extendProperty({a: 0}, {a: 1}, "a"); // {a: 1}
|
11024
|
+
* extendProperty({a: 0}, {b: 1}, "b"); // {a: 0, b: 1}
|
11025
|
+
* extendProperty({a: [0]}, {a: 1}, "a"); // {a: [0, 1]}
|
11026
|
+
* extendProperty({a: [0]}, {a: [1, 2]}, "a"); // {a: [0, 1, 2]}
|
11027
|
+
*/
|
11028
|
+
var extendProperty = function (obj, extender, propName) {
|
11029
|
+
var val = extender[propName];
|
11030
|
+
if(val != null) {
|
11031
|
+
var objVal = obj[propName];
|
11032
|
+
if(Array.isArray(objVal)) {
|
11033
|
+
obj[propName] = objVal.concat(val);
|
11034
|
+
} else if(Array.isArray(val) && objVal) {
|
11035
|
+
obj[propName] = val.concat(objVal); // TODO: Preserve the order
|
11036
|
+
} else {
|
11037
|
+
obj[propName] = val; // WARNING: Overriding existing data
|
11038
|
+
}
|
11039
|
+
}
|
11217
11040
|
};
|
11218
11041
|
|
11219
|
-
|
11220
|
-
|
11221
|
-
|
11222
|
-
|
11223
|
-
|
11224
|
-
|
11225
|
-
|
11226
|
-
|
11042
|
+
|
11043
|
+
/** Compare the values of obj1 and obj2. if they are the same object or have the same value, the result will be true. Otherwise, it will return false.
|
11044
|
+
* @public
|
11045
|
+
* @param {*} obj1
|
11046
|
+
* @param {*} obj2
|
11047
|
+
* @return {boolean}
|
11048
|
+
*/
|
11049
|
+
var deepEqual = function (obj1, obj2) {
|
11050
|
+
|
11051
|
+
if(obj1 === obj2) {
|
11052
|
+
return true;
|
11227
11053
|
}
|
11228
11054
|
|
11229
|
-
if (
|
11230
|
-
return;
|
11055
|
+
if (typeof obj1 !== typeof obj2) {
|
11056
|
+
return false;
|
11231
11057
|
}
|
11232
11058
|
|
11233
|
-
|
11059
|
+
if (typeof obj1 === "object") {
|
11234
11060
|
|
11235
|
-
|
11236
|
-
|
11237
|
-
|
11238
|
-
|
11061
|
+
// We need to split array and object for performance reason
|
11062
|
+
if(Array.isArray(obj1)) {
|
11063
|
+
if(obj1.length !== obj2.length) {
|
11064
|
+
return false;
|
11065
|
+
}
|
11239
11066
|
|
11240
|
-
|
11241
|
-
|
11242
|
-
|
11243
|
-
|
11244
|
-
|
11245
|
-
*/
|
11246
|
-
LayoutGrid.prototype._updateCellSpanSize = function (indexX, indexY, cellSpan) {
|
11247
|
-
var cell = this._getCell(indexX, indexY);
|
11067
|
+
for (var i = 0; i < obj1.length; i++) {
|
11068
|
+
if (!deepEqual(obj1[i], obj2[i])) { // The array may not be a match if the elements are not sorted, so it will not be considered equal if there is a mismatch.
|
11069
|
+
return false;
|
11070
|
+
}
|
11071
|
+
}
|
11248
11072
|
|
11249
|
-
|
11250
|
-
return;
|
11251
|
-
}
|
11073
|
+
} else {
|
11252
11074
|
|
11253
|
-
|
11254
|
-
|
11255
|
-
|
11256
|
-
} else {
|
11257
|
-
cell.setWidth(-1);
|
11258
|
-
}
|
11075
|
+
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
|
11076
|
+
return false;
|
11077
|
+
}
|
11259
11078
|
|
11260
|
-
|
11261
|
-
|
11262
|
-
|
11263
|
-
|
11079
|
+
for (var key in obj1) {
|
11080
|
+
if (!deepEqual(obj1[key], obj2[key])) {
|
11081
|
+
return false;
|
11082
|
+
}
|
11083
|
+
}
|
11084
|
+
}
|
11264
11085
|
|
11265
|
-
|
11086
|
+
|
11087
|
+
return true;
|
11266
11088
|
}
|
11267
|
-
};
|
11268
11089
|
|
11269
|
-
|
11270
|
-
* @private
|
11271
|
-
* @param {Array.<CellSpan>} cellSpans
|
11272
|
-
*/
|
11273
|
-
LayoutGrid.prototype._updateCellSpanLayout = function (cellSpans) {
|
11274
|
-
if (cellSpans == null) { return; }
|
11090
|
+
return false;
|
11275
11091
|
|
11276
|
-
|
11277
|
-
|
11092
|
+
};
|
11093
|
+
/** Array.push() is much faster than Array.concat(). The downside is the parameters must be an array, whereas concat() has no such requirement. <br>
|
11094
|
+
* This method excels in extending known array property in an object.
|
11095
|
+
* @public
|
11096
|
+
* @function
|
11097
|
+
* @param {Object} obj
|
11098
|
+
* @param {string} propName
|
11099
|
+
* @param {*} ary
|
11100
|
+
* @return {Array} Returns the result of the extended array
|
11101
|
+
* @see {@link https://dev.to/uilicious/javascript-array-push-is-945x-faster-than-array-concat-1oki}
|
11102
|
+
* @example
|
11103
|
+
* var obj = {};
|
11104
|
+
* extendArrayProperty(obj, "prop1", 1); // [1]
|
11105
|
+
* extendArrayProperty(obj, "prop1", 2); // [1, 2]
|
11106
|
+
* extendArrayProperty(obj, "prop1", [3, 4]); // [1, 2, 3, 4]
|
11107
|
+
* obj.prop2 = 5;
|
11108
|
+
* extendArrayProperty(obj, "prop2", 6); // [5, 6]
|
11109
|
+
* extendArrayProperty(obj, "prop2", [7]); // [5, 6, 7]
|
11110
|
+
* extendArrayProperty(obj, "prop2", null); // null
|
11111
|
+
*/
|
11112
|
+
var extendArrayProperty = function (obj, propName, ary) {
|
11113
|
+
var objAry = null;
|
11114
|
+
if(ary) {
|
11115
|
+
var objVal = obj[propName];
|
11116
|
+
if(objVal) {
|
11117
|
+
if(Array.isArray(objVal)) {
|
11118
|
+
objAry = objVal;
|
11119
|
+
} else {
|
11120
|
+
objAry = obj[propName] = [objVal];
|
11121
|
+
}
|
11122
|
+
} else {
|
11123
|
+
objAry = obj[propName] = [];
|
11124
|
+
}
|
11125
|
+
// objAry is guaranteed to be an array at this point
|
11278
11126
|
|
11279
|
-
|
11127
|
+
if(Array.isArray(ary)) {
|
11128
|
+
if(ary.length) {
|
11129
|
+
if(ary.length > 1) {
|
11130
|
+
Array.prototype.push.apply(objAry, ary);
|
11131
|
+
} else {
|
11132
|
+
objAry.push(ary[0]);
|
11133
|
+
}
|
11134
|
+
}
|
11135
|
+
} else {
|
11136
|
+
objAry.push(ary);
|
11137
|
+
}
|
11280
11138
|
}
|
11139
|
+
return objAry;
|
11281
11140
|
};
|
11282
11141
|
|
11283
|
-
/**
|
11284
|
-
|
11285
|
-
|
11286
|
-
|
11287
|
-
|
11288
|
-
|
11289
|
-
*/
|
11290
|
-
LayoutGrid.prototype._updateCellSpan = function (indexX, indexY, cellSpan, adding) {
|
11291
|
-
this._updateCellSpanSize(indexX, indexY, adding ? cellSpan : null);
|
11292
|
-
this._updateCellSpanClass(indexX, indexY, cellSpan.colSpan, cellSpan.rowSpan, adding);
|
11142
|
+
/** @private
|
11143
|
+
* @param {string|Array.<string>} item
|
11144
|
+
* @return {string}
|
11145
|
+
*/
|
11146
|
+
var _encloseBracket = function(item) {
|
11147
|
+
return Array.isArray(item) ? "{\n" + item.join("\n") + "\n}" : item;
|
11293
11148
|
};
|
11294
|
-
|
11295
|
-
|
11296
|
-
|
11297
|
-
|
11298
|
-
|
11299
|
-
|
11300
|
-
|
11301
|
-
|
11302
|
-
|
11303
|
-
|
11304
|
-
|
11305
|
-
|
11306
|
-
|
11307
|
-
|
11308
|
-
|
11309
|
-
|
11310
|
-
|
11149
|
+
/** @private
|
11150
|
+
* @param {string} str
|
11151
|
+
* @return {string}
|
11152
|
+
*/
|
11153
|
+
var _indentBracketContent = function(str){
|
11154
|
+
return str.replace(/\n+/g, "\n\t").replace(/\n\t}$/, "\n}");
|
11155
|
+
};
|
11156
|
+
/** @public
|
11157
|
+
* @param {string|Array} css
|
11158
|
+
* @return {string} prettified CSS string
|
11159
|
+
* @example
|
11160
|
+
* prettifyCss(["div", [
|
11161
|
+
* "color: red;",
|
11162
|
+
* "padding: 20px;"
|
11163
|
+
* ],
|
11164
|
+
* ".class", [
|
11165
|
+
* "margin: 0;"
|
11166
|
+
* ]
|
11167
|
+
* ]);
|
11168
|
+
*/
|
11169
|
+
var prettifyCss = function(css) {
|
11170
|
+
if(css) {
|
11171
|
+
var cssStr = "";
|
11172
|
+
if (Array.isArray(css)) {
|
11173
|
+
var ary = css.map(_encloseBracket);
|
11174
|
+
cssStr = ary.join("\n").replace(/{\s*{/g, "{").replace(/\s+{/g, " {");
|
11175
|
+
} else {
|
11176
|
+
cssStr = (typeof css === "string") ? css : css + "";
|
11311
11177
|
}
|
11312
11178
|
|
11313
|
-
|
11314
|
-
|
11315
|
-
|
11316
|
-
var cell = this._getCell(indexX, indexY);
|
11317
|
-
|
11318
|
-
if (cell) {
|
11319
|
-
cell._colSpan = (adding) ? colSpan : 1;
|
11320
|
-
cell._rowSpan = (adding) ? rowSpan : 1; // For quick rendering
|
11179
|
+
if(cssStr) {
|
11180
|
+
return cssStr.replace(/{[\w\W]*?}/g, _indentBracketContent);
|
11181
|
+
}
|
11321
11182
|
}
|
11183
|
+
return "";
|
11322
11184
|
};
|
11323
|
-
|
11324
|
-
|
11325
|
-
|
11326
|
-
|
11327
|
-
|
11328
|
-
|
11329
|
-
|
11330
|
-
|
11331
|
-
|
11332
|
-
|
11333
|
-
|
11334
|
-
|
11335
|
-
|
11185
|
+
/** Get shadow root of the given element regardless of whether the element is in the DOM or not. The immediate shadow root parent is returned in case of nested shadow roots. Any other case return null.
|
11186
|
+
* @public
|
11187
|
+
* @param {Element} elem
|
11188
|
+
* @return {DocumentFragment}
|
11189
|
+
*/
|
11190
|
+
var getShadowRoot = function(elem) {
|
11191
|
+
if(elem) {
|
11192
|
+
var rootNode;
|
11193
|
+
if(elem.shadowRoot) {
|
11194
|
+
rootNode = elem.shadowRoot;
|
11195
|
+
} else if(elem.getRootNode) {
|
11196
|
+
rootNode = elem.getRootNode();
|
11197
|
+
}
|
11198
|
+
if(rootNode) { // getRootNode does not supported in IE. It should be implemented by the polyfills
|
11199
|
+
if(rootNode !== document) { // element that is in the DOM and not in the shadow has document as its root node
|
11200
|
+
if(rootNode !== elem) { // element that is NOT in the DOM and not in the shadow has itself as its root node
|
11201
|
+
return rootNode;
|
11202
|
+
}
|
11203
|
+
}
|
11204
|
+
}
|
11336
11205
|
}
|
11206
|
+
return null;
|
11337
11207
|
};
|
11338
|
-
|
11339
|
-
|
11340
|
-
|
11341
|
-
|
11342
|
-
|
11343
|
-
|
11344
|
-
|
11345
|
-
|
11346
|
-
|
11347
|
-
var colIndex = this._stretchedCells.getColumnIndex(cellElement);
|
11348
|
-
if(colIndex < 0) { // Not found colIndex in stretching cell, then get from normal row
|
11349
|
-
var colElement = util.closestElement(target, "column");
|
11350
|
-
colIndex = this.getColumnIndex(colElement);
|
11208
|
+
/** Attach style tag to the proper document (in case of element inside a shadow root)
|
11209
|
+
* @public
|
11210
|
+
* @param {string} cssStr Valid CSS string (e.g. "div {color: red;}")
|
11211
|
+
* @param {Element=} targetContext Element that needs the CSS
|
11212
|
+
* @return {Element} New style tag
|
11213
|
+
*/
|
11214
|
+
var injectCss = function(cssStr, targetContext) {
|
11215
|
+
if(!cssStr) {
|
11216
|
+
return null;
|
11351
11217
|
}
|
11352
|
-
var rowIndex = this.getCellIndex(colIndex, cellElement);
|
11353
|
-
|
11354
|
-
this.setRowHighlight(rowIndex);
|
11355
|
-
};
|
11356
|
-
|
11357
|
-
/**
|
11358
|
-
* @private
|
11359
|
-
* @param {Object} e
|
11360
|
-
*/
|
11361
|
-
LayoutGrid.prototype._onMouseOut = function (e) {
|
11362
|
-
var rel = e.relatedTarget;
|
11363
11218
|
|
11364
|
-
|
11365
|
-
|
11219
|
+
var styleTag = document.createElement("style");
|
11220
|
+
styleTag.textContent = "\n" + cssStr + "\n";
|
11366
11221
|
|
11367
|
-
|
11368
|
-
|
11222
|
+
var styleHost = getShadowRoot(targetContext);
|
11223
|
+
var isInShadow = true;
|
11224
|
+
if(!styleHost) {
|
11225
|
+
isInShadow = false;
|
11226
|
+
styleHost = document.head;
|
11227
|
+
}
|
11369
11228
|
|
11370
|
-
|
11371
|
-
|
11372
|
-
|
11229
|
+
// Find a place to insert the style tag
|
11230
|
+
var beforeElem;
|
11231
|
+
if(isInShadow) {
|
11232
|
+
if(styleHost.children && styleHost.children.length) {
|
11233
|
+
beforeElem = styleHost.children[0];
|
11373
11234
|
}
|
11374
11235
|
}
|
11375
|
-
|
11376
|
-
|
11377
|
-
}
|
11378
|
-
|
11379
|
-
|
11380
|
-
|
11381
|
-
* @param {number} rowIndex
|
11382
|
-
*/
|
11383
|
-
LayoutGrid.prototype._updateSelectionUI = function (rowIndex) { // Update UI of the specified row index
|
11384
|
-
var selected = this._selectionList.getSelection(rowIndex);
|
11385
|
-
this._enableStretchCellClass(rowIndex, "selected-row", selected);
|
11386
|
-
this.enableRowClass(rowIndex, "selected-row", selected);
|
11236
|
+
if(beforeElem) {
|
11237
|
+
styleHost.insertBefore(styleTag, beforeElem);
|
11238
|
+
} else {
|
11239
|
+
styleHost.appendChild(styleTag);
|
11240
|
+
}
|
11241
|
+
return styleTag;
|
11387
11242
|
};
|
11388
11243
|
|
11389
|
-
/**
|
11390
|
-
* @
|
11244
|
+
/** return true if browser is IE or Edge
|
11245
|
+
* @public
|
11246
|
+
* @return {boolean}
|
11391
11247
|
*/
|
11392
|
-
|
11393
|
-
|
11394
|
-
|
11248
|
+
var isIE = function () {
|
11249
|
+
var ua = window.navigator.userAgent;
|
11250
|
+
return (ua.indexOf('MSIE ') > 0) || (ua.indexOf('Trident/') > 0) || (ua.indexOf('Edge/') > 0);
|
11395
11251
|
};
|
11396
11252
|
|
11397
|
-
/**
|
11398
|
-
|
11399
|
-
|
11400
|
-
|
11401
|
-
|
11402
|
-
|
11403
|
-
this.enableRowClass(rowIndex, "selected-row", false);
|
11253
|
+
/** return true if device is mac
|
11254
|
+
* @public
|
11255
|
+
* @return {boolean}
|
11256
|
+
*/
|
11257
|
+
var isMac = function () {
|
11258
|
+
return /Mac/.test(navigator.platform);
|
11404
11259
|
};
|
11405
11260
|
|
11406
|
-
/**
|
11407
|
-
|
11408
|
-
|
11409
|
-
|
11410
|
-
|
11411
|
-
if (
|
11412
|
-
|
11413
|
-
|
11414
|
-
}
|
11415
|
-
|
11416
|
-
this._syncLayoutToColumns(0);
|
11417
|
-
this._initialized = true;
|
11261
|
+
/** Return true if device is mac
|
11262
|
+
* @public
|
11263
|
+
* @return {boolean}
|
11264
|
+
*/
|
11265
|
+
var isTouchDevice = function () {
|
11266
|
+
if ((navigator["maxTouchPoints"] && navigator["maxTouchPoints"] < 256) ||
|
11267
|
+
(navigator["msMaxTouchPoints"] && navigator["msMaxTouchPoints"] < 256)) {
|
11268
|
+
return true;
|
11418
11269
|
}
|
11270
|
+
return false;
|
11419
11271
|
};
|
11420
11272
|
|
11421
|
-
/**
|
11422
|
-
* @
|
11423
|
-
* @param {
|
11273
|
+
/** parse nested object in to array
|
11274
|
+
* @public
|
11275
|
+
* @param {Object} obj
|
11276
|
+
* @param {Array=} ary
|
11277
|
+
* @return {Array}
|
11424
11278
|
*/
|
11425
|
-
|
11426
|
-
|
11279
|
+
var nestedObjectToArray = function (obj, ary) {
|
11280
|
+
if (!ary) {
|
11281
|
+
ary = [];
|
11282
|
+
}
|
11283
|
+
for (var key in obj) {
|
11284
|
+
var element = obj[key];
|
11285
|
+
if ('object' === typeof element) {
|
11286
|
+
nestedObjectToArray(element, ary);
|
11287
|
+
} else {
|
11288
|
+
ary.push(element);
|
11289
|
+
}
|
11290
|
+
}
|
11291
|
+
return ary;
|
11427
11292
|
};
|
11428
11293
|
|
11429
|
-
/**
|
11430
|
-
* @
|
11431
|
-
* @
|
11294
|
+
/** Convert CSS rgb or rgba formats to CSS hex color string (# prefix)
|
11295
|
+
* @public
|
11296
|
+
* @param {string} rgbCode
|
11297
|
+
* @return {string}
|
11298
|
+
* @example
|
11299
|
+
* rgb2Hex("rgb(255, 255, 0)"); // "#FFFF00"
|
11300
|
+
* rgb2Hex("rgba(255, 255, 0, 1)"); // "#FFFF00"
|
11301
|
+
* rgb2Hex("255 255.0"); // "#FFFF00"
|
11302
|
+
* rgb2Hex("#FFFF00"); // "#FFFF00"
|
11303
|
+
* rgb2Hex("#1a1a1a"); // "#1a1a1a"
|
11304
|
+
* rgb2Hex("2552550"); // "2552550"
|
11305
|
+
* rgb2Hex("invalid"); // "invalid"
|
11306
|
+
* rgb2Hex(null); // ""
|
11432
11307
|
*/
|
11433
|
-
|
11434
|
-
|
11435
|
-
|
11308
|
+
var rgb2Hex = function (rgbCode) {
|
11309
|
+
if(!rgbCode || typeof rgbCode !== "string") {
|
11310
|
+
return "";
|
11311
|
+
}
|
11312
|
+
if(rgbCode.charAt(0) === "#") {
|
11313
|
+
return rgbCode;
|
11314
|
+
}
|
11315
|
+
var rgb = rgbCode.match(/\d+/g);
|
11316
|
+
if(!rgb || rgb.length < 3) {
|
11317
|
+
return rgbCode;
|
11318
|
+
}
|
11436
11319
|
|
11437
|
-
|
11438
|
-
|
11439
|
-
|
11440
|
-
|
11441
|
-
|
11442
|
-
if(!this._transformIETimer) {
|
11443
|
-
this.enableClass("reset-transform");
|
11444
|
-
this._transformIETimer = setTimeout(this._onResetTransformIE, 20);
|
11320
|
+
var hex = "#";
|
11321
|
+
for(var i = 0; i < 3; i++) {
|
11322
|
+
var num = +rgb[i];
|
11323
|
+
if(!(num >= 16)) { // Handle NaN case
|
11324
|
+
hex += "0";
|
11445
11325
|
}
|
11326
|
+
hex += (num) ? num.toString(16).toUpperCase() : "0";
|
11446
11327
|
}
|
11328
|
+
return hex;
|
11447
11329
|
};
|
11448
|
-
|
11330
|
+
|
11331
|
+
/** transform data to tab seperated value
|
11332
|
+
* @public
|
11333
|
+
* @param {*} data
|
11334
|
+
* @return {string}
|
11449
11335
|
*/
|
11450
|
-
|
11451
|
-
|
11452
|
-
|
11453
|
-
}
|
11336
|
+
var prepareTSVContent = function (data) {
|
11337
|
+
if (data == null) {
|
11338
|
+
return "";
|
11339
|
+
}
|
11454
11340
|
|
11455
|
-
|
11341
|
+
var content = (typeof data === 'string') ? data : data.toString();
|
11456
11342
|
|
11457
|
-
|
11343
|
+
if (!content.length) { return ""; }
|
11344
|
+
|
11345
|
+
// Replace any new line and tab
|
11346
|
+
if (content.indexOf("\n") >= 0) {
|
11347
|
+
content = content.replace(/[\r\n]/g, " ");
|
11348
|
+
}
|
11349
|
+
|
11350
|
+
if (content.indexOf("\t") >= 0) {
|
11351
|
+
content = content.replace(/\t/g, " ");
|
11352
|
+
}
|
11353
|
+
|
11354
|
+
// Trim front and back spaces
|
11355
|
+
if (content.charAt(0) === " " || content.charAt(content.length - 1) === " ") {
|
11356
|
+
content = content.trim();
|
11357
|
+
}
|
11358
|
+
|
11359
|
+
return content;
|
11360
|
+
};
|
11361
|
+
|
11362
|
+
/* harmony default export */ const es6_Util = ((/* unused pure expression or super */ null && (Util_Util)));
|
11458
11363
|
|
11459
11364
|
|
11460
|
-
// EXTERNAL MODULE: ./node_modules/tr-grid-util/es6/Util.js
|
11461
|
-
var es6_Util = __webpack_require__(869);
|
11462
11365
|
;// CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/GroupDefinitions.js
|
11463
11366
|
|
11464
11367
|
|
@@ -11552,7 +11455,7 @@ GroupDefinitions.getLeafDescendants = function (groupMap, groupId) {
|
|
11552
11455
|
* @return {Object}
|
11553
11456
|
*/
|
11554
11457
|
GroupDefinitions._cloneObject = function(obj) {
|
11555
|
-
var newObj =
|
11458
|
+
var newObj = cloneObject(obj);
|
11556
11459
|
if(Array.isArray(newObj.children)) {
|
11557
11460
|
newObj.children = newObj.children;
|
11558
11461
|
} else {
|
@@ -25443,6 +25346,7 @@ var Core_Core = function (opt_initializer) {
|
|
25443
25346
|
|
25444
25347
|
_t._onMouseMove = _t._onMouseMove.bind(_t);
|
25445
25348
|
_t._onRowHightlighted = _t._onRowHightlighted.bind(_t);
|
25349
|
+
_t._onGridClicked = _t._onGridClicked.bind(_t);
|
25446
25350
|
|
25447
25351
|
_t._onWindowResize = _t._onWindowResize.bind(_t);
|
25448
25352
|
_t._onSectionDataChanged = _t._onSectionDataChanged.bind(_t);
|
@@ -25528,11 +25432,16 @@ var Core_Core = function (opt_initializer) {
|
|
25528
25432
|
_t._hscrollbar.setOtherScrollbar(_t._vscrollbar);
|
25529
25433
|
_t._vscrollbar.setOtherScrollbar(_t._hscrollbar);
|
25530
25434
|
|
25531
|
-
if (util.isMobile) {
|
25435
|
+
if (util.isMobile || util.isTouchDevice) {
|
25532
25436
|
_t._element.addEventListener("touchmove", this._onMouseMove, false);
|
25533
25437
|
} else {
|
25534
25438
|
_t._element.addEventListener("mousemove", this._onMouseMove, false);
|
25535
25439
|
}
|
25440
|
+
|
25441
|
+
if(util.isSafari){
|
25442
|
+
_t._element.addEventListener("click", this._onGridClicked);
|
25443
|
+
}
|
25444
|
+
|
25536
25445
|
window.addEventListener("resize", _t._onWindowResize, false); // Should be unlistened after destroyed
|
25537
25446
|
_t._rowVirtualizer.listen("indexChanged", _t._onRowInViewChanged);
|
25538
25447
|
_t._colVirtualizer.listen("indexChanged", _t._onColInViewChanged);
|
@@ -25917,7 +25826,7 @@ Core_Core.prototype._batches = null;
|
|
25917
25826
|
* @return {string}
|
25918
25827
|
*/
|
25919
25828
|
Core_Core.getVersion = function () {
|
25920
|
-
return "5.1.
|
25829
|
+
return "5.1.63";
|
25921
25830
|
};
|
25922
25831
|
/** {@link ElementWrapper#dispose}
|
25923
25832
|
* @override
|
@@ -29772,6 +29681,53 @@ Core_Core.prototype.getColumnGroupChildIds = function (groupId) {
|
|
29772
29681
|
return null;
|
29773
29682
|
};
|
29774
29683
|
|
29684
|
+
/** @public
|
29685
|
+
* @description Get a list of objects with column id and column index in sorted order
|
29686
|
+
* @param {Array.<string>} colIds
|
29687
|
+
* @param {Object=} columnMap
|
29688
|
+
* @return {!Array.<string>} Return column array with corresponding order to UI
|
29689
|
+
* @example
|
29690
|
+
* core.getValidColumnList(["c1","c2","c5"]); // Get list of valid columns
|
29691
|
+
* core.getValidColumnList(["c1","c2","c5"],{ "c2":true, "c5":true }); // Get list of valid columns from specific mapping
|
29692
|
+
*/
|
29693
|
+
Core_Core.prototype.getValidColumnList = function (colIds, columnMap) {
|
29694
|
+
var colList = [];
|
29695
|
+
if(!colIds){
|
29696
|
+
return colList;
|
29697
|
+
}
|
29698
|
+
if(!columnMap){
|
29699
|
+
columnMap = this.createColumnMap(colIds);
|
29700
|
+
}
|
29701
|
+
var colCount = this.getColumnCount();
|
29702
|
+
for(var c = 0; c < colCount; ++c) {
|
29703
|
+
var id = this._getColumnDef(c)["id"];
|
29704
|
+
if(columnMap[id] != null){
|
29705
|
+
colList.push({"index": c, "id": id});
|
29706
|
+
}
|
29707
|
+
}
|
29708
|
+
return colList;
|
29709
|
+
};
|
29710
|
+
|
29711
|
+
/** @public
|
29712
|
+
* @description Create mapping object from an array of strings
|
29713
|
+
* @param {Array.<string>=} colIds
|
29714
|
+
* @return {!Object} Column mapping object
|
29715
|
+
*/
|
29716
|
+
Core_Core.prototype.createColumnMap = function (colIds) {
|
29717
|
+
if(!colIds){
|
29718
|
+
colIds = this.getColumnIds();
|
29719
|
+
}
|
29720
|
+
var mappingObj = {};
|
29721
|
+
var count = colIds.length;
|
29722
|
+
for(var i = 0; i < count; i++){
|
29723
|
+
var colId = colIds[i];
|
29724
|
+
if(colId){
|
29725
|
+
mappingObj[colId] = true;
|
29726
|
+
}
|
29727
|
+
}
|
29728
|
+
return mappingObj;
|
29729
|
+
};
|
29730
|
+
|
29775
29731
|
/** @public
|
29776
29732
|
* @param {string} batchType
|
29777
29733
|
* @return {boolean}
|
@@ -29800,7 +29756,7 @@ Core_Core.prototype.stopBatch = function (batchType) {
|
|
29800
29756
|
this._dispatch("afterBatchOperation", { batches: this._batches, batchType: batchType });
|
29801
29757
|
|
29802
29758
|
delete this._batches[batchType];
|
29803
|
-
if(
|
29759
|
+
if(isEmptyObject(this._batches)){
|
29804
29760
|
this._batches = null;
|
29805
29761
|
}
|
29806
29762
|
return true;
|
@@ -30611,6 +30567,18 @@ Core_Core.prototype._onMouseMove = function () {
|
|
30611
30567
|
this._vscrollbar.flash();
|
30612
30568
|
this._hscrollbar.flash();
|
30613
30569
|
};
|
30570
|
+
/** @private */
|
30571
|
+
Core_Core.prototype._onGridClicked = function () {
|
30572
|
+
// research for dragging
|
30573
|
+
var selection = window.getSelection();
|
30574
|
+
if(selection.toString()){
|
30575
|
+
return;
|
30576
|
+
}
|
30577
|
+
var activeElem = document.activeElement;
|
30578
|
+
if(!this._element.contains(activeElem)){
|
30579
|
+
this.focus();
|
30580
|
+
}
|
30581
|
+
};
|
30614
30582
|
|
30615
30583
|
/** @private
|
30616
30584
|
* @param {Object} e
|
@@ -31288,8 +31256,9 @@ es6_Ext.inherits(SortableTitlePlugin, event_EventDispatcher);
|
|
31288
31256
|
|
31289
31257
|
/** The sorting object which will be used for initialSort config.
|
31290
31258
|
* @typedef {Object} SortableTitlePlugin~InitialSort
|
31291
|
-
* @property {number} colIndex Index of the column
|
31292
|
-
* @property {string}
|
31259
|
+
* @property {number=} colIndex Index of the column
|
31260
|
+
* @property {string=} colId column id of the column
|
31261
|
+
* @property {string=} field field of the column
|
31293
31262
|
* @property {SortableTitlePlugin~SortOrder=} sortOrder=null Set to "d" for descending order and "a" for ascending order
|
31294
31263
|
* @property {SortableTitlePlugin~SortOrder=} order Alias of sortOrder
|
31295
31264
|
*/
|
@@ -31751,7 +31720,7 @@ SortableTitlePlugin.prototype.getConfigObject = function (gridOptions) {
|
|
31751
31720
|
extOptions["sortingSequence"] = sortingSeq.slice();
|
31752
31721
|
}
|
31753
31722
|
|
31754
|
-
if(
|
31723
|
+
if(isEmptyObject(obj["sorting"])) {
|
31755
31724
|
delete obj["sorting"];
|
31756
31725
|
}
|
31757
31726
|
|
@@ -31947,6 +31916,7 @@ SortableTitlePlugin.prototype.getSortedColumns = function () {
|
|
31947
31916
|
var state = this._sortStates[i];
|
31948
31917
|
arr[i] = {
|
31949
31918
|
"colIndex": colIndex,
|
31919
|
+
"colId": this._getColumnId(colIndex),
|
31950
31920
|
"field": state["field"] || "",
|
31951
31921
|
"sortOrder": state["sortOrder"] || "n"
|
31952
31922
|
};
|
@@ -31988,7 +31958,7 @@ SortableTitlePlugin.prototype.sortColumns = function (sortOptions, opt_arg) {
|
|
31988
31958
|
var opt = sortOptions[i];
|
31989
31959
|
var colRef = opt["colIndex"];
|
31990
31960
|
if(colRef < 0 || colRef == null) {
|
31991
|
-
colRef = opt["field"];
|
31961
|
+
colRef = opt["colId"] || opt["field"];
|
31992
31962
|
}
|
31993
31963
|
var state = this._prepareSorting(
|
31994
31964
|
colRef,
|
@@ -32575,19 +32545,9 @@ SortableTitlePlugin.prototype._prepareSorting = function (colRef, sortOrder) {
|
|
32575
32545
|
return null;
|
32576
32546
|
}
|
32577
32547
|
|
32578
|
-
var colIndex =
|
32579
|
-
var
|
32580
|
-
var
|
32581
|
-
if(typeof colRef === "number") {
|
32582
|
-
colIndex = colRef;
|
32583
|
-
field = this.getColumnSortingField(colIndex);
|
32584
|
-
priority = this.getSortPriority(colIndex);
|
32585
|
-
} else if(typeof colRef === "string") {
|
32586
|
-
field = colRef;
|
32587
|
-
colIndex = this._getColumnIndexByField(field);
|
32588
|
-
var fields = this.getColumnSortingFields();
|
32589
|
-
priority = fields.indexOf(field);
|
32590
|
-
}
|
32548
|
+
var colIndex = this._getColumnIndex(colRef);
|
32549
|
+
var priority = this.getSortPriority(colIndex);
|
32550
|
+
var field = this.getColumnSortingField(colIndex);
|
32591
32551
|
|
32592
32552
|
var curState = (priority >= 0) ? this._sortStates[priority] : null;
|
32593
32553
|
var curOrder = curState ? curState["sortOrder"] : "n";
|
@@ -32971,21 +32931,29 @@ SortableTitlePlugin.prototype._getColumnIndexByOptions = function (sortOptions)
|
|
32971
32931
|
return -1;
|
32972
32932
|
};
|
32973
32933
|
/** @private
|
32974
|
-
* @param {string}
|
32934
|
+
* @param {string|number} colRef
|
32975
32935
|
* @return {number}
|
32976
32936
|
*/
|
32977
|
-
SortableTitlePlugin.prototype.
|
32978
|
-
|
32979
|
-
|
32980
|
-
|
32981
|
-
for (var c = 0; c < colCount; ++c) {
|
32982
|
-
if(field === this.getColumnSortingField(c)) {
|
32983
|
-
return c;
|
32984
|
-
}
|
32985
|
-
}
|
32937
|
+
SortableTitlePlugin.prototype._getColumnIndex = function (colRef) {
|
32938
|
+
var host = this._hosts[0];
|
32939
|
+
if(host && colRef != null) {
|
32940
|
+
return host.getColumnIndex(colRef);
|
32986
32941
|
}
|
32987
32942
|
return -1;
|
32988
32943
|
};
|
32944
|
+
|
32945
|
+
/** @private
|
32946
|
+
* @param {string|number} colRef
|
32947
|
+
* @return {string} column id or empty string for not found
|
32948
|
+
*/
|
32949
|
+
SortableTitlePlugin.prototype._getColumnId = function (colRef) {
|
32950
|
+
var host = this._hosts[0];
|
32951
|
+
if(host && colRef != null) {
|
32952
|
+
return host.getColumnId(colRef);
|
32953
|
+
}
|
32954
|
+
return "";
|
32955
|
+
};
|
32956
|
+
|
32989
32957
|
/** @private
|
32990
32958
|
* @param {number} colIndex
|
32991
32959
|
* @return {Object}
|
@@ -33147,7 +33115,5 @@ grid.SortableTitlePlugin = plugins_SortableTitlePlugin;
|
|
33147
33115
|
|
33148
33116
|
/* harmony default export */ const src = ((/* unused pure expression or super */ null && (Core)));
|
33149
33117
|
|
33150
|
-
})();
|
33151
|
-
|
33152
33118
|
/******/ })()
|
33153
33119
|
;
|