@veltra/sheet 2.4.0 → 2.5.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/dist/index.d.ts +2 -19
- package/dist/index.js +2 -15
- package/dist/types/index.d.ts +1 -3
- package/package.json +2 -3
- package/src/index.ts +1 -27
- package/src/types/index.ts +0 -2
- package/dist/components/report/binding-badge.js +0 -118
- package/dist/components/report/designer/cell-coords.js +0 -46
- package/dist/components/report/designer/col-widths.js +0 -29
- package/dist/components/report/designer/conditional-rules/helpers.js +0 -139
- package/dist/components/report/designer/drill-dialog.js +0 -258
- package/dist/components/report/designer/drop-highlight-overlay.js +0 -76
- package/dist/components/report/designer/float-panel.js +0 -434
- package/dist/components/report/designer/role.js +0 -17
- package/dist/components/report/designer/rule-preview.js +0 -33
- package/dist/components/report/designer/rule-row.js +0 -253
- package/dist/components/report/designer/rules-dialog.js +0 -118
- package/dist/components/report/designer/topology-overlay.js +0 -122
- package/dist/components/report/designer/topology.js +0 -64
- package/dist/components/report/designer/use-grid-overlay.js +0 -75
- package/dist/components/report/designer-hub.js +0 -177
- package/dist/components/report/field-panel-helpers.js +0 -33
- package/dist/components/report/field-panel.js +0 -132
- package/dist/components/report/filter-bar.js +0 -74
- package/dist/components/report/hub-connection-form.js +0 -145
- package/dist/components/report/hub-dataset-editor.js +0 -409
- package/dist/components/report/preview-grid-size.js +0 -32
- package/dist/components/report/print.js +0 -39
- package/dist/components/report/report-designer.js +0 -428
- package/dist/components/report/report-viewer.js +0 -253
- package/dist/components/report/style.d.ts +0 -17
- package/dist/components/report/style.js +0 -18
- package/dist/components/report/style2.css +0 -965
- package/dist/components/report/use-report-designer.js +0 -387
- package/dist/components/report/use-report-viewer.js +0 -140
- package/dist/report/binding.d.ts +0 -83
- package/dist/report/binding.js +0 -334
- package/dist/report/connector.d.ts +0 -66
- package/dist/report/connector.js +0 -159
- package/dist/report/drill.d.ts +0 -48
- package/dist/report/drill.js +0 -78
- package/dist/report/export-xlsx.d.ts +0 -13
- package/dist/report/export-xlsx.js +0 -13
- package/dist/report/filter-bar.d.ts +0 -10
- package/dist/report/filter-bar.js +0 -31
- package/dist/report/index.d.ts +0 -14
- package/dist/report/params.d.ts +0 -13
- package/dist/report/params.js +0 -61
- package/dist/report/print.d.ts +0 -23
- package/dist/report/print.js +0 -197
- package/dist/report/render/aggregate.js +0 -193
- package/dist/report/render/builder.d.ts +0 -12
- package/dist/report/render/builder.js +0 -139
- package/dist/report/render/coordinate.d.ts +0 -25
- package/dist/report/render/coordinate.js +0 -733
- package/dist/report/render/index.d.ts +0 -14
- package/dist/report/render/index.js +0 -21
- package/dist/report/render/style-resolver.js +0 -50
- package/dist/report/render/template-index.d.ts +0 -24
- package/dist/report/render/template-index.js +0 -137
- package/dist/report/rules/evaluate.d.ts +0 -25
- package/dist/report/rules/evaluate.js +0 -82
- package/dist/report/rules/index.d.ts +0 -2
- package/dist/report/template.d.ts +0 -63
- package/dist/report/template.js +0 -83
- package/dist/report/types.d.ts +0 -103
- package/dist/types/report-designer.d.ts +0 -51
- package/dist/types/report-viewer.d.ts +0 -57
- package/src/components/report/__test__/binding-badge.test.ts +0 -92
- package/src/components/report/__test__/conditional-rules-helpers.test.ts +0 -88
- package/src/components/report/__test__/field-panel-helpers.test.ts +0 -65
- package/src/components/report/__test__/float-panel-position.test.ts +0 -45
- package/src/components/report/__test__/preview-grid-size.test.ts +0 -63
- package/src/components/report/__test__/report-designer.test.ts +0 -559
- package/src/components/report/__test__/report-drill.test.ts +0 -692
- package/src/components/report/__test__/report-viewer.test.ts +0 -400
- package/src/components/report/__test__/topology.test.ts +0 -143
- package/src/components/report/__test__/use-report-designer.test.ts +0 -804
- package/src/components/report/binding-badge.ts +0 -122
- package/src/components/report/designer/cell-coords.ts +0 -95
- package/src/components/report/designer/col-widths.ts +0 -56
- package/src/components/report/designer/conditional-rules/helpers.ts +0 -189
- package/src/components/report/designer/drill-dialog.vue +0 -245
- package/src/components/report/designer/drop-highlight-overlay.vue +0 -75
- package/src/components/report/designer/float-panel.vue +0 -444
- package/src/components/report/designer/role.ts +0 -32
- package/src/components/report/designer/rule-preview.vue +0 -40
- package/src/components/report/designer/rule-row.vue +0 -252
- package/src/components/report/designer/rules-dialog.vue +0 -110
- package/src/components/report/designer/topology-overlay.vue +0 -128
- package/src/components/report/designer/topology.ts +0 -124
- package/src/components/report/designer/use-grid-overlay.ts +0 -114
- package/src/components/report/designer-hub.vue +0 -198
- package/src/components/report/field-panel-helpers.ts +0 -44
- package/src/components/report/field-panel.vue +0 -136
- package/src/components/report/filter-bar.vue +0 -77
- package/src/components/report/hub-connection-form.vue +0 -124
- package/src/components/report/hub-dataset-editor.vue +0 -387
- package/src/components/report/index.ts +0 -2
- package/src/components/report/preview-grid-size.ts +0 -33
- package/src/components/report/print.ts +0 -44
- package/src/components/report/report-designer.vue +0 -454
- package/src/components/report/report-viewer.vue +0 -289
- package/src/components/report/style-designer.scss +0 -653
- package/src/components/report/style-hub.scss +0 -292
- package/src/components/report/style-viewer.scss +0 -144
- package/src/components/report/style.scss +0 -3
- package/src/components/report/style.ts +0 -20
- package/src/components/report/use-report-designer.ts +0 -603
- package/src/components/report/use-report-viewer.ts +0 -227
- package/src/report/__test__/binding.test.ts +0 -320
- package/src/report/__test__/connector.test.ts +0 -239
- package/src/report/__test__/drill.test.ts +0 -194
- package/src/report/__test__/export-xlsx.test.ts +0 -96
- package/src/report/__test__/filter-bar.test.ts +0 -58
- package/src/report/__test__/params.test.ts +0 -156
- package/src/report/__test__/print.test.ts +0 -170
- package/src/report/__test__/render.test.ts +0 -856
- package/src/report/__test__/rules.test.ts +0 -131
- package/src/report/__test__/template.test.ts +0 -366
- package/src/report/binding.ts +0 -474
- package/src/report/connector.ts +0 -206
- package/src/report/drill.ts +0 -112
- package/src/report/export-xlsx.ts +0 -15
- package/src/report/filter-bar.ts +0 -36
- package/src/report/index.ts +0 -16
- package/src/report/params.ts +0 -96
- package/src/report/print.ts +0 -234
- package/src/report/render/__test__/aggregate.test.ts +0 -16
- package/src/report/render/__test__/coordinate.test.ts +0 -405
- package/src/report/render/aggregate.ts +0 -289
- package/src/report/render/builder.ts +0 -211
- package/src/report/render/coordinate.ts +0 -1239
- package/src/report/render/index.ts +0 -30
- package/src/report/render/style-resolver.ts +0 -68
- package/src/report/render/template-index.ts +0 -200
- package/src/report/rules/evaluate.ts +0 -113
- package/src/report/rules/index.ts +0 -7
- package/src/report/template.ts +0 -145
- package/src/report/types.ts +0 -116
- package/src/types/report-designer.ts +0 -55
- package/src/types/report-viewer.ts +0 -54
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { physicalColSpan, physicalRowSpan } from "./coordinate.js";
|
|
2
|
-
import { AggregateIndex, resolvePlacementRecord, resolvePlacementValue } from "./aggregate.js";
|
|
3
|
-
import { StyleResolver } from "./style-resolver.js";
|
|
4
|
-
import { cellKey } from "@veltra/sheet-core";
|
|
5
|
-
//#region src/report/render/builder.ts
|
|
6
|
-
function toCellValue(value) {
|
|
7
|
-
if (value === null || value === void 0) return { v: "" };
|
|
8
|
-
if (typeof value === "number" && !Number.isNaN(value)) return {
|
|
9
|
-
v: value,
|
|
10
|
-
t: "n"
|
|
11
|
-
};
|
|
12
|
-
if (typeof value === "boolean") return {
|
|
13
|
-
v: value,
|
|
14
|
-
t: "b"
|
|
15
|
-
};
|
|
16
|
-
if (typeof value === "string") return {
|
|
17
|
-
v: value,
|
|
18
|
-
t: "s"
|
|
19
|
-
};
|
|
20
|
-
if (value instanceof Date) return {
|
|
21
|
-
v: value.toISOString().slice(0, 10),
|
|
22
|
-
t: "s"
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
v: JSON.stringify(value),
|
|
26
|
-
t: "s"
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function rangeCells(range) {
|
|
30
|
-
const cells = [];
|
|
31
|
-
for (let row = range.start.row; row <= range.end.row; row++) for (let col = range.start.col; col <= range.end.col; col++) cells.push({
|
|
32
|
-
row,
|
|
33
|
-
col
|
|
34
|
-
});
|
|
35
|
-
return cells;
|
|
36
|
-
}
|
|
37
|
-
function placementSourceValue(placement, template, index, data, aggregateIndex) {
|
|
38
|
-
if (placement.binding) return resolvePlacementValue(placement, index, data, aggregateIndex);
|
|
39
|
-
return index.cellAt(placement.logical)?.v;
|
|
40
|
-
}
|
|
41
|
-
function colWidthSourceLogicalCol(placement) {
|
|
42
|
-
const binding = placement.binding;
|
|
43
|
-
if (binding?.colParent) return binding.colParent.col;
|
|
44
|
-
return placement.logical.col;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* 将模板列宽映射到填充报表物理列:横向展开列继承列方向父格所在模板列宽。
|
|
48
|
-
*/
|
|
49
|
-
function mapFilledColWidths(templateColWidths, layout, _index) {
|
|
50
|
-
if (templateColWidths.length === 0 || layout.colCount === 0) return [];
|
|
51
|
-
const widthByTemplateCol = /* @__PURE__ */ new Map();
|
|
52
|
-
for (const [col, width] of templateColWidths) widthByTemplateCol.set(col, width);
|
|
53
|
-
const physicalWidths = /* @__PURE__ */ new Map();
|
|
54
|
-
for (const placement of layout.placements) {
|
|
55
|
-
const sourceCol = colWidthSourceLogicalCol(placement);
|
|
56
|
-
const width = widthByTemplateCol.get(sourceCol);
|
|
57
|
-
if (width === void 0) continue;
|
|
58
|
-
const startCol = placement.physical.start.col;
|
|
59
|
-
const endCol = placement.physical.end.col;
|
|
60
|
-
for (let col = startCol; col <= endCol; col++) physicalWidths.set(col, width);
|
|
61
|
-
}
|
|
62
|
-
return [...physicalWidths.entries()].sort((a, b) => a[0] - b[0]);
|
|
63
|
-
}
|
|
64
|
-
function placementEvalContext(placement, value, template, index, data, aggregateIndex) {
|
|
65
|
-
const binding = placement.binding;
|
|
66
|
-
return {
|
|
67
|
-
cellValue: value,
|
|
68
|
-
bindingField: binding?.field ?? "",
|
|
69
|
-
record: binding ? resolvePlacementRecord(placement, index, data, aggregateIndex) : void 0
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function collectRowConditionalStyles(layout, template, index, data, styles) {
|
|
73
|
-
const aggregateIndex = new AggregateIndex(data);
|
|
74
|
-
for (const placement of layout.placements) {
|
|
75
|
-
const binding = placement.binding;
|
|
76
|
-
if (!binding?.conditionalRules?.some((rule) => rule.scope === "row")) continue;
|
|
77
|
-
const ctx = placementEvalContext(placement, placementSourceValue(placement, template, index, data, aggregateIndex), template, index, data, aggregateIndex);
|
|
78
|
-
for (let row = placement.physical.start.row; row <= placement.physical.end.row; row++) styles.collectRowStyle(row, ctx, binding.conditionalRules);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/** 由扩展坐标布局组装 Filled Report 快照 */
|
|
82
|
-
function buildFilledReport(template, index, layout, data) {
|
|
83
|
-
const styles = new StyleResolver(template);
|
|
84
|
-
collectRowConditionalStyles(layout, template, index, data, styles);
|
|
85
|
-
const aggregateIndex = new AggregateIndex(data);
|
|
86
|
-
const cells = [];
|
|
87
|
-
const merges = [...layout.mappedMerges];
|
|
88
|
-
const mergeKeys = new Set(merges.map((m) => cellKey(m.start)));
|
|
89
|
-
const pushMerge = (range) => {
|
|
90
|
-
const key = cellKey(range.start);
|
|
91
|
-
if (mergeKeys.has(key)) return;
|
|
92
|
-
mergeKeys.add(key);
|
|
93
|
-
merges.push(range);
|
|
94
|
-
};
|
|
95
|
-
const resolveStyleId = (placement, templateRow, templateCol, value, physicalRow) => {
|
|
96
|
-
const binding = placement.binding;
|
|
97
|
-
const ctx = placementEvalContext(placement, value, template, index, data, aggregateIndex);
|
|
98
|
-
const baseStyleId = binding ? styles.resolveCell(templateRow, templateCol, ctx, binding.conditionalRules) : styles.resolveStatic(templateRow, templateCol);
|
|
99
|
-
return styles.mergeRowStyle(baseStyleId, physicalRow);
|
|
100
|
-
};
|
|
101
|
-
for (const placement of layout.placements) {
|
|
102
|
-
const value = placementSourceValue(placement, template, index, data, aggregateIndex);
|
|
103
|
-
const { row: templateRow, col: templateCol } = placement.logical;
|
|
104
|
-
const rowSpan = physicalRowSpan(placement);
|
|
105
|
-
const colSpan = physicalColSpan(placement);
|
|
106
|
-
if (placement.mergeSpan && (rowSpan > 1 || colSpan > 1)) {
|
|
107
|
-
const item = {
|
|
108
|
-
row: placement.physical.start.row,
|
|
109
|
-
col: placement.physical.start.col,
|
|
110
|
-
...toCellValue(value)
|
|
111
|
-
};
|
|
112
|
-
const styleId = resolveStyleId(placement, templateRow, templateCol, value, placement.physical.start.row);
|
|
113
|
-
if (styleId !== void 0) item.s = styleId;
|
|
114
|
-
cells.push(item);
|
|
115
|
-
if (rowSpan > 1 || colSpan > 1) pushMerge(placement.physical);
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
for (const pos of rangeCells(placement.physical)) {
|
|
119
|
-
const item = {
|
|
120
|
-
row: pos.row,
|
|
121
|
-
col: pos.col,
|
|
122
|
-
...toCellValue(value)
|
|
123
|
-
};
|
|
124
|
-
const styleId = resolveStyleId(placement, templateRow, templateCol, value, pos.row);
|
|
125
|
-
if (styleId !== void 0) item.s = styleId;
|
|
126
|
-
cells.push(item);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
cells,
|
|
131
|
-
styles: styles.snapshot(),
|
|
132
|
-
merges,
|
|
133
|
-
frozen: template.frozen,
|
|
134
|
-
rows: layout.rowCount,
|
|
135
|
-
cols: Math.max(layout.colCount, template.cols)
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
export { buildFilledReport, mapFilledColWidths };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ReportBinding } from "../types.js";
|
|
2
|
-
import "./template-index.js";
|
|
3
|
-
import { CellAddress, CellRange } from "@veltra/sheet-core";
|
|
4
|
-
//#region src/report/render/coordinate.d.ts
|
|
5
|
-
/** 逻辑格 → 物理区间映射项(纯几何,不含取值) */
|
|
6
|
-
interface PhysicalPlacement {
|
|
7
|
-
logical: CellAddress;
|
|
8
|
-
physical: CellRange;
|
|
9
|
-
rowPath: readonly number[];
|
|
10
|
-
colPath: readonly number[];
|
|
11
|
-
mergeSpan: boolean;
|
|
12
|
-
binding?: ReportBinding;
|
|
13
|
-
/** `list` 明细实例下标;非 list 时为 0 */
|
|
14
|
-
listIndex: number;
|
|
15
|
-
}
|
|
16
|
-
/** 扩展坐标系计算结果 */
|
|
17
|
-
interface ExpansionLayout {
|
|
18
|
-
rowCount: number;
|
|
19
|
-
colCount: number;
|
|
20
|
-
placements: PhysicalPlacement[];
|
|
21
|
-
/** 模板合并区域映射到物理网格后的区间 */
|
|
22
|
-
mappedMerges: CellRange[];
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { ExpansionLayout, PhysicalPlacement };
|