@visactor/vtable 0.10.3-alpha.3 → 0.11.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.
- package/cjs/ListTable.js +1 -1
- package/cjs/ListTable.js.map +1 -1
- package/cjs/PivotChart.js +1 -3
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/core/BaseTable.d.ts +10 -4
- package/cjs/core/BaseTable.js +53 -14
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/event/event.js +1 -0
- package/cjs/event/event.js.map +1 -1
- package/cjs/event/listener/table-group.js +6 -8
- package/cjs/event/listener/table-group.js.map +1 -1
- package/cjs/event/media-click.js +5 -5
- package/cjs/event/media-click.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.d.ts +1 -0
- package/cjs/layout/pivot-header-layout.js +3 -0
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/layout/pivot-layout.d.ts +1 -0
- package/cjs/layout/pivot-layout.js +1 -0
- package/cjs/layout/pivot-layout.js.map +1 -1
- package/cjs/layout/simple-header-layout.d.ts +1 -0
- package/cjs/layout/simple-header-layout.js +3 -0
- package/cjs/layout/simple-header-layout.js.map +1 -1
- package/cjs/scenegraph/graphic/chart.js +4 -6
- package/cjs/scenegraph/graphic/chart.js.map +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/proxy.js +6 -6
- package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
- package/cjs/scenegraph/layout/compute-col-width.js +1 -1
- package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
- package/cjs/scenegraph/layout/compute-row-height.js +13 -0
- package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
- package/cjs/scenegraph/scenegraph.js +12 -0
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/scenegraph/stick-text/index.js +7 -9
- package/cjs/scenegraph/stick-text/index.js.map +1 -1
- package/cjs/scenegraph/utils/text-icon-layout.js +1 -1
- package/cjs/scenegraph/utils/text-icon-layout.js.map +1 -1
- package/cjs/state/sort/index.js +2 -1
- package/cjs/state/sort/index.js.map +1 -1
- package/cjs/state/spark-line/index.d.ts +1 -1
- package/cjs/state/spark-line/index.js +2 -1
- package/cjs/state/spark-line/index.js.map +1 -1
- package/cjs/state/state.d.ts +1 -1
- package/cjs/state/state.js +8 -6
- package/cjs/state/state.js.map +1 -1
- package/cjs/ts-types/base-table.d.ts +6 -0
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/ts-types/list-table/define/Composite-define.d.ts +21 -0
- package/cjs/ts-types/list-table/define/Composite-define.js +6 -0
- package/cjs/ts-types/list-table/define/Composite-define.js.map +1 -0
- package/cjs/ts-types/list-table/define/index.d.ts +3 -1
- package/cjs/ts-types/list-table/define/index.js.map +1 -1
- package/cjs/ts-types/pivot-table/indicator/composite-indicator.d.ts +21 -0
- package/cjs/ts-types/pivot-table/indicator/composite-indicator.js +6 -0
- package/cjs/ts-types/pivot-table/indicator/composite-indicator.js.map +1 -0
- package/cjs/ts-types/pivot-table/indicator/index.d.ts +2 -1
- package/cjs/ts-types/pivot-table/indicator/index.js.map +1 -1
- package/dist/vtable.js +706 -397
- package/dist/vtable.min.js +3 -3
- package/es/ListTable.js +1 -1
- package/es/ListTable.js.map +1 -1
- package/es/PivotChart.js +1 -3
- package/es/PivotChart.js.map +1 -1
- package/es/core/BaseTable.d.ts +10 -4
- package/es/core/BaseTable.js +53 -12
- package/es/core/BaseTable.js.map +1 -1
- package/es/event/event.js +1 -0
- package/es/event/event.js.map +1 -1
- package/es/event/listener/table-group.js +6 -8
- package/es/event/listener/table-group.js.map +1 -1
- package/es/event/media-click.js +5 -5
- package/es/event/media-click.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.d.ts +1 -0
- package/es/layout/pivot-header-layout.js +3 -0
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/layout/pivot-layout.d.ts +1 -0
- package/es/layout/pivot-layout.js +1 -0
- package/es/layout/pivot-layout.js.map +1 -1
- package/es/layout/simple-header-layout.d.ts +1 -0
- package/es/layout/simple-header-layout.js +3 -0
- package/es/layout/simple-header-layout.js.map +1 -1
- package/es/scenegraph/graphic/chart.js +4 -6
- package/es/scenegraph/graphic/chart.js.map +1 -1
- package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/es/scenegraph/group-creater/progress/proxy.js +3 -3
- package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
- package/es/scenegraph/layout/compute-col-width.js +1 -1
- package/es/scenegraph/layout/compute-col-width.js.map +1 -1
- package/es/scenegraph/layout/compute-row-height.js +13 -0
- package/es/scenegraph/layout/compute-row-height.js.map +1 -1
- package/es/scenegraph/scenegraph.js +12 -0
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/scenegraph/stick-text/index.js +7 -9
- package/es/scenegraph/stick-text/index.js.map +1 -1
- package/es/scenegraph/utils/text-icon-layout.js +2 -2
- package/es/scenegraph/utils/text-icon-layout.js.map +1 -1
- package/es/state/sort/index.js +2 -1
- package/es/state/sort/index.js.map +1 -1
- package/es/state/spark-line/index.d.ts +1 -1
- package/es/state/spark-line/index.js +2 -1
- package/es/state/spark-line/index.js.map +1 -1
- package/es/state/state.d.ts +1 -1
- package/es/state/state.js +8 -6
- package/es/state/state.js.map +1 -1
- package/es/ts-types/base-table.d.ts +6 -0
- package/es/ts-types/base-table.js.map +1 -1
- package/es/ts-types/list-table/define/Composite-define.d.ts +21 -0
- package/es/ts-types/list-table/define/Composite-define.js +2 -0
- package/es/ts-types/list-table/define/Composite-define.js.map +1 -0
- package/es/ts-types/list-table/define/index.d.ts +3 -1
- package/es/ts-types/list-table/define/index.js.map +1 -1
- package/es/ts-types/pivot-table/indicator/composite-indicator.d.ts +21 -0
- package/es/ts-types/pivot-table/indicator/composite-indicator.js +2 -0
- package/es/ts-types/pivot-table/indicator/composite-indicator.js.map +1 -0
- package/es/ts-types/pivot-table/indicator/index.d.ts +2 -1
- package/es/ts-types/pivot-table/indicator/index.js.map +1 -1
- package/package.json +6 -6
- package/cjs/scenegraph/layout/update-cell.d.ts +0 -3
- package/cjs/scenegraph/layout/update-cell.js +0 -56
- package/cjs/scenegraph/layout/update-cell.js.map +0 -1
- package/cjs/tools/text-width.d.ts +0 -1
- package/cjs/tools/text-width.js +0 -17
- package/cjs/tools/text-width.js.map +0 -1
- package/es/scenegraph/layout/update-cell.d.ts +0 -3
- package/es/scenegraph/layout/update-cell.js +0 -57
- package/es/scenegraph/layout/update-cell.js.map +0 -1
- package/es/tools/text-width.d.ts +0 -1
- package/es/tools/text-width.js +0 -9
- package/es/tools/text-width.js.map +0 -1
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.updateCellLayout = void 0;
|
|
6
|
-
|
|
7
|
-
const tableHelper_1 = require("../../core/tableHelper"), custom_1 = require("../component/custom"), progress_bar_cell_1 = require("../group-creater/cell-type/progress-bar-cell"), spark_line_cell_1 = require("../group-creater/cell-type/spark-line-cell"), get_cell_merge_1 = require("../utils/get-cell-merge"), get_prop_1 = require("../utils/get-prop"), padding_1 = require("../utils/padding"), text_icon_layout_1 = require("../utils/text-icon-layout");
|
|
8
|
-
|
|
9
|
-
function updateCellLayout(scene, cell, col, row, width, height, detaX, detaY, isHeader, autoColWidth, autoRowHeight) {
|
|
10
|
-
let cellGroup, distWidth;
|
|
11
|
-
const mergeInfo = (0, get_cell_merge_1.getCellMergeInfo)(scene.table, col, row);
|
|
12
|
-
if (mergeInfo && mergeInfo.end.col - mergeInfo.start.col) {
|
|
13
|
-
const mergeCell = scene.getCell(mergeInfo.start.col, mergeInfo.start.row), mergeCellWidth = mergeCell.attribute.width;
|
|
14
|
-
mergeCell.setAttribute("width", mergeCellWidth + detaX), cellGroup = mergeCell,
|
|
15
|
-
distWidth = mergeCell.attribute.width;
|
|
16
|
-
} else mergeInfo && mergeInfo.start.row === row ? (cell.setAttribute("width", width + detaX),
|
|
17
|
-
cellGroup = cell, distWidth = width + detaX) : mergeInfo || (cell.setAttribute("width", width + detaX),
|
|
18
|
-
cellGroup = cell, distWidth = width + detaX);
|
|
19
|
-
if (!cellGroup) return;
|
|
20
|
-
const type = scene.table.isHeader(col, row) ? scene.table._getHeaderLayoutMap(col, row).headerType : scene.table.getBodyColumnType(col, row);
|
|
21
|
-
if ("progressbar" === type) {
|
|
22
|
-
const columnDefine = scene.table.getBodyColumnDefine(col, row), style = scene.table._getCellStyle(col, row), value = scene.table.getCellValue(col, row), dataValue = scene.table.getCellOriginValue(col, row), padding = (0,
|
|
23
|
-
padding_1.getQuadProps)((0, get_prop_1.getProp)("padding", style, col, row, scene.table)), newBarCell = (0,
|
|
24
|
-
progress_bar_cell_1.createProgressBarCell)(columnDefine, style, cell.attribute.width, value, dataValue, col, row, padding, scene.table), oldBarCell = cell.getChildByName("progress-bar");
|
|
25
|
-
cell.insertBefore(newBarCell, oldBarCell), cell.removeChild(oldBarCell), oldBarCell.removeAllChild(),
|
|
26
|
-
oldBarCell.release();
|
|
27
|
-
} else if ("sparkline" === type) {
|
|
28
|
-
cell.removeAllChild();
|
|
29
|
-
const headerStyle = scene.table._getCellStyle(col, row), padding = (0, padding_1.getQuadProps)((0,
|
|
30
|
-
get_prop_1.getProp)("padding", headerStyle, col, row, scene.table));
|
|
31
|
-
(0, spark_line_cell_1.createSparkLineCellGroup)(cell, cell.parent, cell.attribute.x, cell.attribute.y, col, row, cell.attribute.width, cell.attribute.height, padding, scene.table, (0,
|
|
32
|
-
tableHelper_1.getStyleTheme)(headerStyle, scene.table, col, row, get_prop_1.getProp).theme);
|
|
33
|
-
} else if ("image" === type || "video" === type) ; else {
|
|
34
|
-
const style = scene.table._getCellStyle(col, row);
|
|
35
|
-
(0, text_icon_layout_1.updateCellContentWidth)(cell, distWidth, detaX, autoRowHeight, (0,
|
|
36
|
-
padding_1.getQuadProps)(style.padding), style.textAlign, style.textBaseline, scene);
|
|
37
|
-
const customContainer = cellGroup.getChildByName("custom-container");
|
|
38
|
-
if (customContainer) {
|
|
39
|
-
let customRender, customLayout;
|
|
40
|
-
customContainer.clear(), cellGroup.removeChild(customContainer);
|
|
41
|
-
if ("body" !== scene.table.getCellLocation(cellGroup.col, cellGroup.row)) {
|
|
42
|
-
const define = scene.table.getHeaderDefine(cellGroup.col, cellGroup.row);
|
|
43
|
-
customRender = null == define ? void 0 : define.headerCustomRender, customLayout = null == define ? void 0 : define.headerCustomLayout;
|
|
44
|
-
} else {
|
|
45
|
-
const define = scene.table.getBodyColumnDefine(cellGroup.col, cellGroup.row);
|
|
46
|
-
customRender = (null == define ? void 0 : define.customRender) || scene.table.customRender,
|
|
47
|
-
customLayout = null == define ? void 0 : define.customLayout;
|
|
48
|
-
}
|
|
49
|
-
const customResult = (0, custom_1.dealWithCustom)(customLayout, customRender, cellGroup.col, cellGroup.row, cellGroup.attribute.width, cellGroup.attribute.height, !1, !1, scene.table);
|
|
50
|
-
cellGroup.appendChild(customResult.elementsGroup);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
exports.updateCellLayout = updateCellLayout;
|
|
56
|
-
//# sourceMappingURL=update-cell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["scenegraph/layout/update-cell.ts"],"names":[],"mappings":";;;AACA,wDAAuD;AAEvD,gDAAqD;AAErD,oFAAqF;AACrF,gFAAsF;AAEtF,4DAA2D;AAC3D,gDAA4C;AAC5C,8CAAgD;AAChD,gEAAmE;AAMnE,SAAgB,gBAAgB,CAC9B,KAAiB,EACjB,IAAW,EACX,GAAW,EACX,GAAW,EACX,KAAa,EACb,MAAc,EACd,KAAa,EACb,KA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C,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;YAC/E,IAAI,YAAY,KAAK,MAAM,EAAE;gBAC3B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;gBACzE,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,kBAAkB,CAAC;gBAC1C,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,kBAAkB,CAAC;aAC3C;iBAAM;gBACL,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;gBAC7E,YAAY,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,KAAI,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC;gBAChE,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC;aACrC;YACD,MAAM,YAAY,GAAG,IAAA,uBAAc,EACjC,YAAY,EACZ,YAAY,EACZ,SAAS,CAAC,GAAG,EACb,SAAS,CAAC,GAAG,EACb,SAAS,CAAC,SAAS,CAAC,KAAK,EACzB,SAAS,CAAC,SAAS,CAAC,MAAM,EAC1B,KAAK,EACL,KAAK,EACL,KAAK,CAAC,KAAK,CACZ,CAAC;YACF,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;SACnD;KACF;AACH,CAAC;AA/ID,4CA+IC","file":"update-cell.js","sourcesContent":["import type { ProgressBarStyle } from '../../body-helper/style/ProgressBarStyle';\nimport { getStyleTheme } from '../../core/tableHelper';\nimport type { IProgressbarColumnBodyDefine } from '../../ts-types/list-table/define/progressbar-define';\nimport { dealWithCustom } from '../component/custom';\nimport type { Group } from '../graphic/group';\nimport { createProgressBarCell } from '../group-creater/cell-type/progress-bar-cell';\nimport { createSparkLineCellGroup } from '../group-creater/cell-type/spark-line-cell';\nimport type { Scenegraph } from '../scenegraph';\nimport { getCellMergeInfo } from '../utils/get-cell-merge';\nimport { getProp } from '../utils/get-prop';\nimport { getQuadProps } from '../utils/padding';\nimport { updateCellContentWidth } from '../utils/text-icon-layout';\n\n/**\n * @description: 更新单个单元格宽度/高度\n * @return {*}\n */\nexport function updateCellLayout(\n scene: Scenegraph,\n cell: Group,\n col: number,\n row: number,\n width: number,\n height: number,\n detaX: number,\n detaY: number,\n isHeader: boolean,\n autoColWidth: boolean,\n autoRowHeight: boolean\n) {\n let cellGroup;\n let distWidth;\n const mergeInfo = getCellMergeInfo(scene.table, col, row);\n // TO BE FIXED 这里使用横向和纵向来判断单元格merge情况,目前没有横纵都merge的情况,\n // 如果有这里的逻辑要修改\n if (mergeInfo && mergeInfo.end.col - mergeInfo.start.col) {\n // 更新横向merge cell width\n const mergeCell = scene.getCell(mergeInfo.start.col, mergeInfo.start.row);\n const mergeCellWidth = mergeCell.attribute.width;\n mergeCell.setAttribute('width', mergeCellWidth + detaX);\n\n cellGroup = mergeCell;\n distWidth = mergeCell.attribute.width;\n } else if (mergeInfo && mergeInfo.start.row === row) {\n // 更新纵向merge cell width,只更新一次\n cell.setAttribute('width', width + detaX);\n\n cellGroup = cell;\n distWidth = width + detaX;\n } else if (!mergeInfo) {\n cell.setAttribute('width', width + detaX);\n cellGroup = cell;\n distWidth = width + detaX;\n }\n\n if (!cellGroup) {\n // 合并单元格非主单元格,不处理\n return;\n }\n\n // 更新单元格布局\n\n const type = scene.table.isHeader(col, row)\n ? scene.table._getHeaderLayoutMap(col, row).headerType\n : scene.table.getBodyColumnType(col, row);\n if (type === 'progressbar') {\n // 目前先采用重新生成节点的方案\n const columnDefine = scene.table.getBodyColumnDefine(col, row) as IProgressbarColumnBodyDefine;\n const style = scene.table._getCellStyle(col, row) as ProgressBarStyle;\n const value = scene.table.getCellValue(col, row);\n const dataValue = scene.table.getCellOriginValue(col, row);\n const padding = getQuadProps(getProp('padding', style, col, row, scene.table));\n\n const newBarCell = createProgressBarCell(\n columnDefine,\n style,\n cell.attribute.width,\n // cell.attribute.height,\n value,\n dataValue,\n col,\n row,\n padding,\n scene.table\n );\n\n const oldBarCell = cell.getChildByName('progress-bar') as Group;\n // cell.replaceChild(newBarCell, oldBarCell);\n cell.insertBefore(newBarCell, oldBarCell);\n cell.removeChild(oldBarCell);\n oldBarCell.removeAllChild();\n oldBarCell.release();\n } else if (type === 'sparkline') {\n // 目前先采用重新生成节点的方案\n cell.removeAllChild();\n const headerStyle = scene.table._getCellStyle(col, row);\n const padding = getQuadProps(getProp('padding', headerStyle, col, row, scene.table));\n createSparkLineCellGroup(\n cell,\n cell.parent,\n cell.attribute.x,\n cell.attribute.y,\n col,\n row,\n cell.attribute.width,\n cell.attribute.height,\n padding,\n scene.table,\n getStyleTheme(headerStyle, scene.table, col, row, getProp).theme\n );\n } else if (type === 'image' || type === 'video') {\n // // 只更新背景边框\n // const rect = cell.firstChild as Rect;\n // rect.setAttribute('width', cell.attribute.width);\n } else {\n // 处理文字\n const style = scene.table._getCellStyle(col, row);\n updateCellContentWidth(\n cell,\n distWidth,\n detaX,\n autoRowHeight,\n getQuadProps(style.padding as number),\n style.textAlign,\n style.textBaseline,\n scene\n );\n\n // 处理自定义渲染\n const customContainer = cellGroup.getChildByName('custom-container') as Group;\n if (customContainer) {\n customContainer.clear();\n cellGroup.removeChild(customContainer);\n\n let customRender;\n let customLayout;\n const cellLocation = scene.table.getCellLocation(cellGroup.col, cellGroup.row);\n if (cellLocation !== 'body') {\n const define = scene.table.getHeaderDefine(cellGroup.col, cellGroup.row);\n customRender = define?.headerCustomRender;\n customLayout = define?.headerCustomLayout;\n } else {\n const define = scene.table.getBodyColumnDefine(cellGroup.col, cellGroup.row);\n customRender = define?.customRender || scene.table.customRender;\n customLayout = define?.customLayout;\n }\n const customResult = dealWithCustom(\n customLayout,\n customRender,\n cellGroup.col,\n cellGroup.row,\n cellGroup.attribute.width,\n cellGroup.attribute.height,\n false,\n false,\n scene.table\n );\n cellGroup.appendChild(customResult.elementsGroup);\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getWidth(ctx: CanvasRenderingContext2D, content: string): number;
|
package/cjs/tools/text-width.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.getWidth = void 0;
|
|
6
|
-
|
|
7
|
-
const cachedWidths = new Map;
|
|
8
|
-
|
|
9
|
-
function getWidth(ctx, content) {
|
|
10
|
-
const cachedWidth = cachedWidths.get(`$${content}$${ctx.font}`);
|
|
11
|
-
if (null != cachedWidth) return cachedWidth;
|
|
12
|
-
const width = ctx.measureText(content).width;
|
|
13
|
-
return cachedWidths.set(`$${content}$${ctx.font}`, width), width;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
exports.getWidth = getWidth;
|
|
17
|
-
//# sourceMappingURL=text-width.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["tools/text-width.ts"],"names":[],"mappings":";;;AAAA,MAAM,YAAY,GAAwB,IAAI,GAAG,EAAE,CAAC;AACpD,SAAgB,QAAQ,CAAC,GAA6B,EAAE,OAAe;IAErE,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,EAAE;QACrD,OAAO,WAAW,CAAC;KACpB;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;IAC7C,YAAY,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC;AATD,4BASC","file":"text-width.js","sourcesContent":["const cachedWidths: Map<string, number> = new Map();\nexport function getWidth(ctx: CanvasRenderingContext2D, content: string): number {\n //缓存文本宽度到列表\n const cachedWidth = cachedWidths.get(`$${content}$${ctx.font}`);\n if (cachedWidth !== undefined && cachedWidth !== null) {\n return cachedWidth;\n }\n const width = ctx.measureText(content).width;\n cachedWidths.set(`$${content}$${ctx.font}`, width);\n return width;\n}\n"]}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { Group } from '../graphic/group';
|
|
2
|
-
import type { Scenegraph } from '../scenegraph';
|
|
3
|
-
export declare function updateCellLayout(scene: Scenegraph, cell: Group, col: number, row: number, width: number, height: number, detaX: number, detaY: number, isHeader: boolean, autoColWidth: boolean, autoRowHeight: boolean): void;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { getStyleTheme } from "../../core/tableHelper";
|
|
2
|
-
|
|
3
|
-
import { dealWithCustom } from "../component/custom";
|
|
4
|
-
|
|
5
|
-
import { createProgressBarCell } from "../group-creater/cell-type/progress-bar-cell";
|
|
6
|
-
|
|
7
|
-
import { createSparkLineCellGroup } from "../group-creater/cell-type/spark-line-cell";
|
|
8
|
-
|
|
9
|
-
import { getCellMergeInfo } from "../utils/get-cell-merge";
|
|
10
|
-
|
|
11
|
-
import { getProp } from "../utils/get-prop";
|
|
12
|
-
|
|
13
|
-
import { getQuadProps } from "../utils/padding";
|
|
14
|
-
|
|
15
|
-
import { updateCellContentWidth } from "../utils/text-icon-layout";
|
|
16
|
-
|
|
17
|
-
export function updateCellLayout(scene, cell, col, row, width, height, detaX, detaY, isHeader, autoColWidth, autoRowHeight) {
|
|
18
|
-
let cellGroup, distWidth;
|
|
19
|
-
const mergeInfo = getCellMergeInfo(scene.table, col, row);
|
|
20
|
-
if (mergeInfo && mergeInfo.end.col - mergeInfo.start.col) {
|
|
21
|
-
const mergeCell = scene.getCell(mergeInfo.start.col, mergeInfo.start.row), mergeCellWidth = mergeCell.attribute.width;
|
|
22
|
-
mergeCell.setAttribute("width", mergeCellWidth + detaX), cellGroup = mergeCell,
|
|
23
|
-
distWidth = mergeCell.attribute.width;
|
|
24
|
-
} else mergeInfo && mergeInfo.start.row === row ? (cell.setAttribute("width", width + detaX),
|
|
25
|
-
cellGroup = cell, distWidth = width + detaX) : mergeInfo || (cell.setAttribute("width", width + detaX),
|
|
26
|
-
cellGroup = cell, distWidth = width + detaX);
|
|
27
|
-
if (!cellGroup) return;
|
|
28
|
-
const type = scene.table.isHeader(col, row) ? scene.table._getHeaderLayoutMap(col, row).headerType : scene.table.getBodyColumnType(col, row);
|
|
29
|
-
if ("progressbar" === type) {
|
|
30
|
-
const columnDefine = scene.table.getBodyColumnDefine(col, row), style = scene.table._getCellStyle(col, row), value = scene.table.getCellValue(col, row), dataValue = scene.table.getCellOriginValue(col, row), padding = getQuadProps(getProp("padding", style, col, row, scene.table)), newBarCell = createProgressBarCell(columnDefine, style, cell.attribute.width, value, dataValue, col, row, padding, scene.table), oldBarCell = cell.getChildByName("progress-bar");
|
|
31
|
-
cell.insertBefore(newBarCell, oldBarCell), cell.removeChild(oldBarCell), oldBarCell.removeAllChild(),
|
|
32
|
-
oldBarCell.release();
|
|
33
|
-
} else if ("sparkline" === type) {
|
|
34
|
-
cell.removeAllChild();
|
|
35
|
-
const headerStyle = scene.table._getCellStyle(col, row), padding = getQuadProps(getProp("padding", headerStyle, col, row, scene.table));
|
|
36
|
-
createSparkLineCellGroup(cell, cell.parent, cell.attribute.x, cell.attribute.y, col, row, cell.attribute.width, cell.attribute.height, padding, scene.table, getStyleTheme(headerStyle, scene.table, col, row, getProp).theme);
|
|
37
|
-
} else if ("image" === type || "video" === type) ; else {
|
|
38
|
-
const style = scene.table._getCellStyle(col, row);
|
|
39
|
-
updateCellContentWidth(cell, distWidth, detaX, autoRowHeight, getQuadProps(style.padding), style.textAlign, style.textBaseline, scene);
|
|
40
|
-
const customContainer = cellGroup.getChildByName("custom-container");
|
|
41
|
-
if (customContainer) {
|
|
42
|
-
let customRender, customLayout;
|
|
43
|
-
customContainer.clear(), cellGroup.removeChild(customContainer);
|
|
44
|
-
if ("body" !== scene.table.getCellLocation(cellGroup.col, cellGroup.row)) {
|
|
45
|
-
const define = scene.table.getHeaderDefine(cellGroup.col, cellGroup.row);
|
|
46
|
-
customRender = null == define ? void 0 : define.headerCustomRender, customLayout = null == define ? void 0 : define.headerCustomLayout;
|
|
47
|
-
} else {
|
|
48
|
-
const define = scene.table.getBodyColumnDefine(cellGroup.col, cellGroup.row);
|
|
49
|
-
customRender = (null == define ? void 0 : define.customRender) || scene.table.customRender,
|
|
50
|
-
customLayout = null == define ? void 0 : define.customLayout;
|
|
51
|
-
}
|
|
52
|
-
const customResult = dealWithCustom(customLayout, customRender, cellGroup.col, cellGroup.row, cellGroup.attribute.width, cellGroup.attribute.height, !1, !1, scene.table);
|
|
53
|
-
cellGroup.appendChild(customResult.elementsGroup);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=update-cell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["scenegraph/layout/update-cell.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAEtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAMnE,MAAM,UAAU,gBAAgB,CAC9B,KAAiB,EACjB,IAAW,EACX,GAAW,EAC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CAAC,GAAG,CAAC,CAAC;YAC/E,IAAI,YAAY,KAAK,MAAM,EAAE;gBAC3B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;gBACzE,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,kBAAkB,CAAC;gBAC1C,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,kBAAkB,CAAC;aAC3C;iBAAM;gBACL,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;gBAC7E,YAAY,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,KAAI,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC;gBAChE,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC;aACrC;YACD,MAAM,YAAY,GAAG,cAAc,CACjC,YAAY,EACZ,YAAY,EACZ,SAAS,CAAC,GAAG,EACb,SAAS,CAAC,GAAG,EACb,SAAS,CAAC,SAAS,CAAC,KAAK,EACzB,SAAS,CAAC,SAAS,CAAC,MAAM,EAC1B,KAAK,EACL,KAAK,EACL,KAAK,CAAC,KAAK,CACZ,CAAC;YACF,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;SACnD;KACF;AACH,CAAC","file":"update-cell.js","sourcesContent":["import type { ProgressBarStyle } from '../../body-helper/style/ProgressBarStyle';\nimport { getStyleTheme } from '../../core/tableHelper';\nimport type { IProgressbarColumnBodyDefine } from '../../ts-types/list-table/define/progressbar-define';\nimport { dealWithCustom } from '../component/custom';\nimport type { Group } from '../graphic/group';\nimport { createProgressBarCell } from '../group-creater/cell-type/progress-bar-cell';\nimport { createSparkLineCellGroup } from '../group-creater/cell-type/spark-line-cell';\nimport type { Scenegraph } from '../scenegraph';\nimport { getCellMergeInfo } from '../utils/get-cell-merge';\nimport { getProp } from '../utils/get-prop';\nimport { getQuadProps } from '../utils/padding';\nimport { updateCellContentWidth } from '../utils/text-icon-layout';\n\n/**\n * @description: 更新单个单元格宽度/高度\n * @return {*}\n */\nexport function updateCellLayout(\n scene: Scenegraph,\n cell: Group,\n col: number,\n row: number,\n width: number,\n height: number,\n detaX: number,\n detaY: number,\n isHeader: boolean,\n autoColWidth: boolean,\n autoRowHeight: boolean\n) {\n let cellGroup;\n let distWidth;\n const mergeInfo = getCellMergeInfo(scene.table, col, row);\n // TO BE FIXED 这里使用横向和纵向来判断单元格merge情况,目前没有横纵都merge的情况,\n // 如果有这里的逻辑要修改\n if (mergeInfo && mergeInfo.end.col - mergeInfo.start.col) {\n // 更新横向merge cell width\n const mergeCell = scene.getCell(mergeInfo.start.col, mergeInfo.start.row);\n const mergeCellWidth = mergeCell.attribute.width;\n mergeCell.setAttribute('width', mergeCellWidth + detaX);\n\n cellGroup = mergeCell;\n distWidth = mergeCell.attribute.width;\n } else if (mergeInfo && mergeInfo.start.row === row) {\n // 更新纵向merge cell width,只更新一次\n cell.setAttribute('width', width + detaX);\n\n cellGroup = cell;\n distWidth = width + detaX;\n } else if (!mergeInfo) {\n cell.setAttribute('width', width + detaX);\n cellGroup = cell;\n distWidth = width + detaX;\n }\n\n if (!cellGroup) {\n // 合并单元格非主单元格,不处理\n return;\n }\n\n // 更新单元格布局\n\n const type = scene.table.isHeader(col, row)\n ? scene.table._getHeaderLayoutMap(col, row).headerType\n : scene.table.getBodyColumnType(col, row);\n if (type === 'progressbar') {\n // 目前先采用重新生成节点的方案\n const columnDefine = scene.table.getBodyColumnDefine(col, row) as IProgressbarColumnBodyDefine;\n const style = scene.table._getCellStyle(col, row) as ProgressBarStyle;\n const value = scene.table.getCellValue(col, row);\n const dataValue = scene.table.getCellOriginValue(col, row);\n const padding = getQuadProps(getProp('padding', style, col, row, scene.table));\n\n const newBarCell = createProgressBarCell(\n columnDefine,\n style,\n cell.attribute.width,\n // cell.attribute.height,\n value,\n dataValue,\n col,\n row,\n padding,\n scene.table\n );\n\n const oldBarCell = cell.getChildByName('progress-bar') as Group;\n // cell.replaceChild(newBarCell, oldBarCell);\n cell.insertBefore(newBarCell, oldBarCell);\n cell.removeChild(oldBarCell);\n oldBarCell.removeAllChild();\n oldBarCell.release();\n } else if (type === 'sparkline') {\n // 目前先采用重新生成节点的方案\n cell.removeAllChild();\n const headerStyle = scene.table._getCellStyle(col, row);\n const padding = getQuadProps(getProp('padding', headerStyle, col, row, scene.table));\n createSparkLineCellGroup(\n cell,\n cell.parent,\n cell.attribute.x,\n cell.attribute.y,\n col,\n row,\n cell.attribute.width,\n cell.attribute.height,\n padding,\n scene.table,\n getStyleTheme(headerStyle, scene.table, col, row, getProp).theme\n );\n } else if (type === 'image' || type === 'video') {\n // // 只更新背景边框\n // const rect = cell.firstChild as Rect;\n // rect.setAttribute('width', cell.attribute.width);\n } else {\n // 处理文字\n const style = scene.table._getCellStyle(col, row);\n updateCellContentWidth(\n cell,\n distWidth,\n detaX,\n autoRowHeight,\n getQuadProps(style.padding as number),\n style.textAlign,\n style.textBaseline,\n scene\n );\n\n // 处理自定义渲染\n const customContainer = cellGroup.getChildByName('custom-container') as Group;\n if (customContainer) {\n customContainer.clear();\n cellGroup.removeChild(customContainer);\n\n let customRender;\n let customLayout;\n const cellLocation = scene.table.getCellLocation(cellGroup.col, cellGroup.row);\n if (cellLocation !== 'body') {\n const define = scene.table.getHeaderDefine(cellGroup.col, cellGroup.row);\n customRender = define?.headerCustomRender;\n customLayout = define?.headerCustomLayout;\n } else {\n const define = scene.table.getBodyColumnDefine(cellGroup.col, cellGroup.row);\n customRender = define?.customRender || scene.table.customRender;\n customLayout = define?.customLayout;\n }\n const customResult = dealWithCustom(\n customLayout,\n customRender,\n cellGroup.col,\n cellGroup.row,\n cellGroup.attribute.width,\n cellGroup.attribute.height,\n false,\n false,\n scene.table\n );\n cellGroup.appendChild(customResult.elementsGroup);\n }\n }\n}\n"]}
|
package/es/tools/text-width.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getWidth(ctx: CanvasRenderingContext2D, content: string): number;
|
package/es/tools/text-width.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const cachedWidths = new Map;
|
|
2
|
-
|
|
3
|
-
export function getWidth(ctx, content) {
|
|
4
|
-
const cachedWidth = cachedWidths.get(`$${content}$${ctx.font}`);
|
|
5
|
-
if (null != cachedWidth) return cachedWidth;
|
|
6
|
-
const width = ctx.measureText(content).width;
|
|
7
|
-
return cachedWidths.set(`$${content}$${ctx.font}`, width), width;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=text-width.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["tools/text-width.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAwB,IAAI,GAAG,EAAE,CAAC;AACpD,MAAM,UAAU,QAAQ,CAAC,GAA6B,EAAE,OAAe;IAErE,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,EAAE;QACrD,OAAO,WAAW,CAAC;KACpB;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;IAC7C,YAAY,CAAC,GAAG,CAAC,IAAI,OAAO,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC","file":"text-width.js","sourcesContent":["const cachedWidths: Map<string, number> = new Map();\nexport function getWidth(ctx: CanvasRenderingContext2D, content: string): number {\n //缓存文本宽度到列表\n const cachedWidth = cachedWidths.get(`$${content}$${ctx.font}`);\n if (cachedWidth !== undefined && cachedWidth !== null) {\n return cachedWidth;\n }\n const width = ctx.measureText(content).width;\n cachedWidths.set(`$${content}$${ctx.font}`, width);\n return width;\n}\n"]}
|