@formancy/report-builder-angular 0.0.0-stage → 0.2.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.md ADDED
@@ -0,0 +1,161 @@
1
+ # Formancy Report Source-Available Licence
2
+
3
+ **Version 1 — in force from 14 October 2026. Not reviewed by a lawyer.**
4
+
5
+ This text states the terms Formancy Report is offered under. Version 1 is in
6
+ force from 14 October 2026. Its terms are those of the Formancy Data
7
+ Source-Available Licence, Version 1.1, with this product's names and with the
8
+ documents a reporting product generates named as yours. **This version has
9
+ not been reviewed by a lawyer.** It is published in the repository so that
10
+ the terms are visible to everyone who reads the source. Production licences,
11
+ which section 3 describes, can be had as section 9 says.
12
+
13
+ This is not an open-source licence. It is not Apache-2.0, and it is not the
14
+ licence of [formancy](https://github.com/sharkysan/formancy.ai), on which this
15
+ software builds and whose packages keep their own Apache-2.0 terms.
16
+
17
+ ## The terms in one table
18
+
19
+ | Use | Terms |
20
+ | --- | --- |
21
+ | Read the source and fork the repository | Free |
22
+ | Evaluate, develop and test — including in companies | Free |
23
+ | Run in production, internally or customer-facing | Paid licence |
24
+ | Redistribute inside another software product | Separate commercial agreement |
25
+ | Customer data, report templates and generated documents | Remain the customer's |
26
+
27
+ The rest of this document says what each row means.
28
+
29
+ ## 1. Definitions
30
+
31
+ **The Software** means the source code, declarations, documentation and
32
+ packages in this repository and the packages published from it under the
33
+ `@formancy/report-*` names, in any version, including modified versions.
34
+
35
+ **The Rightsholder** means Daniel Bacher, or whoever the Rightsholder later
36
+ designates in a revision of this document.
37
+
38
+ **Production Use** means running the Software, or anything that incorporates
39
+ it, in a way that serves real end users or real business operations: an
40
+ application people other than its developers and testers rely on, whether
41
+ inside one organisation or offered to others, whether or not it earns money.
42
+ Production is defined by operational use, not by revenue.
43
+
44
+ **Development Use** means any use that is not Production Use: reading,
45
+ evaluating, building, modifying, testing, demonstrating and running in
46
+ development, test, staging and continuous-integration environments, including
47
+ by and within a commercial organisation. A staging environment that real
48
+ users depend on is Production Use whatever it is called.
49
+
50
+ **Redistribution** means delivering the Software, or anything that
51
+ incorporates it, to a third party as part of a software product, a managed
52
+ service, a platform or a toolkit, such that the third party runs it rather
53
+ than you.
54
+
55
+ **Customer Data** means the contents of any dataset, submission, database or
56
+ file the Software is given or connects to, and anything the Software reads
57
+ from or writes to it.
58
+
59
+ **Generated Definitions** means the report definitions, templates, bindings,
60
+ styles, parameter forms, policies and other configuration the Software
61
+ generates or that a person creates with it, and the documents rendered from
62
+ them, PDF files included.
63
+
64
+ ## 2. What is free
65
+
66
+ Subject to section 4, the Rightsholder grants you a worldwide, royalty-free,
67
+ non-exclusive licence to:
68
+
69
+ 1. read, copy, fork and modify the Software;
70
+ 2. use the Software and your modifications for Development Use, without limit
71
+ of time, number of people or size of organisation;
72
+ 3. share the Software and your modifications with others for their
73
+ Development Use, under this licence and with this document attached.
74
+
75
+ No production licence is required to evaluate the Software for as long as you
76
+ like, and no evaluation period expires.
77
+
78
+ ## 3. What is paid
79
+
80
+ **Production Use requires a production licence from the Rightsholder.** A
81
+ production licence is a separate written agreement. It is expected to be
82
+ granted per application, to cover that application's development, test and
83
+ replica environments without further charge, to specify support and update
84
+ entitlements, and to leave you the right to keep running the versions you
85
+ licensed if you later choose not to renew. Those are intentions; the agreement
86
+ you sign is what governs.
87
+
88
+ **Redistribution requires a separate commercial agreement.** Shipping the
89
+ Software inside a product, a platform or a managed service that other parties
90
+ run is not covered by a production licence for your own applications.
91
+
92
+ Running the Software in production without a production licence is a breach of
93
+ this licence.
94
+
95
+ ## 4. Conditions
96
+
97
+ 1. **Notices travel.** A copy of this document, and the NOTICE file, stays
98
+ with every copy and every modified version of the Software.
99
+ 2. **Modified versions carry these terms.** A modified version of the Software
100
+ is the Software for the purposes of this licence. You may not remove or
101
+ circumvent the terms by modifying it.
102
+ 3. **No trademark grant.** This licence grants no right to use the names
103
+ "Formancy", "Formancy Report", "Formancy Report Studio", "formancy.ai" or
104
+ any associated logo, beyond what is needed to identify the Software
105
+ truthfully.
106
+ 4. **Third-party components keep their own licences.** The Software depends on
107
+ packages licensed under the Apache License, Version 2.0, among others. Those
108
+ licences continue to govern those components, their notices are preserved
109
+ in NOTICE, and nothing in this document narrows the rights they grant.
110
+
111
+ ## 5. What stays yours
112
+
113
+ **Customer Data remains the customer's.** This licence grants the Rightsholder
114
+ no right of any kind over the data the Software is given or reads, and the
115
+ Software is designed not to send any of it anywhere.
116
+
117
+ **Generated Definitions remain yours.** Report definitions, templates,
118
+ bindings and policies you generate or author with the Software, and the
119
+ documents rendered from them, are yours, under whatever terms you choose.
120
+ They are not the Software, and this licence does not restrict them —
121
+ including after a production licence ends. A logo, a font or another asset
122
+ you place in a report keeps the rights it came with.
123
+
124
+ ## 6. Contributions
125
+
126
+ Contributions to the Software are accepted under the Contributor License
127
+ Agreement in `CLA.md`, which grants the Rightsholder the right to distribute
128
+ them under this licence and under commercial agreements, and transfers no
129
+ ownership.
130
+
131
+ ## 7. Termination
132
+
133
+ Your rights under this licence end automatically if you breach it and do not
134
+ cure the breach within thirty days of becoming aware of it. The rights in
135
+ section 5 do not end: your data, your definitions and your documents stay
136
+ yours in every case.
137
+
138
+ ## 8. No warranty, limited liability
139
+
140
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
141
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
142
+ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
143
+ RIGHTSHOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
144
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
145
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
146
+
147
+ A production licence may provide warranties and support; this document does
148
+ not.
149
+
150
+ ## 9. Obtaining a production licence
151
+
152
+ Production licences are requested from the Rightsholder at info@formancy.ai.
153
+ The separate commercial agreement that Redistribution requires, which
154
+ section 3 describes, is requested at the same address. The Software is new
155
+ and has no published price; the plan is to set the price after the first
156
+ design partners have established what the Software is worth to them.
157
+
158
+ ## 10. Governing law and place of jurisdiction
159
+
160
+ This licence is governed by Swiss law, excluding its conflict-of-laws rules.
161
+ The place of jurisdiction is the Rightsholder's domicile in Switzerland.
package/NOTICE ADDED
@@ -0,0 +1,17 @@
1
+ Formancy Report
2
+ Copyright 2026 Daniel Bacher
3
+
4
+ This product is distributed under the Formancy Report Source-Available Licence
5
+ (LICENSE.md). It is not open source.
6
+
7
+ This product includes software developed by the formancy project
8
+ (https://github.com/sharkysan/formancy.ai), licensed under the Apache License,
9
+ Version 2.0. Those packages keep their licence; nothing here changes it.
10
+
11
+ @formancy/report-render-pdf includes the Liberation Sans fonts, version
12
+ 2.1.5, Regular and Bold, in its fonts directory and, as base64, in its
13
+ browser build. Digitized data copyright (c) 2010 Google Corporation, with
14
+ Reserved Font Arimo, Tinos and Cousine. Copyright (c) 2012 Red Hat, Inc.,
15
+ with Reserved Font Name Liberation. They are licensed under the SIL Open
16
+ Font License, Version 1.1, whose text travels with them as
17
+ fonts/LICENSE-LiberationSans.txt; nothing here changes it.
package/README.md CHANGED
@@ -1,3 +1,255 @@
1
- # Temporary Holding Version
1
+ # @formancy/report-builder-angular
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
+ Formancy Report Studio's report editor for Angular, written natively: standalone
4
+ components, signals and `OnPush`, running without zone.js. It renders
5
+ [`@formancy/report-builder-core`](../report-builder-core/README.md)'s state and
6
+ sends that package's actions back. It decides nothing of its own about a
7
+ report: which key does what, what may go where, what is available, how a field
8
+ is labelled and what it is called in German are all report-builder-core's. The
9
+ React builder renders the same state, and neither builder depends on the other
10
+ ([0012](../../docs/decisions/0012-the-builders-are-native-and-share-one-session.md)).
11
+ Nothing of React is in this package's dependency closure (plan 21). The package
12
+ suite walks the installed tree to show it, and
13
+ `scripts/finalize-angular-dist.test.mjs` reads the built code.
14
+
15
+ ## Use
16
+
17
+ ```ts
18
+ import { Component, OnDestroy } from '@angular/core'
19
+ import { ReportBuilder } from '@formancy/report-builder-angular'
20
+ import { createReportEditor } from '@formancy/report-builder-core'
21
+ import { openReportSession } from '@formancy/report-core'
22
+
23
+ const opening = openReportSession(definition)
24
+ if (!opening.ok) throw new Error('not a report')
25
+
26
+ @Component({
27
+ selector: 'app-studio',
28
+ imports: [ReportBuilder],
29
+ template: `<report-builder [editor]="editor" />`,
30
+ })
31
+ export class Studio implements OnDestroy {
32
+ // The host makes the editor and disposes of it. The builder only listens.
33
+ readonly editor = createReportEditor(opening.session, { locale: 'de-CH' })
34
+
35
+ ngOnDestroy(): void {
36
+ this.editor.dispose()
37
+ }
38
+ }
39
+ ```
40
+
41
+ The host page dresses it. It imports `@formancy/themes`' `workbench.css`
42
+ first, then `@formancy/report-builder-core/report-builder.css`. This package
43
+ ships no stylesheet and no component styles. Its elements carry only the
44
+ `data-report-part` hooks, their `data-*` states and the workbench's classes
45
+ that the core's stylesheet selects by, so the Angular and React builders are
46
+ dressed by the same rules.
47
+
48
+ **The document and its undo history are the session's.** A builder subscribes
49
+ to its editor while it is mounted and unsubscribes when it is destroyed. A
50
+ builder destroyed and made again over the same editor shows the same document
51
+ and can undo what the first one did, and the editor's `listenerCount()` is back
52
+ where it started. Given another `[editor]`, the builder draws and acts on the
53
+ new one and lets the old one go. Plan 21's switch (edit, put the builder and
54
+ its editor away, undo in a builder in another language, switch back, redo)
55
+ runs in `src/builder.test.ts` over one session. Its React half is the React
56
+ builder's suite and report-builder-core's model test.
57
+
58
+ ## What it renders
59
+
60
+ Exactly the structure report-builder-core's README sets out under *What a
61
+ builder renders*, which the React builder renders too: a region named
62
+ "Report editor" with a bar above the panes (the title and the toolbar, with
63
+ its four pane buttons), the outline pane with the place chooser floating
64
+ over it, the design view -- or the host's view in its place -- the
65
+ properties and the problems sharing the third column, and a bar below with
66
+ the live region. Every name comes from the core's catalogue in English,
67
+ Swiss German and Swiss French.
68
+
69
+ What is Angular's own:
70
+
71
+ - **The element is the editor's root.** `<report-builder>` carries the
72
+ root's role, name, hooks and `data-panel` through a host directive,
73
+ `ReportEditorRoot`.
74
+ - **Focus moves after a render.** An action that moves focus asks the root,
75
+ and the root moves it in `afterEveryRender`, once what the action changed
76
+ is in the document. Every action comes from one of the builder's own
77
+ listeners, which marks the view for check, so a render follows even an
78
+ action that changed nothing.
79
+ - **The host's view is a template.** A host whose editor was made with a
80
+ view of its own gives it as `<ng-template reportHostView>`, and the builder
81
+ stamps it into the design view's place while the editor's `view` is the
82
+ host's
83
+ ([0029](../../docs/decisions/0029-the-preview-stands-in-the-design-views-place-where-it-does-not-fit-beside-the-builder.md)):
84
+
85
+ ```html
86
+ <report-builder [editor]="editor">
87
+ <ng-template reportHostView><app-preview /></ng-template>
88
+ </report-builder>
89
+ ```
90
+
91
+ A template, not projected content, because Angular makes projected
92
+ content once whether its slot is drawn or not: the host's view lives only
93
+ while it is drawn, and the toolbar's Design view destroys it. The builder
94
+ stamps it with `@angular/core` alone, since `NgTemplateOutlet` is
95
+ `@angular/common`'s, which is not this package's peer. A key pressed in
96
+ it is the host's.
97
+ - **Images a person adds** need nothing of the host but the editor's
98
+ store (`createReportEditor`'s `images`, [0033](../../docs/decisions/0033-a-person-adds-an-image-in-either-builder-and-the-host-keeps-its-bytes.md)): the palette draws Add
99
+ image… last, and beside it the hidden file input, an `<input>` the
100
+ `ReportImageChooser` directive holds, which Add image… opens in the same
101
+ click once `chooseImage` is done; the file chosen is taken, the input
102
+ cleared, and handed to `editor.addImage`. The report's own properties
103
+ list its images, each with its Remove, which puts the keyboard on the
104
+ first field only once the image is gone (`ReportEditorRoot.attempt`).
105
+ - **Drag and drop is HTML's**, from the palette, from a canvas box or from an
106
+ outline row, onto the sheet (the nearest place, `targetNear`, read inside
107
+ the sheet's border) or onto a row (before or after it, `targetBeside`). A
108
+ drag the editor did not start -- a file from the desktop -- is not
109
+ accepted. React drags with pointer events instead, over the same places.
110
+
111
+ ## A layout of your own
112
+
113
+ `<report-builder>` is the root directive and the parts in the workbench's
114
+ panes. A host that wants another arrangement puts the root on its own element
115
+ and the parts inside it:
116
+
117
+ ```html
118
+ <div [reportEditor]="editor">
119
+ <div reportToolbar></div>
120
+ <div reportPalette></div>
121
+ <div reportOutline></div>
122
+ <section reportCanvas></section>
123
+ <form reportProperties></form>
124
+ <div reportProblems></div>
125
+ <p reportStatus></p>
126
+ <div reportPlaces></div>
127
+ </div>
128
+ ```
129
+
130
+ Each part is an attribute on the element it is, so the DOM has no wrapper
131
+ elements the React builder lacks. The bars, the panes' headers, the Report
132
+ button and the problems' count are `<report-builder>`'s template, not parts;
133
+ a host that arranges the parts itself writes its own, and draws its own
134
+ view where the state's `view` says, in place of `reportCanvas`. The parts inject
135
+ `ReportEditorRoot`, which holds the state as a signal and the editor's words.
136
+ It also routes key presses through `actionForKey`, dispatches, and moves
137
+ focus. `injectEditorState(editorSignal)` is the same signal for a host's own
138
+ views. It is set on each of the editor's notifications, not built with
139
+ `toSignal`, so no RxJS is needed. Its subscription is an effect's: it follows
140
+ the editor the input names, and is let go when the view is destroyed.
141
+
142
+ ## Building
143
+
144
+ `pnpm --filter @formancy/report-builder-angular build` runs ng-packagr, which
145
+ compiles in partial mode into `dist/`, and then
146
+ [`scripts/finalize-angular-dist.mjs`](../../scripts/finalize-angular-dist.mjs).
147
+ An Angular library publishes from `dist/`, and ng-packagr's `dist/package.json`
148
+ is wrong there in four ways. The script fixes each of them:
149
+
150
+ - it rewrites `workspace:` ranges as pnpm publishes them;
151
+ - it sets `files` to what `dist/` holds, where the source's `["dist", …]`
152
+ would pack no code;
153
+ - it drops the redirect into `dist/` from `publishConfig` and keeps `access`;
154
+ - it copies `LICENSE.md` and `NOTICE` into `dist/` as part of the build, so
155
+ turbo's cache restores them.
156
+
157
+ It refuses a manifest whose `license` is not the source-available one.
158
+
159
+ ng-packagr type-checks the published sources against its own configuration,
160
+ with the library ES2018 and strict templates, and the build passes it no other.
161
+ So the sources stay within ES2018's library: no `flatMap`, no `Object.hasOwn`.
162
+ `pnpm typecheck` reads them with ES2023 and does not see this; the build does.
163
+
164
+ ## Tests
165
+
166
+ `pnpm --filter @formancy/report-builder-angular test:coverage` runs them
167
+ under jsdom with zoneless change detection, as an application on Angular 22
168
+ runs.
169
+
170
+ - **Every `BUILDER_SCENARIOS` scenario**, in English, Swiss German and Swiss
171
+ French. Each step finds elements by role and accessible name only, but an
172
+ `upload`, which finds the hidden file input beside Add image… in the DOM,
173
+ since it has no role; and each scenario ends with axe over the whole page at WCAG 2.2 AA, as formancy.ai's
174
+ conformance suite audits. A scenario left out, or a kind of step never
175
+ taken, fails the file.
176
+ - **The accessible tree:** every element a person operates or reads is
177
+ named, with every row of every kind selected in turn; the editor is a
178
+ landmark with everything inside it (axe's `region` rule); boxes and places
179
+ are pictures named as the outline and the chooser name them; rows say
180
+ where they stand among their siblings. Each group, the form, the list,
181
+ the statuses and the place chooser are named in the editor's words, never
182
+ after text on the page, which Chromium would read in the stylesheet's
183
+ capitals; jsdom applies no stylesheet, so that test reads from the DOM
184
+ how each name is given. The Studio compares this tree with the React
185
+ builder's, in jsdom and in Chromium.
186
+ - **The builder's life:** destroyed and made again, given another editor, and
187
+ plan 21's switch over one session.
188
+ - **Keyboard, panes, pointer and properties** behaviour beyond the
189
+ scenarios, the keyboard kept on a problem when another is listed before
190
+ it among them. Each property of every component kind is found by its role
191
+ and name, and axe runs on each selection in turn.
192
+ - **The stylesheet's hooks:** the parts rendered are exactly `REPORT_PARTS`,
193
+ the design view's and the host's view's together, since the two are never
194
+ drawn at once; the `data-*` states are exactly those `REPORT_ATTRIBUTES`
195
+ lists, and the classes are only the workbench's.
196
+ - **The host's view**: a bare region in the design view's place, with the
197
+ middle pane's `data-pane`, its own part, no workbench class and only the
198
+ host's view in it, stamped while the region is drawn and destroyed with
199
+ it. That test reads the DOM, for the reason the hooks' tests do.
200
+ - **Images**: `image-chooser.test.ts` gives the file input `files` and a
201
+ `value` that behave as a browser's, where clearing the value empties the
202
+ files, and holds the file taken before the input is cleared, the input
203
+ cleared, a chooser closed without a file doing nothing, the keyboard on
204
+ Add image… while an image is added and after, Enter and a click opening
205
+ the chooser, no chooser where the editor takes no file, nothing drawn
206
+ without a store, and the host's types offered; `properties.test.ts` holds
207
+ the image rows. Space is not fired here; the Studio's browser gate
208
+ presses it (`apps/studio/scripts/gate-images.mjs`).
209
+ - **The dependency closure:** the manifest, the installed tree and every
210
+ import the published entry reaches. No React anywhere, and nothing imported
211
+ that is not declared.
212
+
213
+ Each test was seen to fail with the behaviour it guards taken out, except
214
+ three:
215
+
216
+ - The two that walk the installed tree for React could only fail if React
217
+ were installed under this package, which this work did not do.
218
+ - The one that keeps a click's focus from arriving late passes whatever the
219
+ builder does, because Angular renders after every listener. It guards
220
+ against that changing.
221
+
222
+ The scenarios name user-event, but this package's devDependencies do not
223
+ include it yet. Until they do, `src/test-user.ts` fires the events user-event
224
+ fires for the steps the scenarios take, using Testing Library's `fireEvent`.
225
+ It does not type keystroke by keystroke, follow a pointer's path, or activate
226
+ on Space's key up.
227
+
228
+ What this package's tests do not show: layout, colour and contrast, which
229
+ jsdom does not compute; drag and drop with a real pointer, which is
230
+ dispatched as synthetic events; and focus as a real browser moves it on Tab.
231
+ The Studio's browser gate (`apps/studio/scripts/browser-test.mjs`) measures
232
+ those in Chromium for this builder in the Studio's page, a real pointer's
233
+ drag included, and the root README's pictures of it are taken by a script
234
+ and held to the text they show
235
+ ([0013](../../docs/decisions/0013-the-studio-is-the-same-room-and-its-pictures-are-taken-by-a-script.md));
236
+ a host's own page is its own to measure.
237
+
238
+ ## What it does not do
239
+
240
+ - **Nothing draws it in a browser yet.** The install gate compiles it into
241
+ an Angular host ahead of time with strict templates, links it as the
242
+ Angular CLI does, draws it on a server with `@angular/platform-server` and
243
+ bundles it for a browser, at the newest and the oldest Angular 22 its peer
244
+ range admits. What happens after the markup -- focus, keys, a pointer, a
245
+ re-render after an edit -- is this package's suite, in jsdom.
246
+ - **Text that is not a number never reaches the editor from a number field.**
247
+ A browser empties an `<input type="number">` holding "tall" before any
248
+ change event fires, so the field says "This cannot be empty." rather than
249
+ "Enter a number.".
250
+ - **Most touch browsers fire no HTML drag and drop.** There, as everywhere,
251
+ the place chooser is the path to every place.
252
+ - **No measured cost.** Rendering a long report's outline and design view has
253
+ not been timed.
254
+
255
+ Source-available, not open source: see [`LICENSE.md`](../../LICENSE.md).