@visactor/vtable 0.18.2 → 0.18.3-alpha.0

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.
@@ -9,6 +9,7 @@ import { Scenegraph } from '../scenegraph/scenegraph';
9
9
  import { StateManager } from '../state/state';
10
10
  import { EventManager } from '../event/event';
11
11
  import type { CachedDataSource, DataSource } from '../data';
12
+ import type { IBoundsLike } from '@visactor/vutils';
12
13
  import { type ITextSize } from '@visactor/vutils';
13
14
  import type { ColumnData, ColumnDefine, ColumnsDefine, IndicatorData } from '../ts-types/list-table/layout-map/api';
14
15
  import type { TooltipOptions } from '../ts-types/tooltip';
@@ -123,6 +124,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
123
124
  _adjustColWidth(col: number, orgWidth: number): number;
124
125
  setPixelRatio(pixelRatio: number): void;
125
126
  _updateSize(): void;
127
+ updateViewBox(newViewBox: IBoundsLike): void;
126
128
  get rowHierarchyType(): 'grid' | 'tree';
127
129
  getColsWidth(startCol: number, endCol: number): number;
128
130
  getRowHeight(row: number): number;
@@ -45,9 +45,9 @@ class BaseTable extends EventTarget_1.EventTarget {
45
45
  }
46
46
  constructor(container, options = {}) {
47
47
  var _a, _b, _c, _d, _e, _f, _g;
48
- if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.18.2",
48
+ if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.18.3-alpha.0",
49
49
  this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {},
50
- this.throttleInvalidate = (0, util_1.throttle2)(this.render.bind(this), 200), !container && "node" !== options.mode) throw new Error("vtable's container is undefined");
50
+ this.throttleInvalidate = (0, util_1.throttle2)(this.render.bind(this), 200), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
51
51
  const {frozenColCount: frozenColCount = 0, defaultRowHeight: defaultRowHeight = 40, defaultHeaderRowHeight: defaultHeaderRowHeight, defaultColWidth: defaultColWidth = 80, defaultHeaderColWidth: defaultHeaderColWidth, widthMode: widthMode = "standard", heightMode: heightMode = "standard", autoFillWidth: autoFillWidth = !1, autoFillHeight: autoFillHeight = !1, keyboardOptions: keyboardOptions, eventOptions: eventOptions, columnResizeMode: columnResizeMode, dragHeaderMode: dragHeaderMode, showFrozenIcon: showFrozenIcon, allowFrozenColCount: allowFrozenColCount, padding: padding, hover: hover, menu: menu, select: click, customRender: customRender, pixelRatio: pixelRatio = pixel_ratio_1.defaultPixelRatio, renderChartAsync: renderChartAsync, renderChartAsyncBatchCount: renderChartAsyncBatchCount, mode: mode, modeParams: modeParams, canvasWidth: canvasWidth, canvasHeight: canvasHeight, overscrollBehavior: overscrollBehavior, limitMinWidth: limitMinWidth} = options;
52
52
  this.container = container, this.options = options, this.options.container = container,
53
53
  this._widthMode = widthMode, this._heightMode = heightMode, this._autoFillWidth = autoFillWidth,
@@ -63,8 +63,10 @@ class BaseTable extends EventTarget_1.EventTarget {
63
63
  this.tableNoFrameHeight = 0, this.canvasWidth = canvasWidth, this.canvasHeight = canvasHeight;
64
64
  const internalProps = this.internalProps = {};
65
65
  void 0 !== showFrozenIcon && (this.showFrozenIcon = showFrozenIcon), "number" == typeof allowFrozenColCount && allowFrozenColCount <= 0 && (this.showFrozenIcon = !1),
66
- "node" !== env_1.Env.mode && (internalProps.element = (0, tableHelper_1.createRootElement)(this.padding),
66
+ this.options.canvas ? (internalProps.element = this.options.canvas.parentElement,
67
67
  internalProps.focusControl = new FouseInput_1.FocusInput(this, internalProps.element),
68
+ internalProps.canvas = this.options.canvas, internalProps.context = internalProps.canvas.getContext("2d")) : "node" !== env_1.Env.mode && (internalProps.element = (0,
69
+ tableHelper_1.createRootElement)(this.padding), internalProps.focusControl = new FouseInput_1.FocusInput(this, internalProps.element),
68
70
  internalProps.canvas = document.createElement("canvas"), internalProps.element.appendChild(internalProps.canvas),
69
71
  internalProps.context = internalProps.canvas.getContext("2d")), internalProps.handler = new EventHandler_1.EventHandler,
70
72
  (0, vutils_1.isNumber)(this.options.resizeTime) && (internalProps.handler.resizeTime = this.options.resizeTime),
@@ -296,28 +298,32 @@ class BaseTable extends EventTarget_1.EventTarget {
296
298
  this.internalProps.pixelRatio = pixelRatio, this.scenegraph.setPixelRatio(pixelRatio);
297
299
  }
298
300
  _updateSize() {
299
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
301
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
300
302
  const {padding: padding} = this;
301
303
  let widthP = 0, heightP = 0;
302
- if ("browser" === env_1.Env.mode) {
303
- const element = this.getElement(), width1 = null !== (_b = null === (_a = element.parentElement) || void 0 === _a ? void 0 : _a.offsetWidth) && void 0 !== _b ? _b : 0, height1 = null !== (_d = null === (_c = element.parentElement) || void 0 === _c ? void 0 : _c.offsetHeight) && void 0 !== _d ? _d : 0;
304
+ if (this.tableX = 0, this.tableY = 0, this.options.canvas && this.options.viewBox) widthP = this.options.viewBox.x2 - this.options.viewBox.x1,
305
+ heightP = this.options.viewBox.y2 - this.options.viewBox.y1, (null === (_a = null == this ? void 0 : this.scenegraph) || void 0 === _a ? void 0 : _a.stage) && (this.options.viewBox ? this.scenegraph.stage.setViewBox(this.options.viewBox, !1) : this.scenegraph.stage.resize(widthP, heightP)); else if ("browser" === env_1.Env.mode) {
306
+ const element = this.getElement(), width1 = null !== (_c = null === (_b = element.parentElement) || void 0 === _b ? void 0 : _b.offsetWidth) && void 0 !== _c ? _c : 0, height1 = null !== (_e = null === (_d = element.parentElement) || void 0 === _d ? void 0 : _d.offsetHeight) && void 0 !== _e ? _e : 0;
304
307
  element.style.width = width1 && width1 - padding.left - padding.right + "px" || "0px",
305
308
  element.style.height = height1 && height1 - padding.top - padding.bottom + "px" || "0px";
306
309
  const {canvas: canvas} = this.internalProps;
307
- widthP = null !== (_f = null === (_e = canvas.parentElement) || void 0 === _e ? void 0 : _e.offsetWidth) && void 0 !== _f ? _f : 0,
308
- heightP = null !== (_h = null === (_g = canvas.parentElement) || void 0 === _g ? void 0 : _g.offsetHeight) && void 0 !== _h ? _h : 0,
309
- (null === (_j = null == this ? void 0 : this.scenegraph) || void 0 === _j ? void 0 : _j.stage) ? this.scenegraph.stage.resize(widthP, heightP) : (canvas.style.width = "",
310
+ widthP = null !== (_g = null === (_f = canvas.parentElement) || void 0 === _f ? void 0 : _f.offsetWidth) && void 0 !== _g ? _g : 0,
311
+ heightP = null !== (_j = null === (_h = canvas.parentElement) || void 0 === _h ? void 0 : _h.offsetHeight) && void 0 !== _j ? _j : 0,
312
+ (null === (_k = null == this ? void 0 : this.scenegraph) || void 0 === _k ? void 0 : _k.stage) ? this.scenegraph.stage.resize(widthP, heightP) : (canvas.style.width = "",
310
313
  canvas.style.height = "", canvas.width = widthP, canvas.height = heightP, canvas.style.width = `${widthP}px`,
311
314
  canvas.style.height = `${heightP}px`);
312
315
  } else "node" === env_1.Env.mode && (widthP = this.canvasWidth - 1, heightP = this.canvasHeight - 1);
313
316
  const width = Math.floor(widthP - style.getScrollBarSize(this.getTheme().scrollStyle)), height = Math.floor(heightP - style.getScrollBarSize(this.getTheme().scrollStyle));
314
- if (null === (_k = this.internalProps.theme) || void 0 === _k ? void 0 : _k.frameStyle) {
315
- const lineWidths = toBoxArray(null !== (_m = null === (_l = this.internalProps.theme.frameStyle) || void 0 === _l ? void 0 : _l.borderLineWidth) && void 0 !== _m ? _m : [ null ]), shadowWidths = toBoxArray(null !== (_p = null === (_o = this.internalProps.theme.frameStyle) || void 0 === _o ? void 0 : _o.shadowBlur) && void 0 !== _p ? _p : [ 0 ]);
316
- this.tableX = (null !== (_q = lineWidths[3]) && void 0 !== _q ? _q : 0) + (null !== (_r = shadowWidths[3]) && void 0 !== _r ? _r : 0),
317
- this.tableY = (null !== (_s = lineWidths[0]) && void 0 !== _s ? _s : 0) + (null !== (_t = shadowWidths[0]) && void 0 !== _t ? _t : 0),
318
- this.tableNoFrameWidth = width - ((null !== (_u = lineWidths[1]) && void 0 !== _u ? _u : 0) + (null !== (_v = shadowWidths[1]) && void 0 !== _v ? _v : 0)) - ((null !== (_w = lineWidths[3]) && void 0 !== _w ? _w : 0) + (null !== (_x = shadowWidths[3]) && void 0 !== _x ? _x : 0)),
319
- this.tableNoFrameHeight = height - ((null !== (_y = lineWidths[0]) && void 0 !== _y ? _y : 0) + (null !== (_z = shadowWidths[0]) && void 0 !== _z ? _z : 0)) - ((null !== (_0 = lineWidths[2]) && void 0 !== _0 ? _0 : 0) + (null !== (_1 = shadowWidths[2]) && void 0 !== _1 ? _1 : 0));
320
- }
317
+ if (null === (_l = this.internalProps.theme) || void 0 === _l ? void 0 : _l.frameStyle) {
318
+ const lineWidths = toBoxArray(null !== (_o = null === (_m = this.internalProps.theme.frameStyle) || void 0 === _m ? void 0 : _m.borderLineWidth) && void 0 !== _o ? _o : [ null ]), shadowWidths = toBoxArray(null !== (_q = null === (_p = this.internalProps.theme.frameStyle) || void 0 === _p ? void 0 : _p.shadowBlur) && void 0 !== _q ? _q : [ 0 ]);
319
+ this.tableX += (null !== (_r = lineWidths[3]) && void 0 !== _r ? _r : 0) + (null !== (_s = shadowWidths[3]) && void 0 !== _s ? _s : 0),
320
+ this.tableY += (null !== (_t = lineWidths[0]) && void 0 !== _t ? _t : 0) + (null !== (_u = shadowWidths[0]) && void 0 !== _u ? _u : 0),
321
+ this.tableNoFrameWidth = width - ((null !== (_v = lineWidths[1]) && void 0 !== _v ? _v : 0) + (null !== (_w = shadowWidths[1]) && void 0 !== _w ? _w : 0)) - ((null !== (_x = lineWidths[3]) && void 0 !== _x ? _x : 0) + (null !== (_y = shadowWidths[3]) && void 0 !== _y ? _y : 0)),
322
+ this.tableNoFrameHeight = height - ((null !== (_z = lineWidths[0]) && void 0 !== _z ? _z : 0) + (null !== (_0 = shadowWidths[0]) && void 0 !== _0 ? _0 : 0)) - ((null !== (_1 = lineWidths[2]) && void 0 !== _1 ? _1 : 0) + (null !== (_2 = shadowWidths[2]) && void 0 !== _2 ? _2 : 0));
323
+ } else this.tableX += 0, this.tableY += 0, this.tableNoFrameWidth = width, this.tableNoFrameHeight = height;
324
+ }
325
+ updateViewBox(newViewBox) {
326
+ this.options.viewBox = newViewBox, this.resize();
321
327
  }
322
328
  get rowHierarchyType() {
323
329
  return "grid";