@formancy/report-builder-react 0.1.0 → 0.3.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/NOTICE +8 -0
- package/README.md +108 -7
- package/dist/index.d.mts +11 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +498 -142
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/NOTICE
CHANGED
|
@@ -7,3 +7,11 @@ This product is distributed under the Formancy Report Source-Available Licence
|
|
|
7
7
|
This product includes software developed by the formancy project
|
|
8
8
|
(https://github.com/sharkysan/formancy.ai), licensed under the Apache License,
|
|
9
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
|
@@ -45,11 +45,82 @@ geometry. The host imports `workbench.css` from `@formancy/themes`, then
|
|
|
45
45
|
`report-builder.css` from `report-builder-core`, and recolours the builder
|
|
46
46
|
by setting the workbench's `--wb-*` variables.
|
|
47
47
|
|
|
48
|
-
**`ReportBuilder` takes
|
|
48
|
+
**`ReportBuilder` takes the `editor`.** The builder subscribes while
|
|
49
49
|
it is mounted and never disposes the editor. Whoever created the editor
|
|
50
50
|
disposes it, once no builder shows it. Given another editor, the builder
|
|
51
51
|
lets go of the old one and subscribes to the new one.
|
|
52
52
|
|
|
53
|
+
**`hostView` is what it draws in the design view's place** while the
|
|
54
|
+
editor's `view` is the host's: a view of the host's own, which the editor
|
|
55
|
+
was made knowing by name
|
|
56
|
+
([0029](../../docs/decisions/0029-the-preview-stands-in-the-design-views-place-where-it-does-not-fit-beside-the-builder.md)).
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const editor = createReportEditor(opening.session, { hostView: { name: 'Preview', shown: true } })
|
|
60
|
+
|
|
61
|
+
root.render(<ReportBuilder editor={editor} hostView={<Preview />} />)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The builder lends it the middle pane's box and a region named by the
|
|
65
|
+
editor's `hostView`. No rule of `report-builder.css` reaches it, and of
|
|
66
|
+
the workbench's only `.wb *`, which turns transitions off when motion is
|
|
67
|
+
reduced; none of the builder's keys do either, nor from a portal the host
|
|
68
|
+
opens from it, whose events React bubbles through the view wherever its
|
|
69
|
+
DOM is. It is mounted only while it is drawn: the toolbar's Design view
|
|
70
|
+
unmounts it, and the editor's `showHostView` mounts it again.
|
|
71
|
+
|
|
72
|
+
**Images a person adds need nothing of the builder.** A host that keeps
|
|
73
|
+
them gives the editor its store (`createReportEditor`'s `images`,
|
|
74
|
+
report-builder-core's *Images a person adds*), and the builder draws Add
|
|
75
|
+
image… last in the palette, with a hidden file input beside it, and the
|
|
76
|
+
report's images, each with its Remove, under the report's own properties
|
|
77
|
+
([0033](../../docs/decisions/0033-a-person-adds-an-image-in-either-builder-and-the-host-keeps-its-bytes.md)). Add image… sends `chooseImage` and opens the platform's chooser
|
|
78
|
+
in the same click; the file chosen is taken, the input cleared so the same
|
|
79
|
+
file is a change again, and handed to `editor.addImage`, which says what
|
|
80
|
+
became of it. The keyboard stays on the button; a Remove that removed its
|
|
81
|
+
image puts it on the first field.
|
|
82
|
+
|
|
83
|
+
**A report's QR-bill is selected and edited like a component**
|
|
84
|
+
([0039](../../docs/decisions/0039-a-person-selects-a-reports-qr-bill-and-edits-it-field-by-field-in-either-builder.md)): its row stands in the outline after the regions, its band
|
|
85
|
+
on the canvas selects it with a click, and the properties draw its fields
|
|
86
|
+
and its parties as groups, each a `group` named in the editor's words with
|
|
87
|
+
its one button, Remove debtor or Add debtor, which keeps the keyboard as
|
|
88
|
+
its words change. Add QR-bill, in the report's own properties, takes its
|
|
89
|
+
button away with them, and the keyboard goes to the bill's IBAN, as it
|
|
90
|
+
does when a Remove takes its row.
|
|
91
|
+
|
|
92
|
+
**A report's e-invoice is selected and edited the same way**
|
|
93
|
+
([0044](../../docs/decisions/0044-a-person-edits-a-reports-e-invoice-in-either-builder-one-term-a-field-in-groups.md)): its row stands after the bill's, and its properties are
|
|
94
|
+
groups -- the parties, the seller's contact, each VAT category, the list's
|
|
95
|
+
Add, the lines, the payment instructions, an XRechnung's own terms -- each
|
|
96
|
+
with its buttons. One with nowhere to go, the first category's Move up, is
|
|
97
|
+
`aria-disabled` and still sent. Where a button's action says where the
|
|
98
|
+
keyboard goes once it is done (`then`), the builder puts it there once the
|
|
99
|
+
change is drawn: a category moved keeps the keyboard on the same button of
|
|
100
|
+
the group it went to, one removed hands it to the list's Add, and one
|
|
101
|
+
added to its first field.
|
|
102
|
+
|
|
103
|
+
**A report written in several languages**
|
|
104
|
+
([0063](../../docs/decisions/0063-a-reports-own-words-are-written-in-each-language-it-declares-and-a-render-names-the-one-it-prints-in.md))
|
|
105
|
+
has a switch between them in the bar, a native `<select>` beside the
|
|
106
|
+
title that dispatches `setLanguage`, drawn only while the report declares
|
|
107
|
+
more than one; a language is added from the report's own properties, its
|
|
108
|
+
Languages group's Add language. In another language than the report's
|
|
109
|
+
own, a field at a word writes its translation, its note drawn under it
|
|
110
|
+
and describing it, and a box or a field whose word is missing there is
|
|
111
|
+
marked `data-missing`, the box described as missing by its `title`.
|
|
112
|
+
|
|
113
|
+
**A run of a paragraph is set below or above the line from its group**
|
|
114
|
+
([0061](../../docs/decisions/0061-a-paragraphs-run-may-be-set-below-or-above-the-line-in-any-character-its-face-draws-and-prints-only-beside-a-run-on-the-line.md)): each run is a group with two buttons, Subscript and
|
|
115
|
+
Superscript, each showing its word, named after the run by `aria-label`
|
|
116
|
+
("Part 2: Text, subscript") and `aria-pressed` as the run is set.
|
|
117
|
+
Pressed, one reads the selection of its group's text field and the text it
|
|
118
|
+
is of from the element, the one thing it reads from the DOM to send, and
|
|
119
|
+
adds them to the action; the editor decides what it sets, and the
|
|
120
|
+
keyboard goes where the outcome's `then` says, the pressed button of the
|
|
121
|
+
run that holds the text now. A run bound to a value is a select, and is
|
|
122
|
+
set whole.
|
|
123
|
+
|
|
53
124
|
**`useEditorState(editor)`** is the subscription on its own, for a host
|
|
54
125
|
that shows something of the editor's state outside the builder.
|
|
55
126
|
|
|
@@ -80,10 +151,12 @@ and go without losing anything, and two builders can share one session:
|
|
|
80
151
|
|
|
81
152
|
Exactly the structure `report-builder-core`'s README sets out under *What a
|
|
82
153
|
builder renders*, which the Angular builder renders too: a region named
|
|
83
|
-
"Report editor" with a bar above the panes (the title
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
154
|
+
"Report editor" with a bar above the panes (the title, the switch between
|
|
155
|
+
the report's languages where it is written in more than one, and the
|
|
156
|
+
toolbar, with its four pane buttons), the outline pane with the place dialog
|
|
157
|
+
floating over it, the design view -- or the host's view in its place --
|
|
158
|
+
the properties and the problems sharing the third column, and a bar below
|
|
159
|
+
with the live region.
|
|
87
160
|
|
|
88
161
|
## The keyboard
|
|
89
162
|
|
|
@@ -102,10 +175,12 @@ keyboard path came first.
|
|
|
102
175
|
| Anywhere but a text field | Ctrl and +, −, 0 | Zooms in, out, to actual size. |
|
|
103
176
|
| 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
177
|
| A palette entry, Move to… | Enter, Space | Opens the place dialog. Focus goes to its first place. |
|
|
178
|
+
| Add image… | Enter, Space | Opens the platform's file chooser. Focus stays on the button while the image is added and after. |
|
|
105
179
|
| The place dialog | Enter on a place | Inserts or moves there. Focus goes to the row. |
|
|
106
180
|
| 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
181
|
| A single-line field | Enter | Commits the value, and stays in the field. |
|
|
108
182
|
| A text field | Escape | Gives back what the report holds. |
|
|
183
|
+
| The host's view | Any | The host's, and a portal's the host opens from it. The builder passes none of them on, so Ctrl+Z there undoes nothing of the report. |
|
|
109
184
|
|
|
110
185
|
The keys in the outline and the editor's shortcuts are `actionForKey`'s,
|
|
111
186
|
decided in `report-builder-core` for both builders. A text field, a
|
|
@@ -163,7 +238,9 @@ jsdom with Testing Library and user-event:
|
|
|
163
238
|
|
|
164
239
|
- **Every one of `BUILDER_SCENARIOS`, in all three languages.** Each
|
|
165
240
|
scenario runs step by step, with axe over its end state. A last test
|
|
166
|
-
fails when a scenario was skipped or lost.
|
|
241
|
+
fails when a scenario was skipped or lost. A `selectText` step selects
|
|
242
|
+
characters with the field's own `setSelectionRange`, since user-event's
|
|
243
|
+
keyboard extends no selection with Shift and an arrow (0061).
|
|
167
244
|
- **axe** holds the builder to WCAG 2.2 AA by its tags (`wcag2a` through
|
|
168
245
|
`wcag22aa`). `best-practice` is left out, as formancy.ai's builders leave
|
|
169
246
|
it out. Two rules are off because jsdom cannot decide them:
|
|
@@ -177,13 +254,32 @@ jsdom with Testing Library and user-event:
|
|
|
177
254
|
property. Each group, the form, the list, the statuses and the dialog
|
|
178
255
|
are named in the editor's words, never after text on the page, which
|
|
179
256
|
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.
|
|
257
|
+
stylesheet, so that test reads from the DOM how each name is given. A
|
|
258
|
+
run's buttons show their word, are named after the run and say whether
|
|
259
|
+
they are pressed, which that test reads from the DOM too, as no query
|
|
260
|
+
by role and name returns what a button shows (0061).
|
|
181
261
|
- **The keyboard, focus and the pointer** beyond the scenarios: the
|
|
182
262
|
toolbar's tab stop and its arrows, focus after each action, the dialog's
|
|
183
263
|
way out, the panes, a text field's own keys, every pointer drag above,
|
|
184
264
|
the pointer read inside the sheet's border, and the keyboard kept on a
|
|
185
265
|
problem when another is listed before it.
|
|
266
|
+
- **Images**: `image-chooser.test.tsx` gives the file input `files` and a
|
|
267
|
+
`value` that behave as a browser's, where clearing the value empties the
|
|
268
|
+
files, and holds the file taken before the input is cleared, the input
|
|
269
|
+
cleared, a chooser closed without a file doing nothing, the keyboard on
|
|
270
|
+
Add image… while an image is added and after, Enter and Space opening
|
|
271
|
+
the chooser, no chooser where the editor takes no file, nothing drawn
|
|
272
|
+
without a store, and the host's types offered. `properties.test.tsx`
|
|
273
|
+
holds the image rows. These, and the scenarios' `upload`, find the file
|
|
274
|
+
input beside the button in the DOM: it has no role.
|
|
186
275
|
- **One session, many builders**, as above.
|
|
276
|
+
- **The host's view**: a bare region in the design view's place, with the
|
|
277
|
+
middle pane's `data-pane`, its own part, no workbench class and only the
|
|
278
|
+
host's node in it, which is mounted while the region is drawn and
|
|
279
|
+
unmounted with it; and a key pressed in a portal the host opens from it,
|
|
280
|
+
Ctrl+Z on a menu in the body, undoes nothing. That test reads the DOM,
|
|
281
|
+
because which rules reach the host's view is a stylesheet's reach, which
|
|
282
|
+
the accessibility tree cannot show.
|
|
187
283
|
|
|
188
284
|
Each guard was watched failing with the code it guards removed. Among
|
|
189
285
|
them: the subscription left behind on unmount, ids shared between two
|
|
@@ -207,6 +303,11 @@ new child, the sheet's border, and a modified arrow taken by the toolbar.
|
|
|
207
303
|
- **The place dialog's "nowhere" sentence** shows when a component has
|
|
208
304
|
nowhere else to go. No report tried here has such a component. The test
|
|
209
305
|
draws the dialog over a state that says so.
|
|
306
|
+
- **Text that is not a number never reaches the editor from a number field.**
|
|
307
|
+
A browser empties an `<input type="number">` holding "tall" before any
|
|
308
|
+
change event fires, so the field says "This cannot be empty." rather than
|
|
309
|
+
"Enter a number.", and an optional one is emptied: the rows a group
|
|
310
|
+
header is kept with, emptied, are 1 again, the member's absence (0059).
|
|
210
311
|
- Everything `report-builder-core` lists under *What it does not do*
|
|
211
312
|
holds here too: the canvas is not the PDF, some properties have no
|
|
212
313
|
editor yet, and two problems about the report as a whole share a name.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from "react";
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { EditorState, ReportEditor } from "@formancy/report-builder-core";
|
|
3
|
-
//#region src/report-builder.d.ts
|
|
4
3
|
interface ReportBuilderProps {
|
|
5
4
|
/**
|
|
6
5
|
* The editor to render: one person's view of a report session. The
|
|
@@ -8,12 +7,18 @@ interface ReportBuilderProps {
|
|
|
8
7
|
* whoever created it does, once no builder shows it.
|
|
9
8
|
*/
|
|
10
9
|
readonly editor: ReportEditor;
|
|
10
|
+
/**
|
|
11
|
+
* What the builder draws in the design view's place while the editor's
|
|
12
|
+
* `view` is the host's: the host's own view, named by the editor's
|
|
13
|
+
* `hostView`. The builder lends it the middle pane's box and a region's
|
|
14
|
+
* name, none of report-builder.css's rules -- the workbench's `.wb *`
|
|
15
|
+
* reaches it, turning transitions off under reduced motion -- and none of
|
|
16
|
+
* its keys; it is mounted only while drawn.
|
|
17
|
+
*/
|
|
18
|
+
readonly hostView?: ReactNode;
|
|
11
19
|
}
|
|
12
|
-
export declare function ReportBuilder({ editor }: ReportBuilderProps): ReactElement;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/use-editor-state.d.ts
|
|
20
|
+
export declare function ReportBuilder({ editor, hostView }: ReportBuilderProps): ReactElement;
|
|
15
21
|
/** Re-renders the component on every change to `editor`'s state; unsubscribes when it unmounts or the editor is replaced. */
|
|
16
22
|
export declare function useEditorState(editor: ReportEditor): EditorState;
|
|
17
|
-
//#endregion
|
|
18
23
|
export type { ReportBuilderProps };
|
|
19
24
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/report-builder.tsx","../src/use-editor-state.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/report-builder.tsx","../src/use-editor-state.ts"],"mappings":";;UA2DiB;;;;;;WAMN,QAAQ;;;;;;;;;WASR,WAAW;;wBAiBN,gBAAgB,QAAQ,YAAY,qBAAqB;;wBC7EzD,eAAe,QAAQ,eAAe"}
|