report-studio 0.0.1 → 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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +363 -4
  3. package/dist/designer-qy59eEux.js +3416 -0
  4. package/dist/designer.js +2 -0
  5. package/dist/index.js +2 -4
  6. package/dist/react-designer.js +41 -0
  7. package/dist/react.js +58 -2
  8. package/dist/viewer-xa17tyMJ.js +1721 -0
  9. package/package.json +65 -18
  10. package/src/asset/images/icon.png +0 -0
  11. package/src/asset/images/logo.png +0 -0
  12. package/src/cli/index.js +282 -0
  13. package/src/cli/serve.js +135 -0
  14. package/src/designer/blank.js +53 -0
  15. package/src/designer/canvas.js +518 -0
  16. package/src/designer/designer.js +2054 -0
  17. package/src/designer/dialog.js +708 -0
  18. package/src/designer/fields.js +633 -0
  19. package/src/designer/geometry.js +154 -0
  20. package/src/designer/guides.js +370 -0
  21. package/src/designer/history.js +113 -0
  22. package/src/designer/icons.js +123 -0
  23. package/src/designer/index.html +28 -0
  24. package/src/designer/main.js +39 -0
  25. package/src/designer/menu.js +126 -0
  26. package/src/designer/panel.js +498 -0
  27. package/src/designer/preview.js +95 -0
  28. package/src/designer/rulers.js +231 -0
  29. package/src/designer/sample-data.js +411 -0
  30. package/src/designer/select.js +699 -0
  31. package/src/designer/structure.js +685 -0
  32. package/src/designer/styles.css +1654 -0
  33. package/src/designer/toast.js +62 -0
  34. package/src/designer/tokens.js +293 -0
  35. package/src/engine/csv.js +350 -0
  36. package/src/engine/group.js +367 -0
  37. package/src/engine/index.js +35 -0
  38. package/src/engine/measure.js +391 -0
  39. package/src/engine/paginate.js +865 -0
  40. package/src/engine/regions.js +175 -0
  41. package/src/engine/resolve.js +208 -0
  42. package/src/engine/search.js +129 -0
  43. package/src/engine/tables.js +87 -0
  44. package/src/engine/text-metrics.js +206 -0
  45. package/src/engine/validate.js +403 -0
  46. package/src/index.html +79 -0
  47. package/src/index.js +51 -0
  48. package/src/preview/chrome.css +505 -0
  49. package/src/preview/chrome.js +147 -0
  50. package/src/preview/index.html +28 -0
  51. package/src/preview/main.js +66 -0
  52. package/src/preview/styles.css +16 -0
  53. package/src/preview/viewer.js +763 -0
  54. package/src/react/designer.js +87 -0
  55. package/src/react/index.js +117 -0
  56. package/src/render/items.js +518 -0
  57. package/src/render/render.js +98 -0
  58. package/src/render/report.css +232 -0
  59. package/src/server/routes.js +331 -0
  60. package/src/shared/brand.css +29 -0
  61. package/src/shared/dropdown.css +136 -0
  62. package/src/shared/dropdown.js +166 -0
  63. package/src/shared/modal.css +125 -0
  64. package/src/shared/prefix.js +13 -0
  65. package/src/shared/store.js +145 -0
  66. package/src/shared/theme.css +72 -0
  67. package/src/shared/window.js +138 -0
  68. package/src/vite/index.js +53 -0
@@ -0,0 +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>
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The preview page's entry.
3
+ *
4
+ * /preview/?report=<id> a saved report, with its data file
5
+ * /preview/?fixture the sales-summary fixture, for poking at
6
+ *
7
+ * There is almost nothing here, which is the point: the viewer takes one empty
8
+ * element and builds the rest. This page is what any application using it looks
9
+ * like, rather than a special arrangement of markup the library depends on.
10
+ */
11
+
12
+ import { buildPages } from '../engine/index.js';
13
+ import { createViewer } from './viewer.js';
14
+ import { createStore } from '../shared/store.js';
15
+
16
+ const params = new URLSearchParams(location.search);
17
+ const wanted = params.get('report');
18
+
19
+
20
+ async function load() {
21
+ if (wanted) {
22
+ const store = createStore();
23
+
24
+ const [layout, data] = await Promise.all([
25
+ store.load(wanted),
26
+ store.loadData(wanted)
27
+ ]);
28
+
29
+ /**
30
+ * A report with no data file still renders - the placeholders come out
31
+ * empty, which is a truthful preview of a report nobody has supplied
32
+ * data for, and better than refusing to draw it.
33
+ */
34
+ return { layout, data: data ?? {} };
35
+ }
36
+
37
+ const { rptJson, rptData } = await import('../../fixtures/test-data.js');
38
+ return { layout: rptJson, data: rptData };
39
+ }
40
+
41
+
42
+ load().then(({ layout, data }) => {
43
+ /** handy from the devtools console while poking at a layout */
44
+ window.viewer = createViewer({
45
+ mount: '#report',
46
+ paginated: buildPages(layout, data),
47
+ title: layout.name || 'Report Studio'
48
+ });
49
+ }).catch(error => {
50
+ document.getElementById('report').innerHTML = `
51
+ <div class="viewer-problem" role="alert">
52
+ <h2>Nothing to preview</h2>
53
+ <p>${escapeText(error?.message ?? String(error))}</p>
54
+ <p>Open a report with <code>?report=&lt;name&gt;</code>.</p>
55
+ </div>`;
56
+
57
+ console.warn(error);
58
+ });
59
+
60
+
61
+ function escapeText(value) {
62
+ return String(value ?? '')
63
+ .replace(/&/g, '&amp;')
64
+ .replace(/</g, '&lt;')
65
+ .replace(/>/g, '&gt;');
66
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The preview screen's stylesheet, and the one file a consumer links.
3
+ *
4
+ * It is the shared layers plus the viewer's own chrome, in that order, so an
5
+ * application that links `report-studio/viewer.css` and nothing else gets a
6
+ * working viewer. The chrome lives in chrome.css beside chrome.js, because the
7
+ * designer needs it too - it mounts a viewer into a window it builds from its
8
+ * own stylesheets - and importing this file there would pull the shared layers
9
+ * in a second time.
10
+ */
11
+
12
+ @import "../shared/theme.css";
13
+ @import "../render/report.css";
14
+ @import "../shared/modal.css";
15
+ @import "../shared/dropdown.css";
16
+ @import "./chrome.css";