report-studio 1.2.0 → 1.2.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.
@@ -18,7 +18,15 @@
18
18
  */
19
19
  @import "./brand.css";
20
20
 
21
- :root {
21
+ /**
22
+ * Everything below is scoped to what Report Studio owns: the two screens' mounts,
23
+ * and .report-studio-page, the class its own standalone pages put on <html>.
24
+ * On :root and body these reached the host's whole page - its font became
25
+ * Courier, its margins went, and a host --border or --accent fought ours.
26
+ */
27
+ .report-viewer,
28
+ .report-designer,
29
+ .report-studio-page {
22
30
  /* the palette */
23
31
  --surface: #fdfdfe;
24
32
  --accent: #ff9c4b;
@@ -53,13 +61,17 @@
53
61
  --pager-offset: 20px;
54
62
  }
55
63
 
56
- * {
64
+ /* :where() keeps the reset at the zero specificity * had, so no rule loses to it */
65
+ :where(.report-viewer, .report-designer, .report-studio-page),
66
+ :where(.report-viewer, .report-designer, .report-studio-page) * {
57
67
  box-sizing: border-box;
58
68
  margin: 0;
59
69
  padding: 0;
60
70
  }
61
71
 
62
- body {
72
+ .report-viewer,
73
+ .report-designer,
74
+ .report-studio-page {
63
75
  font-family: "Courier Prime", monospace;
64
76
  font-weight: 400;
65
77
  font-style: normal;
package/types/index.d.ts CHANGED
@@ -101,6 +101,54 @@ export function toCSV(pages: Page[], options?: CSVOptions): string;
101
101
  /** the whole report as CSV, one row per line in the order it is read */
102
102
  export function toReportCSV(pages: Page[], options?: ReportCSVOptions): string;
103
103
 
104
+ export interface XLSXOptions {
105
+ /** include the "Report" sheet, the report as it reads; default true */
106
+ report?: boolean;
107
+ /** include one sheet per table; default true */
108
+ tables?: boolean;
109
+ /**
110
+ * carry the report's look: fonts, colours, alignment, table grid, row
111
+ * heights and column widths, text placed where it sits on the page, and
112
+ * pictures, lines and boxes drawn. False writes plain data with bold
113
+ * headers. Default true
114
+ */
115
+ styled?: boolean;
116
+ /**
117
+ * the bytes of pictures given as URLs, keyed by their src; `data:` URIs
118
+ * need none. A picture with no bytes is left out. toXLSXAsync fills this in
119
+ */
120
+ images?: Record<string, Uint8Array | ArrayBuffer> | Map<string, Uint8Array | ArrayBuffer>;
121
+ /** default `'Report'` */
122
+ reportSheetName?: string;
123
+ /** prepend the group key on a grouped table's sheet; default true */
124
+ groupColumn?: boolean;
125
+ /** default `'Group'` */
126
+ groupLabel?: string;
127
+ }
128
+
129
+ /**
130
+ * the report as an .xlsx workbook; empty when the report writes nothing.
131
+ * Throws a RangeError when a sheet would pass Excel's row or column limit
132
+ */
133
+ export function toXLSX(pages: Page[], options?: XLSXOptions): Uint8Array;
134
+
135
+ export interface XLSXAsyncOptions extends XLSXOptions {
136
+ /** what fetches a picture's URL; the global fetch by default */
137
+ fetch?: (url: string) => Promise<{ ok: boolean; arrayBuffer(): Promise<ArrayBuffer> }>;
138
+ }
139
+
140
+ /**
141
+ * toXLSX with the report's URL pictures fetched first; a picture that cannot
142
+ * be fetched is left out rather than failing the workbook
143
+ */
144
+ export function toXLSXAsync(pages: Page[], options?: XLSXAsyncOptions): Promise<Uint8Array>;
145
+
146
+ /** the picture URLs a report shows that need fetching to be embedded */
147
+ export function reportImageSources(pages: Page[]): string[];
148
+
149
+ /** the MIME type to give a Blob of toXLSX's bytes */
150
+ export const XLSX_MIME: string;
151
+
104
152
  /** a download filename from the report's name */
105
153
  export function reportFilename(paginated: { name?: string }, extension?: string): string;
106
154
 
@@ -155,6 +203,11 @@ export interface ViewerHandle {
155
203
  print(): void;
156
204
  /** false when the report has nothing to write */
157
205
  downloadCSV(): boolean;
206
+ /**
207
+ * false when the report has nothing to write. A report with pictures
208
+ * from URLs fetches them first, so its download starts a moment later
209
+ */
210
+ downloadXLSX(): boolean;
158
211
  openExport(): void;
159
212
  closeExport(): void;
160
213
  confirmExport(): void;