report-studio 1.2.3 → 1.3.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/README.md +254 -3
- package/dist/designer-Dj330bWd.js +4690 -0
- package/dist/designer.js +1 -1
- package/dist/index.js +2 -2
- package/dist/react-designer.js +1 -1
- package/dist/react.js +1 -1
- package/dist/viewer-BewnkhfP.js +4028 -0
- package/package.json +2 -2
- package/src/designer/blank.js +0 -1
- package/src/designer/canvas.js +172 -54
- package/src/designer/designer.js +313 -12
- package/src/designer/dialog.js +609 -5
- package/src/designer/fields.js +128 -11
- package/src/designer/geometry.js +77 -4
- package/src/designer/grouping.js +556 -0
- package/src/designer/icons.js +9 -0
- package/src/designer/menu.js +50 -6
- package/src/designer/panel.js +478 -38
- package/src/designer/rulers.js +14 -6
- package/src/designer/sample-data.js +112 -31
- package/src/designer/select.js +3 -2
- package/src/designer/structure.js +126 -12
- package/src/designer/styles.css +661 -27
- package/src/designer/tokens.js +38 -11
- package/src/engine/calculate.js +487 -0
- package/src/engine/csv.js +17 -9
- package/src/engine/format.js +483 -0
- package/src/engine/group.js +350 -70
- package/src/engine/highlight.js +224 -0
- package/src/engine/index.js +8 -1
- package/src/engine/measure.js +53 -26
- package/src/engine/paginate.js +189 -92
- package/src/engine/resolve.js +117 -10
- package/src/engine/rows.js +71 -8
- package/src/engine/search.js +12 -4
- package/src/engine/tables.js +309 -11
- package/src/engine/validate.js +265 -8
- package/src/engine/xlsx-style.js +50 -4
- package/src/engine/xlsx.js +91 -21
- package/src/index.js +18 -0
- package/src/render/items.js +61 -10
- package/src/render/report.css +0 -5
- package/types/index.d.ts +96 -8
- package/types/layout.d.ts +156 -2
- package/dist/designer-DQlfKnTr.js +0 -3416
- package/dist/viewer-BSPNCNRU.js +0 -2912
package/src/index.js
CHANGED
|
@@ -30,6 +30,24 @@ export {
|
|
|
30
30
|
toXLSXAsync,
|
|
31
31
|
reportImageSources,
|
|
32
32
|
XLSX_MIME,
|
|
33
|
+
tablesOf,
|
|
34
|
+
datasetOf,
|
|
35
|
+
groupingOf,
|
|
36
|
+
groupingsOf,
|
|
37
|
+
groupBandsOf,
|
|
38
|
+
levelsOf,
|
|
39
|
+
isGrouped,
|
|
40
|
+
normalizeGrouping,
|
|
41
|
+
fragmentBandsOf,
|
|
42
|
+
MAX_GROUP_LEVELS,
|
|
43
|
+
formatValue,
|
|
44
|
+
describeFormat,
|
|
45
|
+
excelNumberFormat,
|
|
46
|
+
DEFAULT_FORMAT,
|
|
47
|
+
INDIAN_DEFAULTS,
|
|
48
|
+
highlightFor,
|
|
49
|
+
cellHighlight,
|
|
50
|
+
describeHighlight,
|
|
33
51
|
measureText,
|
|
34
52
|
wrapLines,
|
|
35
53
|
textHeight,
|
package/src/render/items.js
CHANGED
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* A pure module with no DOM and no engine state - the one rule for printing a
|
|
19
|
+
* value, shared with measure.js so a cell is drawn as wide as it was measured.
|
|
20
|
+
*/
|
|
21
|
+
import { formatValue } from '../engine/format.js';
|
|
22
|
+
import { cellHighlight } from '../engine/highlight.js';
|
|
23
|
+
|
|
24
|
+
|
|
17
25
|
/** items are placed against the band box, which the caller has made relative */
|
|
18
26
|
export const position = (p) => `position:absolute;top:${px(p?.y)}px;left:${px(p?.x)}px;`;
|
|
19
27
|
|
|
@@ -126,10 +134,13 @@ function text(i) {
|
|
|
126
134
|
* fine. Written by hand or generated by an API rather than drawn, but the
|
|
127
135
|
* two halves of the package have to agree about what they accept.
|
|
128
136
|
*/
|
|
129
|
-
|
|
137
|
+
/** a highlight rule that held lays its style over the item's own */
|
|
138
|
+
const lit = i.highlighted ?? null;
|
|
139
|
+
const style = { ...(i.style ?? {}), ...(lit ?? {}) };
|
|
130
140
|
|
|
131
141
|
return `
|
|
132
142
|
<p id="${esc(i.id)}" style="
|
|
143
|
+
${lit?.background ? `background:${css(lit.background)};` : ''}
|
|
133
144
|
width:${px(i.w)}px;
|
|
134
145
|
height:${px(i.h)}px;
|
|
135
146
|
${position(i)}
|
|
@@ -438,8 +449,15 @@ function table(i) {
|
|
|
438
449
|
* @param {*} value what the cell shows
|
|
439
450
|
* @returns {string} markup
|
|
440
451
|
*/
|
|
441
|
-
function cell(height, align, value) {
|
|
442
|
-
|
|
452
|
+
function cell(height, align, value, lit = null) {
|
|
453
|
+
/** a highlight's text: its colour, weight and slant, over the table's */
|
|
454
|
+
const look = lit ? [
|
|
455
|
+
lit.color ? `color:${css(lit.color)};` : '',
|
|
456
|
+
lit.fontWeight ? `font-weight:${css(lit.fontWeight)};` : '',
|
|
457
|
+
lit.fontStyle ? `font-style:${css(lit.fontStyle)};` : ''
|
|
458
|
+
].join('') : '';
|
|
459
|
+
|
|
460
|
+
return `<div class="cell" style="height:${px(height)}px;text-align:${css(align, 'left')};${look}">` +
|
|
443
461
|
`${esc(value)}</div>`;
|
|
444
462
|
}
|
|
445
463
|
|
|
@@ -469,7 +487,12 @@ function dataRows(i, rows, heights) {
|
|
|
469
487
|
const height = heights?.[n] ?? i.rowHeight;
|
|
470
488
|
|
|
471
489
|
return `<tr style="height:${px(height)}px">
|
|
472
|
-
${i.columns.map(c =>
|
|
490
|
+
${i.columns.map(c => {
|
|
491
|
+
const lit = cellHighlight(i, c, r);
|
|
492
|
+
const fill = lit?.background ? `background:${css(lit.background)};` : '';
|
|
493
|
+
|
|
494
|
+
return `<td style="width:${px(c.width)}px;${fill}">${cell(height, c.align, formatValue(r[c.field], c.format), lit)}</td>`;
|
|
495
|
+
}).join("")}
|
|
473
496
|
</tr>`;
|
|
474
497
|
}).join("");
|
|
475
498
|
}
|
|
@@ -482,8 +505,12 @@ function dataRows(i, rows, heights) {
|
|
|
482
505
|
function groupBandRow(band, colSpan, cls) {
|
|
483
506
|
if (!band) return '';
|
|
484
507
|
const height = band.measuredHeight > 0 ? band.measuredHeight : (band.height ?? 0);
|
|
485
|
-
|
|
486
|
-
|
|
508
|
+
/** which level of a nested grouping, for a stylesheet that tells them apart */
|
|
509
|
+
const level = Number.isInteger(band.level) ? ` data-group-level="${band.level}"` : '';
|
|
510
|
+
/** a group band's own background, across the table's full width */
|
|
511
|
+
const fill = band.background ? ` style="background:${css(band.background)}"` : '';
|
|
512
|
+
return `<tr class="${cls}"${level}>
|
|
513
|
+
<td colspan="${colSpan}" class="group-band-cell"${fill}>
|
|
487
514
|
<div class="band" style="position:relative;height:${px(height)}px">${items(band.items)}</div>
|
|
488
515
|
</td>
|
|
489
516
|
</tr>`;
|
|
@@ -503,16 +530,40 @@ function flatBody(i) {
|
|
|
503
530
|
/**
|
|
504
531
|
* One tbody per group fragment, so a group that survives a page break keeps its
|
|
505
532
|
* header on the next page and only prints its footer on the fragment that ends it.
|
|
533
|
+
*
|
|
534
|
+
* A table grouped within its groups draws every header the fragment opens,
|
|
535
|
+
* outermost first, and every footer it closes, innermost first - pagination
|
|
536
|
+
* has already decided which those are.
|
|
506
537
|
*/
|
|
507
538
|
function groupedBody(i) {
|
|
508
539
|
const colSpan = i.columns.length;
|
|
509
540
|
|
|
510
|
-
return i.groups.map(g =>
|
|
541
|
+
return i.groups.map(g => {
|
|
542
|
+
const { headers, footers } = fragmentBands(g);
|
|
543
|
+
|
|
544
|
+
return `
|
|
511
545
|
${g.showHeader && i.showHeader ? columnHeader(i) : ""}
|
|
512
546
|
<tbody>
|
|
513
|
-
${groupBandRow(
|
|
547
|
+
${headers.map(band => groupBandRow(band, colSpan, "group-header")).join("")}
|
|
514
548
|
${dataRows(i, g.rows, g.rowHeights)}
|
|
515
|
-
${
|
|
549
|
+
${footers.map(band => groupBandRow(band, colSpan, "group-footer")).join("")}
|
|
516
550
|
</tbody>
|
|
517
|
-
|
|
551
|
+
`;
|
|
552
|
+
}).join("");
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* A fragment's group bands, in drawing order. The same reading as the engine's
|
|
558
|
+
* fragmentBandsOf, kept here so render/ stays free of the engine: a fragment
|
|
559
|
+
* built before nested groups, or by the designer, has only the single
|
|
560
|
+
* headerBand and footerBand.
|
|
561
|
+
*/
|
|
562
|
+
function fragmentBands(g) {
|
|
563
|
+
const headers = Array.isArray(g.headerBands) ? g.headerBands : [g.headerBand];
|
|
564
|
+
const footers = Array.isArray(g.footerBands)
|
|
565
|
+
? g.footerBands
|
|
566
|
+
: [g.showFooter ? g.footerBand : null];
|
|
567
|
+
|
|
568
|
+
return { headers: headers.filter(Boolean), footers: footers.filter(Boolean) };
|
|
518
569
|
}
|
package/src/render/report.css
CHANGED
|
@@ -222,11 +222,6 @@
|
|
|
222
222
|
border: none;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
/* warm, so a group break reads differently from a column header */
|
|
226
|
-
.page .group-header .group-band-cell {
|
|
227
|
-
background: var(--accent-soft, #fdf1e9);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
225
|
.page .group-band-cell .band p {
|
|
231
226
|
padding: 0 8px;
|
|
232
227
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
-
Band, BandType,
|
|
6
|
+
Band, BandType, FormatDefaults, GroupBand, GroupFragment, GroupLevel, Layout, PaginatedReport,
|
|
7
|
+
HighlightRule, Page, ReportData, TableColumn, TableItem, TextStyle, ValueFormat
|
|
7
8
|
} from './layout.js';
|
|
8
9
|
|
|
9
10
|
export type * from './layout.js';
|
|
@@ -19,7 +20,11 @@ export function buildPages(layout: Layout, data: ReportData): PaginatedReport;
|
|
|
19
20
|
|
|
20
21
|
/** stage 1 of buildPages: fills in placeholders from the data */
|
|
21
22
|
export function resolve(layout: Layout, data: ReportData): Layout;
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* stage 2: binds each table to its rows and splits every grouped table's rows
|
|
25
|
+
* into groups. Grouping written the older way comes out as each table's own
|
|
26
|
+
* `grouping` - see normalizeGrouping.
|
|
27
|
+
*/
|
|
23
28
|
export function group(resolved: Layout, data: ReportData): Layout;
|
|
24
29
|
/** stage 3: measures text and table rows */
|
|
25
30
|
export function measure(grouped: Layout): Layout;
|
|
@@ -87,10 +92,16 @@ export interface CSVOptions {
|
|
|
87
92
|
header?: boolean;
|
|
88
93
|
/** prepend the group key on a grouped table; default true */
|
|
89
94
|
groupColumn?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
|
|
95
|
+
/**
|
|
96
|
+
* the group column's heading; default `'Group'`. A list names one column
|
|
97
|
+
* per level of a nested grouping, whose columns are otherwise named after
|
|
98
|
+
* the fields they group by
|
|
99
|
+
*/
|
|
100
|
+
groupLabel?: string | string[];
|
|
92
101
|
/** stop cells starting `=`, `+`, `-` or `@` running as formulas; default true */
|
|
93
102
|
neutraliseFormulas?: boolean;
|
|
103
|
+
/** write each cell as printed, ₹1,00,000.00, rather than its value; default false */
|
|
104
|
+
formatted?: boolean;
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
export type ReportCSVOptions = Pick<CSVOptions, 'delimiter' | 'newline' | 'neutraliseFormulas'>;
|
|
@@ -122,8 +133,12 @@ export interface XLSXOptions {
|
|
|
122
133
|
reportSheetName?: string;
|
|
123
134
|
/** prepend the group key on a grouped table's sheet; default true */
|
|
124
135
|
groupColumn?: boolean;
|
|
125
|
-
/**
|
|
126
|
-
|
|
136
|
+
/**
|
|
137
|
+
* the group column's heading; default `'Group'`. A list names one column
|
|
138
|
+
* per level of a nested grouping, whose columns are otherwise named after
|
|
139
|
+
* the fields they group by
|
|
140
|
+
*/
|
|
141
|
+
groupLabel?: string | string[];
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
/**
|
|
@@ -161,8 +176,81 @@ export function tablesOf(layout: Layout): TableItem[];
|
|
|
161
176
|
/** the dataset a table reads: its own, or the layout's */
|
|
162
177
|
export function datasetOf(table: TableItem, layout: Layout): string | null;
|
|
163
178
|
|
|
164
|
-
/**
|
|
165
|
-
export
|
|
179
|
+
/** a grouped table, its field, and the bands its groups are drawn with */
|
|
180
|
+
export interface TableGrouping {
|
|
181
|
+
table: TableItem;
|
|
182
|
+
by: string;
|
|
183
|
+
header: GroupBand | Band | null;
|
|
184
|
+
footer: GroupBand | Band | null;
|
|
185
|
+
/** every level, outermost first; the fields above are the first's */
|
|
186
|
+
levels: Array<{ by: string; header: GroupBand | Band | null; footer: GroupBand | Band | null }>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** every grouped table, in the order they are drawn, either way it is grouped */
|
|
190
|
+
export function groupingsOf(layout: Layout): TableGrouping[];
|
|
191
|
+
|
|
192
|
+
/** the first grouped table, or null when nothing is grouped */
|
|
193
|
+
export function groupingOf(layout: Layout): TableGrouping | null;
|
|
194
|
+
|
|
195
|
+
/** the text a value prints as, under a format and the report's defaults */
|
|
196
|
+
export function formatValue(value: unknown, format?: ValueFormat | null, defaults?: FormatDefaults | null): string;
|
|
197
|
+
|
|
198
|
+
/** a format in one line, such as "Currency · ₹12,34,567.89" */
|
|
199
|
+
export function describeFormat(format?: ValueFormat | null, defaults?: FormatDefaults | null): string;
|
|
200
|
+
|
|
201
|
+
/** the Excel number format code that shows a value as formatValue prints it, or null */
|
|
202
|
+
export function excelNumberFormat(format?: ValueFormat | null, defaults?: FormatDefaults | null): string | null;
|
|
203
|
+
|
|
204
|
+
/** international digit groups, no symbol, ISO dates */
|
|
205
|
+
export const DEFAULT_FORMAT: Readonly<Required<ValueFormat>>;
|
|
206
|
+
|
|
207
|
+
/** the style the first rule that holds gives a value, or null */
|
|
208
|
+
export function highlightFor(
|
|
209
|
+
rules: HighlightRule[] | null | undefined, value: unknown, row?: Record<string, unknown> | null
|
|
210
|
+
): HighlightRule['style'] | null;
|
|
211
|
+
|
|
212
|
+
/** a table cell's style: its row's rules, then its column's own on top */
|
|
213
|
+
export function cellHighlight(
|
|
214
|
+
table: TableItem, column: TableColumn, row: Record<string, unknown>
|
|
215
|
+
): HighlightRule['style'] | null;
|
|
216
|
+
|
|
217
|
+
/** "None", "1 rule", "3 rules" */
|
|
218
|
+
export function describeHighlight(rules: HighlightRule[] | null | undefined): string;
|
|
219
|
+
|
|
220
|
+
/** ₹, 1,00,000 and dd/MM/yyyy - what the designer's one-click Indian button sets */
|
|
221
|
+
export const INDIAN_DEFAULTS: Readonly<FormatDefaults>;
|
|
222
|
+
|
|
223
|
+
/** the most levels a table may be grouped at; validateLayout refuses more */
|
|
224
|
+
export const MAX_GROUP_LEVELS: number;
|
|
225
|
+
|
|
226
|
+
/** a table's grouping levels as the layout states them; empty when it has none */
|
|
227
|
+
export function levelsOf(table: TableItem): GroupLevel[];
|
|
228
|
+
|
|
229
|
+
/** whether a table is grouped, by `grouping` or by the older `groupBy` */
|
|
230
|
+
export function isGrouped(table: TableItem): boolean;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* the bands one level of a table's groups are drawn with - the outermost's
|
|
234
|
+
* when no level is named - from a layout past normalizeGrouping
|
|
235
|
+
*/
|
|
236
|
+
export function groupBandsOf(
|
|
237
|
+
table: TableItem, level?: number
|
|
238
|
+
): { header: GroupBand | null; footer: GroupBand | null };
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* a built group fragment's bands in drawing order: headers outermost first,
|
|
242
|
+
* footers innermost first
|
|
243
|
+
*/
|
|
244
|
+
export function fragmentBandsOf(
|
|
245
|
+
fragment: GroupFragment
|
|
246
|
+
): { headers: Array<GroupBand & { level?: number }>; footers: Array<GroupBand & { level?: number }> };
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* A copy of a layout with grouping written one way only: `layout.groupBy`,
|
|
250
|
+
* `table.groupBy` and the report's groupHeader/groupFooter bands become that
|
|
251
|
+
* table's own `grouping`. Idempotent; the layout given is not changed.
|
|
252
|
+
*/
|
|
253
|
+
export function normalizeGrouping<T extends Layout>(layout: T): T;
|
|
166
254
|
|
|
167
255
|
/** width of one line of text, in pixels */
|
|
168
256
|
export function measureText(text: string, style?: TextStyle): number;
|
package/types/layout.d.ts
CHANGED
|
@@ -26,6 +26,67 @@ export type RuleStyle = LineStyle | 'none';
|
|
|
26
26
|
|
|
27
27
|
export type ImageFit = 'contain' | 'cover' | 'fill';
|
|
28
28
|
|
|
29
|
+
export type FormatType = 'text' | 'number' | 'currency' | 'percent' | 'date' | 'datetime';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* How values print, and how a workbook shows them. Every key is optional; what
|
|
33
|
+
* a format leaves unsaid comes from the report's own `format`, then from the
|
|
34
|
+
* neutral defaults: international digit groups, no symbol, ISO dates.
|
|
35
|
+
*/
|
|
36
|
+
export interface FormatDefaults {
|
|
37
|
+
/** places after the point, 0 to 6; default 2 */
|
|
38
|
+
decimals?: number;
|
|
39
|
+
/** 1,234,567 | 12,34,567 | 1234567; default 'international' */
|
|
40
|
+
grouping?: 'international' | 'indian' | 'none';
|
|
41
|
+
/** -1,234 | (1,234) | 1,234-; default 'minus' */
|
|
42
|
+
negative?: 'minus' | 'brackets' | 'trailing';
|
|
43
|
+
/** 0.00 | - | nothing; default 'zero' */
|
|
44
|
+
zero?: 'zero' | 'dash' | 'blank';
|
|
45
|
+
/** what a currency format prints with it, such as '₹'; default none */
|
|
46
|
+
symbol?: string;
|
|
47
|
+
/** default 'before' */
|
|
48
|
+
symbolPosition?: 'before' | 'after';
|
|
49
|
+
/**
|
|
50
|
+
* a date's layout from yyyy yy MMMM MMM MM M dd d HH H hh h mm ss a;
|
|
51
|
+
* default 'yyyy-MM-dd'
|
|
52
|
+
*/
|
|
53
|
+
pattern?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** what a highlight rule tests for */
|
|
57
|
+
export type HighlightOp =
|
|
58
|
+
| '=' | '!=' | '<' | '<=' | '>' | '>=' | 'between'
|
|
59
|
+
| 'contains' | 'startsWith' | 'empty' | 'notEmpty';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* One conditional formatting rule. Rules are checked in order and the first
|
|
63
|
+
* that holds is used. Numbers compare as numbers, dates by their day, and
|
|
64
|
+
* text without regard to case; a word never orders against a number.
|
|
65
|
+
*/
|
|
66
|
+
export interface HighlightRule {
|
|
67
|
+
when: {
|
|
68
|
+
/** a field of the row, or of the data for a text item; the value itself when absent */
|
|
69
|
+
field?: string;
|
|
70
|
+
op: HighlightOp;
|
|
71
|
+
value?: string | number;
|
|
72
|
+
/** the upper end, for 'between'; both ends are included */
|
|
73
|
+
to?: string | number;
|
|
74
|
+
};
|
|
75
|
+
/** only what is named changes */
|
|
76
|
+
style: {
|
|
77
|
+
color?: string;
|
|
78
|
+
background?: string;
|
|
79
|
+
fontWeight?: string;
|
|
80
|
+
fontStyle?: string;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** a text item's or a column's format */
|
|
85
|
+
export interface ValueFormat extends FormatDefaults {
|
|
86
|
+
/** 'text', or none, prints a value as it comes */
|
|
87
|
+
type: FormatType;
|
|
88
|
+
}
|
|
89
|
+
|
|
29
90
|
export interface Margin {
|
|
30
91
|
top: number;
|
|
31
92
|
right: number;
|
|
@@ -68,6 +129,10 @@ export interface TextItem extends ItemBase {
|
|
|
68
129
|
/** literal text and `{placeholders}`, such as `Total: {sum(amount)}` */
|
|
69
130
|
value: string;
|
|
70
131
|
style?: TextStyle;
|
|
132
|
+
/** how the values its placeholders stand for print */
|
|
133
|
+
format?: ValueFormat | null;
|
|
134
|
+
/** styles the item by the one value it prints, or by a field of the data */
|
|
135
|
+
highlight?: HighlightRule[] | null;
|
|
71
136
|
}
|
|
72
137
|
|
|
73
138
|
export interface TableColumn {
|
|
@@ -76,6 +141,16 @@ export interface TableColumn {
|
|
|
76
141
|
label?: string;
|
|
77
142
|
width?: number;
|
|
78
143
|
align?: Align;
|
|
144
|
+
/**
|
|
145
|
+
* Makes this a calculated column: worked out for each row and stored under
|
|
146
|
+
* `field`, e.g. `{qty} * {price}`, `round({amount} * 0.18, 2)` or
|
|
147
|
+
* `percentage({amount}, group)`.
|
|
148
|
+
*/
|
|
149
|
+
expression?: string | null;
|
|
150
|
+
/** how this column's values print; the workbook keeps them as numbers and dates */
|
|
151
|
+
format?: ValueFormat | null;
|
|
152
|
+
/** styles each cell by its value, or by another field of its row */
|
|
153
|
+
highlight?: HighlightRule[] | null;
|
|
79
154
|
[key: string]: unknown;
|
|
80
155
|
}
|
|
81
156
|
|
|
@@ -95,10 +170,24 @@ export interface TableItem extends ItemBase {
|
|
|
95
170
|
showHeader?: boolean;
|
|
96
171
|
/** the dataset this table reads rows from; the layout's when absent */
|
|
97
172
|
dataset?: string | null;
|
|
98
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* How this table's rows are grouped: the field, and the bands each group
|
|
175
|
+
* is drawn with. Outermost level first; each further level groups within
|
|
176
|
+
* the groups of the one before - by region, then by city. Each level
|
|
177
|
+
* groups by a different field. Any number of tables in a report may be
|
|
178
|
+
* grouped.
|
|
179
|
+
*/
|
|
180
|
+
grouping?: GroupLevel[] | null;
|
|
181
|
+
/**
|
|
182
|
+
* The older way to group: by this field, drawn with the report's own
|
|
183
|
+
* groupHeader and groupFooter bands, so only one table may use it.
|
|
184
|
+
* Read for layouts that have it; prefer `grouping`.
|
|
185
|
+
*/
|
|
99
186
|
groupBy?: string | null;
|
|
100
187
|
/** false keeps each cell to one line with an ellipsis */
|
|
101
188
|
wrap?: boolean;
|
|
189
|
+
/** styles whole rows by a field of the row; a column's own rules go on top */
|
|
190
|
+
rowHighlight?: HighlightRule[] | null;
|
|
102
191
|
style?: TableStyle;
|
|
103
192
|
}
|
|
104
193
|
|
|
@@ -137,6 +226,38 @@ export interface ImageItem extends ItemBase {
|
|
|
137
226
|
|
|
138
227
|
export type ReportItem = TextItem | TableItem | LineItem | BoxItem | ImageItem;
|
|
139
228
|
|
|
229
|
+
/**
|
|
230
|
+
* A band drawn once per group, inside the table it belongs to. Any item but a
|
|
231
|
+
* table. A group band's `{field}` reads the group's rows, and its
|
|
232
|
+
* `{sum(field)}` totals that group alone.
|
|
233
|
+
*/
|
|
234
|
+
export interface GroupBand {
|
|
235
|
+
/** a colour the band is shaded with, across the table's width */
|
|
236
|
+
background?: string | null;
|
|
237
|
+
/** pixels; grows to fit what is in it */
|
|
238
|
+
height?: number;
|
|
239
|
+
items: Array<TextItem | LineItem | BoxItem | ImageItem>;
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** one level of a table's grouping */
|
|
244
|
+
export interface GroupLevel {
|
|
245
|
+
/** the row field whose value decides which group a row is in */
|
|
246
|
+
by: string;
|
|
247
|
+
/** drawn above each group's rows; at least one of header and footer */
|
|
248
|
+
header?: GroupBand | null;
|
|
249
|
+
/** drawn under each group's last row */
|
|
250
|
+
footer?: GroupBand | null;
|
|
251
|
+
/**
|
|
252
|
+
* the order of this level's groups, by their value; numbers sort as
|
|
253
|
+
* numbers. Absent or null keeps the order the values are first seen in
|
|
254
|
+
*/
|
|
255
|
+
sort?: 'asc' | 'desc' | null;
|
|
256
|
+
/** start each of this level's groups, after the table's first, on a new page */
|
|
257
|
+
newPage?: boolean;
|
|
258
|
+
[key: string]: unknown;
|
|
259
|
+
}
|
|
260
|
+
|
|
140
261
|
export interface Band {
|
|
141
262
|
type: BandType;
|
|
142
263
|
/** pixels, or a percentage of the printable height such as `'10%'` */
|
|
@@ -152,8 +273,14 @@ export interface Layout {
|
|
|
152
273
|
page: PageSetup;
|
|
153
274
|
/** the dataset tables read from when they name none of their own */
|
|
154
275
|
dataset?: string | null;
|
|
155
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* The older way to group: the first table's rows by this field, drawn
|
|
278
|
+
* with the report's groupHeader and groupFooter bands. Prefer a table's
|
|
279
|
+
* own `grouping`.
|
|
280
|
+
*/
|
|
156
281
|
groupBy?: string | null;
|
|
282
|
+
/** what every item's and column's format falls back on */
|
|
283
|
+
format?: FormatDefaults | null;
|
|
157
284
|
bands: Band[];
|
|
158
285
|
[key: string]: unknown;
|
|
159
286
|
}
|
|
@@ -164,6 +291,33 @@ export interface Layout {
|
|
|
164
291
|
*/
|
|
165
292
|
export type ReportData = Record<string, unknown>;
|
|
166
293
|
|
|
294
|
+
/**
|
|
295
|
+
* One group's rows on one page - an entry of a built table's `groups`. For a
|
|
296
|
+
* table grouped at more than one level it is one of the innermost groups, with
|
|
297
|
+
* the bands of every outer group it starts or ends.
|
|
298
|
+
*/
|
|
299
|
+
export interface GroupFragment {
|
|
300
|
+
/** the innermost level's group key */
|
|
301
|
+
key: string;
|
|
302
|
+
/** the group key at every level, outermost first */
|
|
303
|
+
path: string[];
|
|
304
|
+
rows: Array<Record<string, unknown>>;
|
|
305
|
+
rowHeights: number[];
|
|
306
|
+
/** whether the table's column labels head this fragment */
|
|
307
|
+
showHeader: boolean;
|
|
308
|
+
/** whether this fragment holds its group's last row */
|
|
309
|
+
showFooter: boolean;
|
|
310
|
+
/** group headers drawn over the rows, outermost first, each with its `level` */
|
|
311
|
+
headerBands: Array<GroupBand & { level: number }>;
|
|
312
|
+
/** group footers drawn under them, innermost first, each with its `level` */
|
|
313
|
+
footerBands: Array<GroupBand & { level: number }>;
|
|
314
|
+
/** the innermost level's header, when drawn here */
|
|
315
|
+
headerBand: (GroupBand & { level: number }) | null;
|
|
316
|
+
/** the innermost level's footer, when drawn here */
|
|
317
|
+
footerBand: (GroupBand & { level: number }) | null;
|
|
318
|
+
[key: string]: unknown;
|
|
319
|
+
}
|
|
320
|
+
|
|
167
321
|
/** one page of a built report */
|
|
168
322
|
export interface Page {
|
|
169
323
|
/** 1-based */
|