report-studio 1.0.0 → 1.1.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/LICENSE +21 -21
- package/README.md +129 -4
- package/dist/designer-qy59eEux.js +3416 -0
- package/dist/designer.js +2 -3209
- package/dist/index.js +2 -2
- package/dist/react-designer.js +41 -0
- package/dist/react.js +60 -0
- package/dist/{viewer-D-c0lKzQ.js → viewer-xa17tyMJ.js} +682 -537
- package/package.json +80 -66
- package/src/cli/serve.js +135 -135
- package/src/designer/designer.js +2054 -1900
- package/src/designer/dialog.js +708 -708
- package/src/designer/fields.js +51 -2
- package/src/designer/icons.js +5 -0
- package/src/designer/index.html +28 -28
- package/src/designer/main.js +39 -39
- package/src/designer/menu.js +2 -2
- package/src/designer/panel.js +21 -1
- package/src/designer/sample-data.js +180 -9
- package/src/designer/structure.js +87 -6
- package/src/designer/styles.css +1654 -1616
- package/src/designer/tokens.js +9 -0
- package/src/engine/csv.js +350 -315
- package/src/engine/group.js +128 -65
- package/src/engine/index.js +35 -34
- package/src/engine/measure.js +13 -12
- package/src/engine/paginate.js +8 -4
- package/src/engine/resolve.js +37 -0
- package/src/engine/tables.js +87 -0
- package/src/engine/validate.js +97 -22
- package/src/index.html +79 -79
- package/src/index.js +51 -50
- package/src/preview/chrome.css +505 -505
- package/src/preview/chrome.js +147 -147
- package/src/preview/index.html +28 -28
- package/src/preview/viewer.js +763 -745
- package/src/react/designer.js +87 -0
- package/src/react/index.js +117 -0
- package/src/render/items.js +94 -1
- package/src/render/report.css +30 -0
- package/src/server/routes.js +331 -331
- package/src/shared/brand.css +29 -29
- package/src/shared/dropdown.css +136 -136
- package/src/shared/modal.css +125 -125
- package/src/shared/store.js +145 -145
- package/src/shared/theme.css +72 -72
- package/src/shared/window.js +138 -138
package/src/preview/chrome.js
CHANGED
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* chrome.js is the viewer's own markup: the toolbar, the floating pager and the
|
|
3
|
-
* export dialog.
|
|
4
|
-
*
|
|
5
|
-
* It lives here rather than in a page because the viewer is something an
|
|
6
|
-
* application mounts, and an API whose first instruction is "copy these 144
|
|
7
|
-
* lines of HTML into your app" is not an API. createDesigner has always taken
|
|
8
|
-
* one empty element and built what it needs inside it; this is the viewer
|
|
9
|
-
* catching up.
|
|
10
|
-
*
|
|
11
|
-
* Ids became data-roles on the way: an id may appear once in a document, and
|
|
12
|
-
* nothing should stop a page showing two reports side by side.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {object} [options]
|
|
18
|
-
* @param {string} [options.title] what the brand corner reads
|
|
19
|
-
* @returns {string} the whole of the viewer's chrome
|
|
20
|
-
*/
|
|
21
|
-
export function chrome({ title = 'Report Studio' } = {}) {
|
|
22
|
-
return `
|
|
23
|
-
<!--
|
|
24
|
-
A header, not role="toolbar": that role promises arrow-key roving focus
|
|
25
|
-
between the controls, and here the arrow keys page the report instead.
|
|
26
|
-
-->
|
|
27
|
-
<header class="toolbar" data-role="bar" aria-label="Report tools">
|
|
28
|
-
<div class="toolbar-brand">${title}</div>
|
|
29
|
-
|
|
30
|
-
<div class="toolbar-centre">
|
|
31
|
-
<div class="toolbar-group toolbar-search">
|
|
32
|
-
<!--
|
|
33
|
-
Buttons cannot live inside an <input>, so the wrapper draws
|
|
34
|
-
the field and the input inside it draws no chrome of its own.
|
|
35
|
-
-->
|
|
36
|
-
<div class="search-field">
|
|
37
|
-
<input type="search" data-role="query" placeholder="Search the report (ctrl+K)"
|
|
38
|
-
title="Search the report (ctrl+K)"
|
|
39
|
-
aria-label="Search the report" spellcheck="false">
|
|
40
|
-
<span class="hits" data-role="hits" data-state="idle" aria-live="polite"></span>
|
|
41
|
-
<button type="button" data-role="hit-prev" title="Previous match (shift+enter)"
|
|
42
|
-
aria-label="Previous match">↑</button>
|
|
43
|
-
<button type="button" data-role="hit-next" title="Next match (enter)"
|
|
44
|
-
aria-label="Next match">↓</button>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<div class="toolbar-group toolbar-zoom">
|
|
49
|
-
<button type="button" data-role="zoom-out" title="Zoom out (ctrl+-)"
|
|
50
|
-
aria-label="Zoom out">−</button>
|
|
51
|
-
|
|
52
|
-
<!--
|
|
53
|
-
A listbox rather than a <select>: option items are drawn by
|
|
54
|
-
the operating system, so they cannot take the palette.
|
|
55
|
-
-->
|
|
56
|
-
<div class="dropdown" data-role="zoom-dropdown">
|
|
57
|
-
<button type="button" class="dropdown-trigger" data-role="zoom"
|
|
58
|
-
aria-haspopup="listbox" aria-expanded="false" aria-label="Zoom level">
|
|
59
|
-
<span class="dropdown-value">100%</span>
|
|
60
|
-
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
61
|
-
</button>
|
|
62
|
-
|
|
63
|
-
<ul class="dropdown-menu" data-role="zoom-menu" role="listbox"
|
|
64
|
-
aria-label="Zoom level" hidden>
|
|
65
|
-
<li class="dropdown-item" role="option" tabindex="-1" data-value="fit">Fit width</li>
|
|
66
|
-
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.5">50%</li>
|
|
67
|
-
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.75">75%</li>
|
|
68
|
-
<li class="dropdown-item" role="option" tabindex="-1" data-value="1"
|
|
69
|
-
data-selected="true">100%</li>
|
|
70
|
-
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.25">125%</li>
|
|
71
|
-
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.5">150%</li>
|
|
72
|
-
<li class="dropdown-item" role="option" tabindex="-1" data-value="2">200%</li>
|
|
73
|
-
<li class="dropdown-item" role="option" tabindex="-1" data-value="3">300%</li>
|
|
74
|
-
</ul>
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
<button type="button" data-role="zoom-in" title="Zoom in (ctrl++)"
|
|
78
|
-
aria-label="Zoom in">+</button>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<div class="toolbar-group toolbar-save">
|
|
83
|
-
<button type="button" data-role="print" title="Print or save as PDF (ctrl+P)">
|
|
84
|
-
Print</button>
|
|
85
|
-
<button type="button" data-role="export" title="Export the report (ctrl+X)">
|
|
86
|
-
Export…</button>
|
|
87
|
-
</div>
|
|
88
|
-
</header>
|
|
89
|
-
|
|
90
|
-
<div class="viewport" data-role="viewport"></div>
|
|
91
|
-
|
|
92
|
-
<!-- paging floats over the report rather than taking a strip of it -->
|
|
93
|
-
<div class="pager" data-role="pager" role="toolbar" aria-label="Page navigation">
|
|
94
|
-
<button type="button" data-role="prev" title="Previous page (left arrow)"
|
|
95
|
-
aria-label="Previous page">‹</button>
|
|
96
|
-
|
|
97
|
-
<label class="page-of">
|
|
98
|
-
<input type="number" data-role="current" min="1" value="1" aria-label="Current page">
|
|
99
|
-
<span>of</span>
|
|
100
|
-
<span data-role="total">1</span>
|
|
101
|
-
</label>
|
|
102
|
-
|
|
103
|
-
<button type="button" data-role="next" title="Next page (right arrow)"
|
|
104
|
-
aria-label="Next page">›</button>
|
|
105
|
-
</div>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<!--
|
|
110
|
-
Hand-written rather than a <dialog>: the element is still unimplemented
|
|
111
|
-
in the environment the specs run in, and a stubbed showModal would test
|
|
112
|
-
the stub instead of the behaviour.
|
|
113
|
-
-->
|
|
114
|
-
<div class="modal" data-role="export-modal" hidden>
|
|
115
|
-
<div class="modal-backdrop" data-role="export-backdrop"></div>
|
|
116
|
-
|
|
117
|
-
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="export-title">
|
|
118
|
-
<h2 id="export-title">Export report</h2>
|
|
119
|
-
|
|
120
|
-
<div class="modal-formats" role="radiogroup" aria-labelledby="export-title">
|
|
121
|
-
<label class="format">
|
|
122
|
-
<input type="radio" name="export-format" value="pdf" checked>
|
|
123
|
-
<span class="format-body">
|
|
124
|
-
<span class="format-name">PDF</span>
|
|
125
|
-
<span class="format-note">Opens the print dialog - choose "Save as PDF"</span>
|
|
126
|
-
</span>
|
|
127
|
-
</label>
|
|
128
|
-
|
|
129
|
-
<label class="format">
|
|
130
|
-
<input type="radio" name="export-format" value="csv">
|
|
131
|
-
<span class="format-body">
|
|
132
|
-
<span class="format-name">CSV</span>
|
|
133
|
-
<span class="format-note">Every text line and table row, in report order</span>
|
|
134
|
-
</span>
|
|
135
|
-
</label>
|
|
136
|
-
</div>
|
|
137
|
-
|
|
138
|
-
<p class="modal-summary" data-role="export-summary" aria-live="polite"></p>
|
|
139
|
-
|
|
140
|
-
<div class="modal-actions">
|
|
141
|
-
<button type="button" data-role="export-cancel">Cancel</button>
|
|
142
|
-
<button type="button" class="is-primary" data-role="export-confirm">Export</button>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
`;
|
|
147
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* chrome.js is the viewer's own markup: the toolbar, the floating pager and the
|
|
3
|
+
* export dialog.
|
|
4
|
+
*
|
|
5
|
+
* It lives here rather than in a page because the viewer is something an
|
|
6
|
+
* application mounts, and an API whose first instruction is "copy these 144
|
|
7
|
+
* lines of HTML into your app" is not an API. createDesigner has always taken
|
|
8
|
+
* one empty element and built what it needs inside it; this is the viewer
|
|
9
|
+
* catching up.
|
|
10
|
+
*
|
|
11
|
+
* Ids became data-roles on the way: an id may appear once in a document, and
|
|
12
|
+
* nothing should stop a page showing two reports side by side.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {object} [options]
|
|
18
|
+
* @param {string} [options.title] what the brand corner reads
|
|
19
|
+
* @returns {string} the whole of the viewer's chrome
|
|
20
|
+
*/
|
|
21
|
+
export function chrome({ title = 'Report Studio' } = {}) {
|
|
22
|
+
return `
|
|
23
|
+
<!--
|
|
24
|
+
A header, not role="toolbar": that role promises arrow-key roving focus
|
|
25
|
+
between the controls, and here the arrow keys page the report instead.
|
|
26
|
+
-->
|
|
27
|
+
<header class="toolbar" data-role="bar" aria-label="Report tools">
|
|
28
|
+
<div class="toolbar-brand">${title}</div>
|
|
29
|
+
|
|
30
|
+
<div class="toolbar-centre">
|
|
31
|
+
<div class="toolbar-group toolbar-search">
|
|
32
|
+
<!--
|
|
33
|
+
Buttons cannot live inside an <input>, so the wrapper draws
|
|
34
|
+
the field and the input inside it draws no chrome of its own.
|
|
35
|
+
-->
|
|
36
|
+
<div class="search-field">
|
|
37
|
+
<input type="search" data-role="query" placeholder="Search the report (ctrl+K)"
|
|
38
|
+
title="Search the report (ctrl+K)"
|
|
39
|
+
aria-label="Search the report" spellcheck="false">
|
|
40
|
+
<span class="hits" data-role="hits" data-state="idle" aria-live="polite"></span>
|
|
41
|
+
<button type="button" data-role="hit-prev" title="Previous match (shift+enter)"
|
|
42
|
+
aria-label="Previous match">↑</button>
|
|
43
|
+
<button type="button" data-role="hit-next" title="Next match (enter)"
|
|
44
|
+
aria-label="Next match">↓</button>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="toolbar-group toolbar-zoom">
|
|
49
|
+
<button type="button" data-role="zoom-out" title="Zoom out (ctrl+-)"
|
|
50
|
+
aria-label="Zoom out">−</button>
|
|
51
|
+
|
|
52
|
+
<!--
|
|
53
|
+
A listbox rather than a <select>: option items are drawn by
|
|
54
|
+
the operating system, so they cannot take the palette.
|
|
55
|
+
-->
|
|
56
|
+
<div class="dropdown" data-role="zoom-dropdown">
|
|
57
|
+
<button type="button" class="dropdown-trigger" data-role="zoom"
|
|
58
|
+
aria-haspopup="listbox" aria-expanded="false" aria-label="Zoom level">
|
|
59
|
+
<span class="dropdown-value">100%</span>
|
|
60
|
+
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
61
|
+
</button>
|
|
62
|
+
|
|
63
|
+
<ul class="dropdown-menu" data-role="zoom-menu" role="listbox"
|
|
64
|
+
aria-label="Zoom level" hidden>
|
|
65
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="fit">Fit width</li>
|
|
66
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.5">50%</li>
|
|
67
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.75">75%</li>
|
|
68
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1"
|
|
69
|
+
data-selected="true">100%</li>
|
|
70
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.25">125%</li>
|
|
71
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.5">150%</li>
|
|
72
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="2">200%</li>
|
|
73
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="3">300%</li>
|
|
74
|
+
</ul>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<button type="button" data-role="zoom-in" title="Zoom in (ctrl++)"
|
|
78
|
+
aria-label="Zoom in">+</button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div class="toolbar-group toolbar-save">
|
|
83
|
+
<button type="button" data-role="print" title="Print or save as PDF (ctrl+P)">
|
|
84
|
+
Print</button>
|
|
85
|
+
<button type="button" data-role="export" title="Export the report (ctrl+X)">
|
|
86
|
+
Export…</button>
|
|
87
|
+
</div>
|
|
88
|
+
</header>
|
|
89
|
+
|
|
90
|
+
<div class="viewport" data-role="viewport"></div>
|
|
91
|
+
|
|
92
|
+
<!-- paging floats over the report rather than taking a strip of it -->
|
|
93
|
+
<div class="pager" data-role="pager" role="toolbar" aria-label="Page navigation">
|
|
94
|
+
<button type="button" data-role="prev" title="Previous page (left arrow)"
|
|
95
|
+
aria-label="Previous page">‹</button>
|
|
96
|
+
|
|
97
|
+
<label class="page-of">
|
|
98
|
+
<input type="number" data-role="current" min="1" value="1" aria-label="Current page">
|
|
99
|
+
<span>of</span>
|
|
100
|
+
<span data-role="total">1</span>
|
|
101
|
+
</label>
|
|
102
|
+
|
|
103
|
+
<button type="button" data-role="next" title="Next page (right arrow)"
|
|
104
|
+
aria-label="Next page">›</button>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
<!--
|
|
110
|
+
Hand-written rather than a <dialog>: the element is still unimplemented
|
|
111
|
+
in the environment the specs run in, and a stubbed showModal would test
|
|
112
|
+
the stub instead of the behaviour.
|
|
113
|
+
-->
|
|
114
|
+
<div class="modal" data-role="export-modal" hidden>
|
|
115
|
+
<div class="modal-backdrop" data-role="export-backdrop"></div>
|
|
116
|
+
|
|
117
|
+
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="export-title">
|
|
118
|
+
<h2 id="export-title">Export report</h2>
|
|
119
|
+
|
|
120
|
+
<div class="modal-formats" role="radiogroup" aria-labelledby="export-title">
|
|
121
|
+
<label class="format">
|
|
122
|
+
<input type="radio" name="export-format" value="pdf" checked>
|
|
123
|
+
<span class="format-body">
|
|
124
|
+
<span class="format-name">PDF</span>
|
|
125
|
+
<span class="format-note">Opens the print dialog - choose "Save as PDF"</span>
|
|
126
|
+
</span>
|
|
127
|
+
</label>
|
|
128
|
+
|
|
129
|
+
<label class="format">
|
|
130
|
+
<input type="radio" name="export-format" value="csv">
|
|
131
|
+
<span class="format-body">
|
|
132
|
+
<span class="format-name">CSV</span>
|
|
133
|
+
<span class="format-note">Every text line and table row, in report order</span>
|
|
134
|
+
</span>
|
|
135
|
+
</label>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<p class="modal-summary" data-role="export-summary" aria-live="polite"></p>
|
|
139
|
+
|
|
140
|
+
<div class="modal-actions">
|
|
141
|
+
<button type="button" data-role="export-cancel">Cancel</button>
|
|
142
|
+
<button type="button" class="is-primary" data-role="export-confirm">Export</button>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
`;
|
|
147
|
+
}
|
package/src/preview/index.html
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>Report Preview</title>
|
|
8
|
-
<link rel="icon" type="image/png" href="../asset/images/icon.png">
|
|
9
|
-
<link rel="stylesheet" href="./styles.css">
|
|
10
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
11
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
12
|
-
<link
|
|
13
|
-
href="https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400;1,700&family=Instrument+Sans:ital,wght@0,400..700;1,400..700&display=swap"
|
|
14
|
-
rel="stylesheet">
|
|
15
|
-
</head>
|
|
16
|
-
|
|
17
|
-
<body class="graph-paper">
|
|
18
|
-
<!--
|
|
19
|
-
The whole host-facing API: one empty element. createViewer builds its
|
|
20
|
-
toolbar, pager and export dialog inside this, so an application never
|
|
21
|
-
copies markup out of here to get a working viewer.
|
|
22
|
-
-->
|
|
23
|
-
<div id="report" class="report-fills-window"></div>
|
|
24
|
-
|
|
25
|
-
<script type="module" src="./main.js"></script>
|
|
26
|
-
</body>
|
|
27
|
-
|
|
28
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>Report Preview</title>
|
|
8
|
+
<link rel="icon" type="image/png" href="../asset/images/icon.png">
|
|
9
|
+
<link rel="stylesheet" href="./styles.css">
|
|
10
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
11
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
12
|
+
<link
|
|
13
|
+
href="https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400;1,700&family=Instrument+Sans:ital,wght@0,400..700;1,400..700&display=swap"
|
|
14
|
+
rel="stylesheet">
|
|
15
|
+
</head>
|
|
16
|
+
|
|
17
|
+
<body class="graph-paper">
|
|
18
|
+
<!--
|
|
19
|
+
The whole host-facing API: one empty element. createViewer builds its
|
|
20
|
+
toolbar, pager and export dialog inside this, so an application never
|
|
21
|
+
copies markup out of here to get a working viewer.
|
|
22
|
+
-->
|
|
23
|
+
<div id="report" class="report-fills-window"></div>
|
|
24
|
+
|
|
25
|
+
<script type="module" src="./main.js"></script>
|
|
26
|
+
</body>
|
|
27
|
+
|
|
28
|
+
</html>
|