@visactor/vtable-plugins 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/cjs/carousel-animation.d.ts +48 -0
- package/cjs/carousel-animation.js +70 -0
- package/cjs/carousel-animation.js.map +1 -0
- package/cjs/header-highlight.d.ts +21 -0
- package/cjs/header-highlight.js +108 -0
- package/cjs/header-highlight.js.map +1 -0
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +22 -0
- package/cjs/index.js.map +1 -0
- package/cjs/invert-highlight.d.ts +18 -0
- package/cjs/invert-highlight.js +61 -0
- package/cjs/invert-highlight.js.map +1 -0
- package/dist/vtable-plugins.js +350 -0
- package/dist/vtable-plugins.min.js +1 -0
- package/es/carousel-animation.d.ts +48 -0
- package/es/carousel-animation.js +62 -0
- package/es/carousel-animation.js.map +1 -0
- package/es/header-highlight.d.ts +21 -0
- package/es/header-highlight.js +100 -0
- package/es/header-highlight.js.map +1 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +6 -0
- package/es/index.js.map +1 -0
- package/es/invert-highlight.d.ts +18 -0
- package/es/invert-highlight.js +57 -0
- package/es/invert-highlight.js.map +1 -0
- package/package.json +88 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="" target="_blank">
|
|
3
|
+
<img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/500_200.svg"/>
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<h1>VTable-Plugins</h1>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
|
|
13
|
+
VTable is not just a high-performance multidimensional data analysis table, but also a grid artist that creates art between rows and columns.React-VTable is a React wrapper of VTable.
|
|
14
|
+
|
|
15
|
+
[](https://www.npmjs.com/package/@visactor/react-vtable)
|
|
16
|
+
[](https://www.npmjs.com/package/@visactor/react-vvtable)
|
|
17
|
+
[](https://github.com/visactor/vtable/blob/main/LICENSE)
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
# Usage
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
[npm package](https://www.npmjs.com/package/@visactor/vtable-search)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
// npm
|
|
29
|
+
npm install @visactor/vtable-plugins
|
|
30
|
+
|
|
31
|
+
// yarn
|
|
32
|
+
yarn add @visactor/vtable-plugins
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
|
|
37
|
+
[More demos and detailed tutorials](https://visactor.io/vtable)
|
|
38
|
+
|
|
39
|
+
# Related Links
|
|
40
|
+
|
|
41
|
+
- [Official website](https://visactor.io/vtable)
|
|
42
|
+
|
|
43
|
+
# Ecosystem
|
|
44
|
+
|
|
45
|
+
| Project | Description |
|
|
46
|
+
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
47
|
+
| [AI-generated Components](https://visactor.io/ai-vtable) | AI-generated table component. |
|
|
48
|
+
|
|
49
|
+
# Contribution
|
|
50
|
+
|
|
51
|
+
If you would like to contribute, please read the [Code of Conduct ](./CODE_OF_CONDUCT.md) 和 [ Guide](./CONTRIBUTING.zh-CN.md) first。
|
|
52
|
+
|
|
53
|
+
Small streams converge to make great rivers and seas!
|
|
54
|
+
|
|
55
|
+
<a href="https://github.com/visactor/vtable/graphs/contributors"><img src="https://contrib.rocks/image?repo=visactor/vtable" /></a>
|
|
56
|
+
|
|
57
|
+
# License
|
|
58
|
+
|
|
59
|
+
[MIT License](./LICENSE)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { EasingType } from '@visactor/vtable/es/vrender';
|
|
2
|
+
import type { BaseTableAPI } from '@visactor/vtable/es/ts-types/base-table';
|
|
3
|
+
export interface ICarouselAnimationPluginOptions {
|
|
4
|
+
rowCount?: number;
|
|
5
|
+
colCount?: number;
|
|
6
|
+
animationDuration?: number;
|
|
7
|
+
animationDelay?: number;
|
|
8
|
+
animationEasing?: EasingType;
|
|
9
|
+
replaceScrollAction?: boolean;
|
|
10
|
+
customDistRowFunction?: (row: number, table: BaseTableAPI) => {
|
|
11
|
+
distRow: number;
|
|
12
|
+
animation?: boolean;
|
|
13
|
+
} | undefined;
|
|
14
|
+
customDistColFunction?: (col: number, table: BaseTableAPI) => {
|
|
15
|
+
distCol: number;
|
|
16
|
+
animation?: boolean;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare class CarouselAnimationPlugin {
|
|
20
|
+
table: BaseTableAPI;
|
|
21
|
+
rowCount: number;
|
|
22
|
+
colCount: number;
|
|
23
|
+
animationDuration: number;
|
|
24
|
+
animationDelay: number;
|
|
25
|
+
animationEasing: EasingType;
|
|
26
|
+
replaceScrollAction: boolean;
|
|
27
|
+
playing: boolean;
|
|
28
|
+
row: number;
|
|
29
|
+
col: number;
|
|
30
|
+
willUpdateRow: boolean;
|
|
31
|
+
willUpdateCol: boolean;
|
|
32
|
+
customDistRowFunction?: (row: number, table: BaseTableAPI) => {
|
|
33
|
+
distRow: number;
|
|
34
|
+
animation?: boolean;
|
|
35
|
+
} | undefined;
|
|
36
|
+
customDistColFunction?: (col: number, table: BaseTableAPI) => {
|
|
37
|
+
distCol: number;
|
|
38
|
+
animation?: boolean;
|
|
39
|
+
} | undefined;
|
|
40
|
+
constructor(table: BaseTableAPI, options?: ICarouselAnimationPluginOptions);
|
|
41
|
+
init(): void;
|
|
42
|
+
reset(): void;
|
|
43
|
+
onScrollEnd(e: Event): void;
|
|
44
|
+
play(): void;
|
|
45
|
+
pause(): void;
|
|
46
|
+
updateRow(): void;
|
|
47
|
+
updateCol(): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.CarouselAnimationPlugin = void 0;
|
|
6
|
+
|
|
7
|
+
class CarouselAnimationPlugin {
|
|
8
|
+
constructor(table, options) {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10
|
+
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,
|
|
11
|
+
this.colCount = null !== (_b = null == options ? void 0 : options.colCount) && void 0 !== _b ? _b : void 0,
|
|
12
|
+
this.animationDuration = null !== (_c = null == options ? void 0 : options.animationDuration) && void 0 !== _c ? _c : 500,
|
|
13
|
+
this.animationDelay = null !== (_d = null == options ? void 0 : options.animationDelay) && void 0 !== _d ? _d : 1e3,
|
|
14
|
+
this.animationEasing = null !== (_e = null == options ? void 0 : options.animationEasing) && void 0 !== _e ? _e : "linear",
|
|
15
|
+
this.replaceScrollAction = null !== (_f = null == options ? void 0 : options.replaceScrollAction) && void 0 !== _f && _f,
|
|
16
|
+
this.customDistColFunction = options.customDistColFunction, this.customDistRowFunction = options.customDistRowFunction,
|
|
17
|
+
this.reset(), this.init();
|
|
18
|
+
}
|
|
19
|
+
init() {
|
|
20
|
+
this.replaceScrollAction && (this.table.disableScroll(), this.table.scenegraph.stage.addEventListener("wheel", this.onScrollEnd.bind(this)));
|
|
21
|
+
}
|
|
22
|
+
reset() {
|
|
23
|
+
this.playing = !1, this.row = this.table.frozenRowCount, this.col = this.table.frozenColCount;
|
|
24
|
+
}
|
|
25
|
+
onScrollEnd(e) {
|
|
26
|
+
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,
|
|
27
|
+
this.row = Math.max(this.row, this.table.frozenRowCount)), this.table.scrollToRow(this.row, {
|
|
28
|
+
duration: this.animationDuration,
|
|
29
|
+
easing: this.animationEasing
|
|
30
|
+
})) : 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,
|
|
31
|
+
this.col = Math.max(this.col, this.table.frozenColCount)), this.table.scrollToCol(this.col, {
|
|
32
|
+
duration: this.animationDuration,
|
|
33
|
+
easing: this.animationEasing
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
play() {
|
|
37
|
+
this.playing = !0, this.rowCount && !this.willUpdateRow ? this.updateRow() : this.colCount && !this.willUpdateCol && this.updateCol();
|
|
38
|
+
}
|
|
39
|
+
pause() {
|
|
40
|
+
this.playing = !1;
|
|
41
|
+
}
|
|
42
|
+
updateRow() {
|
|
43
|
+
var _a;
|
|
44
|
+
if (!this.playing || this.table.isReleased) return;
|
|
45
|
+
let animation = !0;
|
|
46
|
+
const customRow = this.customDistRowFunction && this.customDistRowFunction(this.row, this.table);
|
|
47
|
+
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,
|
|
48
|
+
animation = !1) : this.row += this.rowCount, this.table.scrollToRow(this.row, animation ? {
|
|
49
|
+
duration: this.animationDuration,
|
|
50
|
+
easing: this.animationEasing
|
|
51
|
+
} : void 0), this.willUpdateRow = !0, setTimeout((() => {
|
|
52
|
+
this.willUpdateRow = !1, this.updateRow();
|
|
53
|
+
}), this.animationDuration + this.animationDelay);
|
|
54
|
+
}
|
|
55
|
+
updateCol() {
|
|
56
|
+
var _a;
|
|
57
|
+
if (!this.playing || this.table.isReleased) return;
|
|
58
|
+
let animation = !0;
|
|
59
|
+
const customCol = this.customDistColFunction && this.customDistColFunction(this.col, this.table);
|
|
60
|
+
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,
|
|
61
|
+
animation = !1) : this.col += this.colCount, this.table.scrollToCol(this.col, animation ? {
|
|
62
|
+
duration: this.animationDuration,
|
|
63
|
+
easing: this.animationEasing
|
|
64
|
+
} : void 0), this.willUpdateCol = !0, setTimeout((() => {
|
|
65
|
+
this.willUpdateCol = !1, this.updateCol();
|
|
66
|
+
}), this.animationDuration + this.animationDelay);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
exports.CarouselAnimationPlugin = CarouselAnimationPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["carousel-animation.ts"],"names":[],"mappings":";;;AAeA,MAAa,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,mCAAI,QAAQ,CAAC;QAC5D,IAAI,CAAC,mBAAmB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,mCAAI,KAAK,CAAC;QAEjE,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;QAC3D,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AAqB,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;AApJD,0DAoJC","file":"carousel-animation.js","sourcesContent":["import type { EasingType } from '@visactor/vtable/es/vrender';\nimport type { BaseTableAPI } from '@visactor/vtable/es/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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CellRange } from '@visactor/vtable/es/ts-types';
|
|
2
|
+
import type { BaseTableAPI } from '@visactor/vtable/es/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
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.HeaderHighlightPlugin = void 0;
|
|
6
|
+
|
|
7
|
+
class HeaderHighlightPlugin {
|
|
8
|
+
constructor(table, options) {
|
|
9
|
+
this.table = table, this.options = options, this.registerStyle(), this.bindEvent();
|
|
10
|
+
}
|
|
11
|
+
registerStyle() {
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13
|
+
this.table.registerCustomCellStyle("col-highlight", {
|
|
14
|
+
bgColor: null !== (_b = null === (_a = this.options) || void 0 === _a ? void 0 : _a.colHighlightBGColor) && void 0 !== _b ? _b : "#82b2f5",
|
|
15
|
+
color: null !== (_d = null === (_c = this.options) || void 0 === _c ? void 0 : _c.colHighlightColor) && void 0 !== _d ? _d : "#FFF"
|
|
16
|
+
}), this.table.registerCustomCellStyle("row-highlight", {
|
|
17
|
+
bgColor: null !== (_f = null === (_e = this.options) || void 0 === _e ? void 0 : _e.rowHighlightBGColor) && void 0 !== _f ? _f : "#82b2f5",
|
|
18
|
+
color: null !== (_h = null === (_g = this.options) || void 0 === _g ? void 0 : _g.rowHighlightColor) && void 0 !== _h ? _h : "#FFF"
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
bindEvent() {
|
|
22
|
+
this.table.on("selected_cell", (e => {
|
|
23
|
+
this.updateHighlight();
|
|
24
|
+
})), this.table.on("selected_clear", (() => {
|
|
25
|
+
this.clearHighlight();
|
|
26
|
+
})), this.table.on("mousemove_table", (() => {
|
|
27
|
+
this.table.stateManager.select.selecting && this.updateHighlight();
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
clearHighlight() {
|
|
31
|
+
this.colHeaderRange && this.table.arrangeCustomCellStyle({
|
|
32
|
+
range: this.colHeaderRange
|
|
33
|
+
}, void 0), this.rowHeaderRange && this.table.arrangeCustomCellStyle({
|
|
34
|
+
range: this.rowHeaderRange
|
|
35
|
+
}, void 0), this.colHeaderRange = void 0, this.rowHeaderRange = void 0;
|
|
36
|
+
}
|
|
37
|
+
updateHighlight() {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
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;
|
|
40
|
+
const selectRanges = this.table.getSelectedCellRanges();
|
|
41
|
+
if (0 === selectRanges.length) return void this.clearHighlight();
|
|
42
|
+
const selectRange = selectRanges[0], rowSelectRange = [ selectRange.start.row, selectRange.end.row ];
|
|
43
|
+
rowSelectRange.sort(((a, b) => a - b));
|
|
44
|
+
const colSelectRange = [ selectRange.start.col, selectRange.end.col ];
|
|
45
|
+
let colHeaderRange, rowHeaderRange;
|
|
46
|
+
colSelectRange.sort(((a, b) => a - b)), this.table.isPivotTable() ? (colHeaderRange = {
|
|
47
|
+
start: {
|
|
48
|
+
col: colSelectRange[0],
|
|
49
|
+
row: 0
|
|
50
|
+
},
|
|
51
|
+
end: {
|
|
52
|
+
col: colSelectRange[1],
|
|
53
|
+
row: this.table.columnHeaderLevelCount - 1
|
|
54
|
+
}
|
|
55
|
+
}, rowHeaderRange = {
|
|
56
|
+
start: {
|
|
57
|
+
col: 0,
|
|
58
|
+
row: rowSelectRange[0]
|
|
59
|
+
},
|
|
60
|
+
end: {
|
|
61
|
+
col: this.table.rowHeaderLevelCount - 1,
|
|
62
|
+
row: rowSelectRange[1]
|
|
63
|
+
}
|
|
64
|
+
}) : this.table.internalProps.transpose ? rowHeaderRange = {
|
|
65
|
+
start: {
|
|
66
|
+
col: 0,
|
|
67
|
+
row: rowSelectRange[0]
|
|
68
|
+
},
|
|
69
|
+
end: {
|
|
70
|
+
col: this.table.rowHeaderLevelCount - 1,
|
|
71
|
+
row: rowSelectRange[1]
|
|
72
|
+
}
|
|
73
|
+
} : (colHeaderRange = {
|
|
74
|
+
start: {
|
|
75
|
+
col: colSelectRange[0],
|
|
76
|
+
row: 0
|
|
77
|
+
},
|
|
78
|
+
end: {
|
|
79
|
+
col: colSelectRange[1],
|
|
80
|
+
row: this.table.columnHeaderLevelCount - 1
|
|
81
|
+
}
|
|
82
|
+
}, this.table.internalProps.rowSeriesNumber && (rowHeaderRange = {
|
|
83
|
+
start: {
|
|
84
|
+
col: 0,
|
|
85
|
+
row: rowSelectRange[0]
|
|
86
|
+
},
|
|
87
|
+
end: {
|
|
88
|
+
col: 0,
|
|
89
|
+
row: rowSelectRange[1]
|
|
90
|
+
}
|
|
91
|
+
})), !1 === (null === (_c = this.options) || void 0 === _c ? void 0 : _c.colHighlight) || isSameRange(this.colHeaderRange, colHeaderRange) || (this.colHeaderRange && this.table.arrangeCustomCellStyle({
|
|
92
|
+
range: this.colHeaderRange
|
|
93
|
+
}, void 0), colHeaderRange && this.table.arrangeCustomCellStyle({
|
|
94
|
+
range: colHeaderRange
|
|
95
|
+
}, "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({
|
|
96
|
+
range: this.rowHeaderRange
|
|
97
|
+
}, void 0), rowHeaderRange && this.table.arrangeCustomCellStyle({
|
|
98
|
+
range: rowHeaderRange
|
|
99
|
+
}, "row-highlight"), this.rowHeaderRange = rowHeaderRange);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isSameRange(a, b) {
|
|
104
|
+
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);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=header-highlight.js.map
|
|
108
|
+
exports.HeaderHighlightPlugin = HeaderHighlightPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["header-highlight.ts"],"names":[],"mappings":";;;AAYA,MAAa,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;YAClD,OAAO,EAAE,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,mBAAmB,mCAAI,SAAS;YACvD,KAAK,EAAE,MAAA,MAAA,IAAI,CAAC,OAAO,0CAA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AAI,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;AAzID,sDAyIC;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 '@visactor/vtable/es/ts-types';\nimport type { BaseTableAPI } from '@visactor/vtable/es/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"]}
|
package/cjs/index.d.ts
ADDED
package/cjs/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
15
|
+
for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), __exportStar(require("./carousel-animation"), exports), __exportStar(require("./invert-highlight"), exports),
|
|
21
|
+
__exportStar(require("./header-highlight"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,qDAAmC;AACnC,qDAAmC","file":"index.js","sourcesContent":["export * from './carousel-animation';\nexport * from './invert-highlight';\nexport * from './header-highlight';\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Group } from '@visactor/vtable/es/scenegraph/graphic/group';
|
|
2
|
+
import type { CellRange } from '@visactor/vtable/es/ts-types';
|
|
3
|
+
import type { BaseTableAPI } from '@visactor/vtable/es/ts-types/base-table';
|
|
4
|
+
export interface InvertHighlightPluginOptions {
|
|
5
|
+
fill?: string;
|
|
6
|
+
opacity?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class InvertHighlightPlugin {
|
|
9
|
+
table: BaseTableAPI;
|
|
10
|
+
range?: CellRange;
|
|
11
|
+
_fill: string;
|
|
12
|
+
_opacity: number;
|
|
13
|
+
constructor(table: BaseTableAPI, options?: InvertHighlightPluginOptions);
|
|
14
|
+
setInvertHighlightRange(range?: CellRange): void;
|
|
15
|
+
deleteAllCellGroupShadow(): void;
|
|
16
|
+
updateCellGroupShadow(): void;
|
|
17
|
+
updateCellGroupShadowInContainer(container: Group, range?: CellRange): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.InvertHighlightPlugin = void 0;
|
|
6
|
+
|
|
7
|
+
const vrender_1 = require("@visactor/vtable/es/vrender"), cell_range_1 = require("@visactor/vtable/es/tools/cell-range"), helper_1 = require("@visactor/vtable/es/tools/helper");
|
|
8
|
+
|
|
9
|
+
class InvertHighlightPlugin {
|
|
10
|
+
constructor(table, options) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
this.table = table, this._fill = null !== (_a = null == options ? void 0 : options.fill) && void 0 !== _a ? _a : "#000",
|
|
13
|
+
this._opacity = null !== (_b = null == options ? void 0 : options.opacity) && void 0 !== _b ? _b : .5;
|
|
14
|
+
}
|
|
15
|
+
setInvertHighlightRange(range) {
|
|
16
|
+
(0, cell_range_1.isSameRange)(this.range, range) || (this.range = range, range ? this.updateCellGroupShadow() : this.deleteAllCellGroupShadow(),
|
|
17
|
+
this.table.scenegraph.updateNextFrame());
|
|
18
|
+
}
|
|
19
|
+
deleteAllCellGroupShadow() {
|
|
20
|
+
this.table.isPivotTable() || (this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),
|
|
21
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),
|
|
22
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup), this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),
|
|
23
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),
|
|
24
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup);
|
|
25
|
+
}
|
|
26
|
+
updateCellGroupShadow() {
|
|
27
|
+
this.table.isPivotTable() || (this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup, this.range),
|
|
28
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup, this.range)),
|
|
29
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup, this.range),
|
|
30
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup, this.range),
|
|
31
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),
|
|
32
|
+
this.range, this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup, this.range);
|
|
33
|
+
}
|
|
34
|
+
updateCellGroupShadowInContainer(container, range) {
|
|
35
|
+
container.forEachChildrenSkipChild((item => {
|
|
36
|
+
const column = item;
|
|
37
|
+
"column" === column.role && column.forEachChildrenSkipChild((item => {
|
|
38
|
+
const cell = item;
|
|
39
|
+
if ("cell" !== cell.role) return;
|
|
40
|
+
cell.attachShadow(cell.shadowRoot);
|
|
41
|
+
const shadowGroup = cell.shadowRoot;
|
|
42
|
+
if (range) {
|
|
43
|
+
if ((0, helper_1.cellInRange)(range, cell.col, cell.row)) shadowGroup.removeAllChild(); else if (!shadowGroup.firstChild) {
|
|
44
|
+
const shadowRect = (0, vrender_1.createRect)({
|
|
45
|
+
x: 0,
|
|
46
|
+
y: 0,
|
|
47
|
+
width: cell.attribute.width,
|
|
48
|
+
height: cell.attribute.height,
|
|
49
|
+
fill: this._fill,
|
|
50
|
+
opacity: this._opacity
|
|
51
|
+
});
|
|
52
|
+
shadowRect.name = "shadow-rect", shadowGroup.appendChild(shadowRect);
|
|
53
|
+
}
|
|
54
|
+
} else shadowGroup.removeAllChild();
|
|
55
|
+
}));
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.InvertHighlightPlugin = InvertHighlightPlugin;
|
|
61
|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AAM,IAAI,GAAG,IAAwB,CAAC;oBACtC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;wBACxB,OAAO;qBACR;oBACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBACnC,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC;oBACpC,IAAI,CAAC,KAAK,EAAE;wBAEV,WAAW,CAAC,cAAc,EAAE,CAAC;qBAC9B;yBAAM,IAAI,IAAA,oBAAW,EAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE;wBAEjD,WAAW,CAAC,cAAc,EAAE,CAAC;qBAC9B;yBAAM,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;wBAElC,MAAM,UAAU,GAAG,IAAA,oBAAU,EAAC;4BAC5B,CAAC,EAAE,CAAC;4BACJ,CAAC,EAAE,CAAC;4BACJ,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK;4BAC3B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM;4BAC7B,IAAI,EAAE,IAAI,CAAC,KAAK;4BAChB,OAAO,EAAE,IAAI,CAAC,QAAQ;yBACvB,CAAC,CAAC;wBACH,UAAU,CAAC,IAAI,GAAG,aAAa,CAAC;wBAChC,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;qBACrC;gBACH,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AArFD,sDAqFC","file":"invert-highlight.js","sourcesContent":["import type { INode } from '@visactor/vtable/es/vrender';\nimport { createRect } from '@visactor/vtable/es/vrender';\nimport type { Group } from '@visactor/vtable/es/scenegraph/graphic/group';\nimport { isSameRange } from '@visactor/vtable/es/tools/cell-range';\nimport type { CellRange } from '@visactor/vtable/es/ts-types';\nimport type { BaseTableAPI } from '@visactor/vtable/es/ts-types/base-table';\nimport { cellInRange } from '@visactor/vtable/es/tools/helper';\n\nexport interface InvertHighlightPluginOptions {\n fill?: string;\n opacity?: number;\n}\n\nexport class InvertHighlightPlugin {\n table: BaseTableAPI;\n range?: CellRange;\n _fill: string;\n _opacity: number;\n\n constructor(table: BaseTableAPI, options?: InvertHighlightPluginOptions) {\n this.table = table;\n\n this._fill = options?.fill ?? '#000';\n this._opacity = options?.opacity ?? 0.5;\n }\n\n setInvertHighlightRange(range?: CellRange) {\n if (isSameRange(this.range, range)) {\n return;\n }\n\n this.range = range;\n if (!range) {\n // reset highlight\n this.deleteAllCellGroupShadow();\n } else {\n // update highlight\n this.updateCellGroupShadow();\n }\n\n this.table.scenegraph.updateNextFrame();\n }\n\n deleteAllCellGroupShadow() {\n if (!this.table.isPivotTable()) {\n this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup);\n this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup);\n }\n this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup);\n this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup);\n this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup);\n this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup);\n }\n\n updateCellGroupShadow() {\n if (!this.table.isPivotTable()) {\n this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup, this.range);\n this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup, this.range);\n }\n this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup, this.range);\n this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup, this.range);\n this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup), this.range;\n this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup, this.range);\n }\n updateCellGroupShadowInContainer(container: Group, range?: CellRange) {\n container.forEachChildrenSkipChild((item: INode) => {\n const column = item as unknown as Group;\n if (column.role === 'column') {\n column.forEachChildrenSkipChild((item: INode) => {\n const cell = item as unknown as Group;\n if (cell.role !== 'cell') {\n return;\n }\n cell.attachShadow(cell.shadowRoot);\n const shadowGroup = cell.shadowRoot;\n if (!range) {\n // no highlight\n shadowGroup.removeAllChild();\n } else if (cellInRange(range, cell.col, cell.row)) {\n // inside highlight\n shadowGroup.removeAllChild();\n } else if (!shadowGroup.firstChild) {\n // outside highlight\n const shadowRect = createRect({\n x: 0,\n y: 0,\n width: cell.attribute.width,\n height: cell.attribute.height,\n fill: this._fill,\n opacity: this._opacity\n });\n shadowRect.name = 'shadow-rect';\n shadowGroup.appendChild(shadowRect);\n }\n });\n }\n });\n }\n}\n"]}
|