@visactor/vrender-components 1.0.13 → 1.0.14

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.
Files changed (44) hide show
  1. package/cjs/index.d.ts +2 -1
  2. package/cjs/index.js +3 -2
  3. package/cjs/index.js.map +1 -1
  4. package/cjs/table-series-number/event-manager.d.ts +16 -0
  5. package/cjs/table-series-number/event-manager.js +160 -0
  6. package/cjs/table-series-number/event-manager.js.map +1 -0
  7. package/cjs/table-series-number/index.d.ts +2 -0
  8. package/cjs/table-series-number/index.js +21 -0
  9. package/cjs/table-series-number/index.js.map +1 -0
  10. package/cjs/table-series-number/register.d.ts +1 -0
  11. package/cjs/table-series-number/register.js +14 -0
  12. package/cjs/table-series-number/register.js.map +1 -0
  13. package/cjs/table-series-number/table-series-number.d.ts +76 -0
  14. package/cjs/table-series-number/table-series-number.js +536 -0
  15. package/cjs/table-series-number/table-series-number.js.map +1 -0
  16. package/cjs/table-series-number/tools.d.ts +1 -0
  17. package/cjs/table-series-number/tools.js +14 -0
  18. package/cjs/table-series-number/tools.js.map +1 -0
  19. package/cjs/table-series-number/type.d.ts +80 -0
  20. package/cjs/table-series-number/type.js +17 -0
  21. package/cjs/table-series-number/type.js.map +1 -0
  22. package/dist/index.es.js +1023 -17
  23. package/es/index.d.ts +2 -1
  24. package/es/index.js +3 -1
  25. package/es/index.js.map +1 -1
  26. package/es/table-series-number/event-manager.d.ts +16 -0
  27. package/es/table-series-number/event-manager.js +154 -0
  28. package/es/table-series-number/event-manager.js.map +1 -0
  29. package/es/table-series-number/index.d.ts +2 -0
  30. package/es/table-series-number/index.js +4 -0
  31. package/es/table-series-number/index.js.map +1 -0
  32. package/es/table-series-number/register.d.ts +1 -0
  33. package/es/table-series-number/register.js +6 -0
  34. package/es/table-series-number/register.js.map +1 -0
  35. package/es/table-series-number/table-series-number.d.ts +76 -0
  36. package/es/table-series-number/table-series-number.js +544 -0
  37. package/es/table-series-number/table-series-number.js.map +1 -0
  38. package/es/table-series-number/tools.d.ts +1 -0
  39. package/es/table-series-number/tools.js +8 -0
  40. package/es/table-series-number/tools.js.map +1 -0
  41. package/es/table-series-number/type.d.ts +80 -0
  42. package/es/table-series-number/type.js +16 -0
  43. package/es/table-series-number/type.js.map +1 -0
  44. package/package.json +4 -4
@@ -0,0 +1,536 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.TableSeriesNumber = void 0;
6
+
7
+ const tools_1 = require("./tools"), vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), type_1 = require("./type"), event_manager_1 = require("./event-manager"), vrender_core_1 = require("@visactor/vrender-core"), register_1 = require("./register"), cornerSvg = '<svg t="1716726614852" class="icon" viewBox="0 0 1194 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2621" width="200" height="200"><path d="M1038.694079 367.237067c13.265507 23.342857-16.633865-40.004445-63.05621-40.004446H219.018794c-26.558738 0-46.46393 13.334815-63.05621 40.004446S0.006238 607.277601 0.006238 650.608819V940.647979a82.351494 82.351494 0 0 0 82.961402 83.349526H1111.702885a82.337632 82.337632 0 0 0 82.975264-83.349526V650.608819c0-43.331218-155.970208-283.371753-155.970208-283.371752zM730.066575 667.284269a136.328386 136.328386 0 0 1-132.738243 133.33429 133.417459 133.417459 0 0 1-132.738243-133.33429v-6.681269a40.6698 40.6698 0 0 0-36.497473-26.66963H73.015044l119.458874-220.02445s23.231965-40.004445 53.103614-40.004446h713.481918c26.544876 0 29.871649 10.008042 46.436207 40.004446L1128.33675 633.947231H769.904682c-26.184476 0-39.838107 7.623855-39.838107 33.337038zM338.505391 210.559919l-89.601086-86.69016a22.178487 22.178487 0 0 1 0-33.26773 21.984425 21.984425 0 0 1 33.170699 0l89.601087 86.676299a22.317102 22.317102 0 0 1 0 33.26773 24.950798 24.950798 0 0 1-33.1707 0z m252.197118-40.059891a25.532983 25.532983 0 0 1-6.639685-16.633865l-3.326773-126.694606A28.263709 28.263709 0 0 1 603.995739 0.515788c13.251646-3.326773 23.204242 10.021904 26.544877 23.342858V153.866163a28.249847 28.249847 0 0 1-23.259688 26.66963c-6.611961-3.312911-13.279369-3.312911-16.578419-10.035765z m235.646421 33.337038a22.372548 22.372548 0 0 1 0-33.337038l86.288175-90.030795a22.039871 22.039871 0 0 1 33.170699 0 22.289379 22.289379 0 0 1 0 33.364761l-82.961401 90.003072a25.962691 25.962691 0 0 1-36.483611 0z" fill="#8a8a8a" p-id="2622"></path></svg>';
8
+
9
+ (0, register_1.loadTableSeriesNumberComponent)();
10
+
11
+ class TableSeriesNumber extends base_1.AbstractComponent {
12
+ constructor(attributes, options) {
13
+ if (super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, TableSeriesNumber.defaultAttributes, attributes)),
14
+ this.name = "tableSeriesNumber", this._firstRowSeriesNumberIndex = 0, this._firstColSeriesNumberIndex = 0,
15
+ this._maxTextWidth = 0, this._changeRowSeriesNumberWidthTimer = null, this.interactionState = {
16
+ selectIndexs: new Set,
17
+ _lastHoverItem: null,
18
+ _lastClickItem: null
19
+ }, this._parsedRowSeriesNumberCellPadding = [ 0, 0, 0, 0 ], this._parsedColSeriesNumberCellPadding = [ 0, 0, 0, 0 ],
20
+ this.initRenderAll = !1, this.initRenderAll = (null == options ? void 0 : options.initRenderAll) || !1,
21
+ this._skipRenderAttributes.push("frozenTopRow"), this._skipRenderAttributes.push("frozenLeftCol"),
22
+ this._skipRenderAttributes.push("frozenRightCol"), this._skipRenderAttributes.push("frozenBottomRow"),
23
+ this._skipRenderAttributes.push("rowCount"), this._skipRenderAttributes.push("colCount"),
24
+ this._skipRenderAttributes.push("hover"), this._skipRenderAttributes.push("select"),
25
+ this.attribute.rowSeriesNumberCellStyle.text.padding) {
26
+ const padding = (0, vrender_core_1.parsePadding)(this.attribute.rowSeriesNumberCellStyle.text.padding);
27
+ this._parsedRowSeriesNumberCellPadding = "number" == typeof padding ? [ padding, padding, padding, padding ] : padding;
28
+ }
29
+ if (this.attribute.colSeriesNumberCellStyle.text.padding) {
30
+ const padding = (0, vrender_core_1.parsePadding)(this.attribute.colSeriesNumberCellStyle.text.padding);
31
+ this._parsedColSeriesNumberCellPadding = "number" == typeof padding ? [ padding, padding, padding, padding ] : padding;
32
+ }
33
+ this._eventManager = new event_manager_1.TableSeriesNumberEventManager(this);
34
+ }
35
+ get rowSeriesNumberWidth() {
36
+ const {rowSeriesNumberWidth: rowSeriesNumberWidth} = this.attribute;
37
+ return this._maxTextWidth ? Math.max(this._maxTextWidth + this._parsedRowSeriesNumberCellPadding[3] + this._parsedRowSeriesNumberCellPadding[1], "number" == typeof rowSeriesNumberWidth ? rowSeriesNumberWidth : 40) : "number" == typeof rowSeriesNumberWidth ? rowSeriesNumberWidth : 40;
38
+ }
39
+ get colSeriesNumberHeight() {
40
+ const {colSeriesNumberHeight: colSeriesNumberHeight} = this.attribute;
41
+ return "number" == typeof colSeriesNumberHeight ? colSeriesNumberHeight : 20;
42
+ }
43
+ get rowCount() {
44
+ const {rowCount: rowCount} = this.attribute;
45
+ return rowCount;
46
+ }
47
+ get colCount() {
48
+ const {colCount: colCount} = this.attribute;
49
+ return colCount;
50
+ }
51
+ bindEvents() {
52
+ this._eventManager.bindEvents();
53
+ }
54
+ dispatchTableSeriesNumberEvent(event, ...args) {
55
+ this._dispatchEvent(event, ...args);
56
+ }
57
+ render() {
58
+ const {rowCount: rowCount, colCount: colCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, innerView = this.createOrUpdateChild("tableSeriesNumberContainer", {
59
+ x: 0,
60
+ y: 0,
61
+ fill: "rgba(1,1,1,0)",
62
+ width: this.rowSeriesNumberWidth + colCount * ("number" == typeof colWidth ? colWidth : 20),
63
+ height: this.colSeriesNumberHeight + rowCount * ("number" == typeof rowHeight ? rowHeight : 20),
64
+ pickable: !1,
65
+ childrenPickable: !0
66
+ }, "group");
67
+ this._tableSeriesNumberContainer = innerView, this._renderContent();
68
+ }
69
+ _renderContent() {
70
+ if (this._renderRowSeriesNumber(), this._renderColSeriesNumber(), this._renderFrozenTopRowSeriesNumber(),
71
+ this._renderFrozenLeftColSeriesNumber(), this._renderCorner(), this.initRenderAll) {
72
+ this.recreateCellsToRowSeriesNumberGroup(0, this.attribute.rowCount - 1), this.recreateCellsToColSeriesNumberGroup(0, this.attribute.colCount - 1);
73
+ let y = 0;
74
+ for (let i = 0; i < this.attribute.rowCount; i++) this.setRowSeriesNumberCellAttributes(i, {
75
+ y: y,
76
+ height: "number" == typeof this.attribute.rowHeight ? this.attribute.rowHeight : 20
77
+ }), y += "number" == typeof this.attribute.rowHeight ? this.attribute.rowHeight : 20;
78
+ let x = 0;
79
+ for (let i = 0; i < this.attribute.colCount; i++) this.setColSeriesNumberCellAttributes(i, {
80
+ x: x,
81
+ width: "number" == typeof this.attribute.colWidth ? this.attribute.colWidth : 20
82
+ }), x += "number" == typeof this.attribute.colWidth ? this.attribute.colWidth : 20;
83
+ }
84
+ }
85
+ _renderCorner() {
86
+ const {rowCount: rowCount, colCount: colCount, cornerCellStyle: cornerSeriesNumberCellStyle, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, cornerGroup = this._tableSeriesNumberContainer.createOrUpdateChild("cornerSeriesNumberCell", {
87
+ x: 0,
88
+ y: 0,
89
+ fill: cornerSeriesNumberCellStyle.bgColor,
90
+ stroke: cornerSeriesNumberCellStyle.borderLine.stroke,
91
+ lineWidth: cornerSeriesNumberCellStyle.borderLine.lineWidth,
92
+ pickable: !0,
93
+ width: this.rowSeriesNumberWidth,
94
+ height: this.colSeriesNumberHeight
95
+ }, "group");
96
+ cornerGroup.id = "0,0", cornerGroup.states = cornerSeriesNumberCellStyle.states,
97
+ this._cornerGroup = cornerGroup;
98
+ }
99
+ _renderRowSeriesNumber() {
100
+ const {frozenRowCount: frozenRowCount, rowCount: rowCount, colCount: colCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, rowSeriesNumberGroup = this._tableSeriesNumberContainer.createOrUpdateChild("rowSeriesNumberCellGroup", {
101
+ x: 0,
102
+ y: this.colSeriesNumberHeight,
103
+ pickable: !0,
104
+ fill: rowSeriesNumberCellStyle.bgColor,
105
+ width: this.rowSeriesNumberWidth,
106
+ height: rowCount * ("number" == typeof rowHeight ? rowHeight : 20)
107
+ }, "group");
108
+ this._rowSeriesNumberGroup = rowSeriesNumberGroup;
109
+ }
110
+ _renderColSeriesNumber() {
111
+ const {frozenColCount: frozenColCount, rowCount: rowCount, colCount: colCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, colSeriesNumberGroup = this._tableSeriesNumberContainer.createOrUpdateChild("colSeriesNumberCellGroup", {
112
+ x: this.rowSeriesNumberWidth + frozenColCount * ("number" == typeof colWidth ? colWidth : 20),
113
+ y: 0,
114
+ pickable: !0,
115
+ fill: colSeriesNumberCellStyle.bgColor,
116
+ width: colCount * ("number" == typeof colWidth ? colWidth : 20),
117
+ height: this.colSeriesNumberHeight
118
+ }, "group");
119
+ this._colSeriesNumberGroup = colSeriesNumberGroup;
120
+ }
121
+ _renderFrozenTopRowSeriesNumber() {
122
+ const {frozenRowCount: frozenRowCount, colCount: colCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, frozenTopSeriesNumberGroup = this._tableSeriesNumberContainer.createOrUpdateChild("frozenTopSeriesNumberGroup", {
123
+ x: 0,
124
+ y: this.colSeriesNumberHeight,
125
+ width: this.rowSeriesNumberWidth,
126
+ height: frozenRowCount * ("number" == typeof rowHeight ? rowHeight : 20)
127
+ }, "group");
128
+ this._frozenTopRowSeriesNumberGroup = frozenTopSeriesNumberGroup;
129
+ }
130
+ _renderFrozenLeftColSeriesNumber() {
131
+ const {frozenColCount: frozenColCount, rowCount: rowCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, frozenLeftSeriesNumberGroup = this._tableSeriesNumberContainer.createOrUpdateChild("frozenLeftSeriesNumberGroup", {
132
+ x: this.rowSeriesNumberWidth,
133
+ y: 0,
134
+ height: this.colSeriesNumberHeight,
135
+ width: frozenColCount * ("number" == typeof colWidth ? colWidth : 20)
136
+ }, "group");
137
+ this._frozenLeftColSeriesNumberGroup = frozenLeftSeriesNumberGroup;
138
+ }
139
+ recreateCellsToRowSeriesNumberGroup(startIndex, endIndex) {
140
+ var _a, _b;
141
+ const {frozenRowCount: frozenRowCount, rowCount: rowCount, colCount: colCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute;
142
+ this._frozenTopRowSeriesNumberGroup.removeAllChild(), this._rowSeriesNumberGroup.removeAllChild();
143
+ let y = 0;
144
+ const height = ("number" == typeof rowHeight ? rowHeight : 20) - this._parsedRowSeriesNumberCellPadding[0] - this._parsedRowSeriesNumberCellPadding[2];
145
+ let x;
146
+ y = "middle" === rowSeriesNumberCellStyle.text.textBaseline ? this._parsedRowSeriesNumberCellPadding[0] + (height - rowSeriesNumberCellStyle.text.fontSize) / 2 : "bottom" === rowSeriesNumberCellStyle.text.textBaseline ? this._parsedRowSeriesNumberCellPadding[0] + height - rowSeriesNumberCellStyle.text.fontSize : this._parsedRowSeriesNumberCellPadding[0];
147
+ const width = this.rowSeriesNumberWidth - this._parsedRowSeriesNumberCellPadding[3] - this._parsedRowSeriesNumberCellPadding[1], textAlign = this.attribute.rowSeriesNumberCellStyle.text.textAlign, padding = this._parsedRowSeriesNumberCellPadding;
148
+ x = "center" === textAlign ? padding[3] + +width / 2 : "right" === textAlign ? padding[3] + width : padding[3];
149
+ for (let i = 0; i < frozenRowCount; i++) {
150
+ const cellGroup = this._frozenTopRowSeriesNumberGroup.createOrUpdateChild(`rowSeriesNumberCell-${i}`, {
151
+ x: 0,
152
+ y: 0,
153
+ pickable: !0,
154
+ fill: rowSeriesNumberCellStyle.bgColor,
155
+ stroke: rowSeriesNumberCellStyle.borderLine.stroke,
156
+ lineWidth: rowSeriesNumberCellStyle.borderLine.lineWidth,
157
+ width: this.rowSeriesNumberWidth,
158
+ height: "number" == typeof rowHeight ? rowHeight : 20
159
+ }, "group");
160
+ cellGroup.id = i, cellGroup.states = rowSeriesNumberCellStyle.states, (null === (_a = this.interactionState.selectIndexs) || void 0 === _a ? void 0 : _a.has(cellGroup.name)) && cellGroup.useStates([ type_1.SeriesNumberCellStateValue.select ]);
161
+ cellGroup.createOrUpdateChild(`rowSeriesNumberCellText-${i}`, Object.assign(Object.assign({
162
+ x: x,
163
+ y: y,
164
+ text: `${i + 1}`,
165
+ pickable: !1,
166
+ dx: 0
167
+ }, rowSeriesNumberCellStyle.text), {
168
+ textBaseline: "top"
169
+ }), "text");
170
+ }
171
+ this._firstRowSeriesNumberIndex = Math.max(startIndex, frozenRowCount) - frozenRowCount;
172
+ let thisTextMaxWidth = 0;
173
+ for (let i = this._firstRowSeriesNumberIndex; i <= endIndex - frozenRowCount; i++) {
174
+ const cellGroup = this._rowSeriesNumberGroup.createOrUpdateChild(`rowSeriesNumberCell-${i + frozenRowCount}`, {
175
+ x: 0,
176
+ y: 0,
177
+ pickable: !0,
178
+ fill: rowSeriesNumberCellStyle.bgColor,
179
+ stroke: rowSeriesNumberCellStyle.borderLine.stroke,
180
+ lineWidth: rowSeriesNumberCellStyle.borderLine.lineWidth,
181
+ width: this.rowSeriesNumberWidth,
182
+ height: "number" == typeof rowHeight ? rowHeight : 20
183
+ }, "group");
184
+ cellGroup.id = i + frozenRowCount, cellGroup.states = rowSeriesNumberCellStyle.states,
185
+ (null === (_b = this.interactionState.selectIndexs) || void 0 === _b ? void 0 : _b.has(cellGroup.name)) && cellGroup.useStates([ type_1.SeriesNumberCellStateValue.select ]);
186
+ const text = cellGroup.createOrUpdateChild(`rowSeriesNumberCellText-${i + frozenRowCount}`, Object.assign(Object.assign({
187
+ x: x,
188
+ y: y,
189
+ text: `${i + 1 + frozenRowCount}`,
190
+ pickable: !1,
191
+ dx: 0
192
+ }, rowSeriesNumberCellStyle.text), {
193
+ textBaseline: "top"
194
+ }), "text");
195
+ i === endIndex - frozenRowCount && (thisTextMaxWidth = text.clipedWidth);
196
+ }
197
+ clearTimeout(this._changeRowSeriesNumberWidthTimer), this._changeRowSeriesNumberWidthTimer = setTimeout((() => {
198
+ if (Math.abs(thisTextMaxWidth - this._maxTextWidth) >= 6) {
199
+ const oldWidth = this._maxTextWidth;
200
+ this._maxTextWidth = thisTextMaxWidth, this.changeRowSeriesNumberWidth(Math.max(this.rowSeriesNumberWidth, 20)),
201
+ this._dispatchEvent(type_1.SeriesNumberEvent.rowSeriesNumberWidthChange, {
202
+ newWidth: this.rowSeriesNumberWidth,
203
+ oldWidth: oldWidth
204
+ });
205
+ }
206
+ }), 100);
207
+ }
208
+ recreateCellsToColSeriesNumberGroup(startIndex, endIndex) {
209
+ var _a, _b, _c, _d;
210
+ const {colCount: colCount, colSeriesNumberCellStyle: colSeriesNumberCellStyle, frozenColCount: frozenColCount, colWidth: colWidth} = this.attribute, oldFrozenLeftColSeriesNumberGroupCellsWidth = new Map;
211
+ null === (_b = null === (_a = this._frozenLeftColSeriesNumberGroup) || void 0 === _a ? void 0 : _a.forEachChildren) || void 0 === _b || _b.call(_a, ((child, index) => {
212
+ oldFrozenLeftColSeriesNumberGroupCellsWidth.set(index, child.getAttributes().width);
213
+ })), this._frozenLeftColSeriesNumberGroup.removeAllChild(), this._colSeriesNumberGroup.removeAllChild();
214
+ let y = 0;
215
+ const height = this.colSeriesNumberHeight - this._parsedColSeriesNumberCellPadding[0] - this._parsedColSeriesNumberCellPadding[2];
216
+ let x;
217
+ y = "middle" === colSeriesNumberCellStyle.text.textBaseline ? this._parsedColSeriesNumberCellPadding[0] + (height - colSeriesNumberCellStyle.text.fontSize) / 2 : "bottom" === colSeriesNumberCellStyle.text.textBaseline ? this._parsedColSeriesNumberCellPadding[0] + height - colSeriesNumberCellStyle.text.fontSize : this._parsedColSeriesNumberCellPadding[0];
218
+ const width = ("number" == typeof colWidth ? colWidth : 20) - this._parsedColSeriesNumberCellPadding[3] - this._parsedColSeriesNumberCellPadding[1], textAlign = this.attribute.colSeriesNumberCellStyle.text.textAlign, padding = this._parsedColSeriesNumberCellPadding;
219
+ x = "center" === textAlign ? padding[3] + +width / 2 : "right" === textAlign ? padding[3] + width : padding[3];
220
+ for (let i = 0; i < frozenColCount; i++) {
221
+ const cellGroup = this._frozenLeftColSeriesNumberGroup.createOrUpdateChild(`colSeriesNumberCell-${i}`, {
222
+ x: 0,
223
+ y: 0,
224
+ pickable: !0,
225
+ fill: colSeriesNumberCellStyle.bgColor,
226
+ stroke: colSeriesNumberCellStyle.borderLine.stroke,
227
+ lineWidth: colSeriesNumberCellStyle.borderLine.lineWidth,
228
+ width: oldFrozenLeftColSeriesNumberGroupCellsWidth.get(i) || ("number" == typeof colWidth ? colWidth : 20),
229
+ height: this.colSeriesNumberHeight
230
+ }, "group");
231
+ cellGroup.id = i, cellGroup.states = colSeriesNumberCellStyle.states, (null === (_c = this.interactionState.selectIndexs) || void 0 === _c ? void 0 : _c.has(cellGroup.name)) && cellGroup.useStates([ type_1.SeriesNumberCellStateValue.select ]);
232
+ cellGroup.createOrUpdateChild(`colSeriesNumberCellText-${i}`, Object.assign(Object.assign({
233
+ x: x,
234
+ y: y,
235
+ dx: 0,
236
+ text: (0, tools_1.generateColField)(i),
237
+ pickable: !1
238
+ }, colSeriesNumberCellStyle.text), {
239
+ textBaseline: "top"
240
+ }), "text");
241
+ }
242
+ this._firstColSeriesNumberIndex = Math.max(startIndex, frozenColCount) - frozenColCount;
243
+ for (let i = this._firstColSeriesNumberIndex; i <= endIndex - frozenColCount; i++) {
244
+ const cellGroup = this._colSeriesNumberGroup.createOrUpdateChild(`colSeriesNumberCell-${i + frozenColCount}`, {
245
+ x: 0,
246
+ y: 0,
247
+ pickable: !0,
248
+ fill: colSeriesNumberCellStyle.bgColor,
249
+ stroke: colSeriesNumberCellStyle.borderLine.stroke,
250
+ lineWidth: colSeriesNumberCellStyle.borderLine.lineWidth,
251
+ width: "number" == typeof colWidth ? colWidth : 20,
252
+ height: this.colSeriesNumberHeight
253
+ }, "group");
254
+ cellGroup.id = i + frozenColCount, cellGroup.states = colSeriesNumberCellStyle.states,
255
+ (null === (_d = this.interactionState.selectIndexs) || void 0 === _d ? void 0 : _d.has(cellGroup.name)) && cellGroup.useStates([ type_1.SeriesNumberCellStateValue.select ]);
256
+ cellGroup.createOrUpdateChild(`colSeriesNumberCellText-${i + frozenColCount}`, Object.assign(Object.assign({
257
+ x: x,
258
+ y: y,
259
+ dx: 0,
260
+ text: (0, tools_1.generateColField)(i + frozenColCount),
261
+ pickable: !1
262
+ }, colSeriesNumberCellStyle.text), {
263
+ textBaseline: "top"
264
+ }), "text");
265
+ }
266
+ }
267
+ changeRowSeriesNumberWidth(newWidth) {
268
+ const {rowHeight: rowHeight, rowCount: oldRowCount, frozenRowCount: frozenRowCount, frozenColCount: frozenLeftCol, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle} = this.attribute;
269
+ this._cornerGroup.setAttributes({
270
+ width: newWidth
271
+ }), this._frozenTopRowSeriesNumberGroup.setAttributes({
272
+ width: newWidth
273
+ });
274
+ for (let i = 0; i < this._frozenTopRowSeriesNumberGroup.children.length; i++) this.setRowSeriesNumberCellAttributes(i, {
275
+ width: newWidth
276
+ });
277
+ this._rowSeriesNumberGroup.setAttributes({
278
+ width: newWidth
279
+ });
280
+ for (let i = 0; i < this._rowSeriesNumberGroup.children.length; i++) this.setRowSeriesNumberCellAttributes(i + this._firstRowSeriesNumberIndex + frozenRowCount, {
281
+ width: newWidth
282
+ });
283
+ this._frozenLeftColSeriesNumberGroup.setAttributes({
284
+ x: newWidth
285
+ }), this._colSeriesNumberGroup.setAttributes({
286
+ x: newWidth + this._frozenLeftColSeriesNumberGroup.getAttributes().width
287
+ });
288
+ }
289
+ getRowSeriesNumberCellGroup(index) {
290
+ const {frozenRowCount: frozenRowCount} = this.getAttributes();
291
+ if (index >= 0 && index < frozenRowCount) return this._frozenTopRowSeriesNumberGroup.children[index];
292
+ return this._rowSeriesNumberGroup.children[index - frozenRowCount - this._firstRowSeriesNumberIndex];
293
+ }
294
+ getColSeriesNumberCellGroup(index) {
295
+ const {frozenColCount: frozenColCount} = this.getAttributes();
296
+ if (index >= 0 && index < frozenColCount) return this._frozenLeftColSeriesNumberGroup.children[index];
297
+ return this._colSeriesNumberGroup.children[index - frozenColCount - this._firstColSeriesNumberIndex];
298
+ }
299
+ getRowSeriesNumberCellAttributes(index) {
300
+ const {frozenRowCount: frozenRowCount} = this.getAttributes();
301
+ if (index >= 0 && index < frozenRowCount) return this._frozenTopRowSeriesNumberGroup.children[index].attribute;
302
+ return this._rowSeriesNumberGroup.children[index - frozenRowCount - this._firstRowSeriesNumberIndex].attribute;
303
+ }
304
+ getColSeriesNumberCellAttributes(index) {
305
+ const {frozenColCount: frozenColCount} = this.getAttributes();
306
+ if (index >= 0 && index < frozenColCount) return this._frozenLeftColSeriesNumberGroup.children[index].attribute;
307
+ return this._colSeriesNumberGroup.children[index - frozenColCount - this._firstColSeriesNumberIndex].attribute;
308
+ }
309
+ setRowSeriesNumberCellAttributes(index, attributes) {
310
+ const {frozenRowCount: frozenRowCount} = this.getAttributes();
311
+ let targetCellGroup;
312
+ if (index >= 0 && index < frozenRowCount) {
313
+ const {height: oldHeight, width: oldWidth, y: y} = this._frozenTopRowSeriesNumberGroup.getAttributes();
314
+ targetCellGroup = this._frozenTopRowSeriesNumberGroup.children[index], targetCellGroup.setAttributes(attributes),
315
+ attributes.height && this._frozenTopRowSeriesNumberGroup.setAttributes({
316
+ height: this._frozenTopRowSeriesNumberGroup.getAttributes().height + (attributes.height - oldHeight)
317
+ }), attributes.width && this._frozenTopRowSeriesNumberGroup.setAttributes({
318
+ width: this._frozenTopRowSeriesNumberGroup.getAttributes().width + (attributes.width - oldWidth)
319
+ }), attributes.height && this._rowSeriesNumberGroup.setAttributes({
320
+ y: this._frozenTopRowSeriesNumberGroup.getAttributes().height + this._frozenTopRowSeriesNumberGroup.getAttributes().y
321
+ });
322
+ } else {
323
+ targetCellGroup = this._rowSeriesNumberGroup.children[index - frozenRowCount - this._firstRowSeriesNumberIndex],
324
+ targetCellGroup.setAttributes(attributes);
325
+ }
326
+ if (attributes.width) {
327
+ let x;
328
+ const width = attributes.width - this._parsedRowSeriesNumberCellPadding[3] - this._parsedRowSeriesNumberCellPadding[1], textAlign = this.attribute.rowSeriesNumberCellStyle.text.textAlign, padding = this._parsedRowSeriesNumberCellPadding;
329
+ x = "center" === textAlign ? padding[3] + +width / 2 : "right" === textAlign ? padding[3] + width : padding[3],
330
+ targetCellGroup.children[0].setAttributes({
331
+ x: x
332
+ });
333
+ }
334
+ if (attributes.height) {
335
+ const height = attributes.height - this._parsedRowSeriesNumberCellPadding[0] - this._parsedRowSeriesNumberCellPadding[2], textBaseline = this.attribute.rowSeriesNumberCellStyle.text.textBaseline, padding = this._parsedRowSeriesNumberCellPadding;
336
+ let y;
337
+ y = "middle" === textBaseline ? padding[0] + (height - this.attribute.rowSeriesNumberCellStyle.text.fontSize) / 2 : "bottom" === textBaseline ? padding[0] + height - this.attribute.rowSeriesNumberCellStyle.text.fontSize : padding[0],
338
+ targetCellGroup.children[0].setAttributes({
339
+ y: y
340
+ });
341
+ }
342
+ }
343
+ setColSeriesNumberCellAttributes(index, attributes) {
344
+ const {frozenColCount: frozenColCount} = this.getAttributes();
345
+ let targetCellGroup;
346
+ if (index >= 0 && index < frozenColCount) {
347
+ targetCellGroup = this._frozenLeftColSeriesNumberGroup.children[index];
348
+ const {height: oldHeight, width: oldWidth} = targetCellGroup.getAttributes();
349
+ targetCellGroup.setAttributes(attributes), attributes.height && this._frozenLeftColSeriesNumberGroup.setAttributes({
350
+ height: this._frozenLeftColSeriesNumberGroup.getAttributes().height + (attributes.height - oldHeight)
351
+ }), attributes.width && this._frozenLeftColSeriesNumberGroup.setAttributes({
352
+ width: this._frozenLeftColSeriesNumberGroup.getAttributes().width + (attributes.width - oldWidth)
353
+ }), attributes.width && this._colSeriesNumberGroup.setAttributes({
354
+ x: this._frozenLeftColSeriesNumberGroup.getAttributes().width + this._frozenLeftColSeriesNumberGroup.getAttributes().x
355
+ });
356
+ } else {
357
+ targetCellGroup = this._colSeriesNumberGroup.children[index - frozenColCount - this._firstColSeriesNumberIndex],
358
+ targetCellGroup.setAttributes(attributes);
359
+ }
360
+ if (attributes.width) {
361
+ let x;
362
+ const width = attributes.width - this._parsedColSeriesNumberCellPadding[3] - this._parsedColSeriesNumberCellPadding[1], textAlign = this.attribute.colSeriesNumberCellStyle.text.textAlign, padding = this._parsedColSeriesNumberCellPadding;
363
+ x = "center" === textAlign ? padding[3] + +width / 2 : "right" === textAlign ? padding[3] + width : padding[3],
364
+ targetCellGroup.children[0].setAttributes({
365
+ x: x
366
+ });
367
+ }
368
+ if (attributes.height) {
369
+ const height = attributes.height - this._parsedColSeriesNumberCellPadding[0] - this._parsedColSeriesNumberCellPadding[2], textBaseline = this.attribute.colSeriesNumberCellStyle.text.textBaseline, padding = this._parsedColSeriesNumberCellPadding;
370
+ let y;
371
+ y = "middle" === textBaseline ? padding[0] + (height - this.attribute.colSeriesNumberCellStyle.text.fontSize) / 2 : "bottom" === textBaseline ? padding[0] + height - this.attribute.colSeriesNumberCellStyle.text.fontSize : padding[0],
372
+ targetCellGroup.children[0].setAttributes({
373
+ y: y
374
+ });
375
+ }
376
+ }
377
+ setRowSeriesNumberGroupAttributes(attributes) {
378
+ this._rowSeriesNumberGroup.setAttributes(attributes);
379
+ }
380
+ setColSeriesNumberGroupAttributes(attributes) {
381
+ this._colSeriesNumberGroup.setAttributes(attributes);
382
+ }
383
+ addSelectedIndex(isRow, index) {
384
+ let name;
385
+ name = isRow ? `rowSeriesNumberCell-${index}` : `colSeriesNumberCell-${index}`,
386
+ this.interactionState.selectIndexs.add(name);
387
+ }
388
+ addRowSelectedRanges(ranges) {
389
+ performance.now();
390
+ for (let i = 0; i < ranges.length; i++) {
391
+ const {startIndex: startIndex, endIndex: endIndex} = ranges[i];
392
+ for (let j = startIndex; j <= endIndex; j++) {
393
+ const name = `rowSeriesNumberCell-${j}`;
394
+ this.interactionState.selectIndexs.add(name);
395
+ }
396
+ }
397
+ performance.now();
398
+ }
399
+ addColSelectedRanges(ranges) {
400
+ for (let i = 0; i < ranges.length; i++) {
401
+ const {startIndex: startIndex, endIndex: endIndex} = ranges[i];
402
+ for (let j = startIndex; j <= endIndex; j++) {
403
+ const name = `colSeriesNumberCell-${j}`;
404
+ this.interactionState.selectIndexs.add(name);
405
+ }
406
+ }
407
+ }
408
+ addCornderSelected() {
409
+ this.interactionState.selectIndexs.add(this._cornerGroup.name);
410
+ }
411
+ resetAllSelectedIndexs({rowIndexs: rowIndexs, colIndexs: colIndexs}) {
412
+ if (this.interactionState.selectIndexs = new Set, rowIndexs) for (let i = 0; i < rowIndexs.length; i++) {
413
+ const name = `rowSeriesNumberCell-${rowIndexs[i]}`;
414
+ this.interactionState.selectIndexs.add(name);
415
+ }
416
+ if (colIndexs) for (let i = 0; i < colIndexs.length; i++) {
417
+ const name = `colSeriesNumberCell-${colIndexs[i]}`;
418
+ this.interactionState.selectIndexs.add(name);
419
+ }
420
+ }
421
+ removeSelectedIndex(isRow, index) {
422
+ let name;
423
+ name = isRow ? `rowSeriesNumberLeftCell-${index}` : `colSeriesNumberCell-${index}`,
424
+ this.interactionState.selectIndexs.delete(name);
425
+ }
426
+ removeAllSelectedIndexs() {
427
+ var _a, _b;
428
+ for (const name of this.interactionState.selectIndexs) {
429
+ const isRow = name.startsWith("row"), isCol = name.startsWith("col"), index = Number(name.split("-")[1]);
430
+ isRow ? null === (_a = this.getRowSeriesNumberCellGroup(index)) || void 0 === _a || _a.removeState(type_1.SeriesNumberCellStateValue.select) : isCol ? null === (_b = this.getColSeriesNumberCellGroup(index)) || void 0 === _b || _b.removeState(type_1.SeriesNumberCellStateValue.select) : this._cornerGroup.removeState(type_1.SeriesNumberCellStateValue.select);
431
+ }
432
+ this.interactionState.selectIndexs.clear();
433
+ }
434
+ removeOneGroupSelected(group) {
435
+ this.interactionState.selectIndexs.delete(group.name), group.removeState(type_1.SeriesNumberCellStateValue.select);
436
+ }
437
+ addOneGroupSelected(group) {
438
+ this.interactionState.selectIndexs.add(group.name), group.useStates([ type_1.SeriesNumberCellStateValue.select ]);
439
+ }
440
+ renderSelectedIndexsState() {
441
+ var _a, _b;
442
+ const {rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle} = this.attribute;
443
+ for (const name of this.interactionState.selectIndexs) {
444
+ const isRow = name.startsWith("row"), isCol = name.startsWith("col"), index = Number(name.split("-")[1]);
445
+ isRow ? null === (_a = this.getRowSeriesNumberCellGroup(index)) || void 0 === _a || _a.useStates([ type_1.SeriesNumberCellStateValue.select ]) : isCol ? null === (_b = this.getColSeriesNumberCellGroup(index)) || void 0 === _b || _b.useStates([ type_1.SeriesNumberCellStateValue.select ]) : this._cornerGroup.useStates([ type_1.SeriesNumberCellStateValue.select ]);
446
+ }
447
+ this.stage.render();
448
+ }
449
+ }
450
+
451
+ exports.TableSeriesNumber = TableSeriesNumber, TableSeriesNumber.defaultAttributes = {
452
+ frozenRowCount: 0,
453
+ frozenColCount: 0,
454
+ rightFrozenColCount: 0,
455
+ bottomFrozenRowCount: 0,
456
+ pickable: !1,
457
+ rowCount: 100,
458
+ colCount: 100,
459
+ rowHeight: 20,
460
+ colWidth: 50,
461
+ rowSeriesNumberWidth: 30,
462
+ colSeriesNumberHeight: 30,
463
+ rowSeriesNumberCellStyle: {
464
+ text: {
465
+ fontSize: 14,
466
+ fill: "#7A7A7A",
467
+ pickable: !1,
468
+ textAlign: "left",
469
+ textBaseline: "middle",
470
+ padding: [ 2, 4, 2, 4 ]
471
+ },
472
+ borderLine: {
473
+ stroke: "#D9D9D9",
474
+ lineWidth: 1,
475
+ pickable: !1
476
+ },
477
+ bgColor: "#F9F9F9",
478
+ states: {
479
+ hover: {
480
+ fill: "#98C8A5",
481
+ opacity: .7
482
+ },
483
+ select: {
484
+ fill: "yellow",
485
+ opacity: .7
486
+ }
487
+ }
488
+ },
489
+ colSeriesNumberCellStyle: {
490
+ text: {
491
+ fontSize: 14,
492
+ fill: "#7A7A7A",
493
+ pickable: !1,
494
+ textAlign: "left",
495
+ textBaseline: "middle",
496
+ padding: [ 2, 4, 2, 4 ]
497
+ },
498
+ borderLine: {
499
+ stroke: "#D9D9D9",
500
+ lineWidth: 1,
501
+ pickable: !1
502
+ },
503
+ bgColor: "#F9F9F9",
504
+ states: {
505
+ hover: {
506
+ fill: "#98C8A5",
507
+ opacity: .7
508
+ },
509
+ select: {
510
+ fill: "orange",
511
+ opacity: .7
512
+ }
513
+ }
514
+ },
515
+ cornerCellStyle: {
516
+ borderLine: {
517
+ stroke: "#D9D9D9",
518
+ lineWidth: 1,
519
+ pickable: !1
520
+ },
521
+ bgColor: "#F9F9F9",
522
+ states: {
523
+ hover: {
524
+ fill: "#98C8A5",
525
+ opacity: .7
526
+ },
527
+ select: {
528
+ fill: "#98C8A5",
529
+ opacity: .7
530
+ }
531
+ }
532
+ },
533
+ hover: !0,
534
+ select: !0
535
+ };
536
+ //# sourceMappingURL=table-series-number.js.map