@visactor/vtable-plugins 1.19.4 → 1.19.6
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/cjs/index.d.ts +1 -0
- package/cjs/index.js +2 -1
- package/cjs/index.js.map +1 -1
- package/cjs/table-export/csv/index.d.ts +12 -0
- package/cjs/table-export/csv/index.js +54 -0
- package/cjs/table-export/csv/index.js.map +1 -0
- package/cjs/table-export/excel/index.d.ts +21 -0
- package/cjs/table-export/excel/index.js +243 -0
- package/cjs/table-export/excel/index.js.map +1 -0
- package/cjs/table-export/excel/style.d.ts +6 -0
- package/cjs/table-export/excel/style.js +89 -0
- package/cjs/table-export/excel/style.js.map +1 -0
- package/cjs/table-export/index.d.ts +7 -0
- package/cjs/table-export/index.js +38 -0
- package/cjs/table-export/index.js.map +1 -0
- package/cjs/table-export/util/color.d.ts +152 -0
- package/cjs/table-export/util/color.js +197 -0
- package/cjs/table-export/util/color.js.map +1 -0
- package/cjs/table-export/util/download.d.ts +2 -0
- package/cjs/table-export/util/download.js +60 -0
- package/cjs/table-export/util/download.js.map +1 -0
- package/cjs/table-export/util/encode.d.ts +3 -0
- package/cjs/table-export/util/encode.js +17 -0
- package/cjs/table-export/util/encode.js.map +1 -0
- package/cjs/table-export/util/indent.d.ts +2 -0
- package/cjs/table-export/util/indent.js +27 -0
- package/cjs/table-export/util/indent.js.map +1 -0
- package/cjs/table-export/util/pagination.d.ts +5 -0
- package/cjs/table-export/util/pagination.js +24 -0
- package/cjs/table-export/util/pagination.js.map +1 -0
- package/cjs/table-export/util/promise.d.ts +1 -0
- package/cjs/table-export/util/promise.js +10 -0
- package/cjs/table-export/util/promise.js.map +1 -0
- package/cjs/table-export/util/type.d.ts +6 -0
- package/cjs/table-export/util/type.js +6 -0
- package/cjs/table-export/util/type.js.map +1 -0
- package/cjs/table-export.d.ts +17 -0
- package/cjs/table-export.js +93 -0
- package/cjs/table-export.js.map +1 -0
- package/cjs/types.js +1 -2
- package/cjs/wps-fill-handle.js +1 -0
- package/dist/vtable-plugins.js +1201 -187
- package/dist/vtable-plugins.min.js +14 -14
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/table-export/csv/index.d.ts +12 -0
- package/es/table-export/csv/index.js +47 -0
- package/es/table-export/csv/index.js.map +1 -0
- package/es/table-export/excel/index.d.ts +21 -0
- package/es/table-export/excel/index.js +242 -0
- package/es/table-export/excel/index.js.map +1 -0
- package/es/table-export/excel/style.d.ts +6 -0
- package/es/table-export/excel/style.js +80 -0
- package/es/table-export/excel/style.js.map +1 -0
- package/es/table-export/index.d.ts +7 -0
- package/es/table-export/index.js +8 -0
- package/es/table-export/index.js.map +1 -0
- package/es/table-export/util/color.d.ts +152 -0
- package/es/table-export/util/color.js +189 -0
- package/es/table-export/util/color.js.map +1 -0
- package/es/table-export/util/download.d.ts +2 -0
- package/es/table-export/util/download.js +52 -0
- package/es/table-export/util/download.js.map +1 -0
- package/es/table-export/util/encode.d.ts +3 -0
- package/es/table-export/util/encode.js +10 -0
- package/es/table-export/util/encode.js.map +1 -0
- package/es/table-export/util/indent.d.ts +2 -0
- package/es/table-export/util/indent.js +19 -0
- package/es/table-export/util/indent.js.map +1 -0
- package/es/table-export/util/pagination.d.ts +5 -0
- package/es/table-export/util/pagination.js +16 -0
- package/es/table-export/util/pagination.js.map +1 -0
- package/es/table-export/util/promise.d.ts +1 -0
- package/es/table-export/util/promise.js +4 -0
- package/es/table-export/util/promise.js.map +1 -0
- package/es/table-export/util/type.d.ts +6 -0
- package/es/table-export/util/type.js +2 -0
- package/es/table-export/util/type.js.map +1 -0
- package/es/table-export.d.ts +17 -0
- package/es/table-export.js +62 -0
- package/es/table-export.js.map +1 -0
- package/es/types.js +1 -2
- package/es/wps-fill-handle.js +2 -1
- package/package.json +9 -7
package/dist/vtable-plugins.js
CHANGED
|
@@ -1383,14 +1383,14 @@
|
|
|
1383
1383
|
var eventemitter3Exports = eventemitter3.exports;
|
|
1384
1384
|
var EventEmitter$5 = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
|
1385
1385
|
|
|
1386
|
-
const isType = (value, type) => Object.prototype.toString.call(value) === `[object ${type}]`;
|
|
1387
|
-
var isType$
|
|
1386
|
+
const isType$2 = (value, type) => Object.prototype.toString.call(value) === `[object ${type}]`;
|
|
1387
|
+
var isType$3 = isType$2;
|
|
1388
1388
|
|
|
1389
|
-
const isBoolean$
|
|
1390
|
-
var isBoolean$
|
|
1389
|
+
const isBoolean$3 = (value, fuzzy = !1) => fuzzy ? "boolean" == typeof value : !0 === value || !1 === value || isType$3(value, "Boolean");
|
|
1390
|
+
var isBoolean$4 = isBoolean$3;
|
|
1391
1391
|
|
|
1392
|
-
const isFunction$
|
|
1393
|
-
var isFunction$
|
|
1392
|
+
const isFunction$b = value => "function" == typeof value;
|
|
1393
|
+
var isFunction$c = isFunction$b;
|
|
1394
1394
|
|
|
1395
1395
|
const isNil$1 = value => null == value;
|
|
1396
1396
|
var isNil$2 = isNil$1;
|
|
@@ -1408,7 +1408,7 @@
|
|
|
1408
1408
|
var isObjectLike$e = isObjectLike$d;
|
|
1409
1409
|
|
|
1410
1410
|
const isPlainObject$3 = function (value) {
|
|
1411
|
-
if (!isObjectLike$e(value) || !isType$
|
|
1411
|
+
if (!isObjectLike$e(value) || !isType$3(value, "Object")) return !1;
|
|
1412
1412
|
if (null === Object.getPrototypeOf(value)) return !0;
|
|
1413
1413
|
let proto = value;
|
|
1414
1414
|
for (; null !== Object.getPrototypeOf(proto);) proto = Object.getPrototypeOf(proto);
|
|
@@ -1419,27 +1419,27 @@
|
|
|
1419
1419
|
const isUndefined$1 = value => void 0 === value;
|
|
1420
1420
|
var isUndefined$2 = isUndefined$1;
|
|
1421
1421
|
|
|
1422
|
-
const isString = (value, fuzzy = !1) => {
|
|
1422
|
+
const isString$2 = (value, fuzzy = !1) => {
|
|
1423
1423
|
const type = typeof value;
|
|
1424
|
-
return fuzzy ? "string" === type : "string" === type || isType$
|
|
1424
|
+
return fuzzy ? "string" === type : "string" === type || isType$3(value, "String");
|
|
1425
1425
|
};
|
|
1426
|
-
var isString$
|
|
1426
|
+
var isString$3 = isString$2;
|
|
1427
1427
|
|
|
1428
|
-
const isArray$
|
|
1429
|
-
var isArray$
|
|
1428
|
+
const isArray$b = value => Array.isArray ? Array.isArray(value) : isType$3(value, "Array");
|
|
1429
|
+
var isArray$c = isArray$b;
|
|
1430
1430
|
|
|
1431
1431
|
const isArrayLike$7 = function (value) {
|
|
1432
1432
|
return null !== value && "function" != typeof value && Number.isFinite(value.length);
|
|
1433
1433
|
};
|
|
1434
1434
|
var isArrayLike$8 = isArrayLike$7;
|
|
1435
1435
|
|
|
1436
|
-
const isNumber$
|
|
1436
|
+
const isNumber$5 = (value, fuzzy = !1) => {
|
|
1437
1437
|
const type = typeof value;
|
|
1438
|
-
return fuzzy ? "number" === type : "number" === type || isType$
|
|
1438
|
+
return fuzzy ? "number" === type : "number" === type || isType$3(value, "Number");
|
|
1439
1439
|
};
|
|
1440
|
-
var isNumber$
|
|
1440
|
+
var isNumber$6 = isNumber$5;
|
|
1441
1441
|
|
|
1442
|
-
const isValidNumber = value => isNumber$
|
|
1442
|
+
const isValidNumber = value => isNumber$6(value) && Number.isFinite(value);
|
|
1443
1443
|
var isValidNumber$1 = isValidNumber;
|
|
1444
1444
|
|
|
1445
1445
|
const isValidUrl = value => new RegExp(/^(http(s)?:\/\/)\w+[^\s]+(\.[^\s]+){1,}$/).test(value);
|
|
@@ -1486,7 +1486,7 @@
|
|
|
1486
1486
|
propIndex = -1;
|
|
1487
1487
|
for (; length--;) {
|
|
1488
1488
|
const key = props[++propIndex];
|
|
1489
|
-
!isValid$3(iterable[key]) || "object" != typeof iterable[key] || skipTargetArray && isArray$
|
|
1489
|
+
!isValid$3(iterable[key]) || "object" != typeof iterable[key] || skipTargetArray && isArray$c(target[key]) ? assignMergeValue(target, key, iterable[key]) : baseMergeDeep(target, source, key, shallowArray, skipTargetArray);
|
|
1490
1490
|
}
|
|
1491
1491
|
}
|
|
1492
1492
|
}
|
|
@@ -1496,8 +1496,8 @@
|
|
|
1496
1496
|
srcValue = source[key];
|
|
1497
1497
|
let newValue = source[key],
|
|
1498
1498
|
isCommon = !0;
|
|
1499
|
-
if (isArray$
|
|
1500
|
-
if (shallowArray) newValue = [];else if (isArray$
|
|
1499
|
+
if (isArray$c(srcValue)) {
|
|
1500
|
+
if (shallowArray) newValue = [];else if (isArray$c(objValue)) newValue = objValue;else if (isArrayLike$8(objValue)) {
|
|
1501
1501
|
newValue = new Array(objValue.length);
|
|
1502
1502
|
let index = -1;
|
|
1503
1503
|
const length = objValue.length;
|
|
@@ -1522,7 +1522,7 @@
|
|
|
1522
1522
|
}
|
|
1523
1523
|
|
|
1524
1524
|
function arrayEqual(a, b) {
|
|
1525
|
-
if (!isArray$
|
|
1525
|
+
if (!isArray$c(a) || !isArray$c(b)) return !1;
|
|
1526
1526
|
if (a.length !== b.length) return !1;
|
|
1527
1527
|
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return !1;
|
|
1528
1528
|
return !0;
|
|
@@ -1539,7 +1539,7 @@
|
|
|
1539
1539
|
}(LoggerLevel || (LoggerLevel = {}));
|
|
1540
1540
|
class Logger {
|
|
1541
1541
|
static getInstance(level, method) {
|
|
1542
|
-
return Logger._instance && isNumber$
|
|
1542
|
+
return Logger._instance && isNumber$6(level) ? Logger._instance.level(level) : Logger._instance || (Logger._instance = new Logger(level, method)), Logger._instance;
|
|
1543
1543
|
}
|
|
1544
1544
|
static setInstance(logger) {
|
|
1545
1545
|
return Logger._instance = logger;
|
|
@@ -1729,10 +1729,10 @@
|
|
|
1729
1729
|
return this.x = x, this.y = y, this;
|
|
1730
1730
|
}
|
|
1731
1731
|
add(point) {
|
|
1732
|
-
return isNumber$
|
|
1732
|
+
return isNumber$6(point) ? (this.x += point, void (this.y += point)) : (this.x += point.x, this.y += point.y, this);
|
|
1733
1733
|
}
|
|
1734
1734
|
sub(point) {
|
|
1735
|
-
return isNumber$
|
|
1735
|
+
return isNumber$6(point) ? (this.x -= point, void (this.y -= point)) : (this.x -= point.x, this.y -= point.y, this);
|
|
1736
1736
|
}
|
|
1737
1737
|
multi(point) {
|
|
1738
1738
|
throw new Error("暂不支持");
|
|
@@ -1964,7 +1964,7 @@
|
|
|
1964
1964
|
let {
|
|
1965
1965
|
lineHeight = fontSize
|
|
1966
1966
|
} = this._userSpec;
|
|
1967
|
-
if (isString$
|
|
1967
|
+
if (isString$3(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
|
|
1968
1968
|
const scale = Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100;
|
|
1969
1969
|
lineHeight = fontSize * scale;
|
|
1970
1970
|
}
|
|
@@ -2096,7 +2096,7 @@
|
|
|
2096
2096
|
height: 0
|
|
2097
2097
|
};
|
|
2098
2098
|
if (isNil$2(text)) return defaultResult;
|
|
2099
|
-
if (isArray$
|
|
2099
|
+
if (isArray$c(text)) {
|
|
2100
2100
|
const textArr = text.filter(isValid$3).map(s => s.toString());
|
|
2101
2101
|
return 0 === textArr.length ? defaultResult : 1 === textArr.length ? processor(textArr[0]) : {
|
|
2102
2102
|
width: textArr.reduce((maxWidth, cur) => Math.max(maxWidth, processor(cur).width), 0),
|
|
@@ -2176,7 +2176,7 @@
|
|
|
2176
2176
|
return x < this.x1 && (this.x1 = x), y < this.y1 && (this.y1 = y), x > this.x2 && (this.x2 = x), y > this.y2 && (this.y2 = y), this;
|
|
2177
2177
|
}
|
|
2178
2178
|
expand(d = 0) {
|
|
2179
|
-
return isArray$
|
|
2179
|
+
return isArray$c(d) ? (this.y1 -= d[0], this.x2 += d[1], this.y2 += d[2], this.x1 -= d[3]) : (this.x1 -= d, this.y1 -= d, this.x2 += d, this.y2 += d), this;
|
|
2180
2180
|
}
|
|
2181
2181
|
round() {
|
|
2182
2182
|
return this.x1 = Math.floor(this.x1), this.y1 = Math.floor(this.y1), this.x2 = Math.ceil(this.x2), this.y2 = Math.ceil(this.y2), this;
|
|
@@ -2454,7 +2454,7 @@
|
|
|
2454
2454
|
|
|
2455
2455
|
function normalizePadding(padding) {
|
|
2456
2456
|
if (isValidNumber$1(padding)) return [padding, padding, padding, padding];
|
|
2457
|
-
if (isArray$
|
|
2457
|
+
if (isArray$c(padding)) {
|
|
2458
2458
|
const length = padding.length;
|
|
2459
2459
|
if (1 === length) {
|
|
2460
2460
|
const paddingValue = padding[0];
|
|
@@ -4400,7 +4400,7 @@
|
|
|
4400
4400
|
var _a, _b, _c, _d;
|
|
4401
4401
|
if (!c || !0 === c) return "black";
|
|
4402
4402
|
let result, color;
|
|
4403
|
-
if (isArray$
|
|
4403
|
+
if (isArray$c(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
|
|
4404
4404
|
if (color = GradientParser.Parse(color), "string" == typeof color) return color;
|
|
4405
4405
|
if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
|
|
4406
4406
|
const bounds = params.AABBBounds;
|
|
@@ -4874,7 +4874,7 @@
|
|
|
4874
4874
|
function isNotAroundZero(val) {
|
|
4875
4875
|
return val > EPSILON || val < -EPSILON;
|
|
4876
4876
|
}
|
|
4877
|
-
function isNumber$
|
|
4877
|
+
function isNumber$4(data) {
|
|
4878
4878
|
return "number" == typeof data && Number.isFinite(data);
|
|
4879
4879
|
}
|
|
4880
4880
|
const _v0 = [0, 0],
|
|
@@ -5984,18 +5984,18 @@
|
|
|
5984
5984
|
return this.removeChild(child);
|
|
5985
5985
|
}
|
|
5986
5986
|
addEventListener(type, listener, options) {
|
|
5987
|
-
const capture = isBoolean$
|
|
5987
|
+
const capture = isBoolean$4(options, !0) && options || isObject$c(options) && options.capture,
|
|
5988
5988
|
once = isObject$c(options) && options.once,
|
|
5989
|
-
context = isFunction$
|
|
5990
|
-
return type = capture ? `${type}capture` : type, listener = isFunction$
|
|
5989
|
+
context = isFunction$c(listener) ? void 0 : listener;
|
|
5990
|
+
return type = capture ? `${type}capture` : type, listener = isFunction$c(listener) ? listener : listener.handleEvent, once ? super.once(type, listener, context) : super.on(type, listener, context), this;
|
|
5991
5991
|
}
|
|
5992
5992
|
on(type, listener, options) {
|
|
5993
5993
|
return this.addEventListener(type, listener, options);
|
|
5994
5994
|
}
|
|
5995
5995
|
removeEventListener(type, listener, options) {
|
|
5996
|
-
const capture = isBoolean$
|
|
5997
|
-
context = isFunction$
|
|
5998
|
-
type = capture ? `${type}capture` : type, listener = isFunction$
|
|
5996
|
+
const capture = isBoolean$4(options, !0) && options || isObject$c(options) && options.capture,
|
|
5997
|
+
context = isFunction$c(listener) ? void 0 : listener;
|
|
5998
|
+
type = capture ? `${type}capture` : type, listener = isFunction$c(listener) ? listener : listener.handleEvent;
|
|
5999
5999
|
const once = isObject$c(options) && options.once;
|
|
6000
6000
|
return super.off(type, listener, context, once), this;
|
|
6001
6001
|
}
|
|
@@ -6089,7 +6089,7 @@
|
|
|
6089
6089
|
try {
|
|
6090
6090
|
this.nativeEvent instanceof Event && this.nativeEvent.cancelable && this.nativeEvent.preventDefault();
|
|
6091
6091
|
} catch (err) {
|
|
6092
|
-
this.nativeEvent.preventDefault && isFunction$
|
|
6092
|
+
this.nativeEvent.preventDefault && isFunction$c(this.nativeEvent.preventDefault) && this.nativeEvent.preventDefault();
|
|
6093
6093
|
}
|
|
6094
6094
|
this.defaultPrevented = !0;
|
|
6095
6095
|
}
|
|
@@ -6100,7 +6100,7 @@
|
|
|
6100
6100
|
try {
|
|
6101
6101
|
this.nativeEvent instanceof Event && this.nativeEvent.cancelable && this.nativeEvent.stopPropagation();
|
|
6102
6102
|
} catch (err) {
|
|
6103
|
-
this.nativeEvent.stopPropagation && isFunction$
|
|
6103
|
+
this.nativeEvent.stopPropagation && isFunction$c(this.nativeEvent.stopPropagation) && this.nativeEvent.stopPropagation();
|
|
6104
6104
|
}
|
|
6105
6105
|
this.propagationStopped = !0;
|
|
6106
6106
|
}
|
|
@@ -6553,7 +6553,7 @@
|
|
|
6553
6553
|
if (this.currentCursor === mode) return;
|
|
6554
6554
|
this.currentCursor = mode;
|
|
6555
6555
|
const style = this.cursorStyles[mode];
|
|
6556
|
-
style ? "string" == typeof style && applyStyles ? domElement.style.cursor = style : "function" == typeof style ? style(mode) : "object" == typeof style && applyStyles && Object.assign(domElement.style, style) : applyStyles && isString$
|
|
6556
|
+
style ? "string" == typeof style && applyStyles ? domElement.style.cursor = style : "function" == typeof style ? style(mode) : "object" == typeof style && applyStyles && Object.assign(domElement.style, style) : applyStyles && isString$3(mode) && !has$1(this.cursorStyles, mode) && (domElement.style.cursor = mode);
|
|
6557
6557
|
}
|
|
6558
6558
|
setTargetElement(element) {
|
|
6559
6559
|
this.removeEvents(), this.domElement = element, this.addEvents();
|
|
@@ -6753,7 +6753,7 @@
|
|
|
6753
6753
|
Edge[Edge.Top = 1] = "Top", Edge[Edge.Right = 2] = "Right", Edge[Edge.Bottom = 4] = "Bottom", Edge[Edge.Left = 8] = "Left", Edge[Edge.ALL = 15] = "ALL";
|
|
6754
6754
|
}(Edge || (Edge = {}));
|
|
6755
6755
|
const _paddingVec4 = [0, 0, 0, 0];
|
|
6756
|
-
const parsePadding = padding => padding ? isArray$
|
|
6756
|
+
const parsePadding = padding => padding ? isArray$c(padding) ? 0 === padding.length ? 0 : 1 === padding.length ? padding[0] : 2 === padding.length ? (_paddingVec4[0] = padding[0], _paddingVec4[2] = padding[0], _paddingVec4[1] = padding[1], _paddingVec4[3] = padding[1], _paddingVec4) : padding : padding : 0;
|
|
6757
6757
|
const _coords = [{
|
|
6758
6758
|
x: 0,
|
|
6759
6759
|
y: 0
|
|
@@ -6822,7 +6822,7 @@
|
|
|
6822
6822
|
return points;
|
|
6823
6823
|
}
|
|
6824
6824
|
function getAttributeFromDefaultAttrList(attr, key) {
|
|
6825
|
-
if (isArray$
|
|
6825
|
+
if (isArray$c(attr)) {
|
|
6826
6826
|
let val;
|
|
6827
6827
|
for (let i = 0; i < attr.length && void 0 === val; i++) val = attr[i][key];
|
|
6828
6828
|
return val;
|
|
@@ -6830,7 +6830,7 @@
|
|
|
6830
6830
|
return attr[key];
|
|
6831
6831
|
}
|
|
6832
6832
|
const _calculateLineHeight = (lineHeight, fontSize) => {
|
|
6833
|
-
if (isString$
|
|
6833
|
+
if (isString$3(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
|
|
6834
6834
|
return fontSize * (Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100);
|
|
6835
6835
|
}
|
|
6836
6836
|
return lineHeight;
|
|
@@ -6842,13 +6842,13 @@
|
|
|
6842
6842
|
|
|
6843
6843
|
class BaseSymbol {
|
|
6844
6844
|
bounds(size, bounds) {
|
|
6845
|
-
if (isNumber$
|
|
6845
|
+
if (isNumber$6(size)) {
|
|
6846
6846
|
const halfS = size / 2;
|
|
6847
6847
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
6848
6848
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
6849
6849
|
}
|
|
6850
6850
|
parseSize(size) {
|
|
6851
|
-
return isNumber$
|
|
6851
|
+
return isNumber$6(size) ? size : Math.min(size[0], size[1]);
|
|
6852
6852
|
}
|
|
6853
6853
|
}
|
|
6854
6854
|
|
|
@@ -7264,10 +7264,10 @@
|
|
|
7264
7264
|
super(...arguments), this.type = "rect", this.pathStr = "M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z";
|
|
7265
7265
|
}
|
|
7266
7266
|
draw(ctx, size, x, y) {
|
|
7267
|
-
return isNumber$
|
|
7267
|
+
return isNumber$6(size) ? rectSize(ctx, size, x, y) : rectSizeArray(ctx, size, x, y);
|
|
7268
7268
|
}
|
|
7269
7269
|
drawWithClipRange(ctx, size, x, y, clipRange, z, cb) {
|
|
7270
|
-
isNumber$
|
|
7270
|
+
isNumber$6(size) && (size = [size, size / 2]);
|
|
7271
7271
|
const drawLength = 2 * (size[0] + size[1]) * clipRange,
|
|
7272
7272
|
points = [{
|
|
7273
7273
|
x: x + size[0] / 2,
|
|
@@ -7299,7 +7299,7 @@
|
|
|
7299
7299
|
return !1;
|
|
7300
7300
|
}
|
|
7301
7301
|
drawOffset(ctx, size, x, y, offset) {
|
|
7302
|
-
return isNumber$
|
|
7302
|
+
return isNumber$6(size) ? rectSize(ctx, size + 2 * offset, x, y) : rectSizeArray(ctx, [size[0] + 2 * offset, size[1] + 2 * offset], x, y);
|
|
7303
7303
|
}
|
|
7304
7304
|
}
|
|
7305
7305
|
var rect = new RectSymbol();
|
|
@@ -7307,7 +7307,7 @@
|
|
|
7307
7307
|
const tempBounds = new AABBBounds();
|
|
7308
7308
|
class CustomSymbolClass {
|
|
7309
7309
|
constructor(type, path, isSvg = !1) {
|
|
7310
|
-
this.pathStr = "", this.type = type, isArray$
|
|
7310
|
+
this.pathStr = "", this.type = type, isArray$c(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
7311
7311
|
}
|
|
7312
7312
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
7313
7313
|
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
@@ -7318,7 +7318,7 @@
|
|
|
7318
7318
|
return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
7319
7319
|
}
|
|
7320
7320
|
parseSize(size) {
|
|
7321
|
-
return isNumber$
|
|
7321
|
+
return isNumber$6(size) ? size : Math.min(size[0], size[1]);
|
|
7322
7322
|
}
|
|
7323
7323
|
drawWithClipRange(ctx, size, x, y, clipRange, z, cb) {
|
|
7324
7324
|
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
@@ -8131,7 +8131,7 @@
|
|
|
8131
8131
|
svg: svg
|
|
8132
8132
|
} = parser.parse(symbolType);
|
|
8133
8133
|
if (!svg) return null;
|
|
8134
|
-
const path = isArray$
|
|
8134
|
+
const path = isArray$c(svg.path) ? svg.path : [svg.path];
|
|
8135
8135
|
_tempBounds.clear();
|
|
8136
8136
|
const cacheList = [];
|
|
8137
8137
|
path.forEach(item => {
|
|
@@ -8436,7 +8436,7 @@
|
|
|
8436
8436
|
}
|
|
8437
8437
|
removeState(stateName, hasAnimation) {
|
|
8438
8438
|
if (this.currentStates) {
|
|
8439
|
-
const filter = isArray$
|
|
8439
|
+
const filter = isArray$c(stateName) ? s => !stateName.includes(s) : s => s !== stateName,
|
|
8440
8440
|
newStates = this.currentStates.filter(filter);
|
|
8441
8441
|
newStates.length !== this.currentStates.length && this.useStates(newStates, hasAnimation);
|
|
8442
8442
|
}
|
|
@@ -8604,7 +8604,7 @@
|
|
|
8604
8604
|
};
|
|
8605
8605
|
}
|
|
8606
8606
|
createPathProxy(path) {
|
|
8607
|
-
return isString$
|
|
8607
|
+
return isString$3(path, !0) ? this.pathProxy = new CustomPath2D().fromString(path) : this.pathProxy = new CustomPath2D(), this.pathProxy;
|
|
8608
8608
|
}
|
|
8609
8609
|
loadImage(image, background = !1) {
|
|
8610
8610
|
if (!image || background && backgroundNotImage(image)) return;
|
|
@@ -9055,7 +9055,7 @@
|
|
|
9055
9055
|
}
|
|
9056
9056
|
function runStroke(stroke, lineWidth) {
|
|
9057
9057
|
let s;
|
|
9058
|
-
return s = isArray$
|
|
9058
|
+
return s = isArray$c(stroke) ? stroke.some(item => item || void 0 === item) : !!stroke, s && lineWidth > 0;
|
|
9059
9059
|
}
|
|
9060
9060
|
function fillVisible(opacity, fillOpacity, fill) {
|
|
9061
9061
|
return fill && opacity * fillOpacity > 0;
|
|
@@ -9209,12 +9209,12 @@
|
|
|
9209
9209
|
textBaseline: textBaseline
|
|
9210
9210
|
} = attribute;
|
|
9211
9211
|
if (null != attribute.forceBoundsHeight) {
|
|
9212
|
-
const h = isNumber$
|
|
9212
|
+
const h = isNumber$6(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
|
|
9213
9213
|
dy = textLayoutOffsetY(textBaseline, h, h);
|
|
9214
9214
|
aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
|
|
9215
9215
|
}
|
|
9216
9216
|
if (null != attribute.forceBoundsWidth) {
|
|
9217
|
-
const w = isNumber$
|
|
9217
|
+
const w = isNumber$6(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
|
|
9218
9218
|
dx = textDrawOffsetX(textAlign, w);
|
|
9219
9219
|
aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
|
|
9220
9220
|
}
|
|
@@ -9511,7 +9511,7 @@
|
|
|
9511
9511
|
const {
|
|
9512
9512
|
text: text
|
|
9513
9513
|
} = this.attribute;
|
|
9514
|
-
return isArray$
|
|
9514
|
+
return isArray$c(text) ? !text.every(t => null == t || "" === t) : null != text && "" !== text;
|
|
9515
9515
|
}
|
|
9516
9516
|
getGraphicTheme() {
|
|
9517
9517
|
return getTheme(this).text;
|
|
@@ -9666,7 +9666,7 @@
|
|
|
9666
9666
|
lineHeight: lineHeight
|
|
9667
9667
|
},
|
|
9668
9668
|
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
9669
|
-
lines = isArray$
|
|
9669
|
+
lines = isArray$c(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
9670
9670
|
linesLayout = [],
|
|
9671
9671
|
bboxWH = [0, 0];
|
|
9672
9672
|
let lineCountLimit = 1 / 0;
|
|
@@ -9921,7 +9921,7 @@
|
|
|
9921
9921
|
const {
|
|
9922
9922
|
size: size
|
|
9923
9923
|
} = this.attribute;
|
|
9924
|
-
return isArray$
|
|
9924
|
+
return isArray$c(size) ? 2 === size.length && size.every(this._validNumber) : this._validNumber(size);
|
|
9925
9925
|
}
|
|
9926
9926
|
doUpdateParsedPath() {
|
|
9927
9927
|
const {
|
|
@@ -9948,7 +9948,7 @@
|
|
|
9948
9948
|
const {
|
|
9949
9949
|
size = symbolTheme.size
|
|
9950
9950
|
} = attribute;
|
|
9951
|
-
if (isArray$
|
|
9951
|
+
if (isArray$c(size)) aabbBounds.set(-size[0] / 2, -size[1] / 2, size[0] / 2, size[1] / 2);else {
|
|
9952
9952
|
const halfWH = size / 2;
|
|
9953
9953
|
aabbBounds.set(-halfWH, -halfWH, halfWH, halfWH);
|
|
9954
9954
|
}
|
|
@@ -9969,7 +9969,7 @@
|
|
|
9969
9969
|
toCustomPath() {
|
|
9970
9970
|
const symbolInstance = this.getParsedPath(),
|
|
9971
9971
|
size = this.attribute.size,
|
|
9972
|
-
formattedSize = isArray$
|
|
9972
|
+
formattedSize = isArray$c(size) ? size : [size, size];
|
|
9973
9973
|
return symbolInstance.path ? new CustomPath2D().fromCustomPath2D(symbolInstance.path, 0, 0, formattedSize[0], formattedSize[1]) : new CustomPath2D().fromString(symbolInstance.pathStr, 0, 0, formattedSize[0], formattedSize[1]);
|
|
9974
9974
|
}
|
|
9975
9975
|
clone() {
|
|
@@ -10733,7 +10733,7 @@
|
|
|
10733
10733
|
const halfPi = pi / 2;
|
|
10734
10734
|
function createRectPath(path, x, y, width, height, rectCornerRadius, roundCorner = !0, edgeCb) {
|
|
10735
10735
|
let cornerRadius;
|
|
10736
|
-
if (Array.isArray(roundCorner) && (edgeCb = roundCorner, roundCorner = !0), width < 0 && (x += width, width = -width), height < 0 && (y += height, height = -height), isNumber$
|
|
10736
|
+
if (Array.isArray(roundCorner) && (edgeCb = roundCorner, roundCorner = !0), width < 0 && (x += width, width = -width), height < 0 && (y += height, height = -height), isNumber$6(rectCornerRadius, !0)) cornerRadius = [rectCornerRadius = abs(rectCornerRadius), rectCornerRadius, rectCornerRadius, rectCornerRadius];else if (Array.isArray(rectCornerRadius)) {
|
|
10737
10737
|
const cornerRadiusArr = rectCornerRadius;
|
|
10738
10738
|
let cr0, cr1;
|
|
10739
10739
|
switch (cornerRadiusArr.length) {
|
|
@@ -10835,7 +10835,7 @@
|
|
|
10835
10835
|
nextX = x + sign * d,
|
|
10836
10836
|
nextY = y + sign * d,
|
|
10837
10837
|
dw = 2 * d;
|
|
10838
|
-
if (0 === cornerRadius || isArray$
|
|
10838
|
+
if (0 === cornerRadius || isArray$c(cornerRadius) && cornerRadius.every(num => 0 === num) ? (context.beginPath(), context.rect(nextX, nextY, width - sign * dw, height - sign * dw)) : (context.beginPath(), createRectPath(context, nextX, nextY, width - sign * dw, height - sign * dw, cornerRadius, "bevel" !== cornerType)), context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), strokeCb) strokeCb(context, borderStyle, rectAttribute[key]);else if (doStroke) {
|
|
10839
10839
|
const lastOpacity = rectAttribute[key].opacity;
|
|
10840
10840
|
rectAttribute[key].opacity = opacity, context.setStrokeStyle(rect, borderStyle, (originX - x) / scaleX, (originY - y) / scaleY, rectAttribute[key]), rectAttribute[key].opacity = lastOpacity, context.stroke();
|
|
10841
10841
|
}
|
|
@@ -10874,7 +10874,7 @@
|
|
|
10874
10874
|
height: height
|
|
10875
10875
|
} = rect.attribute;
|
|
10876
10876
|
if (width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0, Array.isArray(stroke) && stroke.some(s => !1 === s)) {
|
|
10877
|
-
if (context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute), !(0 === cornerRadius || isArray$
|
|
10877
|
+
if (context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute), !(0 === cornerRadius || isArray$c(cornerRadius) && cornerRadius.every(num => 0 === num))) {
|
|
10878
10878
|
let lastStroke,
|
|
10879
10879
|
lastStrokeI = 0;
|
|
10880
10880
|
return createRectPath(context, x, y, width, height, cornerRadius, "bevel" !== cornerType, new Array(4).fill(0).map((_, i) => (x1, y1, x2, y2) => {
|
|
@@ -11296,7 +11296,7 @@
|
|
|
11296
11296
|
offsetX: offsetX,
|
|
11297
11297
|
offsetY: offsetY,
|
|
11298
11298
|
offsetZ: z
|
|
11299
|
-
}), line.cache && !isArray$
|
|
11299
|
+
}), line.cache && !isArray$c(line.cache) && line.cache.curves.every(c => c.defined) && line.attribute.curveType && line.attribute.curveType.includes("Closed") && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(line, attribute, defaultAttribute);
|
|
11300
11300
|
const {
|
|
11301
11301
|
x: originX = 0,
|
|
11302
11302
|
x: originY = 0
|
|
@@ -11536,7 +11536,7 @@
|
|
|
11536
11536
|
const {
|
|
11537
11537
|
stroke = areaAttribute && areaAttribute.stroke
|
|
11538
11538
|
} = area.attribute;
|
|
11539
|
-
if (isArray$
|
|
11539
|
+
if (isArray$c(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
|
|
11540
11540
|
context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
|
|
11541
11541
|
for (let i = 1; i < points.length; i++) {
|
|
11542
11542
|
const p = points[i];
|
|
@@ -11714,7 +11714,7 @@
|
|
|
11714
11714
|
const {
|
|
11715
11715
|
stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
|
|
11716
11716
|
} = attribute;
|
|
11717
|
-
isArray$
|
|
11717
|
+
isArray$c(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction.ROW ? "x" : "y", {
|
|
11718
11718
|
offsetX: offsetX,
|
|
11719
11719
|
offsetY: offsetY,
|
|
11720
11720
|
offsetZ: offsetZ
|
|
@@ -11775,7 +11775,7 @@
|
|
|
11775
11775
|
if (!rect.valid || !visible) return;
|
|
11776
11776
|
if (!doFill && !doStroke) return;
|
|
11777
11777
|
if (!(fVisible || sVisible || fillCb || strokeCb || background)) return;
|
|
11778
|
-
0 === cornerRadius || isArray$
|
|
11778
|
+
0 === cornerRadius || isArray$c(cornerRadius) && cornerRadius.every(num => 0 === num) ? (context.beginPath(), context.rect(x, y, width, height)) : (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius, "bevel" !== cornerType));
|
|
11779
11779
|
const doFillOrStroke = {
|
|
11780
11780
|
doFill: doFill,
|
|
11781
11781
|
doStroke: doStroke
|
|
@@ -11847,7 +11847,7 @@
|
|
|
11847
11847
|
const camera = context.camera;
|
|
11848
11848
|
if (keepDirIn3d && camera && context.project) {
|
|
11849
11849
|
const p = context.project(x, y, z);
|
|
11850
|
-
context.camera = null, isArray$
|
|
11850
|
+
context.camera = null, isArray$c(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX, _x = p.x, _y = p.y, _z = void 0;
|
|
11851
11851
|
}
|
|
11852
11852
|
!1 === parsedPath.draw(context, size, _x, _y, _z, (p, a) => {
|
|
11853
11853
|
var _a, _b, _c, _d;
|
|
@@ -12179,7 +12179,7 @@
|
|
|
12179
12179
|
context.disableFill = !0, context.disableStroke = !0, context.disableBeginPath = !0, path.forEach(g => {
|
|
12180
12180
|
drawContext.drawContribution.getRenderContribution(g).draw(g, drawContext.renderService, drawContext, params);
|
|
12181
12181
|
}), context.disableFill = disableFill, context.disableStroke = disableStroke, context.disableBeginPath = disableBeginPath;
|
|
12182
|
-
} else 0 === cornerRadius || isArray$
|
|
12182
|
+
} else 0 === cornerRadius || isArray$c(cornerRadius) && cornerRadius.every(num => 0 === num) ? (context.beginPath(), context.rect(x, y, width, height)) : (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius, "bevel" !== cornerType));
|
|
12183
12183
|
this._groupRenderContribitions || (this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [], this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution));
|
|
12184
12184
|
const doFillOrStroke = {
|
|
12185
12185
|
doFill: doFill,
|
|
@@ -12922,7 +12922,7 @@
|
|
|
12922
12922
|
}) : foreach(group, DefaultAttribute.zIndex, item => {
|
|
12923
12923
|
drawContext.break || (item.isContainer ? this.renderGroup(item, drawContext, nextM) : this.renderItem(item, drawContext));
|
|
12924
12924
|
}, !1, !!(null === (_a = drawContext.context) || void 0 === _a ? void 0 : _a.camera));
|
|
12925
|
-
}, this.currentRenderMap = new Map(), this.defaultRenderMap = new Map(), this.styleRenderMap = new Map(), this.dirtyBounds = new Bounds(), this.backupDirtyBounds = new Bounds(), this.global = application.global, this.layerService = application.layerService, isArray$
|
|
12925
|
+
}, this.currentRenderMap = new Map(), this.defaultRenderMap = new Map(), this.styleRenderMap = new Map(), this.dirtyBounds = new Bounds(), this.backupDirtyBounds = new Bounds(), this.global = application.global, this.layerService = application.layerService, isArray$c(this.contributions) || (this.contributions = [this.contributions]), this.init();
|
|
12926
12926
|
}
|
|
12927
12927
|
reInit() {
|
|
12928
12928
|
this.init(), this.contributions.forEach(item => {
|
|
@@ -13656,7 +13656,7 @@
|
|
|
13656
13656
|
main: !0
|
|
13657
13657
|
})), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
|
|
13658
13658
|
tickRenderMode: "effect"
|
|
13659
|
-
}), this.optmize(params.optimize), params.background && isString$
|
|
13659
|
+
}), this.optmize(params.optimize), params.background && isString$3(this._background) && this._background.includes("/") && this.setAttributes({
|
|
13660
13660
|
background: this._background
|
|
13661
13661
|
}), this.initAnimate(params), this.rafId = null !== (_b = params.rafId) && void 0 !== _b ? _b : Math.floor(6 * Math.random());
|
|
13662
13662
|
}
|
|
@@ -14124,7 +14124,7 @@
|
|
|
14124
14124
|
}
|
|
14125
14125
|
function mapToCanvasPointForCanvas(nativeEvent) {
|
|
14126
14126
|
var _a;
|
|
14127
|
-
if (isNumber$
|
|
14127
|
+
if (isNumber$4(nativeEvent._canvasX) && isNumber$4(nativeEvent._canvasY)) return {
|
|
14128
14128
|
x: nativeEvent._canvasX,
|
|
14129
14129
|
y: nativeEvent._canvasY
|
|
14130
14130
|
};
|
|
@@ -14188,7 +14188,7 @@
|
|
|
14188
14188
|
[key]: value
|
|
14189
14189
|
}, this.attribute, key, context);
|
|
14190
14190
|
if (params) return this._setAttributes(params, forceUpdateTag);
|
|
14191
|
-
isPlainObject$4(this.attribute[key]) && isPlainObject$4(value) && !isFunction$
|
|
14191
|
+
isPlainObject$4(this.attribute[key]) && isPlainObject$4(value) && !isFunction$c(this.attribute[key]) && !isFunction$c(value) ? merge(this.attribute[key], value) : this.attribute[key] = value, this._skipRenderAttributes.includes(key) || this.render(), this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.onAttributeUpdate();
|
|
14192
14192
|
}
|
|
14193
14193
|
setAttributes(params, forceUpdateTag, context) {
|
|
14194
14194
|
return params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this._setAttributes(params, forceUpdateTag);
|
|
@@ -14201,7 +14201,7 @@
|
|
|
14201
14201
|
isNil$2(keys) && (keys = Object.keys(params));
|
|
14202
14202
|
for (let i = 0; i < keys.length; i++) {
|
|
14203
14203
|
const key = keys[i];
|
|
14204
|
-
!isPlainObject$4(this.attribute[key]) || isFunction$
|
|
14204
|
+
!isPlainObject$4(this.attribute[key]) || isFunction$c(this.attribute[key]) || isFunction$c(params[key]) ? this.attribute[key] = params[key] : merge(this.attribute[key], params[key]);
|
|
14205
14205
|
}
|
|
14206
14206
|
}
|
|
14207
14207
|
bindEvents() {}
|
|
@@ -14295,7 +14295,7 @@
|
|
|
14295
14295
|
x += point.x, y += point.y, pickContext.setTransformForCurrent();
|
|
14296
14296
|
} else x = 0, y = 0, onlyTranslate = !1, pickContext.transformFromMatrix(rect.transMatrix, !0);
|
|
14297
14297
|
let picked = !0;
|
|
14298
|
-
if (!onlyTranslate || rect.shadowRoot || isNumber$
|
|
14298
|
+
if (!onlyTranslate || rect.shadowRoot || isNumber$6(cornerRadius, !0) && 0 !== cornerRadius || isArray$c(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
|
|
14299
14299
|
if (picked) return !0;
|
|
14300
14300
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
14301
14301
|
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
@@ -14974,7 +14974,7 @@
|
|
|
14974
14974
|
const maxLineWidth = maxWidth - parsedPadding[1] - parsedPadding[3],
|
|
14975
14975
|
titleVisible = isValid$3(title) && !1 !== visible,
|
|
14976
14976
|
titleAttrs = Object.assign(Object.assign({
|
|
14977
|
-
text: isArray$
|
|
14977
|
+
text: isArray$c(title) ? title : [title],
|
|
14978
14978
|
visible: titleVisible,
|
|
14979
14979
|
wrap: !0
|
|
14980
14980
|
}, titleStyle), {
|
|
@@ -14993,7 +14993,7 @@
|
|
|
14993
14993
|
titleVisible || (height = 0);
|
|
14994
14994
|
const contentVisible = isValid$3(content) && !1 !== visible,
|
|
14995
14995
|
contentAttrs = Object.assign(Object.assign({
|
|
14996
|
-
text: isArray$
|
|
14996
|
+
text: isArray$c(content) ? content : [content],
|
|
14997
14997
|
visible: contentVisible,
|
|
14998
14998
|
wrap: !0
|
|
14999
14999
|
}, contentStyle), {
|
|
@@ -15028,7 +15028,7 @@
|
|
|
15028
15028
|
});
|
|
15029
15029
|
}
|
|
15030
15030
|
const symbolSize = null !== (_a = backgroundStyle.size) && void 0 !== _a ? _a : 12,
|
|
15031
|
-
spaceSize = isArray$
|
|
15031
|
+
spaceSize = isArray$c(symbolSize) ? [symbolSize[0] + (null !== (_b = backgroundStyle.space) && void 0 !== _b ? _b : 0), symbolSize[1] + (null !== (_c = backgroundStyle.space) && void 0 !== _c ? _c : 0)] : symbolSize + (null !== (_d = backgroundStyle.space) && void 0 !== _d ? _d : 0),
|
|
15032
15032
|
lineWidth = null !== (_e = backgroundStyle.lineWidth) && void 0 !== _e ? _e : 1,
|
|
15033
15033
|
range = this.stage ? [null !== (_f = this.stage.viewWidth) && void 0 !== _f ? _f : this.stage.width, null !== (_g = this.stage.viewHeight) && void 0 !== _g ? _g : this.stage.height] : void 0;
|
|
15034
15034
|
if (range) {
|
|
@@ -15036,33 +15036,33 @@
|
|
|
15036
15036
|
leftWidth = null !== (_h = this.attribute.x) && void 0 !== _h ? _h : b.x1,
|
|
15037
15037
|
rightWidth = range[0] - b.x1;
|
|
15038
15038
|
let maxSpace = Math.max(leftWidth, rightWidth);
|
|
15039
|
-
const buf = (isArray$
|
|
15039
|
+
const buf = (isArray$c(symbolSize) ? symbolSize[0] : 12) + 3;
|
|
15040
15040
|
if (maxSpace = Math.min(maxSpace - buf, maxSpace * maxWidthPercent), maxSpace < popTipWidth) {
|
|
15041
15041
|
popTipWidth = maxSpace;
|
|
15042
15042
|
const buf = parsedPadding[1] + parsedPadding[3];
|
|
15043
15043
|
titleShape.setAttribute("maxLineWidth", maxSpace - buf), contentShape.setAttribute("maxLineWidth", maxSpace - buf), poptipHeight = parsedPadding[0] + parsedPadding[2], titleVisible && (poptipHeight += titleShape.AABBBounds.height() + space), poptipHeight += contentShape.AABBBounds.height();
|
|
15044
15044
|
}
|
|
15045
15045
|
}
|
|
15046
|
-
const layout = "auto" === position || isArray$
|
|
15047
|
-
positionList = isArray$
|
|
15046
|
+
const layout = "auto" === position || isArray$c(position),
|
|
15047
|
+
positionList = isArray$c(position) ? position : this.positionList;
|
|
15048
15048
|
let maxBBoxI,
|
|
15049
15049
|
maxBBoxSize = -1 / 0;
|
|
15050
15050
|
for (let i = 0; i < positionList.length + 1; i++) {
|
|
15051
15051
|
const p = layout ? positionList[i === positionList.length ? maxBBoxI : i] : position;
|
|
15052
15052
|
let symbolType = "arrow2Left",
|
|
15053
|
-
offsetX = (isArray$
|
|
15053
|
+
offsetX = (isArray$c(symbolSize) ? symbolSize[0] : symbolSize) / 4,
|
|
15054
15054
|
offsetY = 0;
|
|
15055
|
-
"top" === p || "bottom" === p || "left" === p || "right" === p ? symbolType = "arrow2Left" : "concise" === triangleMode && (symbolType = conciseSymbolMap[p], offsetX = ["tl", "bl", "rt", "rb"].includes(p) ? (isArray$
|
|
15055
|
+
"top" === p || "bottom" === p || "left" === p || "right" === p ? symbolType = "arrow2Left" : "concise" === triangleMode && (symbolType = conciseSymbolMap[p], offsetX = ["tl", "bl", "rt", "rb"].includes(p) ? (isArray$c(symbolSize) ? symbolSize[0] : symbolSize) / 2 : -(isArray$c(symbolSize) ? symbolSize[0] : symbolSize) / 2, offsetY = ["tl", "tr", "lb", "rb"].includes(p) ? -(isArray$c(symbolSize) ? symbolSize[1] : symbolSize) / 2 : (isArray$c(symbolSize) ? symbolSize[1] : symbolSize) / 2);
|
|
15056
15056
|
const {
|
|
15057
15057
|
angle: angle,
|
|
15058
15058
|
offset: offset
|
|
15059
|
-
} = this.getAngleAndOffset(p, popTipWidth, poptipHeight, isArray$
|
|
15059
|
+
} = this.getAngleAndOffset(p, popTipWidth, poptipHeight, isArray$c(spaceSize) ? spaceSize : [spaceSize, spaceSize - lineWidth], symbolType);
|
|
15060
15060
|
let bgSymbol,
|
|
15061
15061
|
anchorPoint = {
|
|
15062
15062
|
x: 0,
|
|
15063
15063
|
y: 0
|
|
15064
15064
|
};
|
|
15065
|
-
if ("bounds" === poptipAnchor && positionBounds && (anchorPoint = this.calculateAnchorPoint(p, positionBounds)), isBoolean$
|
|
15065
|
+
if ("bounds" === poptipAnchor && positionBounds && (anchorPoint = this.calculateAnchorPoint(p, positionBounds)), isBoolean$4(bgVisible)) {
|
|
15066
15066
|
let bgRect;
|
|
15067
15067
|
bgSymbol = group.createOrUpdateChild("poptip-symbol-panel", Object.assign(Object.assign({}, backgroundStyle), {
|
|
15068
15068
|
visible: bgVisible && (contentVisible || titleVisible),
|
|
@@ -15101,7 +15101,7 @@
|
|
|
15101
15101
|
const {
|
|
15102
15102
|
size = 12
|
|
15103
15103
|
} = logoSymbol,
|
|
15104
|
-
sizeArray = isArray$
|
|
15104
|
+
sizeArray = isArray$c(size) ? size : [size, size];
|
|
15105
15105
|
"auto" === sizeArray[1] && (sizeArray[1] = poptipHeight), "auto" === sizeArray[0] && (sizeArray[0] = poptipHeight);
|
|
15106
15106
|
const sizeW = sizeArray[0];
|
|
15107
15107
|
group.createOrUpdateChild("poptip-logo", Object.assign(Object.assign({}, logoSymbol), {
|
|
@@ -15142,7 +15142,7 @@
|
|
|
15142
15142
|
let mainDirectionOverlap = !1;
|
|
15143
15143
|
if (isVerticalPosition ? mainDirectionOverlap = "top" === p && b.y1 < 0 || "bottom" === p && b.y2 > stageBounds.y2 : isHorizontalPosition && (mainDirectionOverlap = "left" === p && b.x1 < 0 || "right" === p && b.x2 > stageBounds.x2), !mainDirectionOverlap) {
|
|
15144
15144
|
let secondaryOffset = 0;
|
|
15145
|
-
const szNumber = (isArray$
|
|
15145
|
+
const szNumber = (isArray$c(symbolSize) ? symbolSize[1] : symbolSize) / 2;
|
|
15146
15146
|
isVerticalPosition ? (b.x1 < 0 ? secondaryOffset = -b.x1 : b.x2 > stageBounds.x2 && (secondaryOffset = stageBounds.x2 - b.x2), group.setAttribute("x", group.attribute.x + secondaryOffset), bgSymbol.setAttribute("dx", min(max(bgSymbol.attribute.dx - secondaryOffset, szNumber), b.width() - szNumber))) : isHorizontalPosition && (b.y1 < 0 ? secondaryOffset = -b.y1 : b.y2 > stageBounds.y2 && (secondaryOffset = stageBounds.y2 - b.y2), group.setAttribute("y", group.attribute.y + secondaryOffset), bgSymbol.setAttribute("dy", min(max(bgSymbol.attribute.dy - secondaryOffset, szNumber), b.height() - szNumber)));
|
|
15147
15147
|
break;
|
|
15148
15148
|
}
|
|
@@ -15298,9 +15298,52 @@
|
|
|
15298
15298
|
return !range1 && !range2 || !(!range1 || !range2) && (null === (_a = range1.start) || void 0 === _a ? void 0 : _a.col) === (null === (_b = range2.start) || void 0 === _b ? void 0 : _b.col) && (null === (_c = range1.start) || void 0 === _c ? void 0 : _c.row) === (null === (_d = range2.start) || void 0 === _d ? void 0 : _d.row) && (null === (_e = range1.end) || void 0 === _e ? void 0 : _e.col) === (null === (_f = range2.end) || void 0 === _f ? void 0 : _f.col) && (null === (_g = range1.end) || void 0 === _g ? void 0 : _g.row) === (null === (_h = range2.end) || void 0 === _h ? void 0 : _h.row);
|
|
15299
15299
|
}
|
|
15300
15300
|
|
|
15301
|
+
const isType = (value, type) => Object.prototype.toString.call(value) === `[object ${type}]`;
|
|
15302
|
+
var isType$1 = isType;
|
|
15303
|
+
|
|
15304
|
+
const isBoolean$1 = (value, fuzzy = !1) => fuzzy ? "boolean" == typeof value : !0 === value || !1 === value || isType$1(value, "Boolean");
|
|
15305
|
+
var isBoolean$2 = isBoolean$1;
|
|
15306
|
+
|
|
15307
|
+
const isFunction$9 = value => "function" == typeof value;
|
|
15308
|
+
var isFunction$a = isFunction$9;
|
|
15309
|
+
|
|
15301
15310
|
const isValid = value => null != value;
|
|
15302
15311
|
var isValid$1 = isValid;
|
|
15303
15312
|
|
|
15313
|
+
const isString = (value, fuzzy = !1) => {
|
|
15314
|
+
const type = typeof value;
|
|
15315
|
+
return fuzzy ? "string" === type : "string" === type || isType$1(value, "String");
|
|
15316
|
+
};
|
|
15317
|
+
var isString$1 = isString;
|
|
15318
|
+
|
|
15319
|
+
const isArray$9 = value => Array.isArray ? Array.isArray(value) : isType$1(value, "Array");
|
|
15320
|
+
var isArray$a = isArray$9;
|
|
15321
|
+
|
|
15322
|
+
const isDate = value => isType$1(value, "Date");
|
|
15323
|
+
var isDate$1 = isDate;
|
|
15324
|
+
|
|
15325
|
+
const isNumber$2 = (value, fuzzy = !1) => {
|
|
15326
|
+
const type = typeof value;
|
|
15327
|
+
return fuzzy ? "number" === type : "number" === type || isType$1(value, "Number");
|
|
15328
|
+
};
|
|
15329
|
+
var isNumber$3 = isNumber$2;
|
|
15330
|
+
|
|
15331
|
+
function cloneDeep(value, ignoreWhen, excludeKeys) {
|
|
15332
|
+
let result;
|
|
15333
|
+
if (!isValid$1(value) || "object" != typeof value || ignoreWhen && ignoreWhen(value)) return value;
|
|
15334
|
+
const isArr = isArray$a(value),
|
|
15335
|
+
length = value.length;
|
|
15336
|
+
result = isArr ? new Array(length) : "object" == typeof value ? {} : isBoolean$2(value) || isNumber$3(value) || isString$1(value) ? value : isDate$1(value) ? new Date(+value) : void 0;
|
|
15337
|
+
const props = isArr ? void 0 : Object.keys(Object(value));
|
|
15338
|
+
let index = -1;
|
|
15339
|
+
if (result) for (; ++index < (props || value).length;) {
|
|
15340
|
+
const key = props ? props[index] : index,
|
|
15341
|
+
subValue = value[key];
|
|
15342
|
+
excludeKeys && excludeKeys.includes(key.toString()) ? result[key] = subValue : result[key] = cloneDeep(subValue, ignoreWhen, excludeKeys);
|
|
15343
|
+
}
|
|
15344
|
+
return result;
|
|
15345
|
+
}
|
|
15346
|
+
|
|
15304
15347
|
const isNode$1 = "undefined" == typeof window || void 0 === window.window;
|
|
15305
15348
|
function analyzeUserAgent() {
|
|
15306
15349
|
if (isNode$1) return {
|
|
@@ -16652,7 +16695,8 @@
|
|
|
16652
16695
|
CLICK_DEPENDENCY_LINK_POINT: "click_dependency_link_point",
|
|
16653
16696
|
CONTEXTMENU_DEPENDENCY_LINK: "contextmenu_dependency_link",
|
|
16654
16697
|
CLICK_MARKLINE_CREATE: "click_markline_create",
|
|
16655
|
-
CLICK_MARKLINE_CONTENT: "click_markline_content"
|
|
16698
|
+
CLICK_MARKLINE_CONTENT: "click_markline_content",
|
|
16699
|
+
MOVE_END_TASK_BAR: "move_end_task_bar"
|
|
16656
16700
|
};
|
|
16657
16701
|
|
|
16658
16702
|
function throttle(func, delay) {
|
|
@@ -18824,11 +18868,12 @@
|
|
|
18824
18868
|
}), this.group.appendChild(this.markLIneContainer), this.initMarkLines();
|
|
18825
18869
|
}
|
|
18826
18870
|
initMarkLines() {
|
|
18827
|
-
this._scene._gantt.parsedOptions.markLine
|
|
18871
|
+
const markLine = this._scene._gantt.parsedOptions.markLine,
|
|
18872
|
+
minDate = this._scene._gantt.parsedOptions.minDate;
|
|
18873
|
+
minDate && markLine.forEach(line => {
|
|
18828
18874
|
const style = line.style,
|
|
18829
18875
|
contentStyle = line.contentStyle || {},
|
|
18830
18876
|
date = this._scene._gantt.parsedOptions.timeScaleIncludeHour ? createDateAtMidnight(line.date) : createDateAtMidnight(line.date, !0),
|
|
18831
|
-
minDate = this._scene._gantt.parsedOptions.minDate,
|
|
18832
18877
|
{
|
|
18833
18878
|
unit: unit,
|
|
18834
18879
|
step: step
|
|
@@ -20804,7 +20849,8 @@
|
|
|
20804
20849
|
deltaY = this.moveTaskBar.deltaY,
|
|
20805
20850
|
target = this.moveTaskBar.target;
|
|
20806
20851
|
if (Math.abs(deltaX) >= 1 || Math.abs(deltaY) >= 1) {
|
|
20807
|
-
const
|
|
20852
|
+
const oldRowIndex = target.task_index,
|
|
20853
|
+
taskIndex = target.task_index,
|
|
20808
20854
|
sub_task_index = target.sub_task_index,
|
|
20809
20855
|
{
|
|
20810
20856
|
startDate: oldStartDate,
|
|
@@ -20830,6 +20876,30 @@
|
|
|
20830
20876
|
index: taskIndex,
|
|
20831
20877
|
record: newRecord
|
|
20832
20878
|
});
|
|
20879
|
+
const newRowIndex = getTaskIndexsByTaskY(targetEndY, this._gantt).task_index;
|
|
20880
|
+
this._gantt.hasListeners(GANTT_EVENT_TYPE.MOVE_END_TASK_BAR) && this._gantt.fireListeners(GANTT_EVENT_TYPE.MOVE_END_TASK_BAR, {
|
|
20881
|
+
startDate: newRecord[this._gantt.parsedOptions.startDateField],
|
|
20882
|
+
endDate: newRecord[this._gantt.parsedOptions.endDateField],
|
|
20883
|
+
oldStartDate: oldStartDate,
|
|
20884
|
+
oldEndDate: oldEndDate,
|
|
20885
|
+
oldRowIndex: oldRowIndex,
|
|
20886
|
+
newRowIndex: newRowIndex,
|
|
20887
|
+
index: taskIndex,
|
|
20888
|
+
record: newRecord
|
|
20889
|
+
});
|
|
20890
|
+
} else {
|
|
20891
|
+
const newRecord = this._gantt.getRecordByIndex(taskIndex, sub_task_index),
|
|
20892
|
+
newRowIndex = getTaskIndexsByTaskY(targetEndY, this._gantt).task_index;
|
|
20893
|
+
this._gantt.hasListeners(GANTT_EVENT_TYPE.MOVE_END_TASK_BAR) && this._gantt.fireListeners(GANTT_EVENT_TYPE.MOVE_END_TASK_BAR, {
|
|
20894
|
+
startDate: newRecord[this._gantt.parsedOptions.startDateField],
|
|
20895
|
+
endDate: newRecord[this._gantt.parsedOptions.endDateField],
|
|
20896
|
+
oldStartDate: oldStartDate,
|
|
20897
|
+
oldEndDate: oldEndDate,
|
|
20898
|
+
oldRowIndex: oldRowIndex,
|
|
20899
|
+
newRowIndex: newRowIndex,
|
|
20900
|
+
index: newRowIndex,
|
|
20901
|
+
record: newRecord
|
|
20902
|
+
});
|
|
20833
20903
|
}
|
|
20834
20904
|
if (this._gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Arrange || this._gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Compact) {
|
|
20835
20905
|
const indexs = getTaskIndexsByTaskY(targetEndY, this._gantt);
|
|
@@ -99162,30 +99232,28 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99162
99232
|
const args = _parseArguments(options, callback),
|
|
99163
99233
|
opts = args[0],
|
|
99164
99234
|
cb = args[1];
|
|
99165
|
-
|
|
99166
|
-
|
|
99167
|
-
|
|
99168
|
-
|
|
99169
|
-
|
|
99170
|
-
|
|
99171
|
-
(function _getUniqueName() {
|
|
99172
|
-
try {
|
|
99173
|
-
const name = _generateTmpName(opts);
|
|
99235
|
+
_assertAndSanitizeOptions(opts, function (err, sanitizedOptions) {
|
|
99236
|
+
if (err) return cb(err);
|
|
99237
|
+
let tries = sanitizedOptions.tries;
|
|
99238
|
+
(function _getUniqueName() {
|
|
99239
|
+
try {
|
|
99240
|
+
const name = _generateTmpName(sanitizedOptions);
|
|
99174
99241
|
|
|
99175
|
-
|
|
99176
|
-
|
|
99177
|
-
/* istanbul ignore else */
|
|
99178
|
-
if (!err) {
|
|
99242
|
+
// check whether the path exists then retry if needed
|
|
99243
|
+
fs.stat(name, function (err) {
|
|
99179
99244
|
/* istanbul ignore else */
|
|
99180
|
-
if (
|
|
99181
|
-
|
|
99182
|
-
|
|
99183
|
-
|
|
99184
|
-
|
|
99185
|
-
|
|
99186
|
-
|
|
99187
|
-
|
|
99188
|
-
|
|
99245
|
+
if (!err) {
|
|
99246
|
+
/* istanbul ignore else */
|
|
99247
|
+
if (tries-- > 0) return _getUniqueName();
|
|
99248
|
+
return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name));
|
|
99249
|
+
}
|
|
99250
|
+
cb(null, name);
|
|
99251
|
+
});
|
|
99252
|
+
} catch (err) {
|
|
99253
|
+
cb(err);
|
|
99254
|
+
}
|
|
99255
|
+
})();
|
|
99256
|
+
});
|
|
99189
99257
|
}
|
|
99190
99258
|
|
|
99191
99259
|
/**
|
|
@@ -99198,10 +99266,10 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99198
99266
|
function tmpNameSync(options) {
|
|
99199
99267
|
const args = _parseArguments(options),
|
|
99200
99268
|
opts = args[0];
|
|
99201
|
-
|
|
99202
|
-
let tries =
|
|
99269
|
+
const sanitizedOptions = _assertAndSanitizeOptionsSync(opts);
|
|
99270
|
+
let tries = sanitizedOptions.tries;
|
|
99203
99271
|
do {
|
|
99204
|
-
const name = _generateTmpName(
|
|
99272
|
+
const name = _generateTmpName(sanitizedOptions);
|
|
99205
99273
|
try {
|
|
99206
99274
|
fs.statSync(name);
|
|
99207
99275
|
} catch (e) {
|
|
@@ -99258,7 +99326,7 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99258
99326
|
opts = args[0];
|
|
99259
99327
|
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
99260
99328
|
const name = tmpNameSync(opts);
|
|
99261
|
-
|
|
99329
|
+
let fd = fs.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
|
|
99262
99330
|
/* istanbul ignore else */
|
|
99263
99331
|
if (opts.discardDescriptor) {
|
|
99264
99332
|
fs.closeSync(fd);
|
|
@@ -99474,23 +99542,12 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99474
99542
|
} catch (e) {
|
|
99475
99543
|
rnd = crypto.pseudoRandomBytes(howMany);
|
|
99476
99544
|
}
|
|
99477
|
-
for (
|
|
99545
|
+
for (let i = 0; i < howMany; i++) {
|
|
99478
99546
|
value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]);
|
|
99479
99547
|
}
|
|
99480
99548
|
return value.join('');
|
|
99481
99549
|
}
|
|
99482
99550
|
|
|
99483
|
-
/**
|
|
99484
|
-
* Helper which determines whether a string s is blank, that is undefined, or empty or null.
|
|
99485
|
-
*
|
|
99486
|
-
* @private
|
|
99487
|
-
* @param {string} s
|
|
99488
|
-
* @returns {Boolean} true whether the string s is blank, false otherwise
|
|
99489
|
-
*/
|
|
99490
|
-
function _isBlank(s) {
|
|
99491
|
-
return s === null || _isUndefined(s) || !s.trim();
|
|
99492
|
-
}
|
|
99493
|
-
|
|
99494
99551
|
/**
|
|
99495
99552
|
* Checks whether the `obj` parameter is defined or not.
|
|
99496
99553
|
*
|
|
@@ -99531,6 +99588,47 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99531
99588
|
return [actualOptions, callback];
|
|
99532
99589
|
}
|
|
99533
99590
|
|
|
99591
|
+
/**
|
|
99592
|
+
* Resolve the specified path name in respect to tmpDir.
|
|
99593
|
+
*
|
|
99594
|
+
* The specified name might include relative path components, e.g. ../
|
|
99595
|
+
* so we need to resolve in order to be sure that is is located inside tmpDir
|
|
99596
|
+
*
|
|
99597
|
+
* @private
|
|
99598
|
+
*/
|
|
99599
|
+
function _resolvePath(name, tmpDir, cb) {
|
|
99600
|
+
const pathToResolve = path.isAbsolute(name) ? name : path.join(tmpDir, name);
|
|
99601
|
+
fs.stat(pathToResolve, function (err) {
|
|
99602
|
+
if (err) {
|
|
99603
|
+
fs.realpath(path.dirname(pathToResolve), function (err, parentDir) {
|
|
99604
|
+
if (err) return cb(err);
|
|
99605
|
+
cb(null, path.join(parentDir, path.basename(pathToResolve)));
|
|
99606
|
+
});
|
|
99607
|
+
} else {
|
|
99608
|
+
fs.realpath(path, cb);
|
|
99609
|
+
}
|
|
99610
|
+
});
|
|
99611
|
+
}
|
|
99612
|
+
|
|
99613
|
+
/**
|
|
99614
|
+
* Resolve the specified path name in respect to tmpDir.
|
|
99615
|
+
*
|
|
99616
|
+
* The specified name might include relative path components, e.g. ../
|
|
99617
|
+
* so we need to resolve in order to be sure that is is located inside tmpDir
|
|
99618
|
+
*
|
|
99619
|
+
* @private
|
|
99620
|
+
*/
|
|
99621
|
+
function _resolvePathSync(name, tmpDir) {
|
|
99622
|
+
const pathToResolve = path.isAbsolute(name) ? name : path.join(tmpDir, name);
|
|
99623
|
+
try {
|
|
99624
|
+
fs.statSync(pathToResolve);
|
|
99625
|
+
return fs.realpathSync(pathToResolve);
|
|
99626
|
+
} catch (_err) {
|
|
99627
|
+
const parentDir = fs.realpathSync(path.dirname(pathToResolve));
|
|
99628
|
+
return path.join(parentDir, path.basename(pathToResolve));
|
|
99629
|
+
}
|
|
99630
|
+
}
|
|
99631
|
+
|
|
99534
99632
|
/**
|
|
99535
99633
|
* Generates a new temporary name.
|
|
99536
99634
|
*
|
|
@@ -99542,10 +99640,14 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99542
99640
|
const tmpDir = opts.tmpdir;
|
|
99543
99641
|
|
|
99544
99642
|
/* istanbul ignore else */
|
|
99545
|
-
if (!_isUndefined(opts.name))
|
|
99643
|
+
if (!_isUndefined(opts.name)) {
|
|
99644
|
+
return path.join(tmpDir, opts.dir, opts.name);
|
|
99645
|
+
}
|
|
99546
99646
|
|
|
99547
99647
|
/* istanbul ignore else */
|
|
99548
|
-
if (!_isUndefined(opts.template))
|
|
99648
|
+
if (!_isUndefined(opts.template)) {
|
|
99649
|
+
return path.join(tmpDir, opts.dir, opts.template).replace(TEMPLATE_PATTERN, _randomChars(6));
|
|
99650
|
+
}
|
|
99549
99651
|
|
|
99550
99652
|
// prefix and postfix
|
|
99551
99653
|
const name = [opts.prefix ? opts.prefix : 'tmp', '-', process.pid, '-', _randomChars(12), opts.postfix ? '-' + opts.postfix : ''].join('');
|
|
@@ -99553,27 +99655,31 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99553
99655
|
}
|
|
99554
99656
|
|
|
99555
99657
|
/**
|
|
99556
|
-
* Asserts
|
|
99557
|
-
* options.
|
|
99658
|
+
* Asserts and sanitizes the basic options.
|
|
99558
99659
|
*
|
|
99559
|
-
* @param {Options} options
|
|
99560
99660
|
* @private
|
|
99561
99661
|
*/
|
|
99562
|
-
function
|
|
99563
|
-
|
|
99564
|
-
|
|
99662
|
+
function _assertOptionsBase(options) {
|
|
99663
|
+
if (!_isUndefined(options.name)) {
|
|
99664
|
+
const name = options.name;
|
|
99665
|
+
|
|
99666
|
+
// assert that name is not absolute and does not contain a path
|
|
99667
|
+
if (path.isAbsolute(name)) throw new Error(`name option must not contain an absolute path, found "${name}".`);
|
|
99668
|
+
|
|
99669
|
+
// must not fail on valid .<name> or ..<name> or similar such constructs
|
|
99670
|
+
const basename = path.basename(name);
|
|
99671
|
+
if (basename === '..' || basename === '.' || basename !== name) throw new Error(`name option must not contain a path, found "${name}".`);
|
|
99672
|
+
}
|
|
99565
99673
|
|
|
99566
99674
|
/* istanbul ignore else */
|
|
99567
|
-
if (!_isUndefined(options.
|
|
99568
|
-
|
|
99569
|
-
if (!_isUndefined(options.dir)) _assertIsRelative(options.dir, 'dir', tmpDir);
|
|
99570
|
-
/* istanbul ignore else */
|
|
99571
|
-
if (!_isUndefined(options.template)) {
|
|
99572
|
-
_assertIsRelative(options.template, 'template', tmpDir);
|
|
99573
|
-
if (!options.template.match(TEMPLATE_PATTERN)) throw new Error(`Invalid template, found "${options.template}".`);
|
|
99675
|
+
if (!_isUndefined(options.template) && !options.template.match(TEMPLATE_PATTERN)) {
|
|
99676
|
+
throw new Error(`Invalid template, found "${options.template}".`);
|
|
99574
99677
|
}
|
|
99678
|
+
|
|
99575
99679
|
/* istanbul ignore else */
|
|
99576
|
-
if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0)
|
|
99680
|
+
if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0) {
|
|
99681
|
+
throw new Error(`Invalid tries, found "${options.tries}".`);
|
|
99682
|
+
}
|
|
99577
99683
|
|
|
99578
99684
|
// if a name was specified we will try once
|
|
99579
99685
|
options.tries = _isUndefined(options.name) ? options.tries || DEFAULT_TRIES : 1;
|
|
@@ -99582,62 +99688,87 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99582
99688
|
options.discardDescriptor = !!options.discardDescriptor;
|
|
99583
99689
|
options.unsafeCleanup = !!options.unsafeCleanup;
|
|
99584
99690
|
|
|
99585
|
-
// sanitize dir, also keep (multiple) blanks if the user, purportedly sane, requests us to
|
|
99586
|
-
options.dir = _isUndefined(options.dir) ? '' : path.relative(tmpDir, _resolvePath(options.dir, tmpDir));
|
|
99587
|
-
options.template = _isUndefined(options.template) ? undefined : path.relative(tmpDir, _resolvePath(options.template, tmpDir));
|
|
99588
|
-
// sanitize further if template is relative to options.dir
|
|
99589
|
-
options.template = _isBlank(options.template) ? undefined : path.relative(options.dir, options.template);
|
|
99590
|
-
|
|
99591
99691
|
// for completeness' sake only, also keep (multiple) blanks if the user, purportedly sane, requests us to
|
|
99592
|
-
options.name = _isUndefined(options.name) ? undefined : options.name;
|
|
99593
99692
|
options.prefix = _isUndefined(options.prefix) ? '' : options.prefix;
|
|
99594
99693
|
options.postfix = _isUndefined(options.postfix) ? '' : options.postfix;
|
|
99595
99694
|
}
|
|
99596
99695
|
|
|
99597
99696
|
/**
|
|
99598
|
-
*
|
|
99697
|
+
* Gets the relative directory to tmpDir.
|
|
99599
99698
|
*
|
|
99600
|
-
*
|
|
99601
|
-
|
|
99699
|
+
* @private
|
|
99700
|
+
*/
|
|
99701
|
+
function _getRelativePath(option, name, tmpDir, cb) {
|
|
99702
|
+
if (_isUndefined(name)) return cb(null);
|
|
99703
|
+
_resolvePath(name, tmpDir, function (err, resolvedPath) {
|
|
99704
|
+
if (err) return cb(err);
|
|
99705
|
+
const relativePath = path.relative(tmpDir, resolvedPath);
|
|
99706
|
+
if (!resolvedPath.startsWith(tmpDir)) {
|
|
99707
|
+
return cb(new Error(`${option} option must be relative to "${tmpDir}", found "${relativePath}".`));
|
|
99708
|
+
}
|
|
99709
|
+
cb(null, relativePath);
|
|
99710
|
+
});
|
|
99711
|
+
}
|
|
99712
|
+
|
|
99713
|
+
/**
|
|
99714
|
+
* Gets the relative path to tmpDir.
|
|
99602
99715
|
*
|
|
99603
|
-
* @param name
|
|
99604
|
-
* @param tmpDir
|
|
99605
|
-
* @returns {string}
|
|
99606
99716
|
* @private
|
|
99607
99717
|
*/
|
|
99608
|
-
function
|
|
99609
|
-
if (name
|
|
99610
|
-
|
|
99611
|
-
|
|
99612
|
-
|
|
99718
|
+
function _getRelativePathSync(option, name, tmpDir) {
|
|
99719
|
+
if (_isUndefined(name)) return;
|
|
99720
|
+
const resolvedPath = _resolvePathSync(name, tmpDir);
|
|
99721
|
+
const relativePath = path.relative(tmpDir, resolvedPath);
|
|
99722
|
+
if (!resolvedPath.startsWith(tmpDir)) {
|
|
99723
|
+
throw new Error(`${option} option must be relative to "${tmpDir}", found "${relativePath}".`);
|
|
99613
99724
|
}
|
|
99725
|
+
return relativePath;
|
|
99614
99726
|
}
|
|
99615
99727
|
|
|
99616
99728
|
/**
|
|
99617
|
-
* Asserts whether specified
|
|
99729
|
+
* Asserts whether the specified options are valid, also sanitizes options and provides sane defaults for missing
|
|
99730
|
+
* options.
|
|
99618
99731
|
*
|
|
99619
|
-
* @param {string} name
|
|
99620
|
-
* @param {string} option
|
|
99621
|
-
* @param {string} tmpDir
|
|
99622
|
-
* @throws {Error}
|
|
99623
99732
|
* @private
|
|
99624
99733
|
*/
|
|
99625
|
-
function
|
|
99626
|
-
|
|
99627
|
-
|
|
99628
|
-
|
|
99629
|
-
|
|
99630
|
-
|
|
99631
|
-
|
|
99632
|
-
|
|
99633
|
-
// if (option === 'dir' || option === 'template') {
|
|
99634
|
-
// assert that dir or template are relative to tmpDir
|
|
99635
|
-
if (path.isAbsolute(name) && !name.startsWith(tmpDir)) {
|
|
99636
|
-
throw new Error(`${option} option must be relative to "${tmpDir}", found "${name}".`);
|
|
99734
|
+
function _assertAndSanitizeOptions(options, cb) {
|
|
99735
|
+
_getTmpDir(options, function (err, tmpDir) {
|
|
99736
|
+
if (err) return cb(err);
|
|
99737
|
+
options.tmpdir = tmpDir;
|
|
99738
|
+
try {
|
|
99739
|
+
_assertOptionsBase(options, tmpDir);
|
|
99740
|
+
} catch (err) {
|
|
99741
|
+
return cb(err);
|
|
99637
99742
|
}
|
|
99638
|
-
|
|
99639
|
-
|
|
99640
|
-
|
|
99743
|
+
|
|
99744
|
+
// sanitize dir, also keep (multiple) blanks if the user, purportedly sane, requests us to
|
|
99745
|
+
_getRelativePath('dir', options.dir, tmpDir, function (err, dir) {
|
|
99746
|
+
if (err) return cb(err);
|
|
99747
|
+
options.dir = _isUndefined(dir) ? '' : dir;
|
|
99748
|
+
|
|
99749
|
+
// sanitize further if template is relative to options.dir
|
|
99750
|
+
_getRelativePath('template', options.template, tmpDir, function (err, template) {
|
|
99751
|
+
if (err) return cb(err);
|
|
99752
|
+
options.template = template;
|
|
99753
|
+
cb(null, options);
|
|
99754
|
+
});
|
|
99755
|
+
});
|
|
99756
|
+
});
|
|
99757
|
+
}
|
|
99758
|
+
|
|
99759
|
+
/**
|
|
99760
|
+
* Asserts whether the specified options are valid, also sanitizes options and provides sane defaults for missing
|
|
99761
|
+
* options.
|
|
99762
|
+
*
|
|
99763
|
+
* @private
|
|
99764
|
+
*/
|
|
99765
|
+
function _assertAndSanitizeOptionsSync(options) {
|
|
99766
|
+
const tmpDir = options.tmpdir = _getTmpDirSync(options);
|
|
99767
|
+
_assertOptionsBase(options);
|
|
99768
|
+
const dir = _getRelativePathSync('dir', options.dir, tmpDir);
|
|
99769
|
+
options.dir = _isUndefined(dir) ? '' : dir;
|
|
99770
|
+
options.template = _getRelativePathSync('template', options.template, tmpDir);
|
|
99771
|
+
return options;
|
|
99641
99772
|
}
|
|
99642
99773
|
|
|
99643
99774
|
/**
|
|
@@ -99695,11 +99826,18 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99695
99826
|
* Returns the currently configured tmp dir from os.tmpdir().
|
|
99696
99827
|
*
|
|
99697
99828
|
* @private
|
|
99698
|
-
* @param {?Options} options
|
|
99699
|
-
* @returns {string} the currently configured tmp dir
|
|
99700
99829
|
*/
|
|
99701
|
-
function _getTmpDir(options) {
|
|
99702
|
-
return
|
|
99830
|
+
function _getTmpDir(options, cb) {
|
|
99831
|
+
return fs.realpath(options && options.tmpdir || os.tmpdir(), cb);
|
|
99832
|
+
}
|
|
99833
|
+
|
|
99834
|
+
/**
|
|
99835
|
+
* Returns the currently configured tmp dir from os.tmpdir().
|
|
99836
|
+
*
|
|
99837
|
+
* @private
|
|
99838
|
+
*/
|
|
99839
|
+
function _getTmpDirSync(options) {
|
|
99840
|
+
return fs.realpathSync(options && options.tmpdir || os.tmpdir());
|
|
99703
99841
|
}
|
|
99704
99842
|
|
|
99705
99843
|
// Install process exit listener
|
|
@@ -99800,7 +99938,7 @@ ${XMLNS_NAMESPACE}.`);
|
|
|
99800
99938
|
enumerable: true,
|
|
99801
99939
|
configurable: false,
|
|
99802
99940
|
get: function () {
|
|
99803
|
-
return
|
|
99941
|
+
return _getTmpDirSync();
|
|
99804
99942
|
}
|
|
99805
99943
|
});
|
|
99806
99944
|
module.exports.dir = dir;
|
|
@@ -101218,6 +101356,881 @@ ${recordsStr}
|
|
|
101218
101356
|
}
|
|
101219
101357
|
}
|
|
101220
101358
|
|
|
101359
|
+
function encodeCellAddress(col, row) {
|
|
101360
|
+
let s = '';
|
|
101361
|
+
for (let column = col + 1; column > 0; column = Math.floor((column - 1) / 26)) {
|
|
101362
|
+
s = String.fromCharCode(((column - 1) % 26) + 65) + s;
|
|
101363
|
+
}
|
|
101364
|
+
return s + (row + 1);
|
|
101365
|
+
}
|
|
101366
|
+
|
|
101367
|
+
function colorStringToRGB(colorString) {
|
|
101368
|
+
if (!colorString) {
|
|
101369
|
+
return [0, 0, 0];
|
|
101370
|
+
}
|
|
101371
|
+
if (colorString.startsWith('#')) {
|
|
101372
|
+
let hex = colorString.substring(1);
|
|
101373
|
+
if (hex.length === 3) {
|
|
101374
|
+
hex = hex.replace(/(.)/g, '$1$1');
|
|
101375
|
+
}
|
|
101376
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
101377
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
101378
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
101379
|
+
return [r, g, b];
|
|
101380
|
+
}
|
|
101381
|
+
else if (colorString.startsWith('rgb(')) {
|
|
101382
|
+
const values = colorString
|
|
101383
|
+
.substring(4, colorString.length - 1)
|
|
101384
|
+
.split(',')
|
|
101385
|
+
.map(Number);
|
|
101386
|
+
return values;
|
|
101387
|
+
}
|
|
101388
|
+
else if (colorString.startsWith('rgba(')) {
|
|
101389
|
+
const values = colorString
|
|
101390
|
+
.substring(5, colorString.length - 1)
|
|
101391
|
+
.split(',')
|
|
101392
|
+
.map(Number);
|
|
101393
|
+
return values;
|
|
101394
|
+
}
|
|
101395
|
+
else if (isNumber$3(DEFAULT_COLORS[colorString])) {
|
|
101396
|
+
return rgb(DEFAULT_COLORS[colorString]);
|
|
101397
|
+
}
|
|
101398
|
+
else if (isNumber$3(DEFAULT_COLORS_OPACITY[colorString])) {
|
|
101399
|
+
return rgba(DEFAULT_COLORS_OPACITY[colorString]);
|
|
101400
|
+
}
|
|
101401
|
+
throw new Error('Unsupported color format');
|
|
101402
|
+
}
|
|
101403
|
+
function rgbaToHex(rgbaArray) {
|
|
101404
|
+
if (rgbaArray.length === 3) {
|
|
101405
|
+
rgbaArray.push(1);
|
|
101406
|
+
}
|
|
101407
|
+
if (rgbaArray.length !== 4) {
|
|
101408
|
+
throw new Error('Invalid RGBA array');
|
|
101409
|
+
}
|
|
101410
|
+
const [r, g, b, a] = rgbaArray.map(Math.round);
|
|
101411
|
+
const alphaHex = Math.round(a * 255)
|
|
101412
|
+
.toString(16)
|
|
101413
|
+
.padStart(2, '0');
|
|
101414
|
+
return `${alphaHex}${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b
|
|
101415
|
+
.toString(16)
|
|
101416
|
+
.padStart(2, '0')}`;
|
|
101417
|
+
}
|
|
101418
|
+
function rgb(value) {
|
|
101419
|
+
return [value >> 16, (value >> 8) & 0xff, value & 0xff, 1];
|
|
101420
|
+
}
|
|
101421
|
+
function rgba(value) {
|
|
101422
|
+
return [
|
|
101423
|
+
value >>> 24,
|
|
101424
|
+
(value >>> 16) & 0xff,
|
|
101425
|
+
(value >>> 8) & 0xff,
|
|
101426
|
+
value & 0xff
|
|
101427
|
+
];
|
|
101428
|
+
}
|
|
101429
|
+
const DEFAULT_COLORS_OPACITY = {
|
|
101430
|
+
transparent: 0xffffff00
|
|
101431
|
+
};
|
|
101432
|
+
const DEFAULT_COLORS = {
|
|
101433
|
+
aliceblue: 0xf0f8ff,
|
|
101434
|
+
antiquewhite: 0xfaebd7,
|
|
101435
|
+
aqua: 0x00ffff,
|
|
101436
|
+
aquamarine: 0x7fffd4,
|
|
101437
|
+
azure: 0xf0ffff,
|
|
101438
|
+
beige: 0xf5f5dc,
|
|
101439
|
+
bisque: 0xffe4c4,
|
|
101440
|
+
black: 0x000000,
|
|
101441
|
+
blanchedalmond: 0xffebcd,
|
|
101442
|
+
blue: 0x0000ff,
|
|
101443
|
+
blueviolet: 0x8a2be2,
|
|
101444
|
+
brown: 0xa52a2a,
|
|
101445
|
+
burlywood: 0xdeb887,
|
|
101446
|
+
cadetblue: 0x5f9ea0,
|
|
101447
|
+
chartreuse: 0x7fff00,
|
|
101448
|
+
chocolate: 0xd2691e,
|
|
101449
|
+
coral: 0xff7f50,
|
|
101450
|
+
cornflowerblue: 0x6495ed,
|
|
101451
|
+
cornsilk: 0xfff8dc,
|
|
101452
|
+
crimson: 0xdc143c,
|
|
101453
|
+
cyan: 0x00ffff,
|
|
101454
|
+
darkblue: 0x00008b,
|
|
101455
|
+
darkcyan: 0x008b8b,
|
|
101456
|
+
darkgoldenrod: 0xb8860b,
|
|
101457
|
+
darkgray: 0xa9a9a9,
|
|
101458
|
+
darkgreen: 0x006400,
|
|
101459
|
+
darkgrey: 0xa9a9a9,
|
|
101460
|
+
darkkhaki: 0xbdb76b,
|
|
101461
|
+
darkmagenta: 0x8b008b,
|
|
101462
|
+
darkolivegreen: 0x556b2f,
|
|
101463
|
+
darkorange: 0xff8c00,
|
|
101464
|
+
darkorchid: 0x9932cc,
|
|
101465
|
+
darkred: 0x8b0000,
|
|
101466
|
+
darksalmon: 0xe9967a,
|
|
101467
|
+
darkseagreen: 0x8fbc8f,
|
|
101468
|
+
darkslateblue: 0x483d8b,
|
|
101469
|
+
darkslategray: 0x2f4f4f,
|
|
101470
|
+
darkslategrey: 0x2f4f4f,
|
|
101471
|
+
darkturquoise: 0x00ced1,
|
|
101472
|
+
darkviolet: 0x9400d3,
|
|
101473
|
+
deeppink: 0xff1493,
|
|
101474
|
+
deepskyblue: 0x00bfff,
|
|
101475
|
+
dimgray: 0x696969,
|
|
101476
|
+
dimgrey: 0x696969,
|
|
101477
|
+
dodgerblue: 0x1e90ff,
|
|
101478
|
+
firebrick: 0xb22222,
|
|
101479
|
+
floralwhite: 0xfffaf0,
|
|
101480
|
+
forestgreen: 0x228b22,
|
|
101481
|
+
fuchsia: 0xff00ff,
|
|
101482
|
+
gainsboro: 0xdcdcdc,
|
|
101483
|
+
ghostwhite: 0xf8f8ff,
|
|
101484
|
+
gold: 0xffd700,
|
|
101485
|
+
goldenrod: 0xdaa520,
|
|
101486
|
+
gray: 0x808080,
|
|
101487
|
+
green: 0x008000,
|
|
101488
|
+
greenyellow: 0xadff2f,
|
|
101489
|
+
grey: 0x808080,
|
|
101490
|
+
honeydew: 0xf0fff0,
|
|
101491
|
+
hotpink: 0xff69b4,
|
|
101492
|
+
indianred: 0xcd5c5c,
|
|
101493
|
+
indigo: 0x4b0082,
|
|
101494
|
+
ivory: 0xfffff0,
|
|
101495
|
+
khaki: 0xf0e68c,
|
|
101496
|
+
lavender: 0xe6e6fa,
|
|
101497
|
+
lavenderblush: 0xfff0f5,
|
|
101498
|
+
lawngreen: 0x7cfc00,
|
|
101499
|
+
lemonchiffon: 0xfffacd,
|
|
101500
|
+
lightblue: 0xadd8e6,
|
|
101501
|
+
lightcoral: 0xf08080,
|
|
101502
|
+
lightcyan: 0xe0ffff,
|
|
101503
|
+
lightgoldenrodyellow: 0xfafad2,
|
|
101504
|
+
lightgray: 0xd3d3d3,
|
|
101505
|
+
lightgreen: 0x90ee90,
|
|
101506
|
+
lightgrey: 0xd3d3d3,
|
|
101507
|
+
lightpink: 0xffb6c1,
|
|
101508
|
+
lightsalmon: 0xffa07a,
|
|
101509
|
+
lightseagreen: 0x20b2aa,
|
|
101510
|
+
lightskyblue: 0x87cefa,
|
|
101511
|
+
lightslategray: 0x778899,
|
|
101512
|
+
lightslategrey: 0x778899,
|
|
101513
|
+
lightsteelblue: 0xb0c4de,
|
|
101514
|
+
lightyellow: 0xffffe0,
|
|
101515
|
+
lime: 0x00ff00,
|
|
101516
|
+
limegreen: 0x32cd32,
|
|
101517
|
+
linen: 0xfaf0e6,
|
|
101518
|
+
magenta: 0xff00ff,
|
|
101519
|
+
maroon: 0x800000,
|
|
101520
|
+
mediumaquamarine: 0x66cdaa,
|
|
101521
|
+
mediumblue: 0x0000cd,
|
|
101522
|
+
mediumorchid: 0xba55d3,
|
|
101523
|
+
mediumpurple: 0x9370db,
|
|
101524
|
+
mediumseagreen: 0x3cb371,
|
|
101525
|
+
mediumslateblue: 0x7b68ee,
|
|
101526
|
+
mediumspringgreen: 0x00fa9a,
|
|
101527
|
+
mediumturquoise: 0x48d1cc,
|
|
101528
|
+
mediumvioletred: 0xc71585,
|
|
101529
|
+
midnightblue: 0x191970,
|
|
101530
|
+
mintcream: 0xf5fffa,
|
|
101531
|
+
mistyrose: 0xffe4e1,
|
|
101532
|
+
moccasin: 0xffe4b5,
|
|
101533
|
+
navajowhite: 0xffdead,
|
|
101534
|
+
navy: 0x000080,
|
|
101535
|
+
oldlace: 0xfdf5e6,
|
|
101536
|
+
olive: 0x808000,
|
|
101537
|
+
olivedrab: 0x6b8e23,
|
|
101538
|
+
orange: 0xffa500,
|
|
101539
|
+
orangered: 0xff4500,
|
|
101540
|
+
orchid: 0xda70d6,
|
|
101541
|
+
palegoldenrod: 0xeee8aa,
|
|
101542
|
+
palegreen: 0x98fb98,
|
|
101543
|
+
paleturquoise: 0xafeeee,
|
|
101544
|
+
palevioletred: 0xdb7093,
|
|
101545
|
+
papayawhip: 0xffefd5,
|
|
101546
|
+
peachpuff: 0xffdab9,
|
|
101547
|
+
peru: 0xcd853f,
|
|
101548
|
+
pink: 0xffc0cb,
|
|
101549
|
+
plum: 0xdda0dd,
|
|
101550
|
+
powderblue: 0xb0e0e6,
|
|
101551
|
+
purple: 0x800080,
|
|
101552
|
+
rebeccapurple: 0x663399,
|
|
101553
|
+
red: 0xff0000,
|
|
101554
|
+
rosybrown: 0xbc8f8f,
|
|
101555
|
+
royalblue: 0x4169e1,
|
|
101556
|
+
saddlebrown: 0x8b4513,
|
|
101557
|
+
salmon: 0xfa8072,
|
|
101558
|
+
sandybrown: 0xf4a460,
|
|
101559
|
+
seagreen: 0x2e8b57,
|
|
101560
|
+
seashell: 0xfff5ee,
|
|
101561
|
+
sienna: 0xa0522d,
|
|
101562
|
+
silver: 0xc0c0c0,
|
|
101563
|
+
skyblue: 0x87ceeb,
|
|
101564
|
+
slateblue: 0x6a5acd,
|
|
101565
|
+
slategray: 0x708090,
|
|
101566
|
+
slategrey: 0x708090,
|
|
101567
|
+
snow: 0xfffafa,
|
|
101568
|
+
springgreen: 0x00ff7f,
|
|
101569
|
+
steelblue: 0x4682b4,
|
|
101570
|
+
tan: 0xd2b48c,
|
|
101571
|
+
teal: 0x008080,
|
|
101572
|
+
thistle: 0xd8bfd8,
|
|
101573
|
+
tomato: 0xff6347,
|
|
101574
|
+
turquoise: 0x40e0d0,
|
|
101575
|
+
violet: 0xee82ee,
|
|
101576
|
+
wheat: 0xf5deb3,
|
|
101577
|
+
white: 0xffffff,
|
|
101578
|
+
whitesmoke: 0xf5f5f5,
|
|
101579
|
+
yellow: 0xffff00,
|
|
101580
|
+
yellowgreen: 0x9acd32
|
|
101581
|
+
};
|
|
101582
|
+
|
|
101583
|
+
function getCellFont(cellStyle, cellType) {
|
|
101584
|
+
return {
|
|
101585
|
+
name: getFirstFontFromFontFamily(cellStyle.fontFamily) || 'Arial',
|
|
101586
|
+
size: cellStyle.fontSize || 10,
|
|
101587
|
+
bold: isFontBold(cellStyle.fontWeight),
|
|
101588
|
+
italic: cellStyle.fontStyle === 'italic',
|
|
101589
|
+
color: getColor(cellType === 'link' ? cellStyle._linkColor : cellStyle.color),
|
|
101590
|
+
underline: cellStyle.underline
|
|
101591
|
+
};
|
|
101592
|
+
}
|
|
101593
|
+
function isFontBold(fontWeight) {
|
|
101594
|
+
if (typeof fontWeight === 'number') {
|
|
101595
|
+
return fontWeight >= 600;
|
|
101596
|
+
}
|
|
101597
|
+
if (Number(fontWeight) >= 600) {
|
|
101598
|
+
return true;
|
|
101599
|
+
}
|
|
101600
|
+
return fontWeight === 'bold';
|
|
101601
|
+
}
|
|
101602
|
+
function getFirstFontFromFontFamily(fontFamily) {
|
|
101603
|
+
const fonts = fontFamily.split(',').map(font => font.trim());
|
|
101604
|
+
return fonts[0];
|
|
101605
|
+
}
|
|
101606
|
+
function getCellFill(cellStyle) {
|
|
101607
|
+
return {
|
|
101608
|
+
type: 'pattern',
|
|
101609
|
+
pattern: 'solid',
|
|
101610
|
+
fgColor: getColor(cellStyle.bgColor)
|
|
101611
|
+
};
|
|
101612
|
+
}
|
|
101613
|
+
function getCellBorder(cellStyle) {
|
|
101614
|
+
const { borderColor, borderLineWidth, borderLineDash, _strokeArrayWidth, _strokeArrayColor } = cellStyle;
|
|
101615
|
+
if (_strokeArrayColor || _strokeArrayWidth) {
|
|
101616
|
+
const border = {};
|
|
101617
|
+
if (!((_strokeArrayColor && !_strokeArrayColor[0]) || (_strokeArrayWidth && !_strokeArrayWidth[0]))) {
|
|
101618
|
+
border.top = {
|
|
101619
|
+
style: getBorderStyle(_strokeArrayWidth?.[0] ?? borderLineWidth, borderLineDash),
|
|
101620
|
+
color: getColor(_strokeArrayColor?.[0] ?? borderColor)
|
|
101621
|
+
};
|
|
101622
|
+
}
|
|
101623
|
+
if (!((_strokeArrayColor && !_strokeArrayColor[1]) || (_strokeArrayWidth && !_strokeArrayWidth[1]))) {
|
|
101624
|
+
border.right = {
|
|
101625
|
+
style: getBorderStyle(_strokeArrayWidth?.[1] ?? borderLineWidth, borderLineDash),
|
|
101626
|
+
color: getColor(_strokeArrayColor?.[1] ?? borderColor)
|
|
101627
|
+
};
|
|
101628
|
+
}
|
|
101629
|
+
if (!((_strokeArrayColor && !_strokeArrayColor[2]) || (_strokeArrayWidth && !_strokeArrayWidth[2]))) {
|
|
101630
|
+
border.bottom = {
|
|
101631
|
+
style: getBorderStyle(_strokeArrayWidth?.[2] ?? borderLineWidth, borderLineDash),
|
|
101632
|
+
color: getColor(_strokeArrayColor?.[2] ?? borderColor)
|
|
101633
|
+
};
|
|
101634
|
+
}
|
|
101635
|
+
if (!((_strokeArrayColor && !_strokeArrayColor[3]) || (_strokeArrayWidth && !_strokeArrayWidth[3]))) {
|
|
101636
|
+
border.left = {
|
|
101637
|
+
style: getBorderStyle(_strokeArrayWidth?.[3] ?? borderLineWidth, borderLineDash),
|
|
101638
|
+
color: getColor(_strokeArrayColor?.[3] ?? borderColor)
|
|
101639
|
+
};
|
|
101640
|
+
}
|
|
101641
|
+
return border;
|
|
101642
|
+
}
|
|
101643
|
+
if (borderLineWidth === 0) {
|
|
101644
|
+
return {};
|
|
101645
|
+
}
|
|
101646
|
+
const border = {
|
|
101647
|
+
style: getBorderStyle(borderLineWidth, borderLineDash),
|
|
101648
|
+
color: getColor(borderColor)
|
|
101649
|
+
};
|
|
101650
|
+
return {
|
|
101651
|
+
top: border,
|
|
101652
|
+
left: border,
|
|
101653
|
+
bottom: border,
|
|
101654
|
+
right: border
|
|
101655
|
+
};
|
|
101656
|
+
}
|
|
101657
|
+
function getBorderStyle(lineWidth, borderLineDash) {
|
|
101658
|
+
if (borderLineDash && borderLineDash.length) {
|
|
101659
|
+
if (lineWidth <= 2) {
|
|
101660
|
+
return 'dashed';
|
|
101661
|
+
}
|
|
101662
|
+
return 'mediumDashed';
|
|
101663
|
+
}
|
|
101664
|
+
if (lineWidth <= 0.5) {
|
|
101665
|
+
return 'hair';
|
|
101666
|
+
}
|
|
101667
|
+
else if (lineWidth <= 1) {
|
|
101668
|
+
return 'thin';
|
|
101669
|
+
}
|
|
101670
|
+
else if (lineWidth <= 2) {
|
|
101671
|
+
return 'medium';
|
|
101672
|
+
}
|
|
101673
|
+
return 'thick';
|
|
101674
|
+
}
|
|
101675
|
+
function getCellAlignment(cellStyle, indent) {
|
|
101676
|
+
return {
|
|
101677
|
+
horizontal: cellStyle.textAlign || 'left',
|
|
101678
|
+
vertical: cellStyle.textBaseline || 'middle',
|
|
101679
|
+
wrapText: cellStyle.autoWrapText || false,
|
|
101680
|
+
indent: indent || 0
|
|
101681
|
+
};
|
|
101682
|
+
}
|
|
101683
|
+
function getColor(color) {
|
|
101684
|
+
return {
|
|
101685
|
+
argb: rgbaToHex(colorStringToRGB(color))
|
|
101686
|
+
};
|
|
101687
|
+
}
|
|
101688
|
+
|
|
101689
|
+
function getHierarchyOffset(col, row, table) {
|
|
101690
|
+
let cellHierarchyIndent = 0;
|
|
101691
|
+
const layoutMap = table.internalProps.layoutMap;
|
|
101692
|
+
if (layoutMap.isHeader(col, row)) {
|
|
101693
|
+
const hd = layoutMap.getHeader(col, row);
|
|
101694
|
+
if (isValid$1(hd?.hierarchyLevel)) {
|
|
101695
|
+
cellHierarchyIndent = (hd.hierarchyLevel ?? 0) * (layoutMap.rowHierarchyIndent ?? 0);
|
|
101696
|
+
}
|
|
101697
|
+
}
|
|
101698
|
+
else {
|
|
101699
|
+
const define = table.getBodyColumnDefine(col, row);
|
|
101700
|
+
if (define?.tree) {
|
|
101701
|
+
const indexArr = table.dataSource.getIndexKey(table.getRecordShowIndexByCell(col, row));
|
|
101702
|
+
cellHierarchyIndent =
|
|
101703
|
+
Array.isArray(indexArr) && table.getHierarchyState(col, row) !== 'none'
|
|
101704
|
+
? (indexArr.length - 1) * (layoutMap.hierarchyIndent ?? 0)
|
|
101705
|
+
: 0;
|
|
101706
|
+
}
|
|
101707
|
+
}
|
|
101708
|
+
return cellHierarchyIndent;
|
|
101709
|
+
}
|
|
101710
|
+
|
|
101711
|
+
function isPromise(obj) {
|
|
101712
|
+
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
|
101713
|
+
}
|
|
101714
|
+
|
|
101715
|
+
function handlePaginationExport(table, exportAllData) {
|
|
101716
|
+
const pagination = cloneDeep(table.pagination);
|
|
101717
|
+
const isPivot = table.isPivotTable();
|
|
101718
|
+
const layoutMap = table.internalProps.layoutMap;
|
|
101719
|
+
let maxRow = table.rowCount - 1;
|
|
101720
|
+
const handleRowCount = () => {
|
|
101721
|
+
if (exportAllData) {
|
|
101722
|
+
if (pagination) {
|
|
101723
|
+
if (isPivot) {
|
|
101724
|
+
table.internalProps.layoutMap.setPagination(undefined);
|
|
101725
|
+
table.refreshRowColCount();
|
|
101726
|
+
maxRow = table.rowCount - 1;
|
|
101727
|
+
}
|
|
101728
|
+
else {
|
|
101729
|
+
maxRow = table.recordsCount * layoutMap.bodyRowSpanCount + layoutMap.headerLevelCount;
|
|
101730
|
+
}
|
|
101731
|
+
}
|
|
101732
|
+
}
|
|
101733
|
+
return maxRow;
|
|
101734
|
+
};
|
|
101735
|
+
const reset = () => {
|
|
101736
|
+
if (isPivot && exportAllData && pagination) {
|
|
101737
|
+
table.internalProps.layoutMap.setPagination(pagination);
|
|
101738
|
+
table.refreshRowColCount();
|
|
101739
|
+
}
|
|
101740
|
+
};
|
|
101741
|
+
return {
|
|
101742
|
+
reset,
|
|
101743
|
+
handleRowCount
|
|
101744
|
+
};
|
|
101745
|
+
}
|
|
101746
|
+
|
|
101747
|
+
function requestIdleCallbackPromise(options) {
|
|
101748
|
+
return new Promise(resolve => {
|
|
101749
|
+
requestIdleCallback(deadline => {
|
|
101750
|
+
resolve(deadline);
|
|
101751
|
+
}, options);
|
|
101752
|
+
});
|
|
101753
|
+
}
|
|
101754
|
+
async function exportVTableToExcel(tableInstance, options, optimization = false) {
|
|
101755
|
+
const workbook = new ExcelJS.Workbook();
|
|
101756
|
+
const worksheet = workbook.addWorksheet('sheet1');
|
|
101757
|
+
const exportAllData = !!options?.exportAllData;
|
|
101758
|
+
const { handleRowCount, reset } = handlePaginationExport(tableInstance, exportAllData);
|
|
101759
|
+
const minRow = 0;
|
|
101760
|
+
const maxRow = handleRowCount();
|
|
101761
|
+
const minCol = 0;
|
|
101762
|
+
const maxCol = tableInstance.colCount - 1;
|
|
101763
|
+
worksheet.properties.defaultRowHeight = 40;
|
|
101764
|
+
const columns = [];
|
|
101765
|
+
const mergeCells = [];
|
|
101766
|
+
const mergeCellSet = new Set();
|
|
101767
|
+
const SLICE_SIZE = 100;
|
|
101768
|
+
let currentRow = minRow;
|
|
101769
|
+
function processSlice(deadline) {
|
|
101770
|
+
return new Promise(async (resolve) => {
|
|
101771
|
+
while (currentRow <= maxRow && (!optimization || deadline?.timeRemaining() > 0)) {
|
|
101772
|
+
const endRow = Math.min(currentRow + SLICE_SIZE - 1, maxRow);
|
|
101773
|
+
for (let col = minCol; col <= maxCol; col++) {
|
|
101774
|
+
const colWidth = tableInstance.getColWidth(col);
|
|
101775
|
+
if (columns[col] === undefined) {
|
|
101776
|
+
columns[col] = { width: colWidth / 6 };
|
|
101777
|
+
}
|
|
101778
|
+
for (let row = currentRow; row <= endRow; row++) {
|
|
101779
|
+
if (col === minCol) {
|
|
101780
|
+
const rowHeight = tableInstance.getRowHeight(row);
|
|
101781
|
+
const worksheetRow = worksheet.getRow(row + 1);
|
|
101782
|
+
worksheetRow.height = rowHeight;
|
|
101783
|
+
}
|
|
101784
|
+
await addCell(col, row, tableInstance, worksheet, workbook, options);
|
|
101785
|
+
const cellRange = tableInstance.getCellRange(col, row);
|
|
101786
|
+
if (cellRange.start.col !== cellRange.end.col || cellRange.start.row !== cellRange.end.row) {
|
|
101787
|
+
const key = `${cellRange.start.col},${cellRange.start.row}:${cellRange.end.col},${cellRange.end.row}`;
|
|
101788
|
+
if (!mergeCellSet.has(key)) {
|
|
101789
|
+
mergeCellSet.add(key);
|
|
101790
|
+
mergeCells.push(cellRange);
|
|
101791
|
+
}
|
|
101792
|
+
}
|
|
101793
|
+
}
|
|
101794
|
+
}
|
|
101795
|
+
currentRow = endRow + 1;
|
|
101796
|
+
}
|
|
101797
|
+
if (currentRow > maxRow) {
|
|
101798
|
+
resolve();
|
|
101799
|
+
}
|
|
101800
|
+
else {
|
|
101801
|
+
let nextDeadline;
|
|
101802
|
+
if (optimization) {
|
|
101803
|
+
nextDeadline = await requestIdleCallbackPromise();
|
|
101804
|
+
}
|
|
101805
|
+
await processSlice(nextDeadline);
|
|
101806
|
+
resolve();
|
|
101807
|
+
}
|
|
101808
|
+
});
|
|
101809
|
+
}
|
|
101810
|
+
await new Promise(async (resolve) => {
|
|
101811
|
+
let deadline;
|
|
101812
|
+
if (optimization) {
|
|
101813
|
+
deadline = await requestIdleCallbackPromise();
|
|
101814
|
+
}
|
|
101815
|
+
await processSlice(deadline);
|
|
101816
|
+
resolve();
|
|
101817
|
+
});
|
|
101818
|
+
worksheet.columns = columns;
|
|
101819
|
+
mergeCells.forEach(mergeCell => {
|
|
101820
|
+
worksheet.mergeCells(mergeCell.start.row + 1, mergeCell.start.col + 1, mergeCell.end.row + 1, mergeCell.end.col + 1);
|
|
101821
|
+
});
|
|
101822
|
+
const frozenView = [];
|
|
101823
|
+
if (tableInstance.frozenRowCount > 0) {
|
|
101824
|
+
frozenView.push({
|
|
101825
|
+
state: 'frozen',
|
|
101826
|
+
ySplit: tableInstance.frozenRowCount,
|
|
101827
|
+
topLeftCell: encodeCellAddress(0, tableInstance.frozenRowCount)
|
|
101828
|
+
});
|
|
101829
|
+
}
|
|
101830
|
+
if (tableInstance.frozenColCount > 0) {
|
|
101831
|
+
frozenView.push({
|
|
101832
|
+
state: 'frozen',
|
|
101833
|
+
xSplit: tableInstance.frozenColCount,
|
|
101834
|
+
topLeftCell: encodeCellAddress(tableInstance.frozenColCount, 0)
|
|
101835
|
+
});
|
|
101836
|
+
}
|
|
101837
|
+
worksheet.views = frozenView;
|
|
101838
|
+
if (options?.excelJSWorksheetCallback) {
|
|
101839
|
+
options.excelJSWorksheetCallback(worksheet);
|
|
101840
|
+
}
|
|
101841
|
+
const buffer = await workbook.xlsx.writeBuffer();
|
|
101842
|
+
reset();
|
|
101843
|
+
return buffer;
|
|
101844
|
+
}
|
|
101845
|
+
async function addCell(col, row, tableInstance, worksheet, workbook, options) {
|
|
101846
|
+
const { layoutMap } = tableInstance.internalProps;
|
|
101847
|
+
const cellType = tableInstance.getCellType(col, row);
|
|
101848
|
+
const rawRecord = tableInstance.getCellRawRecord(col, row);
|
|
101849
|
+
let cellValue = (rawRecord && rawRecord.vtableMergeName) ?? tableInstance.getCellValue(col, row, false);
|
|
101850
|
+
if (isPromise(cellValue)) {
|
|
101851
|
+
cellValue = await cellValue;
|
|
101852
|
+
}
|
|
101853
|
+
const cellStyle = tableInstance.getCellStyle(col, row);
|
|
101854
|
+
const cellLocation = tableInstance.getCellLocation(col, row);
|
|
101855
|
+
const define = cellLocation !== 'body' ? tableInstance.getHeaderDefine(col, row) : tableInstance.getBodyColumnDefine(col, row);
|
|
101856
|
+
const mayHaveIcon = cellLocation !== 'body'
|
|
101857
|
+
? true
|
|
101858
|
+
: define?.dragOrder || !!define?.icon || !!define?.tree;
|
|
101859
|
+
let icons;
|
|
101860
|
+
if (mayHaveIcon) {
|
|
101861
|
+
icons = tableInstance.getCellIcons(col, row);
|
|
101862
|
+
}
|
|
101863
|
+
let customRender;
|
|
101864
|
+
let customLayout;
|
|
101865
|
+
if (cellLocation !== 'body') {
|
|
101866
|
+
customRender = define?.headerCustomRender;
|
|
101867
|
+
customLayout = define?.headerCustomLayout;
|
|
101868
|
+
}
|
|
101869
|
+
else {
|
|
101870
|
+
customRender = define?.customRender || tableInstance.customRender;
|
|
101871
|
+
customLayout = define?.customLayout;
|
|
101872
|
+
}
|
|
101873
|
+
if (options?.formatExportOutput) {
|
|
101874
|
+
const cellInfo = { cellType, cellValue, table: tableInstance, col, row };
|
|
101875
|
+
const formattedValue = options.formatExportOutput(cellInfo);
|
|
101876
|
+
if (formattedValue !== undefined) {
|
|
101877
|
+
let cell = worksheet.getCell(encodeCellAddress(col, row));
|
|
101878
|
+
cell.value = formattedValue;
|
|
101879
|
+
cell.font = getCellFont(cellStyle, cellType);
|
|
101880
|
+
cell.fill = getCellFill(cellStyle);
|
|
101881
|
+
cell.border = getCellBorder(cellStyle);
|
|
101882
|
+
const offset = getHierarchyOffset(col, row, tableInstance);
|
|
101883
|
+
cell.alignment = getCellAlignment(cellStyle, Math.ceil(offset / cell.font.size));
|
|
101884
|
+
if (cell && options?.formatExcelJSCell) {
|
|
101885
|
+
const formatedCell = options.formatExcelJSCell({ cellType, cellValue, table: tableInstance, col, row }, cell);
|
|
101886
|
+
if (formatedCell) {
|
|
101887
|
+
cell = formatedCell;
|
|
101888
|
+
}
|
|
101889
|
+
}
|
|
101890
|
+
return cell;
|
|
101891
|
+
}
|
|
101892
|
+
}
|
|
101893
|
+
let cell;
|
|
101894
|
+
if (cellType === 'image' ||
|
|
101895
|
+
cellType === 'video' ||
|
|
101896
|
+
cellType === 'progressbar' ||
|
|
101897
|
+
cellType === 'sparkline' ||
|
|
101898
|
+
layoutMap.isAxisCell(col, row) ||
|
|
101899
|
+
(!options?.ignoreIcon && isArray$a(icons) && icons.length) ||
|
|
101900
|
+
customRender ||
|
|
101901
|
+
customLayout) {
|
|
101902
|
+
if (!needCellImageExport(cellType, layoutMap.isAxisCell(col, row), !!customRender || !!customLayout, !!(!options?.ignoreIcon && isArray$a(icons) && icons.length), options)) {
|
|
101903
|
+
cell = worksheet.getCell(encodeCellAddress(col, row));
|
|
101904
|
+
}
|
|
101905
|
+
else {
|
|
101906
|
+
const cellImageBase64 = exportCellImg(col, row, tableInstance);
|
|
101907
|
+
const imageId = workbook.addImage({
|
|
101908
|
+
base64: cellImageBase64,
|
|
101909
|
+
extension: 'png'
|
|
101910
|
+
});
|
|
101911
|
+
worksheet.addImage(imageId, {
|
|
101912
|
+
tl: { col: col + 1 / 80, row: row + 1 / 120 },
|
|
101913
|
+
br: { col: col + 1, row: row + 1 },
|
|
101914
|
+
editAs: 'oneCell'
|
|
101915
|
+
});
|
|
101916
|
+
}
|
|
101917
|
+
}
|
|
101918
|
+
else if (cellType === 'text' || cellType === 'link') {
|
|
101919
|
+
cell = worksheet.getCell(encodeCellAddress(col, row));
|
|
101920
|
+
let linkUrl;
|
|
101921
|
+
if (cellType === 'link') {
|
|
101922
|
+
const templateLink = define.templateLink;
|
|
101923
|
+
if (templateLink) {
|
|
101924
|
+
const rowData = tableInstance.getCellOriginRecord(col, row);
|
|
101925
|
+
if (rowData && rowData.vtableMerge) ;
|
|
101926
|
+
else {
|
|
101927
|
+
const cellOriginValue = tableInstance.getCellOriginValue(col, row);
|
|
101928
|
+
const data = Object.assign({
|
|
101929
|
+
__value: cellValue,
|
|
101930
|
+
__dataValue: cellOriginValue
|
|
101931
|
+
}, rowData);
|
|
101932
|
+
if (isFunction$a(templateLink)) {
|
|
101933
|
+
linkUrl = templateLink(data, col, row, tableInstance);
|
|
101934
|
+
}
|
|
101935
|
+
else {
|
|
101936
|
+
const re = /\{\s*(\S+?)\s*\}/g;
|
|
101937
|
+
linkUrl = templateLink.replace(re, (matchs, key) => {
|
|
101938
|
+
return data[key];
|
|
101939
|
+
});
|
|
101940
|
+
}
|
|
101941
|
+
}
|
|
101942
|
+
}
|
|
101943
|
+
}
|
|
101944
|
+
cell.value = getCellValue(cellValue, cellType, linkUrl);
|
|
101945
|
+
cell.font = getCellFont(cellStyle, cellType);
|
|
101946
|
+
cell.fill = getCellFill(cellStyle);
|
|
101947
|
+
cell.border = getCellBorder(cellStyle);
|
|
101948
|
+
const offset = getHierarchyOffset(col, row, tableInstance);
|
|
101949
|
+
cell.alignment = getCellAlignment(cellStyle, Math.ceil(offset / cell.font.size));
|
|
101950
|
+
}
|
|
101951
|
+
else if (cellType === 'chart') {
|
|
101952
|
+
if (!needCellImageExport('chart', false, false, false, options)) {
|
|
101953
|
+
cell = worksheet.getCell(encodeCellAddress(col, row));
|
|
101954
|
+
}
|
|
101955
|
+
else {
|
|
101956
|
+
const cellGroup = tableInstance.scenegraph.getCell(col, row);
|
|
101957
|
+
VTable.renderChart(cellGroup.firstChild);
|
|
101958
|
+
const cellImageBase64 = exportCellImg(col, row, tableInstance);
|
|
101959
|
+
const imageId = workbook.addImage({
|
|
101960
|
+
base64: cellImageBase64,
|
|
101961
|
+
extension: 'png'
|
|
101962
|
+
});
|
|
101963
|
+
worksheet.addImage(imageId, {
|
|
101964
|
+
tl: { col: col + 1 / 80, row: row + 1 / 120 },
|
|
101965
|
+
br: { col: col + 1, row: row + 1 },
|
|
101966
|
+
editAs: 'oneCell'
|
|
101967
|
+
});
|
|
101968
|
+
tableInstance.scenegraph.updateNextFrame();
|
|
101969
|
+
}
|
|
101970
|
+
}
|
|
101971
|
+
if (cell && options?.formatExcelJSCell) {
|
|
101972
|
+
const formatedCell = options.formatExcelJSCell({ cellType, cellValue, table: tableInstance, col, row }, cell);
|
|
101973
|
+
if (formatedCell) {
|
|
101974
|
+
cell = formatedCell;
|
|
101975
|
+
}
|
|
101976
|
+
}
|
|
101977
|
+
return cell;
|
|
101978
|
+
}
|
|
101979
|
+
function getCellValue(cellValue, cellType, linkUrl) {
|
|
101980
|
+
if (cellType === 'link') {
|
|
101981
|
+
return {
|
|
101982
|
+
text: cellValue,
|
|
101983
|
+
hyperlink: linkUrl || cellValue,
|
|
101984
|
+
tooltip: cellValue
|
|
101985
|
+
};
|
|
101986
|
+
}
|
|
101987
|
+
return cellValue;
|
|
101988
|
+
}
|
|
101989
|
+
function exportCellImg(col, row, tableInstance) {
|
|
101990
|
+
let cellGroup = tableInstance.scenegraph.getCell(col, row);
|
|
101991
|
+
let needRemove = false;
|
|
101992
|
+
if (cellGroup.role === 'empty') {
|
|
101993
|
+
cellGroup = VTable.updateCell(col, row, tableInstance, true);
|
|
101994
|
+
cellGroup.setStage(tableInstance.scenegraph.stage);
|
|
101995
|
+
needRemove = true;
|
|
101996
|
+
cellGroup.stage.dirtyBounds.set(-Infinity, -Infinity, Infinity, Infinity);
|
|
101997
|
+
}
|
|
101998
|
+
const oldStroke = cellGroup.attribute.stroke;
|
|
101999
|
+
cellGroup.attribute.stroke = false;
|
|
102000
|
+
const canvas = VTable.graphicUtil.drawGraphicToCanvas(cellGroup, tableInstance.scenegraph.stage);
|
|
102001
|
+
cellGroup.attribute.stroke = oldStroke;
|
|
102002
|
+
if (needRemove) {
|
|
102003
|
+
cellGroup.parent?.removeChild(cellGroup);
|
|
102004
|
+
}
|
|
102005
|
+
return canvas.toDataURL();
|
|
102006
|
+
}
|
|
102007
|
+
function needCellImageExport(cellType, isAxisCell, isCustomCell, isTextWithIcon, options) {
|
|
102008
|
+
if (!options?.skipImageExportCellType) {
|
|
102009
|
+
return true;
|
|
102010
|
+
}
|
|
102011
|
+
if (cellType === 'image' ||
|
|
102012
|
+
cellType === 'video' ||
|
|
102013
|
+
cellType === 'progressbar' ||
|
|
102014
|
+
cellType === 'sparkline' ||
|
|
102015
|
+
cellType === 'chart') {
|
|
102016
|
+
return !options.skipImageExportCellType.includes(cellType);
|
|
102017
|
+
}
|
|
102018
|
+
else if (isAxisCell) {
|
|
102019
|
+
return !options.skipImageExportCellType.includes('chart');
|
|
102020
|
+
}
|
|
102021
|
+
else if (isCustomCell) {
|
|
102022
|
+
return !options.skipImageExportCellType.includes('custom');
|
|
102023
|
+
}
|
|
102024
|
+
else if (isTextWithIcon) {
|
|
102025
|
+
return !options.skipImageExportCellType.includes('textWithIcon');
|
|
102026
|
+
}
|
|
102027
|
+
return true;
|
|
102028
|
+
}
|
|
102029
|
+
|
|
102030
|
+
const newLine = '\r\n';
|
|
102031
|
+
const separator = ',';
|
|
102032
|
+
function exportVTableToCsv(tableInstance, option) {
|
|
102033
|
+
const exportAllData = !!option?.exportAllData;
|
|
102034
|
+
const { handleRowCount, reset } = handlePaginationExport(tableInstance, exportAllData);
|
|
102035
|
+
const minRow = 0;
|
|
102036
|
+
const maxRow = handleRowCount();
|
|
102037
|
+
const minCol = 0;
|
|
102038
|
+
const maxCol = tableInstance.colCount - 1;
|
|
102039
|
+
let copyValue = '';
|
|
102040
|
+
for (let row = minRow; row <= maxRow; row++) {
|
|
102041
|
+
for (let col = minCol; col <= maxCol; col++) {
|
|
102042
|
+
const copyCellValue = getCopyCellValue(col, row, tableInstance, option);
|
|
102043
|
+
if (typeof Promise !== 'undefined' && copyCellValue instanceof Promise) ;
|
|
102044
|
+
else {
|
|
102045
|
+
const strCellValue = `${copyCellValue}`;
|
|
102046
|
+
if (/^\[object .*\]$/.exec(strCellValue)) ;
|
|
102047
|
+
else {
|
|
102048
|
+
copyValue += strCellValue;
|
|
102049
|
+
}
|
|
102050
|
+
}
|
|
102051
|
+
copyValue += separator;
|
|
102052
|
+
}
|
|
102053
|
+
copyValue += newLine;
|
|
102054
|
+
}
|
|
102055
|
+
reset();
|
|
102056
|
+
return copyValue;
|
|
102057
|
+
}
|
|
102058
|
+
function getCopyCellValue(col, row, tableInstance, option) {
|
|
102059
|
+
const rawRecord = tableInstance.getCellRawRecord(col, row);
|
|
102060
|
+
const cellValue = (rawRecord && rawRecord.vtableMergeName) ?? tableInstance.getCellValue(col, row, false);
|
|
102061
|
+
if (option?.formatExportOutput) {
|
|
102062
|
+
const cellType = tableInstance.getCellType(col, row);
|
|
102063
|
+
const cellInfo = { cellType, cellValue, table: tableInstance, col, row };
|
|
102064
|
+
const formattedValue = option.formatExportOutput(cellInfo);
|
|
102065
|
+
if (formattedValue !== undefined) {
|
|
102066
|
+
if (typeof formattedValue === 'string') {
|
|
102067
|
+
return '"' + formattedValue + '"';
|
|
102068
|
+
}
|
|
102069
|
+
return formattedValue;
|
|
102070
|
+
}
|
|
102071
|
+
}
|
|
102072
|
+
const cellRange = tableInstance.getCellRange(col, row);
|
|
102073
|
+
const copyStartCol = cellRange.start.col;
|
|
102074
|
+
const copyStartRow = cellRange.start.row;
|
|
102075
|
+
if (copyStartCol !== col || copyStartRow !== row) {
|
|
102076
|
+
return '';
|
|
102077
|
+
}
|
|
102078
|
+
let value = cellValue;
|
|
102079
|
+
if (option?.escape) {
|
|
102080
|
+
value = escapeForCSV(value);
|
|
102081
|
+
}
|
|
102082
|
+
else if (typeof value === 'string') {
|
|
102083
|
+
value = '"' + value + '"';
|
|
102084
|
+
}
|
|
102085
|
+
return value;
|
|
102086
|
+
}
|
|
102087
|
+
function escapeForCSV(str) {
|
|
102088
|
+
if (typeof str !== 'string') {
|
|
102089
|
+
return str;
|
|
102090
|
+
}
|
|
102091
|
+
let escapedStr = str.replace(/"/g, '""');
|
|
102092
|
+
if (/[,"\r\n]/.test(escapedStr)) {
|
|
102093
|
+
escapedStr = `"${escapedStr}"`;
|
|
102094
|
+
}
|
|
102095
|
+
return escapedStr;
|
|
102096
|
+
}
|
|
102097
|
+
|
|
102098
|
+
var FileSaver_min = {exports: {}};
|
|
102099
|
+
|
|
102100
|
+
(function (module, exports) {
|
|
102101
|
+
(function (a, b) {
|
|
102102
|
+
b();
|
|
102103
|
+
})(commonjsGlobal, function () {
|
|
102104
|
+
|
|
102105
|
+
function b(a, b) {
|
|
102106
|
+
return "undefined" == typeof b ? b = {
|
|
102107
|
+
autoBom: !1
|
|
102108
|
+
} : "object" != typeof b && (b = {
|
|
102109
|
+
autoBom: !b
|
|
102110
|
+
}), b.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type) ? new Blob(["\uFEFF", a], {
|
|
102111
|
+
type: a.type
|
|
102112
|
+
}) : a;
|
|
102113
|
+
}
|
|
102114
|
+
function c(a, b, c) {
|
|
102115
|
+
var d = new XMLHttpRequest();
|
|
102116
|
+
d.open("GET", a), d.responseType = "blob", d.onload = function () {
|
|
102117
|
+
g(d.response, b, c);
|
|
102118
|
+
}, d.onerror = function () {
|
|
102119
|
+
}, d.send();
|
|
102120
|
+
}
|
|
102121
|
+
function d(a) {
|
|
102122
|
+
var b = new XMLHttpRequest();
|
|
102123
|
+
b.open("HEAD", a, !1);
|
|
102124
|
+
try {
|
|
102125
|
+
b.send();
|
|
102126
|
+
} catch (a) {}
|
|
102127
|
+
return 200 <= b.status && 299 >= b.status;
|
|
102128
|
+
}
|
|
102129
|
+
function e(a) {
|
|
102130
|
+
try {
|
|
102131
|
+
a.dispatchEvent(new MouseEvent("click"));
|
|
102132
|
+
} catch (c) {
|
|
102133
|
+
var b = document.createEvent("MouseEvents");
|
|
102134
|
+
b.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), a.dispatchEvent(b);
|
|
102135
|
+
}
|
|
102136
|
+
}
|
|
102137
|
+
var f = "object" == typeof window && window.window === window ? window : "object" == typeof self && self.self === self ? self : "object" == typeof commonjsGlobal && commonjsGlobal.global === commonjsGlobal ? commonjsGlobal : void 0,
|
|
102138
|
+
a = f.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent),
|
|
102139
|
+
g = f.saveAs || ("object" != typeof window || window !== f ? function () {} : "download" in HTMLAnchorElement.prototype && !a ? function (b, g, h) {
|
|
102140
|
+
var i = f.URL || f.webkitURL,
|
|
102141
|
+
j = document.createElement("a");
|
|
102142
|
+
g = g || b.name || "download", j.download = g, j.rel = "noopener", "string" == typeof b ? (j.href = b, j.origin === location.origin ? e(j) : d(j.href) ? c(b, g, h) : e(j, j.target = "_blank")) : (j.href = i.createObjectURL(b), setTimeout(function () {
|
|
102143
|
+
i.revokeObjectURL(j.href);
|
|
102144
|
+
}, 4E4), setTimeout(function () {
|
|
102145
|
+
e(j);
|
|
102146
|
+
}, 0));
|
|
102147
|
+
} : "msSaveOrOpenBlob" in navigator ? function (f, g, h) {
|
|
102148
|
+
if (g = g || f.name || "download", "string" != typeof f) navigator.msSaveOrOpenBlob(b(f, h), g);else if (d(f)) c(f, g, h);else {
|
|
102149
|
+
var i = document.createElement("a");
|
|
102150
|
+
i.href = f, i.target = "_blank", setTimeout(function () {
|
|
102151
|
+
e(i);
|
|
102152
|
+
});
|
|
102153
|
+
}
|
|
102154
|
+
} : function (b, d, e, g) {
|
|
102155
|
+
if (g = g || open("", "_blank"), g && (g.document.title = g.document.body.innerText = "downloading..."), "string" == typeof b) return c(b, d, e);
|
|
102156
|
+
var h = "application/octet-stream" === b.type,
|
|
102157
|
+
i = /constructor/i.test(f.HTMLElement) || f.safari,
|
|
102158
|
+
j = /CriOS\/[\d]+/.test(navigator.userAgent);
|
|
102159
|
+
if ((j || h && i || a) && "undefined" != typeof FileReader) {
|
|
102160
|
+
var k = new FileReader();
|
|
102161
|
+
k.onloadend = function () {
|
|
102162
|
+
var a = k.result;
|
|
102163
|
+
a = j ? a : a.replace(/^data:[^;]*;/, "data:attachment/file;"), g ? g.location.href = a : location = a, g = null;
|
|
102164
|
+
}, k.readAsDataURL(b);
|
|
102165
|
+
} else {
|
|
102166
|
+
var l = f.URL || f.webkitURL,
|
|
102167
|
+
m = l.createObjectURL(b);
|
|
102168
|
+
g ? g.location = m : location.href = m, g = null, setTimeout(function () {
|
|
102169
|
+
l.revokeObjectURL(m);
|
|
102170
|
+
}, 4E4);
|
|
102171
|
+
}
|
|
102172
|
+
});
|
|
102173
|
+
f.saveAs = g.saveAs = g, (module.exports = g);
|
|
102174
|
+
});
|
|
102175
|
+
})(FileSaver_min);
|
|
102176
|
+
var FileSaver_minExports = FileSaver_min.exports;
|
|
102177
|
+
|
|
102178
|
+
async function downloadCsv(str, name) {
|
|
102179
|
+
const blob = new Blob([`\ufeff${str}`], {
|
|
102180
|
+
type: 'text/csv;charset=utf-8'
|
|
102181
|
+
});
|
|
102182
|
+
await FileSaver_minExports.saveAs(blob, `${name}.csv`);
|
|
102183
|
+
}
|
|
102184
|
+
async function downloadExcel(arrayBuffer, name) {
|
|
102185
|
+
const blob = new Blob([arrayBuffer], {
|
|
102186
|
+
type: 'application/octet-stream'
|
|
102187
|
+
});
|
|
102188
|
+
await FileSaver_minExports.saveAs(blob, `${name}.xlsx`);
|
|
102189
|
+
}
|
|
102190
|
+
|
|
102191
|
+
class TableExportPlugin {
|
|
102192
|
+
id = 'table-export-plugin';
|
|
102193
|
+
name = 'TableExport';
|
|
102194
|
+
runTime = [VTable__namespace.TABLE_EVENT_TYPE.INITIALIZED];
|
|
102195
|
+
table;
|
|
102196
|
+
pluginOptions;
|
|
102197
|
+
constructor(pluginOptions) {
|
|
102198
|
+
this.pluginOptions = Object.assign({
|
|
102199
|
+
exportOnIdle: false,
|
|
102200
|
+
exportExcelOptions: { downloadFile: true, fileName: 'export' },
|
|
102201
|
+
exportCsvOptions: { downloadFile: true, fileName: 'export' }
|
|
102202
|
+
}, pluginOptions);
|
|
102203
|
+
}
|
|
102204
|
+
run(...args) {
|
|
102205
|
+
const runTime = args[1];
|
|
102206
|
+
if (runTime === VTable__namespace.TABLE_EVENT_TYPE.INITIALIZED) {
|
|
102207
|
+
args[0];
|
|
102208
|
+
this.table = args[2];
|
|
102209
|
+
this.table.exportToCsv = () => {
|
|
102210
|
+
const options = this.pluginOptions.exportCsvOptions;
|
|
102211
|
+
if (options.downloadFile) {
|
|
102212
|
+
return downloadCsv(exportVTableToCsv(this.table, options), options.fileName || 'export');
|
|
102213
|
+
}
|
|
102214
|
+
return exportVTableToCsv(this.table, options);
|
|
102215
|
+
};
|
|
102216
|
+
this.table.exportToExcel = async () => {
|
|
102217
|
+
const options = this.pluginOptions.exportExcelOptions;
|
|
102218
|
+
if (options.downloadFile) {
|
|
102219
|
+
return await downloadExcel((await exportVTableToExcel(this.table, options, this.pluginOptions.exportOnIdle)), options.fileName || 'export');
|
|
102220
|
+
}
|
|
102221
|
+
return exportVTableToExcel(this.table, options, this.pluginOptions.exportOnIdle);
|
|
102222
|
+
};
|
|
102223
|
+
}
|
|
102224
|
+
}
|
|
102225
|
+
release() {
|
|
102226
|
+
if (this.table) {
|
|
102227
|
+
delete this.table.exportToCsv;
|
|
102228
|
+
delete this.table.exportToExcel;
|
|
102229
|
+
this.table = null;
|
|
102230
|
+
}
|
|
102231
|
+
}
|
|
102232
|
+
}
|
|
102233
|
+
|
|
101221
102234
|
exports.AddRowColumnPlugin = AddRowColumnPlugin;
|
|
101222
102235
|
exports.CarouselAnimationPlugin = CarouselAnimationPlugin;
|
|
101223
102236
|
exports.ColumnSeriesPlugin = ColumnSeriesPlugin;
|
|
@@ -101232,6 +102245,7 @@ ${recordsStr}
|
|
|
101232
102245
|
exports.RotateTablePlugin = RotateTablePlugin;
|
|
101233
102246
|
exports.RowSeriesPlugin = RowSeriesPlugin;
|
|
101234
102247
|
exports.TableCarouselAnimationPlugin = TableCarouselAnimationPlugin;
|
|
102248
|
+
exports.TableExportPlugin = TableExportPlugin;
|
|
101235
102249
|
exports.WpsFillHandlePlugin = WpsFillHandlePlugin;
|
|
101236
102250
|
exports.cancelTransform = cancelTransform;
|
|
101237
102251
|
exports.rotate90WithTransform = rotate90WithTransform;
|