@visactor/vtable 1.11.3 → 1.11.5

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 (63) hide show
  1. package/cjs/ListTable-all.js +6 -5
  2. package/cjs/ListTable-all.js.map +1 -1
  3. package/cjs/PivotTable.js +14 -3
  4. package/cjs/PivotTable.js.map +1 -1
  5. package/cjs/core/BaseTable.d.ts +2 -2
  6. package/cjs/core/BaseTable.js +13 -8
  7. package/cjs/core/BaseTable.js.map +1 -1
  8. package/cjs/core/style-helper.js +6 -6
  9. package/cjs/core/style-helper.js.map +1 -1
  10. package/cjs/index.d.ts +1 -4
  11. package/cjs/index.js +2 -3
  12. package/cjs/index.js.map +1 -1
  13. package/cjs/plugins/custom-cell-style.d.ts +6 -2
  14. package/cjs/plugins/custom-cell-style.js +8 -2
  15. package/cjs/plugins/custom-cell-style.js.map +1 -1
  16. package/cjs/plugins/invert-highlight.d.ts +0 -18
  17. package/cjs/plugins/invert-highlight.js +3 -52
  18. package/cjs/plugins/invert-highlight.js.map +1 -1
  19. package/cjs/plugins/list-tree-stick-cell.d.ts +3 -1
  20. package/cjs/plugins/list-tree-stick-cell.js +1 -1
  21. package/cjs/plugins/list-tree-stick-cell.js.map +1 -1
  22. package/cjs/ts-types/base-table.d.ts +4 -4
  23. package/cjs/ts-types/base-table.js.map +1 -1
  24. package/cjs/vrender.js.map +1 -1
  25. package/dist/vtable.js +188 -517
  26. package/dist/vtable.min.js +2 -2
  27. package/es/ListTable-all.js +5 -3
  28. package/es/ListTable-all.js.map +1 -1
  29. package/es/PivotTable.js +14 -3
  30. package/es/PivotTable.js.map +1 -1
  31. package/es/core/BaseTable.d.ts +2 -2
  32. package/es/core/BaseTable.js +12 -9
  33. package/es/core/BaseTable.js.map +1 -1
  34. package/es/core/style-helper.js +7 -7
  35. package/es/core/style-helper.js.map +1 -1
  36. package/es/index.d.ts +1 -4
  37. package/es/index.js +1 -7
  38. package/es/index.js.map +1 -1
  39. package/es/plugins/custom-cell-style.d.ts +6 -2
  40. package/es/plugins/custom-cell-style.js +6 -0
  41. package/es/plugins/custom-cell-style.js.map +1 -1
  42. package/es/plugins/invert-highlight.d.ts +0 -18
  43. package/es/plugins/invert-highlight.js +0 -55
  44. package/es/plugins/invert-highlight.js.map +1 -1
  45. package/es/plugins/list-tree-stick-cell.d.ts +3 -1
  46. package/es/plugins/list-tree-stick-cell.js +4 -4
  47. package/es/plugins/list-tree-stick-cell.js.map +1 -1
  48. package/es/ts-types/base-table.d.ts +4 -4
  49. package/es/ts-types/base-table.js.map +1 -1
  50. package/es/vrender.js.map +1 -1
  51. package/package.json +3 -3
  52. package/cjs/plugins/carousel-animation.d.ts +0 -48
  53. package/cjs/plugins/carousel-animation.js +0 -71
  54. package/cjs/plugins/carousel-animation.js.map +0 -1
  55. package/cjs/plugins/header-highlight.d.ts +0 -21
  56. package/cjs/plugins/header-highlight.js +0 -108
  57. package/cjs/plugins/header-highlight.js.map +0 -1
  58. package/es/plugins/carousel-animation.d.ts +0 -48
  59. package/es/plugins/carousel-animation.js +0 -63
  60. package/es/plugins/carousel-animation.js.map +0 -1
  61. package/es/plugins/header-highlight.d.ts +0 -21
  62. package/es/plugins/header-highlight.js +0 -100
  63. package/es/plugins/header-highlight.js.map +0 -1
@@ -1,63 +0,0 @@
1
- export class CarouselAnimationPlugin {
2
- constructor(table, options) {
3
- var _a, _b, _c, _d, _e, _f;
4
- this.willUpdateRow = !1, this.willUpdateCol = !1, this.table = table, this.rowCount = null !== (_a = null == options ? void 0 : options.rowCount) && void 0 !== _a ? _a : void 0,
5
- this.colCount = null !== (_b = null == options ? void 0 : options.colCount) && void 0 !== _b ? _b : void 0,
6
- this.animationDuration = null !== (_c = null == options ? void 0 : options.animationDuration) && void 0 !== _c ? _c : 500,
7
- this.animationDelay = null !== (_d = null == options ? void 0 : options.animationDelay) && void 0 !== _d ? _d : 1e3,
8
- this.animationEasing = null !== (_e = null == options ? void 0 : options.animationEasing) && void 0 !== _e ? _e : "linear",
9
- this.replaceScrollAction = null !== (_f = null == options ? void 0 : options.replaceScrollAction) && void 0 !== _f && _f,
10
- this.customDistColFunction = options.customDistColFunction, this.customDistRowFunction = options.customDistRowFunction,
11
- this.reset(), this.init();
12
- }
13
- init() {
14
- this.replaceScrollAction && (this.table.disableScroll(), this.table.scenegraph.stage.addEventListener("wheel", this.onScrollEnd.bind(this)));
15
- }
16
- reset() {
17
- this.playing = !1, this.row = this.table.frozenRowCount, this.col = this.table.frozenColCount;
18
- }
19
- onScrollEnd(e) {
20
- this.rowCount ? (e.deltaY > 0 ? (this.row += this.rowCount, this.row = Math.min(this.row, this.table.rowCount - this.table.frozenRowCount)) : e.deltaY < 0 && (this.row -= this.rowCount,
21
- this.row = Math.max(this.row, this.table.frozenRowCount)), this.table.scrollToRow(this.row, {
22
- duration: this.animationDuration,
23
- easing: this.animationEasing
24
- })) : this.colCount && (e.deltaX > 0 ? (this.col += this.colCount, this.col = Math.min(this.col, this.table.colCount - this.table.frozenColCount)) : e.deltaX < 0 && (this.col -= this.colCount,
25
- this.col = Math.max(this.col, this.table.frozenColCount)), this.table.scrollToCol(this.col, {
26
- duration: this.animationDuration,
27
- easing: this.animationEasing
28
- }));
29
- }
30
- play() {
31
- this.playing = !0, this.rowCount && !this.willUpdateRow ? this.updateRow() : this.colCount && !this.willUpdateCol && this.updateCol();
32
- }
33
- pause() {
34
- this.playing = !1;
35
- }
36
- updateRow() {
37
- var _a;
38
- if (!this.playing || this.table.isReleased) return;
39
- let animation = !0;
40
- const customRow = this.customDistRowFunction && this.customDistRowFunction(this.row, this.table);
41
- customRow ? (this.row = customRow.distRow, animation = null === (_a = customRow.animation) || void 0 === _a || _a) : this.table.scenegraph.proxy.screenTopRow !== this.row ? (this.row = this.table.frozenRowCount,
42
- animation = !1) : this.row += this.rowCount, this.table.scrollToRow(this.row, animation ? {
43
- duration: this.animationDuration,
44
- easing: this.animationEasing
45
- } : void 0), this.willUpdateRow = !0, setTimeout((() => {
46
- this.willUpdateRow = !1, this.updateRow();
47
- }), this.animationDuration + this.animationDelay);
48
- }
49
- updateCol() {
50
- var _a;
51
- if (!this.playing || this.table.isReleased) return;
52
- let animation = !0;
53
- const customCol = this.customDistColFunction && this.customDistColFunction(this.col, this.table);
54
- customCol ? (this.col = customCol.distCol, animation = null === (_a = customCol.animation) || void 0 === _a || _a) : this.table.scenegraph.proxy.screenLeftCol !== this.col ? (this.col = this.table.frozenColCount,
55
- animation = !1) : this.col += this.colCount, this.table.scrollToCol(this.col, animation ? {
56
- duration: this.animationDuration,
57
- easing: this.animationEasing
58
- } : void 0), this.willUpdateCol = !0, setTimeout((() => {
59
- this.willUpdateCol = !1, this.updateCol();
60
- }), this.animationDuration + this.animationDelay);
61
- }
62
- }
63
- //# sourceMappingURL=carousel-animation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/plugins/carousel-animation.ts"],"names":[],"mappings":"AAeA,MAAM,OAAO,uBAAuB;IAkBlC,YAAY,KAAmB,EAAE,OAAyC;;QAL1E,kBAAa,GAAY,KAAK,CAAC;QAC/B,kBAAa,GAAY,KAAK,CAAC;QAK7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,CAAC,QAAQ,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,SAAS,CAAC;QAC/C,IAAI,CAAC,QAAQ,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,SAAS,CAAC;QAC/C,IAAI,CAAC,iBAAiB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,mCAAI,GAAG,CAAC;QAC3D,IAAI,CAAC,cAAc,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,mCAAI,IAAI,CAAC;QACtD,IAAI,CAAC,eAAe,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,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IACJ,CAAC;IAED,SAAS;;QACP,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;YAC1C,OAAO;SACR;QAED,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,MAAM,SAAS,GAAG,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjG,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;YAC7B,SAAS,GAAG,MAAA,SAAS,CAAC,SAAS,mCAAI,IAAI,CAAC;SACzC;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC,GAAG,EAAE;YACjE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;YACrC,SAAS,GAAG,KAAK,CAAC;SACnB;aAAM;YACL,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC;SAC3B;QAED,IAAI,CAAC,KAAK,CAAC,WAAW,CACpB,IAAI,CAAC,GAAG,EACR,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,SAAS,CAC3F,CAAC;QAEF,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,UAAU,CACR,GAAG,EAAE;YACH,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;YAC3B,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC,EAED,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAC7C,CAAC;IACJ,CAAC;CACF","file":"carousel-animation.js","sourcesContent":["import type { EasingType } from './../vrender';\nimport type { BaseTableAPI } from '../ts-types/base-table';\n\nexport interface ICarouselAnimationPluginOptions {\n rowCount?: number;\n colCount?: number;\n animationDuration?: number;\n animationDelay?: number;\n animationEasing?: EasingType;\n replaceScrollAction?: boolean;\n\n customDistRowFunction?: (row: number, table: BaseTableAPI) => { distRow: number; animation?: boolean } | undefined;\n customDistColFunction?: (col: number, table: BaseTableAPI) => { distCol: number; animation?: boolean } | undefined;\n}\n\nexport class CarouselAnimationPlugin {\n table: BaseTableAPI;\n\n rowCount: number;\n colCount: number;\n animationDuration: number;\n animationDelay: number;\n animationEasing: EasingType;\n replaceScrollAction: boolean;\n\n playing: boolean;\n row: number;\n col: number;\n willUpdateRow: boolean = false;\n willUpdateCol: boolean = false;\n\n customDistRowFunction?: (row: number, table: BaseTableAPI) => { distRow: number; animation?: boolean } | undefined;\n customDistColFunction?: (col: number, table: BaseTableAPI) => { distCol: number; animation?: boolean } | undefined;\n constructor(table: BaseTableAPI, options?: ICarouselAnimationPluginOptions) {\n this.table = table;\n\n this.rowCount = options?.rowCount ?? undefined;\n this.colCount = options?.colCount ?? undefined;\n this.animationDuration = options?.animationDuration ?? 500;\n this.animationDelay = options?.animationDelay ?? 1000;\n this.animationEasing = options?.animationEasing ?? 'linear';\n this.replaceScrollAction = options?.replaceScrollAction ?? false;\n\n this.customDistColFunction = options.customDistColFunction;\n this.customDistRowFunction = options.customDistRowFunction;\n\n this.reset();\n this.init();\n }\n\n init() {\n if (this.replaceScrollAction) {\n this.table.disableScroll();\n\n this.table.scenegraph.stage.addEventListener('wheel', this.onScrollEnd.bind(this));\n }\n }\n\n reset() {\n this.playing = false;\n this.row = this.table.frozenRowCount;\n this.col = this.table.frozenColCount;\n }\n\n onScrollEnd(e: Event) {\n if (this.rowCount) {\n if ((e as any).deltaY > 0) {\n this.row += this.rowCount;\n this.row = Math.min(this.row, this.table.rowCount - this.table.frozenRowCount);\n } else if ((e as any).deltaY < 0) {\n this.row -= this.rowCount;\n this.row = Math.max(this.row, this.table.frozenRowCount);\n }\n this.table.scrollToRow(this.row, { duration: this.animationDuration, easing: this.animationEasing });\n } else if (this.colCount) {\n if ((e as any).deltaX > 0) {\n this.col += this.colCount;\n this.col = Math.min(this.col, this.table.colCount - this.table.frozenColCount);\n } else if ((e as any).deltaX < 0) {\n this.col -= this.colCount;\n this.col = Math.max(this.col, this.table.frozenColCount);\n }\n this.table.scrollToCol(this.col, { duration: this.animationDuration, easing: this.animationEasing });\n }\n }\n\n play() {\n this.playing = true;\n\n if (this.rowCount && !this.willUpdateRow) {\n this.updateRow();\n } else if (this.colCount && !this.willUpdateCol) {\n this.updateCol();\n }\n }\n\n pause() {\n this.playing = false;\n }\n\n updateRow() {\n if (!this.playing || this.table.isReleased) {\n return;\n }\n\n let animation = true;\n const customRow = this.customDistRowFunction && this.customDistRowFunction(this.row, this.table);\n if (customRow) {\n this.row = customRow.distRow;\n animation = customRow.animation ?? true;\n } else if (this.table.scenegraph.proxy.screenTopRow !== this.row) {\n this.row = this.table.frozenRowCount;\n animation = false;\n } else {\n this.row += this.rowCount;\n }\n this.table.scrollToRow(\n this.row,\n animation ? { duration: this.animationDuration, easing: this.animationEasing } : undefined\n );\n this.willUpdateRow = true;\n setTimeout(\n () => {\n this.willUpdateRow = false;\n this.updateRow();\n },\n // animation ? this.animationDuration + this.animationDelay : 0\n this.animationDuration + this.animationDelay\n );\n }\n\n updateCol() {\n if (!this.playing || this.table.isReleased) {\n return;\n }\n\n let animation = true;\n const customCol = this.customDistColFunction && this.customDistColFunction(this.col, this.table);\n if (customCol) {\n this.col = customCol.distCol;\n animation = customCol.animation ?? true;\n } else if (this.table.scenegraph.proxy.screenLeftCol !== this.col) {\n this.col = this.table.frozenColCount;\n animation = false;\n } else {\n this.col += this.colCount;\n }\n\n this.table.scrollToCol(\n this.col,\n animation ? { duration: this.animationDuration, easing: this.animationEasing } : undefined\n );\n\n this.willUpdateCol = true;\n setTimeout(\n () => {\n this.willUpdateCol = false;\n this.updateCol();\n },\n // animation ? this.animationDuration + this.animationDelay : 0\n this.animationDuration + this.animationDelay\n );\n }\n}\n"]}
@@ -1,21 +0,0 @@
1
- import type { CellRange } from '../ts-types';
2
- import type { BaseTableAPI } from '../ts-types/base-table';
3
- export interface IHeaderHighlightPluginOptions {
4
- rowHighlight?: boolean;
5
- colHighlight?: boolean;
6
- colHighlightBGColor?: string;
7
- colHighlightColor?: string;
8
- rowHighlightBGColor?: string;
9
- rowHighlightColor?: string;
10
- }
11
- export declare class HeaderHighlightPlugin {
12
- table: BaseTableAPI;
13
- options: IHeaderHighlightPluginOptions;
14
- colHeaderRange?: CellRange;
15
- rowHeaderRange?: CellRange;
16
- constructor(table: BaseTableAPI, options?: IHeaderHighlightPluginOptions);
17
- registerStyle(): void;
18
- bindEvent(): void;
19
- clearHighlight(): void;
20
- updateHighlight(): void;
21
- }
@@ -1,100 +0,0 @@
1
- export class HeaderHighlightPlugin {
2
- constructor(table, options) {
3
- this.table = table, this.options = options, this.registerStyle(), this.bindEvent();
4
- }
5
- registerStyle() {
6
- var _a, _b, _c, _d, _e, _f, _g, _h;
7
- this.table.registerCustomCellStyle("col-highlight", {
8
- bgColor: null !== (_b = null === (_a = this.options) || void 0 === _a ? void 0 : _a.colHighlightBGColor) && void 0 !== _b ? _b : "#82b2f5",
9
- color: null !== (_d = null === (_c = this.options) || void 0 === _c ? void 0 : _c.colHighlightColor) && void 0 !== _d ? _d : "#FFF"
10
- }), this.table.registerCustomCellStyle("row-highlight", {
11
- bgColor: null !== (_f = null === (_e = this.options) || void 0 === _e ? void 0 : _e.rowHighlightBGColor) && void 0 !== _f ? _f : "#82b2f5",
12
- color: null !== (_h = null === (_g = this.options) || void 0 === _g ? void 0 : _g.rowHighlightColor) && void 0 !== _h ? _h : "#FFF"
13
- });
14
- }
15
- bindEvent() {
16
- this.table.on("selected_cell", (e => {
17
- this.updateHighlight();
18
- })), this.table.on("selected_clear", (() => {
19
- this.clearHighlight();
20
- })), this.table.on("mousemove_table", (() => {
21
- this.table.stateManager.select.selecting && this.updateHighlight();
22
- }));
23
- }
24
- clearHighlight() {
25
- this.colHeaderRange && this.table.arrangeCustomCellStyle({
26
- range: this.colHeaderRange
27
- }, void 0), this.rowHeaderRange && this.table.arrangeCustomCellStyle({
28
- range: this.rowHeaderRange
29
- }, void 0), this.colHeaderRange = void 0, this.rowHeaderRange = void 0;
30
- }
31
- updateHighlight() {
32
- var _a, _b, _c, _d;
33
- if (!1 === (null === (_a = this.options) || void 0 === _a ? void 0 : _a.colHighlight) && !1 === (null === (_b = this.options) || void 0 === _b ? void 0 : _b.rowHighlight)) return;
34
- const selectRanges = this.table.getSelectedCellRanges();
35
- if (0 === selectRanges.length) return void this.clearHighlight();
36
- const selectRange = selectRanges[0], rowSelectRange = [ selectRange.start.row, selectRange.end.row ];
37
- rowSelectRange.sort(((a, b) => a - b));
38
- const colSelectRange = [ selectRange.start.col, selectRange.end.col ];
39
- let colHeaderRange, rowHeaderRange;
40
- colSelectRange.sort(((a, b) => a - b)), this.table.isPivotTable() ? (colHeaderRange = {
41
- start: {
42
- col: colSelectRange[0],
43
- row: 0
44
- },
45
- end: {
46
- col: colSelectRange[1],
47
- row: this.table.columnHeaderLevelCount - 1
48
- }
49
- }, rowHeaderRange = {
50
- start: {
51
- col: 0,
52
- row: rowSelectRange[0]
53
- },
54
- end: {
55
- col: this.table.rowHeaderLevelCount - 1,
56
- row: rowSelectRange[1]
57
- }
58
- }) : this.table.internalProps.transpose ? rowHeaderRange = {
59
- start: {
60
- col: 0,
61
- row: rowSelectRange[0]
62
- },
63
- end: {
64
- col: this.table.rowHeaderLevelCount - 1,
65
- row: rowSelectRange[1]
66
- }
67
- } : (colHeaderRange = {
68
- start: {
69
- col: colSelectRange[0],
70
- row: 0
71
- },
72
- end: {
73
- col: colSelectRange[1],
74
- row: this.table.columnHeaderLevelCount - 1
75
- }
76
- }, this.table.internalProps.rowSeriesNumber && (rowHeaderRange = {
77
- start: {
78
- col: 0,
79
- row: rowSelectRange[0]
80
- },
81
- end: {
82
- col: 0,
83
- row: rowSelectRange[1]
84
- }
85
- })), !1 === (null === (_c = this.options) || void 0 === _c ? void 0 : _c.colHighlight) || isSameRange(this.colHeaderRange, colHeaderRange) || (this.colHeaderRange && this.table.arrangeCustomCellStyle({
86
- range: this.colHeaderRange
87
- }, void 0), colHeaderRange && this.table.arrangeCustomCellStyle({
88
- range: colHeaderRange
89
- }, "col-highlight"), this.colHeaderRange = colHeaderRange), !1 === (null === (_d = this.options) || void 0 === _d ? void 0 : _d.rowHighlight) || isSameRange(this.rowHeaderRange, rowHeaderRange) || (this.rowHeaderRange && this.table.arrangeCustomCellStyle({
90
- range: this.rowHeaderRange
91
- }, void 0), rowHeaderRange && this.table.arrangeCustomCellStyle({
92
- range: rowHeaderRange
93
- }, "row-highlight"), this.rowHeaderRange = rowHeaderRange);
94
- }
95
- }
96
-
97
- function isSameRange(a, b) {
98
- return void 0 === a && void 0 === b || void 0 !== a && void 0 !== b && (a.start.col === b.start.col && a.start.row === b.start.row && a.end.col === b.end.col && a.end.row === b.end.row);
99
- }
100
- //# sourceMappingURL=header-highlight.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/plugins/header-highlight.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,qBAAqB;IAKhC,YAAY,KAAmB,EAAE,OAAuC;QACtE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,aAAa;;QACX,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,eAAe,EAAE;YAClD,OAAO,EAAE,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,mBAAmB,mCAAI,SAAS;YACvD,KAAK,EAAE,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,iBAAiB,mCAAI,MAAM;SACjD,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,eAAe,EAAE;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e,CAAC,CAAC;YAChG,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;SACtC;QAED,IAAI,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,YAAY,MAAK,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE;YAC7F,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAC;YACpG,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,eAAe,CAAC,CAAC;YAChG,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;SACtC;IACH,CAAC;CACF;AAED,SAAS,WAAW,CAAC,CAAwB,EAAE,CAAwB;IACrE,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,EAAE;QACtC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,EAAE;QACtC,OAAO,KAAK,CAAC;KACd;IAED,OAAO,CACL,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CACjH,CAAC;AACJ,CAAC","file":"header-highlight.js","sourcesContent":["import type { CellRange } from '../ts-types';\nimport type { BaseTableAPI } from '../ts-types/base-table';\n\nexport interface IHeaderHighlightPluginOptions {\n rowHighlight?: boolean;\n colHighlight?: boolean;\n colHighlightBGColor?: string;\n colHighlightColor?: string;\n rowHighlightBGColor?: string;\n rowHighlightColor?: string;\n}\n\nexport class HeaderHighlightPlugin {\n table: BaseTableAPI;\n options: IHeaderHighlightPluginOptions;\n colHeaderRange?: CellRange;\n rowHeaderRange?: CellRange;\n constructor(table: BaseTableAPI, options?: IHeaderHighlightPluginOptions) {\n this.table = table;\n this.options = options;\n\n this.registerStyle();\n this.bindEvent();\n }\n\n registerStyle() {\n this.table.registerCustomCellStyle('col-highlight', {\n bgColor: this.options?.colHighlightBGColor ?? '#82b2f5',\n color: this.options?.colHighlightColor ?? '#FFF'\n });\n\n this.table.registerCustomCellStyle('row-highlight', {\n bgColor: this.options?.rowHighlightBGColor ?? '#82b2f5',\n color: this.options?.rowHighlightColor ?? '#FFF'\n });\n }\n\n bindEvent() {\n this.table.on('selected_cell', e => {\n this.updateHighlight();\n });\n\n this.table.on('selected_clear', () => {\n this.clearHighlight();\n });\n\n this.table.on('mousemove_table', () => {\n if (this.table.stateManager.select.selecting) {\n this.updateHighlight();\n }\n });\n }\n\n clearHighlight() {\n this.colHeaderRange && this.table.arrangeCustomCellStyle({ range: this.colHeaderRange }, undefined);\n this.rowHeaderRange && this.table.arrangeCustomCellStyle({ range: this.rowHeaderRange }, undefined);\n\n // clear range\n this.colHeaderRange = undefined;\n this.rowHeaderRange = undefined;\n }\n\n updateHighlight() {\n if (this.options?.colHighlight === false && this.options?.rowHighlight === false) {\n return;\n }\n const selectRanges = this.table.getSelectedCellRanges();\n if (selectRanges.length === 0) {\n this.clearHighlight();\n return;\n }\n\n const selectRange = selectRanges[0];\n const rowSelectRange = [selectRange.start.row, selectRange.end.row];\n rowSelectRange.sort((a, b) => a - b); // sort\n const colSelectRange = [selectRange.start.col, selectRange.end.col];\n colSelectRange.sort((a, b) => a - b); // sort\n\n let colHeaderRange: CellRange;\n let rowHeaderRange: CellRange;\n if (this.table.isPivotTable()) {\n colHeaderRange = {\n start: {\n col: colSelectRange[0],\n row: 0\n },\n end: {\n col: colSelectRange[1],\n row: this.table.columnHeaderLevelCount - 1\n }\n };\n rowHeaderRange = {\n start: {\n col: 0,\n row: rowSelectRange[0]\n },\n end: {\n col: this.table.rowHeaderLevelCount - 1,\n row: rowSelectRange[1]\n }\n };\n } else if (this.table.internalProps.transpose) {\n rowHeaderRange = {\n start: {\n col: 0,\n row: rowSelectRange[0]\n },\n end: {\n col: this.table.rowHeaderLevelCount - 1,\n row: rowSelectRange[1]\n }\n };\n } else {\n colHeaderRange = {\n start: {\n col: colSelectRange[0],\n row: 0\n },\n end: {\n col: colSelectRange[1],\n row: this.table.columnHeaderLevelCount - 1\n }\n };\n if (this.table.internalProps.rowSeriesNumber) {\n rowHeaderRange = {\n start: {\n col: 0,\n row: rowSelectRange[0]\n },\n end: {\n col: 0,\n row: rowSelectRange[1]\n }\n };\n }\n }\n\n if (this.options?.colHighlight !== false && !isSameRange(this.colHeaderRange, colHeaderRange)) {\n this.colHeaderRange && this.table.arrangeCustomCellStyle({ range: this.colHeaderRange }, undefined);\n colHeaderRange && this.table.arrangeCustomCellStyle({ range: colHeaderRange }, 'col-highlight');\n this.colHeaderRange = colHeaderRange;\n }\n\n if (this.options?.rowHighlight !== false && !isSameRange(this.rowHeaderRange, rowHeaderRange)) {\n this.rowHeaderRange && this.table.arrangeCustomCellStyle({ range: this.rowHeaderRange }, undefined);\n rowHeaderRange && this.table.arrangeCustomCellStyle({ range: rowHeaderRange }, 'row-highlight');\n this.rowHeaderRange = rowHeaderRange;\n }\n }\n}\n\nfunction isSameRange(a: CellRange | undefined, b: CellRange | undefined) {\n if (a === undefined && b === undefined) {\n return true;\n }\n\n if (a === undefined || b === undefined) {\n return false;\n }\n\n return (\n a.start.col === b.start.col && a.start.row === b.start.row && a.end.col === b.end.col && a.end.row === b.end.row\n );\n}\n"]}