@visactor/vtable-plugins 1.17.7-alpha.0 → 1.17.7
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/add-row-column.d.ts +40 -0
- package/cjs/add-row-column.js +217 -0
- package/cjs/add-row-column.js.map +1 -0
- package/cjs/carousel-animation.js +2 -1
- package/cjs/column-series.d.ts +29 -0
- package/cjs/column-series.js +76 -0
- package/cjs/column-series.js.map +1 -0
- package/cjs/excel-edit-cell-keyboard.d.ts +16 -0
- package/cjs/excel-edit-cell-keyboard.js +79 -0
- package/cjs/excel-edit-cell-keyboard.js.map +1 -0
- package/cjs/focus-highlight.d.ts +23 -0
- package/cjs/focus-highlight.js +93 -0
- package/cjs/focus-highlight.js.map +1 -0
- package/cjs/header-highlight.js.map +1 -1
- package/cjs/highlight-header-when-select-cell.d.ts +25 -0
- package/cjs/highlight-header-when-select-cell.js +111 -0
- package/cjs/highlight-header-when-select-cell.js.map +1 -0
- package/cjs/index.d.ts +8 -0
- package/cjs/index.js +5 -1
- package/cjs/index.js.map +1 -1
- package/cjs/invert-highlight.js.map +1 -1
- package/cjs/row-series.d.ts +15 -0
- package/cjs/row-series.js +35 -0
- package/cjs/row-series.js.map +1 -0
- package/cjs/table-carousel-animation.d.ts +53 -0
- package/cjs/table-carousel-animation.js +73 -0
- package/cjs/table-carousel-animation.js.map +1 -0
- package/cjs/types.d.ts +3 -0
- package/cjs/types.js +6 -0
- package/cjs/types.js.map +1 -0
- package/dist/vtable-plugins.js +2893 -859
- package/dist/vtable-plugins.min.js +1 -1
- package/es/add-row-column.d.ts +40 -0
- package/es/add-row-column.js +184 -0
- package/es/add-row-column.js.map +1 -0
- package/es/carousel-animation.js +2 -1
- package/es/column-series.d.ts +29 -0
- package/es/column-series.js +43 -0
- package/es/column-series.js.map +1 -0
- package/es/excel-edit-cell-keyboard.d.ts +16 -0
- package/es/excel-edit-cell-keyboard.js +46 -0
- package/es/excel-edit-cell-keyboard.js.map +1 -0
- package/es/focus-highlight.d.ts +23 -0
- package/es/focus-highlight.js +91 -0
- package/es/focus-highlight.js.map +1 -0
- package/es/header-highlight.js.map +1 -1
- package/es/highlight-header-when-select-cell.d.ts +25 -0
- package/es/highlight-header-when-select-cell.js +103 -0
- package/es/highlight-header-when-select-cell.js.map +1 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +16 -0
- package/es/index.js.map +1 -1
- package/es/invert-highlight.js.map +1 -1
- package/es/row-series.d.ts +15 -0
- package/es/row-series.js +27 -0
- package/es/row-series.js.map +1 -0
- package/es/table-carousel-animation.d.ts +53 -0
- package/es/table-carousel-animation.js +65 -0
- package/es/table-carousel-animation.js.map +1 -0
- package/es/types.d.ts +3 -0
- package/es/types.js +2 -0
- package/es/types.js.map +1 -0
- package/package.json +7 -7
package/dist/vtable-plugins.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.VTable = global.VTable || {}, global.VTable.plugins = {})));
|
|
5
|
-
})(this, (function (exports) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@visactor/vtable')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@visactor/vtable'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.VTable = global.VTable || {}, global.VTable.plugins = {}), global.VTable));
|
|
5
|
+
})(this, (function (exports, VTable) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var VTable__namespace = /*#__PURE__*/_interopNamespaceDefault(VTable);
|
|
25
|
+
|
|
26
|
+
function isInteger$1(value) {
|
|
8
27
|
return Math.floor(value) === value;
|
|
9
28
|
}
|
|
10
29
|
class CarouselAnimationPlugin {
|
|
@@ -92,11 +111,11 @@
|
|
|
92
111
|
this.row = customRow.distRow;
|
|
93
112
|
animation = customRow.animation ?? true;
|
|
94
113
|
}
|
|
95
|
-
else if (isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== this.row) {
|
|
114
|
+
else if (isInteger$1(this.row) && this.table.scenegraph.proxy.screenTopRow !== this.row) {
|
|
96
115
|
this.row = this.table.frozenRowCount;
|
|
97
116
|
animation = false;
|
|
98
117
|
}
|
|
99
|
-
else if (!isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== Math.floor(this.row)) {
|
|
118
|
+
else if (!isInteger$1(this.row) && this.table.scenegraph.proxy.screenTopRow !== Math.floor(this.row)) {
|
|
100
119
|
this.row = this.table.frozenRowCount;
|
|
101
120
|
animation = false;
|
|
102
121
|
}
|
|
@@ -120,11 +139,11 @@
|
|
|
120
139
|
this.col = customCol.distCol;
|
|
121
140
|
animation = customCol.animation ?? true;
|
|
122
141
|
}
|
|
123
|
-
else if (isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) {
|
|
142
|
+
else if (isInteger$1(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) {
|
|
124
143
|
this.col = this.table.frozenColCount;
|
|
125
144
|
animation = false;
|
|
126
145
|
}
|
|
127
|
-
else if (!isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== Math.floor(this.col)) {
|
|
146
|
+
else if (!isInteger$1(this.col) && this.table.scenegraph.proxy.screenLeftCol !== Math.floor(this.col)) {
|
|
128
147
|
this.col = this.table.frozenColCount;
|
|
129
148
|
animation = false;
|
|
130
149
|
}
|
|
@@ -902,6 +921,25 @@
|
|
|
902
921
|
clone() {
|
|
903
922
|
return new OBBBounds(this);
|
|
904
923
|
}
|
|
924
|
+
getRotatedCorners() {
|
|
925
|
+
const originPoint = {
|
|
926
|
+
x: (this.x1 + this.x2) / 2,
|
|
927
|
+
y: (this.y1 + this.y2) / 2
|
|
928
|
+
};
|
|
929
|
+
return [rotatePoint({
|
|
930
|
+
x: this.x1,
|
|
931
|
+
y: this.y1
|
|
932
|
+
}, this.angle, originPoint), rotatePoint({
|
|
933
|
+
x: this.x2,
|
|
934
|
+
y: this.y1
|
|
935
|
+
}, this.angle, originPoint), rotatePoint({
|
|
936
|
+
x: this.x1,
|
|
937
|
+
y: this.y2
|
|
938
|
+
}, this.angle, originPoint), rotatePoint({
|
|
939
|
+
x: this.x2,
|
|
940
|
+
y: this.y2
|
|
941
|
+
}, this.angle, originPoint)];
|
|
942
|
+
}
|
|
905
943
|
}
|
|
906
944
|
|
|
907
945
|
class Matrix {
|
|
@@ -1525,10 +1563,13 @@
|
|
|
1525
1563
|
|
|
1526
1564
|
class CurvePath {
|
|
1527
1565
|
constructor() {
|
|
1528
|
-
this.
|
|
1566
|
+
this._curves = [], this.bounds = new AABBBounds();
|
|
1567
|
+
}
|
|
1568
|
+
get curves() {
|
|
1569
|
+
return this._curves;
|
|
1529
1570
|
}
|
|
1530
1571
|
getCurveLengths() {
|
|
1531
|
-
return this.
|
|
1572
|
+
return this._curves.map(curve => curve.getLength());
|
|
1532
1573
|
}
|
|
1533
1574
|
getPointAt(t) {
|
|
1534
1575
|
return {
|
|
@@ -1770,7 +1811,83 @@
|
|
|
1770
1811
|
y = cubicCalc(p0.y, p1.y, p2.y, p3.y, t);
|
|
1771
1812
|
return new Point(x, y);
|
|
1772
1813
|
}
|
|
1814
|
+
function quadCalc(p0, p1, p2, t) {
|
|
1815
|
+
const one = 1 - t;
|
|
1816
|
+
return one * one * p0 + 2 * one * t * p1 + t * t * p2;
|
|
1817
|
+
}
|
|
1818
|
+
function quadPointAt(p0, p1, p2, t) {
|
|
1819
|
+
const x = quadCalc(p0.x, p1.x, p2.x, t),
|
|
1820
|
+
y = quadCalc(p0.y, p1.y, p2.y, t);
|
|
1821
|
+
return new Point(x, y);
|
|
1822
|
+
}
|
|
1823
|
+
function quadLength(p0, p1, p2, iterationCount) {
|
|
1824
|
+
return snapLength([p0.x, p1.x, p2.x], [p0.y, p1.y, p2.y]);
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
class QuadraticBezierCurve extends Curve {
|
|
1828
|
+
constructor(p0, p1, p2) {
|
|
1829
|
+
super(), this.type = CurveTypeEnum.QuadraticBezierCurve, this.p0 = p0, this.p1 = p1, this.p2 = p2;
|
|
1830
|
+
}
|
|
1831
|
+
_validPoint() {
|
|
1832
|
+
return Number.isFinite(this.p0.x + this.p0.y + this.p1.x + this.p1.y + this.p2.x + this.p2.y);
|
|
1833
|
+
}
|
|
1834
|
+
getPointAt(t) {
|
|
1835
|
+
if (!1 !== this.defined) return quadPointAt(this.p0, this.p1, this.p2, t);
|
|
1836
|
+
throw new Error("defined为false的点不能getPointAt");
|
|
1837
|
+
}
|
|
1838
|
+
calcLength() {
|
|
1839
|
+
return this._validPoint() ? quadLength(this.p0, this.p1, this.p2) : 60;
|
|
1840
|
+
}
|
|
1841
|
+
calcProjLength(direction) {
|
|
1842
|
+
return direction === Direction.ROW ? abs(this.p0.x - this.p2.x) : direction === Direction.COLUMN ? abs(this.p0.y - this.p2.y) : 0;
|
|
1843
|
+
}
|
|
1844
|
+
getAngleAt(t) {
|
|
1845
|
+
const minT = max(t - .01, 0),
|
|
1846
|
+
maxT = min(t + .01, 1),
|
|
1847
|
+
minP = this.getPointAt(minT),
|
|
1848
|
+
maxP = this.getPointAt(maxT);
|
|
1849
|
+
return atan2(maxP.y - minP.y, maxP.x - minP.x);
|
|
1850
|
+
}
|
|
1851
|
+
draw(path, x, y, sx, sy, percent) {
|
|
1852
|
+
if (path.moveTo(this.p0.x * sx + x, this.p0.y * sy + y), percent >= 1) path.quadraticCurveTo(this.p1.x * sx + x, this.p1.y * sy + y, this.p2.x * sx + x, this.p2.y * sy + y);else if (percent > 0) {
|
|
1853
|
+
const [curve1] = divideQuad(this, percent);
|
|
1854
|
+
path.quadraticCurveTo(curve1.p1.x * sx + x, curve1.p1.y * sy + y, curve1.p2.x * sx + x, curve1.p2.y * sy + y);
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
getYAt(x) {
|
|
1858
|
+
throw new Error("QuadraticBezierCurve暂不支持getYAt");
|
|
1859
|
+
}
|
|
1860
|
+
includeX(x) {
|
|
1861
|
+
throw new Error("QuadraticBezierCurve暂不支持includeX");
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1773
1864
|
|
|
1865
|
+
function divideCubic(curve, t) {
|
|
1866
|
+
const {
|
|
1867
|
+
p0: p0,
|
|
1868
|
+
p1: p1,
|
|
1869
|
+
p2: p2,
|
|
1870
|
+
p3: p3
|
|
1871
|
+
} = curve,
|
|
1872
|
+
pt = cubicPointAt(p0, p1, p2, p3, t),
|
|
1873
|
+
c1 = PointService.pointAtPP(p0, p1, t),
|
|
1874
|
+
c2 = PointService.pointAtPP(p1, p2, t),
|
|
1875
|
+
c3 = PointService.pointAtPP(p2, p3, t),
|
|
1876
|
+
c12 = PointService.pointAtPP(c1, c2, t),
|
|
1877
|
+
c23 = PointService.pointAtPP(c2, c3, t);
|
|
1878
|
+
return [new CubicBezierCurve(p0, c1, c12, pt), new CubicBezierCurve(pt, c23, c3, p3)];
|
|
1879
|
+
}
|
|
1880
|
+
function divideQuad(curve, t) {
|
|
1881
|
+
const {
|
|
1882
|
+
p0: p0,
|
|
1883
|
+
p1: p1,
|
|
1884
|
+
p2: p2
|
|
1885
|
+
} = curve,
|
|
1886
|
+
pt = quadPointAt(p0, p1, p2, t),
|
|
1887
|
+
c1 = PointService.pointAtPP(p0, p1, t),
|
|
1888
|
+
c2 = PointService.pointAtPP(p1, p2, t);
|
|
1889
|
+
return [new QuadraticBezierCurve(p0, c1, pt), new QuadraticBezierCurve(pt, c2, p2)];
|
|
1890
|
+
}
|
|
1774
1891
|
class CubicBezierCurve extends Curve {
|
|
1775
1892
|
constructor(p0, p1, p2, p3) {
|
|
1776
1893
|
super(), this.type = CurveTypeEnum.CubicBezierCurve, this.p0 = p0, this.p1 = p1, this.p2 = p2, this.p3 = p3;
|
|
@@ -1795,6 +1912,22 @@
|
|
|
1795
1912
|
maxP = this.getPointAt(maxT);
|
|
1796
1913
|
return atan2(maxP.y - minP.y, maxP.x - minP.x);
|
|
1797
1914
|
}
|
|
1915
|
+
draw(path, x, y, sx, sy, percent) {
|
|
1916
|
+
if (path.moveTo(this.p0.x * sx + x, this.p0.y * sy + y), percent >= 1) path.bezierCurveTo(this.p1.x * sx + x, this.p1.y * sy + y, this.p2.x * sx + x, this.p2.y * sy + y, this.p3.x * sx + x, this.p3.y * sy + y);else if (percent > 0) {
|
|
1917
|
+
const [curve1] = divideCubic(this, percent);
|
|
1918
|
+
path.bezierCurveTo(curve1.p1.x * sx + x, curve1.p1.y * sy + y, curve1.p2.x * sx + x, curve1.p2.y * sy + y, curve1.p3.x * sx + x, curve1.p3.y * sy + y);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
includeX(x) {
|
|
1922
|
+
const minX = min(this.p0.x, this.p1.x, this.p2.x, this.p3.x),
|
|
1923
|
+
maxX = max(this.p0.x, this.p1.x, this.p2.x, this.p3.x);
|
|
1924
|
+
return x >= minX && x <= maxX;
|
|
1925
|
+
}
|
|
1926
|
+
getYAt(x) {
|
|
1927
|
+
const minX = min(this.p0.x, this.p1.x, this.p2.x, this.p3.x),
|
|
1928
|
+
t = (x - minX) / (max(this.p0.x, this.p1.x, this.p2.x, this.p3.x) - minX);
|
|
1929
|
+
return this.getPointAt(t).y;
|
|
1930
|
+
}
|
|
1798
1931
|
}
|
|
1799
1932
|
|
|
1800
1933
|
class LineCurve extends Curve {
|
|
@@ -1817,6 +1950,25 @@
|
|
|
1817
1950
|
calcProjLength(direction) {
|
|
1818
1951
|
return direction === Direction.ROW ? abs(this.p0.x - this.p1.x) : direction === Direction.COLUMN ? abs(this.p0.y - this.p1.y) : 0;
|
|
1819
1952
|
}
|
|
1953
|
+
draw(path, x, y, sx, sy, percent) {
|
|
1954
|
+
if (path.moveTo(this.p0.x * sx + x, this.p0.y * sy + y), percent >= 1) path.lineTo(this.p1.x * sx + x, this.p1.y * sy + y);else if (percent > 0) {
|
|
1955
|
+
const p = this.getPointAt(percent);
|
|
1956
|
+
path.lineTo(p.x * sx + x, p.y * sy + y);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
includeX(x) {
|
|
1960
|
+
return x >= this.p0.x && x <= this.p1.x || x >= this.p1.x && x <= this.p0.x;
|
|
1961
|
+
}
|
|
1962
|
+
getYAt(x) {
|
|
1963
|
+
if (this.includeX(x)) {
|
|
1964
|
+
let minP = this.p0,
|
|
1965
|
+
maxP = this.p1;
|
|
1966
|
+
this.p0.x > this.p1.x && (minP = this.p1, maxP = this.p0);
|
|
1967
|
+
const percent = (x - minP.x) / (maxP.x - minP.x);
|
|
1968
|
+
return minP.y + percent * (maxP.y - minP.y);
|
|
1969
|
+
}
|
|
1970
|
+
return 1 / 0;
|
|
1971
|
+
}
|
|
1820
1972
|
}
|
|
1821
1973
|
|
|
1822
1974
|
class SegContext {
|
|
@@ -2155,7 +2307,7 @@
|
|
|
2155
2307
|
default:
|
|
2156
2308
|
if (this._t <= 0) this.context.lineTo(this._x, y, !1 !== this._lastDefined && !1 !== p.defined, this.lastPoint), this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined, p);else {
|
|
2157
2309
|
const x1 = this._x * (1 - this._t) + x * this._t;
|
|
2158
|
-
this.context.lineTo(x1, this._y, !1 !== this._lastDefined && !1 !== p.defined, this.lastPoint), this.context.lineTo(x1, y, !1 !== this._lastDefined && !1 !== p.defined, p);
|
|
2310
|
+
.5 === this._t ? this.context.lineTo(x1, this._y, !1 !== this._lastDefined, this.lastPoint) : this.context.lineTo(x1, this._y, !1 !== this._lastDefined && !1 !== p.defined, this.lastPoint), this.context.lineTo(x1, y, !1 !== this._lastDefined && !1 !== p.defined, p);
|
|
2159
2311
|
}
|
|
2160
2312
|
}
|
|
2161
2313
|
this._lastDefined = p.defined, this._x = x, this._y = y, this.lastPoint = p;
|
|
@@ -2353,6 +2505,45 @@
|
|
|
2353
2505
|
}
|
|
2354
2506
|
const genCatmullRomClosedSegments = commonGenCatmullRomSegments("catmullRomClosed", CatmullRomClosed);
|
|
2355
2507
|
|
|
2508
|
+
class CurveContext {
|
|
2509
|
+
constructor(path) {
|
|
2510
|
+
this.path = path, this._lastX = this._lastY = this._startX = this._startY = 0;
|
|
2511
|
+
}
|
|
2512
|
+
moveTo(x, y) {
|
|
2513
|
+
return this._lastX = this._startX = x, this._lastY = this._startY = y, this;
|
|
2514
|
+
}
|
|
2515
|
+
lineTo(x, y) {
|
|
2516
|
+
const curve = this.addLinearCurve(x, y);
|
|
2517
|
+
this.path.addCurve(curve), this._lastX = x, this._lastY = y;
|
|
2518
|
+
}
|
|
2519
|
+
addLinearCurve(x, y) {
|
|
2520
|
+
return new LineCurve(new Point(this._lastX, this._lastY), new Point(x, y));
|
|
2521
|
+
}
|
|
2522
|
+
quadraticCurveTo(aCPx, aCPy, aX, aY) {
|
|
2523
|
+
const curve = new QuadraticBezierCurve(new Point(this._lastX, this._lastY), new Point(aCPx, aCPy), new Point(aX, aY));
|
|
2524
|
+
this.path.addCurve(curve), this._lastX = aX, this._lastY = aY;
|
|
2525
|
+
}
|
|
2526
|
+
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
2527
|
+
const curve = new CubicBezierCurve(new Point(this._lastX, this._lastY), new Point(cp1x, cp1y), new Point(cp2x, cp2y), new Point(x, y));
|
|
2528
|
+
this.path.addCurve(curve), this._lastX = x, this._lastY = y;
|
|
2529
|
+
}
|
|
2530
|
+
arcTo(aX1, aY1, aX2, aY2, aRadius) {
|
|
2531
|
+
throw new Error("CurveContext不支持调用arcTo");
|
|
2532
|
+
}
|
|
2533
|
+
ellipse(aX, aY, xRadius, yRadius, aRotation, aStartAngle, aEndAngle, aClockwise) {
|
|
2534
|
+
throw new Error("CurveContext不支持调用ellipse");
|
|
2535
|
+
}
|
|
2536
|
+
rect(x, y, w, h) {
|
|
2537
|
+
throw new Error("CurveContext不支持调用rect");
|
|
2538
|
+
}
|
|
2539
|
+
arc(x, y, radius, startAngle, endAngle, counterclockwise) {
|
|
2540
|
+
throw new Error("CurveContext不支持调用arc");
|
|
2541
|
+
}
|
|
2542
|
+
closePath() {
|
|
2543
|
+
this.path.curves.length < 2 || this.lineTo(this._startX, this._startY);
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2356
2547
|
function calcLineCache(points, curveType, params) {
|
|
2357
2548
|
var _a, _b;
|
|
2358
2549
|
switch (curveType) {
|
|
@@ -2384,6 +2575,9 @@
|
|
|
2384
2575
|
constructor(ctx) {
|
|
2385
2576
|
super(), this.commandList = [], ctx && (this._ctx = ctx), this._boundsContext = new BoundsContext(this.bounds);
|
|
2386
2577
|
}
|
|
2578
|
+
get curves() {
|
|
2579
|
+
return this.tryBuildCurves();
|
|
2580
|
+
}
|
|
2387
2581
|
setCtx(ctx) {
|
|
2388
2582
|
this._ctx = ctx;
|
|
2389
2583
|
}
|
|
@@ -2415,14 +2609,21 @@
|
|
|
2415
2609
|
return this.commandList.push([enumCommandMap.Z]), this._ctx && this._ctx.closePath(), this;
|
|
2416
2610
|
}
|
|
2417
2611
|
addCurve(curve) {
|
|
2418
|
-
this.
|
|
2612
|
+
this._curves.push(curve);
|
|
2419
2613
|
}
|
|
2420
2614
|
clear() {
|
|
2421
|
-
this.transformCbList = null, this.commandList.length = 0, this.
|
|
2615
|
+
this.transformCbList = null, this.commandList.length = 0, this._curves.length = 0;
|
|
2422
2616
|
}
|
|
2423
2617
|
beginPath() {
|
|
2424
2618
|
this.clear();
|
|
2425
2619
|
}
|
|
2620
|
+
tryBuildCurves() {
|
|
2621
|
+
if (!this._curves || !this._curves.length) {
|
|
2622
|
+
const curveContext = new CurveContext(this);
|
|
2623
|
+
renderCommandList(this.commandList, curveContext, 0, 0, 1, 1);
|
|
2624
|
+
}
|
|
2625
|
+
return this._curves;
|
|
2626
|
+
}
|
|
2426
2627
|
toString() {
|
|
2427
2628
|
if (!this.toStringCbList) {
|
|
2428
2629
|
const list = [];
|
|
@@ -2453,7 +2654,7 @@
|
|
|
2453
2654
|
} = line.attribute;
|
|
2454
2655
|
if (!points) return;
|
|
2455
2656
|
const cache = calcLineCache(points, curveType);
|
|
2456
|
-
"x" === clipRangeByDimension ? this.direction = Direction.ROW : "y" === clipRangeByDimension ? this.direction = Direction.COLUMN : "auto" === clipRangeByDimension && (this.direction = cache.direction), this.
|
|
2657
|
+
"x" === clipRangeByDimension ? this.direction = Direction.ROW : "y" === clipRangeByDimension ? this.direction = Direction.COLUMN : "auto" === clipRangeByDimension && (this.direction = cache.direction), this._curves = cache.curves;
|
|
2457
2658
|
}
|
|
2458
2659
|
fromCustomPath2D(path, x, y, sX, sY) {
|
|
2459
2660
|
return this.clear(), this._runCommandList(path.commandList, x, y, sX, sY), this._updateBounds(), this;
|
|
@@ -2541,10 +2742,10 @@
|
|
|
2541
2742
|
x = current[5], y = current[6], controlX = current[3], controlY = current[4], this.bezierCurveTo(current[1] + l, current[2] + t, controlX + l, controlY + t, x + l, y + t);
|
|
2542
2743
|
break;
|
|
2543
2744
|
case "s":
|
|
2544
|
-
tempX = x + current[3], tempY = y + current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t,
|
|
2745
|
+
tempX = x + current[3], tempY = y + current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x, controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = x + current[1], tempControlY = y + current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t), controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
|
|
2545
2746
|
break;
|
|
2546
2747
|
case "S":
|
|
2547
|
-
tempX = current[3], tempY = current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t,
|
|
2748
|
+
tempX = current[3], tempY = current[4], null === previous[0].match(/[CcSs]/) ? (controlX = x, controlY = y) : (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = current[1], tempControlY = current[2], this.bezierCurveTo(controlX + l, controlY + t, tempControlX + l, tempControlY + t, tempX + l, tempY + t), controlX = tempControlX, controlY = tempControlY, x = tempX, y = tempY;
|
|
2548
2749
|
break;
|
|
2549
2750
|
case "q":
|
|
2550
2751
|
tempX = x + current[3], tempY = y + current[4], controlX = x + current[1], controlY = y + current[2], this.quadraticCurveTo(controlX + l, controlY + t, tempX + l, tempY + t), x = tempX, y = tempY;
|
|
@@ -2616,21 +2817,29 @@
|
|
|
2616
2817
|
}
|
|
2617
2818
|
getLength() {
|
|
2618
2819
|
if (this.direction === Direction.COLUMN) {
|
|
2619
|
-
if (!this.
|
|
2620
|
-
const sc = this.
|
|
2621
|
-
ec = this.
|
|
2820
|
+
if (!this._curves.length) return 0;
|
|
2821
|
+
const sc = this._curves[0],
|
|
2822
|
+
ec = this._curves[this._curves.length - 1];
|
|
2622
2823
|
return abs(sc.p0.y - ec.p1.y);
|
|
2623
2824
|
}
|
|
2624
2825
|
if (this.direction === Direction.ROW) {
|
|
2625
|
-
if (!this.
|
|
2626
|
-
const sc = this.
|
|
2627
|
-
ec = this.
|
|
2826
|
+
if (!this._curves.length) return 0;
|
|
2827
|
+
const sc = this._curves[0],
|
|
2828
|
+
ec = this._curves[this._curves.length - 1];
|
|
2628
2829
|
return abs(sc.p0.x - ec.p1.x);
|
|
2629
2830
|
}
|
|
2630
|
-
return this.
|
|
2831
|
+
return this._curves.reduce((l, c) => l + c.getLength(), 0);
|
|
2832
|
+
}
|
|
2833
|
+
getYAt(x) {
|
|
2834
|
+
if (!this.curves) return 1 / 0;
|
|
2835
|
+
for (let i = 0; i < this.curves.length; i++) {
|
|
2836
|
+
const curve = this.curves[i];
|
|
2837
|
+
if (curve.includeX(x)) return curve.getYAt(x);
|
|
2838
|
+
}
|
|
2839
|
+
return 1 / 0;
|
|
2631
2840
|
}
|
|
2632
2841
|
getAttrAt(distance) {
|
|
2633
|
-
if (!this.
|
|
2842
|
+
if (!this._curves) return {
|
|
2634
2843
|
pos: {
|
|
2635
2844
|
x: 0,
|
|
2636
2845
|
y: 0
|
|
@@ -2639,8 +2848,8 @@
|
|
|
2639
2848
|
};
|
|
2640
2849
|
let curve,
|
|
2641
2850
|
_dis = 0;
|
|
2642
|
-
for (let i = 0; i < this.
|
|
2643
|
-
curve = this.
|
|
2851
|
+
for (let i = 0; i < this._curves.length; i++) {
|
|
2852
|
+
curve = this._curves[i];
|
|
2644
2853
|
const cl = curve.getLength(this.direction);
|
|
2645
2854
|
if (_dis + cl >= distance) break;
|
|
2646
2855
|
_dis += cl;
|
|
@@ -2651,6 +2860,21 @@
|
|
|
2651
2860
|
angle: curve.getAngleAt(t)
|
|
2652
2861
|
};
|
|
2653
2862
|
}
|
|
2863
|
+
drawWithClipRange(ctx, size, x, y, clipRange) {
|
|
2864
|
+
this.tryBuildCurves();
|
|
2865
|
+
const totalLen = this.getLength() * clipRange;
|
|
2866
|
+
let currLen = 0;
|
|
2867
|
+
for (let i = 0; i < this._curves.length; i++) {
|
|
2868
|
+
const curve = this._curves[i],
|
|
2869
|
+
cl = curve.getLength(this.direction);
|
|
2870
|
+
if (!(currLen + cl <= totalLen)) {
|
|
2871
|
+
const percent = 1 - (currLen + cl - totalLen) / cl;
|
|
2872
|
+
curve.draw(ctx, x, y, size, size, percent);
|
|
2873
|
+
break;
|
|
2874
|
+
}
|
|
2875
|
+
curve.draw(ctx, x, y, size, size, 1), currLen += cl;
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2654
2878
|
}
|
|
2655
2879
|
const temp = ["l", 0, 0, 0, 0, 0, 0, 0];
|
|
2656
2880
|
function scale(current, sX, sY) {
|
|
@@ -2748,6 +2972,9 @@
|
|
|
2748
2972
|
forceBoundsHeight: void 0,
|
|
2749
2973
|
opacity: 1,
|
|
2750
2974
|
background: null,
|
|
2975
|
+
autoAnimateTexture: !1,
|
|
2976
|
+
textureRatio: 1,
|
|
2977
|
+
textureOptions: null,
|
|
2751
2978
|
backgroundOpacity: 1,
|
|
2752
2979
|
backgroundCornerRadius: 0,
|
|
2753
2980
|
texture: null,
|
|
@@ -2756,10 +2983,17 @@
|
|
|
2756
2983
|
texturePadding: 2,
|
|
2757
2984
|
backgroundMode: "no-repeat",
|
|
2758
2985
|
backgroundFit: !0,
|
|
2986
|
+
backgroundKeepAspectRatio: !1,
|
|
2987
|
+
backgroundClip: !0,
|
|
2988
|
+
backgroundScale: 1,
|
|
2989
|
+
backgroundOffsetX: 0,
|
|
2990
|
+
backgroundOffsetY: 0,
|
|
2759
2991
|
blur: 0,
|
|
2992
|
+
filter: "",
|
|
2760
2993
|
cursor: null,
|
|
2761
2994
|
html: null,
|
|
2762
|
-
react: null
|
|
2995
|
+
react: null,
|
|
2996
|
+
vue: null
|
|
2763
2997
|
}, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout), DefaultPickStyle);
|
|
2764
2998
|
const DefaultConnectAttribute = {
|
|
2765
2999
|
connectedType: "none",
|
|
@@ -2793,7 +3027,8 @@
|
|
|
2793
3027
|
globalCompositeOperation: "",
|
|
2794
3028
|
overflow: "hidden",
|
|
2795
3029
|
shadowPickMode: "graphic",
|
|
2796
|
-
keepStrokeScale: !1
|
|
3030
|
+
keepStrokeScale: !1,
|
|
3031
|
+
clipConfig: null
|
|
2797
3032
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
2798
3033
|
const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2799
3034
|
startAngle: 0,
|
|
@@ -2834,7 +3069,8 @@
|
|
|
2834
3069
|
justifyContent: "flex-start",
|
|
2835
3070
|
alignItems: "flex-start",
|
|
2836
3071
|
alignContent: "flex-start",
|
|
2837
|
-
baseOpacity: 1
|
|
3072
|
+
baseOpacity: 1,
|
|
3073
|
+
cornerType: "round"
|
|
2838
3074
|
});
|
|
2839
3075
|
const DefaultGlyphAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2840
3076
|
path: "",
|
|
@@ -2855,6 +3091,7 @@
|
|
|
2855
3091
|
const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2856
3092
|
path: new CustomPath2D(),
|
|
2857
3093
|
fillStrokeOrder: 1,
|
|
3094
|
+
clipRange: 1,
|
|
2858
3095
|
customPath: () => {
|
|
2859
3096
|
Logger.getInstance().warn("空函数");
|
|
2860
3097
|
}
|
|
@@ -2864,13 +3101,20 @@
|
|
|
2864
3101
|
cornerRadius: 0,
|
|
2865
3102
|
closePath: !0
|
|
2866
3103
|
});
|
|
3104
|
+
const DefaultStarAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
3105
|
+
width: 100,
|
|
3106
|
+
height: 100,
|
|
3107
|
+
spikes: 5,
|
|
3108
|
+
thickness: .5
|
|
3109
|
+
});
|
|
2867
3110
|
const DefaultRectAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2868
3111
|
width: 0,
|
|
2869
3112
|
height: 0,
|
|
2870
3113
|
x1: 0,
|
|
2871
3114
|
y1: 0,
|
|
2872
3115
|
strokeBoundsBuffer: 0,
|
|
2873
|
-
cornerRadius: 0
|
|
3116
|
+
cornerRadius: 0,
|
|
3117
|
+
cornerType: "round"
|
|
2874
3118
|
});
|
|
2875
3119
|
Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2876
3120
|
width: 0,
|
|
@@ -2878,19 +3122,24 @@
|
|
|
2878
3122
|
x1: 0,
|
|
2879
3123
|
y1: 0,
|
|
2880
3124
|
cornerRadius: 0,
|
|
2881
|
-
length: 0
|
|
3125
|
+
length: 0,
|
|
3126
|
+
cornerType: "round"
|
|
2882
3127
|
});
|
|
2883
3128
|
const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2884
3129
|
symbolType: "circle",
|
|
2885
3130
|
size: 10,
|
|
2886
|
-
keepDirIn3d: !0
|
|
3131
|
+
keepDirIn3d: !0,
|
|
3132
|
+
clipRange: 1
|
|
2887
3133
|
});
|
|
2888
3134
|
const DefaultTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), {
|
|
2889
3135
|
strokeBoundsBuffer: 0,
|
|
2890
3136
|
keepDirIn3d: !0
|
|
2891
3137
|
});
|
|
2892
3138
|
const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), {
|
|
3139
|
+
upgradeAttrs: null,
|
|
2893
3140
|
editable: !1,
|
|
3141
|
+
editOptions: null,
|
|
3142
|
+
ascentDescentMode: "actual",
|
|
2894
3143
|
width: 300,
|
|
2895
3144
|
height: 300,
|
|
2896
3145
|
ellipsis: !0,
|
|
@@ -2910,10 +3159,13 @@
|
|
|
2910
3159
|
repeatY: "no-repeat",
|
|
2911
3160
|
image: "",
|
|
2912
3161
|
width: 0,
|
|
2913
|
-
height: 0
|
|
3162
|
+
height: 0,
|
|
3163
|
+
maxWidth: 500,
|
|
3164
|
+
maxHeight: 500
|
|
2914
3165
|
}, DefaultAttribute), {
|
|
2915
3166
|
fill: !0,
|
|
2916
|
-
cornerRadius: 0
|
|
3167
|
+
cornerRadius: 0,
|
|
3168
|
+
cornerType: "round"
|
|
2917
3169
|
});
|
|
2918
3170
|
const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImageAttribute), {
|
|
2919
3171
|
backgroundShowMode: "never",
|
|
@@ -2947,6 +3199,7 @@
|
|
|
2947
3199
|
text: DefaultTextAttribute,
|
|
2948
3200
|
rect: DefaultRectAttribute,
|
|
2949
3201
|
polygon: DefaultPolygonAttribute,
|
|
3202
|
+
star: DefaultStarAttribute,
|
|
2950
3203
|
richtext: DefaultRichTextAttribute,
|
|
2951
3204
|
richtextIcon: DefaultRichTextIconAttribute,
|
|
2952
3205
|
image: DefaultImageAttribute,
|
|
@@ -2965,6 +3218,7 @@
|
|
|
2965
3218
|
text: Object.assign({}, defaultThemeObj.text),
|
|
2966
3219
|
rect: Object.assign({}, defaultThemeObj.rect),
|
|
2967
3220
|
polygon: Object.assign({}, defaultThemeObj.polygon),
|
|
3221
|
+
star: Object.assign({}, defaultThemeObj.star),
|
|
2968
3222
|
richtext: Object.assign({}, defaultThemeObj.richtext),
|
|
2969
3223
|
richtextIcon: Object.assign({}, defaultThemeObj.richtextIcon),
|
|
2970
3224
|
image: Object.assign({}, defaultThemeObj.image),
|
|
@@ -3444,7 +3698,7 @@
|
|
|
3444
3698
|
}
|
|
3445
3699
|
_composedDetailPath(params) {
|
|
3446
3700
|
if (params && params.graphic) {
|
|
3447
|
-
const g =
|
|
3701
|
+
const g = params.graphic;
|
|
3448
3702
|
if (g.stage) {
|
|
3449
3703
|
const path = g.stage.eventSystem.manager.propagationPath(g);
|
|
3450
3704
|
this.detailPath.push(path), this._composedDetailPath(params.params);
|
|
@@ -3593,8 +3847,26 @@
|
|
|
3593
3847
|
return (t *= 2) < 1 ? amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * -.5 : amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * .5 + 1;
|
|
3594
3848
|
};
|
|
3595
3849
|
}
|
|
3850
|
+
static registerFunc(name, func) {
|
|
3851
|
+
Easing[name] = func;
|
|
3852
|
+
}
|
|
3596
3853
|
}
|
|
3597
|
-
|
|
3854
|
+
function flicker(t, n) {
|
|
3855
|
+
const step = 1 / n;
|
|
3856
|
+
let flag = 1;
|
|
3857
|
+
for (; t > step;) t -= step, flag *= -1;
|
|
3858
|
+
const v = flag * t / step;
|
|
3859
|
+
return v > 0 ? v : 1 + v;
|
|
3860
|
+
}
|
|
3861
|
+
Easing.quadIn = Easing.getPowIn(2), Easing.quadOut = Easing.getPowOut(2), Easing.quadInOut = Easing.getPowInOut(2), Easing.cubicIn = Easing.getPowIn(3), Easing.cubicOut = Easing.getPowOut(3), Easing.cubicInOut = Easing.getPowInOut(3), Easing.quartIn = Easing.getPowIn(4), Easing.quartOut = Easing.getPowOut(4), Easing.quartInOut = Easing.getPowInOut(4), Easing.quintIn = Easing.getPowIn(5), Easing.quintOut = Easing.getPowOut(5), Easing.quintInOut = Easing.getPowInOut(5), Easing.backIn = Easing.getBackIn(1.7), Easing.backOut = Easing.getBackOut(1.7), Easing.backInOut = Easing.getBackInOut(1.7), Easing.elasticIn = Easing.getElasticIn(1, .3), Easing.elasticOut = Easing.getElasticOut(1, .3), Easing.elasticInOut = Easing.getElasticInOut(1, .3 * 1.5), Easing.easeInOutQuad = t => (t /= .5) < 1 ? .5 * Math.pow(t, 2) : -.5 * ((t -= 2) * t - 2), Easing.easeOutElastic = x => {
|
|
3862
|
+
const c4 = 2 * Math.PI / 3;
|
|
3863
|
+
return 0 === x ? 0 : 1 === x ? 1 : Math.pow(2, -10 * x) * Math.sin((10 * x - .75) * c4) + 1;
|
|
3864
|
+
}, Easing.easeInOutElastic = x => {
|
|
3865
|
+
const c5 = 2 * Math.PI / 4.5;
|
|
3866
|
+
return 0 === x ? 0 : 1 === x ? 1 : x < .5 ? -Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1;
|
|
3867
|
+
};
|
|
3868
|
+
for (let i = 0; i < 10; i++) Easing[`flicker${i}`] = t => flicker(t, i);
|
|
3869
|
+
for (let i = 2; i < 10; i++) Easing[`aIn${i}`] = t => i * t * t + (1 - i) * t;
|
|
3598
3870
|
|
|
3599
3871
|
class DefaultTimeline {
|
|
3600
3872
|
constructor() {
|
|
@@ -3673,7 +3945,7 @@
|
|
|
3673
3945
|
let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Generator.GenAutoIncrementId();
|
|
3674
3946
|
let timeline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultTimeline;
|
|
3675
3947
|
let slience = arguments.length > 2 ? arguments[2] : undefined;
|
|
3676
|
-
this.id = id, this.timeline = timeline, this.status = AnimateStatus.INITIAL, this.tailAnimate = new SubAnimate(this), this.subAnimates = [this.tailAnimate], this.timeScale = 1, this.rawPosition = -1, this._startTime = 0, this._duringTime = 0, this.timeline.addAnimate(this), this.slience = slience;
|
|
3948
|
+
this.id = id, this.timeline = timeline || defaultTimeline, this.status = AnimateStatus.INITIAL, this.tailAnimate = new SubAnimate(this), this.subAnimates = [this.tailAnimate], this.timeScale = 1, this.rawPosition = -1, this._startTime = 0, this._duringTime = 0, this.timeline.addAnimate(this), this.slience = slience;
|
|
3677
3949
|
}
|
|
3678
3950
|
setTimeline(timeline) {
|
|
3679
3951
|
timeline !== this.timeline && (this.timeline.removeAnimate(this, !1), timeline.addAnimate(this));
|
|
@@ -3869,7 +4141,7 @@
|
|
|
3869
4141
|
(null == duration || duration < 0) && (duration = 0);
|
|
3870
4142
|
const easingFunc = "string" == typeof easing ? Easing[easing] : easing,
|
|
3871
4143
|
step = this._addStep(duration, null, easingFunc);
|
|
3872
|
-
return step.type = AnimateStepType.to, this._appendProps(props, step, !!params && params.tempProps), step.propKeys || (step.propKeys = Object.keys(step.props)), params && params.noPreventAttrs || this.target.animates.forEach(a => {
|
|
4144
|
+
return step.type = AnimateStepType.to, this._appendProps(props, step, !!params && params.tempProps), step.propKeys || (step.propKeys = Object.keys(step.props)), params && params.noPreventAttrs || this.target.animates && this.target.animates.forEach(a => {
|
|
3873
4145
|
a.id !== this.animate.id && a.preventAttrs(step.propKeys);
|
|
3874
4146
|
}), this;
|
|
3875
4147
|
}
|
|
@@ -4248,697 +4520,713 @@
|
|
|
4248
4520
|
}
|
|
4249
4521
|
ResourceLoader.cache = new Map(), ResourceLoader.isLoading = !1, ResourceLoader.toLoadAueue = [], ResourceLoader.onLoadSuccessCb = [];
|
|
4250
4522
|
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
point = new Point();
|
|
4258
|
-
const NOWORK_ANIMATE_ATTR = {
|
|
4259
|
-
strokeSeg: 1,
|
|
4260
|
-
boundsPadding: 2,
|
|
4261
|
-
pickMode: 1,
|
|
4262
|
-
boundsMode: 1,
|
|
4263
|
-
customPickShape: 1,
|
|
4264
|
-
pickable: 1,
|
|
4265
|
-
childrenPickable: 1,
|
|
4266
|
-
visible: 1,
|
|
4267
|
-
zIndex: 1,
|
|
4268
|
-
layout: 1,
|
|
4269
|
-
keepDirIn3d: 1,
|
|
4270
|
-
globalZIndex: 1,
|
|
4271
|
-
outerBorder: 1,
|
|
4272
|
-
innerBorder: 1,
|
|
4273
|
-
lineDash: 1,
|
|
4274
|
-
lineCap: 1,
|
|
4275
|
-
lineJoin: 1,
|
|
4276
|
-
miterLimit: 2,
|
|
4277
|
-
strokeBoundsBuffer: 2,
|
|
4278
|
-
scaleCenter: 1,
|
|
4279
|
-
anchor: 1,
|
|
4280
|
-
anchor3d: 1,
|
|
4281
|
-
postMatrix: 1,
|
|
4282
|
-
backgroundMode: 2,
|
|
4283
|
-
background: 1,
|
|
4284
|
-
texture: 1,
|
|
4285
|
-
cursor: 1,
|
|
4286
|
-
html: 1
|
|
4287
|
-
};
|
|
4288
|
-
class Graphic extends Node {
|
|
4289
|
-
static mixin(source) {
|
|
4290
|
-
const keys = Object.keys(source);
|
|
4291
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
4292
|
-
const propertyName = keys[i];
|
|
4293
|
-
Object.defineProperty(Graphic.prototype, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));
|
|
4294
|
-
}
|
|
4523
|
+
class BaseSymbol {
|
|
4524
|
+
bounds(size, bounds) {
|
|
4525
|
+
if (isNumber$1(size)) {
|
|
4526
|
+
const halfS = size / 2;
|
|
4527
|
+
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
4528
|
+
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
4295
4529
|
}
|
|
4296
|
-
|
|
4297
|
-
return
|
|
4530
|
+
parseSize(size) {
|
|
4531
|
+
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
4298
4532
|
}
|
|
4299
|
-
|
|
4300
|
-
|
|
4533
|
+
}
|
|
4534
|
+
|
|
4535
|
+
function circle(ctx, r, x, y, z) {
|
|
4536
|
+
return z ? ctx.arc(x, y, r, 0, tau, !1, z) : ctx.arc(x, y, r, 0, tau), !1;
|
|
4537
|
+
}
|
|
4538
|
+
class CircleSymbol extends BaseSymbol {
|
|
4539
|
+
constructor() {
|
|
4540
|
+
super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
|
|
4301
4541
|
}
|
|
4302
|
-
|
|
4303
|
-
return this.
|
|
4542
|
+
draw(ctx, size, x, y, z) {
|
|
4543
|
+
return circle(ctx, this.parseSize(size) / 2, x, y, z);
|
|
4304
4544
|
}
|
|
4305
|
-
|
|
4306
|
-
return this.
|
|
4545
|
+
drawOffset(ctx, size, x, y, offset, z) {
|
|
4546
|
+
return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
4307
4547
|
}
|
|
4308
|
-
|
|
4309
|
-
|
|
4548
|
+
drawToSvgPath(size, x, y, z) {
|
|
4549
|
+
const r = this.parseSize(size) / 2;
|
|
4550
|
+
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
4310
4551
|
}
|
|
4552
|
+
}
|
|
4553
|
+
var circle$1 = new CircleSymbol();
|
|
4554
|
+
|
|
4555
|
+
function cross(ctx, r, x, y, z) {
|
|
4556
|
+
return ctx.moveTo(-3 * r + x, -r + y, z), ctx.lineTo(-r + x, -r + y, z), ctx.lineTo(-r + x, -3 * r + y, z), ctx.lineTo(r + x, -3 * r + y, z), ctx.lineTo(r + x, -r + y, z), ctx.lineTo(3 * r + x, -r + y, z), ctx.lineTo(3 * r + x, r + y, z), ctx.lineTo(r + x, r + y, z), ctx.lineTo(r + x, 3 * r + y, z), ctx.lineTo(-r + x, 3 * r + y, z), ctx.lineTo(-r + x, r + y, z), ctx.lineTo(-3 * r + x, r + y, z), ctx.closePath(), !0;
|
|
4557
|
+
}
|
|
4558
|
+
function crossOffset(ctx, r, x, y, offset, z) {
|
|
4559
|
+
return ctx.moveTo(-3 * r + x - offset, -r + y - offset, z), ctx.lineTo(-r + x - offset, -r + y - offset, z), ctx.lineTo(-r + x - offset, -3 * r + y - offset, z), ctx.lineTo(r + x + offset, -3 * r + y - offset, z), ctx.lineTo(r + x + offset, -r + y - offset, z), ctx.lineTo(3 * r + x + offset, -r + y - offset, z), ctx.lineTo(3 * r + x + offset, r + y + offset, z), ctx.lineTo(r + x + offset, r + y + offset, z), ctx.lineTo(r + x + offset, 3 * r + y + offset, z), ctx.lineTo(-r + x - offset, 3 * r + y + offset, z), ctx.lineTo(-r + x - offset, r + y + offset, z), ctx.lineTo(-3 * r + x - offset, r + y + offset, z), ctx.closePath(), !0;
|
|
4560
|
+
}
|
|
4561
|
+
class CrossSymbol extends BaseSymbol {
|
|
4311
4562
|
constructor() {
|
|
4312
|
-
|
|
4313
|
-
var _a;
|
|
4314
|
-
super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
|
|
4563
|
+
super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
|
|
4315
4564
|
}
|
|
4316
|
-
|
|
4317
|
-
|
|
4565
|
+
draw(ctx, size, x, y, z) {
|
|
4566
|
+
return cross(ctx, this.parseSize(size) / 6, x, y, z);
|
|
4318
4567
|
}
|
|
4319
|
-
|
|
4320
|
-
this.
|
|
4568
|
+
drawOffset(ctx, size, x, y, offset, z) {
|
|
4569
|
+
return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
|
|
4321
4570
|
}
|
|
4322
|
-
|
|
4323
|
-
|
|
4571
|
+
}
|
|
4572
|
+
var cross$1 = new CrossSymbol();
|
|
4573
|
+
|
|
4574
|
+
function diamond(ctx, r, x, y, z) {
|
|
4575
|
+
return ctx.moveTo(x, y - r, z), ctx.lineTo(r + x, y, z), ctx.lineTo(x, y + r, z), ctx.lineTo(x - r, y, z), ctx.closePath(), !0;
|
|
4576
|
+
}
|
|
4577
|
+
class DiamondSymbol extends BaseSymbol {
|
|
4578
|
+
constructor() {
|
|
4579
|
+
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
4324
4580
|
}
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
var _a, _b;
|
|
4328
|
-
const {
|
|
4329
|
-
dx = attr.dx,
|
|
4330
|
-
dy = attr.dy
|
|
4331
|
-
} = this.attribute;
|
|
4332
|
-
if (includeScroll && this.parent) {
|
|
4333
|
-
const attribute = this.parent.attribute;
|
|
4334
|
-
point.x = dx + (null !== (_a = attribute.scrollX) && void 0 !== _a ? _a : 0), point.y = dy + (null !== (_b = attribute.scrollY) && void 0 !== _b ? _b : 0);
|
|
4335
|
-
} else point.x = dx, point.y = dy;
|
|
4336
|
-
return point;
|
|
4581
|
+
draw(ctx, size, x, y, z) {
|
|
4582
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
4337
4583
|
}
|
|
4338
|
-
|
|
4339
|
-
this.
|
|
4584
|
+
drawFitDir(ctx, size, x, y, z) {
|
|
4585
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
4340
4586
|
}
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
|
|
4344
|
-
application.graphicService.beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
|
|
4345
|
-
const bounds = this.doUpdateAABBBounds(full);
|
|
4346
|
-
return application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0), bounds;
|
|
4587
|
+
drawOffset(ctx, size, x, y, offset, z) {
|
|
4588
|
+
return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
4347
4589
|
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4590
|
+
}
|
|
4591
|
+
var diamond$1 = new DiamondSymbol();
|
|
4592
|
+
|
|
4593
|
+
function square(ctx, r, x, y) {
|
|
4594
|
+
const wh = 2 * r;
|
|
4595
|
+
return ctx.rect(x - r, y - r, wh, wh), !1;
|
|
4596
|
+
}
|
|
4597
|
+
class SquareSymbol extends BaseSymbol {
|
|
4598
|
+
constructor() {
|
|
4599
|
+
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
4352
4600
|
}
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
const b = this.shadowRoot.AABBBounds.clone();
|
|
4356
|
-
bounds.union(b);
|
|
4357
|
-
}
|
|
4601
|
+
draw(ctx, size, x, y) {
|
|
4602
|
+
return square(ctx, this.parseSize(size) / 2, x, y);
|
|
4358
4603
|
}
|
|
4359
|
-
|
|
4360
|
-
return this.
|
|
4604
|
+
drawOffset(ctx, size, x, y, offset) {
|
|
4605
|
+
return square(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
4361
4606
|
}
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
return paddingArray && bounds.expand(paddingArray), this.clearUpdateBoundTag(), bounds;
|
|
4607
|
+
}
|
|
4608
|
+
var square$1 = new SquareSymbol();
|
|
4609
|
+
|
|
4610
|
+
function trianglUpOffset(ctx, r, x, y) {
|
|
4611
|
+
let offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
4612
|
+
return ctx.moveTo(x + r + 2 * offset, r + y + offset), ctx.lineTo(x - r - 2 * offset, r + y + offset), ctx.lineTo(x, y - r - 2 * offset), ctx.closePath(), !0;
|
|
4613
|
+
}
|
|
4614
|
+
class TriangleUpSymbol extends BaseSymbol {
|
|
4615
|
+
constructor() {
|
|
4616
|
+
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
4373
4617
|
}
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
if (!path) return !1;
|
|
4377
|
-
const boundsContext = new BoundsContext(aabbBounds);
|
|
4378
|
-
return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
|
|
4618
|
+
draw(ctx, size, x, y) {
|
|
4619
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
4379
4620
|
}
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
return this._globalAABBBounds ? this._globalAABBBounds.setValue(b.x1, b.y1, b.x2, b.y2) : this._globalAABBBounds = b.clone(), this._globalAABBBounds.empty() || this.parent && this._globalAABBBounds.transformWithMatrix(this.parent.globalTransMatrix), this._globalAABBBounds;
|
|
4621
|
+
drawOffset(ctx, size, x, y, offset) {
|
|
4622
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
4383
4623
|
}
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
} else this._globalTransMatrix = this.parent ? this.parent.globalTransMatrix.clone() : this.transMatrix.clone();
|
|
4391
|
-
return this.shouldUpdateGlobalMatrix() && this.doUpdateGlobalMatrix(), this._globalTransMatrix;
|
|
4624
|
+
}
|
|
4625
|
+
var triangleUp = new TriangleUpSymbol();
|
|
4626
|
+
|
|
4627
|
+
class TriangleSymbol extends TriangleUpSymbol {
|
|
4628
|
+
constructor() {
|
|
4629
|
+
super(...arguments), this.type = "triangle";
|
|
4392
4630
|
}
|
|
4393
|
-
|
|
4394
|
-
|
|
4631
|
+
}
|
|
4632
|
+
var triangle = new TriangleSymbol();
|
|
4633
|
+
|
|
4634
|
+
const kr = Math.sin(Math.PI / 10) / Math.sin(7 * Math.PI / 10),
|
|
4635
|
+
kx = Math.sin(tau / 10) * kr,
|
|
4636
|
+
ky = -Math.cos(tau / 10) * kr;
|
|
4637
|
+
function star(ctx, r, transX, transY) {
|
|
4638
|
+
const x = kx * r,
|
|
4639
|
+
y = ky * r;
|
|
4640
|
+
ctx.moveTo(transX, -r + transY), ctx.lineTo(x + transX, y + transY);
|
|
4641
|
+
for (let i = 1; i < 5; ++i) {
|
|
4642
|
+
const a = tau * i / 5,
|
|
4643
|
+
c = Math.cos(a),
|
|
4644
|
+
s = Math.sin(a);
|
|
4645
|
+
ctx.lineTo(s * r + transX, -c * r + transY), ctx.lineTo(c * x - s * y + transX, s * x + c * y + transY);
|
|
4646
|
+
}
|
|
4647
|
+
return ctx.closePath(), !0;
|
|
4648
|
+
}
|
|
4649
|
+
class StarSymbol extends BaseSymbol {
|
|
4650
|
+
constructor() {
|
|
4651
|
+
super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
|
|
4395
4652
|
}
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
return this._transMatrix || (this._transMatrix = new Matrix()), this.shouldUpdateLocalMatrix() && (this.doUpdateLocalMatrix(), clearTag && this.clearUpdateLocalPositionTag()), this._transMatrix;
|
|
4653
|
+
draw(ctx, size, transX, transY) {
|
|
4654
|
+
return star(ctx, this.parseSize(size) / 2, transX, transY);
|
|
4399
4655
|
}
|
|
4400
|
-
|
|
4401
|
-
return
|
|
4656
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4657
|
+
return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
4402
4658
|
}
|
|
4403
|
-
|
|
4404
|
-
|
|
4659
|
+
}
|
|
4660
|
+
var star$1 = new StarSymbol();
|
|
4661
|
+
|
|
4662
|
+
const sqrt3$1 = sqrt(3);
|
|
4663
|
+
function arrow(ctx, r, transX, transY) {
|
|
4664
|
+
const triangleH = r,
|
|
4665
|
+
trangleBottomSide = triangleH / sqrt3$1,
|
|
4666
|
+
rectW = trangleBottomSide / 5,
|
|
4667
|
+
rectH = r;
|
|
4668
|
+
return ctx.moveTo(0 + transX, -triangleH + transY), ctx.lineTo(trangleBottomSide / 2 + transX, transY), ctx.lineTo(rectW / 2 + transX, transY), ctx.lineTo(rectW / 2 + transX, rectH + transY), ctx.lineTo(-rectW / 2 + transX, rectH + transY), ctx.lineTo(-rectW / 2 + transX, transY), ctx.lineTo(-trangleBottomSide / 2 + transX, transY), ctx.closePath(), !0;
|
|
4669
|
+
}
|
|
4670
|
+
class ArrowSymbol extends BaseSymbol {
|
|
4671
|
+
constructor() {
|
|
4672
|
+
super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
|
|
4405
4673
|
}
|
|
4406
|
-
|
|
4407
|
-
return
|
|
4674
|
+
draw(ctx, size, transX, transY) {
|
|
4675
|
+
return arrow(ctx, this.parseSize(size) / 2, transX, transY);
|
|
4408
4676
|
}
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
const attribute = this.attribute;
|
|
4412
|
-
return Number.isFinite((null !== (_a = attribute.x) && void 0 !== _a ? _a : 0) + (null !== (_b = attribute.y) && void 0 !== _b ? _b : 0));
|
|
4677
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4678
|
+
return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
4413
4679
|
}
|
|
4414
|
-
|
|
4415
|
-
|
|
4680
|
+
}
|
|
4681
|
+
var arrow$1 = new ArrowSymbol();
|
|
4682
|
+
|
|
4683
|
+
function wedge(ctx, r, transX, transY) {
|
|
4684
|
+
const h = 2 * r;
|
|
4685
|
+
return ctx.moveTo(transX, -r + transY), ctx.lineTo(h / 3 / 2 + transX, r + transY), ctx.lineTo(-h / 3 / 2 + transX, r + transY), ctx.closePath(), !0;
|
|
4686
|
+
}
|
|
4687
|
+
class WedgeSymbol extends BaseSymbol {
|
|
4688
|
+
constructor() {
|
|
4689
|
+
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
4416
4690
|
}
|
|
4417
|
-
|
|
4418
|
-
return
|
|
4691
|
+
draw(ctx, size, transX, transY) {
|
|
4692
|
+
return wedge(ctx, this.parseSize(size) / 2, transX, transY);
|
|
4419
4693
|
}
|
|
4420
|
-
|
|
4421
|
-
this.
|
|
4694
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4695
|
+
return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
4422
4696
|
}
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
});
|
|
4697
|
+
}
|
|
4698
|
+
var wedge$1 = new WedgeSymbol();
|
|
4699
|
+
|
|
4700
|
+
function stroke(ctx, r, transX, transY) {
|
|
4701
|
+
return ctx.moveTo(-r + transX, transY), ctx.lineTo(transX, r + transY), !1;
|
|
4702
|
+
}
|
|
4703
|
+
class StrokeSymbol extends BaseSymbol {
|
|
4704
|
+
constructor() {
|
|
4705
|
+
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
4433
4706
|
}
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
let context = arguments.length > 2 ? arguments[2] : undefined;
|
|
4437
|
-
(params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context);
|
|
4707
|
+
draw(ctx, size, transX, transY) {
|
|
4708
|
+
return stroke(ctx, this.parseSize(size) / 2, transX, transY);
|
|
4438
4709
|
}
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
let context = arguments.length > 2 ? arguments[2] : undefined;
|
|
4442
|
-
const keys = Object.keys(params);
|
|
4443
|
-
for (let i = 0; i < keys.length; i++) {
|
|
4444
|
-
const key = keys[i];
|
|
4445
|
-
this.attribute[key] = params[key];
|
|
4446
|
-
}
|
|
4447
|
-
this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTags(keys) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context);
|
|
4710
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4711
|
+
return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
4448
4712
|
}
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4713
|
+
}
|
|
4714
|
+
var stroke$1 = new StrokeSymbol();
|
|
4715
|
+
|
|
4716
|
+
const c = -.5,
|
|
4717
|
+
s = sqrt(3) / 2,
|
|
4718
|
+
k = 1 / sqrt(12);
|
|
4719
|
+
function wye(ctx, r, transX, transY) {
|
|
4720
|
+
const x0 = r / 2,
|
|
4721
|
+
y0 = r * k,
|
|
4722
|
+
x1 = x0,
|
|
4723
|
+
y1 = r * k + r,
|
|
4724
|
+
x2 = -x1,
|
|
4725
|
+
y2 = y1;
|
|
4726
|
+
return ctx.moveTo(x0 + transX, y0 + transY), ctx.lineTo(x1 + transX, y1 + transY), ctx.lineTo(x2 + transX, y2 + transY), ctx.lineTo(c * x0 - s * y0 + transX, s * x0 + c * y0 + transY), ctx.lineTo(c * x1 - s * y1 + transX, s * x1 + c * y1 + transY), ctx.lineTo(c * x2 - s * y2 + transX, s * x2 + c * y2 + transY), ctx.lineTo(c * x0 + s * y0 + transX, c * y0 - s * x0 + transY), ctx.lineTo(c * x1 + s * y1 + transX, c * y1 - s * x1 + transY), ctx.lineTo(c * x2 + s * y2 + transX, c * y2 - s * x2 + transY), ctx.closePath(), !1;
|
|
4727
|
+
}
|
|
4728
|
+
class WyeSymbol extends BaseSymbol {
|
|
4729
|
+
constructor() {
|
|
4730
|
+
super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
|
|
4455
4731
|
}
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
for (let i = 0; i < k.length; i++) {
|
|
4459
|
-
const attrKey = k[i];
|
|
4460
|
-
if (-1 !== keys.indexOf(attrKey)) return !0;
|
|
4461
|
-
}
|
|
4462
|
-
return !1;
|
|
4732
|
+
draw(ctx, size, transX, transY) {
|
|
4733
|
+
return wye(ctx, this.parseSize(size) / 2, transX, transY);
|
|
4463
4734
|
}
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
for (let i = 0; i < k.length; i++) {
|
|
4467
|
-
if (key === k[i]) return !0;
|
|
4468
|
-
}
|
|
4469
|
-
return !1;
|
|
4735
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4736
|
+
return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
4470
4737
|
}
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4738
|
+
}
|
|
4739
|
+
var wye$1 = new WyeSymbol();
|
|
4740
|
+
|
|
4741
|
+
function trianglLeftOffset(ctx, r, x, y, offset) {
|
|
4742
|
+
return ctx.moveTo(-r + x - 2 * offset, y), ctx.lineTo(r + x + offset, r + y + 2 * offset), ctx.lineTo(r + x + offset, y - r - 2 * offset), ctx.closePath(), !0;
|
|
4743
|
+
}
|
|
4744
|
+
class TriangleLeftSymbol extends BaseSymbol {
|
|
4745
|
+
constructor() {
|
|
4746
|
+
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
4476
4747
|
}
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
if (0 === x && 0 === y) return this;
|
|
4480
|
-
const context = {
|
|
4481
|
-
type: AttributeUpdateType.TRANSLATE
|
|
4482
|
-
},
|
|
4483
|
-
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
4484
|
-
x: x,
|
|
4485
|
-
y: y
|
|
4486
|
-
}, this.attribute, tempConstantXYKey, context);
|
|
4487
|
-
params && (x = params.x, y = params.y, delete params.x, delete params.y, this._setAttributes(params));
|
|
4488
|
-
const attribute = this.attribute,
|
|
4489
|
-
postMatrix = attribute.postMatrix;
|
|
4490
|
-
return postMatrix ? application.transformUtil.fromMatrix(postMatrix, postMatrix).translate(x, y) : (attribute.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : DefaultTransform.x) + x, attribute.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : DefaultTransform.y) + y), this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this;
|
|
4748
|
+
draw(ctx, size, x, y) {
|
|
4749
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
|
|
4491
4750
|
}
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
if (attribute.x === x && attribute.y === y) return this;
|
|
4495
|
-
const context = {
|
|
4496
|
-
type: AttributeUpdateType.TRANSLATE_TO
|
|
4497
|
-
},
|
|
4498
|
-
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
4499
|
-
x: x,
|
|
4500
|
-
y: y
|
|
4501
|
-
}, this.attribute, tempConstantXYKey, context);
|
|
4502
|
-
return params ? (this._setAttributes(params, !1, context), this) : (attribute.x = x, attribute.y = y, this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this);
|
|
4751
|
+
drawOffset(ctx, size, x, y, offset) {
|
|
4752
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
4503
4753
|
}
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
}, this.attribute, tempConstantScaleXYKey, context);
|
|
4515
|
-
params && (scaleX = params.scaleX, scaleY = params.scaleY, delete params.scaleX, delete params.scaleY, this._setAttributes(params));
|
|
4516
|
-
const attribute = this.attribute;
|
|
4517
|
-
if (scaleCenter) {
|
|
4518
|
-
let {
|
|
4519
|
-
postMatrix: postMatrix
|
|
4520
|
-
} = this.attribute;
|
|
4521
|
-
postMatrix || (postMatrix = new Matrix(), attribute.postMatrix = postMatrix), application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter);
|
|
4522
|
-
} else attribute.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : DefaultTransform.scaleX) * scaleX, attribute.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : DefaultTransform.scaleY) * scaleY;
|
|
4523
|
-
return this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this;
|
|
4754
|
+
}
|
|
4755
|
+
var triangleLeft = new TriangleLeftSymbol();
|
|
4756
|
+
|
|
4757
|
+
function trianglRightOffset(ctx, r, x, y) {
|
|
4758
|
+
let offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
4759
|
+
return ctx.moveTo(x - r - offset, r + y + 2 * offset), ctx.lineTo(r + x + 2 * offset, y), ctx.lineTo(x - r - offset, y - r - 2 * offset), ctx.closePath(), !0;
|
|
4760
|
+
}
|
|
4761
|
+
class TriangleRightSymbol extends BaseSymbol {
|
|
4762
|
+
constructor() {
|
|
4763
|
+
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
4524
4764
|
}
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
if (attribute.scaleX === scaleX && attribute.scaleY === scaleY) return this;
|
|
4528
|
-
const context = {
|
|
4529
|
-
type: AttributeUpdateType.SCALE_TO
|
|
4530
|
-
},
|
|
4531
|
-
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
4532
|
-
scaleX: scaleX,
|
|
4533
|
-
scaleY: scaleY
|
|
4534
|
-
}, this.attribute, tempConstantScaleXYKey, context);
|
|
4535
|
-
return params ? (this._setAttributes(params, !1, context), this) : (attribute.scaleX = scaleX, attribute.scaleY = scaleY, this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this);
|
|
4765
|
+
draw(ctx, size, x, y) {
|
|
4766
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
4536
4767
|
}
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
if (0 === angle) return this;
|
|
4540
|
-
const context = {
|
|
4541
|
-
type: AttributeUpdateType.ROTATE
|
|
4542
|
-
},
|
|
4543
|
-
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
4544
|
-
angle: angle,
|
|
4545
|
-
rotateCenter: rotateCenter
|
|
4546
|
-
}, this.attribute, tempConstantAngleKey, context);
|
|
4547
|
-
params && (delete params.angle, this._setAttributes(params, !1, context));
|
|
4548
|
-
const attribute = this.attribute;
|
|
4549
|
-
if (rotateCenter) {
|
|
4550
|
-
let {
|
|
4551
|
-
postMatrix: postMatrix
|
|
4552
|
-
} = this.attribute;
|
|
4553
|
-
postMatrix || (postMatrix = new Matrix(), attribute.postMatrix = postMatrix), application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter);
|
|
4554
|
-
} else attribute.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : DefaultTransform.angle) + angle;
|
|
4555
|
-
return this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this;
|
|
4768
|
+
drawOffset(ctx, size, x, y, offset) {
|
|
4769
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
4556
4770
|
}
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4771
|
+
}
|
|
4772
|
+
var triangleRight = new TriangleRightSymbol();
|
|
4773
|
+
|
|
4774
|
+
function trianglDownOffset(ctx, r, x, y) {
|
|
4775
|
+
let offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
4776
|
+
return ctx.moveTo(x - r - 2 * offset, y - r - offset), ctx.lineTo(x + r + 2 * offset, y - r - offset), ctx.lineTo(x, y + r + 2 * offset), ctx.closePath(), !0;
|
|
4777
|
+
}
|
|
4778
|
+
class TriangleDownSymbol extends BaseSymbol {
|
|
4779
|
+
constructor() {
|
|
4780
|
+
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
4565
4781
|
}
|
|
4566
|
-
|
|
4567
|
-
return this;
|
|
4782
|
+
draw(ctx, size, x, y) {
|
|
4783
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
4568
4784
|
}
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
const animate = new Animate(null == params ? void 0 : params.id, this.stage && this.stage.getTimeline(), null == params ? void 0 : params.slience);
|
|
4572
|
-
if (animate.bind(this), params) {
|
|
4573
|
-
const {
|
|
4574
|
-
onStart: onStart,
|
|
4575
|
-
onFrame: onFrame,
|
|
4576
|
-
onEnd: onEnd,
|
|
4577
|
-
onRemove: onRemove
|
|
4578
|
-
} = params;
|
|
4579
|
-
null != onStart && animate.onStart(onStart), null != onFrame && animate.onFrame(onFrame), null != onEnd && animate.onEnd(onEnd), null != onRemove && animate.onRemove(onRemove), animate.interpolateFunc = params.interpolate;
|
|
4580
|
-
}
|
|
4581
|
-
return this.animates.set(animate.id, animate), animate.onRemove(() => {
|
|
4582
|
-
this.animates.delete(animate.id);
|
|
4583
|
-
}), animate;
|
|
4785
|
+
drawOffset(ctx, size, x, y, offset) {
|
|
4786
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
4584
4787
|
}
|
|
4585
|
-
|
|
4586
|
-
|
|
4788
|
+
}
|
|
4789
|
+
var triangleDown = new TriangleDownSymbol();
|
|
4790
|
+
|
|
4791
|
+
const sqrt3 = sqrt(3);
|
|
4792
|
+
function thinTriangle(ctx, r, x, y) {
|
|
4793
|
+
const h = r * sqrt3;
|
|
4794
|
+
return ctx.moveTo(x, y + -h / 3 * 2), ctx.lineTo(r + x, y + h), ctx.lineTo(x - r, y + h), ctx.closePath(), !0;
|
|
4795
|
+
}
|
|
4796
|
+
class ThinTriangleSymbol extends BaseSymbol {
|
|
4797
|
+
constructor() {
|
|
4798
|
+
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
4587
4799
|
}
|
|
4588
|
-
|
|
4589
|
-
|
|
4800
|
+
draw(ctx, size, x, y) {
|
|
4801
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
|
|
4590
4802
|
}
|
|
4591
|
-
|
|
4592
|
-
return
|
|
4803
|
+
drawOffset(ctx, size, x, y, offset) {
|
|
4804
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
|
|
4593
4805
|
}
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4806
|
+
}
|
|
4807
|
+
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
4808
|
+
|
|
4809
|
+
function arrow2Left(ctx, r, transX, transY) {
|
|
4810
|
+
const r2 = 2 * r;
|
|
4811
|
+
return ctx.moveTo(r + transX, transY - r2), ctx.lineTo(transX - r, transY), ctx.lineTo(r + transX, r2 + transY), !0;
|
|
4812
|
+
}
|
|
4813
|
+
class Arrow2LeftSymbol extends BaseSymbol {
|
|
4814
|
+
constructor() {
|
|
4815
|
+
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
4597
4816
|
}
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
if (hasAnimation) {
|
|
4601
|
-
const keys = Object.keys(attrs),
|
|
4602
|
-
noWorkAttrs = this.getNoWorkAnimateAttr(),
|
|
4603
|
-
animateAttrs = {};
|
|
4604
|
-
let noAnimateAttrs;
|
|
4605
|
-
keys.forEach(key => {
|
|
4606
|
-
noWorkAttrs[key] ? (noAnimateAttrs || (noAnimateAttrs = {}), noAnimateAttrs[key] = attrs[key]) : animateAttrs[key] = isClear && void 0 === attrs[key] ? this.getDefaultAttribute(key) : attrs[key];
|
|
4607
|
-
});
|
|
4608
|
-
const animate = this.animate({
|
|
4609
|
-
slience: !0
|
|
4610
|
-
});
|
|
4611
|
-
animate.stateNames = stateNames, animate.to(animateAttrs, null !== (_b = null === (_a = this.stateAnimateConfig) || void 0 === _a ? void 0 : _a.duration) && void 0 !== _b ? _b : DefaultStateAnimateConfig.duration, null !== (_d = null === (_c = this.stateAnimateConfig) || void 0 === _c ? void 0 : _c.easing) && void 0 !== _d ? _d : DefaultStateAnimateConfig.easing), noAnimateAttrs && this.setAttributes(noAnimateAttrs, !1, {
|
|
4612
|
-
type: AttributeUpdateType.STATE
|
|
4613
|
-
});
|
|
4614
|
-
} else this.stopStateAnimates(), this.setAttributes(attrs, !1, {
|
|
4615
|
-
type: AttributeUpdateType.STATE
|
|
4616
|
-
});
|
|
4817
|
+
draw(ctx, size, transX, transY) {
|
|
4818
|
+
return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
|
|
4617
4819
|
}
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
this.normalAttrs ? (Object.keys(stateAttrs).forEach(key => {
|
|
4621
|
-
key in this.normalAttrs ? (newNormalAttrs[key] = this.normalAttrs[key], delete this.normalAttrs[key]) : newNormalAttrs[key] = this.getNormalAttribute(key);
|
|
4622
|
-
}), Object.keys(this.normalAttrs).forEach(key => {
|
|
4623
|
-
stateAttrs[key] = this.normalAttrs[key];
|
|
4624
|
-
})) : Object.keys(stateAttrs).forEach(key => {
|
|
4625
|
-
newNormalAttrs[key] = this.getNormalAttribute(key);
|
|
4626
|
-
}), this.normalAttrs = newNormalAttrs;
|
|
4820
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4821
|
+
return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
4627
4822
|
}
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4823
|
+
}
|
|
4824
|
+
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
4825
|
+
|
|
4826
|
+
function arrow2Right(ctx, r, transX, transY) {
|
|
4827
|
+
const r2 = 2 * r;
|
|
4828
|
+
return ctx.moveTo(transX - r, transY - r2), ctx.lineTo(transX + r, transY), ctx.lineTo(transX - r, r2 + transY), !0;
|
|
4829
|
+
}
|
|
4830
|
+
class Arrow2RightSymbol extends BaseSymbol {
|
|
4831
|
+
constructor() {
|
|
4832
|
+
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
4633
4833
|
}
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
return this.animates && this.animates.forEach(animate => {
|
|
4637
|
-
if (animate.stateNames) {
|
|
4638
|
-
const endProps = animate.getEndProps();
|
|
4639
|
-
has$1(endProps, key) && (value = endProps[key]);
|
|
4640
|
-
}
|
|
4641
|
-
}), value;
|
|
4834
|
+
draw(ctx, size, transX, transY) {
|
|
4835
|
+
return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
|
|
4642
4836
|
}
|
|
4643
|
-
|
|
4644
|
-
|
|
4837
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4838
|
+
return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
4645
4839
|
}
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4840
|
+
}
|
|
4841
|
+
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
4842
|
+
|
|
4843
|
+
function arrow2Up(ctx, r, transX, transY) {
|
|
4844
|
+
const r2 = 2 * r;
|
|
4845
|
+
return ctx.moveTo(transX - r2, transY + r), ctx.lineTo(transX, transY - r), ctx.lineTo(transX + r2, transY + r), !0;
|
|
4846
|
+
}
|
|
4847
|
+
class Arrow2UpSymbol extends BaseSymbol {
|
|
4848
|
+
constructor() {
|
|
4849
|
+
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
4651
4850
|
}
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
if ((this.currentStates ? this.currentStates.indexOf(stateName) : -1) < 0) {
|
|
4655
|
-
const nextStates = this.currentStates ? this.currentStates.slice() : [];
|
|
4656
|
-
nextStates.push(stateName), this.useStates(nextStates, hasAnimation);
|
|
4657
|
-
}
|
|
4658
|
-
}
|
|
4851
|
+
draw(ctx, size, transX, transY) {
|
|
4852
|
+
return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
|
|
4659
4853
|
}
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
if (this.currentStates && this.currentStates.includes(stateName) && (keepCurrentStates || 1 === this.currentStates.length)) return;
|
|
4663
|
-
const newStates = keepCurrentStates && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) ? this.currentStates.concat([stateName]) : [stateName];
|
|
4664
|
-
this.useStates(newStates, hasAnimation);
|
|
4854
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4855
|
+
return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
4665
4856
|
}
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4857
|
+
}
|
|
4858
|
+
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
4859
|
+
|
|
4860
|
+
function arrow2Down(ctx, r, transX, transY) {
|
|
4861
|
+
const r2 = 2 * r;
|
|
4862
|
+
return ctx.moveTo(transX - r2, transY - r), ctx.lineTo(transX, transY + r), ctx.lineTo(transX + r2, transY - r), !0;
|
|
4863
|
+
}
|
|
4864
|
+
class Arrow2DownSymbol extends BaseSymbol {
|
|
4865
|
+
constructor() {
|
|
4866
|
+
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
4676
4867
|
}
|
|
4677
|
-
|
|
4678
|
-
|
|
4868
|
+
draw(ctx, size, transX, transY) {
|
|
4869
|
+
return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
|
|
4679
4870
|
}
|
|
4680
|
-
|
|
4681
|
-
this.
|
|
4871
|
+
drawOffset(ctx, size, transX, transY, offset) {
|
|
4872
|
+
return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
4682
4873
|
}
|
|
4683
|
-
|
|
4684
|
-
|
|
4874
|
+
}
|
|
4875
|
+
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
4876
|
+
|
|
4877
|
+
function lineV(ctx, r, x, y, z) {
|
|
4878
|
+
return ctx.moveTo(x, y - r), ctx.lineTo(x, y + r), !0;
|
|
4879
|
+
}
|
|
4880
|
+
class LineVSymbol extends BaseSymbol {
|
|
4881
|
+
constructor() {
|
|
4882
|
+
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
4685
4883
|
}
|
|
4686
|
-
|
|
4687
|
-
return (this.
|
|
4884
|
+
draw(ctx, size, x, y, z) {
|
|
4885
|
+
return lineV(ctx, this.parseSize(size) / 2, x, y);
|
|
4688
4886
|
}
|
|
4689
|
-
|
|
4690
|
-
this.
|
|
4887
|
+
drawOffset(ctx, size, x, y, offset, z) {
|
|
4888
|
+
return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
4691
4889
|
}
|
|
4692
|
-
|
|
4693
|
-
|
|
4890
|
+
drawToSvgPath(size, x, y, z) {
|
|
4891
|
+
const r = this.parseSize(size) / 2;
|
|
4892
|
+
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
4694
4893
|
}
|
|
4695
|
-
|
|
4696
|
-
|
|
4894
|
+
}
|
|
4895
|
+
var lineV$1 = new LineVSymbol();
|
|
4896
|
+
|
|
4897
|
+
function lineH(ctx, r, x, y, z) {
|
|
4898
|
+
return ctx.moveTo(x - r, y), ctx.lineTo(x + r, y), !0;
|
|
4899
|
+
}
|
|
4900
|
+
class LineHSymbol extends BaseSymbol {
|
|
4901
|
+
constructor() {
|
|
4902
|
+
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
4697
4903
|
}
|
|
4698
|
-
|
|
4699
|
-
this.
|
|
4904
|
+
draw(ctx, size, x, y, z) {
|
|
4905
|
+
return lineH(ctx, this.parseSize(size) / 2, x, y);
|
|
4700
4906
|
}
|
|
4701
|
-
|
|
4702
|
-
this.
|
|
4907
|
+
drawOffset(ctx, size, x, y, offset, z) {
|
|
4908
|
+
return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
4703
4909
|
}
|
|
4704
|
-
|
|
4705
|
-
this.
|
|
4910
|
+
drawToSvgPath(size, x, y, z) {
|
|
4911
|
+
const r = this.parseSize(size) / 2;
|
|
4912
|
+
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
4706
4913
|
}
|
|
4707
|
-
|
|
4708
|
-
|
|
4914
|
+
}
|
|
4915
|
+
var lineH$1 = new LineHSymbol();
|
|
4916
|
+
|
|
4917
|
+
function close(ctx, r, x, y, z) {
|
|
4918
|
+
return ctx.moveTo(x - r, y - r), ctx.lineTo(x + r, y + r), ctx.moveTo(x + r, y - r), ctx.lineTo(x - r, y + r), !0;
|
|
4919
|
+
}
|
|
4920
|
+
class CloseSymbol extends BaseSymbol {
|
|
4921
|
+
constructor() {
|
|
4922
|
+
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
4709
4923
|
}
|
|
4710
|
-
|
|
4711
|
-
return
|
|
4924
|
+
draw(ctx, size, x, y, z) {
|
|
4925
|
+
return close(ctx, this.parseSize(size) / 2, x, y);
|
|
4712
4926
|
}
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
getBounds = () => {
|
|
4716
|
-
if (params.b) return params.b;
|
|
4717
|
-
const {
|
|
4718
|
-
scaleX: scaleX,
|
|
4719
|
-
scaleY: scaleY,
|
|
4720
|
-
angle: angle
|
|
4721
|
-
} = this.attribute;
|
|
4722
|
-
return tempBounds.copy(this._AABBBounds), this.setAttributes({
|
|
4723
|
-
scaleX: 1,
|
|
4724
|
-
scaleY: 1,
|
|
4725
|
-
angle: 0
|
|
4726
|
-
}), params.b = this.AABBBounds.clone(), this._AABBBounds.copy(tempBounds), this.setAttributes({
|
|
4727
|
-
scaleX: scaleX,
|
|
4728
|
-
scaleY: scaleY,
|
|
4729
|
-
angle: angle
|
|
4730
|
-
}), params.b;
|
|
4731
|
-
};
|
|
4732
|
-
if ("string" == typeof anchor[0]) {
|
|
4733
|
-
const ratio = parseFloat(anchor[0]) / 100,
|
|
4734
|
-
bounds = getBounds();
|
|
4735
|
-
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
4736
|
-
} else _anchor[0] = anchor[0];
|
|
4737
|
-
if ("string" == typeof anchor[1]) {
|
|
4738
|
-
const ratio = parseFloat(anchor[1]) / 100,
|
|
4739
|
-
bounds = getBounds();
|
|
4740
|
-
_anchor[1] = bounds.y1 + (bounds.y2 - bounds.y1) * ratio;
|
|
4741
|
-
} else _anchor[1] = anchor[1];
|
|
4742
|
-
return _anchor;
|
|
4927
|
+
drawOffset(ctx, size, x, y, offset, z) {
|
|
4928
|
+
return close(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
4743
4929
|
}
|
|
4744
|
-
|
|
4745
|
-
const
|
|
4746
|
-
|
|
4747
|
-
y = DefaultTransform.y,
|
|
4748
|
-
scaleX = DefaultTransform.scaleX,
|
|
4749
|
-
scaleY = DefaultTransform.scaleY,
|
|
4750
|
-
angle = DefaultTransform.angle,
|
|
4751
|
-
scaleCenter: scaleCenter,
|
|
4752
|
-
anchor: anchor,
|
|
4753
|
-
postMatrix: postMatrix
|
|
4754
|
-
} = this.attribute;
|
|
4755
|
-
let _anchor = [0, 0];
|
|
4756
|
-
const params = {};
|
|
4757
|
-
if (anchor && (_anchor = this.getAnchor(anchor, params)), !scaleCenter || 1 === scaleX && 1 === scaleY) normalTransform(this._transMatrix, this._transMatrix.reset(), x, y, scaleX, scaleY, angle, anchor && _anchor);else {
|
|
4758
|
-
const m = this._transMatrix;
|
|
4759
|
-
m.reset(), m.translate(_anchor[0], _anchor[1]), m.rotate(angle), m.translate(-_anchor[0], -_anchor[1]), m.translate(x, y), _anchor = this.getAnchor(scaleCenter, params), application.transformUtil.fromMatrix(m, m).scale(scaleX, scaleY, {
|
|
4760
|
-
x: _anchor[0],
|
|
4761
|
-
y: _anchor[1]
|
|
4762
|
-
});
|
|
4763
|
-
}
|
|
4764
|
-
const p = this.getOffsetXY(DefaultTransform);
|
|
4765
|
-
if (this._transMatrix.e += p.x, this._transMatrix.f += p.y, postMatrix) {
|
|
4766
|
-
const m1 = tempMatrix.setValue(postMatrix.a, postMatrix.b, postMatrix.c, postMatrix.d, postMatrix.e, postMatrix.f),
|
|
4767
|
-
m2 = this._transMatrix;
|
|
4768
|
-
m1.multiply(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f), m2.setValue(m1.a, m1.b, m1.c, m1.d, m1.e, m1.f);
|
|
4769
|
-
}
|
|
4930
|
+
drawToSvgPath(size, x, y, z) {
|
|
4931
|
+
const r = this.parseSize(size) / 2;
|
|
4932
|
+
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
4770
4933
|
}
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4934
|
+
}
|
|
4935
|
+
var close$1 = new CloseSymbol();
|
|
4936
|
+
|
|
4937
|
+
function rectSizeArray(ctx, size, x, y) {
|
|
4938
|
+
return ctx.rect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]), !1;
|
|
4939
|
+
}
|
|
4940
|
+
function rectSize(ctx, size, x, y) {
|
|
4941
|
+
const w = size,
|
|
4942
|
+
h = size / 2;
|
|
4943
|
+
return ctx.rect(x - w / 2, y - h / 2, w, h), !1;
|
|
4944
|
+
}
|
|
4945
|
+
class RectSymbol extends BaseSymbol {
|
|
4946
|
+
constructor() {
|
|
4947
|
+
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";
|
|
4948
|
+
}
|
|
4949
|
+
draw(ctx, size, x, y) {
|
|
4950
|
+
return isNumber$1(size) ? rectSize(ctx, size, x, y) : rectSizeArray(ctx, size, x, y);
|
|
4951
|
+
}
|
|
4952
|
+
drawWithClipRange(ctx, size, x, y, clipRange, z, cb) {
|
|
4953
|
+
isNumber$1(size) && (size = [size, size / 2]);
|
|
4954
|
+
const drawLength = 2 * (size[0] + size[1]) * clipRange,
|
|
4955
|
+
points = [{
|
|
4956
|
+
x: x + size[0] / 2,
|
|
4957
|
+
y: y - size[1] / 2
|
|
4958
|
+
}, {
|
|
4959
|
+
x: x + size[0] / 2,
|
|
4960
|
+
y: y + size[1] / 2
|
|
4961
|
+
}, {
|
|
4962
|
+
x: x - size[0] / 2,
|
|
4963
|
+
y: y + size[1] / 2
|
|
4964
|
+
}, {
|
|
4965
|
+
x: x - size[0] / 2,
|
|
4966
|
+
y: y - size[1] / 2
|
|
4967
|
+
}];
|
|
4968
|
+
let currLength = 0,
|
|
4969
|
+
lastP = points[3];
|
|
4970
|
+
ctx.moveTo(lastP.x, lastP.y);
|
|
4971
|
+
for (let i = 0; i < points.length; i++) {
|
|
4972
|
+
const p = points[i],
|
|
4973
|
+
len = Math.sqrt((p.x - lastP.x) * (p.x - lastP.x) + (p.y - lastP.y) * (p.y - lastP.y));
|
|
4974
|
+
if (currLength + len > drawLength) {
|
|
4975
|
+
const dx = (p.x - lastP.x) * (drawLength - currLength) / len,
|
|
4976
|
+
dy = (p.y - lastP.y) * (drawLength - currLength) / len;
|
|
4977
|
+
ctx.lineTo(lastP.x + dx, lastP.y + dy);
|
|
4978
|
+
break;
|
|
4979
|
+
}
|
|
4980
|
+
ctx.lineTo(p.x, p.y), lastP = p, currLength += len;
|
|
4779
4981
|
}
|
|
4982
|
+
return !1;
|
|
4780
4983
|
}
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4984
|
+
drawOffset(ctx, size, x, y, offset) {
|
|
4985
|
+
return isNumber$1(size) ? rectSize(ctx, size + 2 * offset, x, y) : rectSizeArray(ctx, [size[0] + 2 * offset, size[1] + 2 * offset], x, y);
|
|
4986
|
+
}
|
|
4987
|
+
}
|
|
4988
|
+
var rect = new RectSymbol();
|
|
4989
|
+
|
|
4990
|
+
const tempBounds$1 = new AABBBounds();
|
|
4991
|
+
class CustomSymbolClass {
|
|
4992
|
+
constructor(type, path) {
|
|
4993
|
+
let isSvg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
|
|
4994
|
+
this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
4995
|
+
}
|
|
4996
|
+
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
4997
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
4998
|
+
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
4999
|
+
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
5000
|
+
}
|
|
5001
|
+
draw(ctx, size, x, y, z, cb) {
|
|
5002
|
+
return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
5003
|
+
}
|
|
5004
|
+
parseSize(size) {
|
|
5005
|
+
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
5006
|
+
}
|
|
5007
|
+
drawWithClipRange(ctx, size, x, y, clipRange, z, cb) {
|
|
5008
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
5009
|
+
item.path.drawWithClipRange(ctx, size, x, y, clipRange), cb && cb(item.path, item.attribute);
|
|
5010
|
+
}), !1) : (this.path.drawWithClipRange(ctx, size, x, y, clipRange), !1);
|
|
5011
|
+
}
|
|
5012
|
+
bounds(size, bounds) {
|
|
5013
|
+
if (size = this.parseSize(size), this.isSvg) {
|
|
5014
|
+
if (!this.svgCache) return;
|
|
5015
|
+
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
5016
|
+
let {
|
|
5017
|
+
path: path
|
|
5018
|
+
} = _ref;
|
|
5019
|
+
tempBounds$1.x1 = path.bounds.x1 * size, tempBounds$1.y1 = path.bounds.y1 * size, tempBounds$1.x2 = path.bounds.x2 * size, tempBounds$1.y2 = path.bounds.y2 * size, bounds.union(tempBounds$1);
|
|
5020
|
+
});
|
|
4790
5021
|
}
|
|
5022
|
+
this.path.bounds && (bounds.x1 = this.path.bounds.x1 * size, bounds.y1 = this.path.bounds.y1 * size, bounds.x2 = this.path.bounds.x2 * size, bounds.y2 = this.path.bounds.y2 * size);
|
|
4791
5023
|
}
|
|
4792
|
-
|
|
4793
|
-
|
|
5024
|
+
}
|
|
5025
|
+
|
|
5026
|
+
const builtinSymbols = [circle$1, cross$1, diamond$1, square$1, thinTriangle$1, triangle, star$1, arrow$1, wedge$1, stroke$1, wye$1, triangleLeft, triangleRight, triangleUp, triangleDown, arrow2Left$1, arrow2Right$1, arrow2Up$1, arrow2Down$1, rect, lineV$1, lineH$1, close$1];
|
|
5027
|
+
const builtinSymbolsMap = {};
|
|
5028
|
+
builtinSymbols.forEach(symbol => {
|
|
5029
|
+
builtinSymbolsMap[symbol.type] = symbol;
|
|
5030
|
+
});
|
|
5031
|
+
const builtInSymbolStrMap = {
|
|
5032
|
+
arrowLeft: "M 0.25 -0.5 L -0.25 0 l 0.5 0.5",
|
|
5033
|
+
arrowRight: "M -0.25 -0.5 l 0.5 0.5 l -0.5 0.5",
|
|
5034
|
+
rectRound: "M 0.3 -0.5 C 0.41 -0.5 0.5 -0.41 0.5 -0.3 C 0.5 -0.3 0.5 0.3 0.5 0.3 C 0.5 0.41 0.41 0.5 0.3 0.5 C 0.3 0.5 -0.3 0.5 -0.3 0.5 C -0.41 0.5 -0.5 0.41 -0.5 0.3 C -0.5 0.3 -0.5 -0.3 -0.5 -0.3 C -0.5 -0.41 -0.41 -0.5 -0.3 -0.5 C -0.3 -0.5 0.3 -0.5 0.3 -0.5 Z",
|
|
5035
|
+
roundLine: "M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z"
|
|
5036
|
+
};
|
|
5037
|
+
|
|
5038
|
+
function getAllMatches(string, regex) {
|
|
5039
|
+
const matches = [];
|
|
5040
|
+
let match = regex.exec(string);
|
|
5041
|
+
for (; match;) {
|
|
5042
|
+
const allmatches = [];
|
|
5043
|
+
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
5044
|
+
const len = match.length;
|
|
5045
|
+
for (let index = 0; index < len; index++) allmatches.push(match[index]);
|
|
5046
|
+
matches.push(allmatches), match = regex.exec(string);
|
|
5047
|
+
}
|
|
5048
|
+
return matches;
|
|
5049
|
+
}
|
|
5050
|
+
|
|
5051
|
+
class XmlNode {
|
|
5052
|
+
constructor(tagname) {
|
|
5053
|
+
this.tagname = tagname, this.child = [], this[":@"] = {};
|
|
4794
5054
|
}
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
type: AttributeUpdateType.ANIMATE_END
|
|
5055
|
+
add(key, val) {
|
|
5056
|
+
"__proto__" === key && (key = "#__proto__"), this.child.push({
|
|
5057
|
+
[key]: val
|
|
4799
5058
|
});
|
|
4800
5059
|
}
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
}
|
|
4809
|
-
this.setAttributes(nextAttributes, !1, {
|
|
4810
|
-
type: AttributeUpdateType.ANIMATE_UPDATE,
|
|
4811
|
-
animationState: {
|
|
4812
|
-
ratio: ratio,
|
|
4813
|
-
end: end,
|
|
4814
|
-
step: step,
|
|
4815
|
-
isFirstFrameOfStep: subAnimate.getLastStep() !== step
|
|
4816
|
-
}
|
|
4817
|
-
}), this.stage && this.stage.renderNextFrame();
|
|
5060
|
+
addChild(node) {
|
|
5061
|
+
"__proto__" === node.tagname && (node.tagname = "#__proto__"), node[":@"] && Object.keys(node[":@"]).length > 0 ? this.child.push({
|
|
5062
|
+
[node.tagname]: node.child,
|
|
5063
|
+
":@": node[":@"]
|
|
5064
|
+
}) : this.child.push({
|
|
5065
|
+
[node.tagname]: node.child
|
|
5066
|
+
});
|
|
4818
5067
|
}
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
5068
|
+
}
|
|
5069
|
+
function findClosingIndex(xmlData, str, i, errMsg) {
|
|
5070
|
+
const closingIndex = xmlData.indexOf(str, i);
|
|
5071
|
+
if (-1 === closingIndex) throw new Error(errMsg);
|
|
5072
|
+
return closingIndex + str.length - 1;
|
|
5073
|
+
}
|
|
5074
|
+
function tagExpWithClosingIndex(xmlData, i) {
|
|
5075
|
+
let closingChar = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ">";
|
|
5076
|
+
let attrBoundary,
|
|
5077
|
+
tagExp = "";
|
|
5078
|
+
for (let index = i; index < xmlData.length; index++) {
|
|
5079
|
+
let ch = xmlData[index];
|
|
5080
|
+
if (attrBoundary) ch === attrBoundary && (attrBoundary = "");else if ('"' === ch || "'" === ch) attrBoundary = ch;else if (ch === closingChar[0]) {
|
|
5081
|
+
if (!closingChar[1]) return {
|
|
5082
|
+
data: tagExp,
|
|
5083
|
+
index: index
|
|
5084
|
+
};
|
|
5085
|
+
if (xmlData[index + 1] === closingChar[1]) return {
|
|
5086
|
+
data: tagExp,
|
|
5087
|
+
index: index
|
|
5088
|
+
};
|
|
5089
|
+
} else "\t" === ch && (ch = " ");
|
|
5090
|
+
tagExp += ch;
|
|
4831
5091
|
}
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
5092
|
+
}
|
|
5093
|
+
function readTagExp(xmlData, i, removeNSPrefix) {
|
|
5094
|
+
let closingChar = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ">";
|
|
5095
|
+
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
5096
|
+
if (!result) return;
|
|
5097
|
+
let tagExp = result.data;
|
|
5098
|
+
const closeIndex = result.index,
|
|
5099
|
+
separatorIndex = tagExp.search(/\s/);
|
|
5100
|
+
let tagName = tagExp,
|
|
5101
|
+
attrExpPresent = !0;
|
|
5102
|
+
-1 !== separatorIndex && (tagName = tagExp.substr(0, separatorIndex).replace(/\s\s*$/, ""), tagExp = tagExp.substr(separatorIndex + 1));
|
|
5103
|
+
const rawTagName = tagName;
|
|
5104
|
+
if (removeNSPrefix) {
|
|
5105
|
+
const colonIndex = tagName.indexOf(":");
|
|
5106
|
+
-1 !== colonIndex && (tagName = tagName.substr(colonIndex + 1), attrExpPresent = tagName !== result.data.substr(colonIndex + 1));
|
|
5107
|
+
}
|
|
5108
|
+
return {
|
|
5109
|
+
tagName: tagName,
|
|
5110
|
+
tagExp: tagExp,
|
|
5111
|
+
closeIndex: closeIndex,
|
|
5112
|
+
attrExpPresent: attrExpPresent,
|
|
5113
|
+
rawTagName: rawTagName
|
|
5114
|
+
};
|
|
5115
|
+
}
|
|
5116
|
+
const attrsRegx = new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm");
|
|
5117
|
+
class OrderedObjParser {
|
|
5118
|
+
constructor(options) {
|
|
5119
|
+
this.currentNode = null, this.options = options, this.tagsNodeStack = [], this.docTypeEntities = {};
|
|
5120
|
+
}
|
|
5121
|
+
addChild(currentNode, childNode, jPath) {
|
|
5122
|
+
const result = childNode.tagname;
|
|
5123
|
+
"string" == typeof result ? (childNode.tagname = result, currentNode.addChild(childNode)) : currentNode.addChild(childNode);
|
|
5124
|
+
}
|
|
5125
|
+
buildAttributesMap(attrStr, jPath, tagName) {
|
|
5126
|
+
const attrs = {};
|
|
5127
|
+
if (!attrStr) return;
|
|
5128
|
+
const matches = getAllMatches(attrStr, attrsRegx),
|
|
5129
|
+
len = matches.length;
|
|
5130
|
+
for (let i = 0; i < len; i++) {
|
|
5131
|
+
const attrName = matches[i][1],
|
|
5132
|
+
oldVal = matches[i][4],
|
|
5133
|
+
aName = attrName;
|
|
5134
|
+
attrName && (attrs[aName] = void 0 === oldVal || (isNaN(oldVal) ? oldVal : Number(oldVal)));
|
|
4849
5135
|
}
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
5136
|
+
return attrs;
|
|
5137
|
+
}
|
|
5138
|
+
parseXml(xmlData) {
|
|
5139
|
+
xmlData = xmlData.replace(/\r\n?/g, "\n");
|
|
5140
|
+
const xmlObj = new XmlNode("!xml");
|
|
5141
|
+
let currentNode = xmlObj,
|
|
5142
|
+
textData = "",
|
|
5143
|
+
jPath = "";
|
|
5144
|
+
for (let i = 0; i < xmlData.length; i++) {
|
|
5145
|
+
if ("<" === xmlData[i]) {
|
|
5146
|
+
if ("/" === xmlData[i + 1]) {
|
|
5147
|
+
const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed."),
|
|
5148
|
+
propIndex = jPath.lastIndexOf(".");
|
|
5149
|
+
jPath = jPath.substring(0, propIndex), currentNode = this.tagsNodeStack.pop(), currentNode && currentNode.child && textData && currentNode.child[currentNode.child.length - 1][":@"] && (currentNode.child[currentNode.child.length - 1][":@"].text = textData), textData = "", i = closeIndex;
|
|
5150
|
+
} else if ("?" === xmlData[i + 1]) {
|
|
5151
|
+
i = readTagExp(xmlData, i, !1, "?>").closeIndex + 1;
|
|
5152
|
+
} else if ("!--" === xmlData.substr(i + 1, 3)) {
|
|
5153
|
+
i = findClosingIndex(xmlData, "--\x3e", i + 4, "Comment is not closed.");
|
|
5154
|
+
} else {
|
|
5155
|
+
const result = readTagExp(xmlData, i, !1);
|
|
5156
|
+
let tagName = result.tagName,
|
|
5157
|
+
tagExp = result.tagExp;
|
|
5158
|
+
const attrExpPresent = result.attrExpPresent,
|
|
5159
|
+
closeIndex = result.closeIndex;
|
|
5160
|
+
if (tagName !== xmlObj.tagname && (jPath += jPath ? "." + tagName : tagName), tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
5161
|
+
"/" === tagName[tagName.length - 1] ? (tagName = tagName.substr(0, tagName.length - 1), jPath = jPath.substr(0, jPath.length - 1), tagExp = tagName) : tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
5162
|
+
const childNode = new XmlNode(tagName);
|
|
5163
|
+
tagName !== tagExp && attrExpPresent && (childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName)), this.addChild(currentNode, childNode, jPath), jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
5164
|
+
} else {
|
|
5165
|
+
const childNode = new XmlNode(tagName);
|
|
5166
|
+
this.tagsNodeStack.push(currentNode), tagName !== tagExp && attrExpPresent && (childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName)), this.addChild(currentNode, childNode, jPath), currentNode = childNode;
|
|
5167
|
+
}
|
|
5168
|
+
textData = "", i = closeIndex;
|
|
5169
|
+
}
|
|
5170
|
+
} else textData += xmlData[i];
|
|
4857
5171
|
}
|
|
4858
|
-
return
|
|
4859
|
-
}
|
|
4860
|
-
_interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {}
|
|
4861
|
-
getDefaultAttribute(name) {
|
|
4862
|
-
return this.getGraphicTheme()[name];
|
|
5172
|
+
return xmlObj.child;
|
|
4863
5173
|
}
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
5174
|
+
}
|
|
5175
|
+
|
|
5176
|
+
function prettify(node, options) {
|
|
5177
|
+
return compress(node);
|
|
5178
|
+
}
|
|
5179
|
+
function compress(arr, jPath) {
|
|
5180
|
+
const compressedObj = {};
|
|
5181
|
+
for (let i = 0; i < arr.length; i++) {
|
|
5182
|
+
const tagObj = arr[i],
|
|
5183
|
+
property = propName(tagObj);
|
|
5184
|
+
if (void 0 !== property && tagObj[property]) {
|
|
5185
|
+
const val = compress(tagObj[property]);
|
|
5186
|
+
isLeafTag(val);
|
|
5187
|
+
tagObj[":@"] && assignAttributes(val, tagObj[":@"]), void 0 !== compressedObj[property] && compressedObj.hasOwnProperty(property) ? (Array.isArray(compressedObj[property]) || (compressedObj[property] = [compressedObj[property]]), compressedObj[property].push(val)) : compressedObj[property] = val;
|
|
5188
|
+
}
|
|
4867
5189
|
}
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
5190
|
+
return compressedObj;
|
|
5191
|
+
}
|
|
5192
|
+
function propName(obj) {
|
|
5193
|
+
const keys = Object.keys(obj);
|
|
5194
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5195
|
+
const key = keys[i];
|
|
5196
|
+
if (":@" !== key) return key;
|
|
4871
5197
|
}
|
|
4872
|
-
|
|
4873
|
-
|
|
5198
|
+
}
|
|
5199
|
+
function assignAttributes(obj, attrMap, jpath) {
|
|
5200
|
+
if (attrMap) {
|
|
5201
|
+
const keys = Object.keys(attrMap),
|
|
5202
|
+
len = keys.length;
|
|
5203
|
+
for (let i = 0; i < len; i++) {
|
|
5204
|
+
const atrrName = keys[i];
|
|
5205
|
+
obj[atrrName] = attrMap[atrrName];
|
|
5206
|
+
}
|
|
4874
5207
|
}
|
|
4875
|
-
|
|
4876
|
-
|
|
5208
|
+
}
|
|
5209
|
+
function isLeafTag(obj) {
|
|
5210
|
+
return 0 === Object.keys(obj).length;
|
|
5211
|
+
}
|
|
5212
|
+
|
|
5213
|
+
class XMLParser {
|
|
5214
|
+
constructor(options) {
|
|
5215
|
+
this.options = Object.assign({}, XMLParser.defaultOptions, options);
|
|
4877
5216
|
}
|
|
4878
|
-
|
|
4879
|
-
return
|
|
4880
|
-
attribute: this.attribute,
|
|
4881
|
-
_uid: this._uid,
|
|
4882
|
-
type: this.type,
|
|
4883
|
-
name: this.name,
|
|
4884
|
-
children: this.children.map(item => item.toJson())
|
|
4885
|
-
};
|
|
5217
|
+
valid(xml) {
|
|
5218
|
+
return xml.startsWith("<");
|
|
4886
5219
|
}
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
let background = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
4892
|
-
if (!image || background && backgroundNotImage(image)) return;
|
|
4893
|
-
const url = image;
|
|
4894
|
-
this.resources || (this.resources = new Map());
|
|
4895
|
-
const cache = {
|
|
4896
|
-
data: "init",
|
|
4897
|
-
state: null
|
|
4898
|
-
};
|
|
4899
|
-
this.resources.set(url, cache), "string" == typeof image ? (cache.state = "loading", image.startsWith("<svg") ? (ResourceLoader.GetSvg(image, this), this.backgroundImg = this.backgroundImg || background) : (isValidUrl$1(image) || image.includes("/") || isBase64$1(image)) && (ResourceLoader.GetImage(image, this), this.backgroundImg = this.backgroundImg || background)) : isObject$1(image) ? (cache.state = "success", cache.data = image, this.backgroundImg = this.backgroundImg || background) : cache.state = "fail";
|
|
4900
|
-
}
|
|
4901
|
-
setShadowGraphic(graphic) {
|
|
4902
|
-
if (graphic) {
|
|
4903
|
-
this.attachShadow().add(graphic);
|
|
4904
|
-
} else this.detachShadow();
|
|
4905
|
-
}
|
|
4906
|
-
imageLoadSuccess(url, image, cb) {
|
|
4907
|
-
if (!this.resources) return;
|
|
4908
|
-
const res = this.resources.get(url);
|
|
4909
|
-
res && (res.state = "success", res.data = image, cb && cb(), this.addUpdateBoundTag(), this.stage && this.stage.renderNextFrame());
|
|
4910
|
-
}
|
|
4911
|
-
imageLoadFail(url, cb) {
|
|
4912
|
-
if (!this.resources) return;
|
|
4913
|
-
const res = this.resources.get(url);
|
|
4914
|
-
res && (res.state = "fail", cb && cb());
|
|
4915
|
-
}
|
|
4916
|
-
_stopAnimates(animates) {
|
|
4917
|
-
animates && animates.forEach(animate => {
|
|
4918
|
-
animate.stop();
|
|
4919
|
-
});
|
|
4920
|
-
}
|
|
4921
|
-
stopAnimates() {
|
|
4922
|
-
let stopChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
|
|
4923
|
-
this._stopAnimates(this.animates), this.shadowRoot && this.shadowRoot.stopAnimates(!0), this.isContainer && stopChildren && this.forEachChildren(c => {
|
|
4924
|
-
c.stopAnimates(stopChildren);
|
|
4925
|
-
});
|
|
4926
|
-
}
|
|
4927
|
-
release() {
|
|
4928
|
-
this.releaseStatus = "released", application.graphicService.onRelease(this);
|
|
4929
|
-
}
|
|
4930
|
-
_emitCustomEvent(type, context) {
|
|
4931
|
-
var _a, _b;
|
|
4932
|
-
if (this._events && type in this._events) {
|
|
4933
|
-
const changeEvent = new CustomEvent(type, context);
|
|
4934
|
-
changeEvent.bubbles = !1, changeEvent.manager = null === (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem) || void 0 === _b ? void 0 : _b.manager, this.dispatchEvent(changeEvent);
|
|
4935
|
-
}
|
|
5220
|
+
parse(xmlData) {
|
|
5221
|
+
if (!this.valid) return !1;
|
|
5222
|
+
const orderedResult = new OrderedObjParser(this.options).parseXml(xmlData);
|
|
5223
|
+
return prettify(orderedResult, this.options);
|
|
4936
5224
|
}
|
|
4937
5225
|
}
|
|
4938
|
-
|
|
4939
|
-
|
|
5226
|
+
XMLParser.defaultOptions = {};
|
|
5227
|
+
function isSvg(str) {
|
|
5228
|
+
return str.startsWith("<svg") || str.startsWith("<?xml");
|
|
4940
5229
|
}
|
|
4941
|
-
Graphic.mixin(EventTarget);
|
|
4942
5230
|
|
|
4943
5231
|
undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4944
5232
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -4996,128 +5284,1870 @@
|
|
|
4996
5284
|
genNumberType();
|
|
4997
5285
|
genNumberType();
|
|
4998
5286
|
genNumberType();
|
|
4999
|
-
|
|
5000
|
-
const
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
} = outerBorder;
|
|
5011
|
-
aabbBounds.expand(distance + (shadowBlur + lineWidth) / 2);
|
|
5012
|
-
}
|
|
5013
|
-
return aabbBounds;
|
|
5287
|
+
genNumberType();
|
|
5288
|
+
const SVG_PARSE_ATTRIBUTE_MAP = {
|
|
5289
|
+
"stroke-linecap": "lineCap",
|
|
5290
|
+
"stroke-linejoin": "lineJoin",
|
|
5291
|
+
"stroke-dasharray": "lineDash",
|
|
5292
|
+
"stroke-dashoffset": "lineDashOffset",
|
|
5293
|
+
"stroke-width": "lineWidth",
|
|
5294
|
+
"fill-opacity": "fillOpacity",
|
|
5295
|
+
"stroke-opacity": "strokeOpacity",
|
|
5296
|
+
stroke: "stroke",
|
|
5297
|
+
fill: "fill"
|
|
5014
5298
|
};
|
|
5299
|
+
const SVG_PARSE_ATTRIBUTE_MAP_KEYS = Object.keys(SVG_PARSE_ATTRIBUTE_MAP);
|
|
5015
5300
|
|
|
5016
|
-
const
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5301
|
+
const _tempBounds = new AABBBounds(),
|
|
5302
|
+
tempMatrix = new Matrix(),
|
|
5303
|
+
tempBounds = new AABBBounds();
|
|
5304
|
+
const GRAPHIC_UPDATE_TAG_KEY = ["lineWidth", "scaleX", "scaleY", "angle", "anchor", "visible"];
|
|
5305
|
+
const tempConstantXYKey = ["x", "y"],
|
|
5306
|
+
tempConstantScaleXYKey = ["scaleX", "scaleY"],
|
|
5307
|
+
tempConstantAngleKey = ["angle"],
|
|
5308
|
+
point = new Point();
|
|
5309
|
+
const NOWORK_ANIMATE_ATTR = {
|
|
5310
|
+
strokeSeg: 1,
|
|
5311
|
+
boundsPadding: 2,
|
|
5312
|
+
pickMode: 1,
|
|
5313
|
+
boundsMode: 1,
|
|
5314
|
+
customPickShape: 1,
|
|
5315
|
+
pickable: 1,
|
|
5316
|
+
childrenPickable: 1,
|
|
5317
|
+
visible: 1,
|
|
5318
|
+
zIndex: 1,
|
|
5319
|
+
layout: 1,
|
|
5320
|
+
keepDirIn3d: 1,
|
|
5321
|
+
globalZIndex: 1,
|
|
5322
|
+
outerBorder: 1,
|
|
5323
|
+
innerBorder: 1,
|
|
5324
|
+
lineDash: 1,
|
|
5325
|
+
lineCap: 1,
|
|
5326
|
+
lineJoin: 1,
|
|
5327
|
+
miterLimit: 2,
|
|
5328
|
+
strokeBoundsBuffer: 2,
|
|
5329
|
+
scaleCenter: 1,
|
|
5330
|
+
anchor: 1,
|
|
5331
|
+
anchor3d: 1,
|
|
5332
|
+
postMatrix: 1,
|
|
5333
|
+
backgroundMode: 2,
|
|
5334
|
+
background: 1,
|
|
5335
|
+
texture: 1,
|
|
5336
|
+
cursor: 1,
|
|
5337
|
+
html: 1
|
|
5338
|
+
};
|
|
5339
|
+
class Graphic extends Node {
|
|
5340
|
+
static mixin(source) {
|
|
5341
|
+
const keys = Object.keys(source);
|
|
5342
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
5343
|
+
const propertyName = keys[i];
|
|
5344
|
+
Object.defineProperty(Graphic.prototype, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));
|
|
5345
|
+
}
|
|
5020
5346
|
}
|
|
5021
|
-
|
|
5022
|
-
return
|
|
5347
|
+
get AABBBounds() {
|
|
5348
|
+
return this.tryUpdateAABBBounds();
|
|
5023
5349
|
}
|
|
5024
|
-
|
|
5025
|
-
return
|
|
5350
|
+
get OBBBounds() {
|
|
5351
|
+
return this.tryUpdateOBBBounds();
|
|
5026
5352
|
}
|
|
5027
|
-
|
|
5028
|
-
return
|
|
5353
|
+
get globalAABBBounds() {
|
|
5354
|
+
return this.tryUpdateGlobalAABBBounds();
|
|
5029
5355
|
}
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5356
|
+
get transMatrix() {
|
|
5357
|
+
return this.tryUpdateLocalTransMatrix(!0);
|
|
5358
|
+
}
|
|
5359
|
+
get globalTransMatrix() {
|
|
5360
|
+
return this.tryUpdateGlobalTransMatrix(!0);
|
|
5361
|
+
}
|
|
5362
|
+
constructor() {
|
|
5363
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5364
|
+
var _a;
|
|
5365
|
+
super(), this._AABBBounds = new AABBBounds(), this._updateTag = UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
|
|
5366
|
+
}
|
|
5367
|
+
setMode(mode) {
|
|
5368
|
+
"3d" === mode ? this.set3dMode() : this.set2dMode();
|
|
5369
|
+
}
|
|
5370
|
+
set3dMode() {
|
|
5371
|
+
this.in3dMode = !0;
|
|
5372
|
+
}
|
|
5373
|
+
set2dMode() {
|
|
5374
|
+
this.in3dMode = !1;
|
|
5375
|
+
}
|
|
5376
|
+
getOffsetXY(attr) {
|
|
5377
|
+
let includeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
5378
|
+
var _a, _b;
|
|
5044
5379
|
const {
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
} =
|
|
5048
|
-
|
|
5380
|
+
dx = attr.dx,
|
|
5381
|
+
dy = attr.dy
|
|
5382
|
+
} = this.attribute;
|
|
5383
|
+
if (includeScroll && this.parent) {
|
|
5384
|
+
const attribute = this.parent.attribute;
|
|
5385
|
+
point.x = dx + (null !== (_a = attribute.scrollX) && void 0 !== _a ? _a : 0), point.y = dy + (null !== (_b = attribute.scrollY) && void 0 !== _b ? _b : 0);
|
|
5386
|
+
} else point.x = dx, point.y = dy;
|
|
5387
|
+
return point;
|
|
5049
5388
|
}
|
|
5050
|
-
|
|
5051
|
-
|
|
5389
|
+
onAnimateBind(animate) {
|
|
5390
|
+
this._emitCustomEvent("animate-bind", animate);
|
|
5052
5391
|
}
|
|
5053
|
-
|
|
5054
|
-
|
|
5392
|
+
tryUpdateAABBBounds() {
|
|
5393
|
+
const full = "imprecise" === this.attribute.boundsMode;
|
|
5394
|
+
if (!this.shouldUpdateAABBBounds()) return this._AABBBounds;
|
|
5395
|
+
if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
|
|
5396
|
+
application.graphicService.beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
|
|
5397
|
+
const bounds = this.doUpdateAABBBounds(full);
|
|
5398
|
+
return application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0), "empty" === this.attribute.boundsMode && bounds.clear(), bounds;
|
|
5055
5399
|
}
|
|
5056
|
-
|
|
5400
|
+
tryUpdateOBBBounds() {
|
|
5401
|
+
if (this._OBBBounds || (this._OBBBounds = new OBBBounds()), this.tryUpdateAABBBounds(), this.updateOBBBoundsStamp === this.updateAABBBoundsStamp) return this._OBBBounds;
|
|
5402
|
+
if (this.updateOBBBoundsStamp = this.updateAABBBoundsStamp, !this.valid) return this._OBBBounds.clear(), this._OBBBounds;
|
|
5403
|
+
return this.doUpdateOBBBounds();
|
|
5404
|
+
}
|
|
5405
|
+
combindShadowAABBBounds(bounds) {
|
|
5406
|
+
if (this.shadowRoot) {
|
|
5407
|
+
const b = this.shadowRoot.AABBBounds.clone();
|
|
5408
|
+
bounds.union(b);
|
|
5409
|
+
}
|
|
5410
|
+
}
|
|
5411
|
+
doUpdateOBBBounds() {
|
|
5412
|
+
return this._OBBBounds;
|
|
5413
|
+
}
|
|
5414
|
+
getClipPath() {
|
|
5415
|
+
const {
|
|
5416
|
+
clipConfig: clipConfig
|
|
5417
|
+
} = this.attribute;
|
|
5418
|
+
if (!clipConfig) return null;
|
|
5419
|
+
this.clipPathMap || (this.clipPathMap = new Map());
|
|
5420
|
+
const {
|
|
5421
|
+
shape: shape
|
|
5422
|
+
} = clipConfig;
|
|
5423
|
+
let path = this.clipPathMap.get(shape) || null;
|
|
5424
|
+
return path || (this.clipPathMap.size > 10 && this.clipPathMap.clear(), path = this.parsePath(shape), path && this.clipPathMap.set(shape, path)), path;
|
|
5425
|
+
}
|
|
5426
|
+
parsePath(symbolType) {
|
|
5427
|
+
if (!symbolType) return null;
|
|
5428
|
+
let path = builtinSymbolsMap[symbolType];
|
|
5429
|
+
if (path) return path;
|
|
5430
|
+
if (path = Graphic.userSymbolMap[symbolType], path) return path;
|
|
5431
|
+
const _symbolType = builtInSymbolStrMap[symbolType];
|
|
5432
|
+
if (!0 === isSvg(symbolType = _symbolType || symbolType)) {
|
|
5433
|
+
const parser = new XMLParser(),
|
|
5434
|
+
{
|
|
5435
|
+
svg: svg
|
|
5436
|
+
} = parser.parse(symbolType);
|
|
5437
|
+
if (!svg) return null;
|
|
5438
|
+
const path = isArray$1(svg.path) ? svg.path : [svg.path];
|
|
5439
|
+
_tempBounds.clear();
|
|
5440
|
+
const cacheList = [];
|
|
5441
|
+
path.forEach(item => {
|
|
5442
|
+
const cache = new CustomPath2D().fromString(item.d),
|
|
5443
|
+
attribute = {};
|
|
5444
|
+
SVG_PARSE_ATTRIBUTE_MAP_KEYS.forEach(k => {
|
|
5445
|
+
item[k] && (attribute[SVG_PARSE_ATTRIBUTE_MAP[k]] = item[k]);
|
|
5446
|
+
}), cacheList.push({
|
|
5447
|
+
path: cache,
|
|
5448
|
+
attribute: attribute
|
|
5449
|
+
}), _tempBounds.union(cache.bounds);
|
|
5450
|
+
});
|
|
5451
|
+
const width = _tempBounds.width(),
|
|
5452
|
+
height = _tempBounds.height(),
|
|
5453
|
+
scale = 1 / max(width, height);
|
|
5454
|
+
cacheList.forEach(cache => cache.path.transform(0, 0, scale, scale));
|
|
5455
|
+
const _parsedPath = new CustomSymbolClass(symbolType, cacheList, !0);
|
|
5456
|
+
return Graphic.userSymbolMap[symbolType] = _parsedPath, _parsedPath;
|
|
5457
|
+
}
|
|
5458
|
+
const cache = new CustomPath2D().fromString(symbolType),
|
|
5459
|
+
width = cache.bounds.width(),
|
|
5460
|
+
height = cache.bounds.height(),
|
|
5461
|
+
scale = 1 / max(width, height);
|
|
5462
|
+
cache.transform(0, 0, scale, scale);
|
|
5463
|
+
const _parsedPath = new CustomSymbolClass(symbolType, cache);
|
|
5464
|
+
return Graphic.userSymbolMap[symbolType] = _parsedPath, _parsedPath;
|
|
5465
|
+
}
|
|
5466
|
+
doUpdateAABBBounds(full) {
|
|
5467
|
+
this.updateAABBBoundsStamp++;
|
|
5468
|
+
const graphicTheme = this.getGraphicTheme();
|
|
5469
|
+
this._AABBBounds.clear();
|
|
5057
5470
|
const attribute = this.attribute,
|
|
5471
|
+
bounds = this.updateAABBBounds(attribute, graphicTheme, this._AABBBounds, full),
|
|
5058
5472
|
{
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
} = normalizeRectAttributes(attribute),
|
|
5064
|
-
path = new CustomPath2D();
|
|
5065
|
-
return path.moveTo(x, y), path.rect(x, y, width, height), path;
|
|
5473
|
+
boundsPadding = graphicTheme.boundsPadding
|
|
5474
|
+
} = attribute,
|
|
5475
|
+
paddingArray = parsePadding(boundsPadding);
|
|
5476
|
+
return paddingArray && bounds.expand(paddingArray), this.clearUpdateBoundTag(), bounds;
|
|
5066
5477
|
}
|
|
5067
|
-
|
|
5068
|
-
|
|
5478
|
+
updatePathProxyAABBBounds(aabbBounds) {
|
|
5479
|
+
const path = "function" == typeof this.pathProxy ? this.pathProxy(this.attribute) : this.pathProxy;
|
|
5480
|
+
if (!path) return !1;
|
|
5481
|
+
const boundsContext = new BoundsContext(aabbBounds);
|
|
5482
|
+
return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
|
|
5069
5483
|
}
|
|
5070
|
-
|
|
5071
|
-
|
|
5484
|
+
tryUpdateGlobalAABBBounds() {
|
|
5485
|
+
const b = this.AABBBounds;
|
|
5486
|
+
return this._globalAABBBounds ? this._globalAABBBounds.setValue(b.x1, b.y1, b.x2, b.y2) : this._globalAABBBounds = b.clone(), this._globalAABBBounds.empty() || this.parent && this._globalAABBBounds.transformWithMatrix(this.parent.globalTransMatrix), this._globalAABBBounds;
|
|
5072
5487
|
}
|
|
5488
|
+
tryUpdateGlobalTransMatrix() {
|
|
5489
|
+
if (this._globalTransMatrix) {
|
|
5490
|
+
if (this.parent) {
|
|
5491
|
+
const m = this.parent.globalTransMatrix;
|
|
5492
|
+
this._globalTransMatrix.setValue(m.a, m.b, m.c, m.d, m.e, m.f);
|
|
5493
|
+
}
|
|
5494
|
+
} else this._globalTransMatrix = this.parent ? this.parent.globalTransMatrix.clone() : this.transMatrix.clone();
|
|
5495
|
+
return this.shouldUpdateGlobalMatrix() && this.doUpdateGlobalMatrix(), this._globalTransMatrix;
|
|
5496
|
+
}
|
|
5497
|
+
shouldUpdateGlobalMatrix() {
|
|
5498
|
+
return !0;
|
|
5499
|
+
}
|
|
5500
|
+
tryUpdateLocalTransMatrix() {
|
|
5501
|
+
let clearTag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
|
|
5502
|
+
return this._transMatrix || (this._transMatrix = new Matrix()), this.shouldUpdateLocalMatrix() && (this.doUpdateLocalMatrix(), clearTag && this.clearUpdateLocalPositionTag()), this._transMatrix;
|
|
5503
|
+
}
|
|
5504
|
+
shouldUpdateAABBBounds() {
|
|
5505
|
+
return this.shadowRoot ? (!!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds()) && application.graphicService.validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this) : !!(this._updateTag & UpdateTag.UPDATE_BOUNDS) && application.graphicService.validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this);
|
|
5506
|
+
}
|
|
5507
|
+
shouldSelfChangeUpdateAABBBounds() {
|
|
5508
|
+
return this.shadowRoot ? !!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds() : !!(this._updateTag & UpdateTag.UPDATE_BOUNDS);
|
|
5509
|
+
}
|
|
5510
|
+
shouldUpdateLocalMatrix() {
|
|
5511
|
+
return !!(this._updateTag & UpdateTag.UPDATE_LOCAL_MATRIX);
|
|
5512
|
+
}
|
|
5513
|
+
isValid() {
|
|
5514
|
+
var _a, _b;
|
|
5515
|
+
const attribute = this.attribute;
|
|
5516
|
+
return Number.isFinite((null !== (_a = attribute.x) && void 0 !== _a ? _a : 0) + (null !== (_b = attribute.y) && void 0 !== _b ? _b : 0));
|
|
5517
|
+
}
|
|
5518
|
+
_validNumber(num) {
|
|
5519
|
+
return null == num || Number.isFinite(num);
|
|
5520
|
+
}
|
|
5521
|
+
shouldUpdateShape() {
|
|
5522
|
+
return !!(this._updateTag & UpdateTag.UPDATE_SHAPE);
|
|
5523
|
+
}
|
|
5524
|
+
clearUpdateShapeTag() {
|
|
5525
|
+
this._updateTag &= UpdateTag.CLEAR_SHAPE;
|
|
5526
|
+
}
|
|
5527
|
+
containsPoint(x, y, mode, picker) {
|
|
5528
|
+
if (!picker) return !1;
|
|
5529
|
+
if (mode === IContainPointMode.GLOBAL) {
|
|
5530
|
+
const point = new Point(x, y);
|
|
5531
|
+
this.parent && this.parent.globalTransMatrix.transformPoint(point, point), x = point.x, y = point.y;
|
|
5532
|
+
}
|
|
5533
|
+
return picker.containsPoint(this, {
|
|
5534
|
+
x: x,
|
|
5535
|
+
y: y
|
|
5536
|
+
});
|
|
5537
|
+
}
|
|
5538
|
+
setWidthHeightWithoutTransform(aabbBounds) {
|
|
5539
|
+
this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;
|
|
5540
|
+
}
|
|
5541
|
+
setAttributes(params) {
|
|
5542
|
+
let forceUpdateTag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
5543
|
+
let context = arguments.length > 2 ? arguments[2] : undefined;
|
|
5544
|
+
(params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context);
|
|
5545
|
+
}
|
|
5546
|
+
_setAttributes(params) {
|
|
5547
|
+
let forceUpdateTag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
5548
|
+
let context = arguments.length > 2 ? arguments[2] : undefined;
|
|
5549
|
+
const keys = Object.keys(params);
|
|
5550
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5551
|
+
const key = keys[i];
|
|
5552
|
+
this.attribute[key] = params[key];
|
|
5553
|
+
}
|
|
5554
|
+
this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTags(keys) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context);
|
|
5555
|
+
}
|
|
5556
|
+
setAttribute(key, value, forceUpdateTag, context) {
|
|
5557
|
+
var _a;
|
|
5558
|
+
const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
5559
|
+
[key]: value
|
|
5560
|
+
}, this.attribute, key, context);
|
|
5561
|
+
params ? this._setAttributes(params, forceUpdateTag, context) : isNil$1(null === (_a = this.normalAttrs) || void 0 === _a ? void 0 : _a[key]) ? (this.attribute[key] = value, this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context)) : this.normalAttrs[key] = value, "background" === key ? this.loadImage(value, !0) : "shadowGraphic" === key && this.setShadowGraphic(value);
|
|
5562
|
+
}
|
|
5563
|
+
needUpdateTags(keys) {
|
|
5564
|
+
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GRAPHIC_UPDATE_TAG_KEY;
|
|
5565
|
+
for (let i = 0; i < k.length; i++) {
|
|
5566
|
+
const attrKey = k[i];
|
|
5567
|
+
if (-1 !== keys.indexOf(attrKey)) return !0;
|
|
5568
|
+
}
|
|
5569
|
+
return !1;
|
|
5570
|
+
}
|
|
5571
|
+
needUpdateTag(key) {
|
|
5572
|
+
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GRAPHIC_UPDATE_TAG_KEY;
|
|
5573
|
+
for (let i = 0; i < k.length; i++) {
|
|
5574
|
+
if (key === k[i]) return !0;
|
|
5575
|
+
}
|
|
5576
|
+
return !1;
|
|
5577
|
+
}
|
|
5578
|
+
initAttributes(params) {
|
|
5579
|
+
const context = {
|
|
5580
|
+
type: AttributeUpdateType.INIT
|
|
5581
|
+
};
|
|
5582
|
+
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, params.background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
|
|
5583
|
+
}
|
|
5584
|
+
translate(x, y) {
|
|
5585
|
+
var _a, _b;
|
|
5586
|
+
if (0 === x && 0 === y) return this;
|
|
5587
|
+
const context = {
|
|
5588
|
+
type: AttributeUpdateType.TRANSLATE
|
|
5589
|
+
},
|
|
5590
|
+
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
5591
|
+
x: x,
|
|
5592
|
+
y: y
|
|
5593
|
+
}, this.attribute, tempConstantXYKey, context);
|
|
5594
|
+
params && (x = params.x, y = params.y, delete params.x, delete params.y, this._setAttributes(params));
|
|
5595
|
+
const attribute = this.attribute,
|
|
5596
|
+
postMatrix = attribute.postMatrix;
|
|
5597
|
+
return postMatrix ? application.transformUtil.fromMatrix(postMatrix, postMatrix).translate(x, y) : (attribute.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : DefaultTransform.x) + x, attribute.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : DefaultTransform.y) + y), this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this;
|
|
5598
|
+
}
|
|
5599
|
+
translateTo(x, y) {
|
|
5600
|
+
const attribute = this.attribute;
|
|
5601
|
+
if (attribute.x === x && attribute.y === y) return this;
|
|
5602
|
+
const context = {
|
|
5603
|
+
type: AttributeUpdateType.TRANSLATE_TO
|
|
5604
|
+
},
|
|
5605
|
+
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
5606
|
+
x: x,
|
|
5607
|
+
y: y
|
|
5608
|
+
}, this.attribute, tempConstantXYKey, context);
|
|
5609
|
+
return params ? (this._setAttributes(params, !1, context), this) : (attribute.x = x, attribute.y = y, this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this);
|
|
5610
|
+
}
|
|
5611
|
+
scale(scaleX, scaleY, scaleCenter) {
|
|
5612
|
+
var _a, _b;
|
|
5613
|
+
if (1 === scaleX && 1 === scaleY) return this;
|
|
5614
|
+
const context = {
|
|
5615
|
+
type: AttributeUpdateType.SCALE
|
|
5616
|
+
},
|
|
5617
|
+
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
5618
|
+
scaleX: scaleX,
|
|
5619
|
+
scaleY: scaleY,
|
|
5620
|
+
scaleCenter: scaleCenter
|
|
5621
|
+
}, this.attribute, tempConstantScaleXYKey, context);
|
|
5622
|
+
params && (scaleX = params.scaleX, scaleY = params.scaleY, delete params.scaleX, delete params.scaleY, this._setAttributes(params));
|
|
5623
|
+
const attribute = this.attribute;
|
|
5624
|
+
if (scaleCenter) {
|
|
5625
|
+
let {
|
|
5626
|
+
postMatrix: postMatrix
|
|
5627
|
+
} = this.attribute;
|
|
5628
|
+
postMatrix || (postMatrix = new Matrix(), attribute.postMatrix = postMatrix), application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter);
|
|
5629
|
+
} else attribute.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : DefaultTransform.scaleX) * scaleX, attribute.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : DefaultTransform.scaleY) * scaleY;
|
|
5630
|
+
return this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this;
|
|
5631
|
+
}
|
|
5632
|
+
scaleTo(scaleX, scaleY) {
|
|
5633
|
+
const attribute = this.attribute;
|
|
5634
|
+
if (attribute.scaleX === scaleX && attribute.scaleY === scaleY) return this;
|
|
5635
|
+
const context = {
|
|
5636
|
+
type: AttributeUpdateType.SCALE_TO
|
|
5637
|
+
},
|
|
5638
|
+
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
5639
|
+
scaleX: scaleX,
|
|
5640
|
+
scaleY: scaleY
|
|
5641
|
+
}, this.attribute, tempConstantScaleXYKey, context);
|
|
5642
|
+
return params ? (this._setAttributes(params, !1, context), this) : (attribute.scaleX = scaleX, attribute.scaleY = scaleY, this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this);
|
|
5643
|
+
}
|
|
5644
|
+
rotate(angle, rotateCenter) {
|
|
5645
|
+
var _a;
|
|
5646
|
+
if (0 === angle) return this;
|
|
5647
|
+
const context = {
|
|
5648
|
+
type: AttributeUpdateType.ROTATE
|
|
5649
|
+
},
|
|
5650
|
+
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
|
|
5651
|
+
angle: angle,
|
|
5652
|
+
rotateCenter: rotateCenter
|
|
5653
|
+
}, this.attribute, tempConstantAngleKey, context);
|
|
5654
|
+
params && (delete params.angle, this._setAttributes(params, !1, context));
|
|
5655
|
+
const attribute = this.attribute;
|
|
5656
|
+
if (rotateCenter) {
|
|
5657
|
+
let {
|
|
5658
|
+
postMatrix: postMatrix
|
|
5659
|
+
} = this.attribute;
|
|
5660
|
+
postMatrix || (postMatrix = new Matrix(), attribute.postMatrix = postMatrix), application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter);
|
|
5661
|
+
} else attribute.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : DefaultTransform.angle) + angle;
|
|
5662
|
+
return this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this;
|
|
5663
|
+
}
|
|
5664
|
+
rotateTo(angle) {
|
|
5665
|
+
const attribute = this.attribute;
|
|
5666
|
+
if (attribute.angle === angle) return this;
|
|
5667
|
+
const context = {
|
|
5668
|
+
type: AttributeUpdateType.ROTATE_TO
|
|
5669
|
+
},
|
|
5670
|
+
params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(angle, this.attribute, tempConstantAngleKey, context);
|
|
5671
|
+
return params ? (this._setAttributes(params, !1, context), this) : (attribute.angle = angle, this.addUpdatePositionTag(), this.addUpdateBoundTag(), this.addUpdateLayoutTag(), this.onAttributeUpdate(context), this);
|
|
5672
|
+
}
|
|
5673
|
+
skewTo(b, c) {
|
|
5674
|
+
return this;
|
|
5675
|
+
}
|
|
5676
|
+
animate(params) {
|
|
5677
|
+
var _a;
|
|
5678
|
+
this.animates || (this.animates = new Map());
|
|
5679
|
+
const animate = new Animate(null == params ? void 0 : params.id, null !== (_a = null == params ? void 0 : params.timeline) && void 0 !== _a ? _a : this.stage && this.stage.getTimeline(), null == params ? void 0 : params.slience);
|
|
5680
|
+
if (animate.bind(this), params) {
|
|
5681
|
+
const {
|
|
5682
|
+
onStart: onStart,
|
|
5683
|
+
onFrame: onFrame,
|
|
5684
|
+
onEnd: onEnd,
|
|
5685
|
+
onRemove: onRemove
|
|
5686
|
+
} = params;
|
|
5687
|
+
null != onStart && animate.onStart(onStart), null != onFrame && animate.onFrame(onFrame), null != onEnd && animate.onEnd(onEnd), null != onRemove && animate.onRemove(onRemove), animate.interpolateFunc = params.interpolate;
|
|
5688
|
+
}
|
|
5689
|
+
return this.animates.set(animate.id, animate), animate.onRemove(() => {
|
|
5690
|
+
animate.stop(), this.animates.delete(animate.id);
|
|
5691
|
+
}), animate;
|
|
5692
|
+
}
|
|
5693
|
+
onAttributeUpdate(context) {
|
|
5694
|
+
context && context.skipUpdateCallback || (application.graphicService.onAttributeUpdate(this), this._emitCustomEvent("afterAttributeUpdate", context));
|
|
5695
|
+
}
|
|
5696
|
+
update(d) {
|
|
5697
|
+
d ? (d.bounds && this.tryUpdateAABBBounds(), d.trans && this.tryUpdateLocalTransMatrix()) : (this.tryUpdateAABBBounds(), this.tryUpdateLocalTransMatrix());
|
|
5698
|
+
}
|
|
5699
|
+
hasState(stateName) {
|
|
5700
|
+
return !(!this.currentStates || !this.currentStates.length) && (!!isNil$1(stateName) || this.currentStates.includes(stateName));
|
|
5701
|
+
}
|
|
5702
|
+
getState(stateName) {
|
|
5703
|
+
var _a;
|
|
5704
|
+
return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
|
|
5705
|
+
}
|
|
5706
|
+
applyStateAttrs(attrs, stateNames, hasAnimation, isClear) {
|
|
5707
|
+
var _a, _b, _c, _d;
|
|
5708
|
+
if (hasAnimation) {
|
|
5709
|
+
const keys = Object.keys(attrs),
|
|
5710
|
+
noWorkAttrs = this.getNoWorkAnimateAttr(),
|
|
5711
|
+
animateAttrs = {};
|
|
5712
|
+
let noAnimateAttrs;
|
|
5713
|
+
keys.forEach(key => {
|
|
5714
|
+
noWorkAttrs[key] ? (noAnimateAttrs || (noAnimateAttrs = {}), noAnimateAttrs[key] = attrs[key]) : animateAttrs[key] = isClear && void 0 === attrs[key] ? this.getDefaultAttribute(key) : attrs[key];
|
|
5715
|
+
});
|
|
5716
|
+
const animate = this.animate({
|
|
5717
|
+
slience: !0
|
|
5718
|
+
});
|
|
5719
|
+
animate.stateNames = stateNames, animate.to(animateAttrs, null !== (_b = null === (_a = this.stateAnimateConfig) || void 0 === _a ? void 0 : _a.duration) && void 0 !== _b ? _b : DefaultStateAnimateConfig.duration, null !== (_d = null === (_c = this.stateAnimateConfig) || void 0 === _c ? void 0 : _c.easing) && void 0 !== _d ? _d : DefaultStateAnimateConfig.easing), noAnimateAttrs && this.setAttributes(noAnimateAttrs, !1, {
|
|
5720
|
+
type: AttributeUpdateType.STATE
|
|
5721
|
+
});
|
|
5722
|
+
} else this.stopStateAnimates(), this.setAttributes(attrs, !1, {
|
|
5723
|
+
type: AttributeUpdateType.STATE
|
|
5724
|
+
});
|
|
5725
|
+
}
|
|
5726
|
+
updateNormalAttrs(stateAttrs) {
|
|
5727
|
+
const newNormalAttrs = {};
|
|
5728
|
+
this.normalAttrs ? (Object.keys(stateAttrs).forEach(key => {
|
|
5729
|
+
key in this.normalAttrs ? (newNormalAttrs[key] = this.normalAttrs[key], delete this.normalAttrs[key]) : newNormalAttrs[key] = this.getNormalAttribute(key);
|
|
5730
|
+
}), Object.keys(this.normalAttrs).forEach(key => {
|
|
5731
|
+
stateAttrs[key] = this.normalAttrs[key];
|
|
5732
|
+
})) : Object.keys(stateAttrs).forEach(key => {
|
|
5733
|
+
newNormalAttrs[key] = this.getNormalAttribute(key);
|
|
5734
|
+
}), this.normalAttrs = newNormalAttrs;
|
|
5735
|
+
}
|
|
5736
|
+
stopStateAnimates() {
|
|
5737
|
+
let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "end";
|
|
5738
|
+
this.animates && this.animates.forEach(animate => {
|
|
5739
|
+
animate.stateNames && (animate.stop(type), this.animates.delete(animate.id));
|
|
5740
|
+
});
|
|
5741
|
+
}
|
|
5742
|
+
getNormalAttribute(key) {
|
|
5743
|
+
let value = this.attribute[key];
|
|
5744
|
+
return this.animates && this.animates.forEach(animate => {
|
|
5745
|
+
if (animate.stateNames) {
|
|
5746
|
+
const endProps = animate.getEndProps();
|
|
5747
|
+
has$1(endProps, key) && (value = endProps[key]);
|
|
5748
|
+
}
|
|
5749
|
+
}), value;
|
|
5750
|
+
}
|
|
5751
|
+
clearStates(hasAnimation) {
|
|
5752
|
+
this.hasState() && this.normalAttrs ? (this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
|
|
5753
|
+
}
|
|
5754
|
+
removeState(stateName, hasAnimation) {
|
|
5755
|
+
if (this.currentStates) {
|
|
5756
|
+
const filter = isArray$1(stateName) ? s => !stateName.includes(s) : s => s !== stateName,
|
|
5757
|
+
newStates = this.currentStates.filter(filter);
|
|
5758
|
+
newStates.length !== this.currentStates.length && this.useStates(newStates, hasAnimation);
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
5761
|
+
toggleState(stateName, hasAnimation) {
|
|
5762
|
+
if (this.hasState(stateName)) this.removeState(stateName, hasAnimation);else {
|
|
5763
|
+
if ((this.currentStates ? this.currentStates.indexOf(stateName) : -1) < 0) {
|
|
5764
|
+
const nextStates = this.currentStates ? this.currentStates.slice() : [];
|
|
5765
|
+
nextStates.push(stateName), this.useStates(nextStates, hasAnimation);
|
|
5766
|
+
}
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
addState(stateName, keepCurrentStates, hasAnimation) {
|
|
5770
|
+
var _a;
|
|
5771
|
+
if (this.currentStates && this.currentStates.includes(stateName) && (keepCurrentStates || 1 === this.currentStates.length)) return;
|
|
5772
|
+
const newStates = keepCurrentStates && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) ? this.currentStates.concat([stateName]) : [stateName];
|
|
5773
|
+
this.useStates(newStates, hasAnimation);
|
|
5774
|
+
}
|
|
5775
|
+
useStates(states, hasAnimation) {
|
|
5776
|
+
var _a;
|
|
5777
|
+
if (!states.length) return void this.clearStates(hasAnimation);
|
|
5778
|
+
if (!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) !== states.length || states.some((stateName, index) => this.currentStates[index] !== stateName))) return;
|
|
5779
|
+
const stateAttrs = {};
|
|
5780
|
+
states.forEach(stateName => {
|
|
5781
|
+
var _a;
|
|
5782
|
+
const attrs = this.stateProxy ? this.stateProxy(stateName, states) : null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
|
|
5783
|
+
attrs && Object.assign(stateAttrs, attrs);
|
|
5784
|
+
}), this.updateNormalAttrs(stateAttrs), this.currentStates = states, this.applyStateAttrs(stateAttrs, states, hasAnimation);
|
|
5785
|
+
}
|
|
5786
|
+
addUpdateBoundTag() {
|
|
5787
|
+
this._updateTag |= UpdateTag.UPDATE_BOUNDS, this.parent && this.parent.addChildUpdateBoundTag(), this.glyphHost && this.glyphHost.addUpdateBoundTag();
|
|
5788
|
+
}
|
|
5789
|
+
addUpdateShapeTag() {
|
|
5790
|
+
this._updateTag |= UpdateTag.UPDATE_SHAPE;
|
|
5791
|
+
}
|
|
5792
|
+
addUpdateShapeAndBoundsTag() {
|
|
5793
|
+
this._updateTag |= UpdateTag.UPDATE_SHAPE_AND_BOUNDS, this.parent && this.parent.addChildUpdateBoundTag(), this.glyphHost && this.glyphHost.addUpdateBoundTag();
|
|
5794
|
+
}
|
|
5795
|
+
updateShapeAndBoundsTagSetted() {
|
|
5796
|
+
return (this._updateTag & UpdateTag.UPDATE_SHAPE_AND_BOUNDS) === UpdateTag.UPDATE_SHAPE_AND_BOUNDS;
|
|
5797
|
+
}
|
|
5798
|
+
clearUpdateBoundTag() {
|
|
5799
|
+
this._updateTag &= UpdateTag.CLEAR_BOUNDS;
|
|
5800
|
+
}
|
|
5801
|
+
addUpdatePositionTag() {
|
|
5802
|
+
this.shadowRoot && this.shadowRoot.addUpdateGlobalPositionTag(), this._updateTag |= UpdateTag.UPDATE_GLOBAL_LOCAL_MATRIX;
|
|
5803
|
+
}
|
|
5804
|
+
addUpdateGlobalPositionTag() {
|
|
5805
|
+
this.shadowRoot && this.shadowRoot.addUpdateGlobalPositionTag(), this._updateTag |= UpdateTag.UPDATE_GLOBAL_MATRIX;
|
|
5806
|
+
}
|
|
5807
|
+
clearUpdateLocalPositionTag() {
|
|
5808
|
+
this._updateTag &= UpdateTag.CLEAR_LOCAL_MATRIX;
|
|
5809
|
+
}
|
|
5810
|
+
clearUpdateGlobalPositionTag() {
|
|
5811
|
+
this._updateTag &= UpdateTag.CLEAR_GLOBAL_MATRIX;
|
|
5812
|
+
}
|
|
5813
|
+
addUpdateLayoutTag() {
|
|
5814
|
+
this._updateTag |= UpdateTag.UPDATE_LAYOUT;
|
|
5815
|
+
}
|
|
5816
|
+
clearUpdateLayoutTag() {
|
|
5817
|
+
this._updateTag &= UpdateTag.CLEAR_LAYOUT;
|
|
5818
|
+
}
|
|
5819
|
+
needUpdateLayout() {
|
|
5820
|
+
return !!(this._updateTag & UpdateTag.UPDATE_LAYOUT);
|
|
5821
|
+
}
|
|
5822
|
+
getAnchor(anchor, params) {
|
|
5823
|
+
const _anchor = [0, 0],
|
|
5824
|
+
getBounds = () => {
|
|
5825
|
+
if (params.b) return params.b;
|
|
5826
|
+
const {
|
|
5827
|
+
scaleX: scaleX,
|
|
5828
|
+
scaleY: scaleY,
|
|
5829
|
+
angle: angle,
|
|
5830
|
+
scaleCenter: scaleCenter
|
|
5831
|
+
} = this.attribute;
|
|
5832
|
+
return tempBounds.copy(this._AABBBounds), this.setAttributes({
|
|
5833
|
+
angle: 0,
|
|
5834
|
+
scaleCenter: null
|
|
5835
|
+
}), params.b = this.AABBBounds.clone(), this._AABBBounds.copy(tempBounds), this.setAttributes({
|
|
5836
|
+
scaleX: scaleX,
|
|
5837
|
+
scaleY: scaleY,
|
|
5838
|
+
angle: angle,
|
|
5839
|
+
scaleCenter: scaleCenter
|
|
5840
|
+
}), params.b;
|
|
5841
|
+
};
|
|
5842
|
+
if ("string" == typeof anchor[0]) {
|
|
5843
|
+
const ratio = parseFloat(anchor[0]) / 100,
|
|
5844
|
+
bounds = getBounds();
|
|
5845
|
+
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
5846
|
+
} else _anchor[0] = anchor[0];
|
|
5847
|
+
if ("string" == typeof anchor[1]) {
|
|
5848
|
+
const ratio = parseFloat(anchor[1]) / 100,
|
|
5849
|
+
bounds = getBounds();
|
|
5850
|
+
_anchor[1] = bounds.y1 + (bounds.y2 - bounds.y1) * ratio;
|
|
5851
|
+
} else _anchor[1] = anchor[1];
|
|
5852
|
+
return _anchor;
|
|
5853
|
+
}
|
|
5854
|
+
doUpdateLocalMatrix() {
|
|
5855
|
+
const {
|
|
5856
|
+
x = DefaultTransform.x,
|
|
5857
|
+
y = DefaultTransform.y,
|
|
5858
|
+
scaleX = DefaultTransform.scaleX,
|
|
5859
|
+
scaleY = DefaultTransform.scaleY,
|
|
5860
|
+
angle = DefaultTransform.angle,
|
|
5861
|
+
scaleCenter: scaleCenter,
|
|
5862
|
+
anchor: anchor,
|
|
5863
|
+
postMatrix: postMatrix
|
|
5864
|
+
} = this.attribute;
|
|
5865
|
+
let _anchor = [0, 0];
|
|
5866
|
+
const params = {};
|
|
5867
|
+
if (anchor && angle && (_anchor = this.getAnchor(anchor, params)), !scaleCenter || 1 === scaleX && 1 === scaleY) normalTransform(this._transMatrix, this._transMatrix.reset(), x, y, scaleX, scaleY, angle, anchor && _anchor);else {
|
|
5868
|
+
const m = this._transMatrix;
|
|
5869
|
+
m.reset(), m.translate(_anchor[0], _anchor[1]), m.rotate(angle), m.translate(-_anchor[0], -_anchor[1]), m.translate(x, y), _anchor = this.getAnchor(scaleCenter, params), application.transformUtil.fromMatrix(m, m).scale(scaleX, scaleY, {
|
|
5870
|
+
x: _anchor[0],
|
|
5871
|
+
y: _anchor[1]
|
|
5872
|
+
});
|
|
5873
|
+
}
|
|
5874
|
+
const p = this.getOffsetXY(DefaultTransform);
|
|
5875
|
+
if (this._transMatrix.e += p.x, this._transMatrix.f += p.y, postMatrix) {
|
|
5876
|
+
const m1 = tempMatrix.setValue(postMatrix.a, postMatrix.b, postMatrix.c, postMatrix.d, postMatrix.e, postMatrix.f),
|
|
5877
|
+
m2 = this._transMatrix;
|
|
5878
|
+
m1.multiply(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f), m2.setValue(m1.a, m1.b, m1.c, m1.d, m1.e, m1.f);
|
|
5879
|
+
}
|
|
5880
|
+
}
|
|
5881
|
+
doUpdateGlobalMatrix() {
|
|
5882
|
+
if (this.parent) {
|
|
5883
|
+
this._globalTransMatrix.multiply(this.transMatrix.a, this.transMatrix.b, this.transMatrix.c, this.transMatrix.d, this.transMatrix.e, this.transMatrix.f);
|
|
5884
|
+
const {
|
|
5885
|
+
scrollX = 0,
|
|
5886
|
+
scrollY = 0
|
|
5887
|
+
} = this.parent.attribute;
|
|
5888
|
+
this._globalTransMatrix.translate(scrollX, scrollY);
|
|
5889
|
+
}
|
|
5890
|
+
}
|
|
5891
|
+
setStage(stage, layer) {
|
|
5892
|
+
if (this.stage !== stage) {
|
|
5893
|
+
if (this.stage = stage, this.layer = layer, this.setStageToShadowRoot(stage, layer), this.animates && this.animates.size) {
|
|
5894
|
+
const timeline = stage.getTimeline();
|
|
5895
|
+
this.animates.forEach(a => {
|
|
5896
|
+
a.timeline === defaultTimeline && a.setTimeline(timeline);
|
|
5897
|
+
});
|
|
5898
|
+
}
|
|
5899
|
+
this._onSetStage && this._onSetStage(this, stage, layer), application.graphicService.onSetStage(this, stage);
|
|
5900
|
+
}
|
|
5901
|
+
}
|
|
5902
|
+
setStageToShadowRoot(stage, layer) {
|
|
5903
|
+
this.shadowRoot && this.shadowRoot.setStage(stage, layer);
|
|
5904
|
+
}
|
|
5905
|
+
onAddStep(step) {}
|
|
5906
|
+
onStop(props) {
|
|
5907
|
+
props && this.setAttributes(props, !1, {
|
|
5908
|
+
type: AttributeUpdateType.ANIMATE_END
|
|
5909
|
+
});
|
|
5910
|
+
}
|
|
5911
|
+
onStep(subAnimate, animate, step, ratio, end) {
|
|
5912
|
+
const nextAttributes = {};
|
|
5913
|
+
if (step.customAnimate) step.customAnimate.update(end, ratio, nextAttributes);else {
|
|
5914
|
+
const nextProps = step.props,
|
|
5915
|
+
nextParsedProps = step.parsedProps,
|
|
5916
|
+
propKeys = step.propKeys;
|
|
5917
|
+
this.stepInterpolate(subAnimate, animate, nextAttributes, step, ratio, end, nextProps, void 0, nextParsedProps, propKeys);
|
|
5918
|
+
}
|
|
5919
|
+
this.setAttributes(nextAttributes, !1, {
|
|
5920
|
+
type: AttributeUpdateType.ANIMATE_UPDATE,
|
|
5921
|
+
animationState: {
|
|
5922
|
+
ratio: ratio,
|
|
5923
|
+
end: end,
|
|
5924
|
+
step: step,
|
|
5925
|
+
isFirstFrameOfStep: subAnimate.getLastStep() !== step
|
|
5926
|
+
}
|
|
5927
|
+
}), this.stage && this.stage.renderNextFrame();
|
|
5928
|
+
}
|
|
5929
|
+
stepInterpolate(subAnimate, animate, nextAttributes, step, ratio, end, nextProps, lastProps, nextParsedProps, propKeys) {
|
|
5930
|
+
propKeys || (propKeys = Object.keys(nextProps), step.propKeys = propKeys), end ? step.propKeys.forEach(key => {
|
|
5931
|
+
animate.validAttr(key) && (nextAttributes[key] = nextProps[key]);
|
|
5932
|
+
}) : propKeys.forEach(key => {
|
|
5933
|
+
var _a;
|
|
5934
|
+
if (!animate.validAttr(key)) return;
|
|
5935
|
+
const nextStepVal = nextProps[key],
|
|
5936
|
+
lastStepVal = null !== (_a = lastProps && lastProps[key]) && void 0 !== _a ? _a : subAnimate.getLastPropByName(key, step);
|
|
5937
|
+
if (null == nextStepVal || null == lastStepVal || nextStepVal === lastStepVal) return void (nextAttributes[key] = nextStepVal);
|
|
5938
|
+
let match;
|
|
5939
|
+
match = animate.interpolateFunc && animate.interpolateFunc(key, ratio, lastStepVal, nextStepVal, nextAttributes), match || (match = animate.customInterpolate(key, ratio, lastStepVal, nextStepVal, this, nextAttributes), match || this.defaultInterpolate(nextStepVal, lastStepVal, key, nextAttributes, nextParsedProps, ratio) || this._interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes));
|
|
5940
|
+
}), step.parsedProps = nextParsedProps;
|
|
5941
|
+
}
|
|
5942
|
+
defaultInterpolate(nextStepVal, lastStepVal, key, nextAttributes, nextParsedProps, ratio) {
|
|
5943
|
+
if (Number.isFinite(nextStepVal) && Number.isFinite(lastStepVal)) return nextAttributes[key] = lastStepVal + (nextStepVal - lastStepVal) * ratio, !0;
|
|
5944
|
+
if ("fill" === key) {
|
|
5945
|
+
nextParsedProps || (nextParsedProps = {});
|
|
5946
|
+
const fillColorArray = nextParsedProps.fillColorArray,
|
|
5947
|
+
color = interpolateColor(lastStepVal, null != fillColorArray ? fillColorArray : nextStepVal, ratio, !1, (fArray, tArray) => {
|
|
5948
|
+
nextParsedProps.fillColorArray = tArray;
|
|
5949
|
+
});
|
|
5950
|
+
return color && (nextAttributes[key] = color), !0;
|
|
5951
|
+
}
|
|
5952
|
+
if ("stroke" === key) {
|
|
5953
|
+
nextParsedProps || (nextParsedProps = {});
|
|
5954
|
+
const strokeColorArray = nextParsedProps.strokeColorArray,
|
|
5955
|
+
color = interpolateColor(lastStepVal, null != strokeColorArray ? strokeColorArray : nextStepVal, ratio, !1, (fArray, tArray) => {
|
|
5956
|
+
nextParsedProps.strokeColorArray = tArray;
|
|
5957
|
+
});
|
|
5958
|
+
return color && (nextAttributes[key] = color), !0;
|
|
5959
|
+
}
|
|
5960
|
+
if ("shadowColor" === key) {
|
|
5961
|
+
nextParsedProps || (nextParsedProps = {});
|
|
5962
|
+
const shadowColorArray = nextParsedProps.shadowColorArray,
|
|
5963
|
+
color = interpolateColor(lastStepVal, null != shadowColorArray ? shadowColorArray : nextStepVal, ratio, !0, (fArray, tArray) => {
|
|
5964
|
+
nextParsedProps.shadowColorArray = tArray;
|
|
5965
|
+
});
|
|
5966
|
+
return color && (nextAttributes[key] = color), !0;
|
|
5967
|
+
}
|
|
5968
|
+
if (Array.isArray(nextStepVal) && nextStepVal.length === lastStepVal.length) {
|
|
5969
|
+
const nextList = [];
|
|
5970
|
+
let valid = !0;
|
|
5971
|
+
for (let i = 0; i < nextStepVal.length; i++) {
|
|
5972
|
+
const v = lastStepVal[i],
|
|
5973
|
+
val = v + (nextStepVal[i] - v) * ratio;
|
|
5974
|
+
if (!Number.isFinite(val)) {
|
|
5975
|
+
valid = !1;
|
|
5976
|
+
break;
|
|
5977
|
+
}
|
|
5978
|
+
nextList.push(val);
|
|
5979
|
+
}
|
|
5980
|
+
valid && (nextAttributes[key] = nextList);
|
|
5981
|
+
}
|
|
5982
|
+
return !1;
|
|
5983
|
+
}
|
|
5984
|
+
_interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {}
|
|
5985
|
+
getDefaultAttribute(name) {
|
|
5986
|
+
return this.getGraphicTheme()[name];
|
|
5987
|
+
}
|
|
5988
|
+
getComputedAttribute(name) {
|
|
5989
|
+
var _a;
|
|
5990
|
+
return null !== (_a = this.attribute[name]) && void 0 !== _a ? _a : this.getDefaultAttribute(name);
|
|
5991
|
+
}
|
|
5992
|
+
onSetStage(cb) {
|
|
5993
|
+
let immediate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
5994
|
+
this._onSetStage = cb, immediate && this.stage && cb(this, this.stage);
|
|
5995
|
+
}
|
|
5996
|
+
attachShadow(shadowRoot) {
|
|
5997
|
+
return shadowRoot && (shadowRoot.shadowHost = this), this.shadowRoot = null != shadowRoot ? shadowRoot : application.graphicService.creator.shadowRoot(this), this.addUpdateBoundTag(), this.shadowRoot.setStage(this.stage, this.layer), this.shadowRoot;
|
|
5998
|
+
}
|
|
5999
|
+
detachShadow() {
|
|
6000
|
+
this.shadowRoot && (this.addUpdateBoundTag(), this.shadowRoot.release(!0), this.shadowRoot = null);
|
|
6001
|
+
}
|
|
6002
|
+
toJson() {
|
|
6003
|
+
return {
|
|
6004
|
+
attribute: this.attribute,
|
|
6005
|
+
_uid: this._uid,
|
|
6006
|
+
type: this.type,
|
|
6007
|
+
name: this.name,
|
|
6008
|
+
children: this.children.map(item => item.toJson())
|
|
6009
|
+
};
|
|
6010
|
+
}
|
|
6011
|
+
createPathProxy(path) {
|
|
6012
|
+
return isString$1(path, !0) ? this.pathProxy = new CustomPath2D().fromString(path) : this.pathProxy = new CustomPath2D(), this.pathProxy;
|
|
6013
|
+
}
|
|
6014
|
+
loadImage(image) {
|
|
6015
|
+
let background = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
6016
|
+
if (!image || background && backgroundNotImage(image)) return;
|
|
6017
|
+
const url = image;
|
|
6018
|
+
this.resources || (this.resources = new Map());
|
|
6019
|
+
const cache = {
|
|
6020
|
+
data: "init",
|
|
6021
|
+
state: null
|
|
6022
|
+
};
|
|
6023
|
+
this.resources.set(url, cache), "string" == typeof image ? (cache.state = "loading", image.startsWith("<svg") ? (ResourceLoader.GetSvg(image, this), this.backgroundImg = this.backgroundImg || background) : (isValidUrl$1(image) || image.includes("/") || isBase64$1(image)) && (ResourceLoader.GetImage(image, this), this.backgroundImg = this.backgroundImg || background)) : isObject$1(image) ? (cache.state = "success", cache.data = image, this.backgroundImg = this.backgroundImg || background) : cache.state = "fail";
|
|
6024
|
+
}
|
|
6025
|
+
setShadowGraphic(graphic) {
|
|
6026
|
+
if (graphic) {
|
|
6027
|
+
this.attachShadow().add(graphic);
|
|
6028
|
+
} else this.detachShadow();
|
|
6029
|
+
}
|
|
6030
|
+
imageLoadSuccess(url, image, cb) {
|
|
6031
|
+
if (!this.resources) return;
|
|
6032
|
+
const res = this.resources.get(url);
|
|
6033
|
+
res && (res.state = "success", res.data = image, cb && cb(), this.addUpdateBoundTag(), this.stage && this.stage.renderNextFrame());
|
|
6034
|
+
}
|
|
6035
|
+
imageLoadFail(url, cb) {
|
|
6036
|
+
if (!this.resources) return;
|
|
6037
|
+
const res = this.resources.get(url);
|
|
6038
|
+
res && (res.state = "fail", cb && cb());
|
|
6039
|
+
}
|
|
6040
|
+
_stopAnimates(animates) {
|
|
6041
|
+
animates && animates.forEach(animate => {
|
|
6042
|
+
animate.stop();
|
|
6043
|
+
});
|
|
6044
|
+
}
|
|
6045
|
+
stopAnimates() {
|
|
6046
|
+
let stopChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
|
|
6047
|
+
this._stopAnimates(this.animates), this.shadowRoot && this.shadowRoot.stopAnimates(!0), this.isContainer && stopChildren && this.forEachChildren(c => {
|
|
6048
|
+
c.stopAnimates(stopChildren);
|
|
6049
|
+
});
|
|
6050
|
+
}
|
|
6051
|
+
release() {
|
|
6052
|
+
this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this);
|
|
6053
|
+
}
|
|
6054
|
+
_emitCustomEvent(type, context) {
|
|
6055
|
+
var _a, _b;
|
|
6056
|
+
if (this._events && type in this._events) {
|
|
6057
|
+
const changeEvent = new CustomEvent(type, context);
|
|
6058
|
+
changeEvent.bubbles = !1, changeEvent.manager = null === (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem) || void 0 === _b ? void 0 : _b.manager, this.dispatchEvent(changeEvent);
|
|
6059
|
+
}
|
|
6060
|
+
}
|
|
6061
|
+
}
|
|
6062
|
+
function backgroundNotImage(image) {
|
|
6063
|
+
return !(!image.fill && !image.stroke);
|
|
6064
|
+
}
|
|
6065
|
+
Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
|
|
6066
|
+
|
|
6067
|
+
const updateBoundsOfCommonOuterBorder = (attribute, theme, aabbBounds) => {
|
|
6068
|
+
const {
|
|
6069
|
+
outerBorder: outerBorder,
|
|
6070
|
+
shadowBlur = theme.shadowBlur
|
|
6071
|
+
} = attribute;
|
|
6072
|
+
if (outerBorder) {
|
|
6073
|
+
const defaultOuterBorder = theme.outerBorder,
|
|
6074
|
+
{
|
|
6075
|
+
distance = defaultOuterBorder.distance,
|
|
6076
|
+
lineWidth = defaultOuterBorder.lineWidth
|
|
6077
|
+
} = outerBorder;
|
|
6078
|
+
aabbBounds.expand(distance + (shadowBlur + lineWidth) / 2);
|
|
6079
|
+
}
|
|
6080
|
+
return aabbBounds;
|
|
6081
|
+
};
|
|
6082
|
+
|
|
6083
|
+
const RECT_UPDATE_TAG_KEY = ["width", "x1", "y1", "height", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
6084
|
+
class Rect extends Graphic {
|
|
6085
|
+
constructor(params) {
|
|
6086
|
+
super(params), this.type = "rect", this.numberType = RECT_NUMBER_TYPE;
|
|
6087
|
+
}
|
|
6088
|
+
isValid() {
|
|
6089
|
+
return super.isValid() && this._isValid();
|
|
6090
|
+
}
|
|
6091
|
+
_isValid() {
|
|
6092
|
+
return !0;
|
|
6093
|
+
}
|
|
6094
|
+
getGraphicTheme() {
|
|
6095
|
+
return getTheme(this).rect;
|
|
6096
|
+
}
|
|
6097
|
+
updateAABBBounds(attribute, rectTheme, aabbBounds) {
|
|
6098
|
+
if (!this.updatePathProxyAABBBounds(aabbBounds)) {
|
|
6099
|
+
let {
|
|
6100
|
+
width: width,
|
|
6101
|
+
height: height
|
|
6102
|
+
} = attribute;
|
|
6103
|
+
const {
|
|
6104
|
+
x1: x1,
|
|
6105
|
+
y1: y1,
|
|
6106
|
+
x: x,
|
|
6107
|
+
y: y
|
|
6108
|
+
} = attribute;
|
|
6109
|
+
width = null != width ? width : x1 - x, height = null != height ? height : y1 - y, (isFinite(width) || isFinite(height) || isFinite(x) || isFinite(y)) && aabbBounds.set(0, 0, width || 0, height || 0);
|
|
6110
|
+
}
|
|
6111
|
+
const {
|
|
6112
|
+
tb1: tb1,
|
|
6113
|
+
tb2: tb2
|
|
6114
|
+
} = application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
6115
|
+
return updateBoundsOfCommonOuterBorder(attribute, rectTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, rectTheme, !1, this), aabbBounds;
|
|
6116
|
+
}
|
|
6117
|
+
needUpdateTags(keys) {
|
|
6118
|
+
return super.needUpdateTags(keys, RECT_UPDATE_TAG_KEY);
|
|
6119
|
+
}
|
|
6120
|
+
needUpdateTag(key) {
|
|
6121
|
+
return super.needUpdateTag(key, RECT_UPDATE_TAG_KEY);
|
|
6122
|
+
}
|
|
6123
|
+
toCustomPath() {
|
|
6124
|
+
const attribute = this.attribute,
|
|
6125
|
+
{
|
|
6126
|
+
x: x,
|
|
6127
|
+
y: y,
|
|
6128
|
+
width: width,
|
|
6129
|
+
height: height
|
|
6130
|
+
} = normalizeRectAttributes(attribute),
|
|
6131
|
+
path = new CustomPath2D();
|
|
6132
|
+
return path.moveTo(x, y), path.rect(x, y, width, height), path;
|
|
6133
|
+
}
|
|
6134
|
+
clone() {
|
|
6135
|
+
return new Rect(Object.assign({}, this.attribute));
|
|
6136
|
+
}
|
|
6137
|
+
getNoWorkAnimateAttr() {
|
|
6138
|
+
return Rect.NOWORK_ANIMATE_ATTR;
|
|
6139
|
+
}
|
|
6140
|
+
}
|
|
6141
|
+
Rect.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
6142
|
+
function createRect(attributes) {
|
|
6143
|
+
return new Rect(attributes);
|
|
6144
|
+
}
|
|
6145
|
+
|
|
6146
|
+
function isSameRange$2(range1, range2) {
|
|
6147
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6148
|
+
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);
|
|
6149
|
+
}
|
|
6150
|
+
|
|
6151
|
+
const isNode = "undefined" == typeof window || void 0 === window.window;
|
|
6152
|
+
function analyzeUserAgent() {
|
|
6153
|
+
if (isNode) return {
|
|
6154
|
+
IE: !1,
|
|
6155
|
+
Edge: !1,
|
|
6156
|
+
Chrome: !1,
|
|
6157
|
+
Firefox: !1,
|
|
6158
|
+
Safari: !1
|
|
6159
|
+
};
|
|
6160
|
+
const ua = window.navigator.userAgent.toLowerCase();
|
|
6161
|
+
return {
|
|
6162
|
+
IE: !!/(msie|trident)/.exec(ua),
|
|
6163
|
+
Edge: ua.indexOf("edge") > -1,
|
|
6164
|
+
Chrome: ua.indexOf("chrome") > -1 && -1 === ua.indexOf("edge"),
|
|
6165
|
+
Firefox: ua.indexOf("firefox") > -1,
|
|
6166
|
+
Safari: ua.indexOf("safari") > -1 && -1 === ua.indexOf("edge")
|
|
6167
|
+
};
|
|
6168
|
+
}
|
|
6169
|
+
analyzeUserAgent();
|
|
6170
|
+
function cellInRange(range, col, row) {
|
|
6171
|
+
return range.start.col <= col && col <= range.end.col && range.start.row <= row && row <= range.end.row || range.end.col <= col && col <= range.start.col && range.end.row <= row && row <= range.start.row || range.end.col <= col && col <= range.start.col && range.start.row <= row && row <= range.end.row || range.start.col <= col && col <= range.end.col && range.end.row <= row && row <= range.start.row;
|
|
6172
|
+
}
|
|
6173
|
+
|
|
6174
|
+
class InvertHighlightPlugin {
|
|
6175
|
+
table;
|
|
6176
|
+
range;
|
|
6177
|
+
_fill;
|
|
6178
|
+
_opacity;
|
|
6179
|
+
constructor(table, options) {
|
|
6180
|
+
this.table = table;
|
|
6181
|
+
this._fill = options?.fill ?? '#000';
|
|
6182
|
+
this._opacity = options?.opacity ?? 0.5;
|
|
6183
|
+
}
|
|
6184
|
+
setInvertHighlightRange(range) {
|
|
6185
|
+
if (isSameRange$2(this.range, range)) {
|
|
6186
|
+
return;
|
|
6187
|
+
}
|
|
6188
|
+
this.range = range;
|
|
6189
|
+
if (!range) {
|
|
6190
|
+
this.deleteAllCellGroupShadow();
|
|
6191
|
+
}
|
|
6192
|
+
else {
|
|
6193
|
+
this.updateCellGroupShadow();
|
|
6194
|
+
}
|
|
6195
|
+
this.table.scenegraph.updateNextFrame();
|
|
6196
|
+
}
|
|
6197
|
+
deleteAllCellGroupShadow() {
|
|
6198
|
+
if (!this.table.isPivotTable()) {
|
|
6199
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup);
|
|
6200
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup);
|
|
6201
|
+
}
|
|
6202
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup);
|
|
6203
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup);
|
|
6204
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup);
|
|
6205
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup);
|
|
6206
|
+
}
|
|
6207
|
+
updateCellGroupShadow() {
|
|
6208
|
+
if (!this.table.isPivotTable()) {
|
|
6209
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup, this.range);
|
|
6210
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup, this.range);
|
|
6211
|
+
}
|
|
6212
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup, this.range);
|
|
6213
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup, this.range);
|
|
6214
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup), this.range;
|
|
6215
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup, this.range);
|
|
6216
|
+
}
|
|
6217
|
+
updateCellGroupShadowInContainer(container, range) {
|
|
6218
|
+
container.forEachChildrenSkipChild((item) => {
|
|
6219
|
+
const column = item;
|
|
6220
|
+
if (column.role === 'column') {
|
|
6221
|
+
column.forEachChildrenSkipChild((item) => {
|
|
6222
|
+
const cell = item;
|
|
6223
|
+
if (cell.role !== 'cell') {
|
|
6224
|
+
return;
|
|
6225
|
+
}
|
|
6226
|
+
cell.attachShadow(cell.shadowRoot);
|
|
6227
|
+
const shadowGroup = cell.shadowRoot;
|
|
6228
|
+
if (!range) {
|
|
6229
|
+
shadowGroup.removeAllChild();
|
|
6230
|
+
}
|
|
6231
|
+
else if (cellInRange(range, cell.col, cell.row)) {
|
|
6232
|
+
shadowGroup.removeAllChild();
|
|
6233
|
+
}
|
|
6234
|
+
else if (!shadowGroup.firstChild) {
|
|
6235
|
+
const shadowRect = createRect({
|
|
6236
|
+
x: 0,
|
|
6237
|
+
y: 0,
|
|
6238
|
+
width: cell.attribute.width,
|
|
6239
|
+
height: cell.attribute.height,
|
|
6240
|
+
fill: this._fill,
|
|
6241
|
+
opacity: this._opacity
|
|
6242
|
+
});
|
|
6243
|
+
shadowRect.name = 'shadow-rect';
|
|
6244
|
+
shadowGroup.appendChild(shadowRect);
|
|
6245
|
+
}
|
|
6246
|
+
});
|
|
6247
|
+
}
|
|
6248
|
+
});
|
|
6249
|
+
}
|
|
6250
|
+
}
|
|
6251
|
+
|
|
6252
|
+
class HeaderHighlightPlugin {
|
|
6253
|
+
table;
|
|
6254
|
+
options;
|
|
6255
|
+
colHeaderRange;
|
|
6256
|
+
rowHeaderRange;
|
|
6257
|
+
constructor(table, options) {
|
|
6258
|
+
this.table = table;
|
|
6259
|
+
this.options = options;
|
|
6260
|
+
this.registerStyle();
|
|
6261
|
+
this.bindEvent();
|
|
6262
|
+
}
|
|
6263
|
+
registerStyle() {
|
|
6264
|
+
this.table.registerCustomCellStyle('col-highlight', {
|
|
6265
|
+
bgColor: this.options?.colHighlightBGColor ?? '#82b2f5',
|
|
6266
|
+
color: this.options?.colHighlightColor ?? '#FFF'
|
|
6267
|
+
});
|
|
6268
|
+
this.table.registerCustomCellStyle('row-highlight', {
|
|
6269
|
+
bgColor: this.options?.rowHighlightBGColor ?? '#82b2f5',
|
|
6270
|
+
color: this.options?.rowHighlightColor ?? '#FFF'
|
|
6271
|
+
});
|
|
6272
|
+
}
|
|
6273
|
+
bindEvent() {
|
|
6274
|
+
this.table.on('selected_cell', () => {
|
|
6275
|
+
this.updateHighlight();
|
|
6276
|
+
});
|
|
6277
|
+
this.table.on('selected_clear', () => {
|
|
6278
|
+
this.clearHighlight();
|
|
6279
|
+
});
|
|
6280
|
+
this.table.on('mousemove_table', () => {
|
|
6281
|
+
if (this.table.stateManager.select.selecting) {
|
|
6282
|
+
this.updateHighlight();
|
|
6283
|
+
}
|
|
6284
|
+
});
|
|
6285
|
+
}
|
|
6286
|
+
clearHighlight() {
|
|
6287
|
+
this.colHeaderRange && this.table.arrangeCustomCellStyle({ range: this.colHeaderRange }, undefined, true);
|
|
6288
|
+
this.rowHeaderRange && this.table.arrangeCustomCellStyle({ range: this.rowHeaderRange }, undefined, true);
|
|
6289
|
+
this.colHeaderRange = undefined;
|
|
6290
|
+
this.rowHeaderRange = undefined;
|
|
6291
|
+
}
|
|
6292
|
+
updateHighlight() {
|
|
6293
|
+
if (this.options?.colHighlight === false && this.options?.rowHighlight === false) {
|
|
6294
|
+
return;
|
|
6295
|
+
}
|
|
6296
|
+
const selectRanges = this.table.getSelectedCellRanges();
|
|
6297
|
+
if (selectRanges.length === 0) {
|
|
6298
|
+
this.clearHighlight();
|
|
6299
|
+
return;
|
|
6300
|
+
}
|
|
6301
|
+
const selectRange = selectRanges[0];
|
|
6302
|
+
const rowSelectRange = [selectRange.start.row, selectRange.end.row];
|
|
6303
|
+
rowSelectRange.sort((a, b) => a - b);
|
|
6304
|
+
const colSelectRange = [selectRange.start.col, selectRange.end.col];
|
|
6305
|
+
colSelectRange.sort((a, b) => a - b);
|
|
6306
|
+
let colHeaderRange;
|
|
6307
|
+
let rowHeaderRange;
|
|
6308
|
+
if (this.table.isPivotTable()) {
|
|
6309
|
+
colHeaderRange = {
|
|
6310
|
+
start: {
|
|
6311
|
+
col: colSelectRange[0],
|
|
6312
|
+
row: 0
|
|
6313
|
+
},
|
|
6314
|
+
end: {
|
|
6315
|
+
col: colSelectRange[1],
|
|
6316
|
+
row: this.table.columnHeaderLevelCount - 1
|
|
6317
|
+
}
|
|
6318
|
+
};
|
|
6319
|
+
rowHeaderRange = {
|
|
6320
|
+
start: {
|
|
6321
|
+
col: 0,
|
|
6322
|
+
row: rowSelectRange[0]
|
|
6323
|
+
},
|
|
6324
|
+
end: {
|
|
6325
|
+
col: this.table.rowHeaderLevelCount - 1,
|
|
6326
|
+
row: rowSelectRange[1]
|
|
6327
|
+
}
|
|
6328
|
+
};
|
|
6329
|
+
}
|
|
6330
|
+
else if (this.table.internalProps.transpose) {
|
|
6331
|
+
rowHeaderRange = {
|
|
6332
|
+
start: {
|
|
6333
|
+
col: 0,
|
|
6334
|
+
row: rowSelectRange[0]
|
|
6335
|
+
},
|
|
6336
|
+
end: {
|
|
6337
|
+
col: this.table.rowHeaderLevelCount - 1,
|
|
6338
|
+
row: rowSelectRange[1]
|
|
6339
|
+
}
|
|
6340
|
+
};
|
|
6341
|
+
}
|
|
6342
|
+
else {
|
|
6343
|
+
colHeaderRange = {
|
|
6344
|
+
start: {
|
|
6345
|
+
col: colSelectRange[0],
|
|
6346
|
+
row: 0
|
|
6347
|
+
},
|
|
6348
|
+
end: {
|
|
6349
|
+
col: colSelectRange[1],
|
|
6350
|
+
row: this.table.columnHeaderLevelCount - 1
|
|
6351
|
+
}
|
|
6352
|
+
};
|
|
6353
|
+
if (this.table.internalProps.rowSeriesNumber) {
|
|
6354
|
+
rowHeaderRange = {
|
|
6355
|
+
start: {
|
|
6356
|
+
col: 0,
|
|
6357
|
+
row: rowSelectRange[0]
|
|
6358
|
+
},
|
|
6359
|
+
end: {
|
|
6360
|
+
col: 0,
|
|
6361
|
+
row: rowSelectRange[1]
|
|
6362
|
+
}
|
|
6363
|
+
};
|
|
6364
|
+
}
|
|
6365
|
+
}
|
|
6366
|
+
if (this.options?.colHighlight !== false && !isSameRange$1(this.colHeaderRange, colHeaderRange)) {
|
|
6367
|
+
this.colHeaderRange && this.table.arrangeCustomCellStyle({ range: this.colHeaderRange }, undefined);
|
|
6368
|
+
colHeaderRange && this.table.arrangeCustomCellStyle({ range: colHeaderRange }, 'col-highlight');
|
|
6369
|
+
this.colHeaderRange = colHeaderRange;
|
|
6370
|
+
}
|
|
6371
|
+
if (this.options?.rowHighlight !== false && !isSameRange$1(this.rowHeaderRange, rowHeaderRange)) {
|
|
6372
|
+
this.rowHeaderRange && this.table.arrangeCustomCellStyle({ range: this.rowHeaderRange }, undefined);
|
|
6373
|
+
rowHeaderRange && this.table.arrangeCustomCellStyle({ range: rowHeaderRange }, 'row-highlight');
|
|
6374
|
+
this.rowHeaderRange = rowHeaderRange;
|
|
6375
|
+
}
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
function isSameRange$1(a, b) {
|
|
6379
|
+
if (a === undefined && b === undefined) {
|
|
6380
|
+
return true;
|
|
6381
|
+
}
|
|
6382
|
+
if (a === undefined || b === undefined) {
|
|
6383
|
+
return false;
|
|
6384
|
+
}
|
|
6385
|
+
return (a.start.col === b.start.col && a.start.row === b.start.row && a.end.col === b.end.col && a.end.row === b.end.row);
|
|
6386
|
+
}
|
|
6387
|
+
|
|
6388
|
+
class AddRowColumnPlugin {
|
|
6389
|
+
id = 'add-row-column';
|
|
6390
|
+
runTime = [
|
|
6391
|
+
VTable__namespace.TABLE_EVENT_TYPE.MOUSEENTER_CELL,
|
|
6392
|
+
VTable__namespace.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,
|
|
6393
|
+
VTable__namespace.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE
|
|
6394
|
+
];
|
|
6395
|
+
pluginOptions;
|
|
6396
|
+
table;
|
|
6397
|
+
hoverCell;
|
|
6398
|
+
hideAllTimeoutId_addColumn;
|
|
6399
|
+
hideAllTimeoutId_addRow;
|
|
6400
|
+
leftDotForAddColumn;
|
|
6401
|
+
rightDotForAddColumn;
|
|
6402
|
+
addIconForAddColumn;
|
|
6403
|
+
addLineForAddColumn;
|
|
6404
|
+
topDotForAddRow;
|
|
6405
|
+
bottomDotForAddRow;
|
|
6406
|
+
addIconForAddRow;
|
|
6407
|
+
addLineForAddRow;
|
|
6408
|
+
constructor(pluginOptions = {
|
|
6409
|
+
addColumnEnable: true,
|
|
6410
|
+
addRowEnable: true
|
|
6411
|
+
}) {
|
|
6412
|
+
this.pluginOptions = pluginOptions;
|
|
6413
|
+
this.pluginOptions.addColumnEnable = this.pluginOptions.addColumnEnable ?? true;
|
|
6414
|
+
this.pluginOptions.addRowEnable = this.pluginOptions.addRowEnable ?? true;
|
|
6415
|
+
if (this.pluginOptions.addColumnEnable) {
|
|
6416
|
+
this.initAddColumnDomElement();
|
|
6417
|
+
this.bindEventForAddColumn();
|
|
6418
|
+
}
|
|
6419
|
+
if (this.pluginOptions.addRowEnable) {
|
|
6420
|
+
this.initAddRowDomElement();
|
|
6421
|
+
this.bindEventForAddRow();
|
|
6422
|
+
}
|
|
6423
|
+
}
|
|
6424
|
+
run(...args) {
|
|
6425
|
+
const eventArgs = args[0];
|
|
6426
|
+
const runTime = args[1];
|
|
6427
|
+
const table = args[2];
|
|
6428
|
+
this.table = table;
|
|
6429
|
+
if (runTime === VTable__namespace.TABLE_EVENT_TYPE.MOUSEENTER_CELL) {
|
|
6430
|
+
clearTimeout(this.hideAllTimeoutId_addColumn);
|
|
6431
|
+
clearTimeout(this.hideAllTimeoutId_addRow);
|
|
6432
|
+
const canvasBounds = table.canvas.getBoundingClientRect();
|
|
6433
|
+
const cell = table.getCellAtRelativePosition(eventArgs.event.clientX - canvasBounds.left, eventArgs.event.clientY - canvasBounds.top);
|
|
6434
|
+
this.hoverCell = cell;
|
|
6435
|
+
const cellRect = table.getCellRelativeRect(cell.col, cell.row);
|
|
6436
|
+
if (this.pluginOptions.addColumnEnable) {
|
|
6437
|
+
const isRowSerierNumberCol = table.isSeriesNumber(cell.col, 0);
|
|
6438
|
+
this.showDotForAddColumn(canvasBounds.top - 6, cellRect.left + canvasBounds.left, cellRect.right + canvasBounds.left, !isRowSerierNumberCol);
|
|
6439
|
+
}
|
|
6440
|
+
if (this.pluginOptions.addRowEnable) {
|
|
6441
|
+
const isHeader = table.isHeader(cell.col, cell.row);
|
|
6442
|
+
this.showDotForAddRow(cellRect.top + canvasBounds.top, canvasBounds.left - 6, cellRect.bottom + canvasBounds.top, !isHeader, !isHeader);
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
else if (runTime === VTable__namespace.TABLE_EVENT_TYPE.MOUSELEAVE_CELL) ;
|
|
6446
|
+
else if (runTime === VTable__namespace.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE) {
|
|
6447
|
+
if (this.pluginOptions.addColumnEnable) {
|
|
6448
|
+
this.delayHideAllForAddColumn();
|
|
6449
|
+
}
|
|
6450
|
+
if (this.pluginOptions.addRowEnable) {
|
|
6451
|
+
this.delayHideAllForAddRow();
|
|
6452
|
+
}
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
initAddColumnDomElement() {
|
|
6456
|
+
this.leftDotForAddColumn = document.createElement('div');
|
|
6457
|
+
this.leftDotForAddColumn.style.width = '6px';
|
|
6458
|
+
this.leftDotForAddColumn.style.height = '6px';
|
|
6459
|
+
this.leftDotForAddColumn.style.backgroundColor = '#4A90E2';
|
|
6460
|
+
this.leftDotForAddColumn.style.position = 'absolute';
|
|
6461
|
+
this.leftDotForAddColumn.style.cursor = 'pointer';
|
|
6462
|
+
this.leftDotForAddColumn.style.zIndex = '1000';
|
|
6463
|
+
this.leftDotForAddColumn.style.borderRadius = '50%';
|
|
6464
|
+
this.leftDotForAddColumn.style.border = '1px solid white';
|
|
6465
|
+
this.leftDotForAddColumn.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
|
|
6466
|
+
document.body.appendChild(this.leftDotForAddColumn);
|
|
6467
|
+
this.rightDotForAddColumn = document.createElement('div');
|
|
6468
|
+
this.rightDotForAddColumn.style.width = '6px';
|
|
6469
|
+
this.rightDotForAddColumn.style.height = '6px';
|
|
6470
|
+
this.rightDotForAddColumn.style.backgroundColor = '#4A90E2';
|
|
6471
|
+
this.rightDotForAddColumn.style.position = 'absolute';
|
|
6472
|
+
this.rightDotForAddColumn.style.cursor = 'pointer';
|
|
6473
|
+
this.rightDotForAddColumn.style.zIndex = '1000';
|
|
6474
|
+
this.rightDotForAddColumn.style.borderRadius = '50%';
|
|
6475
|
+
this.rightDotForAddColumn.style.border = '1px solid white';
|
|
6476
|
+
this.rightDotForAddColumn.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
|
|
6477
|
+
document.body.appendChild(this.rightDotForAddColumn);
|
|
6478
|
+
this.addIconForAddColumn = document.createElement('div');
|
|
6479
|
+
this.addIconForAddColumn.style.width = '18px';
|
|
6480
|
+
this.addIconForAddColumn.style.height = '18px';
|
|
6481
|
+
this.addIconForAddColumn.style.backgroundColor = '#4A90E2';
|
|
6482
|
+
this.addIconForAddColumn.style.position = 'absolute';
|
|
6483
|
+
this.addIconForAddColumn.style.zIndex = '1001';
|
|
6484
|
+
this.addIconForAddColumn.style.display = 'none';
|
|
6485
|
+
this.addIconForAddColumn.style.borderRadius = '50%';
|
|
6486
|
+
this.addIconForAddColumn.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
|
|
6487
|
+
this.addIconForAddColumn.style.display = 'flex';
|
|
6488
|
+
this.addIconForAddColumn.style.justifyContent = 'center';
|
|
6489
|
+
this.addIconForAddColumn.style.alignItems = 'center';
|
|
6490
|
+
this.addIconForAddColumn.style.border = '1px solid white';
|
|
6491
|
+
document.body.appendChild(this.addIconForAddColumn);
|
|
6492
|
+
const addIconText = document.createElement('div');
|
|
6493
|
+
addIconText.textContent = '+';
|
|
6494
|
+
addIconText.style.color = 'white';
|
|
6495
|
+
addIconText.style.fontSize = '18px';
|
|
6496
|
+
addIconText.style.fontWeight = 'bold';
|
|
6497
|
+
addIconText.style.lineHeight = '15px';
|
|
6498
|
+
addIconText.style.userSelect = 'none';
|
|
6499
|
+
addIconText.style.cursor = 'pointer';
|
|
6500
|
+
addIconText.style.verticalAlign = 'top';
|
|
6501
|
+
addIconText.style.textAlign = 'center';
|
|
6502
|
+
this.addIconForAddColumn.appendChild(addIconText);
|
|
6503
|
+
this.addLineForAddColumn = document.createElement('div');
|
|
6504
|
+
this.addLineForAddColumn.style.width = '2px';
|
|
6505
|
+
this.addLineForAddColumn.style.height = '10px';
|
|
6506
|
+
this.addLineForAddColumn.style.backgroundColor = '#4A90E2';
|
|
6507
|
+
this.addLineForAddColumn.style.position = 'absolute';
|
|
6508
|
+
this.addLineForAddColumn.style.zIndex = '1001';
|
|
6509
|
+
this.addLineForAddColumn.style.display = 'none';
|
|
6510
|
+
document.body.appendChild(this.addLineForAddColumn);
|
|
6511
|
+
}
|
|
6512
|
+
bindEventForAddColumn() {
|
|
6513
|
+
this.leftDotForAddColumn.addEventListener('mouseenter', () => {
|
|
6514
|
+
clearTimeout(this.hideAllTimeoutId_addColumn);
|
|
6515
|
+
this.addIconForAddColumn.style.display = 'block';
|
|
6516
|
+
const dotWidth = this.leftDotForAddColumn.offsetWidth;
|
|
6517
|
+
const dotHeight = this.leftDotForAddColumn.offsetHeight;
|
|
6518
|
+
this.showAddIconForAddColumn(this.leftDotForAddColumn.offsetLeft + dotWidth / 2, this.leftDotForAddColumn.offsetTop + dotHeight / 2, true);
|
|
6519
|
+
this.showSplitLineForAddColumn(this.leftDotForAddColumn.offsetLeft + dotWidth / 2 - 1, this.leftDotForAddColumn.offsetTop + dotHeight / 2 + 2, this.table.getDrawRange().height);
|
|
6520
|
+
});
|
|
6521
|
+
this.rightDotForAddColumn.addEventListener('mouseenter', () => {
|
|
6522
|
+
clearTimeout(this.hideAllTimeoutId_addColumn);
|
|
6523
|
+
this.addIconForAddColumn.style.display = 'block';
|
|
6524
|
+
const dotWidth = this.rightDotForAddColumn.offsetWidth;
|
|
6525
|
+
const dotHeight = this.rightDotForAddColumn.offsetHeight;
|
|
6526
|
+
this.showAddIconForAddColumn(this.rightDotForAddColumn.offsetLeft + dotWidth / 2, this.rightDotForAddColumn.offsetTop + dotHeight / 2, false);
|
|
6527
|
+
this.showSplitLineForAddColumn(this.rightDotForAddColumn.offsetLeft + dotWidth / 2 - 1, this.rightDotForAddColumn.offsetTop + dotHeight / 2 + 2, this.table.getDrawRange().height);
|
|
6528
|
+
});
|
|
6529
|
+
this.addIconForAddColumn.addEventListener('mouseleave', () => {
|
|
6530
|
+
this.addIconForAddColumn.style.display = 'none';
|
|
6531
|
+
this.addLineForAddColumn.style.display = 'none';
|
|
6532
|
+
this.delayHideAllForAddColumn();
|
|
6533
|
+
});
|
|
6534
|
+
this.addIconForAddColumn.addEventListener('click', (e) => {
|
|
6535
|
+
const isLeft = this.addIconForAddColumn.dataset.addIconType === 'left';
|
|
6536
|
+
const columns = this.table.options.columns;
|
|
6537
|
+
const col = this.hoverCell.col;
|
|
6538
|
+
const addColIndex = isLeft ? col : col + 1;
|
|
6539
|
+
if (this.pluginOptions.addColumnCallback) {
|
|
6540
|
+
this.pluginOptions.addColumnCallback(addColIndex);
|
|
6541
|
+
}
|
|
6542
|
+
else {
|
|
6543
|
+
columns.splice(addColIndex, 0, {
|
|
6544
|
+
field: ``,
|
|
6545
|
+
title: `New Column ${col}`,
|
|
6546
|
+
width: 100
|
|
6547
|
+
});
|
|
6548
|
+
this.table.updateColumns(columns);
|
|
6549
|
+
}
|
|
6550
|
+
this.delayHideAllForAddColumn(0);
|
|
6551
|
+
});
|
|
6552
|
+
}
|
|
6553
|
+
showDotForAddColumn(top, left, right, isShowLeft = true, isShowRight = true) {
|
|
6554
|
+
const dotWidth = this.leftDotForAddColumn.offsetWidth;
|
|
6555
|
+
const dotHeight = this.leftDotForAddColumn.offsetHeight;
|
|
6556
|
+
this.leftDotForAddColumn.style.left = `${left - dotWidth / 2}px`;
|
|
6557
|
+
this.leftDotForAddColumn.style.top = `${top - dotHeight / 2}px`;
|
|
6558
|
+
this.rightDotForAddColumn.style.left = `${right - dotWidth / 2}px`;
|
|
6559
|
+
this.rightDotForAddColumn.style.top = `${top - dotHeight / 2}px`;
|
|
6560
|
+
this.leftDotForAddColumn.style.display = isShowLeft ? 'block' : 'none';
|
|
6561
|
+
this.rightDotForAddColumn.style.display = isShowRight ? 'block' : 'none';
|
|
6562
|
+
}
|
|
6563
|
+
showAddIconForAddColumn(left, top, isLeft) {
|
|
6564
|
+
const iconWidth = this.addIconForAddColumn.offsetWidth;
|
|
6565
|
+
const iconHeight = this.addIconForAddColumn.offsetHeight;
|
|
6566
|
+
const dotHeight = this.leftDotForAddColumn.offsetHeight;
|
|
6567
|
+
this.addIconForAddColumn.style.left = `${left - iconWidth / 2}px`;
|
|
6568
|
+
this.addIconForAddColumn.style.top = `${top - iconHeight / 2 - dotHeight / 2}px`;
|
|
6569
|
+
if (isLeft) {
|
|
6570
|
+
this.addIconForAddColumn.dataset.addIconType = 'left';
|
|
6571
|
+
}
|
|
6572
|
+
else {
|
|
6573
|
+
this.addIconForAddColumn.dataset.addIconType = 'right';
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
showSplitLineForAddColumn(left, top, height) {
|
|
6577
|
+
this.addLineForAddColumn.style.left = `${left}px`;
|
|
6578
|
+
this.addLineForAddColumn.style.top = `${top}px`;
|
|
6579
|
+
this.addLineForAddColumn.style.height = `${height}px`;
|
|
6580
|
+
this.addLineForAddColumn.style.display = 'block';
|
|
6581
|
+
}
|
|
6582
|
+
delayHideAllForAddColumn(delay = 1000) {
|
|
6583
|
+
this.hideAllTimeoutId_addColumn = setTimeout(() => {
|
|
6584
|
+
this.addIconForAddColumn.style.display = 'none';
|
|
6585
|
+
this.addLineForAddColumn.style.display = 'none';
|
|
6586
|
+
this.leftDotForAddColumn.style.display = 'none';
|
|
6587
|
+
this.rightDotForAddColumn.style.display = 'none';
|
|
6588
|
+
}, delay);
|
|
6589
|
+
}
|
|
6590
|
+
initAddRowDomElement() {
|
|
6591
|
+
this.topDotForAddRow = document.createElement('div');
|
|
6592
|
+
this.topDotForAddRow.style.width = '6px';
|
|
6593
|
+
this.topDotForAddRow.style.height = '6px';
|
|
6594
|
+
this.topDotForAddRow.style.backgroundColor = '#4A90E2';
|
|
6595
|
+
this.topDotForAddRow.style.position = 'absolute';
|
|
6596
|
+
this.topDotForAddRow.style.cursor = 'pointer';
|
|
6597
|
+
this.topDotForAddRow.style.zIndex = '1000';
|
|
6598
|
+
this.topDotForAddRow.style.borderRadius = '50%';
|
|
6599
|
+
this.topDotForAddRow.style.border = '1px solid white';
|
|
6600
|
+
this.topDotForAddRow.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
|
|
6601
|
+
document.body.appendChild(this.topDotForAddRow);
|
|
6602
|
+
this.bottomDotForAddRow = document.createElement('div');
|
|
6603
|
+
this.bottomDotForAddRow.style.width = '6px';
|
|
6604
|
+
this.bottomDotForAddRow.style.height = '6px';
|
|
6605
|
+
this.bottomDotForAddRow.style.backgroundColor = '#4A90E2';
|
|
6606
|
+
this.bottomDotForAddRow.style.position = 'absolute';
|
|
6607
|
+
this.bottomDotForAddRow.style.cursor = 'pointer';
|
|
6608
|
+
this.bottomDotForAddRow.style.zIndex = '1000';
|
|
6609
|
+
this.bottomDotForAddRow.style.borderRadius = '50%';
|
|
6610
|
+
this.bottomDotForAddRow.style.border = '1px solid white';
|
|
6611
|
+
this.bottomDotForAddRow.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
|
|
6612
|
+
document.body.appendChild(this.bottomDotForAddRow);
|
|
6613
|
+
this.addIconForAddRow = document.createElement('div');
|
|
6614
|
+
this.addIconForAddRow.style.width = '18px';
|
|
6615
|
+
this.addIconForAddRow.style.height = '18px';
|
|
6616
|
+
this.addIconForAddRow.style.backgroundColor = '#4A90E2';
|
|
6617
|
+
this.addIconForAddRow.style.position = 'absolute';
|
|
6618
|
+
this.addIconForAddRow.style.zIndex = '1001';
|
|
6619
|
+
this.addIconForAddRow.style.display = 'none';
|
|
6620
|
+
this.addIconForAddRow.style.borderRadius = '50%';
|
|
6621
|
+
this.addIconForAddRow.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
|
|
6622
|
+
this.addIconForAddRow.style.display = 'flex';
|
|
6623
|
+
this.addIconForAddRow.style.justifyContent = 'center';
|
|
6624
|
+
this.addIconForAddRow.style.alignItems = 'center';
|
|
6625
|
+
this.addIconForAddRow.style.border = '1px solid white';
|
|
6626
|
+
document.body.appendChild(this.addIconForAddRow);
|
|
6627
|
+
const addIconText = document.createElement('div');
|
|
6628
|
+
addIconText.textContent = '+';
|
|
6629
|
+
addIconText.style.color = 'white';
|
|
6630
|
+
addIconText.style.fontSize = '18px';
|
|
6631
|
+
addIconText.style.fontWeight = 'bold';
|
|
6632
|
+
addIconText.style.lineHeight = '15px';
|
|
6633
|
+
addIconText.style.userSelect = 'none';
|
|
6634
|
+
addIconText.style.cursor = 'pointer';
|
|
6635
|
+
addIconText.style.verticalAlign = 'top';
|
|
6636
|
+
addIconText.style.textAlign = 'center';
|
|
6637
|
+
this.addIconForAddRow.appendChild(addIconText);
|
|
6638
|
+
this.addLineForAddRow = document.createElement('div');
|
|
6639
|
+
this.addLineForAddRow.style.width = '10px';
|
|
6640
|
+
this.addLineForAddRow.style.height = '2px';
|
|
6641
|
+
this.addLineForAddRow.style.backgroundColor = '#4A90E2';
|
|
6642
|
+
this.addLineForAddRow.style.position = 'absolute';
|
|
6643
|
+
this.addLineForAddRow.style.zIndex = '1001';
|
|
6644
|
+
this.addLineForAddRow.style.display = 'none';
|
|
6645
|
+
document.body.appendChild(this.addLineForAddRow);
|
|
6646
|
+
}
|
|
6647
|
+
bindEventForAddRow() {
|
|
6648
|
+
this.topDotForAddRow.addEventListener('mouseenter', () => {
|
|
6649
|
+
clearTimeout(this.hideAllTimeoutId_addRow);
|
|
6650
|
+
this.addIconForAddRow.style.display = 'block';
|
|
6651
|
+
const dotWidth = this.topDotForAddRow.offsetWidth;
|
|
6652
|
+
const dotHeight = this.topDotForAddRow.offsetHeight;
|
|
6653
|
+
this.showAddIconForAddRow(this.topDotForAddRow.offsetLeft + dotWidth / 2, this.topDotForAddRow.offsetTop + dotHeight / 2, true);
|
|
6654
|
+
this.showSplitLineForAddRow(this.topDotForAddRow.offsetLeft + dotWidth + 2, this.topDotForAddRow.offsetTop + dotHeight / 2 - 1, this.table.getDrawRange().width);
|
|
6655
|
+
});
|
|
6656
|
+
this.bottomDotForAddRow.addEventListener('mouseenter', () => {
|
|
6657
|
+
clearTimeout(this.hideAllTimeoutId_addRow);
|
|
6658
|
+
this.addIconForAddRow.style.display = 'block';
|
|
6659
|
+
const dotWidth = this.bottomDotForAddRow.offsetWidth;
|
|
6660
|
+
const dotHeight = this.bottomDotForAddRow.offsetHeight;
|
|
6661
|
+
this.showAddIconForAddRow(this.bottomDotForAddRow.offsetLeft + dotWidth / 2, this.bottomDotForAddRow.offsetTop + dotHeight / 2, false);
|
|
6662
|
+
this.showSplitLineForAddRow(this.bottomDotForAddRow.offsetLeft + dotWidth + 2, this.bottomDotForAddRow.offsetTop + dotHeight / 2 - 1, this.table.getDrawRange().height);
|
|
6663
|
+
});
|
|
6664
|
+
this.addIconForAddRow.addEventListener('mouseleave', () => {
|
|
6665
|
+
this.addIconForAddRow.style.display = 'none';
|
|
6666
|
+
this.addLineForAddRow.style.display = 'none';
|
|
6667
|
+
this.delayHideAllForAddRow();
|
|
6668
|
+
});
|
|
6669
|
+
this.addIconForAddRow.addEventListener('click', (e) => {
|
|
6670
|
+
const isTop = this.addIconForAddRow.dataset.addIconType === 'top';
|
|
6671
|
+
const row = this.hoverCell.row;
|
|
6672
|
+
const addRowIndex = isTop ? row : row + 1;
|
|
6673
|
+
if (this.pluginOptions.addRowCallback) {
|
|
6674
|
+
this.pluginOptions.addRowCallback(addRowIndex);
|
|
6675
|
+
}
|
|
6676
|
+
else {
|
|
6677
|
+
const recordIndex = this.table.getRecordIndexByCell(0, addRowIndex);
|
|
6678
|
+
this.table.addRecord({}, recordIndex);
|
|
6679
|
+
}
|
|
6680
|
+
this.delayHideAllForAddRow(0);
|
|
6681
|
+
});
|
|
6682
|
+
}
|
|
6683
|
+
showDotForAddRow(top, left, bottom, isShowTop = true, isShowBottom = true) {
|
|
6684
|
+
const dotWidth = this.topDotForAddRow.offsetWidth;
|
|
6685
|
+
const dotHeight = this.topDotForAddRow.offsetHeight;
|
|
6686
|
+
this.topDotForAddRow.style.left = `${left - dotWidth / 2}px`;
|
|
6687
|
+
this.topDotForAddRow.style.top = `${top - dotHeight / 2}px`;
|
|
6688
|
+
this.bottomDotForAddRow.style.left = `${left - dotWidth / 2}px`;
|
|
6689
|
+
this.bottomDotForAddRow.style.top = `${bottom - dotHeight / 2}px`;
|
|
6690
|
+
this.topDotForAddRow.style.display = isShowTop ? 'block' : 'none';
|
|
6691
|
+
this.bottomDotForAddRow.style.display = isShowBottom ? 'block' : 'none';
|
|
6692
|
+
}
|
|
6693
|
+
showAddIconForAddRow(left, top, isTop) {
|
|
6694
|
+
const iconWidth = this.addIconForAddRow.offsetWidth;
|
|
6695
|
+
const iconHeight = this.addIconForAddRow.offsetHeight;
|
|
6696
|
+
const dotWidth = this.topDotForAddRow.offsetWidth;
|
|
6697
|
+
this.addIconForAddRow.style.left = `${left - iconWidth / 2 - dotWidth / 2}px`;
|
|
6698
|
+
this.addIconForAddRow.style.top = `${top - iconHeight / 2}px`;
|
|
6699
|
+
if (isTop) {
|
|
6700
|
+
this.addIconForAddRow.dataset.addIconType = 'top';
|
|
6701
|
+
}
|
|
6702
|
+
else {
|
|
6703
|
+
this.addIconForAddRow.dataset.addIconType = 'bottom';
|
|
6704
|
+
}
|
|
6705
|
+
}
|
|
6706
|
+
showSplitLineForAddRow(left, top, width) {
|
|
6707
|
+
this.addLineForAddRow.style.left = `${left}px`;
|
|
6708
|
+
this.addLineForAddRow.style.top = `${top}px`;
|
|
6709
|
+
this.addLineForAddRow.style.width = `${width}px`;
|
|
6710
|
+
this.addLineForAddRow.style.display = 'block';
|
|
6711
|
+
}
|
|
6712
|
+
delayHideAllForAddRow(delay = 1000) {
|
|
6713
|
+
this.hideAllTimeoutId_addRow = setTimeout(() => {
|
|
6714
|
+
this.addIconForAddRow.style.display = 'none';
|
|
6715
|
+
this.addLineForAddRow.style.display = 'none';
|
|
6716
|
+
this.topDotForAddRow.style.display = 'none';
|
|
6717
|
+
this.bottomDotForAddRow.style.display = 'none';
|
|
6718
|
+
}, delay);
|
|
6719
|
+
}
|
|
6720
|
+
release() {
|
|
6721
|
+
this.leftDotForAddColumn.remove();
|
|
6722
|
+
this.rightDotForAddColumn.remove();
|
|
6723
|
+
this.addIconForAddColumn.remove();
|
|
6724
|
+
this.addLineForAddColumn.remove();
|
|
6725
|
+
this.topDotForAddRow.remove();
|
|
6726
|
+
this.bottomDotForAddRow.remove();
|
|
6727
|
+
this.addIconForAddRow.remove();
|
|
6728
|
+
this.addLineForAddRow.remove();
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6731
|
+
|
|
6732
|
+
class ColumnSeriesPlugin {
|
|
6733
|
+
id = 'column-series';
|
|
6734
|
+
runTime = [VTable__namespace.TABLE_EVENT_TYPE.BEFORE_INIT, VTable__namespace.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];
|
|
6735
|
+
pluginOptions;
|
|
6736
|
+
table;
|
|
6737
|
+
columns = [];
|
|
6738
|
+
constructor(pluginOptions) {
|
|
6739
|
+
this.pluginOptions = Object.assign({ columnCount: 100, autoExtendColumn: true }, pluginOptions);
|
|
6740
|
+
}
|
|
6741
|
+
run(...args) {
|
|
6742
|
+
if (args[1] === VTable__namespace.TABLE_EVENT_TYPE.BEFORE_INIT) {
|
|
6743
|
+
const eventArgs = args[0];
|
|
6744
|
+
const table = args[2];
|
|
6745
|
+
this.table = table;
|
|
6746
|
+
const options = eventArgs.options;
|
|
6747
|
+
this.columns = this.generateColumns(this.pluginOptions.columnCount);
|
|
6748
|
+
options.columns = this.columns;
|
|
6749
|
+
}
|
|
6750
|
+
else if (args[1] === VTable__namespace.TABLE_EVENT_TYPE.BEFORE_KEYDOWN) {
|
|
6751
|
+
const eventArgs = args[0];
|
|
6752
|
+
const e = eventArgs.event;
|
|
6753
|
+
if (e.key === 'ArrowRight') {
|
|
6754
|
+
if (this.pluginOptions.autoExtendColumn &&
|
|
6755
|
+
this.table.stateManager.select.cellPos.col === this.table.colCount - 1) {
|
|
6756
|
+
this.table.addColumn(this.generateColumn(this.table.colCount - 1));
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
}
|
|
6761
|
+
generateColumns(columnCount) {
|
|
6762
|
+
const columnFields = [];
|
|
6763
|
+
for (let i = 0; i < columnCount; i++) {
|
|
6764
|
+
columnFields.push(this.generateColumn(i));
|
|
6765
|
+
}
|
|
6766
|
+
return columnFields;
|
|
6767
|
+
}
|
|
6768
|
+
generateColumn(index) {
|
|
6769
|
+
const column = {
|
|
6770
|
+
title: this.pluginOptions.generateColumnTitle
|
|
6771
|
+
? this.pluginOptions.generateColumnTitle(index)
|
|
6772
|
+
: this.generateColumnField(index)
|
|
6773
|
+
};
|
|
6774
|
+
return column;
|
|
6775
|
+
}
|
|
6776
|
+
generateColumnField(index) {
|
|
6777
|
+
if (index < 26) {
|
|
6778
|
+
return String.fromCharCode(65 + index);
|
|
6779
|
+
}
|
|
6780
|
+
const title = [];
|
|
6781
|
+
index++;
|
|
6782
|
+
while (index > 0) {
|
|
6783
|
+
index--;
|
|
6784
|
+
title.unshift(String.fromCharCode(65 + (index % 26)));
|
|
6785
|
+
index = Math.floor(index / 26);
|
|
6786
|
+
}
|
|
6787
|
+
return title.join('');
|
|
6788
|
+
}
|
|
6789
|
+
resetColumnCount(columnCount) {
|
|
6790
|
+
this.pluginOptions.columnCount = columnCount;
|
|
6791
|
+
this.columns = this.generateColumns(columnCount);
|
|
6792
|
+
this.table.updateColumns(this.columns);
|
|
6793
|
+
}
|
|
6794
|
+
}
|
|
6795
|
+
|
|
6796
|
+
class RowSeriesPlugin {
|
|
6797
|
+
id = 'row-series';
|
|
6798
|
+
runTime = [VTable.TABLE_EVENT_TYPE.BEFORE_INIT, VTable.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];
|
|
6799
|
+
pluginOptions;
|
|
6800
|
+
table;
|
|
6801
|
+
constructor(pluginOptions) {
|
|
6802
|
+
this.pluginOptions = Object.assign({ rowCount: 100, autoExtendRow: true }, pluginOptions);
|
|
6803
|
+
}
|
|
6804
|
+
run(...args) {
|
|
6805
|
+
if (args[1] === VTable.TABLE_EVENT_TYPE.BEFORE_INIT) {
|
|
6806
|
+
const eventArgs = args[0];
|
|
6807
|
+
const table = args[2];
|
|
6808
|
+
this.table = table;
|
|
6809
|
+
const options = eventArgs.options;
|
|
6810
|
+
const records = options.records ?? [];
|
|
6811
|
+
for (let i = records.length; i < this.pluginOptions.rowCount; i++) {
|
|
6812
|
+
records.push(this.pluginOptions.fillRowRecord ? this.pluginOptions.fillRowRecord(i) : {});
|
|
6813
|
+
}
|
|
6814
|
+
options.records = records;
|
|
6815
|
+
if (this.pluginOptions.rowSeriesNumber) {
|
|
6816
|
+
options.rowSeriesNumber = this.pluginOptions.rowSeriesNumber;
|
|
6817
|
+
if (!this.pluginOptions.rowSeriesNumber.width) {
|
|
6818
|
+
options.rowSeriesNumber.width = 'auto';
|
|
6819
|
+
}
|
|
6820
|
+
}
|
|
6821
|
+
else if (!options.rowSeriesNumber) {
|
|
6822
|
+
options.rowSeriesNumber = {
|
|
6823
|
+
width: 'auto'
|
|
6824
|
+
};
|
|
6825
|
+
}
|
|
6826
|
+
}
|
|
6827
|
+
else if (args[1] === VTable.TABLE_EVENT_TYPE.BEFORE_KEYDOWN) {
|
|
6828
|
+
const eventArgs = args[0];
|
|
6829
|
+
const e = eventArgs.event;
|
|
6830
|
+
if (e.key === 'ArrowDown') {
|
|
6831
|
+
if (this.pluginOptions.autoExtendRow &&
|
|
6832
|
+
this.table.stateManager.select.cellPos.row === this.table.rowCount - 1) {
|
|
6833
|
+
this.table.addRecord(this.pluginOptions.fillRowRecord
|
|
6834
|
+
? this.pluginOptions.fillRowRecord(this.table.rowCount - this.table.columnHeaderLevelCount)
|
|
6835
|
+
: {});
|
|
6836
|
+
}
|
|
6837
|
+
}
|
|
6838
|
+
}
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
|
|
6842
|
+
class HighlightHeaderWhenSelectCellPlugin {
|
|
6843
|
+
id = 'highlight-header-when-select-cell';
|
|
6844
|
+
runTime = [
|
|
6845
|
+
VTable.TABLE_EVENT_TYPE.INITIALIZED,
|
|
6846
|
+
VTable.TABLE_EVENT_TYPE.SELECTED_CLEAR,
|
|
6847
|
+
VTable.TABLE_EVENT_TYPE.SELECTED_CELL,
|
|
6848
|
+
VTable.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE
|
|
6849
|
+
];
|
|
6850
|
+
table;
|
|
6851
|
+
pluginOptions;
|
|
6852
|
+
colHeaderRanges = [];
|
|
6853
|
+
rowHeaderRanges = [];
|
|
6854
|
+
constructor(pluginOptions) {
|
|
6855
|
+
this.pluginOptions = pluginOptions;
|
|
6856
|
+
}
|
|
6857
|
+
run(...args) {
|
|
6858
|
+
const runTime = args[1];
|
|
6859
|
+
const table = args[2];
|
|
6860
|
+
this.table = table;
|
|
6861
|
+
if (runTime === VTable.TABLE_EVENT_TYPE.SELECTED_CLEAR) {
|
|
6862
|
+
this.clearHighlight();
|
|
6863
|
+
}
|
|
6864
|
+
else if (runTime === VTable.TABLE_EVENT_TYPE.SELECTED_CELL) {
|
|
6865
|
+
this.updateHighlight();
|
|
6866
|
+
}
|
|
6867
|
+
else if (runTime === VTable.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE) {
|
|
6868
|
+
this.updateHighlight();
|
|
6869
|
+
}
|
|
6870
|
+
else if (runTime === VTable.TABLE_EVENT_TYPE.INITIALIZED) {
|
|
6871
|
+
this.registerStyle();
|
|
6872
|
+
}
|
|
6873
|
+
}
|
|
6874
|
+
registerStyle() {
|
|
6875
|
+
this.table.registerCustomCellStyle('col-highlight', {
|
|
6876
|
+
bgColor: this.pluginOptions?.colHighlightBGColor ?? '#82b2f5',
|
|
6877
|
+
color: this.pluginOptions?.colHighlightColor ?? '#FFF'
|
|
6878
|
+
});
|
|
6879
|
+
this.table.registerCustomCellStyle('row-highlight', {
|
|
6880
|
+
bgColor: this.pluginOptions?.rowHighlightBGColor ?? '#82b2f5',
|
|
6881
|
+
color: this.pluginOptions?.rowHighlightColor ?? 'yellow'
|
|
6882
|
+
});
|
|
6883
|
+
}
|
|
6884
|
+
clearHighlight() {
|
|
6885
|
+
if (this.colHeaderRanges) {
|
|
6886
|
+
this.colHeaderRanges.forEach(range => {
|
|
6887
|
+
this.table.arrangeCustomCellStyle({ range }, undefined);
|
|
6888
|
+
});
|
|
6889
|
+
}
|
|
6890
|
+
if (this.rowHeaderRanges) {
|
|
6891
|
+
this.rowHeaderRanges.forEach(range => {
|
|
6892
|
+
this.table.arrangeCustomCellStyle({ range }, undefined);
|
|
6893
|
+
});
|
|
6894
|
+
}
|
|
6895
|
+
this.colHeaderRanges = [];
|
|
6896
|
+
this.rowHeaderRanges = [];
|
|
6897
|
+
}
|
|
6898
|
+
updateHighlight() {
|
|
6899
|
+
if (this.pluginOptions?.colHighlight === false && this.pluginOptions?.rowHighlight === false) {
|
|
6900
|
+
return;
|
|
6901
|
+
}
|
|
6902
|
+
const selectRanges = this.table.getSelectedCellRanges();
|
|
6903
|
+
if (selectRanges.length < 2) {
|
|
6904
|
+
this.clearHighlight();
|
|
6905
|
+
}
|
|
6906
|
+
for (let i = 0; i < selectRanges.length; i++) {
|
|
6907
|
+
const selectRange = selectRanges[i];
|
|
6908
|
+
const rowSelectRange = [selectRange.start.row, selectRange.end.row];
|
|
6909
|
+
rowSelectRange.sort((a, b) => a - b);
|
|
6910
|
+
const colSelectRange = [selectRange.start.col, selectRange.end.col];
|
|
6911
|
+
colSelectRange.sort((a, b) => a - b);
|
|
6912
|
+
let colHeaderRange;
|
|
6913
|
+
let rowHeaderRange;
|
|
6914
|
+
if (this.table.isPivotTable()) {
|
|
6915
|
+
colHeaderRange = {
|
|
6916
|
+
start: {
|
|
6917
|
+
col: colSelectRange[0],
|
|
6918
|
+
row: 0
|
|
6919
|
+
},
|
|
6920
|
+
end: {
|
|
6921
|
+
col: colSelectRange[1],
|
|
6922
|
+
row: this.table.columnHeaderLevelCount - 1
|
|
6923
|
+
}
|
|
6924
|
+
};
|
|
6925
|
+
rowHeaderRange = {
|
|
6926
|
+
start: {
|
|
6927
|
+
col: 0,
|
|
6928
|
+
row: rowSelectRange[0]
|
|
6929
|
+
},
|
|
6930
|
+
end: {
|
|
6931
|
+
col: this.table.rowHeaderLevelCount - 1,
|
|
6932
|
+
row: rowSelectRange[1]
|
|
6933
|
+
}
|
|
6934
|
+
};
|
|
6935
|
+
}
|
|
6936
|
+
else if (this.table.internalProps.transpose) {
|
|
6937
|
+
rowHeaderRange = {
|
|
6938
|
+
start: {
|
|
6939
|
+
col: 0,
|
|
6940
|
+
row: rowSelectRange[0]
|
|
6941
|
+
},
|
|
6942
|
+
end: {
|
|
6943
|
+
col: this.table.rowHeaderLevelCount - 1,
|
|
6944
|
+
row: rowSelectRange[1]
|
|
6945
|
+
}
|
|
6946
|
+
};
|
|
6947
|
+
}
|
|
6948
|
+
else {
|
|
6949
|
+
colHeaderRange = {
|
|
6950
|
+
start: {
|
|
6951
|
+
col: colSelectRange[0],
|
|
6952
|
+
row: 0
|
|
6953
|
+
},
|
|
6954
|
+
end: {
|
|
6955
|
+
col: colSelectRange[1],
|
|
6956
|
+
row: this.table.columnHeaderLevelCount - 1
|
|
6957
|
+
}
|
|
6958
|
+
};
|
|
6959
|
+
if (this.table.internalProps.rowSeriesNumber) {
|
|
6960
|
+
rowHeaderRange = {
|
|
6961
|
+
start: {
|
|
6962
|
+
col: 0,
|
|
6963
|
+
row: rowSelectRange[0]
|
|
6964
|
+
},
|
|
6965
|
+
end: {
|
|
6966
|
+
col: 0,
|
|
6967
|
+
row: rowSelectRange[1]
|
|
6968
|
+
}
|
|
6969
|
+
};
|
|
6970
|
+
}
|
|
6971
|
+
}
|
|
6972
|
+
if (this.pluginOptions?.colHighlight !== false &&
|
|
6973
|
+
!this.colHeaderRanges.find(range => isSameRange(range, colHeaderRange))) {
|
|
6974
|
+
colHeaderRange && this.table.arrangeCustomCellStyle({ range: colHeaderRange }, 'col-highlight');
|
|
6975
|
+
this.colHeaderRanges.push(colHeaderRange);
|
|
6976
|
+
}
|
|
6977
|
+
if (this.pluginOptions?.rowHighlight !== false &&
|
|
6978
|
+
!this.rowHeaderRanges.find(range => isSameRange(range, rowHeaderRange))) {
|
|
6979
|
+
rowHeaderRange && this.table.arrangeCustomCellStyle({ range: rowHeaderRange }, 'row-highlight');
|
|
6980
|
+
this.rowHeaderRanges.push(rowHeaderRange);
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
}
|
|
6984
|
+
release() {
|
|
6985
|
+
this.rowHeaderRanges = [];
|
|
6986
|
+
this.colHeaderRanges = [];
|
|
6987
|
+
}
|
|
6988
|
+
}
|
|
6989
|
+
function isSameRange(a, b) {
|
|
6990
|
+
if (a === undefined && b === undefined) {
|
|
6991
|
+
return true;
|
|
6992
|
+
}
|
|
6993
|
+
if (a === undefined || b === undefined) {
|
|
6994
|
+
return false;
|
|
6995
|
+
}
|
|
6996
|
+
return (a.start.col === b.start.col && a.start.row === b.start.row && a.end.col === b.end.col && a.end.row === b.end.row);
|
|
6997
|
+
}
|
|
6998
|
+
|
|
6999
|
+
class ExcelEditCellKeyboardPlugin {
|
|
7000
|
+
id = 'excel-edit-cell-keyboard';
|
|
7001
|
+
runTime = [VTable__namespace.TABLE_EVENT_TYPE.INITIALIZED];
|
|
7002
|
+
table;
|
|
7003
|
+
pluginOptions;
|
|
7004
|
+
constructor(pluginOptions) {
|
|
7005
|
+
this.pluginOptions = pluginOptions;
|
|
7006
|
+
this.bindEvent();
|
|
7007
|
+
}
|
|
7008
|
+
run(...args) {
|
|
7009
|
+
const table = args[2];
|
|
7010
|
+
this.table = table;
|
|
7011
|
+
}
|
|
7012
|
+
bindEvent() {
|
|
7013
|
+
document.addEventListener('keydown', this.handleKeyDown.bind(this), true);
|
|
7014
|
+
}
|
|
7015
|
+
handleKeyDown(event) {
|
|
7016
|
+
if (this.table.editorManager) {
|
|
7017
|
+
if (this.table.editorManager.beginTriggerEditCellMode === 'keydown') {
|
|
7018
|
+
if (this.table.editorManager.editingEditor && this.isExcelShortcutKey(event)) {
|
|
7019
|
+
const { col, row } = this.table.editorManager.editCell;
|
|
7020
|
+
this.table.editorManager.completeEdit();
|
|
7021
|
+
this.table.getElement().focus();
|
|
7022
|
+
if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
|
7023
|
+
if (event.key === 'Enter') {
|
|
7024
|
+
this.table.selectCell(col, row + 1);
|
|
7025
|
+
}
|
|
7026
|
+
else if (event.key === 'Tab') {
|
|
7027
|
+
this.table.selectCell(col + 1, row);
|
|
7028
|
+
}
|
|
7029
|
+
else if (event.key === 'ArrowLeft') {
|
|
7030
|
+
this.table.selectCell(col - 1, row);
|
|
7031
|
+
}
|
|
7032
|
+
else if (event.key === 'ArrowRight') {
|
|
7033
|
+
this.table.selectCell(col + 1, row);
|
|
7034
|
+
}
|
|
7035
|
+
else if (event.key === 'ArrowDown') {
|
|
7036
|
+
this.table.selectCell(col, row + 1);
|
|
7037
|
+
}
|
|
7038
|
+
else if (event.key === 'ArrowUp') {
|
|
7039
|
+
this.table.selectCell(col, row - 1);
|
|
7040
|
+
}
|
|
7041
|
+
event.stopPropagation();
|
|
7042
|
+
event.preventDefault();
|
|
7043
|
+
}
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
else {
|
|
7047
|
+
const { col, row } = this.table.stateManager.select.cellPos;
|
|
7048
|
+
if (this.table.editorManager.editingEditor && (event.key === 'Enter' || event.key === 'Tab')) {
|
|
7049
|
+
this.table.editorManager.completeEdit();
|
|
7050
|
+
this.table.getElement().focus();
|
|
7051
|
+
if (event.key === 'Enter') {
|
|
7052
|
+
this.table.selectCell(col, row + 1);
|
|
7053
|
+
}
|
|
7054
|
+
else if (event.key === 'Tab') {
|
|
7055
|
+
this.table.selectCell(col + 1, row);
|
|
7056
|
+
}
|
|
7057
|
+
event.stopPropagation();
|
|
7058
|
+
event.preventDefault();
|
|
7059
|
+
}
|
|
7060
|
+
else if (event.key === 'Delete') {
|
|
7061
|
+
const selectCells = this.table.getSelectedCellInfos();
|
|
7062
|
+
if (selectCells?.length > 0) {
|
|
7063
|
+
deleteSelectRange(selectCells, this.table);
|
|
7064
|
+
}
|
|
7065
|
+
event.stopPropagation();
|
|
7066
|
+
event.preventDefault();
|
|
7067
|
+
}
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
|
+
}
|
|
7071
|
+
isExcelShortcutKey(event) {
|
|
7072
|
+
return (event.key === 'Enter' ||
|
|
7073
|
+
event.key === 'Tab' ||
|
|
7074
|
+
event.key === 'ArrowLeft' ||
|
|
7075
|
+
event.key === 'ArrowRight' ||
|
|
7076
|
+
event.key === 'ArrowDown' ||
|
|
7077
|
+
event.key === 'ArrowUp');
|
|
7078
|
+
}
|
|
7079
|
+
release() {
|
|
7080
|
+
document.removeEventListener('keydown', this.handleKeyDown, true);
|
|
7081
|
+
}
|
|
5073
7082
|
}
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
return !range1 && !range2 || !(!range1 || !range2) && range1.start.col === range2.start.col && range1.start.row === range2.start.row && range1.end.col === range2.end.col && range1.end.row === range2.end.row;
|
|
5081
|
-
}
|
|
5082
|
-
|
|
5083
|
-
const isNode = "undefined" == typeof window || void 0 === window.window;
|
|
5084
|
-
function analyzeUserAgent() {
|
|
5085
|
-
if (isNode) return {
|
|
5086
|
-
IE: !1,
|
|
5087
|
-
Edge: !1,
|
|
5088
|
-
Chrome: !1,
|
|
5089
|
-
Firefox: !1,
|
|
5090
|
-
Safari: !1
|
|
5091
|
-
};
|
|
5092
|
-
const ua = window.navigator.userAgent.toLowerCase();
|
|
5093
|
-
return {
|
|
5094
|
-
IE: !!/(msie|trident)/.exec(ua),
|
|
5095
|
-
Edge: ua.indexOf("edge") > -1,
|
|
5096
|
-
Chrome: ua.indexOf("chrome") > -1 && -1 === ua.indexOf("edge"),
|
|
5097
|
-
Firefox: ua.indexOf("firefox") > -1,
|
|
5098
|
-
Safari: ua.indexOf("safari") > -1 && -1 === ua.indexOf("edge")
|
|
5099
|
-
};
|
|
5100
|
-
}
|
|
5101
|
-
analyzeUserAgent();
|
|
5102
|
-
function cellInRange(range, col, row) {
|
|
5103
|
-
return range.start.col <= col && col <= range.end.col && range.start.row <= row && row <= range.end.row || range.end.col <= col && col <= range.start.col && range.end.row <= row && row <= range.start.row || range.end.col <= col && col <= range.start.col && range.start.row <= row && row <= range.end.row || range.start.col <= col && col <= range.end.col && range.end.row <= row && row <= range.start.row;
|
|
7083
|
+
function deleteSelectRange(selectCells, tableInstance) {
|
|
7084
|
+
for (let i = 0; i < selectCells.length; i++) {
|
|
7085
|
+
for (let j = 0; j < selectCells[i].length; j++) {
|
|
7086
|
+
tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '');
|
|
7087
|
+
}
|
|
7088
|
+
}
|
|
5104
7089
|
}
|
|
5105
7090
|
|
|
5106
|
-
class
|
|
7091
|
+
class FocusHighlightPlugin {
|
|
7092
|
+
id = 'focus-highlight';
|
|
7093
|
+
name = 'Focus Highlight';
|
|
7094
|
+
runTime = [VTable.TABLE_EVENT_TYPE.INITIALIZED, VTable.TABLE_EVENT_TYPE.SELECTED_CELL, VTable.TABLE_EVENT_TYPE.SELECTED_CLEAR];
|
|
5107
7095
|
table;
|
|
5108
7096
|
range;
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
7097
|
+
pluginOptions;
|
|
7098
|
+
constructor(options = {
|
|
7099
|
+
fill: '#000',
|
|
7100
|
+
opacity: 0.5,
|
|
7101
|
+
highlightRange: undefined
|
|
7102
|
+
}) {
|
|
7103
|
+
this.pluginOptions = Object.assign({
|
|
7104
|
+
fill: '#000',
|
|
7105
|
+
opacity: 0.5
|
|
7106
|
+
}, options);
|
|
5115
7107
|
}
|
|
5116
|
-
|
|
5117
|
-
if (
|
|
7108
|
+
run(...args) {
|
|
7109
|
+
if (!this.table) {
|
|
7110
|
+
this.table = args[2];
|
|
7111
|
+
}
|
|
7112
|
+
if (args[1] === VTable.TABLE_EVENT_TYPE.INITIALIZED) {
|
|
7113
|
+
this.pluginOptions.highlightRange && this.setFocusHighlightRange(this.pluginOptions.highlightRange);
|
|
7114
|
+
}
|
|
7115
|
+
else if (args[1] === VTable.TABLE_EVENT_TYPE.SELECTED_CELL) {
|
|
7116
|
+
const posCell = this.table.stateManager.select.cellPos;
|
|
7117
|
+
if (this.table.isHeader(posCell.col, posCell.row)) {
|
|
7118
|
+
this.setFocusHighlightRange(undefined);
|
|
7119
|
+
}
|
|
7120
|
+
else {
|
|
7121
|
+
const ranges = this.table.stateManager.select.ranges;
|
|
7122
|
+
const min_col = 0;
|
|
7123
|
+
const max_col = this.table.colCount - 1;
|
|
7124
|
+
const min_row = Math.min(ranges[0].start.row, ranges[0].end.row);
|
|
7125
|
+
const max_row = Math.max(ranges[0].start.row, ranges[0].end.row);
|
|
7126
|
+
this.setFocusHighlightRange({
|
|
7127
|
+
start: { col: min_col, row: min_row },
|
|
7128
|
+
end: { col: max_col, row: max_row }
|
|
7129
|
+
});
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7132
|
+
else if (args[1] === VTable.TABLE_EVENT_TYPE.SELECTED_CLEAR) {
|
|
7133
|
+
this.setFocusHighlightRange(undefined);
|
|
7134
|
+
}
|
|
7135
|
+
}
|
|
7136
|
+
setFocusHighlightRange(range) {
|
|
7137
|
+
let cellRange;
|
|
7138
|
+
if (range && 'start' in range && 'end' in range) {
|
|
7139
|
+
cellRange = range;
|
|
7140
|
+
}
|
|
7141
|
+
else if (range) {
|
|
7142
|
+
cellRange = {
|
|
7143
|
+
start: range,
|
|
7144
|
+
end: range
|
|
7145
|
+
};
|
|
7146
|
+
}
|
|
7147
|
+
if (isSameRange$2(this.range, cellRange)) {
|
|
5118
7148
|
return;
|
|
5119
7149
|
}
|
|
5120
|
-
this.range =
|
|
7150
|
+
this.range = cellRange;
|
|
5121
7151
|
if (!range) {
|
|
5122
7152
|
this.deleteAllCellGroupShadow();
|
|
5123
7153
|
}
|
|
@@ -5147,6 +7177,16 @@
|
|
|
5147
7177
|
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup, this.range);
|
|
5148
7178
|
}
|
|
5149
7179
|
updateCellGroupShadowInContainer(container, range) {
|
|
7180
|
+
let cellRange;
|
|
7181
|
+
if (range && 'start' in range && 'end' in range) {
|
|
7182
|
+
cellRange = range;
|
|
7183
|
+
}
|
|
7184
|
+
else if (range) {
|
|
7185
|
+
cellRange = {
|
|
7186
|
+
start: range,
|
|
7187
|
+
end: range
|
|
7188
|
+
};
|
|
7189
|
+
}
|
|
5150
7190
|
container.forEachChildrenSkipChild((item) => {
|
|
5151
7191
|
const column = item;
|
|
5152
7192
|
if (column.role === 'column') {
|
|
@@ -5157,10 +7197,10 @@
|
|
|
5157
7197
|
}
|
|
5158
7198
|
cell.attachShadow(cell.shadowRoot);
|
|
5159
7199
|
const shadowGroup = cell.shadowRoot;
|
|
5160
|
-
if (!
|
|
7200
|
+
if (!cellRange) {
|
|
5161
7201
|
shadowGroup.removeAllChild();
|
|
5162
7202
|
}
|
|
5163
|
-
else if (cellInRange(
|
|
7203
|
+
else if (cellInRange(cellRange, cell.col, cell.row)) {
|
|
5164
7204
|
shadowGroup.removeAllChild();
|
|
5165
7205
|
}
|
|
5166
7206
|
else if (!shadowGroup.firstChild) {
|
|
@@ -5169,8 +7209,8 @@
|
|
|
5169
7209
|
y: 0,
|
|
5170
7210
|
width: cell.attribute.width,
|
|
5171
7211
|
height: cell.attribute.height,
|
|
5172
|
-
fill: this.
|
|
5173
|
-
opacity: this.
|
|
7212
|
+
fill: this.pluginOptions.fill,
|
|
7213
|
+
opacity: this.pluginOptions.opacity
|
|
5174
7214
|
});
|
|
5175
7215
|
shadowRect.name = 'shadow-rect';
|
|
5176
7216
|
shadowGroup.appendChild(shadowRect);
|
|
@@ -5181,144 +7221,138 @@
|
|
|
5181
7221
|
}
|
|
5182
7222
|
}
|
|
5183
7223
|
|
|
5184
|
-
|
|
7224
|
+
function isInteger(value) {
|
|
7225
|
+
return Math.floor(value) === value;
|
|
7226
|
+
}
|
|
7227
|
+
class TableCarouselAnimationPlugin {
|
|
7228
|
+
id = 'table-carousel-animation';
|
|
7229
|
+
runTime = [VTable.TABLE_EVENT_TYPE.INITIALIZED];
|
|
5185
7230
|
table;
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
7231
|
+
rowCount;
|
|
7232
|
+
colCount;
|
|
7233
|
+
animationDuration;
|
|
7234
|
+
animationDelay;
|
|
7235
|
+
animationEasing;
|
|
7236
|
+
playing;
|
|
7237
|
+
row;
|
|
7238
|
+
col;
|
|
7239
|
+
willUpdateRow = false;
|
|
7240
|
+
willUpdateCol = false;
|
|
7241
|
+
autoPlay;
|
|
7242
|
+
autoPlayDelay;
|
|
7243
|
+
customDistRowFunction;
|
|
7244
|
+
customDistColFunction;
|
|
7245
|
+
constructor(options = {}) {
|
|
7246
|
+
this.rowCount = options?.rowCount ?? undefined;
|
|
7247
|
+
this.colCount = options?.colCount ?? undefined;
|
|
7248
|
+
this.animationDuration = options?.animationDuration ?? 500;
|
|
7249
|
+
this.animationDelay = options?.animationDelay ?? 1000;
|
|
7250
|
+
this.animationEasing = options?.animationEasing ?? 'linear';
|
|
7251
|
+
this.autoPlay = options?.autoPlay ?? false;
|
|
7252
|
+
this.autoPlayDelay = options?.autoPlayDelay ?? 0;
|
|
7253
|
+
this.customDistColFunction = options.customDistColFunction;
|
|
7254
|
+
this.customDistRowFunction = options.customDistRowFunction;
|
|
5194
7255
|
}
|
|
5195
|
-
|
|
5196
|
-
this.table
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
this.
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
7256
|
+
run(...args) {
|
|
7257
|
+
if (!this.table) {
|
|
7258
|
+
this.table = args[2];
|
|
7259
|
+
}
|
|
7260
|
+
this.reset();
|
|
7261
|
+
if (this.autoPlay) {
|
|
7262
|
+
setTimeout(() => {
|
|
7263
|
+
this.play();
|
|
7264
|
+
}, this.autoPlayDelay);
|
|
7265
|
+
}
|
|
5204
7266
|
}
|
|
5205
|
-
|
|
5206
|
-
this.
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
this.table.on('selected_clear', () => {
|
|
5210
|
-
this.clearHighlight();
|
|
5211
|
-
});
|
|
5212
|
-
this.table.on('mousemove_table', () => {
|
|
5213
|
-
if (this.table.stateManager.select.selecting) {
|
|
5214
|
-
this.updateHighlight();
|
|
5215
|
-
}
|
|
5216
|
-
});
|
|
7267
|
+
reset() {
|
|
7268
|
+
this.playing = false;
|
|
7269
|
+
this.row = this.table.frozenRowCount;
|
|
7270
|
+
this.col = this.table.frozenColCount;
|
|
5217
7271
|
}
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
this.
|
|
7272
|
+
play() {
|
|
7273
|
+
if (!this.table) {
|
|
7274
|
+
throw new Error('table is not initialized');
|
|
7275
|
+
}
|
|
7276
|
+
this.playing = true;
|
|
7277
|
+
if (this.rowCount && !this.willUpdateRow) {
|
|
7278
|
+
this.updateRow();
|
|
7279
|
+
}
|
|
7280
|
+
else if (this.colCount && !this.willUpdateCol) {
|
|
7281
|
+
this.updateCol();
|
|
7282
|
+
}
|
|
5223
7283
|
}
|
|
5224
|
-
|
|
5225
|
-
|
|
7284
|
+
pause() {
|
|
7285
|
+
this.playing = false;
|
|
7286
|
+
}
|
|
7287
|
+
updateRow() {
|
|
7288
|
+
if (!this.playing || this.table.isReleased) {
|
|
5226
7289
|
return;
|
|
5227
7290
|
}
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
7291
|
+
let animation = true;
|
|
7292
|
+
const customRow = this.customDistRowFunction && this.customDistRowFunction(this.row, this.table);
|
|
7293
|
+
if (customRow) {
|
|
7294
|
+
this.row = customRow.distRow;
|
|
7295
|
+
animation = customRow.animation ?? true;
|
|
5232
7296
|
}
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
const colSelectRange = [selectRange.start.col, selectRange.end.col];
|
|
5237
|
-
colSelectRange.sort((a, b) => a - b);
|
|
5238
|
-
let colHeaderRange;
|
|
5239
|
-
let rowHeaderRange;
|
|
5240
|
-
if (this.table.isPivotTable()) {
|
|
5241
|
-
colHeaderRange = {
|
|
5242
|
-
start: {
|
|
5243
|
-
col: colSelectRange[0],
|
|
5244
|
-
row: 0
|
|
5245
|
-
},
|
|
5246
|
-
end: {
|
|
5247
|
-
col: colSelectRange[1],
|
|
5248
|
-
row: this.table.columnHeaderLevelCount - 1
|
|
5249
|
-
}
|
|
5250
|
-
};
|
|
5251
|
-
rowHeaderRange = {
|
|
5252
|
-
start: {
|
|
5253
|
-
col: 0,
|
|
5254
|
-
row: rowSelectRange[0]
|
|
5255
|
-
},
|
|
5256
|
-
end: {
|
|
5257
|
-
col: this.table.rowHeaderLevelCount - 1,
|
|
5258
|
-
row: rowSelectRange[1]
|
|
5259
|
-
}
|
|
5260
|
-
};
|
|
7297
|
+
else if (isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== this.row) {
|
|
7298
|
+
this.row = this.table.frozenRowCount;
|
|
7299
|
+
animation = false;
|
|
5261
7300
|
}
|
|
5262
|
-
else if (this.table.
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
col: 0,
|
|
5266
|
-
row: rowSelectRange[0]
|
|
5267
|
-
},
|
|
5268
|
-
end: {
|
|
5269
|
-
col: this.table.rowHeaderLevelCount - 1,
|
|
5270
|
-
row: rowSelectRange[1]
|
|
5271
|
-
}
|
|
5272
|
-
};
|
|
7301
|
+
else if (!isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== Math.floor(this.row)) {
|
|
7302
|
+
this.row = this.table.frozenRowCount;
|
|
7303
|
+
animation = false;
|
|
5273
7304
|
}
|
|
5274
7305
|
else {
|
|
5275
|
-
|
|
5276
|
-
start: {
|
|
5277
|
-
col: colSelectRange[0],
|
|
5278
|
-
row: 0
|
|
5279
|
-
},
|
|
5280
|
-
end: {
|
|
5281
|
-
col: colSelectRange[1],
|
|
5282
|
-
row: this.table.columnHeaderLevelCount - 1
|
|
5283
|
-
}
|
|
5284
|
-
};
|
|
5285
|
-
if (this.table.internalProps.rowSeriesNumber) {
|
|
5286
|
-
rowHeaderRange = {
|
|
5287
|
-
start: {
|
|
5288
|
-
col: 0,
|
|
5289
|
-
row: rowSelectRange[0]
|
|
5290
|
-
},
|
|
5291
|
-
end: {
|
|
5292
|
-
col: 0,
|
|
5293
|
-
row: rowSelectRange[1]
|
|
5294
|
-
}
|
|
5295
|
-
};
|
|
5296
|
-
}
|
|
7306
|
+
this.row += this.rowCount;
|
|
5297
7307
|
}
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
this.
|
|
7308
|
+
this.table.scrollToRow(this.row, animation ? { duration: this.animationDuration, easing: this.animationEasing } : undefined);
|
|
7309
|
+
this.willUpdateRow = true;
|
|
7310
|
+
setTimeout(() => {
|
|
7311
|
+
this.willUpdateRow = false;
|
|
7312
|
+
this.updateRow();
|
|
7313
|
+
}, this.animationDuration + this.animationDelay);
|
|
7314
|
+
}
|
|
7315
|
+
updateCol() {
|
|
7316
|
+
if (!this.playing || this.table.isReleased) {
|
|
7317
|
+
return;
|
|
5302
7318
|
}
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
this.
|
|
7319
|
+
let animation = true;
|
|
7320
|
+
const customCol = this.customDistColFunction && this.customDistColFunction(this.col, this.table);
|
|
7321
|
+
if (customCol) {
|
|
7322
|
+
this.col = customCol.distCol;
|
|
7323
|
+
animation = customCol.animation ?? true;
|
|
5307
7324
|
}
|
|
7325
|
+
else if (isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) {
|
|
7326
|
+
this.col = this.table.frozenColCount;
|
|
7327
|
+
animation = false;
|
|
7328
|
+
}
|
|
7329
|
+
else if (!isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== Math.floor(this.col)) {
|
|
7330
|
+
this.col = this.table.frozenColCount;
|
|
7331
|
+
animation = false;
|
|
7332
|
+
}
|
|
7333
|
+
else {
|
|
7334
|
+
this.col += this.colCount;
|
|
7335
|
+
}
|
|
7336
|
+
this.table.scrollToCol(this.col, animation ? { duration: this.animationDuration, easing: this.animationEasing } : undefined);
|
|
7337
|
+
this.willUpdateCol = true;
|
|
7338
|
+
setTimeout(() => {
|
|
7339
|
+
this.willUpdateCol = false;
|
|
7340
|
+
this.updateCol();
|
|
7341
|
+
}, this.animationDuration + this.animationDelay);
|
|
5308
7342
|
}
|
|
5309
|
-
|
|
5310
|
-
function isSameRange(a, b) {
|
|
5311
|
-
if (a === undefined && b === undefined) {
|
|
5312
|
-
return true;
|
|
5313
|
-
}
|
|
5314
|
-
if (a === undefined || b === undefined) {
|
|
5315
|
-
return false;
|
|
7343
|
+
release() {
|
|
5316
7344
|
}
|
|
5317
|
-
return (a.start.col === b.start.col && a.start.row === b.start.row && a.end.col === b.end.col && a.end.row === b.end.row);
|
|
5318
7345
|
}
|
|
5319
7346
|
|
|
7347
|
+
exports.AddRowColumnPlugin = AddRowColumnPlugin;
|
|
5320
7348
|
exports.CarouselAnimationPlugin = CarouselAnimationPlugin;
|
|
7349
|
+
exports.ColumnSeriesPlugin = ColumnSeriesPlugin;
|
|
7350
|
+
exports.ExcelEditCellKeyboardPlugin = ExcelEditCellKeyboardPlugin;
|
|
7351
|
+
exports.FocusHighlightPlugin = FocusHighlightPlugin;
|
|
5321
7352
|
exports.HeaderHighlightPlugin = HeaderHighlightPlugin;
|
|
7353
|
+
exports.HighlightHeaderWhenSelectCellPlugin = HighlightHeaderWhenSelectCellPlugin;
|
|
5322
7354
|
exports.InvertHighlightPlugin = InvertHighlightPlugin;
|
|
7355
|
+
exports.RowSeriesPlugin = RowSeriesPlugin;
|
|
7356
|
+
exports.TableCarouselAnimationPlugin = TableCarouselAnimationPlugin;
|
|
5323
7357
|
|
|
5324
7358
|
}));
|