@visactor/vrender-components 1.0.14-alpha.0 → 1.0.15

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 +999 -4
  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 +6 -6
@@ -0,0 +1,544 @@
1
+ import { generateColField } from "./tools";
2
+
3
+ import { merge } from "@visactor/vutils";
4
+
5
+ import { AbstractComponent } from "../core/base";
6
+
7
+ import { SeriesNumberCellStateValue, SeriesNumberEvent } from "./type";
8
+
9
+ import { TableSeriesNumberEventManager } from "./event-manager";
10
+
11
+ import { parsePadding } from "@visactor/vrender-core";
12
+
13
+ import { loadTableSeriesNumberComponent } from "./register";
14
+
15
+ const 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>';
16
+
17
+ loadTableSeriesNumberComponent();
18
+
19
+ export class TableSeriesNumber extends AbstractComponent {
20
+ constructor(attributes, options) {
21
+ if (super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, TableSeriesNumber.defaultAttributes, attributes)),
22
+ this.name = "tableSeriesNumber", this._firstRowSeriesNumberIndex = 0, this._firstColSeriesNumberIndex = 0,
23
+ this._maxTextWidth = 0, this._changeRowSeriesNumberWidthTimer = null, this.interactionState = {
24
+ selectIndexs: new Set,
25
+ _lastHoverItem: null,
26
+ _lastClickItem: null
27
+ }, this._parsedRowSeriesNumberCellPadding = [ 0, 0, 0, 0 ], this._parsedColSeriesNumberCellPadding = [ 0, 0, 0, 0 ],
28
+ this.initRenderAll = !1, this.initRenderAll = (null == options ? void 0 : options.initRenderAll) || !1,
29
+ this._skipRenderAttributes.push("frozenTopRow"), this._skipRenderAttributes.push("frozenLeftCol"),
30
+ this._skipRenderAttributes.push("frozenRightCol"), this._skipRenderAttributes.push("frozenBottomRow"),
31
+ this._skipRenderAttributes.push("rowCount"), this._skipRenderAttributes.push("colCount"),
32
+ this._skipRenderAttributes.push("hover"), this._skipRenderAttributes.push("select"),
33
+ this.attribute.rowSeriesNumberCellStyle.text.padding) {
34
+ const padding = parsePadding(this.attribute.rowSeriesNumberCellStyle.text.padding);
35
+ this._parsedRowSeriesNumberCellPadding = "number" == typeof padding ? [ padding, padding, padding, padding ] : padding;
36
+ }
37
+ if (this.attribute.colSeriesNumberCellStyle.text.padding) {
38
+ const padding = parsePadding(this.attribute.colSeriesNumberCellStyle.text.padding);
39
+ this._parsedColSeriesNumberCellPadding = "number" == typeof padding ? [ padding, padding, padding, padding ] : padding;
40
+ }
41
+ this._eventManager = new TableSeriesNumberEventManager(this);
42
+ }
43
+ get rowSeriesNumberWidth() {
44
+ const {rowSeriesNumberWidth: rowSeriesNumberWidth} = this.attribute;
45
+ return this._maxTextWidth ? Math.max(this._maxTextWidth + this._parsedRowSeriesNumberCellPadding[3] + this._parsedRowSeriesNumberCellPadding[1], "number" == typeof rowSeriesNumberWidth ? rowSeriesNumberWidth : 40) : "number" == typeof rowSeriesNumberWidth ? rowSeriesNumberWidth : 40;
46
+ }
47
+ get colSeriesNumberHeight() {
48
+ const {colSeriesNumberHeight: colSeriesNumberHeight} = this.attribute;
49
+ return "number" == typeof colSeriesNumberHeight ? colSeriesNumberHeight : 20;
50
+ }
51
+ get rowCount() {
52
+ const {rowCount: rowCount} = this.attribute;
53
+ return rowCount;
54
+ }
55
+ get colCount() {
56
+ const {colCount: colCount} = this.attribute;
57
+ return colCount;
58
+ }
59
+ bindEvents() {
60
+ this._eventManager.bindEvents();
61
+ }
62
+ dispatchTableSeriesNumberEvent(event, ...args) {
63
+ this._dispatchEvent(event, ...args);
64
+ }
65
+ render() {
66
+ const {rowCount: rowCount, colCount: colCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, innerView = this.createOrUpdateChild("tableSeriesNumberContainer", {
67
+ x: 0,
68
+ y: 0,
69
+ fill: "rgba(1,1,1,0)",
70
+ width: this.rowSeriesNumberWidth + colCount * ("number" == typeof colWidth ? colWidth : 20),
71
+ height: this.colSeriesNumberHeight + rowCount * ("number" == typeof rowHeight ? rowHeight : 20),
72
+ pickable: !1,
73
+ childrenPickable: !0
74
+ }, "group");
75
+ this._tableSeriesNumberContainer = innerView, this._renderContent();
76
+ }
77
+ _renderContent() {
78
+ if (this._renderRowSeriesNumber(), this._renderColSeriesNumber(), this._renderFrozenTopRowSeriesNumber(),
79
+ this._renderFrozenLeftColSeriesNumber(), this._renderCorner(), this.initRenderAll) {
80
+ this.recreateCellsToRowSeriesNumberGroup(0, this.attribute.rowCount - 1), this.recreateCellsToColSeriesNumberGroup(0, this.attribute.colCount - 1);
81
+ let y = 0;
82
+ for (let i = 0; i < this.attribute.rowCount; i++) this.setRowSeriesNumberCellAttributes(i, {
83
+ y: y,
84
+ height: "number" == typeof this.attribute.rowHeight ? this.attribute.rowHeight : 20
85
+ }), y += "number" == typeof this.attribute.rowHeight ? this.attribute.rowHeight : 20;
86
+ let x = 0;
87
+ for (let i = 0; i < this.attribute.colCount; i++) this.setColSeriesNumberCellAttributes(i, {
88
+ x: x,
89
+ width: "number" == typeof this.attribute.colWidth ? this.attribute.colWidth : 20
90
+ }), x += "number" == typeof this.attribute.colWidth ? this.attribute.colWidth : 20;
91
+ }
92
+ }
93
+ _renderCorner() {
94
+ 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", {
95
+ x: 0,
96
+ y: 0,
97
+ fill: cornerSeriesNumberCellStyle.bgColor,
98
+ stroke: cornerSeriesNumberCellStyle.borderLine.stroke,
99
+ lineWidth: cornerSeriesNumberCellStyle.borderLine.lineWidth,
100
+ pickable: !0,
101
+ width: this.rowSeriesNumberWidth,
102
+ height: this.colSeriesNumberHeight
103
+ }, "group");
104
+ cornerGroup.id = "0,0", cornerGroup.states = cornerSeriesNumberCellStyle.states,
105
+ this._cornerGroup = cornerGroup;
106
+ }
107
+ _renderRowSeriesNumber() {
108
+ 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", {
109
+ x: 0,
110
+ y: this.colSeriesNumberHeight,
111
+ pickable: !0,
112
+ fill: rowSeriesNumberCellStyle.bgColor,
113
+ width: this.rowSeriesNumberWidth,
114
+ height: rowCount * ("number" == typeof rowHeight ? rowHeight : 20)
115
+ }, "group");
116
+ this._rowSeriesNumberGroup = rowSeriesNumberGroup;
117
+ }
118
+ _renderColSeriesNumber() {
119
+ 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", {
120
+ x: this.rowSeriesNumberWidth + frozenColCount * ("number" == typeof colWidth ? colWidth : 20),
121
+ y: 0,
122
+ pickable: !0,
123
+ fill: colSeriesNumberCellStyle.bgColor,
124
+ width: colCount * ("number" == typeof colWidth ? colWidth : 20),
125
+ height: this.colSeriesNumberHeight
126
+ }, "group");
127
+ this._colSeriesNumberGroup = colSeriesNumberGroup;
128
+ }
129
+ _renderFrozenTopRowSeriesNumber() {
130
+ const {frozenRowCount: frozenRowCount, colCount: colCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, frozenTopSeriesNumberGroup = this._tableSeriesNumberContainer.createOrUpdateChild("frozenTopSeriesNumberGroup", {
131
+ x: 0,
132
+ y: this.colSeriesNumberHeight,
133
+ width: this.rowSeriesNumberWidth,
134
+ height: frozenRowCount * ("number" == typeof rowHeight ? rowHeight : 20)
135
+ }, "group");
136
+ this._frozenTopRowSeriesNumberGroup = frozenTopSeriesNumberGroup;
137
+ }
138
+ _renderFrozenLeftColSeriesNumber() {
139
+ const {frozenColCount: frozenColCount, rowCount: rowCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute, frozenLeftSeriesNumberGroup = this._tableSeriesNumberContainer.createOrUpdateChild("frozenLeftSeriesNumberGroup", {
140
+ x: this.rowSeriesNumberWidth,
141
+ y: 0,
142
+ height: this.colSeriesNumberHeight,
143
+ width: frozenColCount * ("number" == typeof colWidth ? colWidth : 20)
144
+ }, "group");
145
+ this._frozenLeftColSeriesNumberGroup = frozenLeftSeriesNumberGroup;
146
+ }
147
+ recreateCellsToRowSeriesNumberGroup(startIndex, endIndex) {
148
+ var _a, _b;
149
+ const {frozenRowCount: frozenRowCount, rowCount: rowCount, colCount: colCount, rowSeriesNumberWidth: rowSeriesNumberWidth, colSeriesNumberHeight: colSeriesNumberHeight, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle, rowHeight: rowHeight, colWidth: colWidth} = this.attribute;
150
+ this._frozenTopRowSeriesNumberGroup.removeAllChild(), this._rowSeriesNumberGroup.removeAllChild();
151
+ let y = 0;
152
+ const height = ("number" == typeof rowHeight ? rowHeight : 20) - this._parsedRowSeriesNumberCellPadding[0] - this._parsedRowSeriesNumberCellPadding[2];
153
+ let x;
154
+ 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];
155
+ const width = this.rowSeriesNumberWidth - this._parsedRowSeriesNumberCellPadding[3] - this._parsedRowSeriesNumberCellPadding[1], textAlign = this.attribute.rowSeriesNumberCellStyle.text.textAlign, padding = this._parsedRowSeriesNumberCellPadding;
156
+ x = "center" === textAlign ? padding[3] + +width / 2 : "right" === textAlign ? padding[3] + width : padding[3];
157
+ for (let i = 0; i < frozenRowCount; i++) {
158
+ const cellGroup = this._frozenTopRowSeriesNumberGroup.createOrUpdateChild(`rowSeriesNumberCell-${i}`, {
159
+ x: 0,
160
+ y: 0,
161
+ pickable: !0,
162
+ fill: rowSeriesNumberCellStyle.bgColor,
163
+ stroke: rowSeriesNumberCellStyle.borderLine.stroke,
164
+ lineWidth: rowSeriesNumberCellStyle.borderLine.lineWidth,
165
+ width: this.rowSeriesNumberWidth,
166
+ height: "number" == typeof rowHeight ? rowHeight : 20
167
+ }, "group");
168
+ cellGroup.id = i, cellGroup.states = rowSeriesNumberCellStyle.states, (null === (_a = this.interactionState.selectIndexs) || void 0 === _a ? void 0 : _a.has(cellGroup.name)) && cellGroup.useStates([ SeriesNumberCellStateValue.select ]);
169
+ cellGroup.createOrUpdateChild(`rowSeriesNumberCellText-${i}`, Object.assign(Object.assign({
170
+ x: x,
171
+ y: y,
172
+ text: `${i + 1}`,
173
+ pickable: !1,
174
+ dx: 0
175
+ }, rowSeriesNumberCellStyle.text), {
176
+ textBaseline: "top"
177
+ }), "text");
178
+ }
179
+ this._firstRowSeriesNumberIndex = Math.max(startIndex, frozenRowCount) - frozenRowCount;
180
+ let thisTextMaxWidth = 0;
181
+ for (let i = this._firstRowSeriesNumberIndex; i <= endIndex - frozenRowCount; i++) {
182
+ const cellGroup = this._rowSeriesNumberGroup.createOrUpdateChild(`rowSeriesNumberCell-${i + frozenRowCount}`, {
183
+ x: 0,
184
+ y: 0,
185
+ pickable: !0,
186
+ fill: rowSeriesNumberCellStyle.bgColor,
187
+ stroke: rowSeriesNumberCellStyle.borderLine.stroke,
188
+ lineWidth: rowSeriesNumberCellStyle.borderLine.lineWidth,
189
+ width: this.rowSeriesNumberWidth,
190
+ height: "number" == typeof rowHeight ? rowHeight : 20
191
+ }, "group");
192
+ cellGroup.id = i + frozenRowCount, cellGroup.states = rowSeriesNumberCellStyle.states,
193
+ (null === (_b = this.interactionState.selectIndexs) || void 0 === _b ? void 0 : _b.has(cellGroup.name)) && cellGroup.useStates([ SeriesNumberCellStateValue.select ]);
194
+ const text = cellGroup.createOrUpdateChild(`rowSeriesNumberCellText-${i + frozenRowCount}`, Object.assign(Object.assign({
195
+ x: x,
196
+ y: y,
197
+ text: `${i + 1 + frozenRowCount}`,
198
+ pickable: !1,
199
+ dx: 0
200
+ }, rowSeriesNumberCellStyle.text), {
201
+ textBaseline: "top"
202
+ }), "text");
203
+ i === endIndex - frozenRowCount && (thisTextMaxWidth = text.clipedWidth);
204
+ }
205
+ clearTimeout(this._changeRowSeriesNumberWidthTimer), this._changeRowSeriesNumberWidthTimer = setTimeout((() => {
206
+ if (Math.abs(thisTextMaxWidth - this._maxTextWidth) >= 6) {
207
+ const oldWidth = this._maxTextWidth;
208
+ this._maxTextWidth = thisTextMaxWidth, this.changeRowSeriesNumberWidth(Math.max(this.rowSeriesNumberWidth, 20)),
209
+ this._dispatchEvent(SeriesNumberEvent.rowSeriesNumberWidthChange, {
210
+ newWidth: this.rowSeriesNumberWidth,
211
+ oldWidth: oldWidth
212
+ });
213
+ }
214
+ }), 100);
215
+ }
216
+ recreateCellsToColSeriesNumberGroup(startIndex, endIndex) {
217
+ var _a, _b, _c, _d;
218
+ const {colCount: colCount, colSeriesNumberCellStyle: colSeriesNumberCellStyle, frozenColCount: frozenColCount, colWidth: colWidth} = this.attribute, oldFrozenLeftColSeriesNumberGroupCellsWidth = new Map;
219
+ null === (_b = null === (_a = this._frozenLeftColSeriesNumberGroup) || void 0 === _a ? void 0 : _a.forEachChildren) || void 0 === _b || _b.call(_a, ((child, index) => {
220
+ oldFrozenLeftColSeriesNumberGroupCellsWidth.set(index, child.getAttributes().width);
221
+ })), this._frozenLeftColSeriesNumberGroup.removeAllChild(), this._colSeriesNumberGroup.removeAllChild();
222
+ let y = 0;
223
+ const height = this.colSeriesNumberHeight - this._parsedColSeriesNumberCellPadding[0] - this._parsedColSeriesNumberCellPadding[2];
224
+ let x;
225
+ 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];
226
+ const width = ("number" == typeof colWidth ? colWidth : 20) - this._parsedColSeriesNumberCellPadding[3] - this._parsedColSeriesNumberCellPadding[1], textAlign = this.attribute.colSeriesNumberCellStyle.text.textAlign, padding = this._parsedColSeriesNumberCellPadding;
227
+ x = "center" === textAlign ? padding[3] + +width / 2 : "right" === textAlign ? padding[3] + width : padding[3];
228
+ for (let i = 0; i < frozenColCount; i++) {
229
+ const cellGroup = this._frozenLeftColSeriesNumberGroup.createOrUpdateChild(`colSeriesNumberCell-${i}`, {
230
+ x: 0,
231
+ y: 0,
232
+ pickable: !0,
233
+ fill: colSeriesNumberCellStyle.bgColor,
234
+ stroke: colSeriesNumberCellStyle.borderLine.stroke,
235
+ lineWidth: colSeriesNumberCellStyle.borderLine.lineWidth,
236
+ width: oldFrozenLeftColSeriesNumberGroupCellsWidth.get(i) || ("number" == typeof colWidth ? colWidth : 20),
237
+ height: this.colSeriesNumberHeight
238
+ }, "group");
239
+ cellGroup.id = i, cellGroup.states = colSeriesNumberCellStyle.states, (null === (_c = this.interactionState.selectIndexs) || void 0 === _c ? void 0 : _c.has(cellGroup.name)) && cellGroup.useStates([ SeriesNumberCellStateValue.select ]);
240
+ cellGroup.createOrUpdateChild(`colSeriesNumberCellText-${i}`, Object.assign(Object.assign({
241
+ x: x,
242
+ y: y,
243
+ dx: 0,
244
+ text: generateColField(i),
245
+ pickable: !1
246
+ }, colSeriesNumberCellStyle.text), {
247
+ textBaseline: "top"
248
+ }), "text");
249
+ }
250
+ this._firstColSeriesNumberIndex = Math.max(startIndex, frozenColCount) - frozenColCount;
251
+ for (let i = this._firstColSeriesNumberIndex; i <= endIndex - frozenColCount; i++) {
252
+ const cellGroup = this._colSeriesNumberGroup.createOrUpdateChild(`colSeriesNumberCell-${i + frozenColCount}`, {
253
+ x: 0,
254
+ y: 0,
255
+ pickable: !0,
256
+ fill: colSeriesNumberCellStyle.bgColor,
257
+ stroke: colSeriesNumberCellStyle.borderLine.stroke,
258
+ lineWidth: colSeriesNumberCellStyle.borderLine.lineWidth,
259
+ width: "number" == typeof colWidth ? colWidth : 20,
260
+ height: this.colSeriesNumberHeight
261
+ }, "group");
262
+ cellGroup.id = i + frozenColCount, cellGroup.states = colSeriesNumberCellStyle.states,
263
+ (null === (_d = this.interactionState.selectIndexs) || void 0 === _d ? void 0 : _d.has(cellGroup.name)) && cellGroup.useStates([ SeriesNumberCellStateValue.select ]);
264
+ cellGroup.createOrUpdateChild(`colSeriesNumberCellText-${i + frozenColCount}`, Object.assign(Object.assign({
265
+ x: x,
266
+ y: y,
267
+ dx: 0,
268
+ text: generateColField(i + frozenColCount),
269
+ pickable: !1
270
+ }, colSeriesNumberCellStyle.text), {
271
+ textBaseline: "top"
272
+ }), "text");
273
+ }
274
+ }
275
+ changeRowSeriesNumberWidth(newWidth) {
276
+ const {rowHeight: rowHeight, rowCount: oldRowCount, frozenRowCount: frozenRowCount, frozenColCount: frozenLeftCol, rowSeriesNumberCellStyle: rowSeriesNumberCellStyle} = this.attribute;
277
+ this._cornerGroup.setAttributes({
278
+ width: newWidth
279
+ }), this._frozenTopRowSeriesNumberGroup.setAttributes({
280
+ width: newWidth
281
+ });
282
+ for (let i = 0; i < this._frozenTopRowSeriesNumberGroup.children.length; i++) this.setRowSeriesNumberCellAttributes(i, {
283
+ width: newWidth
284
+ });
285
+ this._rowSeriesNumberGroup.setAttributes({
286
+ width: newWidth
287
+ });
288
+ for (let i = 0; i < this._rowSeriesNumberGroup.children.length; i++) this.setRowSeriesNumberCellAttributes(i + this._firstRowSeriesNumberIndex + frozenRowCount, {
289
+ width: newWidth
290
+ });
291
+ this._frozenLeftColSeriesNumberGroup.setAttributes({
292
+ x: newWidth
293
+ }), this._colSeriesNumberGroup.setAttributes({
294
+ x: newWidth + this._frozenLeftColSeriesNumberGroup.getAttributes().width
295
+ });
296
+ }
297
+ getRowSeriesNumberCellGroup(index) {
298
+ const {frozenRowCount: frozenRowCount} = this.getAttributes();
299
+ if (index >= 0 && index < frozenRowCount) return this._frozenTopRowSeriesNumberGroup.children[index];
300
+ return this._rowSeriesNumberGroup.children[index - frozenRowCount - this._firstRowSeriesNumberIndex];
301
+ }
302
+ getColSeriesNumberCellGroup(index) {
303
+ const {frozenColCount: frozenColCount} = this.getAttributes();
304
+ if (index >= 0 && index < frozenColCount) return this._frozenLeftColSeriesNumberGroup.children[index];
305
+ return this._colSeriesNumberGroup.children[index - frozenColCount - this._firstColSeriesNumberIndex];
306
+ }
307
+ getRowSeriesNumberCellAttributes(index) {
308
+ const {frozenRowCount: frozenRowCount} = this.getAttributes();
309
+ if (index >= 0 && index < frozenRowCount) return this._frozenTopRowSeriesNumberGroup.children[index].attribute;
310
+ return this._rowSeriesNumberGroup.children[index - frozenRowCount - this._firstRowSeriesNumberIndex].attribute;
311
+ }
312
+ getColSeriesNumberCellAttributes(index) {
313
+ const {frozenColCount: frozenColCount} = this.getAttributes();
314
+ if (index >= 0 && index < frozenColCount) return this._frozenLeftColSeriesNumberGroup.children[index].attribute;
315
+ return this._colSeriesNumberGroup.children[index - frozenColCount - this._firstColSeriesNumberIndex].attribute;
316
+ }
317
+ setRowSeriesNumberCellAttributes(index, attributes) {
318
+ const {frozenRowCount: frozenRowCount} = this.getAttributes();
319
+ let targetCellGroup;
320
+ if (index >= 0 && index < frozenRowCount) {
321
+ const {height: oldHeight, width: oldWidth, y: y} = this._frozenTopRowSeriesNumberGroup.getAttributes();
322
+ targetCellGroup = this._frozenTopRowSeriesNumberGroup.children[index], targetCellGroup.setAttributes(attributes),
323
+ attributes.height && this._frozenTopRowSeriesNumberGroup.setAttributes({
324
+ height: this._frozenTopRowSeriesNumberGroup.getAttributes().height + (attributes.height - oldHeight)
325
+ }), attributes.width && this._frozenTopRowSeriesNumberGroup.setAttributes({
326
+ width: this._frozenTopRowSeriesNumberGroup.getAttributes().width + (attributes.width - oldWidth)
327
+ }), attributes.height && this._rowSeriesNumberGroup.setAttributes({
328
+ y: this._frozenTopRowSeriesNumberGroup.getAttributes().height + this._frozenTopRowSeriesNumberGroup.getAttributes().y
329
+ });
330
+ } else {
331
+ targetCellGroup = this._rowSeriesNumberGroup.children[index - frozenRowCount - this._firstRowSeriesNumberIndex],
332
+ targetCellGroup.setAttributes(attributes);
333
+ }
334
+ if (attributes.width) {
335
+ let x;
336
+ const width = attributes.width - this._parsedRowSeriesNumberCellPadding[3] - this._parsedRowSeriesNumberCellPadding[1], textAlign = this.attribute.rowSeriesNumberCellStyle.text.textAlign, padding = this._parsedRowSeriesNumberCellPadding;
337
+ x = "center" === textAlign ? padding[3] + +width / 2 : "right" === textAlign ? padding[3] + width : padding[3],
338
+ targetCellGroup.children[0].setAttributes({
339
+ x: x
340
+ });
341
+ }
342
+ if (attributes.height) {
343
+ const height = attributes.height - this._parsedRowSeriesNumberCellPadding[0] - this._parsedRowSeriesNumberCellPadding[2], textBaseline = this.attribute.rowSeriesNumberCellStyle.text.textBaseline, padding = this._parsedRowSeriesNumberCellPadding;
344
+ let y;
345
+ y = "middle" === textBaseline ? padding[0] + (height - this.attribute.rowSeriesNumberCellStyle.text.fontSize) / 2 : "bottom" === textBaseline ? padding[0] + height - this.attribute.rowSeriesNumberCellStyle.text.fontSize : padding[0],
346
+ targetCellGroup.children[0].setAttributes({
347
+ y: y
348
+ });
349
+ }
350
+ }
351
+ setColSeriesNumberCellAttributes(index, attributes) {
352
+ const {frozenColCount: frozenColCount} = this.getAttributes();
353
+ let targetCellGroup;
354
+ if (index >= 0 && index < frozenColCount) {
355
+ targetCellGroup = this._frozenLeftColSeriesNumberGroup.children[index];
356
+ const {height: oldHeight, width: oldWidth} = targetCellGroup.getAttributes();
357
+ targetCellGroup.setAttributes(attributes), attributes.height && this._frozenLeftColSeriesNumberGroup.setAttributes({
358
+ height: this._frozenLeftColSeriesNumberGroup.getAttributes().height + (attributes.height - oldHeight)
359
+ }), attributes.width && this._frozenLeftColSeriesNumberGroup.setAttributes({
360
+ width: this._frozenLeftColSeriesNumberGroup.getAttributes().width + (attributes.width - oldWidth)
361
+ }), attributes.width && this._colSeriesNumberGroup.setAttributes({
362
+ x: this._frozenLeftColSeriesNumberGroup.getAttributes().width + this._frozenLeftColSeriesNumberGroup.getAttributes().x
363
+ });
364
+ } else {
365
+ targetCellGroup = this._colSeriesNumberGroup.children[index - frozenColCount - this._firstColSeriesNumberIndex],
366
+ targetCellGroup.setAttributes(attributes);
367
+ }
368
+ if (attributes.width) {
369
+ let x;
370
+ const width = attributes.width - this._parsedColSeriesNumberCellPadding[3] - this._parsedColSeriesNumberCellPadding[1], textAlign = this.attribute.colSeriesNumberCellStyle.text.textAlign, padding = this._parsedColSeriesNumberCellPadding;
371
+ x = "center" === textAlign ? padding[3] + +width / 2 : "right" === textAlign ? padding[3] + width : padding[3],
372
+ targetCellGroup.children[0].setAttributes({
373
+ x: x
374
+ });
375
+ }
376
+ if (attributes.height) {
377
+ const height = attributes.height - this._parsedColSeriesNumberCellPadding[0] - this._parsedColSeriesNumberCellPadding[2], textBaseline = this.attribute.colSeriesNumberCellStyle.text.textBaseline, padding = this._parsedColSeriesNumberCellPadding;
378
+ let y;
379
+ y = "middle" === textBaseline ? padding[0] + (height - this.attribute.colSeriesNumberCellStyle.text.fontSize) / 2 : "bottom" === textBaseline ? padding[0] + height - this.attribute.colSeriesNumberCellStyle.text.fontSize : padding[0],
380
+ targetCellGroup.children[0].setAttributes({
381
+ y: y
382
+ });
383
+ }
384
+ }
385
+ setRowSeriesNumberGroupAttributes(attributes) {
386
+ this._rowSeriesNumberGroup.setAttributes(attributes);
387
+ }
388
+ setColSeriesNumberGroupAttributes(attributes) {
389
+ this._colSeriesNumberGroup.setAttributes(attributes);
390
+ }
391
+ addSelectedIndex(isRow, index) {
392
+ let name;
393
+ name = isRow ? `rowSeriesNumberCell-${index}` : `colSeriesNumberCell-${index}`,
394
+ this.interactionState.selectIndexs.add(name);
395
+ }
396
+ addRowSelectedRanges(ranges) {
397
+ performance.now();
398
+ for (let i = 0; i < ranges.length; i++) {
399
+ const {startIndex: startIndex, endIndex: endIndex} = ranges[i];
400
+ for (let j = startIndex; j <= endIndex; j++) {
401
+ const name = `rowSeriesNumberCell-${j}`;
402
+ this.interactionState.selectIndexs.add(name);
403
+ }
404
+ }
405
+ performance.now();
406
+ }
407
+ addColSelectedRanges(ranges) {
408
+ for (let i = 0; i < ranges.length; i++) {
409
+ const {startIndex: startIndex, endIndex: endIndex} = ranges[i];
410
+ for (let j = startIndex; j <= endIndex; j++) {
411
+ const name = `colSeriesNumberCell-${j}`;
412
+ this.interactionState.selectIndexs.add(name);
413
+ }
414
+ }
415
+ }
416
+ addCornderSelected() {
417
+ this.interactionState.selectIndexs.add(this._cornerGroup.name);
418
+ }
419
+ resetAllSelectedIndexs({rowIndexs: rowIndexs, colIndexs: colIndexs}) {
420
+ if (this.interactionState.selectIndexs = new Set, rowIndexs) for (let i = 0; i < rowIndexs.length; i++) {
421
+ const name = `rowSeriesNumberCell-${rowIndexs[i]}`;
422
+ this.interactionState.selectIndexs.add(name);
423
+ }
424
+ if (colIndexs) for (let i = 0; i < colIndexs.length; i++) {
425
+ const name = `colSeriesNumberCell-${colIndexs[i]}`;
426
+ this.interactionState.selectIndexs.add(name);
427
+ }
428
+ }
429
+ removeSelectedIndex(isRow, index) {
430
+ let name;
431
+ name = isRow ? `rowSeriesNumberLeftCell-${index}` : `colSeriesNumberCell-${index}`,
432
+ this.interactionState.selectIndexs.delete(name);
433
+ }
434
+ removeAllSelectedIndexs() {
435
+ var _a, _b;
436
+ for (const name of this.interactionState.selectIndexs) {
437
+ const isRow = name.startsWith("row"), isCol = name.startsWith("col"), index = Number(name.split("-")[1]);
438
+ isRow ? null === (_a = this.getRowSeriesNumberCellGroup(index)) || void 0 === _a || _a.removeState(SeriesNumberCellStateValue.select) : isCol ? null === (_b = this.getColSeriesNumberCellGroup(index)) || void 0 === _b || _b.removeState(SeriesNumberCellStateValue.select) : this._cornerGroup.removeState(SeriesNumberCellStateValue.select);
439
+ }
440
+ this.interactionState.selectIndexs.clear();
441
+ }
442
+ removeOneGroupSelected(group) {
443
+ this.interactionState.selectIndexs.delete(group.name), group.removeState(SeriesNumberCellStateValue.select);
444
+ }
445
+ addOneGroupSelected(group) {
446
+ this.interactionState.selectIndexs.add(group.name), group.useStates([ SeriesNumberCellStateValue.select ]);
447
+ }
448
+ renderSelectedIndexsState() {
449
+ var _a, _b;
450
+ const {rowSeriesNumberCellStyle: rowSeriesNumberCellStyle, colSeriesNumberCellStyle: colSeriesNumberCellStyle} = this.attribute;
451
+ for (const name of this.interactionState.selectIndexs) {
452
+ const isRow = name.startsWith("row"), isCol = name.startsWith("col"), index = Number(name.split("-")[1]);
453
+ isRow ? null === (_a = this.getRowSeriesNumberCellGroup(index)) || void 0 === _a || _a.useStates([ SeriesNumberCellStateValue.select ]) : isCol ? null === (_b = this.getColSeriesNumberCellGroup(index)) || void 0 === _b || _b.useStates([ SeriesNumberCellStateValue.select ]) : this._cornerGroup.useStates([ SeriesNumberCellStateValue.select ]);
454
+ }
455
+ this.stage.render();
456
+ }
457
+ }
458
+
459
+ TableSeriesNumber.defaultAttributes = {
460
+ frozenRowCount: 0,
461
+ frozenColCount: 0,
462
+ rightFrozenColCount: 0,
463
+ bottomFrozenRowCount: 0,
464
+ pickable: !1,
465
+ rowCount: 100,
466
+ colCount: 100,
467
+ rowHeight: 20,
468
+ colWidth: 50,
469
+ rowSeriesNumberWidth: 30,
470
+ colSeriesNumberHeight: 30,
471
+ rowSeriesNumberCellStyle: {
472
+ text: {
473
+ fontSize: 14,
474
+ fill: "#7A7A7A",
475
+ pickable: !1,
476
+ textAlign: "left",
477
+ textBaseline: "middle",
478
+ padding: [ 2, 4, 2, 4 ]
479
+ },
480
+ borderLine: {
481
+ stroke: "#D9D9D9",
482
+ lineWidth: 1,
483
+ pickable: !1
484
+ },
485
+ bgColor: "#F9F9F9",
486
+ states: {
487
+ hover: {
488
+ fill: "#98C8A5",
489
+ opacity: .7
490
+ },
491
+ select: {
492
+ fill: "yellow",
493
+ opacity: .7
494
+ }
495
+ }
496
+ },
497
+ colSeriesNumberCellStyle: {
498
+ text: {
499
+ fontSize: 14,
500
+ fill: "#7A7A7A",
501
+ pickable: !1,
502
+ textAlign: "left",
503
+ textBaseline: "middle",
504
+ padding: [ 2, 4, 2, 4 ]
505
+ },
506
+ borderLine: {
507
+ stroke: "#D9D9D9",
508
+ lineWidth: 1,
509
+ pickable: !1
510
+ },
511
+ bgColor: "#F9F9F9",
512
+ states: {
513
+ hover: {
514
+ fill: "#98C8A5",
515
+ opacity: .7
516
+ },
517
+ select: {
518
+ fill: "orange",
519
+ opacity: .7
520
+ }
521
+ }
522
+ },
523
+ cornerCellStyle: {
524
+ borderLine: {
525
+ stroke: "#D9D9D9",
526
+ lineWidth: 1,
527
+ pickable: !1
528
+ },
529
+ bgColor: "#F9F9F9",
530
+ states: {
531
+ hover: {
532
+ fill: "#98C8A5",
533
+ opacity: .7
534
+ },
535
+ select: {
536
+ fill: "#98C8A5",
537
+ opacity: .7
538
+ }
539
+ }
540
+ },
541
+ hover: !0,
542
+ select: !0
543
+ };
544
+ //# sourceMappingURL=table-series-number.js.map