@progress/kendo-spreadsheet-common 1.1.3-develop.1 → 1.1.3-develop.3

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/index.js CHANGED
@@ -1166,66 +1166,36 @@
1166
1166
  }
1167
1167
  }
1168
1168
 
1169
- const wrapExpression = function(members, paramName) {
1170
- let result = paramName || "d",
1171
- index,
1172
- idx,
1173
- length,
1174
- member,
1175
- count = 1;
1176
-
1177
- for (idx = 0, length = members.length; idx < length; idx++) {
1178
- member = members[idx];
1179
- if (member !== "") {
1180
- index = member.indexOf("[");
1181
-
1182
- if (index !== 0) {
1183
- if (index === -1) {
1184
- member = "." + member;
1185
- } else {
1186
- count++;
1187
- member = "." + member.substring(0, index) + " || {})" + member.substring(index);
1188
- }
1189
- }
1190
-
1191
- count++;
1192
- result += member + ((idx < length - 1) ? " || {})" : ")");
1193
- }
1194
- }
1195
- return new Array(count).join("(") + result;
1196
- };
1197
-
1198
1169
  const getterCache = {};
1199
1170
 
1200
- function expr(expression, safe, paramName) {
1201
- expression = expression || "";
1202
-
1203
- if (typeof safe == 'string') {
1204
- paramName = safe;
1205
- safe = false;
1206
- }
1171
+ getterCache["undefined"] = (obj) => obj;
1207
1172
 
1208
- paramName = paramName || "d";
1173
+ const FIELD_REGEX = /\[(?:(\d+)|['"](.*?)['"])\]|((?:(?!\[.*?\]|\.).)+)/g;
1174
+ function getter(field, safe) {
1175
+ const key = field + safe;
1209
1176
 
1210
- if (expression && expression.charAt(0) !== "[") {
1211
- expression = "." + expression;
1177
+ if (getterCache[key]) {
1178
+ return getterCache[key];
1212
1179
  }
1213
1180
 
1214
- if (safe) {
1215
- expression = expression.replace(/"([^.]*)\.([^"]*)"/g,'"$1_$DOT$_$2"');
1216
- expression = expression.replace(/'([^.]*)\.([^']*)'/g,"'$1_$DOT$_$2'");
1217
- expression = wrapExpression(expression.split("."), paramName);
1218
- expression = expression.replace(/_\$DOT\$_/g, ".");
1219
- } else {
1220
- expression = paramName + expression;
1221
- }
1181
+ const fields = [];
1182
+ field.replace(FIELD_REGEX, (_, index, indexAccessor, field) => {
1183
+ fields.push(isPresent(index) ? index : indexAccessor || field);
1184
+ return undefined;
1185
+ });
1222
1186
 
1223
- return expression;
1224
- }
1187
+ getterCache[key] = (obj) => {
1188
+ let result = obj;
1189
+ for (let idx = 0; idx < fields.length; idx++) {
1190
+ result = result[fields[idx]];
1191
+ if (!isPresent(result) && safe) {
1192
+ return result;
1193
+ }
1194
+ }
1195
+
1196
+ return result;
1197
+ };
1225
1198
 
1226
- function getter(expression, safe) {
1227
- let key = expression + safe;
1228
- getterCache[key] = getterCache[key] || new Function("d", "return " + expr(expression, safe));
1229
1199
  return getterCache[key];
1230
1200
  }
1231
1201
 
@@ -1240,10 +1210,6 @@
1240
1210
  return destination;
1241
1211
  }
1242
1212
 
1243
- function isFunction(fn) {
1244
- return typeof fn === "function";
1245
- }
1246
-
1247
1213
  function deepExtendOne(destination, source) {
1248
1214
  let property,
1249
1215
  propValue,
@@ -1317,7 +1283,12 @@
1317
1283
  let div = document.createElement("div"),
1318
1284
  result;
1319
1285
 
1320
- div.style.cssText = "overflow:scroll;overflow-x:hidden;zoom:1;clear:both;display:block";
1286
+ div.style.overflow = "scroll";
1287
+ div.style.overflowX = "hidden";
1288
+ div.style.zoom = "1";
1289
+ div.style.clear = "both";
1290
+ div.style.display = "block";
1291
+
1321
1292
  div.innerHTML = "&nbsp;";
1322
1293
  document.body.appendChild(div);
1323
1294
 
@@ -1392,6 +1363,13 @@
1392
1363
  }
1393
1364
  };
1394
1365
 
1366
+ const isPresent = (value) => value !== null && value !== undefined;
1367
+ const isBlank = (value) => !isPresent(value);
1368
+ const isDate = (value) => value && value.getTime;
1369
+ const isString = (value) => typeof value === "string";
1370
+ const isNumeric = (value) => !isNaN(value - parseFloat(value));
1371
+ const isFunction = (fn) => typeof fn === "function";
1372
+
1395
1373
  class CalcError {
1396
1374
 
1397
1375
  constructor(code) {
@@ -2486,13 +2464,13 @@
2486
2464
  }
2487
2465
  }
2488
2466
 
2489
- function limitPrecision$1(num) {
2490
- return num === parseInt(num, 10) ? num : +num.toPrecision(16);
2467
+ function limitPrecision$1(num, digits) {
2468
+ return num === parseInt(num, 10) ? num : +num.toPrecision(digits || 16);
2491
2469
  }
2492
2470
 
2493
- function maybeRoundFloatErrors(num) {
2471
+ function maybeRoundFloatErrors(num, digits) {
2494
2472
  if (typeof num == "number") {
2495
- return limitPrecision$1(num);
2473
+ return limitPrecision$1(num, digits);
2496
2474
  } else {
2497
2475
  return num;
2498
2476
  }
@@ -5651,6 +5629,10 @@
5651
5629
  // try global name
5652
5630
  val = this.workbook.nameValue(this._displayString(ref.name));
5653
5631
  }
5632
+ if (val == null) {
5633
+ // try without _displayString
5634
+ val = this.workbook.nameValue(ref.print()) || this.workbook.nameValue(ref.name);
5635
+ }
5654
5636
  }
5655
5637
  if (val instanceof Ref) {
5656
5638
  val = val.absolute(frow, fcol);
@@ -8869,6 +8851,7 @@
8869
8851
  sheet._set(ref, propName, propValue);
8870
8852
  };
8871
8853
 
8854
+ let isValue = false;
8872
8855
  for (ci = topLeftCol; ci <= bottomRightCol; ci ++) {
8873
8856
  if (!isAutofill && sheet.isHiddenColumn(ci)) {
8874
8857
  continue;
@@ -8884,12 +8867,14 @@
8884
8867
  if (row) {
8885
8868
  data = row[ci - topLeftCol];
8886
8869
  if (data) {
8887
- Object.keys(data).forEach(setProp);
8870
+ const keys = Object.keys(data);
8871
+ keys.forEach(setProp);
8872
+ isValue = isValue || keys.includes("value");
8888
8873
  }
8889
8874
  }
8890
8875
  }
8891
8876
  }
8892
- sheet.triggerChange({ recalc: true, ref: this._ref });
8877
+ sheet.triggerChange({ recalc: true, ref: this._ref, isValue: isValue });
8893
8878
  return this;
8894
8879
  }
8895
8880
  }
@@ -8902,7 +8887,8 @@
8902
8887
 
8903
8888
  let reason = {
8904
8889
  recalc: clearAll || options.contentsOnly,
8905
- ref: this._ref
8890
+ ref: this._ref,
8891
+ isValue: true
8906
8892
  };
8907
8893
 
8908
8894
  sheet.batch(function() {
@@ -9399,13 +9385,18 @@
9399
9385
 
9400
9386
  function getTextHeight(text, width, fontFamily, fontSize, wrap) {
9401
9387
  const measureBox = document.createElement("div");
9402
- measureBox.setAttribute(
9403
- "style",
9404
- "position: absolute !important; top: -4000px !important; height: auto !important;" +
9405
- "padding: 1px 3px !important; box-sizing: border-box; margin: 0 !important; border: 1px solid black !important;" +
9406
- "line-height: normal !important; visibility: hidden !important;" +
9407
- "white-space: pre-wrap;"
9408
- );
9388
+
9389
+ measureBox.style.setProperty('position', 'absolute', 'important');
9390
+ measureBox.style.setProperty('top', '-4000px', 'important');
9391
+ measureBox.style.setProperty('height', 'auto', 'important');
9392
+ measureBox.style.setProperty('padding', '1px 3px', 'important');
9393
+ measureBox.style.setProperty('box-sizing', 'border-box', 'important');
9394
+ measureBox.style.setProperty('margin', '0', 'important');
9395
+ measureBox.style.setProperty('border', '1px solid black', 'important');
9396
+ measureBox.style.setProperty('line-height', 'normal', 'important');
9397
+ measureBox.style.setProperty('visibility', 'hidden', 'important');
9398
+ measureBox.style.setProperty('white-space', 'pre-wrap');
9399
+
9409
9400
  let styles = {
9410
9401
  "baselineMarkerSize" : 0,
9411
9402
  "width" : (wrap === true) ? width + "px" : "auto",
@@ -12120,210 +12111,131 @@
12120
12111
 
12121
12112
  /* eslint-disable no-var */
12122
12113
 
12123
- const dateRegExp = /^\/Date\((.*?)\)\/$/;
12114
+ const logic = {
12115
+ or: {
12116
+ concat: (acc, fn) => (a) => acc(a) || fn(a),
12117
+ identity: () => false,
12118
+ },
12119
+ and: {
12120
+ concat: (acc, fn) => (a) => acc(a) && fn(a),
12121
+ identity: () => true,
12122
+ },
12123
+ };
12124
+
12125
+ const operatorsMap = {
12126
+ contains: (a, b) => (a || "").indexOf(b) >= 0,
12127
+ doesnotcontain: (a, b) => (a || "").indexOf(b) === -1,
12128
+ doesnotendwith: (a, b) =>
12129
+ (a || "").indexOf(b, (a || "").length - (b || "").length) < 0,
12130
+ doesnotstartwith: (a, b) => (a || "").lastIndexOf(b, 0) === -1,
12131
+ endswith: (a, b) =>
12132
+ (a || "").indexOf(b, (a || "").length - (b || "").length) >= 0,
12133
+ eq: (a, b) => a === b,
12134
+ gt: (a, b) => a > b,
12135
+ gte: (a, b) => a >= b,
12136
+ isempty: (a) => a === "",
12137
+ isnotempty: (a) => a !== "",
12138
+ isnotnull: (a) => isPresent(a),
12139
+ isnull: (a) => isBlank(a),
12140
+ lt: (a, b) => a < b,
12141
+ lte: (a, b) => a <= b,
12142
+ neq: (a, b) => a != b, // tslint:disable-line:triple-equals
12143
+ startswith: (a, b) => (a || "").lastIndexOf(b, 0) === 0,
12144
+ };
12124
12145
 
12125
- var operators = (function() {
12146
+ const dateRegExp = /^\/Date\((.*?)\)\/$/;
12126
12147
 
12127
- function quote(str) {
12128
- if (typeof str == "string") {
12129
- str = str.replace(/[\r\n]+/g, "");
12148
+ const convertValue = (value, ignoreCase, accentFoldingFiltering) => {
12149
+ if (value != null && isString(value)) {
12150
+ const date = dateRegExp.exec(value);
12151
+ if (date) {
12152
+ return new Date(+date[1]).getTime();
12153
+ } else if (ignoreCase) {
12154
+ return accentFoldingFiltering
12155
+ ? value.toLocaleLowerCase(accentFoldingFiltering)
12156
+ : value.toLowerCase();
12130
12157
  }
12131
- return JSON.stringify(str);
12158
+ } else if (value != null && isDate(value)) {
12159
+ return value.getTime();
12132
12160
  }
12161
+ return value;
12162
+ };
12133
12163
 
12134
- function textOp(impl) {
12135
- return function(a, b, ignore, accentFoldingFiltering) {
12136
- b += "";
12137
- if (ignore) {
12138
- a = "(" + a + " + '').toString()" + ((accentFoldingFiltering) ? ".toLocaleLowerCase('" + accentFoldingFiltering + "')" : ".toLowerCase()");
12139
- b = ((accentFoldingFiltering) ? b.toLocaleLowerCase(accentFoldingFiltering) : b.toLowerCase());
12140
- }
12141
- return impl(a, quote(b), ignore);
12142
- };
12143
- }
12164
+ const transformFilter = ({
12165
+ field,
12166
+ ignoreCase,
12167
+ value,
12168
+ operator,
12169
+ accentFoldingFiltering,
12170
+ }) => {
12171
+ field = !isPresent(field) ? (a) => a : field;
12172
+
12173
+ ignoreCase = isPresent(ignoreCase) ? ignoreCase : true;
12174
+
12175
+ const itemProp = typedGetter(
12176
+ isFunction(field) ? field : getter(field, true),
12177
+ value,
12178
+ ignoreCase,
12179
+ accentFoldingFiltering
12180
+ );
12144
12181
 
12145
- function operator(op, a, b, ignore, accentFoldingFiltering) {
12146
- if (b != null) {
12147
- if (typeof b === 'string') {
12148
- var date = dateRegExp.exec(b);
12149
- if (date) {
12150
- b = new Date(+date[1]);
12151
- } else if (ignore) {
12152
- b = quote(((accentFoldingFiltering) ? b.toLocaleLowerCase(accentFoldingFiltering) : b.toLowerCase()));
12153
- a = "((" + a + " || '')+'')" + ((accentFoldingFiltering) ? ".toLocaleLowerCase('" + accentFoldingFiltering + "')" : ".toLowerCase()");
12154
- } else {
12155
- b = quote(b);
12156
- }
12157
- }
12182
+ value = convertValue(value, ignoreCase, accentFoldingFiltering);
12158
12183
 
12159
- if (b.getTime) {
12160
- //b looks like a Date
12161
- a = "(" + a + "&&" + a + ".getTime?" + a + ".getTime():" + a + ")";
12162
- b = b.getTime();
12163
- }
12164
- }
12184
+ const op = isFunction(operator) ? operator : operatorsMap[operator];
12165
12185
 
12166
- return a + " " + op + " " + b;
12167
- }
12186
+ return (a) => op(itemProp(a), value, ignoreCase);
12187
+ };
12168
12188
 
12169
- function getMatchRegexp(pattern) {
12170
- // take a pattern, as supported by Excel match filter, and
12171
- // convert it to the equivalent JS regular expression.
12172
- // Excel patterns support:
12173
- //
12174
- // * - match any sequence of characters
12175
- // ? - match a single character
12176
- //
12177
- // to match a literal * or ?, they must be prefixed by a tilde (~)
12178
- var rx = "/^";
12179
- for (var esc = false, i = 0; i < pattern.length; ++i) {
12180
- var ch = pattern.charAt(i);
12181
- if (esc) {
12182
- rx += "\\" + ch;
12183
- } else if (ch === "~") {
12184
- esc = true;
12185
- continue;
12186
- } else if (ch === "*") {
12187
- rx += ".*";
12188
- } else if (ch === "?") {
12189
- rx += ".";
12190
- } else if (".+^$()[]{}|\\/\n\r\u2028\u2029\xA0".indexOf(ch) >= 0) {
12191
- rx += "\\" + ch;
12192
- } else {
12193
- rx += ch;
12194
- }
12195
- esc = false;
12196
- }
12197
- return rx + "$/";
12189
+ const typedGetter = (prop, value, ignoreCase, accentFoldingFiltering) => {
12190
+ if (!isPresent(value)) {
12191
+ return prop;
12198
12192
  }
12199
12193
 
12200
- return {
12201
- quote: function(value) {
12202
- if (value && value.getTime) {
12203
- return "new Date(" + value.getTime() + ")";
12204
- }
12205
- return quote(value);
12206
- },
12207
- eq: function(a, b, ignore, accentFoldingFiltering) {
12208
- return operator("==", a, b, ignore, accentFoldingFiltering);
12209
- },
12210
- neq: function(a, b, ignore, accentFoldingFiltering) {
12211
- return operator("!=", a, b, ignore, accentFoldingFiltering);
12212
- },
12213
- gt: function(a, b, ignore) {
12214
- return operator(">", a, b, ignore);
12215
- },
12216
- gte: function(a, b, ignore) {
12217
- return operator(">=", a, b, ignore);
12218
- },
12219
- lt: function(a, b, ignore) {
12220
- return operator("<", a, b, ignore);
12221
- },
12222
- lte: function(a, b, ignore) {
12223
- return operator("<=", a, b, ignore);
12224
- },
12225
- startswith: textOp(function(a, b) {
12226
- return a + ".lastIndexOf(" + b + ", 0) == 0";
12227
- }),
12228
- doesnotstartwith: textOp(function(a, b) {
12229
- return a + ".lastIndexOf(" + b + ", 0) == -1";
12230
- }),
12231
- endswith: textOp(function(a, b) {
12232
- var n = b ? b.length - 2 : 0;
12233
- return a + ".indexOf(" + b + ", " + a + ".length - " + n + ") >= 0";
12234
- }),
12235
- doesnotendwith: textOp(function(a, b) {
12236
- var n = b ? b.length - 2 : 0;
12237
- return a + ".indexOf(" + b + ", " + a + ".length - " + n + ") < 0";
12238
- }),
12239
- contains: textOp(function(a, b) {
12240
- return a + ".indexOf(" + b + ") >= 0";
12241
- }),
12242
- doesnotcontain: textOp(function(a, b) {
12243
- return a + ".indexOf(" + b + ") == -1";
12244
- }),
12245
- matches: textOp(function(a, b) {
12246
- b = b.substring(1, b.length - 1);
12247
- return getMatchRegexp(b) + ".test(" + a + ")";
12248
- }),
12249
- doesnotmatch: textOp(function(a, b) {
12250
- b = b.substring(1, b.length - 1);
12251
- return "!" + getMatchRegexp(b) + ".test(" + a + ")";
12252
- }),
12253
- isempty: function(a) {
12254
- return a + " === ''";
12255
- },
12256
- isnotempty: function(a) {
12257
- return a + " !== ''";
12258
- },
12259
- isnull: function(a) {
12260
- return "(" + a + " == null)";
12261
- },
12262
- isnotnull: function(a) {
12263
- return "(" + a + " != null)";
12264
- },
12265
- isnullorempty: function(a) {
12266
- return "(" + a + " === null) || (" + a + " === '')";
12267
- },
12268
- isnotnullorempty: function(a) {
12269
- return "(" + a + " !== null) && (" + a + " !== '')";
12270
- }
12271
- };
12272
- })();
12273
-
12274
- const filterExpr = function(expression) {
12275
- var expressions = [],
12276
- logic = { and: " && ", or: " || " },
12277
- idx,
12278
- length,
12279
- filter,
12280
- expr$1,
12281
- fieldFunctions = [],
12282
- operatorFunctions = [],
12283
- field,
12284
- operator,
12285
- filters = expression.filters;
12286
-
12287
- for (idx = 0, length = filters.length; idx < length; idx++) {
12288
- filter = filters[idx];
12289
- field = filter.field;
12290
- operator = filter.operator;
12291
-
12292
- if (filter.filters) {
12293
- expr$1 = filterExpr(filter);
12294
- //Nested function fields or operators - update their index e.g. __o[0] -> __o[1]
12295
- filter = expr$1.expression
12296
- .replace(/__o\[(\d+)\]/g, function(match, index) {
12297
- index = +index;
12298
- return "__o[" + (operatorFunctions.length + index) + "]";
12299
- })
12300
- .replace(/__f\[(\d+)\]/g, function(match, index) {
12301
- index = +index;
12302
- return "__f[" + (fieldFunctions.length + index) + "]";
12303
- });
12194
+ let acc = prop;
12304
12195
 
12305
- operatorFunctions.push.apply(operatorFunctions, expr$1.operators);
12306
- fieldFunctions.push.apply(fieldFunctions, expr$1.fields);
12196
+ if (isString(value)) {
12197
+ const date = dateRegExp.exec(value);
12198
+ if (date) {
12199
+ value = new Date(+date[1]);
12307
12200
  } else {
12308
- if (typeof field === 'function') {
12309
- expr$1 = "__f[" + fieldFunctions.length + "](d)";
12310
- fieldFunctions.push(field);
12311
- } else {
12312
- expr$1 = expr(field);
12313
- }
12314
-
12315
- if (typeof operator === 'function') {
12316
- filter = "__o[" + operatorFunctions.length + "](" + expr$1 + ", " + operators.quote(filter.value) + ")";
12317
- operatorFunctions.push(operator);
12318
- } else {
12319
- filter = operators[(operator || "eq").toLowerCase()](expr$1, filter.value, filter.ignoreCase !== undefined ? filter.ignoreCase : true, expression.accentFoldingFiltering);
12320
- }
12201
+ acc = (a) => {
12202
+ const x = prop(a);
12203
+ if (typeof x === "string" && ignoreCase) {
12204
+ return accentFoldingFiltering
12205
+ ? x.toLocaleLowerCase(accentFoldingFiltering)
12206
+ : x.toLowerCase();
12207
+ } else {
12208
+ return isNumeric(x) ? x + "" : x;
12209
+ }
12210
+ };
12321
12211
  }
12212
+ }
12322
12213
 
12323
- expressions.push(filter);
12214
+ if (isDate(value)) {
12215
+ return (a) => {
12216
+ const x = acc(a);
12217
+ return isDate(x) ? x.getTime() : x;
12218
+ };
12324
12219
  }
12220
+ return acc;
12221
+ };
12325
12222
 
12326
- return { expression: "(" + expressions.join(logic[expression.logic]) + ")", fields: fieldFunctions, operators: operatorFunctions };
12223
+ const transformCompositeFilter = function (filter) {
12224
+ const accentFoldingFiltering = filter.accentFoldingFiltering;
12225
+ const combiner = logic[filter.logic || "and"];
12226
+
12227
+ return filter.filters
12228
+ .filter(isPresent)
12229
+ .map((x) => {
12230
+ const extendedFilter = isPresent(accentFoldingFiltering)
12231
+ ? deepExtend({}, x, { accentFoldingFiltering })
12232
+ : x;
12233
+
12234
+ return isPresent(x.filters)
12235
+ ? transformCompositeFilter(extendedFilter)
12236
+ : transformFilter(extendedFilter);
12237
+ })
12238
+ .reduce(combiner.concat, combiner.identity);
12327
12239
  };
12328
12240
 
12329
12241
  /* eslint-disable max-params */
@@ -12438,13 +12350,11 @@
12438
12350
 
12439
12351
  this._criteria = options.criteria;
12440
12352
 
12441
- var expression = filterExpr({
12353
+ this._matches = transformCompositeFilter({
12442
12354
  logic: this._logic,
12443
12355
  filters: this._criteria,
12444
- accentFoldingFiltering: culture().name
12445
- }).expression;
12446
-
12447
- this._matches = new Function("d", "return " + expression);
12356
+ accentFoldingFiltering: culture().name,
12357
+ });
12448
12358
  }
12449
12359
  matches(value) {
12450
12360
  if (value === null) {
@@ -16173,7 +16083,7 @@
16173
16083
  if (data.__dataType) {
16174
16084
  type = data.__dataType;
16175
16085
  }
16176
- } else if (data !== null && data !== undefined) {
16086
+ } else if (data != null) {
16177
16087
  if (cell.html) {
16178
16088
  data = dom.html(data);
16179
16089
  } else {
@@ -16208,6 +16118,17 @@
16208
16118
  }
16209
16119
  if (cell.merged) {
16210
16120
  classNames.push("k-spreadsheet-merged-cell");
16121
+ if (!cell.enable) {
16122
+ collection.push(dom.element("div", {
16123
+ className: "k-spreadsheet-disabled-mask",
16124
+ style: {
16125
+ left: (cell.left + 1) + "px",
16126
+ top: (cell.top + 1) + "px",
16127
+ width: (cell.width - 1) + "px",
16128
+ height: (cell.height - 1) + "px"
16129
+ }
16130
+ }));
16131
+ }
16211
16132
  }
16212
16133
  if (cell.comment) {
16213
16134
  classNames.push("k-spreadsheet-has-comment");
@@ -17009,24 +16930,9 @@
17009
16930
  end = begin;
17010
16931
  }
17011
16932
  if (begin && end) {
17012
- let range = document.createRange();
17013
- range.setStart(begin.node, begin.pos);
17014
- range.setEnd(end.node, end.pos);
17015
- let sel = window.getSelection();
17016
- let currentRange = sel.getRangeAt(0);
17017
- if (differ(range, currentRange)) {
17018
- sel.removeAllRanges();
17019
- sel.addRange(range);
17020
- }
17021
- }
17022
- function differ(a, b) {
17023
- return (
17024
- a.startOffset !== b.startOffset ||
17025
- a.endOffset !== b.endOffset ||
17026
- a.startContainer !== b.endContainer ||
17027
- a.endContainer !== b.endContainer
17028
- );
16933
+ this._setRange(begin, end);
17029
16934
  }
16935
+
17030
16936
  function lookup(node, pos) {
17031
16937
  try {
17032
16938
  (function loop(node) {
@@ -17064,6 +16970,27 @@
17064
16970
  return this.value().length;
17065
16971
  }
17066
16972
 
16973
+ _setRange(begin, end) {
16974
+ let range = document.createRange();
16975
+ range.setStart(begin.node, begin.pos);
16976
+ range.setEnd(end.node, end.pos);
16977
+ let sel = window.getSelection();
16978
+ let currentRange = sel.getRangeAt(0);
16979
+ if (differ(range, currentRange)) {
16980
+ sel.removeAllRanges();
16981
+ sel.addRange(range);
16982
+ }
16983
+
16984
+ function differ(a, b) {
16985
+ return (
16986
+ a.startOffset !== b.startOffset ||
16987
+ a.endOffset !== b.endOffset ||
16988
+ a.startContainer !== b.endContainer ||
16989
+ a.endContainer !== b.endContainer
16990
+ );
16991
+ }
16992
+ }
16993
+
17067
16994
  _formulaSource() {
17068
16995
  let result = [];
17069
16996
  let value;
@@ -17814,27 +17741,43 @@
17814
17741
  }
17815
17742
  }
17816
17743
 
17744
+ let attrs = { style: style };
17745
+
17817
17746
  if (!style.textAlign) {
17818
17747
  switch (type) {
17819
- case "number":
17820
- case "date":
17821
- case "percent":
17822
- case "currency":
17823
- style.textAlign = "right";
17824
- break;
17825
- case "boolean":
17826
- style.textAlign = "center";
17748
+ case "number":
17749
+ case "date":
17750
+ case "percent":
17751
+ case "currency":
17752
+ style.textAlign = "right";
17753
+ break;
17754
+ case "boolean":
17755
+ style.textAlign = "center";
17827
17756
  break;
17828
17757
  }
17829
17758
  }
17830
17759
 
17760
+ if (!/^(?:string|undefined)$/.test(type)) {
17761
+ // provide original value and number format for better
17762
+ // interoperability with google sheets and libre office.
17763
+ attrs.sdval = cell.value;
17764
+ attrs["data-sheets-value"] = JSON.stringify({ 1: 3, 3: cell.value });
17765
+ if (format) {
17766
+ attrs.sdnum = format;
17767
+ attrs["data-sheets-numberformat"] = JSON.stringify({ 1: 2, 2: format, 3: 1 });
17768
+ }
17769
+ }
17770
+ if (cell.formula) {
17771
+ attrs["data-sheets-formula"] = "=" + cell.formula.print();
17772
+ }
17773
+
17831
17774
  let className = null;
17832
17775
 
17833
17776
  if (cell.enable === false) {
17834
17777
  className = "k-disabled";
17835
17778
  }
17836
17779
 
17837
- let td = table.addCell(row, data, style, className, cell.validation);
17780
+ let td = table.addCell(row, data, attrs, className, cell.validation);
17838
17781
 
17839
17782
  let border, sibling;
17840
17783
 
@@ -17893,7 +17836,7 @@
17893
17836
  this.trs.push(tr);
17894
17837
  }
17895
17838
 
17896
- addCell(rowIndex, text, style, className, validation) {
17839
+ addCell(rowIndex, text, attrs, className, validation) {
17897
17840
  if (text === null || text === undefined) {
17898
17841
  text = "";
17899
17842
  }
@@ -17902,19 +17845,18 @@
17902
17845
  }
17903
17846
 
17904
17847
  let children = [ text ];
17905
- let properties = { style: style };
17906
17848
 
17907
17849
  if (validation && !validation.value) {
17908
17850
  children.push(dom.element("span", { className: "k-dirty" }));
17909
17851
 
17910
17852
  className = (className || "") + (className ? " " : "") + "k-dirty-cell";
17911
- properties.title = validation.message;
17853
+ attrs.title = validation.message;
17912
17854
  }
17913
17855
 
17914
17856
  if (className) {
17915
- properties.className = className;
17857
+ attrs.className = className;
17916
17858
  }
17917
- let td = dom.element("td", properties, children);
17859
+ let td = dom.element("td", attrs, children);
17918
17860
 
17919
17861
  this.trs[rowIndex].children.push(td);
17920
17862
  return td;
@@ -18907,7 +18849,13 @@
18907
18849
  return style.replace(/^-(?:ms|moz|webkit)-/, "");
18908
18850
  }
18909
18851
 
18910
- function borderObject(styles) {
18852
+ function borderObject(element, styles) {
18853
+ // MS Office uses class name and writes borders in the <style> section, so for it we need to
18854
+ // use the computed styles. For Google Sheets / LibreOffice, however, the inline styles are
18855
+ // more accurate.
18856
+ if (!element.className) {
18857
+ styles = element.style;
18858
+ }
18911
18859
  let obj = {};
18912
18860
  [
18913
18861
  "borderBottom",
@@ -18915,16 +18863,45 @@
18915
18863
  "borderLeft",
18916
18864
  "borderTop"
18917
18865
  ].forEach(function(key) {
18918
- obj[key] = styles[key + "Style"] === "none" ? null : {
18919
- size: 1,
18920
- color: styles[key + "Color"]
18921
- };
18866
+ let width = styles[key + "Width"];
18867
+ if (width) {
18868
+ width = parseInt(width, 10);
18869
+ }
18870
+ if (width) {
18871
+ obj[key] = {
18872
+ size: width,
18873
+ color: styles[key + "Color"] || "#000"
18874
+ };
18875
+ }
18922
18876
  });
18923
18877
  return obj;
18924
18878
  }
18925
18879
 
18926
18880
  function cellState(row, col, element, hBorders, vBorders) {
18927
18881
  let styles = window.getComputedStyle(element);
18882
+ let value, format, formula;
18883
+
18884
+ // google sheets
18885
+ if ((value = element.getAttribute("data-sheets-value"))) {
18886
+ value = JSON.parse(value);
18887
+ value = value[value[1]];
18888
+ }
18889
+ if ((format = element.getAttribute("data-sheets-numberformat"))) {
18890
+ format = JSON.parse(format);
18891
+ format = format[format[1]];
18892
+ }
18893
+ formula = element.getAttribute("data-sheets-formula");
18894
+
18895
+ // libre office
18896
+ if (value == null && format == null && formula == null) {
18897
+ value = element.getAttribute("sdval");
18898
+ format = element.getAttribute("sdnum");
18899
+ if (format) {
18900
+ // for ungoogable reasons, libreoffice prepends format strings with
18901
+ // "1033;" and sometimes with "1033;0;". discard it below.
18902
+ format = format.replace(/^1033;(?:0;)?/, "");
18903
+ }
18904
+ }
18928
18905
 
18929
18906
  // note: Chrome 70 appends a \t to a cell's text, which is actually mandated by the standard
18930
18907
  // ([1] item 6). We remove it below. In [2] it's suggested they might switch back to
@@ -18932,49 +18909,62 @@
18932
18909
  //
18933
18910
  // [1] https://www.w3.org/TR/html53/dom.html#dom-htmlelement-innertext
18934
18911
  // [2] https://bugs.chromium.org/p/chromium/issues/detail?id=897373
18935
- let text = (element.innerText || element.textContent).replace(/\t$/, "");
18912
+ if (value == null) {
18913
+ value = (element.innerText || element.textContent).replace(/\t$/, "");
18914
+ }
18936
18915
 
18937
- let borders = borderObject(styles);
18916
+ let borders = borderObject(element, styles);
18938
18917
  let state = {
18939
- value: text === "" ? null : text,
18918
+ value: value === "" ? null : value,
18919
+ formula: formula,
18940
18920
 
18941
18921
  borderTop: borders.borderTop || hBorders.get(row, col) || null,
18942
18922
  borderBottom: borders.borderBottom || hBorders.get(row + 1, col) || null,
18943
18923
  borderLeft: borders.borderLeft || vBorders.get(row, col) || null,
18944
18924
  borderRight: borders.borderRight || vBorders.get(row, col + 1) || null,
18945
18925
 
18946
- fontSize: parseInt(styles["font-size"], 10)
18926
+ fontSize: parseInt(styles["fontSize"], 10)
18947
18927
  };
18948
18928
 
18929
+ if (format != null) {
18930
+ state.format = format;
18931
+ }
18932
+
18949
18933
  hBorders.set(row, col, state.borderTop);
18950
18934
  hBorders.set(row + 1, col, state.borderBottom);
18951
18935
  vBorders.set(row, col, state.borderLeft);
18952
18936
  vBorders.set(row, col + 1, state.borderRight);
18953
18937
 
18954
- if (styles["background-color"] !== "rgb(0, 0, 0)" && styles["background-color"] !== "rgba(0, 0, 0, 0)") {
18955
- state.background = styles["background-color"];
18938
+ if (styles["backgroundColor"] !== "rgb(0, 0, 0)" && styles["backgroundColor"] !== "rgba(0, 0, 0, 0)") {
18939
+ state.background = styles["backgroundColor"];
18956
18940
  }
18941
+ if (stripStyle(styles["textAlign"]) !== "right") {
18942
+ state.textAlign = stripStyle(styles["textAlign"]);
18943
+ }
18944
+ if (styles["verticalAlign"] !== "middle") {
18945
+ state.verticalAlign = styles["verticalAlign"];
18946
+ }
18947
+ if (styles["wordWrap"] !== "normal" ) {
18948
+ state.wrap = true;
18949
+ }
18950
+
18951
+ const txtElem = element.querySelector("font"); // libre office
18952
+ if (txtElem) {
18953
+ styles = window.getComputedStyle(txtElem);
18954
+ }
18955
+
18957
18956
  if (styles.color !== "rgb(0, 0, 0)" && styles.color !== "rgba(0, 0, 0, 0)") {
18958
18957
  state.color = styles.color;
18959
18958
  }
18960
- if (styles["text-decoration"] === "underline") {
18959
+ if (/^underline/.test(styles["textDecoration"])) {
18961
18960
  state.underline = true;
18962
18961
  }
18963
- if (styles["font-style"] === "italic") {
18962
+ if (styles["fontStyle"] == "italic") {
18964
18963
  state.italic = true;
18965
18964
  }
18966
- if (styles["font-weight"] === "bold") {
18965
+ if (/^(?:bold|[67]00)$/i.test(styles["fontWeight"])) {
18967
18966
  state.bold = true;
18968
18967
  }
18969
- if (stripStyle(styles["text-align"]) !== "right") {
18970
- state.textAlign = stripStyle(styles["text-align"]);
18971
- }
18972
- if (styles["vertical-align"] !== "middle") {
18973
- state.verticalAlign = styles["vertical-align"];
18974
- }
18975
- if (styles["word-wrap"] !== "normal" ) {
18976
- state.wrap = true;
18977
- }
18978
18968
 
18979
18969
  return state;
18980
18970
  }
@@ -20808,6 +20798,60 @@
20808
20798
  }
20809
20799
  };
20810
20800
 
20801
+ class Deferred {
20802
+ constructor() {
20803
+ this._progressHandlers = [];
20804
+ this._resolved = false;
20805
+ this._rejected = false;
20806
+ this.promise = new window.Promise((resolve, reject) => {
20807
+ this._resolve = (value) => {
20808
+ if (!this._resolved && !this._rejected) {
20809
+ this._resolved = true;
20810
+ resolve(value);
20811
+ }
20812
+ };
20813
+ this._reject = (reason) => {
20814
+ if (!this._resolved && !this._rejected) {
20815
+ this._rejected = true;
20816
+ reject(reason);
20817
+ }
20818
+ };
20819
+ });
20820
+ }
20821
+
20822
+ resolve(value) {
20823
+ this._resolve(value);
20824
+ return this;
20825
+ }
20826
+
20827
+ reject(reason) {
20828
+ this._reject(reason);
20829
+ return this;
20830
+ }
20831
+
20832
+ notify(value) {
20833
+ if (!this._resolved && !this._rejected) {
20834
+ this._progressHandlers.forEach(handler => handler(value));
20835
+ }
20836
+ }
20837
+
20838
+ progress(callback) {
20839
+ this._progressHandlers.push(callback);
20840
+ return this;
20841
+ }
20842
+
20843
+ then(onFulfilled, onRejected, onProgress) {
20844
+ if (onProgress) {
20845
+ this.progress(onProgress);
20846
+ }
20847
+ return this.promise.then(onFulfilled, onRejected);
20848
+ }
20849
+
20850
+ promise() {
20851
+ return this.promise;
20852
+ }
20853
+ }
20854
+
20811
20855
  /* eslint-disable complexity */
20812
20856
 
20813
20857
  // WARNING: removing the following jshint declaration and turning
@@ -20822,12 +20866,11 @@
20822
20866
 
20823
20867
  let ERROR_LOG = null;
20824
20868
 
20825
- function readExcel(file, workbook) {
20869
+ function readExcel(file, workbook, deferred) {
20826
20870
  let reader = new FileReader();
20827
- reader.onload = function(e) {
20828
- JSZip.loadAsync(e.target.result).then(zip => {
20829
- readWorkbook(zip, workbook);
20830
- });
20871
+ reader.onload = async function(e) {
20872
+ JSZip.loadAsync(e.target.result)
20873
+ .then(async zip => await readWorkbook(zip, workbook, deferred));
20831
20874
  };
20832
20875
 
20833
20876
  reader.readAsArrayBuffer(file);
@@ -20849,6 +20892,7 @@
20849
20892
  let SEL_VIEW = ["bookViews", "workbookView"];
20850
20893
  let SEL_SHEET_VIEW = ["sheetViews", "sheetView"];
20851
20894
  let SEL_HYPERLINK = ["hyperlinks", "hyperlink"];
20895
+ let SEL_PROTECTION = ["sheetProtection"];
20852
20896
 
20853
20897
  /* A validation section looks like this:
20854
20898
  *
@@ -20910,7 +20954,7 @@
20910
20954
  return file;
20911
20955
  }
20912
20956
 
20913
- async function readWorkbook(zip, workbook) {
20957
+ async function readWorkbook(zip, workbook, progress) {
20914
20958
  ERROR_LOG = workbook.excelImportErrors = [];
20915
20959
 
20916
20960
  let strings = await readStrings(zip);
@@ -20927,6 +20971,10 @@
20927
20971
  let file = relationships.byId[relId];
20928
20972
  let name = attrs.name;
20929
20973
  let state = attrs.state;
20974
+ let dim = sheetDimensions(relationships.bytes[file]);
20975
+
20976
+ workbook.options.columnWidth = dim.columnWidth || workbook.options.columnWidth;
20977
+ workbook.options.rowHeight = dim.rowHeight || workbook.options.rowHeight;
20930
20978
 
20931
20979
  items.push({
20932
20980
  workbook: workbook,
@@ -20936,7 +20984,11 @@
20936
20984
  file: file,
20937
20985
  options: {
20938
20986
  state: state,
20939
- name: name
20987
+ name: name,
20988
+ rows: Math.max(workbook.options.rows || 0, dim.rows),
20989
+ columns: Math.max(workbook.options.columns || 0, dim.cols),
20990
+ columnWidth: dim.columnWidth,
20991
+ rowHeight: dim.rowHeight
20940
20992
  }
20941
20993
  });
20942
20994
  } else if (this.is(SEL_VIEW)) {
@@ -20966,43 +21018,63 @@
20966
21018
  }
20967
21019
  });
20968
21020
 
20969
- for (let i = 0; i < items.length; i++) {
20970
- const item = items[i];
20971
- const dim = await sheetDimensions(item.zip, item.file);
20972
- const { workbook } = item;
20973
-
20974
- workbook.options.columnWidth = dim.columnWidth || workbook.options.columnWidth;
20975
- workbook.options.rowHeight = dim.rowHeight || workbook.options.rowHeight;
20976
-
20977
- item.options = {
20978
- ...item.options,
20979
- rows: Math.max(workbook.options.rows || 0, dim.rows),
20980
- columns: Math.max(workbook.options.columns || 0, dim.cols),
20981
- columnWidth: dim.columnWidth,
20982
- rowHeight: dim.rowHeight
20983
- };
20984
- }
21021
+ let loading = new Deferred();
21022
+ loading.progress(function(args) {
21023
+ if (progress) {
21024
+ progress.notify(args);
21025
+ }
21026
+ })
21027
+ .then(function() {
21028
+ let sheets = workbook.sheets();
21029
+ recalcSheets(sheets);
20985
21030
 
20986
- await loadSheets(items, workbook);
21031
+ workbook.activeSheet(sheets[activeSheet]);
20987
21032
 
20988
- let sheets = workbook.sheets();
20989
- recalcSheets(sheets);
21033
+ if (progress) {
21034
+ progress.resolve();
21035
+ }
21036
+ });
20990
21037
 
20991
- workbook.activeSheet(sheets[activeSheet]);
21038
+ loadSheets(items, workbook, loading);
20992
21039
  }
20993
21040
 
20994
- async function loadSheets(items, workbook) {
21041
+ function loadSheets(items, workbook, progress) {
21042
+ let ready = window.Promise.resolve();
20995
21043
  for (let i = 0; i < items.length; i++) {
20996
- const ctx = items[i];
20997
- let sheet = workbook.insertSheet(ctx.options);
21044
+ (function(entry, i) {
21045
+ ready = ready.then(function() {
21046
+ let sheet = workbook.insertSheet(entry.options);
21047
+ sheet.suspendChanges(true);
21048
+
21049
+ let promise = queueSheet(sheet, entry);
21050
+ let args = {
21051
+ sheet: sheet,
21052
+ progress: i === 1 ? 1 : (i / (items.length - 1))
21053
+ };
20998
21054
 
20999
- if (!sheet) {
21000
- continue;
21001
- }
21055
+ promise.then(function() {
21056
+ progress.notify(args);
21057
+ });
21002
21058
 
21003
- sheet.suspendChanges(true);
21004
- await readSheet(ctx.zip, ctx.file, sheet, ctx.strings, ctx.styles);
21059
+ return promise;
21060
+ });
21061
+ })(items[i], i);
21005
21062
  }
21063
+
21064
+ ready.then(function() {
21065
+ progress.resolve();
21066
+ });
21067
+ }
21068
+
21069
+ function queueSheet(sheet, ctx) {
21070
+ let deferred = new Deferred();
21071
+
21072
+ setTimeout(async function() {
21073
+ await readSheet(ctx.zip, ctx.file, sheet, ctx.strings, ctx.styles);
21074
+ deferred.resolve();
21075
+ }, 0);
21076
+
21077
+ return deferred;
21006
21078
  }
21007
21079
 
21008
21080
  function recalcSheets(sheets) {
@@ -21013,13 +21085,13 @@
21013
21085
  }
21014
21086
  }
21015
21087
 
21016
- async function sheetDimensions(zip, file) {
21088
+ function sheetDimensions(bytes) {
21017
21089
  let ref, dim = {
21018
21090
  rows: 0,
21019
21091
  cols: 0
21020
21092
  };
21021
21093
 
21022
- await parse(zip, xl(file), {
21094
+ parseXML(bytes, {
21023
21095
  enter: function(tag, attrs) {
21024
21096
  if (tag === "dimension") {
21025
21097
  ref = calc.parseReference(attrs.ref);
@@ -21077,6 +21149,7 @@
21077
21149
  let valueFilterBlanks;
21078
21150
  let valueFilterValues;
21079
21151
  let filters = [];
21152
+ let deferredStyles = [];
21080
21153
 
21081
21154
  ERROR_LOG = sheet._workbook.excelImportErrors;
21082
21155
 
@@ -21121,7 +21194,7 @@
21121
21194
 
21122
21195
  let styleIndex = attrs.s;
21123
21196
  if (styleIndex != null) {
21124
- applyStyle(sheet, ref, styles, styleIndex);
21197
+ deferredStyles.push({ ref: ref, sty: +styleIndex });
21125
21198
  }
21126
21199
  } else if (this.is(SEL_MERGE)) {
21127
21200
  sheet.range(attrs.ref).merge();
@@ -21142,10 +21215,13 @@
21142
21215
  }
21143
21216
  if (attrs.style != null) {
21144
21217
  // apply style on a whole range of columns
21145
- applyStyle(sheet, new RangeRef(
21146
- new CellRef(-Infinity, start),
21147
- new CellRef(+Infinity, stop)
21148
- ), styles, attrs.style);
21218
+ deferredStyles.unshift({
21219
+ ref: new RangeRef(
21220
+ new CellRef(-Infinity, start),
21221
+ new CellRef(+Infinity, stop)
21222
+ ),
21223
+ sty: +attrs.style
21224
+ });
21149
21225
  }
21150
21226
  } else if (this.is(SEL_ROW)) {
21151
21227
  let row = integer(attrs.r) - 1;
@@ -21182,6 +21258,10 @@
21182
21258
  if (target) {
21183
21259
  sheet.range(attrs.ref).link(target);
21184
21260
  }
21261
+ } else if (this.is(SEL_PROTECTION)) {
21262
+ if (attrs.sheet) {
21263
+ sheet.range(SHEETREF).enable(false);
21264
+ }
21185
21265
  } else if (this.is(["autoFilter"])) {
21186
21266
  filterRef = attrs.ref;
21187
21267
  if (closed) {
@@ -21352,6 +21432,8 @@
21352
21432
  }
21353
21433
  });
21354
21434
 
21435
+ deferredStyles.forEach(({ ref, sty }) => applyStyle(sheet, ref, styles, sty));
21436
+
21355
21437
  if (relationships.byType.comments) {
21356
21438
  let commentFile = relative_file(file, relationships.byType.comments[0]);
21357
21439
  await readComments(zip, commentFile, sheet);
@@ -21402,12 +21484,14 @@
21402
21484
  let relationships = await readRelationships(zip, relsFile);
21403
21485
 
21404
21486
  if (relationships.byType.image) {
21405
- for (const id of Object.keys(relationships.byId)) {
21487
+ let relkeys = Object.keys(relationships.byId);
21488
+ for (let i = 0; i < relkeys.length; ++i) {
21489
+ let id = relkeys[i];
21406
21490
  let img = relative_file(file, relationships.byId[id]);
21407
21491
  let type = getContentType(img);
21408
21492
 
21409
21493
  if (type) {
21410
- let data = await zip.files[img].async("arrayBuffer");
21494
+ let data = await zip.file(img).async("arraybuffer");
21411
21495
  let name = getFileName(img);
21412
21496
  let blob = name && !(kendoCommon.browser.edge)
21413
21497
  ? new window.File([ data ], name, { type: type })
@@ -21681,6 +21765,9 @@
21681
21765
  if (shouldSet("applyNumberFormat", "numFmtId")) {
21682
21766
  setFormat(styles.numFmts[value] || DEFAULT_FORMATS[value]);
21683
21767
  }
21768
+ if (shouldSet("applyProtection", "protection")) {
21769
+ range.enable(!xf.protection.locked);
21770
+ }
21684
21771
 
21685
21772
  function setFormat(f) {
21686
21773
  let format = typeof f == "string" ? f : f.formatCode;
@@ -21769,11 +21856,18 @@
21769
21856
  }
21770
21857
  }
21771
21858
 
21772
- async function parse(zip, file, callbacks) {
21773
- let part = zip.files[file];
21774
- if (part) {
21775
- await parseXML(await part.async("uint8array"), callbacks);
21776
- }
21859
+ function parse(zip, file, callbacks) {
21860
+ return new window.Promise(resolve => {
21861
+ let obj = zip.file(file);
21862
+ if (obj) {
21863
+ obj.async("uint8array").then(bytes => {
21864
+ parseXML(bytes, callbacks);
21865
+ resolve();
21866
+ });
21867
+ } else {
21868
+ resolve();
21869
+ }
21870
+ });
21777
21871
  }
21778
21872
 
21779
21873
  async function readStrings(zip) {
@@ -21799,7 +21893,7 @@
21799
21893
  }
21800
21894
 
21801
21895
  async function readRelationships(zip, file) {
21802
- let map = { byId: {}, byType: { theme: [] } };
21896
+ let map = { byId: {}, byType: { theme: [] }, bytes: {} };
21803
21897
  await parse(zip, xl(file) + ".rels", {
21804
21898
  enter: function(tag, attrs) {
21805
21899
  if (tag === "Relationship") {
@@ -21812,6 +21906,18 @@
21812
21906
  }
21813
21907
  }
21814
21908
  });
21909
+ let names = [];
21910
+ let promises = [];
21911
+ Object.keys(map.byId).forEach(id => {
21912
+ let filename = map.byId[id];
21913
+ let obj = zip.file(xl(filename));
21914
+ if (obj) {
21915
+ names.push(filename);
21916
+ promises.push(obj.async("uint8array"));
21917
+ }
21918
+ });
21919
+ let data = await window.Promise.all(promises);
21920
+ names.forEach((name, i) => map.bytes[name] = data[i]);
21815
21921
  return map;
21816
21922
  }
21817
21923
 
@@ -21953,6 +22059,10 @@
21953
22059
  if (attrs.indent != null) {
21954
22060
  xf.indent = integer(attrs.indent);
21955
22061
  }
22062
+ } else if (tag == "protection") {
22063
+ xf.protection = {
22064
+ locked: bool(attrs.locked)
22065
+ };
21956
22066
  }
21957
22067
  }
21958
22068
  },
@@ -21984,10 +22094,12 @@
21984
22094
  addBool("applyFill");
21985
22095
  addBool("applyFont");
21986
22096
  addBool("applyNumberFormat");
21987
- addBool("applyProtection");
22097
+ if (addBool("applyProtection")) {
22098
+ xf.protection = { locked: true };
22099
+ }
21988
22100
  function addBool(name) {
21989
22101
  if (attrs[name] != null) {
21990
- xf[name] = bool(attrs[name]);
22102
+ return xf[name] = bool(attrs[name]);
21991
22103
  }
21992
22104
  }
21993
22105
  return xf;
@@ -22036,7 +22148,7 @@
22036
22148
  };
22037
22149
 
22038
22150
  let file = xl(rel);
22039
- if (zip.files[file]) {
22151
+ if (zip.file(file)) {
22040
22152
  await parse(zip, file, {
22041
22153
  enter: function(tag, attrs) {
22042
22154
  if (this.is(SEL_SCHEME_SYSCLR)) {
@@ -22767,10 +22879,18 @@
22767
22879
  }
22768
22880
 
22769
22881
  fromFile(file) {
22770
- if (file && !this.trigger("excelImport", { file })) {
22882
+ const deferred = new Deferred();
22883
+
22884
+ if (file && !this.trigger("excelImport", { file, deferred })) {
22771
22885
  this._clearSheets();
22772
- readExcel(file, this);
22886
+ this._readExcel(file, this, deferred);
22773
22887
  }
22888
+
22889
+ return deferred.promise;
22890
+ }
22891
+
22892
+ _readExcel(file, workbook, deferred) {
22893
+ readExcel(file, workbook, deferred);
22774
22894
  }
22775
22895
 
22776
22896
  saveAsExcel(options) {
@@ -24268,6 +24388,11 @@
24268
24388
  right = right.toLowerCase();
24269
24389
  }
24270
24390
  if (typeof right == typeof left) {
24391
+ // for issue https://github.com/telerik/kendo-ui-core/issues/6879, limitPrecision
24392
+ // digits got bumped to 16, but it's too much for the case 9.302 - 0.002 (issue
24393
+ // https://github.com/telerik/kendo-ui-core/issues/7170).
24394
+ left = maybeRoundFloatErrors(left, 15);
24395
+ right = maybeRoundFloatErrors(right, 15);
24271
24396
  return func(left, right);
24272
24397
  } else {
24273
24398
  return new CalcError("VALUE");
@@ -32610,10 +32735,10 @@
32610
32735
  }
32611
32736
  }
32612
32737
  if (ref.width == 1) {
32613
- return callback(ref.get(row - 1, 0));
32738
+ return callback(ref.get((row || 1) - 1, 0));
32614
32739
  }
32615
32740
  if (ref.height == 1) {
32616
- return callback(ref.get(0, col - 1));
32741
+ return callback(ref.get(0, (col || 1) - 1));
32617
32742
  }
32618
32743
  } else {
32619
32744
  callback(new CalcError('REF'));
@@ -43762,6 +43887,7 @@
43762
43887
  exports.CalcError = CalcError;
43763
43888
  exports.CellRef = CellRef;
43764
43889
  exports.Context = Context;
43890
+ exports.Deferred = Deferred;
43765
43891
  exports.Matrix = Matrix;
43766
43892
  exports.NULLREF = NULLREF;
43767
43893
  exports.NameRef = NameRef;