@visactor/vtable 0.22.2-alpha.0 → 0.22.2-alpha.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.
- package/cjs/components/legend/continue-legend/continue-legend.js +1 -1
- package/cjs/components/legend/continue-legend/continue-legend.js.map +1 -1
- package/cjs/core/BaseTable.d.ts +2 -0
- package/cjs/core/BaseTable.js +19 -14
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/pivot-header-layout.js +4 -2
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/group-contribution-render.js +10 -6
- package/cjs/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
- package/cjs/scenegraph/layout/compute-col-width.js +5 -4
- package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
- package/cjs/state/state.js +1 -1
- package/cjs/themes/component.js +1 -1
- package/cjs/ts-types/base-table.d.ts +3 -0
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +59 -33
- package/dist/vtable.min.js +2 -2
- package/es/components/legend/continue-legend/continue-legend.js +1 -1
- package/es/components/legend/continue-legend/continue-legend.js.map +1 -1
- package/es/core/BaseTable.d.ts +2 -0
- package/es/core/BaseTable.js +19 -14
- package/es/core/BaseTable.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/pivot-header-layout.js +4 -2
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/scenegraph/graphic/contributions/group-contribution-render.js +10 -6
- package/es/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
- package/es/scenegraph/layout/compute-col-width.js +5 -4
- package/es/scenegraph/layout/compute-col-width.js.map +1 -1
- package/es/state/state.js +1 -1
- package/es/themes/component.js +1 -1
- package/es/ts-types/base-table.d.ts +3 -0
- package/es/ts-types/base-table.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +4 -4
|
@@ -13,7 +13,7 @@ export class ContinueTableLegend {
|
|
|
13
13
|
var _a, _b, _c, _d;
|
|
14
14
|
this.table = table, this.option = cloneDeep(option), this.orient = null !== (_a = option.orient) && void 0 !== _a ? _a : "left",
|
|
15
15
|
this.visible = null === (_b = option.visible) || void 0 === _b || _b, this.position = null !== (_c = option.position) && void 0 !== _c ? _c : "middle",
|
|
16
|
-
this.selectedData = null !== (_d = option.defaultSelected) && void 0 !== _d ? _d :
|
|
16
|
+
this.selectedData = null !== (_d = option.defaultSelected) && void 0 !== _d ? _d : null,
|
|
17
17
|
this.createComponent(), this.initEvent();
|
|
18
18
|
}
|
|
19
19
|
createComponent() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/legend/continue-legend/continue-legend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAe,MAAM,8BAA8B,CAAC;AACxG,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjE,MAAM,OAAO,mBAAmB;IAS9B,YAAY,MAAwD,EAAE,KAAmB;;QACvF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAA,MAAM,CAAC,MAAM,mCAAI,MAAM,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAI,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,MAAA,MAA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AAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED,eAAe;QACb,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9G,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjH,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM;SACf,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACnG,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC9B,CAAC;CACF","file":"continue-legend.js","sourcesContent":["import { cloneDeep, get, merge } from '@visactor/vutils';\nimport type { IColorTableLegendOption, ISizeTableLegendOption } from '../../../ts-types/component/legend';\nimport type { BaseTableAPI } from '../../../ts-types/base-table';\nimport { ColorContinuousLegend, SizeContinuousLegend, LegendEvent } from '@visactor/vrender-components';\nimport { getContinuousLegendAttributes } from './get-continue-legend-attributes';\nimport { TABLE_EVENT_TYPE } from '../../../core/TABLE_EVENT_TYPE';\nimport { getQuadProps } from '../../../scenegraph/utils/padding';\nimport type { IOrientType } from '../../../ts-types/component/util';\n\nexport class ContinueTableLegend {\n table: BaseTableAPI;\n option: IColorTableLegendOption | ISizeTableLegendOption;\n orient: IOrientType;\n visible: boolean;\n position: 'start' | 'middle' | 'end';\n selectedData: (string | number)[];\n legendComponent: ColorContinuousLegend | SizeContinuousLegend;\n\n constructor(option: IColorTableLegendOption | ISizeTableLegendOption, table: BaseTableAPI) {\n this.table = table;\n this.option = cloneDeep(option);\n this.orient = option.orient ?? 'left';\n this.visible = option.visible ?? true;\n this.position = option.position ?? 'middle';\n this.selectedData = option.defaultSelected ?? [];\n\n this.createComponent();\n this.initEvent();\n }\n\n createComponent() {\n const attrs = this.getLegendAttributes({\n width: this.table.tableNoFrameWidth,\n height: this.table.tableNoFrameHeight\n });\n\n let legend;\n if (this.option.type === 'color') {\n legend = new ColorContinuousLegend(\n merge({}, attrs, {\n slidable: true\n // defaultSelected: this.selectedData\n })\n );\n } else {\n legend = new SizeContinuousLegend(\n merge({}, attrs, {\n slidable: true\n // defaultSelected: this.selectedData\n })\n );\n }\n legend.name = 'legend';\n this.legendComponent = legend;\n this.table.scenegraph.stage.defaultLayer.appendChild(legend);\n\n this.adjustTableSize(attrs);\n }\n\n resize() {\n if (!this.legendComponent) {\n return;\n }\n\n this.legendComponent.setAttributes({\n width: this.table.tableNoFrameWidth,\n height: this.table.tableNoFrameHeight\n });\n\n this.adjustTableSize(this.legendComponent.attribute);\n }\n\n adjustTableSize(attrs: any) {\n // 调整位置\n let width = isFinite(this.legendComponent.AABBBounds.width()) ? this.legendComponent.AABBBounds.width() : 0;\n let height = isFinite(this.legendComponent.AABBBounds.height()) ? this.legendComponent.AABBBounds.height() : 0;\n if (width <= 0 || height <= 0) {\n return;\n }\n const rectWidth = this.table.tableNoFrameWidth;\n const rectHeight = this.table.tableNoFrameHeight;\n const padding = getQuadProps(attrs.padding ?? this.option.padding ?? 10);\n\n let x = 0;\n let y = 0;\n if (this.orient === 'left') {\n x = padding[3];\n y = 0;\n width += padding[1] + padding[3];\n } else if (this.orient === 'top') {\n x = 0;\n y = padding[0];\n height += padding[0] + padding[2];\n } else if (this.orient === 'right') {\n x = rectWidth - width - padding[1];\n y = 0;\n width += padding[1] + padding[3];\n } else if (this.orient === 'bottom') {\n x = 0;\n y = rectHeight - height - padding[2];\n height += padding[0] + padding[2];\n }\n\n const layout = this.orient === 'bottom' || this.orient === 'top' ? 'horizontal' : 'vertical';\n const position = this.position;\n // const { width: rectWidth, height: rectHeight } = fullSpace;\n let offsetX = 0;\n let offsetY = 0;\n if (layout === 'horizontal') {\n if (position === 'middle') {\n offsetX = (rectWidth - width) / 2;\n } else if (position === 'end') {\n offsetX = rectWidth - width - padding[1];\n } else {\n offsetX = padding[3];\n }\n } else {\n if (position === 'middle') {\n offsetY = (rectHeight - height) / 2;\n } else if (position === 'end') {\n offsetY = rectHeight - height - padding[2];\n } else {\n offsetY = padding[0];\n }\n }\n\n this.legendComponent.setAttributes({\n dx: offsetX,\n dy: offsetY,\n x,\n y\n });\n\n // update table size\n if (this.orient === 'left') {\n this.table.tableNoFrameWidth = this.table.tableNoFrameWidth - Math.ceil(width);\n this.table.tableX += Math.ceil(width);\n } else if (this.orient === 'top') {\n this.table.tableNoFrameHeight = this.table.tableNoFrameHeight - Math.ceil(height);\n this.table.tableY += Math.ceil(height);\n } else if (this.orient === 'right') {\n this.table.tableNoFrameWidth = this.table.tableNoFrameWidth - Math.ceil(width);\n } else if (this.orient === 'bottom') {\n this.table.tableNoFrameHeight = this.table.tableNoFrameHeight - Math.ceil(height);\n }\n }\n\n getLegendAttributes(rect: any) {\n const layout = this.orient === 'bottom' || this.orient === 'top' ? 'horizontal' : 'vertical';\n const align = layout === 'horizontal' ? 'bottom' : this.orient;\n\n const attrs = {\n ...getContinuousLegendAttributes(this.option, rect),\n layout,\n align,\n // zIndex: this.layoutZIndex,\n min: this.option.min,\n max: this.option.max,\n value: this.option.value,\n [this.option.type === 'color' ? 'colors' : 'sizeRange']:\n this.option.type === 'color'\n ? (this.option as IColorTableLegendOption).colors\n : (this.option as ISizeTableLegendOption).sizeRange\n };\n return attrs;\n }\n\n initEvent() {\n if (this.legendComponent) {\n this.legendComponent.addEventListener('change', (e: any) => {\n const selectedData = get(e, 'detail.value');\n this.table.fireListeners(TABLE_EVENT_TYPE.LEGEND_CHANGE, { model: this, value: selectedData, event: e });\n this.table.scenegraph.updateNextFrame();\n });\n }\n }\n\n getLegendBounds() {\n const width = isFinite(this.legendComponent.AABBBounds.width()) ? this.legendComponent.AABBBounds.width() : 0;\n const height = isFinite(this.legendComponent.AABBBounds.height()) ? this.legendComponent.AABBBounds.height() : 0;\n\n return {\n width: width,\n height: height\n };\n }\n release() {\n this.legendComponent && this.table.scenegraph.stage.defaultLayer.removeChild(this.legendComponent);\n this.legendComponent = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/legend/continue-legend/continue-legend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAe,MAAM,8BAA8B,CAAC;AACxG,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjE,MAAM,OAAO,mBAAmB;IAS9B,YAAY,MAAwD,EAAE,KAAmB;;QACvF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAA,MAAM,CAAC,MAAM,mCAAI,MAAM,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAI,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,MAAA,MAAM,CAAC,QAAQ,mCAAI,QAAQ,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,MAAA,MAAM,CAAC,eAAe,mCAAI,IAAI,CAAC;QAEnD,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,eAAe;QACb,M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CAAC,CAAC,CAAC;QAC9G,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjH,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM;SACf,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACnG,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC9B,CAAC;CACF","file":"continue-legend.js","sourcesContent":["import { cloneDeep, get, merge } from '@visactor/vutils';\nimport type { IColorTableLegendOption, ISizeTableLegendOption } from '../../../ts-types/component/legend';\nimport type { BaseTableAPI } from '../../../ts-types/base-table';\nimport { ColorContinuousLegend, SizeContinuousLegend, LegendEvent } from '@visactor/vrender-components';\nimport { getContinuousLegendAttributes } from './get-continue-legend-attributes';\nimport { TABLE_EVENT_TYPE } from '../../../core/TABLE_EVENT_TYPE';\nimport { getQuadProps } from '../../../scenegraph/utils/padding';\nimport type { IOrientType } from '../../../ts-types/component/util';\n\nexport class ContinueTableLegend {\n table: BaseTableAPI;\n option: IColorTableLegendOption | ISizeTableLegendOption;\n orient: IOrientType;\n visible: boolean;\n position: 'start' | 'middle' | 'end';\n selectedData: (string | number)[];\n legendComponent: ColorContinuousLegend | SizeContinuousLegend;\n\n constructor(option: IColorTableLegendOption | ISizeTableLegendOption, table: BaseTableAPI) {\n this.table = table;\n this.option = cloneDeep(option);\n this.orient = option.orient ?? 'left';\n this.visible = option.visible ?? true;\n this.position = option.position ?? 'middle';\n this.selectedData = option.defaultSelected ?? null;\n\n this.createComponent();\n this.initEvent();\n }\n\n createComponent() {\n const attrs = this.getLegendAttributes({\n width: this.table.tableNoFrameWidth,\n height: this.table.tableNoFrameHeight\n });\n\n let legend;\n if (this.option.type === 'color') {\n legend = new ColorContinuousLegend(\n merge({}, attrs, {\n slidable: true\n // defaultSelected: this.selectedData\n })\n );\n } else {\n legend = new SizeContinuousLegend(\n merge({}, attrs, {\n slidable: true\n // defaultSelected: this.selectedData\n })\n );\n }\n legend.name = 'legend';\n this.legendComponent = legend;\n this.table.scenegraph.stage.defaultLayer.appendChild(legend);\n\n this.adjustTableSize(attrs);\n }\n\n resize() {\n if (!this.legendComponent) {\n return;\n }\n\n this.legendComponent.setAttributes({\n width: this.table.tableNoFrameWidth,\n height: this.table.tableNoFrameHeight\n });\n\n this.adjustTableSize(this.legendComponent.attribute);\n }\n\n adjustTableSize(attrs: any) {\n // 调整位置\n let width = isFinite(this.legendComponent.AABBBounds.width()) ? this.legendComponent.AABBBounds.width() : 0;\n let height = isFinite(this.legendComponent.AABBBounds.height()) ? this.legendComponent.AABBBounds.height() : 0;\n if (width <= 0 || height <= 0) {\n return;\n }\n const rectWidth = this.table.tableNoFrameWidth;\n const rectHeight = this.table.tableNoFrameHeight;\n const padding = getQuadProps(attrs.padding ?? this.option.padding ?? 10);\n\n let x = 0;\n let y = 0;\n if (this.orient === 'left') {\n x = padding[3];\n y = 0;\n width += padding[1] + padding[3];\n } else if (this.orient === 'top') {\n x = 0;\n y = padding[0];\n height += padding[0] + padding[2];\n } else if (this.orient === 'right') {\n x = rectWidth - width - padding[1];\n y = 0;\n width += padding[1] + padding[3];\n } else if (this.orient === 'bottom') {\n x = 0;\n y = rectHeight - height - padding[2];\n height += padding[0] + padding[2];\n }\n\n const layout = this.orient === 'bottom' || this.orient === 'top' ? 'horizontal' : 'vertical';\n const position = this.position;\n // const { width: rectWidth, height: rectHeight } = fullSpace;\n let offsetX = 0;\n let offsetY = 0;\n if (layout === 'horizontal') {\n if (position === 'middle') {\n offsetX = (rectWidth - width) / 2;\n } else if (position === 'end') {\n offsetX = rectWidth - width - padding[1];\n } else {\n offsetX = padding[3];\n }\n } else {\n if (position === 'middle') {\n offsetY = (rectHeight - height) / 2;\n } else if (position === 'end') {\n offsetY = rectHeight - height - padding[2];\n } else {\n offsetY = padding[0];\n }\n }\n\n this.legendComponent.setAttributes({\n dx: offsetX,\n dy: offsetY,\n x,\n y\n });\n\n // update table size\n if (this.orient === 'left') {\n this.table.tableNoFrameWidth = this.table.tableNoFrameWidth - Math.ceil(width);\n this.table.tableX += Math.ceil(width);\n } else if (this.orient === 'top') {\n this.table.tableNoFrameHeight = this.table.tableNoFrameHeight - Math.ceil(height);\n this.table.tableY += Math.ceil(height);\n } else if (this.orient === 'right') {\n this.table.tableNoFrameWidth = this.table.tableNoFrameWidth - Math.ceil(width);\n } else if (this.orient === 'bottom') {\n this.table.tableNoFrameHeight = this.table.tableNoFrameHeight - Math.ceil(height);\n }\n }\n\n getLegendAttributes(rect: any) {\n const layout = this.orient === 'bottom' || this.orient === 'top' ? 'horizontal' : 'vertical';\n const align = layout === 'horizontal' ? 'bottom' : this.orient;\n\n const attrs = {\n ...getContinuousLegendAttributes(this.option, rect),\n layout,\n align,\n // zIndex: this.layoutZIndex,\n min: this.option.min,\n max: this.option.max,\n value: this.option.value,\n [this.option.type === 'color' ? 'colors' : 'sizeRange']:\n this.option.type === 'color'\n ? (this.option as IColorTableLegendOption).colors\n : (this.option as ISizeTableLegendOption).sizeRange\n };\n return attrs;\n }\n\n initEvent() {\n if (this.legendComponent) {\n this.legendComponent.addEventListener('change', (e: any) => {\n const selectedData = get(e, 'detail.value');\n this.table.fireListeners(TABLE_EVENT_TYPE.LEGEND_CHANGE, { model: this, value: selectedData, event: e });\n this.table.scenegraph.updateNextFrame();\n });\n }\n }\n\n getLegendBounds() {\n const width = isFinite(this.legendComponent.AABBBounds.width()) ? this.legendComponent.AABBBounds.width() : 0;\n const height = isFinite(this.legendComponent.AABBBounds.height()) ? this.legendComponent.AABBBounds.height() : 0;\n\n return {\n width: width,\n height: height\n };\n }\n release() {\n this.legendComponent && this.table.scenegraph.stage.defaultLayer.removeChild(this.legendComponent);\n this.legendComponent = null;\n }\n}\n"]}
|
package/es/core/BaseTable.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
|
|
|
57
57
|
callback: AnyFunction;
|
|
58
58
|
}[]>;
|
|
59
59
|
customCellStylePlugin: CustomCellStylePlugin;
|
|
60
|
+
columnWidthComputeMode?: 'normal' | 'only-header' | 'only-body';
|
|
60
61
|
constructor(container: HTMLElement, options?: BaseTableConstructorOptions);
|
|
61
62
|
throttleInvalidate: (this: any, ...args: any[]) => void;
|
|
62
63
|
getContainer(): HTMLElement;
|
|
@@ -128,6 +129,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
|
|
|
128
129
|
get rowHierarchyType(): 'grid' | 'tree';
|
|
129
130
|
getColsWidth(startCol: number, endCol: number): number;
|
|
130
131
|
getRowHeight(row: number): number;
|
|
132
|
+
getDefaultColumnWidth(col: number): number | "auto";
|
|
131
133
|
getDefaultRowHeight(row: number): number | "auto";
|
|
132
134
|
_setRowHeight(row: number, height: number, clearCache?: boolean): void;
|
|
133
135
|
getRowsHeight(startRow: number, endRow: number): number;
|
package/es/core/BaseTable.js
CHANGED
|
@@ -81,8 +81,8 @@ export class BaseTable extends EventTarget {
|
|
|
81
81
|
return TABLE_EVENT_TYPE;
|
|
82
82
|
}
|
|
83
83
|
constructor(container, options = {}) {
|
|
84
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
85
|
-
if (super(), this.showFrozenIcon = !0, this.version = "0.22.2-alpha.
|
|
84
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
85
|
+
if (super(), this.showFrozenIcon = !0, this.version = "0.22.2-alpha.2", this.id = `VTable${Date.now()}`,
|
|
86
86
|
this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200),
|
|
87
87
|
!container && "node" !== options.mode) throw new Error("vtable's container is undefined");
|
|
88
88
|
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, rowSeriesNumber: rowSeriesNumber, columnResizeMode: columnResizeMode, dragHeaderMode: dragHeaderMode, showFrozenIcon: showFrozenIcon, allowFrozenColCount: allowFrozenColCount, padding: padding, hover: hover, menu: menu, select: click, customRender: customRender, pixelRatio: pixelRatio = defaultPixelRatio, renderChartAsync: renderChartAsync, renderChartAsyncBatchCount: renderChartAsyncBatchCount, mode: mode, modeParams: modeParams, canvasWidth: canvasWidth, canvasHeight: canvasHeight, overscrollBehavior: overscrollBehavior, limitMinWidth: limitMinWidth} = options;
|
|
@@ -97,7 +97,8 @@ export class BaseTable extends EventTarget {
|
|
|
97
97
|
this.padding.bottom = padding, this.padding.right = padding) : (padding.top && (this.padding.top = padding.top),
|
|
98
98
|
padding.bottom && (this.padding.bottom = padding.bottom), padding.left && (this.padding.left = padding.left),
|
|
99
99
|
padding.right && (this.padding.right = padding.right))), this.tableNoFrameWidth = 0,
|
|
100
|
-
this.tableNoFrameHeight = 0, this.canvasWidth = canvasWidth, this.canvasHeight = canvasHeight
|
|
100
|
+
this.tableNoFrameHeight = 0, this.canvasWidth = canvasWidth, this.canvasHeight = canvasHeight,
|
|
101
|
+
this.columnWidthComputeMode = null !== (_a = options.columnWidthComputeMode) && void 0 !== _a ? _a : "normal";
|
|
101
102
|
const internalProps = this.internalProps = {};
|
|
102
103
|
void 0 !== showFrozenIcon && (this.showFrozenIcon = showFrozenIcon), "number" == typeof allowFrozenColCount && allowFrozenColCount <= 0 && (this.showFrozenIcon = !1),
|
|
103
104
|
"node" !== Env.mode && (internalProps.element = createRootElement(this.padding),
|
|
@@ -120,14 +121,14 @@ export class BaseTable extends EventTarget {
|
|
|
120
121
|
var _a;
|
|
121
122
|
return "node" === Env.mode ? canvasWidth / (null != pixelRatio ? pixelRatio : 1) : this._.canvas.width / (null !== (_a = this._.context.pixelRatio) && void 0 !== _a ? _a : window.devicePixelRatio);
|
|
122
123
|
}
|
|
123
|
-
}, internalProps.cellTextOverflows = {}, internalProps.focusedTable = !1, internalProps.theme = themes.of(null !== (
|
|
124
|
+
}, internalProps.cellTextOverflows = {}, internalProps.focusedTable = !1, internalProps.theme = themes.of(null !== (_b = options.theme) && void 0 !== _b ? _b : themes.DEFAULT),
|
|
124
125
|
internalProps.theme.isPivot = this.isPivotTable(), container ? (container.innerHTML = "",
|
|
125
126
|
container.appendChild(internalProps.element), this._updateSize()) : this._updateSize(),
|
|
126
|
-
this.options = options, internalProps.theme = themes.of(null !== (
|
|
127
|
+
this.options = options, internalProps.theme = themes.of(null !== (_c = options.theme) && void 0 !== _c ? _c : themes.DEFAULT),
|
|
127
128
|
internalProps.theme.isPivot = this.isPivotTable(), internalProps.bodyHelper = new BodyHelper(this),
|
|
128
129
|
internalProps.headerHelper = new HeaderHelper(this), internalProps.rowSeriesNumberHelper = new RowSeriesNumberHelper(this),
|
|
129
|
-
internalProps.autoWrapText = options.autoWrapText, internalProps.allowFrozenColCount = null !== (
|
|
130
|
-
internalProps.limitMaxAutoWidth = null !== (
|
|
130
|
+
internalProps.autoWrapText = options.autoWrapText, internalProps.allowFrozenColCount = null !== (_d = options.allowFrozenColCount) && void 0 !== _d ? _d : 0,
|
|
131
|
+
internalProps.limitMaxAutoWidth = null !== (_e = options.limitMaxAutoWidth) && void 0 !== _e ? _e : 450,
|
|
131
132
|
internalProps.limitMinWidth = null != limitMinWidth ? "number" == typeof limitMinWidth ? limitMinWidth : limitMinWidth ? 10 : 0 : 10,
|
|
132
133
|
this._vDataSet = new DataSet, this.scenegraph = new Scenegraph(this), this.stateManager = new StateManager(this),
|
|
133
134
|
this.eventManager = new EventManager(this), options.legends && (internalProps.legends = createLegend(options.legends, this),
|
|
@@ -141,13 +142,13 @@ export class BaseTable extends EventTarget {
|
|
|
141
142
|
}, options.tooltip), "html" === internalProps.tooltip.renderMode && (internalProps.tooltipHandler = new TooltipHandler(this, internalProps.tooltip.confine)),
|
|
142
143
|
internalProps.menu = Object.assign({
|
|
143
144
|
renderMode: "html"
|
|
144
|
-
}, options.menu), Array.isArray(null === (
|
|
145
|
-
Array.isArray(null === (
|
|
145
|
+
}, options.menu), Array.isArray(null === (_f = options.menu) || void 0 === _f ? void 0 : _f.dropDownMenuHighlight) && this.setDropDownMenuHighlight(null === (_g = options.menu) || void 0 === _g ? void 0 : _g.dropDownMenuHighlight),
|
|
146
|
+
Array.isArray(null === (_h = options.menu) || void 0 === _h ? void 0 : _h.defaultHeaderMenuItems) && (this.globalDropDownMenu = options.menu.defaultHeaderMenuItems),
|
|
146
147
|
"html" === internalProps.menu.renderMode && (internalProps.menuHandler = new MenuHandler(this)),
|
|
147
148
|
this.headerStyleCache = new Map, this.bodyStyleCache = new Map, this.bodyBottomStyleCache = new Map,
|
|
148
149
|
internalProps.stick = {
|
|
149
150
|
changedCells: new Map
|
|
150
|
-
}, internalProps.customMergeCell = options.customMergeCell, this.customCellStylePlugin = new CustomCellStylePlugin(this, null !== (
|
|
151
|
+
}, internalProps.customMergeCell = options.customMergeCell, this.customCellStylePlugin = new CustomCellStylePlugin(this, null !== (_j = options.customCellStyle) && void 0 !== _j ? _j : [], null !== (_k = options.customCellStyleArrangement) && void 0 !== _k ? _k : []);
|
|
151
152
|
}
|
|
152
153
|
getContainer() {
|
|
153
154
|
return this.container;
|
|
@@ -383,6 +384,10 @@ export class BaseTable extends EventTarget {
|
|
|
383
384
|
const defaultHeight = this.getDefaultRowHeight(row);
|
|
384
385
|
return isNumber(defaultHeight) ? defaultHeight : this.defaultRowHeight;
|
|
385
386
|
}
|
|
387
|
+
getDefaultColumnWidth(col) {
|
|
388
|
+
var _a, _b;
|
|
389
|
+
return this.isRowHeader(col, 0) || this.isCornerHeader(col, 0) ? Array.isArray(this.defaultHeaderColWidth) ? null !== (_a = this.defaultHeaderColWidth[col]) && void 0 !== _a ? _a : this.defaultColWidth : this.defaultHeaderColWidth : this.isRightFrozenColumn(col, this.columnHeaderLevelCount) && this.isPivotTable() ? Array.isArray(this.defaultHeaderColWidth) ? null !== (_b = this.defaultHeaderColWidth[this.rowHeaderLevelCount - this.rightFrozenColCount]) && void 0 !== _b ? _b : this.defaultColWidth : this.defaultHeaderColWidth : this.defaultColWidth;
|
|
390
|
+
}
|
|
386
391
|
getDefaultRowHeight(row) {
|
|
387
392
|
var _a, _b;
|
|
388
393
|
return this.isColumnHeader(0, row) || this.isCornerHeader(0, row) ? Array.isArray(this.defaultHeaderRowHeight) ? null !== (_a = this.defaultHeaderRowHeight[row]) && void 0 !== _a ? _a : this.internalProps.defaultRowHeight : this.defaultHeaderRowHeight : this.isBottomFrozenRow(this.rowHeaderLevelCount, row) ? Array.isArray(this.defaultHeaderRowHeight) ? null !== (_b = this.defaultHeaderRowHeight[this.columnHeaderLevelCount > 0 ? this.columnHeaderLevelCount - this.bottomFrozenRowCount : 0]) && void 0 !== _b ? _b : this.internalProps.defaultRowHeight : this.defaultHeaderRowHeight : this.internalProps.defaultRowHeight;
|
|
@@ -402,19 +407,19 @@ export class BaseTable extends EventTarget {
|
|
|
402
407
|
return Math.round(h);
|
|
403
408
|
}
|
|
404
409
|
getColWidthDefined(col) {
|
|
405
|
-
var _a
|
|
410
|
+
var _a;
|
|
406
411
|
const {layoutMap: layoutMap} = this.internalProps;
|
|
407
412
|
if ("autoWidth" === this.widthMode) return "auto";
|
|
408
413
|
const {width: width} = null !== (_a = null == layoutMap ? void 0 : layoutMap.getColumnWidthDefined(col)) && void 0 !== _a ? _a : {};
|
|
409
|
-
return "number" == typeof width && width <= 0 ? 0 : width ||
|
|
414
|
+
return "number" == typeof width && width <= 0 ? 0 : width || this.getDefaultColumnWidth(col);
|
|
410
415
|
}
|
|
411
416
|
getColWidthDefinedNumber(col) {
|
|
412
417
|
const width = this.getColWidthDefined(col);
|
|
413
418
|
return this._adjustColWidth(col, this._colWidthDefineToPxWidth(width));
|
|
414
419
|
}
|
|
415
420
|
getColWidth(col) {
|
|
416
|
-
var _a
|
|
417
|
-
const width = null !== (_a = this.colWidthsMap.get(col)) && void 0 !== _a ? _a :
|
|
421
|
+
var _a;
|
|
422
|
+
const width = null !== (_a = this.colWidthsMap.get(col)) && void 0 !== _a ? _a : this.getDefaultColumnWidth(col);
|
|
418
423
|
return "adaptive" === this.widthMode && "number" == typeof width || this.transpose && "number" == typeof width ? this._colWidthDefineToPxWidth(width) : this._adjustColWidth(col, this._colWidthDefineToPxWidth(width));
|
|
419
424
|
}
|
|
420
425
|
_setColWidth(col, width, clearCache, skipCheckFrozen) {
|