angular-my-report 0.1.0 → 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 (88) hide show
  1. package/README.md +124 -40
  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 +16 -5
  45. package/{src/public-api.ts → public-api.d.ts} +0 -5
  46. package/ng-package.json +0 -7
  47. package/src/lib/engine/barcode.ts +0 -118
  48. package/src/lib/engine/chart.ts +0 -85
  49. package/src/lib/engine/chartLayout.ts +0 -265
  50. package/src/lib/engine/crosstab.ts +0 -96
  51. package/src/lib/engine/dataSources.ts +0 -204
  52. package/src/lib/engine/expressions.ts +0 -734
  53. package/src/lib/engine/measure.ts +0 -62
  54. package/src/lib/engine/parameters.ts +0 -96
  55. package/src/lib/engine/qr.ts +0 -26
  56. package/src/lib/engine/renderer.ts +0 -324
  57. package/src/lib/engine/table.ts +0 -58
  58. package/src/lib/model/defaults.ts +0 -249
  59. package/src/lib/model/factories.ts +0 -324
  60. package/src/lib/model/types.ts +0 -281
  61. package/src/lib/ui/css.ts +0 -12
  62. package/src/lib/ui/designer/banded-table-dialog.component.ts +0 -127
  63. package/src/lib/ui/designer/canvas.component.ts +0 -281
  64. package/src/lib/ui/designer/data-source-dialog.component.ts +0 -201
  65. package/src/lib/ui/designer/element-box.component.ts +0 -138
  66. package/src/lib/ui/designer/graphics.components.ts +0 -140
  67. package/src/lib/ui/designer/left-panel.component.ts +0 -189
  68. package/src/lib/ui/designer/safe-image.pipe.ts +0 -16
  69. package/src/lib/ui/designer/table-view.component.ts +0 -120
  70. package/src/lib/ui/designer.component.ts +0 -296
  71. package/src/lib/ui/designer.store.ts +0 -230
  72. package/src/lib/ui/inputs.ts +0 -34
  73. package/src/lib/ui/myreport.css +0 -267
  74. package/src/lib/ui/properties/band-props.component.ts +0 -86
  75. package/src/lib/ui/properties/element-props.component.ts +0 -326
  76. package/src/lib/ui/properties/expr-input.component.ts +0 -191
  77. package/src/lib/ui/properties/graphics-props.component.ts +0 -260
  78. package/src/lib/ui/properties/image-picker.component.ts +0 -62
  79. package/src/lib/ui/properties/properties-panel.component.ts +0 -37
  80. package/src/lib/ui/properties/report-extras.component.ts +0 -198
  81. package/src/lib/ui/properties/report-props.component.ts +0 -211
  82. package/src/lib/ui/properties/table-props.component.ts +0 -197
  83. package/src/lib/ui/viewer/page-view.component.ts +0 -73
  84. package/src/lib/ui/viewer/render.ts +0 -161
  85. package/src/lib/ui/viewer/viewer.component.ts +0 -555
  86. package/src/lib/ui/viewer.component.ts +0 -107
  87. package/tsconfig.lib.json +0 -12
  88. package/tsconfig.lib.prod.json +0 -5
package/README.md CHANGED
@@ -1,51 +1,79 @@
1
- # @mohamed351/angular
1
+ # angular-my-report
2
2
 
3
- Banded report designer and viewer for Angular, as two standalone components.
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
4
21
 
5
22
  ```bash
6
- npm install @mohamed351/angular
23
+ npm install angular-my-report
7
24
  ```
8
25
 
9
- Requires Angular 19.2 or later. The styles are bundled with the components and scoped under `.myreport`, so there is no stylesheet to import and nothing leaks into your app.
26
+ ### Supported Angular versions
10
27
 
11
- ## Designer
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
12
36
 
13
37
  ```ts
14
- import { MyReportDesignerComponent, type ReportDefinition } from '@mohamed351/angular';
38
+ import { Component } from '@angular/core';
39
+ import { MyReportDesignerComponent, type ReportDefinition } from 'angular-my-report';
15
40
 
16
41
  @Component({
42
+ selector: 'app-designer-page',
17
43
  imports: [MyReportDesignerComponent],
18
- template: `<myreport-designer path="/reports/sales.report.json" [download]="false" (save)="store($event)" />`,
19
- styles: `myreport-designer { height: 100vh; }`,
44
+ template: `<myreport-designer persistKey="my-report" (save)="save($event)" />`,
45
+ styles: `myreport-designer { display: block; height: 100vh; }`,
20
46
  })
21
47
  export class DesignerPage {
22
- store(report: ReportDefinition) { /* POST it to your API */ }
48
+ save(report: ReportDefinition) {
49
+ // Send it to your API, or keep the .report.json file the Save button downloads.
50
+ }
23
51
  }
24
52
  ```
25
53
 
26
- | Input | Type | Description |
27
- |---|---|---|
28
- | `path` | `string` | URL of a `.report.json` to open. |
29
- | `report` | `ReportDefinition \| string` | A report to open (object or JSON). Used when `path` is empty. |
30
- | `datasource` | `string \| array \| object` | Data to design against, replacing the report's data source. See [Data](#data). |
31
- | `type` | `'json' \| 'odata'` | How `datasource` is read. Default `json`. |
32
- | `params` | `object \| string` | Parameter values. See [Parameters](#parameters). |
33
- | `persistKey` | `string` | `localStorage` key to autosave to. When `path` and `report` are empty, the saved report is restored from it. |
34
- | `viewerUrl` | `string` | Shows a "Viewer ↗" toolbar link to this URL. |
35
- | `download` | `boolean` | Whether **Save** downloads a `.report.json`. Default `true`. `(save)` fires either way. |
36
- | `brand` | `string` | Toolbar title. Default `My Report`. |
54
+ ### 2. Show the report
37
55
 
38
- | Output | Payload |
39
- |---|---|
40
- | `save` | `ReportDefinition`, when the user clicks Save |
41
- | `reportChange` | `ReportDefinition`, after every edit |
42
- | `loaded` | `ReportDefinition`, after `path` loaded |
43
- | `loadError` | `string` |
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.
44
72
 
45
73
  ## Viewer
46
74
 
47
75
  ```html
48
- <!-- the report's own data source -->
76
+ <!-- The report's own data source -->
49
77
  <myreport-viewer path="/reports/sales.report.json" />
50
78
 
51
79
  <!-- JSON from your API -->
@@ -54,8 +82,8 @@ export class DesignerPage {
54
82
  <!-- OData: service root or full entity-set URL -->
55
83
  <myreport-viewer path="/reports/orders.report.json" datasource="https://host/odata/Orders" type="odata" />
56
84
 
57
- <!-- data you already have -->
58
- <myreport-viewer path="/reports/sales.report.json" [datasource]="orders" />
85
+ <!-- Data you already have, with parameters -->
86
+ <myreport-viewer path="/reports/sales.report.json" [datasource]="orders" [params]="{ Country: 'Egypt' }" />
59
87
  ```
60
88
 
61
89
  | Input | Type | Description |
@@ -63,7 +91,7 @@ export class DesignerPage {
63
91
  | `path` | `string` | URL of the `.report.json` to show. |
64
92
  | `report` | `ReportDefinition \| string` | A report to show (object or JSON). Used when `path` is empty. |
65
93
  | `datasource` | `string \| array \| object` | The report's data. See [Data](#data). |
66
- | `type` | `'json' \| 'odata'` | How `datasource` is read. Default `json`. |
94
+ | `type` | `'json' \| 'odata'` | How a `datasource` URL is read. Default `json`. |
67
95
  | `params` | `object \| string` | Parameter values. See [Parameters](#parameters). |
68
96
  | `designerUrl` | `string` | Shows a "Designer" toolbar link to this URL. |
69
97
  | `allowOpen` | `boolean` | Shows the toolbar Open button for local `.report.json` files. Default `true`. |
@@ -71,30 +99,86 @@ export class DesignerPage {
71
99
  | Output | Payload |
72
100
  |---|---|
73
101
  | `loaded` | `ReportDefinition` |
74
- | `dataLoaded` | the data rows |
75
- | `loadError` | `string`, for a report or data load failure |
102
+ | `dataLoaded` | The data rows |
103
+ | `loadError` | `string`, when the report or its data fails to load |
76
104
 
77
- The viewer has paging, zoom, find, bookmarks, thumbnails, parameters, print, and export to PDF (via the print dialog), HTML, CSV and `.report.json`.
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` |
78
133
 
79
134
  ## Data
80
135
 
81
136
  `datasource` replaces the data source saved in the report. Leave it empty to use the report's own.
82
137
 
83
- - **URL, `type="json"`**: fetched as JSON. The report's array path (for example `data.items`) still applies. If that path is missing from the response, the array is detected automatically.
84
- - **URL, `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.
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.
85
140
  - **JSON string, array or object**: used as the data directly.
86
141
 
87
142
  Request headers (for example `Authorization`) come from the report's data source settings.
88
143
 
89
144
  ## Parameters
90
145
 
91
- 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 used as `@Country` in formulas and `{@Country}` in data source URLs, and can be changed in the viewer's parameter bar.
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.
92
147
 
93
- ## Also exported
148
+ ## Expressions
94
149
 
95
- The report model types (`ReportDefinition`, `Band`, `ReportElement` and others), `newReport()`, `receiptReport(width)`, `loadData()` and `detectDataSource()`.
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
+ ```
96
176
 
97
177
  ## Other frameworks
98
178
 
99
- - React: [`@mohamed351/react`](https://www.npmjs.com/package/@mohamed351/react)
100
- - Any framework or plain HTML (Web Components): [`@mohamed351/elements`](https://www.npmjs.com/package/@mohamed351/elements)
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