@visactor/vtable-plugins 1.18.2-alpha.3 → 1.18.2

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 (53) hide show
  1. package/cjs/add-row-column.d.ts +1 -0
  2. package/cjs/add-row-column.js +1 -1
  3. package/cjs/add-row-column.js.map +1 -1
  4. package/cjs/carousel-animation.js.map +1 -1
  5. package/cjs/column-series.d.ts +2 -1
  6. package/cjs/column-series.js +5 -4
  7. package/cjs/column-series.js.map +1 -1
  8. package/cjs/excel-edit-cell-keyboard.d.ts +1 -0
  9. package/cjs/excel-edit-cell-keyboard.js +3 -2
  10. package/cjs/excel-edit-cell-keyboard.js.map +1 -1
  11. package/cjs/focus-highlight.d.ts +2 -1
  12. package/cjs/focus-highlight.js +6 -3
  13. package/cjs/focus-highlight.js.map +1 -1
  14. package/cjs/highlight-header-when-select-cell.d.ts +2 -0
  15. package/cjs/highlight-header-when-select-cell.js +5 -1
  16. package/cjs/highlight-header-when-select-cell.js.map +1 -1
  17. package/cjs/rotate-table.d.ts +3 -0
  18. package/cjs/rotate-table.js +16 -9
  19. package/cjs/rotate-table.js.map +1 -1
  20. package/cjs/row-series.d.ts +2 -1
  21. package/cjs/row-series.js +5 -5
  22. package/cjs/row-series.js.map +1 -1
  23. package/cjs/table-carousel-animation.d.ts +1 -0
  24. package/cjs/table-carousel-animation.js +3 -2
  25. package/cjs/table-carousel-animation.js.map +1 -1
  26. package/dist/vtable-plugins.js +62 -26
  27. package/dist/vtable-plugins.min.js +1 -1
  28. package/es/add-row-column.d.ts +1 -0
  29. package/es/add-row-column.js +1 -1
  30. package/es/add-row-column.js.map +1 -1
  31. package/es/carousel-animation.js.map +1 -1
  32. package/es/column-series.d.ts +2 -1
  33. package/es/column-series.js +5 -4
  34. package/es/column-series.js.map +1 -1
  35. package/es/excel-edit-cell-keyboard.d.ts +1 -0
  36. package/es/excel-edit-cell-keyboard.js +3 -2
  37. package/es/excel-edit-cell-keyboard.js.map +1 -1
  38. package/es/focus-highlight.d.ts +2 -1
  39. package/es/focus-highlight.js +7 -4
  40. package/es/focus-highlight.js.map +1 -1
  41. package/es/highlight-header-when-select-cell.d.ts +2 -0
  42. package/es/highlight-header-when-select-cell.js +5 -1
  43. package/es/highlight-header-when-select-cell.js.map +1 -1
  44. package/es/rotate-table.d.ts +3 -0
  45. package/es/rotate-table.js +16 -9
  46. package/es/rotate-table.js.map +1 -1
  47. package/es/row-series.d.ts +2 -1
  48. package/es/row-series.js +5 -5
  49. package/es/row-series.js.map +1 -1
  50. package/es/table-carousel-animation.d.ts +1 -0
  51. package/es/table-carousel-animation.js +3 -2
  52. package/es/table-carousel-animation.js.map +1 -1
  53. package/package.json +6 -6
@@ -2,10 +2,13 @@ import type { BaseTable } from '@visactor/vtable/src/core/BaseTable';
2
2
  import * as VTable from '@visactor/vtable';
3
3
  import type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';
4
4
  import type { EventArg } from './types';
5
+ import type { Matrix } from '@visactor/vutils';
5
6
  export declare class RotateTablePlugin implements VTable.plugins.IVTablePlugin {
6
7
  id: string;
8
+ name: string;
7
9
  runTime: "initialized"[];
8
10
  table: VTable.ListTable;
11
+ matrix: Matrix;
9
12
  vglobal_mapToCanvasPoint: any;
10
13
  constructor();
11
14
  run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], VTable.BaseTableAPI]): void;
@@ -4,7 +4,7 @@ import * as VTable from "@visactor/vtable";
4
4
 
5
5
  export class RotateTablePlugin {
6
6
  constructor() {
7
- this.id = "rotate-table", this.runTime = [ VTable.TABLE_EVENT_TYPE.INITIALIZED ];
7
+ this.id = "rotate-table", this.name = "Rotate Table", this.runTime = [ VTable.TABLE_EVENT_TYPE.INITIALIZED ];
8
8
  }
9
9
  run(...args) {
10
10
  const table = args[2];
@@ -16,7 +16,7 @@ export class RotateTablePlugin {
16
16
 
17
17
  export function rotate90WithTransform(rotateDom) {
18
18
  this.rotateDegree = 90;
19
- const rotateCenter = Math.min(rotateDom.clientWidth, rotateDom.clientHeight) / 2, domRect = this.getElement().getBoundingClientRect(), x1 = domRect.left, y1 = domRect.top, x2 = domRect.right, y2 = domRect.bottom;
19
+ const rotateCenter = rotateDom.clientWidth < rotateDom.clientHeight ? Math.max(rotateDom.clientWidth, rotateDom.clientHeight) / 2 : Math.min(rotateDom.clientWidth, rotateDom.clientHeight) / 2, domRect = this.getElement().getBoundingClientRect(), x1 = domRect.left, y1 = domRect.top, x2 = domRect.right, y2 = domRect.bottom;
20
20
  rotateDom.style.transform = "rotate(90deg)", rotateDom.style.transformOrigin = `${rotateCenter}px ${rotateCenter}px`;
21
21
  const getRect = () => ({
22
22
  x1: x1,
@@ -24,15 +24,21 @@ export function rotate90WithTransform(rotateDom) {
24
24
  x2: x2,
25
25
  y2: y2
26
26
  }), getMatrix = () => {
27
- const containerRect = rotateDom.getBoundingClientRect(), domRect = this.getElement().getBoundingClientRect(), x1 = domRect.top, y1 = containerRect.width - domRect.right, matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
27
+ const viewPortWidth = ("undefined" != typeof window ? {
28
+ width: window.innerWidth || document.documentElement.clientWidth,
29
+ height: window.innerHeight || document.documentElement.clientHeight
30
+ } : vglobal && vglobal.getViewportSize ? vglobal.getViewportSize() : rotateDom.getBoundingClientRect()).width, domRect = this.getElement().getBoundingClientRect(), x1 = domRect.top, y1 = viewPortWidth - domRect.right, matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
28
31
  matrix.translate(x1, y1);
29
32
  const centerX = rotateCenter - x1, centerY = rotateCenter - y1;
30
- return matrix.translate(centerX, centerY), matrix.rotate(Math.PI / 2), matrix.translate(-centerX, -centerY),
31
- matrix;
33
+ matrix.translate(centerX, centerY), matrix.rotate(Math.PI / 2), matrix.translate(-centerX, -centerY);
34
+ const rotateRablePlugin = this.pluginManager.getPluginByName("Rotate Table");
35
+ return rotateRablePlugin && (rotateRablePlugin.matrix = matrix), matrix;
32
36
  };
33
37
  registerGlobalEventTransformer(vglobal, this.getElement(), getMatrix, getRect, transformPointForCanvas),
34
- registerWindowEventTransformer(this.scenegraph.stage.window, this.getElement(), getMatrix, getRect, transformPointForCanvas),
35
- this.vglobal_mapToCanvasPoint = vglobal.mapToCanvasPoint, vglobal.mapToCanvasPoint = mapToCanvasPointForCanvas;
38
+ registerWindowEventTransformer(this.scenegraph.stage.window, this.getElement(), getMatrix, getRect, transformPointForCanvas);
39
+ const rotateRablePlugin = this.pluginManager.getPluginByName("Rotate Table");
40
+ rotateRablePlugin && (rotateRablePlugin.vglobal_mapToCanvasPoint = vglobal.mapToCanvasPoint),
41
+ vglobal.mapToCanvasPoint = mapToCanvasPointForCanvas;
36
42
  }
37
43
 
38
44
  export function cancelTransform(rotateDom) {
@@ -47,7 +53,8 @@ export function cancelTransform(rotateDom) {
47
53
  return matrix.translate(x1, y1), matrix;
48
54
  };
49
55
  registerGlobalEventTransformer(vglobal, this.getElement(), getMatrix, getRect, transformPointForCanvas),
50
- registerWindowEventTransformer(this.scenegraph.stage.window, this.getElement(), getMatrix, getRect, transformPointForCanvas),
51
- vglobal.mapToCanvasPoint = this.vglobal_mapToCanvasPoint;
56
+ registerWindowEventTransformer(this.scenegraph.stage.window, this.getElement(), getMatrix, getRect, transformPointForCanvas);
57
+ const rotateRablePlugin = this.pluginManager.getPluginByName("Rotate Table");
58
+ rotateRablePlugin && (vglobal.mapToCanvasPoint = rotateRablePlugin.vglobal_mapToCanvasPoint);
52
59
  }
53
60
  //# sourceMappingURL=rotate-table.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["rotate-table.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,OAAO,EACR,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAa3C,MAAM,OAAO,iBAAiB;IAM5B;QALA,OA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ACtB,SAAS,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;IACnC,SAAS,CAAC,KAAK,CAAC,eAAe,GAAG,MAAM,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,qBAAqB,EAAE,CAAC;IAC1D,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IACxB,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IACvB,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IACzB,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAE1B,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,OAAO;YACL,EAAE;YACF,EAAE;YACF,EAAE;YACF,EAAE;SACH,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,8BAA8B,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC;IACxG,8BAA8B,CAC5B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,EAC5B,IAAI,CAAC,UAAU,EAAE,EACjB,SAAS,EACT,OAAO,EACP,uBAAuB,CACxB,CAAC;IACF,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,wBAAwB,CAAC;AAC3D,CAAC","file":"rotate-table.js","sourcesContent":["import {\n matrixAllocate,\n transformPointForCanvas,\n mapToCanvasPointForCanvas,\n registerGlobalEventTransformer,\n registerWindowEventTransformer,\n vglobal\n} from '@visactor/vtable/es/vrender';\nimport type { BaseTable } from '@visactor/vtable/src/core/BaseTable';\nimport * as VTable from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\n// export type IRotateTablePluginOptions = {\n// // 旋转角度\n// rotate?: number;\n// };\n/**\n * 旋转表格插件。\n * 业务层旋转功能没有使用收系统接口的话,用的transform:'rotate(90deg)'的设置来达到旋转的目的。vtable及vrender都没有进行坐标处理,这样就会导致交互错乱。\n * 所以需要进行坐标转换,将旋转后的坐标转换后作为VRender及VTable逻辑中用到的坐标。\n * 这里使用transform:'rotate(90deg)'的设置来达到旋转的目的。 其他角度应该也是可以实现的,请自行扩展这个插件并兼容\n */\nexport class RotateTablePlugin implements VTable.plugins.IVTablePlugin {\n id = 'rotate-table';\n runTime = [VTable.TABLE_EVENT_TYPE.INITIALIZED];\n table: VTable.ListTable;\n vglobal_mapToCanvasPoint: any; // 保存vrender中vglobal的mapToCanvasPoint原方法\n // pluginOptions: IRotateTablePluginOptions;\n constructor() {\n // this.pluginOptions = pluginOptions;\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], VTable.BaseTableAPI]) {\n const table: VTable.BaseTableAPI = args[2];\n this.table = table as VTable.ListTable;\n //将函数rotate90WithTransform绑定到table实例上\n this.table.rotate90WithTransform = rotate90WithTransform.bind(this.table);\n this.table.cancelTransform = cancelTransform.bind(this.table);\n }\n\n release() {\n // 移除绑定的事件\n }\n}\n\n/**\n * 业务层旋转功能没有使用收系统接口的话,用的transform:'rotate(90deg)'的设置来达到旋转的目的。vtable及vrender都没有进行坐标处理,这样就会导致交互错乱。\n * 所以需要进行坐标转换,将旋转后的坐标转换后作为VRender及VTable逻辑中用到的坐标。\n */\nexport function rotate90WithTransform(this: BaseTable, rotateDom: HTMLElement) {\n this.rotateDegree = 90;\n const rotateCenter = Math.min(rotateDom.clientWidth, rotateDom.clientHeight) / 2;\n const domRect = this.getElement().getBoundingClientRect();\n const x1 = domRect.left;\n const y1 = domRect.top;\n const x2 = domRect.right;\n const y2 = domRect.bottom;\n\n rotateDom.style.transform = 'rotate(90deg)';\n rotateDom.style.transformOrigin = `${rotateCenter}px ${rotateCenter}px`;\n const getRect = () => {\n return {\n x1,\n y1,\n x2,\n y2\n };\n };\n const getMatrix = () => {\n const containerRect = rotateDom.getBoundingClientRect(); //TODO 这个地方应该获取窗口的宽高 最好能从vglobal上直接获取\n const domRect = this.getElement().getBoundingClientRect();\n const x1 = domRect.top;\n const y1 = containerRect.width - domRect.right;\n\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n matrix.translate(x1, y1);\n const centerX = rotateCenter - x1;\n const centerY = rotateCenter - y1;\n matrix.translate(centerX, centerY);\n matrix.rotate(Math.PI / 2);\n matrix.translate(-centerX, -centerY);\n return matrix;\n };\n registerGlobalEventTransformer(vglobal, this.getElement(), getMatrix, getRect, transformPointForCanvas);\n registerWindowEventTransformer(\n this.scenegraph.stage.window,\n this.getElement(),\n getMatrix,\n getRect,\n transformPointForCanvas\n );\n this.vglobal_mapToCanvasPoint = vglobal.mapToCanvasPoint;\n vglobal.mapToCanvasPoint = mapToCanvasPointForCanvas;\n //transformPointForCanvas和mapToCanvasPointForCanvas时相对应的\n //具体逻辑在 VRender/packages/vrender-core/src/common/event-transformer.ts中\n // 可以自定义这两个函数 来修改事件属性,transformPointForCanvas中将坐标转换后存放了_canvasX _canvasY,mapToCanvasPointForCanvas中加以利用\n // 在VTable的touch文件中,利用到了_canvasX _canvasY 所以如果自定义上面两个函数也需提供_canvasX _canvasY\n}\nexport function cancelTransform(this: BaseTable, rotateDom: HTMLElement) {\n this.rotateDegree = 0;\n rotateDom.style.transform = 'none';\n rotateDom.style.transformOrigin = 'none';\n const domRect = this.getElement().getBoundingClientRect();\n const x1 = domRect.left;\n const y1 = domRect.top;\n const x2 = domRect.right;\n const y2 = domRect.bottom;\n\n const getRect = () => {\n return {\n x1,\n y1,\n x2,\n y2\n };\n };\n const getMatrix = () => {\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n matrix.translate(x1, y1);\n return matrix;\n };\n registerGlobalEventTransformer(vglobal, this.getElement(), getMatrix, getRect, transformPointForCanvas);\n registerWindowEventTransformer(\n this.scenegraph.stage.window,\n this.getElement(),\n getMatrix,\n getRect,\n transformPointForCanvas\n );\n vglobal.mapToCanvasPoint = this.vglobal_mapToCanvasPoint;\n}\n"]}
1
+ {"version":3,"sources":["rotate-table.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,OAAO,EACR,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAc3C,MAAM,OAAO,iBAAiB;IAQ5B;QAPA,OAAE,GAAG,cAAc,CAAC;QACpB,SAAI,GAAG,cAAc,CAAC;QACtB,YAAO,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAOhD,CAAC;IACD,GAAG,CAAC,GAAG,IAAwG;QAC7G,MAAM,KAAK,GAAwB,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAyB,CAAC;QAEvC,IAAI,CAAC,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1E,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,OAAO;IAEP,CAAC;CACF;AAMD,MAAM,UAAU,qBAAqB,CAAkB,SAAsB;IAC3E,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACvB,MAAM,YAAY,GAChB,SAAS,CAAC,WAAW,GAAG,SAAS,CAAC,YAAY;QAC5C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW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,cAAc,CAAC,CAAC;IAC7E,IAAI,iBAAiB,EAAE;QACrB,OAAO,CAAC,gBAAgB,GAAI,iBAAuC,CAAC,wBAAwB,CAAC;KAC9F;AACH,CAAC","file":"rotate-table.js","sourcesContent":["import {\n matrixAllocate,\n transformPointForCanvas,\n mapToCanvasPointForCanvas,\n registerGlobalEventTransformer,\n registerWindowEventTransformer,\n vglobal\n} from '@visactor/vtable/es/vrender';\nimport type { BaseTable } from '@visactor/vtable/src/core/BaseTable';\nimport * as VTable from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\nimport type { Matrix } from '@visactor/vutils';\n// export type IRotateTablePluginOptions = {\n// // 旋转角度\n// rotate?: number;\n// };\n/**\n * 旋转表格插件。\n * 业务层旋转功能没有使用收系统接口的话,用的transform:'rotate(90deg)'的设置来达到旋转的目的。vtable及vrender都没有进行坐标处理,这样就会导致交互错乱。\n * 所以需要进行坐标转换,将旋转后的坐标转换后作为VRender及VTable逻辑中用到的坐标。\n * 这里使用transform:'rotate(90deg)'的设置来达到旋转的目的。 其他角度应该也是可以实现的,请自行扩展这个插件并兼容\n */\nexport class RotateTablePlugin implements VTable.plugins.IVTablePlugin {\n id = 'rotate-table';\n name = 'Rotate Table';\n runTime = [VTable.TABLE_EVENT_TYPE.INITIALIZED];\n table: VTable.ListTable;\n matrix: Matrix;\n vglobal_mapToCanvasPoint: any; // 保存vrender中vglobal的mapToCanvasPoint原方法\n // pluginOptions: IRotateTablePluginOptions;\n constructor() {\n // this.pluginOptions = pluginOptions;\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], VTable.BaseTableAPI]) {\n const table: VTable.BaseTableAPI = args[2];\n this.table = table as VTable.ListTable;\n //将函数rotate90WithTransform绑定到table实例上\n this.table.rotate90WithTransform = rotate90WithTransform.bind(this.table);\n this.table.cancelTransform = cancelTransform.bind(this.table);\n }\n\n release() {\n // 移除绑定的事件\n }\n}\n\n/**\n * 业务层旋转功能没有使用收系统接口的话,用的transform:'rotate(90deg)'的设置来达到旋转的目的。vtable及vrender都没有进行坐标处理,这样就会导致交互错乱。\n * 所以需要进行坐标转换,将旋转后的坐标转换后作为VRender及VTable逻辑中用到的坐标。\n */\nexport function rotate90WithTransform(this: BaseTable, rotateDom: HTMLElement) {\n this.rotateDegree = 90;\n const rotateCenter =\n rotateDom.clientWidth < rotateDom.clientHeight\n ? Math.max(rotateDom.clientWidth, rotateDom.clientHeight) / 2\n : Math.min(rotateDom.clientWidth, rotateDom.clientHeight) / 2;\n const domRect = this.getElement().getBoundingClientRect();\n const x1 = domRect.left;\n const y1 = domRect.top;\n const x2 = domRect.right;\n const y2 = domRect.bottom;\n\n rotateDom.style.transform = 'rotate(90deg)';\n rotateDom.style.transformOrigin = `${rotateCenter}px ${rotateCenter}px`;\n const getRect = () => {\n return {\n x1,\n y1,\n x2,\n y2\n };\n };\n // 获取视口尺寸的通用方法\n const getViewportDimensions = () => {\n // 浏览器环境\n if (typeof window !== 'undefined') {\n return {\n width: window.innerWidth || document.documentElement.clientWidth,\n height: window.innerHeight || document.documentElement.clientHeight\n };\n }\n // 如果有 vglobal 上的方法可以使用\n if (vglobal && vglobal.getViewportSize) {\n return vglobal.getViewportSize();\n }\n // 默认使用容器的尺寸\n return rotateDom.getBoundingClientRect();\n };\n\n const getMatrix = () => {\n const viewPortWidth = getViewportDimensions().width; //获取整个视口的尺寸\n const domRect = this.getElement().getBoundingClientRect(); //TODO 这个地方应该获取窗口的宽高 最好能从vglobal上直接获取\n const x1 = domRect.top;\n const y1 = viewPortWidth - domRect.right;\n\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n matrix.translate(x1, y1);\n const centerX = rotateCenter - x1;\n const centerY = rotateCenter - y1;\n matrix.translate(centerX, centerY);\n matrix.rotate(Math.PI / 2);\n matrix.translate(-centerX, -centerY);\n const rotateRablePlugin = this.pluginManager.getPluginByName('Rotate Table');\n if (rotateRablePlugin) {\n (rotateRablePlugin as RotateTablePlugin).matrix = matrix;\n }\n return matrix;\n };\n registerGlobalEventTransformer(vglobal, this.getElement(), getMatrix, getRect, transformPointForCanvas);\n registerWindowEventTransformer(\n this.scenegraph.stage.window,\n this.getElement(),\n getMatrix,\n getRect,\n transformPointForCanvas\n );\n const rotateRablePlugin = this.pluginManager.getPluginByName('Rotate Table');\n if (rotateRablePlugin) {\n (rotateRablePlugin as RotateTablePlugin).vglobal_mapToCanvasPoint = vglobal.mapToCanvasPoint;\n }\n vglobal.mapToCanvasPoint = mapToCanvasPointForCanvas;\n //transformPointForCanvas和mapToCanvasPointForCanvas时相对应的\n //具体逻辑在 VRender/packages/vrender-core/src/common/event-transformer.ts中\n // 可以自定义这两个函数 来修改事件属性,transformPointForCanvas中将坐标转换后存放了_canvasX _canvasY,mapToCanvasPointForCanvas中加以利用\n // 在VTable的touch文件中,利用到了_canvasX _canvasY 所以如果自定义上面两个函数也需提供_canvasX _canvasY\n}\nexport function cancelTransform(this: BaseTable, rotateDom: HTMLElement) {\n this.rotateDegree = 0;\n rotateDom.style.transform = 'none';\n rotateDom.style.transformOrigin = 'none';\n const domRect = this.getElement().getBoundingClientRect();\n const x1 = domRect.left;\n const y1 = domRect.top;\n const x2 = domRect.right;\n const y2 = domRect.bottom;\n\n const getRect = () => {\n return {\n x1,\n y1,\n x2,\n y2\n };\n };\n const getMatrix = () => {\n const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n matrix.translate(x1, y1);\n return matrix;\n };\n registerGlobalEventTransformer(vglobal, this.getElement(), getMatrix, getRect, transformPointForCanvas);\n registerWindowEventTransformer(\n this.scenegraph.stage.window,\n this.getElement(),\n getMatrix,\n getRect,\n transformPointForCanvas\n );\n const rotateRablePlugin = this.pluginManager.getPluginByName('Rotate Table');\n if (rotateRablePlugin) {\n vglobal.mapToCanvasPoint = (rotateRablePlugin as RotateTablePlugin).vglobal_mapToCanvasPoint;\n }\n}\n"]}
@@ -3,10 +3,11 @@ export interface RowSeriesOptions {
3
3
  rowCount: number;
4
4
  fillRowRecord?: (index: number) => any;
5
5
  rowSeriesNumber?: TYPES.IRowSeriesNumber;
6
- autoExtendRow?: boolean;
6
+ autoExtendRowTriggerKeys?: ('ArrowDown' | 'Enter')[];
7
7
  }
8
8
  export declare class RowSeriesPlugin implements plugins.IVTablePlugin {
9
9
  id: string;
10
+ name: string;
10
11
  runTime: ("before_keydown" | "before_init")[];
11
12
  pluginOptions: RowSeriesOptions;
12
13
  table: ListTable;
package/es/row-series.js CHANGED
@@ -2,14 +2,13 @@ import { TABLE_EVENT_TYPE } from "@visactor/vtable";
2
2
 
3
3
  export class RowSeriesPlugin {
4
4
  constructor(pluginOptions) {
5
- this.id = "row-series", this.runTime = [ TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_KEYDOWN ],
5
+ this.id = `row-series-${Date.now()}`, this.name = "Row Series", this.runTime = [ TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_KEYDOWN ],
6
6
  this.pluginOptions = Object.assign({
7
- rowCount: 100,
8
- autoExtendRow: !0
7
+ rowCount: 100
9
8
  }, pluginOptions);
10
9
  }
11
10
  run(...args) {
12
- var _a;
11
+ var _a, _b;
13
12
  if (args[1] === TABLE_EVENT_TYPE.BEFORE_INIT) {
14
13
  const eventArgs = args[0], table = args[2];
15
14
  this.table = table;
@@ -20,7 +19,8 @@ export class RowSeriesPlugin {
20
19
  width: "auto"
21
20
  });
22
21
  } else if (args[1] === TABLE_EVENT_TYPE.BEFORE_KEYDOWN) {
23
- "ArrowDown" === args[0].event.key && this.pluginOptions.autoExtendRow && this.table.stateManager.select.cellPos.row === this.table.rowCount - 1 && this.table.addRecord(this.pluginOptions.fillRowRecord ? this.pluginOptions.fillRowRecord(this.table.rowCount - this.table.columnHeaderLevelCount) : {});
22
+ const e = args[0].event;
23
+ (null === (_b = this.pluginOptions.autoExtendRowTriggerKeys) || void 0 === _b ? void 0 : _b.includes(e.key)) && this.table.stateManager.select.cellPos.row === this.table.rowCount - 1 && this.table.addRecord(this.pluginOptions.fillRowRecord ? this.pluginOptions.fillRowRecord(this.table.rowCount - this.table.columnHeaderLevelCount) : {});
24
24
  }
25
25
  }
26
26
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["row-series.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAkBpD,MAAM,OAAO,eAAe;IAM1B,YAAY,aAA+B;QAL3C,OAAE,GAAG,YAAY,CAAC;QAClB,YAAO,GAAG,CAAC,gBAAgB,CAAC,WAAW,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;QAKxE,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,aAAa,CAAC,CAAC;IAC5F,CAAC;IACD,GAAG,CAAC,GAAG,IAAW;;QAChB,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,WAAW,EAAE;YAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAC1B,MAAM,KAAK,GAAiB,IAAI,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,CAAC,KAAK,GAAG,KAAkB,CAAC;YAChC,MAAM,OAAO,GAAgC,SAAS,CAAC,OAAO,CAAC;YAC/D,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE,CAAC;YAEtC,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE;gBACjE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aAC3F;YACD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;YAC1B,IAAI,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE;gBACtC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC;gBAC7D,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,KAAK,EAAE;oBAC7C,OAAO,CAAC,eAAe,CAAC,KAAK,GAAG,MAAM,CAAC;iBACxC;aACF;iBAAM,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;gBACnC,OAAO,CAAC,eAAe,GAAG;oBACxB,KAAK,EAAE,MAAM;iBACd,CAAC;aACH;SACF;aAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,cAAc,EAAE;YACtD,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAE1B,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC;YAC1B,IAAI,CAAC,CAAC,GAAG,KAAK,WAAW,EAAE;gBACzB,IACE,IAAI,CAAC,aAAa,CAAC,aAAa;oBAChC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,EACtE;oBACC,IAAI,CAAC,KAAmB,CAAC,SAAS,CACjC,IAAI,CAAC,aAAa,CAAC,aAAa;wBAC9B,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC;wBAC3F,CAAC,CAAC,EAAE,CACP,CAAC;iBACH;aACF;SACF;IACH,CAAC;CACF","file":"row-series.js","sourcesContent":["import { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { TYPES, BaseTableAPI, ListTable, ListTableConstructorOptions, plugins } from '@visactor/vtable';\n/**\n * 添加行和列的插件的配置选项\n */\nexport interface RowSeriesOptions {\n rowCount: number;\n fillRowRecord?: (index: number) => any;\n rowSeriesNumber?: TYPES.IRowSeriesNumber;\n /**\n * 是否自动扩展行\n * @default true\n */\n autoExtendRow?: boolean;\n}\n/**\n * 生成行序号标题的插件\n */\nexport class RowSeriesPlugin implements plugins.IVTablePlugin {\n id = 'row-series';\n runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_KEYDOWN];\n pluginOptions: RowSeriesOptions;\n table: ListTable;\n\n constructor(pluginOptions: RowSeriesOptions) {\n this.pluginOptions = Object.assign({ rowCount: 100, autoExtendRow: true }, pluginOptions);\n }\n run(...args: any[]) {\n if (args[1] === TABLE_EVENT_TYPE.BEFORE_INIT) {\n const eventArgs = args[0];\n const table: BaseTableAPI = args[2];\n this.table = table as ListTable;\n const options: ListTableConstructorOptions = eventArgs.options;\n const records = options.records ?? [];\n //用空数据将records填充到pluginOptions.rowCount\n for (let i = records.length; i < this.pluginOptions.rowCount; i++) {\n records.push(this.pluginOptions.fillRowRecord ? this.pluginOptions.fillRowRecord(i) : {});\n }\n options.records = records;\n if (this.pluginOptions.rowSeriesNumber) {\n options.rowSeriesNumber = this.pluginOptions.rowSeriesNumber;\n if (!this.pluginOptions.rowSeriesNumber.width) {\n options.rowSeriesNumber.width = 'auto';\n }\n } else if (!options.rowSeriesNumber) {\n options.rowSeriesNumber = {\n width: 'auto'\n };\n }\n } else if (args[1] === TABLE_EVENT_TYPE.BEFORE_KEYDOWN) {\n const eventArgs = args[0];\n\n const e = eventArgs.event;\n if (e.key === 'ArrowDown') {\n if (\n this.pluginOptions.autoExtendRow &&\n this.table.stateManager.select.cellPos.row === this.table.rowCount - 1\n ) {\n (this.table as ListTable).addRecord(\n this.pluginOptions.fillRowRecord\n ? this.pluginOptions.fillRowRecord(this.table.rowCount - this.table.columnHeaderLevelCount)\n : {}\n );\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"s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C,eAAe,CAAC;gBAC7D,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,KAAK,EAAE;oBAC7C,OAAO,CAAC,eAAe,CAAC,KAAK,GAAG,MAAM,CAAC;iBACxC;aACF;iBAAM,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;gBACnC,OAAO,CAAC,eAAe,GAAG;oBACxB,KAAK,EAAE,MAAM;iBACd,CAAC;aACH;SACF;aAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,cAAc,EAAE;YACtD,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAE1B,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC;YAE1B,IACE,CAAA,MAAA,IAAI,CAAC,aAAa,CAAC,wBAAwB,0CAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC5D,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,EACtE;gBACC,IAAI,CAAC,KAAmB,CAAC,SAAS,CACjC,IAAI,CAAC,aAAa,CAAC,aAAa;oBAC9B,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC;oBAC3F,CAAC,CAAC,EAAE,CACP,CAAC;aACH;SACF;IACH,CAAC;CACF","file":"row-series.js","sourcesContent":["import { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { TYPES, BaseTableAPI, ListTable, ListTableConstructorOptions, plugins } from '@visactor/vtable';\n/**\n * 添加行和列的插件的配置选项\n */\nexport interface RowSeriesOptions {\n rowCount: number;\n fillRowRecord?: (index: number) => any;\n rowSeriesNumber?: TYPES.IRowSeriesNumber;\n /**\n * 是否自动扩展行\n * @default true\n */\n autoExtendRowTriggerKeys?: ('ArrowDown' | 'Enter')[];\n}\n/**\n * 生成行序号标题的插件\n */\nexport class RowSeriesPlugin implements plugins.IVTablePlugin {\n id = `row-series-${Date.now()}`;\n name = 'Row Series';\n runTime = [TABLE_EVENT_TYPE.BEFORE_INIT, TABLE_EVENT_TYPE.BEFORE_KEYDOWN];\n pluginOptions: RowSeriesOptions;\n table: ListTable;\n\n constructor(pluginOptions: RowSeriesOptions) {\n this.pluginOptions = Object.assign({ rowCount: 100 }, pluginOptions);\n }\n run(...args: any[]) {\n if (args[1] === TABLE_EVENT_TYPE.BEFORE_INIT) {\n const eventArgs = args[0];\n const table: BaseTableAPI = args[2];\n this.table = table as ListTable;\n const options: ListTableConstructorOptions = eventArgs.options;\n const records = options.records ?? [];\n //用空数据将records填充到pluginOptions.rowCount\n for (let i = records.length; i < this.pluginOptions.rowCount; i++) {\n records.push(this.pluginOptions.fillRowRecord ? this.pluginOptions.fillRowRecord(i) : {});\n }\n options.records = records;\n if (this.pluginOptions.rowSeriesNumber) {\n options.rowSeriesNumber = this.pluginOptions.rowSeriesNumber;\n if (!this.pluginOptions.rowSeriesNumber.width) {\n options.rowSeriesNumber.width = 'auto';\n }\n } else if (!options.rowSeriesNumber) {\n options.rowSeriesNumber = {\n width: 'auto'\n };\n }\n } else if (args[1] === TABLE_EVENT_TYPE.BEFORE_KEYDOWN) {\n const eventArgs = args[0];\n\n const e = eventArgs.event;\n\n if (\n this.pluginOptions.autoExtendRowTriggerKeys?.includes(e.key) &&\n this.table.stateManager.select.cellPos.row === this.table.rowCount - 1\n ) {\n (this.table as ListTable).addRecord(\n this.pluginOptions.fillRowRecord\n ? this.pluginOptions.fillRowRecord(this.table.rowCount - this.table.columnHeaderLevelCount)\n : {}\n );\n }\n }\n }\n}\n"]}
@@ -20,6 +20,7 @@ export interface ITableCarouselAnimationPluginOptions {
20
20
  }
21
21
  export declare class TableCarouselAnimationPlugin implements VTable.plugins.IVTablePlugin {
22
22
  id: string;
23
+ name: string;
23
24
  runTime: "initialized"[];
24
25
  table: BaseTableAPI;
25
26
  rowCount: number;
@@ -7,8 +7,9 @@ function isInteger(value) {
7
7
  export class TableCarouselAnimationPlugin {
8
8
  constructor(options = {}) {
9
9
  var _a, _b, _c, _d, _e, _f, _g;
10
- this.id = "table-carousel-animation", this.runTime = [ TABLE_EVENT_TYPE.INITIALIZED ],
11
- this.willUpdateRow = !1, this.willUpdateCol = !1, this.rowCount = null !== (_a = null == options ? void 0 : options.rowCount) && void 0 !== _a ? _a : void 0,
10
+ this.id = `table-carousel-animation-${Date.now()}`, this.name = "Table Carousel Animation",
11
+ this.runTime = [ TABLE_EVENT_TYPE.INITIALIZED ], this.willUpdateRow = !1, this.willUpdateCol = !1,
12
+ this.rowCount = null !== (_a = null == options ? void 0 : options.rowCount) && void 0 !== _a ? _a : void 0,
12
13
  this.colCount = null !== (_b = null == options ? void 0 : options.colCount) && void 0 !== _b ? _b : void 0,
13
14
  this.animationDuration = null !== (_c = null == options ? void 0 : options.animationDuration) && void 0 !== _c ? _c : 500,
14
15
  this.animationDelay = null !== (_d = null == options ? void 0 : options.animationDelay) && void 0 !== _d ? _d : 1e3,
@@ -1 +1 @@
1
- {"version":3,"sources":["table-carousel-animation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;AACrC,CAAC;AAeD,MAAM,OAAO,4BAA4B;IAqBvC,YAAY,UAAgD,EAAE;;QApB9D,OAAE,GAAG,0BAA0B,CAAC;QAChC,YAAO,GAAG,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAYzC,kBAAa,GAAY,KAAK,CAAC;QAC/B,kBAAa,GAAY,KAAK,CAAC;QAO7B,IAAI,CAAC,QAAQ,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,SAAS,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AAa,KAAK,IAAI,CAAC,GAAG,EAAE;YACxF,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;YACrC,SAAS,GAAG,KAAK,CAAC;SACnB;aAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACrG,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;IACD,OAAO;IAEP,CAAC;CACF","file":"table-carousel-animation.js","sourcesContent":["import type { EasingType } from '@visactor/vtable/es/vrender';\nimport type { BaseTableAPI } from '@visactor/vtable/es/ts-types/base-table';\nimport { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type * as VTable from '@visactor/vtable';\nfunction isInteger(value: number) {\n return Math.floor(value) === value;\n}\n\nexport interface ITableCarouselAnimationPluginOptions {\n rowCount?: number;\n colCount?: number;\n animationDuration?: number;\n animationDelay?: number;\n animationEasing?: EasingType;\n autoPlay?: boolean;\n autoPlayDelay?: number;\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 TableCarouselAnimationPlugin implements VTable.plugins.IVTablePlugin {\n id = 'table-carousel-animation';\n runTime = [TABLE_EVENT_TYPE.INITIALIZED];\n table: BaseTableAPI;\n\n rowCount: number;\n colCount: number;\n animationDuration: number;\n animationDelay: number;\n animationEasing: EasingType;\n\n playing: boolean;\n row: number;\n col: number;\n willUpdateRow: boolean = false;\n willUpdateCol: boolean = false;\n autoPlay: boolean;\n autoPlayDelay: number;\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(options: ITableCarouselAnimationPluginOptions = {}) {\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.autoPlay = options?.autoPlay ?? false;\n this.autoPlayDelay = options?.autoPlayDelay ?? 0;\n this.customDistColFunction = options.customDistColFunction;\n this.customDistRowFunction = options.customDistRowFunction;\n }\n run(...args: any[]) {\n if (!this.table) {\n this.table = args[2] as BaseTableAPI;\n }\n this.reset();\n\n if (this.autoPlay) {\n setTimeout(() => {\n this.play();\n }, this.autoPlayDelay);\n }\n }\n\n reset() {\n this.playing = false;\n this.row = this.table.frozenRowCount;\n this.col = this.table.frozenColCount;\n }\n\n play() {\n if (!this.table) {\n throw new Error('table is not initialized');\n }\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 (isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== this.row) {\n this.row = this.table.frozenRowCount;\n animation = false;\n } else if (!isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== Math.floor(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 (isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) {\n this.col = this.table.frozenColCount;\n animation = false;\n } else if (!isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== Math.floor(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 release() {\n // do nothing\n }\n}\n"]}
1
+ {"version":3,"sources":["table-carousel-animation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,SAAS,SAAS,CAAC,KAAa;IAC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AG,KAAK,CAAC;YAC3B,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC,EAED,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAC7C,CAAC;IACJ,CAAC;IACD,OAAO;IAEP,CAAC;CACF","file":"table-carousel-animation.js","sourcesContent":["import type { EasingType } from '@visactor/vtable/es/vrender';\nimport type { BaseTableAPI } from '@visactor/vtable/es/ts-types/base-table';\nimport { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type * as VTable from '@visactor/vtable';\nfunction isInteger(value: number) {\n return Math.floor(value) === value;\n}\n\nexport interface ITableCarouselAnimationPluginOptions {\n rowCount?: number;\n colCount?: number;\n animationDuration?: number;\n animationDelay?: number;\n animationEasing?: EasingType;\n autoPlay?: boolean;\n autoPlayDelay?: number;\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 TableCarouselAnimationPlugin implements VTable.plugins.IVTablePlugin {\n id = `table-carousel-animation-${Date.now()}`;\n name = 'Table Carousel Animation';\n runTime = [TABLE_EVENT_TYPE.INITIALIZED];\n table: BaseTableAPI;\n\n rowCount: number;\n colCount: number;\n animationDuration: number;\n animationDelay: number;\n animationEasing: EasingType;\n\n playing: boolean;\n row: number;\n col: number;\n willUpdateRow: boolean = false;\n willUpdateCol: boolean = false;\n autoPlay: boolean;\n autoPlayDelay: number;\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(options: ITableCarouselAnimationPluginOptions = {}) {\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.autoPlay = options?.autoPlay ?? false;\n this.autoPlayDelay = options?.autoPlayDelay ?? 0;\n this.customDistColFunction = options.customDistColFunction;\n this.customDistRowFunction = options.customDistRowFunction;\n }\n run(...args: any[]) {\n if (!this.table) {\n this.table = args[2] as BaseTableAPI;\n }\n this.reset();\n\n if (this.autoPlay) {\n setTimeout(() => {\n this.play();\n }, this.autoPlayDelay);\n }\n }\n\n reset() {\n this.playing = false;\n this.row = this.table.frozenRowCount;\n this.col = this.table.frozenColCount;\n }\n\n play() {\n if (!this.table) {\n throw new Error('table is not initialized');\n }\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 (isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== this.row) {\n this.row = this.table.frozenRowCount;\n animation = false;\n } else if (!isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== Math.floor(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 (isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) {\n this.col = this.table.frozenColCount;\n animation = false;\n } else if (!isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== Math.floor(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 release() {\n // do nothing\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vtable-plugins",
3
- "version": "1.18.2-alpha.3",
3
+ "version": "1.18.2",
4
4
  "description": "The search util of VTable",
5
5
  "author": {
6
6
  "name": "VisActor",
@@ -33,11 +33,9 @@
33
33
  "@visactor/vutils": "~0.19.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@visactor/vtable": "1.18.2-alpha.3"
36
+ "@visactor/vtable": "1.18.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@visactor/vtable": "1.18.2-alpha.3",
40
- "@visactor/vtable-editors": "1.18.2-alpha.3",
41
39
  "@visactor/vchart": "1.13.3-alpha.2",
42
40
  "@rushstack/eslint-patch": "~1.1.4",
43
41
  "react": "^18.0.0",
@@ -79,9 +77,11 @@
79
77
  "axios": "^1.4.0",
80
78
  "@types/react-is": "^17.0.3",
81
79
  "rollup-plugin-node-resolve": "5.2.0",
80
+ "@visactor/vtable": "1.18.2",
81
+ "@visactor/vtable-editors": "1.18.2",
82
+ "@internal/eslint-config": "0.0.1",
82
83
  "@internal/bundler": "0.0.1",
83
- "@internal/ts-config": "0.0.1",
84
- "@internal/eslint-config": "0.0.1"
84
+ "@internal/ts-config": "0.0.1"
85
85
  },
86
86
  "scripts": {
87
87
  "demo": "vite ./demo",