@formancy/report-builder-react 0.0.0-stage → 0.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.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,9 @@
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.
package/README.md CHANGED
@@ -1,3 +1,214 @@
1
- # Temporary Holding Version
1
+ # @formancy/report-builder-react
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 builder for React. It renders the three
4
+ panes of the workbench over one
5
+ [`report-builder-core`](../report-builder-core/README.md) editor: the
6
+ palette and the outline, the design view, and the properties with the
7
+ problems. A toolbar sits above them and a status line below.
8
+
9
+ It renders the editor's state and dispatches what the person did. It
10
+ decides nothing the editor decides: the keys are `actionForKey`'s, the
11
+ places a component may go are the editor's drop targets, what is
12
+ available is the editor's `can`, and every word comes from the editor's
13
+ catalogue. What is React's is the subscription (`useSyncExternalStore`),
14
+ the DOM, and focus, because only the builder knows which element the
15
+ person was on. The Angular builder renders the same state, and neither
16
+ depends on the other
17
+ ([0012](../../docs/decisions/0012-the-builders-are-native-and-share-one-session.md)).
18
+
19
+ ## Mounting it
20
+
21
+ ```tsx
22
+ import '@formancy/themes/workbench.css'
23
+ import '@formancy/report-builder-core/report-builder.css'
24
+ import { createReportEditor } from '@formancy/report-builder-core'
25
+ import { openReportSession } from '@formancy/report-core'
26
+ import { ReportBuilder } from '@formancy/report-builder-react'
27
+
28
+ const opening = openReportSession(report)
29
+ if (!opening.ok) throw new Error('not a report')
30
+ const editor = createReportEditor(opening.session, { locale: 'de-CH' })
31
+
32
+ // The builder fills its container; the host gives the container a height.
33
+ root.render(
34
+ <div style={{ height: '100vh' }}>
35
+ <ReportBuilder editor={editor} />
36
+ </div>,
37
+ )
38
+
39
+ // Once no builder shows it:
40
+ editor.dispose()
41
+ ```
42
+
43
+ The package imports no CSS and sets no style of its own but the state's
44
+ geometry. The host imports `workbench.css` from `@formancy/themes`, then
45
+ `report-builder.css` from `report-builder-core`, and recolours the builder
46
+ by setting the workbench's `--wb-*` variables.
47
+
48
+ **`ReportBuilder` takes one prop, `editor`.** The builder subscribes while
49
+ it is mounted and never disposes the editor. Whoever created the editor
50
+ disposes it, once no builder shows it. Given another editor, the builder
51
+ lets go of the old one and subscribes to the new one.
52
+
53
+ **`useEditorState(editor)`** is the subscription on its own, for a host
54
+ that shows something of the editor's state outside the builder.
55
+
56
+ The panes are not exported as components of their own. Focus moves
57
+ between them: a place chosen in the dialog focuses its outline row, and a
58
+ problem followed focuses the row it is about. That coordination belongs
59
+ to the builder as a whole.
60
+
61
+ ### One session, many builders
62
+
63
+ The document and its undo history live in the session, and the editor
64
+ holds only one person's view of it (plan 11.4). So the builder can come
65
+ and go without losing anything, and two builders can share one session:
66
+
67
+ - **Unmounted and mounted again** over the same editor, it shows the same
68
+ document and can undo the edit made before it went away. The editor's
69
+ listener count is back where it was after each unmount.
70
+ - **Given another editor** over the same session, in another language, it
71
+ undoes the step the first one made, and the first editor has no listener
72
+ left. This is plan 21's switch between two React editors. The Angular
73
+ half of the switch is the Angular builder's to show.
74
+ - **Two builders on one page** stay in step: an edit in one shows in the
75
+ other, and each keeps its own selection. No element id is minted twice
76
+ (`useId`). A duplicated id would label the second builder's fields with
77
+ the first builder's labels, and a test fails on exactly that.
78
+
79
+ ## What it renders
80
+
81
+ Exactly the structure `report-builder-core`'s README sets out under *What a
82
+ builder renders*, which the Angular builder renders too: a region named
83
+ "Report editor" with a bar above the panes (the title and the toolbar,
84
+ with its four pane buttons), the outline pane with the place dialog
85
+ floating over it, the design view, the properties and the problems
86
+ sharing the third column, and a bar below with the live region.
87
+
88
+ ## The keyboard
89
+
90
+ Every pointer action has a keyboard path (formancy.ai 0046), and the
91
+ keyboard path came first.
92
+
93
+ | Where | Keys | Does |
94
+ | --- | --- | --- |
95
+ | The outline | ↑ ↓, Home, End | Selects the previous, next, first or last row. Focus follows. |
96
+ | The outline | ← → | Selects what holds the row, or the first thing it holds. |
97
+ | The outline | Alt+↑, Alt+↓ | Moves the selection up or down its list. |
98
+ | The outline | Alt+→, Alt+← | Moves it into the container before it, or out of its own. |
99
+ | The outline | Delete, Backspace | Deletes it. Focus goes to the next row, else the one before, else the tree. |
100
+ | The outline | Ctrl+D (⌘D) | Duplicates it, and selects the copy. |
101
+ | Anywhere but a text field | Ctrl+Z, Ctrl+Y, Ctrl+Shift+Z | Undoes, redoes. In the outline, focus goes to the selected row, else to the tree itself, never to a row nothing selected. |
102
+ | Anywhere but a text field | Ctrl and +, −, 0 | Zooms in, out, to actual size. |
103
+ | The toolbar | ← →, Home, End | Moves between tools. The toolbar is one tab stop. → is "next" in a left-to-right page and "previous" under `dir="rtl"`; with Ctrl, Alt or ⌘ held the arrow is the browser's. |
104
+ | A palette entry, Move to… | Enter, Space | Opens the place dialog. Focus goes to its first place. |
105
+ | The place dialog | Enter on a place | Inserts or moves there. Focus goes to the row. |
106
+ | The place dialog | Escape, Cancel | Closes it. Focus goes back to what opened it; for a dialog another builder over the same editor opened, to the palette entry of what is placed, else the selected row, else the tree. |
107
+ | A single-line field | Enter | Commits the value, and stays in the field. |
108
+ | A text field | Escape | Gives back what the report holds. |
109
+
110
+ The keys in the outline and the editor's shortcuts are `actionForKey`'s,
111
+ decided in `report-builder-core` for both builders. A text field, a
112
+ number field and a select keep their own keys: Ctrl+Z there undoes
113
+ typing, not the report. A checkbox has no typing to undo, so Ctrl+Z on it
114
+ undoes the report.
115
+
116
+ **Focus follows the selection.** Moving focus to a row selects it. Every
117
+ action that selects moves focus to that row: a place chosen, a box
118
+ clicked, a problem followed. So a screen reader says what was selected as
119
+ the focused row's name and state. The editor does not say it again in the
120
+ live region.
121
+
122
+ A tool with nothing to act on is `aria-disabled`, not `disabled`, and
123
+ `report-builder.css` draws it as the workbench draws a disabled button. It
124
+ stays focusable, so pressing Redo for the last time does not throw focus
125
+ out of the toolbar. Pressing such a tool says why nothing happened
126
+ ("Nothing to undo.").
127
+
128
+ ## The pointer
129
+
130
+ A palette entry, a box or an outline row can be dragged. It can be dropped
131
+ on the canvas, at the nearest place in the list under the pointer
132
+ (`targetNear`, read inside the sheet's border), or over an outline row,
133
+ before or after it (`targetBeside`). The drag is the editor's state
134
+ machine: `startDrag`, `updateDrag`, `drop`, `cancelDrag`. A pointer is
135
+ never offered a place the session would refuse, and it is offered exactly
136
+ the places the dialog lists.
137
+
138
+ A press becomes a drag only after it moves 4 CSS pixels, Windows' default
139
+ drag distance (a convention, not a measurement). A click stays a click: it
140
+ opens the dialog, or selects a box. Escape, the browser cancelling the
141
+ pointer, and the builder unmounting all end a drag with nothing placed.
142
+ Letting go over nothing says "Nothing was moved." Only the primary button
143
+ of a mouse or pen drags. A touch never starts a drag, so a finger scrolls
144
+ the page as it expects to, and a tap is a click. The Angular builder drags
145
+ with HTML's drag and drop instead, over the same places.
146
+
147
+ ## The words, and what is said aloud
148
+
149
+ Every word the builder shows comes from `report-builder-core`'s catalogue,
150
+ in English, Swiss German and Swiss French, and none is written here.
151
+
152
+ The status line is a polite live region. Each announcement is a new child
153
+ element, so the same words said twice ("Nothing to undo.") are two
154
+ announcements. The zoom `<output>` has `aria-live="off"`: the status line
155
+ already says "Zoom 125%.", and an `<output>` would say it a second time.
156
+ The problems' count is a `status` of its own, so a problem an edit causes
157
+ is announced ("Problems 1") without moving the person.
158
+
159
+ ## What the tests show
160
+
161
+ `pnpm --filter @formancy/report-builder-react test` runs the suite in
162
+ jsdom with Testing Library and user-event:
163
+
164
+ - **Every one of `BUILDER_SCENARIOS`, in all three languages.** Each
165
+ scenario runs step by step, with axe over its end state. A last test
166
+ fails when a scenario was skipped or lost.
167
+ - **axe** holds the builder to WCAG 2.2 AA by its tags (`wcag2a` through
168
+ `wcag22aa`). `best-practice` is left out, as formancy.ai's builders leave
169
+ it out. Two rules are off because jsdom cannot decide them:
170
+ `color-contrast` (jsdom computes no colour) and `target-size` (jsdom
171
+ lays nothing out). The reason for each is written beside it in
172
+ `test-support.tsx`.
173
+ - **Every part, named.** One report holds every kind of component. Each
174
+ row is selected in turn, so every kind of property control is drawn and
175
+ audited. Every element with a role a person operates or reads must have
176
+ a name. A test fails if no row of that report shows some kind of
177
+ property. Each group, the form, the list, the statuses and the dialog
178
+ are named in the editor's words, never after text on the page, which
179
+ Chromium would read in the stylesheet's capitals; jsdom applies no
180
+ stylesheet, so that test reads from the DOM how each name is given.
181
+ - **The keyboard, focus and the pointer** beyond the scenarios: the
182
+ toolbar's tab stop and its arrows, focus after each action, the dialog's
183
+ way out, the panes, a text field's own keys, every pointer drag above,
184
+ the pointer read inside the sheet's border, and the keyboard kept on a
185
+ problem when another is listed before it.
186
+ - **One session, many builders**, as above.
187
+
188
+ Each guard was watched failing with the code it guards removed. Among
189
+ them: the subscription left behind on unmount, ids shared between two
190
+ builders, the drag distance, the swallowed click, focus returned after
191
+ Escape, `aria-disabled` turned into `disabled`, an announcement without a
192
+ new child, the sheet's border, and a modified arrow taken by the toolbar.
193
+
194
+ ## What it does not do
195
+
196
+ - **No browser runs in this package's suite.** jsdom has no layout, so
197
+ the suite does not test the three-pane and narrow layouts, scrolling,
198
+ contrast or target sizes, and its pointer tests place the pointer by the
199
+ editor's own pixel geometry. The Studio's browser gate
200
+ (`apps/studio/scripts/browser-test.mjs`) measures them in Chromium for
201
+ this builder in the Studio's page, a real pointer's drag from the
202
+ palette included, and compares its accessible tree with the Angular
203
+ builder's; the root README's pictures of it are taken by a
204
+ script and held to the text they show
205
+ ([0013](../../docs/decisions/0013-the-studio-is-the-same-room-and-its-pictures-are-taken-by-a-script.md));
206
+ a host's own page is its own to measure.
207
+ - **The place dialog's "nowhere" sentence** shows when a component has
208
+ nowhere else to go. No report tried here has such a component. The test
209
+ draws the dialog over a state that says so.
210
+ - Everything `report-builder-core` lists under *What it does not do*
211
+ holds here too: the canvas is not the PDF, some properties have no
212
+ editor yet, and two problems about the report as a whole share a name.
213
+
214
+ Source-available, not open source: see [`LICENSE.md`](../../LICENSE.md).
@@ -0,0 +1,19 @@
1
+ import { ReactElement } from "react";
2
+ import { EditorState, ReportEditor } from "@formancy/report-builder-core";
3
+ //#region src/report-builder.d.ts
4
+ interface ReportBuilderProps {
5
+ /**
6
+ * The editor to render: one person's view of a report session. The
7
+ * builder subscribes while it is mounted and never disposes the editor;
8
+ * whoever created it does, once no builder shows it.
9
+ */
10
+ readonly editor: ReportEditor;
11
+ }
12
+ export declare function ReportBuilder({ editor }: ReportBuilderProps): ReactElement;
13
+ //#endregion
14
+ //#region src/use-editor-state.d.ts
15
+ /** Re-renders the component on every change to `editor`'s state; unsubscribes when it unmounts or the editor is replaced. */
16
+ export declare function useEditorState(editor: ReportEditor): EditorState;
17
+ //#endregion
18
+ export type { ReportBuilderProps };
19
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/report-builder.tsx","../src/use-editor-state.ts"],"mappings":";;;UAgCiB;;;;;;WAMN,QAAQ;;wBAgBH,gBAAgB,UAAU,qBAAqB;;;;wBCxC/C,eAAe,QAAQ,eAAe"}