angular-my-report 0.0.0-stage → 0.1.1

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 (45) hide show
  1. package/README.md +183 -2
  2. package/fesm2022/angular-my-report.mjs +7931 -0
  3. package/fesm2022/angular-my-report.mjs.map +1 -0
  4. package/index.d.ts +5 -0
  5. package/lib/engine/barcode.d.ts +17 -0
  6. package/lib/engine/chart.d.ts +26 -0
  7. package/lib/engine/chartLayout.d.ts +45 -0
  8. package/lib/engine/crosstab.d.ts +22 -0
  9. package/lib/engine/dataSources.d.ts +35 -0
  10. package/lib/engine/expressions.d.ts +46 -0
  11. package/lib/engine/measure.d.ts +7 -0
  12. package/lib/engine/parameters.d.ts +15 -0
  13. package/lib/engine/qr.d.ts +8 -0
  14. package/lib/engine/renderer.d.ts +43 -0
  15. package/lib/engine/table.d.ts +22 -0
  16. package/lib/model/defaults.d.ts +31 -0
  17. package/lib/model/factories.d.ts +31 -0
  18. package/lib/model/types.d.ts +244 -0
  19. package/lib/ui/css.d.ts +2 -0
  20. package/lib/ui/designer/banded-table-dialog.component.d.ts +27 -0
  21. package/lib/ui/designer/canvas.component.d.ts +41 -0
  22. package/lib/ui/designer/data-source-dialog.component.d.ts +37 -0
  23. package/lib/ui/designer/element-box.component.d.ts +32 -0
  24. package/lib/ui/designer/graphics.components.d.ts +36 -0
  25. package/lib/ui/designer/left-panel.component.d.ts +37 -0
  26. package/lib/ui/designer/safe-image.pipe.d.ts +13 -0
  27. package/lib/ui/designer/table-view.component.d.ts +19 -0
  28. package/lib/ui/designer.component.d.ts +59 -0
  29. package/lib/ui/designer.store.d.ts +82 -0
  30. package/lib/ui/inputs.d.ts +8 -0
  31. package/lib/ui/properties/band-props.component.d.ts +15 -0
  32. package/lib/ui/properties/element-props.component.d.ts +46 -0
  33. package/lib/ui/properties/expr-input.component.d.ts +43 -0
  34. package/lib/ui/properties/graphics-props.component.d.ts +52 -0
  35. package/lib/ui/properties/image-picker.component.d.ts +15 -0
  36. package/lib/ui/properties/properties-panel.component.d.ts +13 -0
  37. package/lib/ui/properties/report-extras.component.d.ts +40 -0
  38. package/lib/ui/properties/report-props.component.d.ts +34 -0
  39. package/lib/ui/properties/table-props.component.d.ts +31 -0
  40. package/lib/ui/viewer/page-view.component.d.ts +17 -0
  41. package/lib/ui/viewer/render.d.ts +43 -0
  42. package/lib/ui/viewer/viewer.component.d.ts +99 -0
  43. package/lib/ui/viewer.component.d.ts +40 -0
  44. package/package.json +34 -3
  45. package/public-api.d.ts +7 -0
package/README.md CHANGED
@@ -1,3 +1,184 @@
1
- # Temporary Holding Version
1
+ # angular-my-report
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/angular-my-report.svg)](https://www.npmjs.com/package/angular-my-report)
4
+ [![license](https://img.shields.io/npm/l/angular-my-report.svg)](https://www.npmjs.com/package/angular-my-report)
5
+
6
+ A banded report **designer** and **viewer** for Angular, shipped as two standalone components: `<myreport-designer>` and `<myreport-viewer>`.
7
+
8
+ Design a report in the browser, save it as a `.report.json` file, and show it in your app with live data from a JSON API, an OData service, or data you already have.
9
+
10
+ ## Features
11
+
12
+ - **Banded layout**: report header, page header, group headers, detail, group footers, page footer and report footer.
13
+ - **Elements**: text, data fields, lines, rectangles, images, tables, charts (bar, horizontal bar, line, area, pie, doughnut), crosstabs, barcodes (Code 128, EAN-13) and QR codes.
14
+ - **Expressions**: `{Field}`, `{sum(Amount)}`, `{PageNumber} of {TotalPages}`, `iif(...)`, string, number and date functions, and number, currency, percent and date formats.
15
+ - **Data**: JSON files and APIs, OData v2/v4 (with paging), or arrays you pass in.
16
+ - **Parameters**: bind values from your app or let users change them in the viewer.
17
+ - **Viewer**: paging, zoom, find, bookmarks, thumbnails, print, and export to PDF (via print), HTML, CSV and `.report.json`.
18
+ - **Self-contained styles**: scoped under `.myreport`, with no stylesheet to import and nothing leaking into your app.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ npm install angular-my-report
24
+ ```
25
+
26
+ ### Supported Angular versions
27
+
28
+ | Angular | Supported |
29
+ |---|---|
30
+ | 18.1 – 22.x | ✅ This package. Works with zone.js and zoneless apps. |
31
+ | 13 – 18.0 | Use [`angular-my-report-legacy`](https://www.npmjs.com/package/angular-my-report-legacy), which works on every version from 13 to 22. |
32
+
33
+ ## Quick start
34
+
35
+ ### 1. Design a report
36
+
37
+ ```ts
38
+ import { Component } from '@angular/core';
39
+ import { MyReportDesignerComponent, type ReportDefinition } from 'angular-my-report';
40
+
41
+ @Component({
42
+ selector: 'app-designer-page',
43
+ imports: [MyReportDesignerComponent],
44
+ template: `<myreport-designer persistKey="my-report" (save)="save($event)" />`,
45
+ styles: `myreport-designer { display: block; height: 100vh; }`,
46
+ })
47
+ export class DesignerPage {
48
+ save(report: ReportDefinition) {
49
+ // Send it to your API, or keep the .report.json file the Save button downloads.
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### 2. Show the report
55
+
56
+ Put the saved file in your app's `public/reports/` folder, then:
57
+
58
+ ```ts
59
+ import { Component } from '@angular/core';
60
+ import { MyReportViewerComponent } from 'angular-my-report';
61
+
62
+ @Component({
63
+ selector: 'app-sales-report',
64
+ imports: [MyReportViewerComponent],
65
+ template: `<myreport-viewer path="/reports/sales.report.json" datasource="/api/orders" type="json" />`,
66
+ styles: `myreport-viewer { display: block; height: 100vh; }`,
67
+ })
68
+ export class SalesReportPage {}
69
+ ```
70
+
71
+ Both components fill their container, so give them a height.
72
+
73
+ ## Viewer
74
+
75
+ ```html
76
+ <!-- The report's own data source -->
77
+ <myreport-viewer path="/reports/sales.report.json" />
78
+
79
+ <!-- JSON from your API -->
80
+ <myreport-viewer path="/reports/sales.report.json" datasource="/api/orders" type="json" />
81
+
82
+ <!-- OData: service root or full entity-set URL -->
83
+ <myreport-viewer path="/reports/orders.report.json" datasource="https://host/odata/Orders" type="odata" />
84
+
85
+ <!-- Data you already have, with parameters -->
86
+ <myreport-viewer path="/reports/sales.report.json" [datasource]="orders" [params]="{ Country: 'Egypt' }" />
87
+ ```
88
+
89
+ | Input | Type | Description |
90
+ |---|---|---|
91
+ | `path` | `string` | URL of the `.report.json` to show. |
92
+ | `report` | `ReportDefinition \| string` | A report to show (object or JSON). Used when `path` is empty. |
93
+ | `datasource` | `string \| array \| object` | The report's data. See [Data](#data). |
94
+ | `type` | `'json' \| 'odata'` | How a `datasource` URL is read. Default `json`. |
95
+ | `params` | `object \| string` | Parameter values. See [Parameters](#parameters). |
96
+ | `designerUrl` | `string` | Shows a "Designer" toolbar link to this URL. |
97
+ | `allowOpen` | `boolean` | Shows the toolbar Open button for local `.report.json` files. Default `true`. |
98
+
99
+ | Output | Payload |
100
+ |---|---|
101
+ | `loaded` | `ReportDefinition` |
102
+ | `dataLoaded` | The data rows |
103
+ | `loadError` | `string`, when the report or its data fails to load |
104
+
105
+ ## Designer
106
+
107
+ ```html
108
+ <myreport-designer
109
+ path="/reports/sales.report.json"
110
+ datasource="/api/orders"
111
+ [download]="false"
112
+ (save)="save($event)" />
113
+ ```
114
+
115
+ | Input | Type | Description |
116
+ |---|---|---|
117
+ | `path` | `string` | URL of a `.report.json` to open. |
118
+ | `report` | `ReportDefinition \| string` | A report to open (object or JSON). Used when `path` is empty. |
119
+ | `datasource` | `string \| array \| object` | Data to design against, replacing the report's data source. See [Data](#data). |
120
+ | `type` | `'json' \| 'odata'` | How a `datasource` URL is read. Default `json`. |
121
+ | `params` | `object \| string` | Parameter values. See [Parameters](#parameters). |
122
+ | `persistKey` | `string` | `localStorage` key to autosave to. When `path` and `report` are empty, the saved report is restored from it. |
123
+ | `viewerUrl` | `string` | Shows a "Viewer ↗" toolbar link to this URL. |
124
+ | `download` | `boolean` | Whether **Save** downloads a `.report.json`. Default `true`. `(save)` fires either way. |
125
+ | `brand` | `string` | Toolbar title. Default `My Report`. |
126
+
127
+ | Output | Payload |
128
+ |---|---|
129
+ | `save` | `ReportDefinition`, when the user clicks Save |
130
+ | `reportChange` | `ReportDefinition`, after every edit |
131
+ | `loaded` | `ReportDefinition`, after `path` loads |
132
+ | `loadError` | `string` |
133
+
134
+ ## Data
135
+
136
+ `datasource` replaces the data source saved in the report. Leave it empty to use the report's own.
137
+
138
+ - **URL with `type="json"`**: fetched as JSON. The array path saved in the report (for example `data.items`) still applies. If that path isn't in the response, the array is found automatically.
139
+ - **URL with `type="odata"`**: an OData v2/v4 service root or entity-set URL. The report's entity set, `$select`, `$filter`, `$orderby`, `$expand` and `$top` still apply, and `nextLink` paging is followed.
140
+ - **JSON string, array or object**: used as the data directly.
141
+
142
+ Request headers (for example `Authorization`) come from the report's data source settings.
143
+
144
+ ## Parameters
145
+
146
+ Pass values as an object (`{ Country: 'Egypt' }`), a JSON string, or a query string (`Country=Egypt&Year=2024`). They fill the report's parameters, are available as `@Country` in expressions and as `{@Country}` in data source URLs, and can be changed in the viewer's parameter bar.
147
+
148
+ ## Expressions
149
+
150
+ Text elements are templates. Anything inside `{ }` is evaluated:
151
+
152
+ | Example | Result |
153
+ |---|---|
154
+ | `{CustomerName}` | A field from the current row |
155
+ | `{sum(Amount)}` | Total for the current group, or for all rows in report bands |
156
+ | `{sum(Amount, report)}` | Total over all rows (scopes: `group`, `page`, `report`) |
157
+ | `{count()}`, `{avg(Price)}`, `{distinctcount(City)}` | Other aggregates: `min`, `max`, `first`, `last` |
158
+ | `Page {PageNumber} of {TotalPages}` | Page numbers |
159
+ | `{RowNumber}`, `{Today}`, `{Now}`, `{ReportName}` | Built-in values |
160
+ | `{iif(Amount > 1000, 'Large', 'Small')}` | Conditions |
161
+ | `{upper(Name)}`, `{formatdate(OrderDate, 'dd/MM/yyyy')}` | String and date functions |
162
+ | `{@Country}` | A parameter value |
163
+
164
+ ## Working with reports in code
165
+
166
+ The report model and helpers are exported as well:
167
+
168
+ ```ts
169
+ import {
170
+ newReport, sampleReport, receiptReport, // start a report (receiptReport(80) or receiptReport(58) for receipt printers)
171
+ loadData, detectDataSource, // load data the way the viewer does
172
+ overrideDataSource, // swap a report's data source
173
+ type ReportDefinition, type Band, type ReportElement,
174
+ } from 'angular-my-report';
175
+ ```
176
+
177
+ ## Other frameworks
178
+
179
+ - **React**: [`react-my-report`](https://www.npmjs.com/package/react-my-report)
180
+ - **Vue, Svelte, plain HTML or anything else** (Web Components): [`elements-my-report`](https://www.npmjs.com/package/elements-my-report)
181
+
182
+ ## License
183
+
184
+ MIT