@formancy/report-builder-react 0.2.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/README.md CHANGED
@@ -80,6 +80,47 @@ file is a change again, and handed to `editor.addImage`, which says what
80
80
  became of it. The keyboard stays on the button; a Remove that removed its
81
81
  image puts it on the first field.
82
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
+
83
124
  **`useEditorState(editor)`** is the subscription on its own, for a host
84
125
  that shows something of the editor's state outside the builder.
85
126
 
@@ -110,8 +151,9 @@ and go without losing anything, and two builders can share one session:
110
151
 
111
152
  Exactly the structure `report-builder-core`'s README sets out under *What a
112
153
  builder renders*, which the Angular builder renders too: a region named
113
- "Report editor" with a bar above the panes (the title and the toolbar,
114
- with its four pane buttons), the outline pane with the place dialog
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
115
157
  floating over it, the design view -- or the host's view in its place --
116
158
  the properties and the problems sharing the third column, and a bar below
117
159
  with the live region.
@@ -196,7 +238,9 @@ jsdom with Testing Library and user-event:
196
238
 
197
239
  - **Every one of `BUILDER_SCENARIOS`, in all three languages.** Each
198
240
  scenario runs step by step, with axe over its end state. A last test
199
- 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).
200
244
  - **axe** holds the builder to WCAG 2.2 AA by its tags (`wcag2a` through
201
245
  `wcag22aa`). `best-practice` is left out, as formancy.ai's builders leave
202
246
  it out. Two rules are off because jsdom cannot decide them:
@@ -210,7 +254,10 @@ jsdom with Testing Library and user-event:
210
254
  property. Each group, the form, the list, the statuses and the dialog
211
255
  are named in the editor's words, never after text on the page, which
212
256
  Chromium would read in the stylesheet's capitals; jsdom applies no
213
- 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).
214
261
  - **The keyboard, focus and the pointer** beyond the scenarios: the
215
262
  toolbar's tab stop and its arrows, focus after each action, the dialog's
216
263
  way out, the panes, a text field's own keys, every pointer drag above,
@@ -256,6 +303,11 @@ new child, the sheet's border, and a modified arrow taken by the toolbar.
256
303
  - **The place dialog's "nowhere" sentence** shows when a component has
257
304
  nowhere else to go. No report tried here has such a component. The test
258
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).
259
311
  - Everything `report-builder-core` lists under *What it does not do*
260
312
  holds here too: the canvas is not the PDF, some properties have no
261
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
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
@@ -19,10 +18,7 @@ interface ReportBuilderProps {
19
18
  readonly hostView?: ReactNode;
20
19
  }
21
20
  export declare function ReportBuilder({ editor, hostView }: ReportBuilderProps): ReactElement;
22
- //#endregion
23
- //#region src/use-editor-state.d.ts
24
21
  /** Re-renders the component on every change to `editor`'s state; unsubscribes when it unmounts or the editor is replaced. */
25
22
  export declare function useEditorState(editor: ReportEditor): EditorState;
26
- //#endregion
27
23
  export type { ReportBuilderProps };
28
24
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/report-builder.tsx","../src/use-editor-state.ts"],"mappings":";;;UA4CiB;;;;;;WAMN,QAAQ;;;;;;;;;WASR,WAAW;;wBAgBN,gBAAgB,QAAQ,YAAY,qBAAqB;;;;wBC7DzD,eAAe,QAAQ,eAAe"}
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"}
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
2
2
  import { actionForKey, editorText, targetBeside, targetNear } from "@formancy/report-builder-core";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- //#region src/canvas.tsx
4
+ // src/canvas.tsx
5
5
  /** A box's place on the sheet: physical left and top, because a page's coordinates run from its top-left whatever the language. */
6
6
  function placed(box) {
7
7
  return {
@@ -27,6 +27,11 @@ function Ruler({ orientation, ticks, length, label }) {
27
27
  }, tick.mm))
28
28
  });
29
29
  }
30
+ /** What a box says beyond its name, as its description: that it runs over, and that a word it prints is missing in the language edited. */
31
+ function described$1(box, t) {
32
+ const said = [box.overflows ? t("canvas.overflow") : void 0, box.missing].filter((sentence) => sentence !== void 0);
33
+ return said.length === 0 ? void 0 : said.join(". ");
34
+ }
30
35
  function selection$1(box) {
31
36
  return box.column === void 0 ? {
32
37
  type: "select",
@@ -86,8 +91,9 @@ function Canvas({ state, t, canvas: canvasRef, sheet: sheetRef, drag, select })
86
91
  "data-kind": box.kind,
87
92
  "data-selected": box.selected ? "true" : void 0,
88
93
  "data-overflows": box.overflows ? "true" : void 0,
94
+ "data-missing": box.missing === void 0 ? void 0 : "true",
89
95
  "data-dragging": box.column === void 0 && box.id === moving ? "true" : void 0,
90
- title: box.overflows ? t("canvas.overflow") : void 0,
96
+ title: described$1(box, t),
91
97
  style: placed(box.px),
92
98
  onPointerDown: (event) => {
93
99
  if (box.column === void 0) drag.press(event, { id: box.id });
@@ -105,15 +111,27 @@ function Canvas({ state, t, canvas: canvasRef, sheet: sheetRef, drag, select })
105
111
  children: box.problems
106
112
  }) : null]
107
113
  }, box.key)),
108
- canvas.paymentPart === null ? null : /* @__PURE__ */ jsx("div", {
114
+ canvas.paymentPart === null ? null : /* @__PURE__ */ jsxs("div", {
109
115
  role: "img",
110
116
  "aria-label": canvas.paymentPart.label,
111
117
  "data-report-part": "payment-part",
118
+ "data-selected": canvas.paymentPart.selected ? "true" : void 0,
119
+ "data-missing": canvas.paymentPart.missing === void 0 ? void 0 : "true",
120
+ title: canvas.paymentPart.missing,
112
121
  style: placed(canvas.paymentPart.px),
113
- children: /* @__PURE__ */ jsx("span", {
122
+ onClick: () => select({
123
+ type: "select",
124
+ part: "paymentPart"
125
+ }),
126
+ children: [/* @__PURE__ */ jsx("span", {
114
127
  "data-report-part": "region-label",
115
128
  children: canvas.paymentPart.label
116
- })
129
+ }), canvas.paymentPart.problems > 0 ? /* @__PURE__ */ jsx("span", {
130
+ "data-report-part": "badge",
131
+ "data-severity": canvas.paymentPart.severity,
132
+ "aria-hidden": "true",
133
+ children: canvas.paymentPart.problems
134
+ }) : null]
117
135
  }),
118
136
  placing === null ? null : dropTargets.map((target) => /* @__PURE__ */ jsx("div", {
119
137
  role: "img",
@@ -127,8 +145,7 @@ function Canvas({ state, t, canvas: canvasRef, sheet: sheetRef, drag, select })
127
145
  ]
128
146
  });
129
147
  }
130
- //#endregion
131
- //#region src/diagnostics.tsx
148
+ // src/diagnostics.tsx
132
149
  function Diagnostics({ state, t, ids, list, follow }) {
133
150
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("ul", {
134
151
  ref: list,
@@ -153,8 +170,7 @@ function Diagnostics({ state, t, ids, list, follow }) {
153
170
  })
154
171
  }), state.diagnostics.length === 0 ? /* @__PURE__ */ jsx("p", { children: t("problems.none") }) : null] });
155
172
  }
156
- //#endregion
157
- //#region src/image-chooser.tsx
173
+ // src/image-chooser.tsx
158
174
  /**
159
175
  * Add image…: the palette's last button, where the host keeps images
160
176
  * (0033), and the file input it opens, hidden beside it.
@@ -204,8 +220,7 @@ function ImageChooser({ state, t, ids, choose, add }) {
204
220
  }
205
221
  })] });
206
222
  }
207
- //#endregion
208
- //#region src/image-library.tsx
223
+ // src/image-library.tsx
209
224
  function ImageLibrary({ state, t, ids, remove }) {
210
225
  const { assets } = state.images;
211
226
  if (assets.length === 0) return null;
@@ -232,8 +247,7 @@ function ImageLibrary({ state, t, ids, remove }) {
232
247
  })
233
248
  });
234
249
  }
235
- //#endregion
236
- //#region src/outline.tsx
250
+ // src/outline.tsx
237
251
  function rows(nodes, into = []) {
238
252
  nodes.forEach((node, at) => {
239
253
  into.push({
@@ -247,9 +261,23 @@ function rows(nodes, into = []) {
247
261
  }
248
262
  /** The ids of what describes a row: how many problems it has, and that it is wider than its place. */
249
263
  function described(node, problems, overflow) {
250
- const ids = [...node.problems > 0 ? [problems] : [], ...node.overflows ? [overflow] : []];
264
+ const ids = [...node.problems > 0 ? [problems] : [], ...node.overflows === true ? [overflow] : []];
251
265
  return ids.length === 0 ? void 0 : ids.join(" ");
252
266
  }
267
+ /** A row's count of problems: drawn, and said as its description; inside the name it would make "Introduction" read "Introduction 1". */
268
+ function Problems({ row, id, t }) {
269
+ if (row.problems === 0) return null;
270
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
271
+ "data-report-part": "badge",
272
+ "data-severity": row.severity,
273
+ "aria-hidden": "true",
274
+ children: row.problems
275
+ }), /* @__PURE__ */ jsx("span", {
276
+ id,
277
+ hidden: true,
278
+ children: t("outline.problems", { count: row.problems })
279
+ })] });
280
+ }
253
281
  function selection(node) {
254
282
  return node.column === void 0 ? {
255
283
  type: "select",
@@ -265,8 +293,8 @@ function Outline({ state, t, ids, tree, drag, act }) {
265
293
  region,
266
294
  rows: rows(region.nodes)
267
295
  }));
268
- const all = regions.flatMap((region) => region.rows);
269
- const stop = all.find((row) => row.node.selected)?.node.key ?? all[0]?.node.key;
296
+ const all = [...regions.flatMap((region) => region.rows.map((row) => row.node)), ...state.outlineParts];
297
+ const stop = all.find((row) => row.selected)?.key ?? all[0]?.key;
270
298
  const empty = `${ids}-outline-empty`;
271
299
  if (stop === void 0) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
272
300
  ref: tree,
@@ -280,13 +308,13 @@ function Outline({ state, t, ids, tree, drag, act }) {
280
308
  "data-report-part": "outline-empty",
281
309
  children: t("outline.empty")
282
310
  })] });
283
- return /* @__PURE__ */ jsx("div", {
311
+ return /* @__PURE__ */ jsxs("div", {
284
312
  ref: tree,
285
313
  role: "tree",
286
314
  "aria-label": t("pane.outline"),
287
315
  "data-report-part": "outline",
288
316
  tabIndex: -1,
289
- children: regions.map(({ region, rows: list }) => {
317
+ children: [regions.map(({ region, rows: list }) => {
290
318
  return /* @__PURE__ */ jsxs("div", {
291
319
  role: "group",
292
320
  "aria-label": region.label,
@@ -323,16 +351,11 @@ function Outline({ state, t, ids, tree, drag, act }) {
323
351
  },
324
352
  children: [
325
353
  node.label,
326
- node.problems > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
327
- "data-report-part": "badge",
328
- "data-severity": node.severity,
329
- "aria-hidden": "true",
330
- children: node.problems
331
- }), /* @__PURE__ */ jsx("span", {
354
+ /* @__PURE__ */ jsx(Problems, {
355
+ row: node,
332
356
  id: problems,
333
- hidden: true,
334
- children: t("outline.problems", { count: node.problems })
335
- })] }) : null,
357
+ t
358
+ }),
336
359
  node.overflows ? /* @__PURE__ */ jsx("span", {
337
360
  id: overflow,
338
361
  hidden: true,
@@ -343,11 +366,49 @@ function Outline({ state, t, ids, tree, drag, act }) {
343
366
  })
344
367
  ]
345
368
  }, region.region);
346
- })
369
+ }), state.outlineParts.map((part, at) => /* @__PURE__ */ jsx(PartRow, {
370
+ part,
371
+ position: at + 1,
372
+ siblings: state.outlineParts.length,
373
+ tabbable: part.key === stop,
374
+ ids,
375
+ t,
376
+ act
377
+ }, part.key))]
378
+ });
379
+ }
380
+ /**
381
+ * A part of the report's own level, as a row at the tree's top: selected by
382
+ * focus or a click, as a component's row is, and dragged nowhere, since it
383
+ * has one place.
384
+ */
385
+ function PartRow({ part, position, siblings, tabbable, ids, t, act }) {
386
+ const problems = `${ids}-problems-${part.key}`;
387
+ const select = () => act({
388
+ type: "select",
389
+ part: part.part
390
+ });
391
+ return /* @__PURE__ */ jsxs("div", {
392
+ role: "treeitem",
393
+ "aria-level": 1,
394
+ "aria-posinset": position,
395
+ "aria-setsize": siblings,
396
+ "aria-selected": part.selected,
397
+ "aria-describedby": described(part, problems, ""),
398
+ tabIndex: tabbable ? 0 : -1,
399
+ "data-report-part": "outline-item",
400
+ onFocus: () => {
401
+ if (!part.selected) select();
402
+ },
403
+ onClick: select,
404
+ children: [part.label, /* @__PURE__ */ jsx(Problems, {
405
+ row: part,
406
+ id: problems,
407
+ t
408
+ })]
347
409
  });
348
410
  }
349
- //#endregion
350
- //#region src/palette.tsx
411
+ // src/palette.tsx
351
412
  function Palette({ state, t, ids, drag, place, chooser }) {
352
413
  return /* @__PURE__ */ jsxs("div", {
353
414
  role: "group",
@@ -374,8 +435,7 @@ function Palette({ state, t, ids, drag, place, chooser }) {
374
435
  }), chooser]
375
436
  });
376
437
  }
377
- //#endregion
378
- //#region src/places.tsx
438
+ // src/places.tsx
379
439
  function Places({ state, drag, t, ids, act, choose, cancel }) {
380
440
  const nowhere = `${ids}-nowhere`;
381
441
  return /* @__PURE__ */ jsxs("div", {
@@ -409,8 +469,7 @@ function Places({ state, drag, t, ids, act, choose, cancel }) {
409
469
  ]
410
470
  });
411
471
  }
412
- //#endregion
413
- //#region src/pointer-drag.ts
472
+ // src/pointer-drag.ts
414
473
  /**
415
474
  * Dragging with a pointer: a palette entry, a box on the canvas or an outline
416
475
  * row, dropped on the canvas or beside an outline row.
@@ -541,8 +600,7 @@ function usePointerDrag(editor, zones, placed) {
541
600
  }
542
601
  };
543
602
  }
544
- //#endregion
545
- //#region src/properties.tsx
603
+ // src/properties.tsx
546
604
  /**
547
605
  * The properties: one native control per field of the selection, or of the
548
606
  * report when nothing is selected, each labelled by its field's label.
@@ -553,7 +611,31 @@ function usePointerDrag(editor, zones, placed) {
553
611
  * the field, or Enter in a single-line one -- and a value the editor refuses
554
612
  * stays as typed, `aria-invalid`, with the reason beside it as its
555
613
  * description. Escape gives back what the report holds. Under the
556
- * report's own fields, its images (`library`, 0033).
614
+ * report's own fields, its images (`library`, 0033). A field at a word in
615
+ * a language besides the report's own has its note under it, which
616
+ * describes it too, and is marked while the word is missing (0063).
617
+ *
618
+ * Fields the editor groups -- a QR-bill's creditor and debtor (0039), an
619
+ * e-invoice's parties, its VAT categories and its payment instructions
620
+ * (0044) -- are a `group` named in the editor's words, their name drawn and
621
+ * hidden from the tree, which reads the group's own, and the group's
622
+ * buttons after them, one with nowhere to go `aria-disabled` and still
623
+ * sent. A button keeps the keyboard where it is as its words change, Add to
624
+ * Remove and back, unless the editor says where it goes once done (`then`):
625
+ * the same button of the group a VAT category moved to, the list's Add once
626
+ * one is removed, a new one's first field (report-builder.tsx). Add
627
+ * QR-bill, which gives the properties the bill's in place of the report's,
628
+ * takes its own button away, and the keyboard goes to the first field, the
629
+ * bill's IBAN, as it does when a Remove takes its row.
630
+ *
631
+ * Each run of a paragraph is such a group, its buttons Subscript and
632
+ * Superscript, each named after the run, showing only its own word, and
633
+ * `aria-pressed` as the run is set (0061). Pressed, one sends the
634
+ * selection of its group's text field -- its start, its end and the text
635
+ * it is of -- read from the element as the button is pressed: the one
636
+ * thing only the DOM knows, which the editor applies to the text the
637
+ * report holds and to nothing else. The keyboard then goes where the
638
+ * editor's outcome says, the run that holds the text now.
557
639
  */
558
640
  /** A text, a colour, an expression, a number or a length: typed, then committed. */
559
641
  function Typed({ field, id, validity, commit }) {
@@ -618,48 +700,129 @@ function Control(props) {
618
700
  default: return /* @__PURE__ */ jsx(Typed, { ...props });
619
701
  }
620
702
  }
621
- function Properties({ state, ids, act, library }) {
703
+ /** One field's row: its label, its control and, after a refusal or about a problem, why. `at` is its place among every field, for its ids. */
704
+ function Row({ field, at, ids, act }) {
705
+ const id = `${ids}-field-${at}`;
706
+ const error = `${id}-error`;
707
+ const note = `${id}-note`;
708
+ const described = [field.error === void 0 ? null : error, field.note === void 0 ? null : note].filter((part) => part !== null).join(" ");
709
+ const validity = {
710
+ ...field.error === void 0 ? {} : { "aria-invalid": true },
711
+ ...described === "" ? {} : { "aria-describedby": described }
712
+ };
713
+ return /* @__PURE__ */ jsxs("div", {
714
+ "data-report-part": "property",
715
+ "data-kind": field.kind,
716
+ "data-missing": field.missing === true ? "true" : void 0,
717
+ children: [
718
+ /* @__PURE__ */ jsx("label", {
719
+ htmlFor: id,
720
+ children: field.label
721
+ }),
722
+ /* @__PURE__ */ jsx(Control, {
723
+ field,
724
+ id,
725
+ validity,
726
+ commit: (value) => act({
727
+ type: "setProperty",
728
+ key: field.key,
729
+ value
730
+ })
731
+ }),
732
+ field.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
733
+ id: error,
734
+ "data-report-part": "property-error",
735
+ children: field.error
736
+ }),
737
+ field.note === void 0 ? null : /* @__PURE__ */ jsx("p", {
738
+ id: note,
739
+ "data-report-part": "property-note",
740
+ children: field.note
741
+ })
742
+ ]
743
+ });
744
+ }
745
+ /**
746
+ * What a group's button sends: a run's `setBaseline` with what its group's
747
+ * text field has selected, read from the element now, as only the DOM
748
+ * knows it (0061); any other action as the state gives it. A field bound
749
+ * to a value is a select, and has no selection: its run is set whole.
750
+ */
751
+ function sent(action, group) {
752
+ if (action.action.type !== "setBaseline") return action;
753
+ const field = group?.querySelector("input, textarea");
754
+ if (!(field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement) || field.selectionStart === null || field.selectionEnd === null) return action;
755
+ return {
756
+ ...action,
757
+ action: {
758
+ ...action.action,
759
+ selected: {
760
+ start: field.selectionStart,
761
+ end: field.selectionEnd,
762
+ text: field.value
763
+ }
764
+ }
765
+ };
766
+ }
767
+ /** A group of fields, named in the editor's words, with its buttons after them, each keyed by its place so that it keeps the keyboard as its words change. */
768
+ function Group({ group, first, ids, act, press }) {
769
+ const element = useRef(null);
770
+ return /* @__PURE__ */ jsxs("div", {
771
+ ref: element,
772
+ role: "group",
773
+ "aria-label": group.label,
774
+ "data-report-part": "property-group",
775
+ children: [
776
+ /* @__PURE__ */ jsx("span", {
777
+ "aria-hidden": "true",
778
+ children: group.label
779
+ }),
780
+ group.fields.map((field, at) => /* @__PURE__ */ jsx(Row, {
781
+ field,
782
+ at: first + at,
783
+ ids,
784
+ act
785
+ }, field.key)),
786
+ group.actions.map((action, at) => /* @__PURE__ */ jsx("button", {
787
+ type: "button",
788
+ "aria-label": action.text === void 0 ? void 0 : action.label,
789
+ "aria-pressed": action.pressed,
790
+ "aria-disabled": action.available ? void 0 : true,
791
+ onClick: () => press(sent(action, element.current)),
792
+ children: action.text ?? action.label
793
+ }, `action-${String(at)}`))
794
+ ]
795
+ });
796
+ }
797
+ function Properties({ state, ids, act, press, library }) {
798
+ let next = 0;
622
799
  return /* @__PURE__ */ jsxs("form", {
623
800
  "aria-label": state.properties.heading,
624
801
  "data-report-part": "properties",
625
802
  onSubmit: (event) => event.preventDefault(),
626
- children: [state.properties.fields.map((field, at) => {
627
- const id = `${ids}-field-${at}`;
628
- const error = `${id}-error`;
629
- const validity = field.error === void 0 ? {} : {
630
- "aria-invalid": true,
631
- "aria-describedby": error
632
- };
633
- return /* @__PURE__ */ jsxs("div", {
634
- "data-report-part": "property",
635
- "data-kind": field.kind,
636
- children: [
637
- /* @__PURE__ */ jsx("label", {
638
- htmlFor: id,
639
- children: field.label
640
- }),
641
- /* @__PURE__ */ jsx(Control, {
642
- field,
643
- id,
644
- validity,
645
- commit: (value) => act({
646
- type: "setProperty",
647
- key: field.key,
648
- value
649
- })
650
- }),
651
- field.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
652
- id: error,
653
- "data-report-part": "property-error",
654
- children: field.error
655
- })
656
- ]
657
- }, field.key);
803
+ children: [state.properties.rows.map((row) => {
804
+ const first = next;
805
+ if ("group" in row) {
806
+ next += row.group.fields.length;
807
+ return /* @__PURE__ */ jsx(Group, {
808
+ group: row.group,
809
+ first,
810
+ ids,
811
+ act,
812
+ press
813
+ }, row.group.key);
814
+ }
815
+ next += 1;
816
+ return /* @__PURE__ */ jsx(Row, {
817
+ field: row.field,
818
+ at: first,
819
+ ids,
820
+ act
821
+ }, row.field.key);
658
822
  }), library]
659
823
  });
660
824
  }
661
- //#endregion
662
- //#region src/toolbar.tsx
825
+ // src/toolbar.tsx
663
826
  /**
664
827
  * The toolbar: undo and redo, the structural actions on the selection, the
665
828
  * zoom, and the panes a narrow screen shows one at a time.
@@ -836,8 +999,7 @@ function Toolbar({ state, t, act, placeSelection, showPane }) {
836
999
  ]
837
1000
  });
838
1001
  }
839
- //#endregion
840
- //#region src/use-editor-state.ts
1002
+ // src/use-editor-state.ts
841
1003
  /**
842
1004
  * The editor's state as a React value.
843
1005
  *
@@ -852,8 +1014,7 @@ function Toolbar({ state, t, act, placeSelection, showPane }) {
852
1014
  function useEditorState(editor) {
853
1015
  return useSyncExternalStore(editor.subscribe, editor.state, editor.state);
854
1016
  }
855
- //#endregion
856
- //#region src/report-builder.tsx
1017
+ // src/report-builder.tsx
857
1018
  /**
858
1019
  * The report builder for React: the workbench's three panes over one
859
1020
  * report-builder-core editor -- the palette and the outline, the design
@@ -876,6 +1037,10 @@ function useEditorState(editor) {
876
1037
  * named by the editor's `hostView`, holding what the host gave and nothing
877
1038
  * of the builder's, its keys the host's.
878
1039
  *
1040
+ * A report written in more than one language has a switch between them
1041
+ * beside its title, which shows and edits the words of the one chosen
1042
+ * (0063).
1043
+ *
879
1044
  * Where the host gave the editor a store for images, the palette ends with
880
1045
  * Add image…, and the report's own properties list its images (0033): the
881
1046
  * file a person chooses goes to `editor.addImage`, which says what became
@@ -910,6 +1075,11 @@ function ReportBuilder({ editor, hostView }) {
910
1075
  const wanted = useRef(null);
911
1076
  const focus = useCallback((where) => {
912
1077
  const selectedRow = () => tree.current?.querySelector("[role=\"treeitem\"][aria-selected=\"true\"]") ?? null;
1078
+ if (typeof where === "object") {
1079
+ const groups = editor.state().properties.rows.flatMap((row) => "group" in row ? [row.group.key] : []);
1080
+ const element = fields.current?.querySelectorAll("[data-report-part=\"property-group\"]")[groups.indexOf(where.group)];
1081
+ return (where.button === void 0 ? element?.querySelector("input, select, textarea") : element?.querySelectorAll(":scope > button")[where.button])?.focus();
1082
+ }
913
1083
  switch (where) {
914
1084
  case "selection": return (selectedRow() ?? tree.current)?.focus();
915
1085
  case "outline": return (selectedRow() ?? tree.current?.querySelector("[role=\"treeitem\"][tabindex=\"0\"]") ?? tree.current)?.focus();
@@ -925,7 +1095,7 @@ function ReportBuilder({ editor, hostView }) {
925
1095
  case "properties": return fields.current?.querySelector("input, select, textarea")?.focus();
926
1096
  case "diagnostics": return problemList.current?.focus();
927
1097
  }
928
- }, []);
1098
+ }, [editor]);
929
1099
  useLayoutEffect(() => {
930
1100
  const where = wanted.current;
931
1101
  if (where === null) return;
@@ -942,13 +1112,19 @@ function ReportBuilder({ editor, hostView }) {
942
1112
  const dropped = document.activeElement === null || document.activeElement === document.body;
943
1113
  if (lastInProperties.current && last instanceof Node && !last.isConnected && dropped) focus("properties");
944
1114
  }, [state, focus]);
945
- /** Dispatches `action`; when it succeeds, focus goes to `then` -- at once if nothing changed, else once the change is drawn. */
1115
+ /**
1116
+ * Dispatches `action`; when it succeeds, focus goes to `then` -- at once
1117
+ * if nothing changed, else once the change is drawn -- or where the
1118
+ * outcome says, where the action decided it only once done: a run's
1119
+ * button, whose run a split moved (0061).
1120
+ */
946
1121
  function act(action, then) {
947
1122
  const before = editor.state();
948
1123
  const outcome = editor.dispatch(action);
949
- if (then === void 0 || !outcome.ok) return outcome;
950
- if (editor.state() === before) focus(then);
951
- else wanted.current = then;
1124
+ const where = outcome.ok ? outcome.then ?? then : void 0;
1125
+ if (where === void 0) return outcome;
1126
+ if (editor.state() === before) focus(where);
1127
+ else wanted.current = where;
952
1128
  return outcome;
953
1129
  }
954
1130
  const drag = usePointerDrag(editor, {
@@ -1018,6 +1194,10 @@ function ReportBuilder({ editor, hostView }) {
1018
1194
  type: "select",
1019
1195
  id: null
1020
1196
  });
1197
+ else if ("part" in target) act({
1198
+ type: "select",
1199
+ part: target.part
1200
+ }, "selection");
1021
1201
  else act(target.column === void 0 ? {
1022
1202
  type: "select",
1023
1203
  id: target.id
@@ -1056,19 +1236,35 @@ function ReportBuilder({ editor, hostView }) {
1056
1236
  children: [
1057
1237
  /* @__PURE__ */ jsx("div", {
1058
1238
  className: "wb-pane",
1059
- children: /* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsx("span", {
1060
- "data-report-part": "title",
1061
- children: state.document.title
1062
- }), /* @__PURE__ */ jsx(Toolbar, {
1063
- state,
1064
- t,
1065
- act,
1066
- placeSelection,
1067
- showPane: (pane) => act({
1068
- type: "openPanel",
1069
- panel: pane
1070
- }, pane)
1071
- })] })
1239
+ children: /* @__PURE__ */ jsxs("header", { children: [
1240
+ /* @__PURE__ */ jsx("span", {
1241
+ "data-report-part": "title",
1242
+ children: state.document.title
1243
+ }),
1244
+ state.languages.declared.length > 1 ? /* @__PURE__ */ jsx("select", {
1245
+ "aria-label": t("language.label"),
1246
+ "data-report-part": "language",
1247
+ value: state.languages.edited,
1248
+ onChange: (event) => act({
1249
+ type: "setLanguage",
1250
+ locale: event.target.value
1251
+ }),
1252
+ children: state.languages.declared.map((language) => /* @__PURE__ */ jsx("option", {
1253
+ value: language.locale,
1254
+ children: language.label
1255
+ }, language.locale))
1256
+ }) : null,
1257
+ /* @__PURE__ */ jsx(Toolbar, {
1258
+ state,
1259
+ t,
1260
+ act,
1261
+ placeSelection,
1262
+ showPane: (pane) => act({
1263
+ type: "openPanel",
1264
+ panel: pane
1265
+ }, pane)
1266
+ })
1267
+ ] })
1072
1268
  }),
1073
1269
  shows("outline") ? /* @__PURE__ */ jsxs("section", {
1074
1270
  className: "wb-pane",
@@ -1160,6 +1356,7 @@ function ReportBuilder({ editor, hostView }) {
1160
1356
  state,
1161
1357
  ids,
1162
1358
  act,
1359
+ press: (action) => act(action.action, action.then),
1163
1360
  library: state.selection === null ? /* @__PURE__ */ jsx(ImageLibrary, {
1164
1361
  state,
1165
1362
  t,
@@ -1204,7 +1401,6 @@ function ReportBuilder({ editor, hostView }) {
1204
1401
  ]
1205
1402
  });
1206
1403
  }
1207
- //#endregion
1208
1404
  export { ReportBuilder, useEditorState };
1209
1405
 
1210
1406
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["selection"],"sources":["../src/canvas.tsx","../src/diagnostics.tsx","../src/image-chooser.tsx","../src/image-library.tsx","../src/outline.tsx","../src/palette.tsx","../src/places.tsx","../src/pointer-drag.ts","../src/properties.tsx","../src/toolbar.tsx","../src/use-editor-state.ts","../src/report-builder.tsx"],"sourcesContent":["/**\n * The design view: one sheet as wide as the page, the regions as bands on it,\n * a box per component and table column, a payment part's band at its foot,\n * rulers in millimetres, and while something is being placed, an indicator\n * at every place it may go.\n *\n * It draws the state's geometry and decides none: every left, top, width and\n * height is a number report-builder-core computed in pixels at the zoom. It\n * is labelled as not the PDF, because it is not -- the renderer measures text\n * and breaks pages, and the preview shows what prints.\n *\n * Each box is a picture of where a component stands -- `role=\"img\"`, named\n * by its label, so reading the view says what is on it. A click selects; a\n * box is not a tab stop, because the outline is the keyboard's way to every\n * box and two ways to the same place would double the tabbing. The view\n * itself is one stop, so a keyboard can scroll it.\n */\nimport type { CSSProperties, ReactElement, Ref } from 'react'\nimport type { Box, CanvasBox, EditorAction, EditorState, EditorText, RulerTick } from '@formancy/report-builder-core'\nimport type { PointerDrag } from './pointer-drag.js'\n\nexport interface CanvasProps {\n readonly state: EditorState\n readonly t: EditorText\n readonly canvas: Ref<HTMLElement>\n readonly sheet: Ref<HTMLDivElement>\n readonly drag: PointerDrag\n /** Selects a box, focus to follow to its outline row. */\n readonly select: (action: EditorAction) => void\n}\n\n/** A box's place on the sheet: physical left and top, because a page's coordinates run from its top-left whatever the language. */\nfunction placed(box: Box): CSSProperties {\n return { left: box.x, top: box.y, width: box.width, height: box.height }\n}\n\nfunction Ruler({ orientation, ticks, length, label }: { readonly orientation: 'horizontal' | 'vertical'; readonly ticks: readonly RulerTick[]; readonly length: number; readonly label: string }): ReactElement {\n const across = orientation === 'horizontal'\n return (\n <div role=\"img\" aria-label={label} data-report-part=\"ruler\" data-orientation={orientation} style={across ? { width: length } : { height: length }}>\n {ticks.map((tick) => (\n <span key={tick.mm} data-report-part=\"ruler-tick\" data-major={tick.major ? 'true' : undefined} style={across ? { left: tick.at } : { top: tick.at }}>\n {tick.label === undefined ? null : <span>{tick.label}</span>}\n </span>\n ))}\n </div>\n )\n}\n\nfunction selection(box: CanvasBox): EditorAction {\n return box.column === undefined ? { type: 'select', id: box.id } : { type: 'select', id: box.id, column: box.column }\n}\n\nexport function Canvas({ state, t, canvas: canvasRef, sheet: sheetRef, drag, select }: CanvasProps): ReactElement {\n const { canvas, drag: placing, dropTargets } = state\n const moving = placing !== null && 'id' in placing.subject ? placing.subject.id : undefined\n return (\n <section ref={canvasRef} aria-label={canvas.label} data-report-part=\"canvas\" tabIndex={0}>\n <p data-report-part=\"canvas-note\">{canvas.note}</p>\n <Ruler orientation=\"horizontal\" ticks={canvas.rulers.horizontal} length={canvas.sheet.px.width} label={t('ruler.horizontal')} />\n <Ruler orientation=\"vertical\" ticks={canvas.rulers.vertical} length={canvas.sheet.px.height} label={t('ruler.vertical')} />\n <div ref={sheetRef} data-report-part=\"sheet\" style={{ width: canvas.sheet.px.width, height: canvas.sheet.px.height }}>\n {canvas.regions.map((region) => (\n <div key={region.region} data-report-part=\"region\" data-empty={region.empty ? 'true' : undefined} style={placed(region.px)}>\n <span data-report-part=\"region-label\">{region.label}</span>\n </div>\n ))}\n {canvas.boxes.map((box) => (\n <div\n key={box.key}\n role=\"img\"\n aria-label={box.label}\n data-report-part=\"box\"\n data-kind={box.kind}\n data-selected={box.selected ? 'true' : undefined}\n data-overflows={box.overflows ? 'true' : undefined}\n data-dragging={box.column === undefined && box.id === moving ? 'true' : undefined}\n title={box.overflows ? t('canvas.overflow') : undefined}\n style={placed(box.px)}\n onPointerDown={(event) => {\n if (box.column === undefined) drag.press(event, { id: box.id })\n }}\n onClick={() => {\n if (!drag.swallowClick()) select(selection(box))\n }}\n >\n <span data-report-part=\"box-label\">{box.label}</span>\n {box.problems > 0 ? (\n <span data-report-part=\"badge\" data-severity={box.severity} aria-hidden=\"true\">\n {box.problems}\n </span>\n ) : null}\n </div>\n ))}\n {/* Where a payment part's slip prints, below every region: a\n picture named as SIX names the part, as a box is named by its\n label. */}\n {canvas.paymentPart === null ? null : (\n <div role=\"img\" aria-label={canvas.paymentPart.label} data-report-part=\"payment-part\" style={placed(canvas.paymentPart.px)}>\n <span data-report-part=\"region-label\">{canvas.paymentPart.label}</span>\n </div>\n )}\n {/* Drawn only for the places the session accepts, named as the place\n dialog names them; the one under the pointer, or focused in the\n dialog, is marked. */}\n {placing === null\n ? null\n : dropTargets.map((target) => (\n <div key={target.index} role=\"img\" aria-label={target.label} data-report-part=\"drop-indicator\" data-over={placing.over === target.index ? 'true' : undefined} style={placed(target.px)} />\n ))}\n </div>\n </section>\n )\n}\n","/**\n * The problems: report-core's diagnostics, each a button named \"Error:\n * Introduction\" and described by report-core's sentence. Activating one\n * selects what it is about, and the builder moves focus to its outline row;\n * one about the report as a whole selects nothing, which shows the report's\n * own properties.\n *\n * Each entry is keyed by what it is (`DiagnosticEntry.key`), never by its\n * place in the list: a problem listed before the one the keyboard is on\n * leaves that one's button, and the keyboard, where they were.\n */\nimport type { ReactElement, Ref } from 'react'\nimport type { DiagnosticEntry, EditorState, EditorText } from '@formancy/report-builder-core'\n\nexport interface DiagnosticsProps {\n readonly state: EditorState\n readonly t: EditorText\n readonly ids: string\n readonly list: Ref<HTMLUListElement>\n readonly follow: (entry: DiagnosticEntry) => void\n}\n\nexport function Diagnostics({ state, t, ids, list, follow }: DiagnosticsProps): ReactElement {\n return (\n <>\n {/* Not a tab stop: the problems pane's button moves focus here, to say\n how many there are. Named in words, as the pane's heading says. */}\n <ul ref={list} aria-label={t('pane.problems')} data-report-part=\"diagnostics\" tabIndex={-1}>\n {state.diagnostics.map((entry, at) => {\n const message = `${ids}-problem-${at}`\n return (\n <li key={entry.key} data-report-part=\"diagnostic\" data-severity={entry.severity}>\n <button type=\"button\" aria-describedby={message} onClick={() => follow(entry)}>\n {entry.label}\n </button>\n <div id={message}>{entry.message}</div>\n </li>\n )\n })}\n </ul>\n {state.diagnostics.length === 0 ? <p>{t('problems.none')}</p> : null}\n </>\n )\n}\n","/**\n * Add image…: the palette's last button, where the host keeps images\n * (0033), and the file input it opens, hidden beside it.\n *\n * The button sends `chooseImage` and, when the editor will take a file\n * now, calls the input's `click()` at once, in the same activation -- a\n * click, Enter or Space -- which opens the platform's chooser; awaiting\n * anything first would lose the activation, and the browser would open\n * nothing. The input is outside the accessibility tree and never has\n * focus: the keyboard stays on the button throughout.\n *\n * On the input's change the file is taken into a local before `value` is\n * cleared, because in a browser clearing it empties `files`; it is cleared\n * so that the same file chosen again is a change again. A chooser closed\n * without a file changes nothing, and nothing is sent. What the file is,\n * and whether it is added, is the editor's to say, in the live region.\n */\nimport { useRef } from 'react'\nimport type { ReactElement } from 'react'\nimport type { EditorState, EditorText } from '@formancy/report-builder-core'\n\nexport interface ImageChooserProps {\n readonly state: EditorState\n readonly t: EditorText\n /** Prefix for the element ids this pane mints, unique to its builder. */\n readonly ids: string\n /** Sends `chooseImage`: whether the editor takes a file now, else it has said why not. */\n readonly choose: () => boolean\n /** Hands the editor the file a person chose. */\n readonly add: (file: File) => void\n}\n\nexport function ImageChooser({ state, t, ids, choose, add }: ImageChooserProps): ReactElement | null {\n const input = useRef<HTMLInputElement>(null)\n const { images } = state\n if (!images.store) return null\n const why = `${ids}-unavailable-add-image`\n return (\n <>\n <button\n type=\"button\"\n data-report-part=\"palette-item\"\n aria-disabled={state.can.addImage ? undefined : true}\n aria-describedby={images.unavailable === undefined ? undefined : why}\n aria-busy={images.adding === null ? undefined : true}\n onClick={() => {\n if (choose()) input.current?.click()\n }}\n >\n {t('images.add')}\n {images.unavailable === undefined ? null : (\n <span id={why} hidden>\n {images.unavailable}\n </span>\n )}\n </button>\n <input\n ref={input}\n type=\"file\"\n hidden\n accept={images.accept}\n onChange={(event) => {\n const chosen = event.currentTarget\n const file = chosen.files?.[0]\n chosen.value = ''\n if (file !== undefined) add(file)\n }}\n />\n </>\n )\n}\n","/**\n * The report's images, listed under its own properties (0033): a group\n * named by the catalogue, with a row per image the report declares -- its\n * label as text, and a Remove named after the image.\n *\n * A Remove whose image something draws is `aria-disabled`, described by\n * what draws it, and still sends `removeImage`, so the live region says\n * why nothing happened. One that removed its image takes its own button\n * away, so the builder puts the keyboard on the first field, as the way\n * back to the report's properties does.\n */\nimport type { ReactElement } from 'react'\nimport type { EditorState, EditorText } from '@formancy/report-builder-core'\n\nexport interface ImageLibraryProps {\n readonly state: EditorState\n readonly t: EditorText\n /** Prefix for the element ids this pane mints, unique to its builder. */\n readonly ids: string\n readonly remove: (asset: string) => void\n}\n\nexport function ImageLibrary({ state, t, ids, remove }: ImageLibraryProps): ReactElement | null {\n const { assets } = state.images\n if (assets.length === 0) return null\n return (\n <div role=\"group\" aria-label={t('images.heading')}>\n {assets.map((image, at) => {\n const why = `${ids}-image-${String(at)}-in-use`\n return (\n <div key={image.id} data-report-part=\"property\">\n <span>{image.label}</span>\n <button type=\"button\" aria-label={image.removeLabel} aria-disabled={image.inUse === undefined ? undefined : true} aria-describedby={image.inUse === undefined ? undefined : why} onClick={() => remove(image.id)}>\n {t('images.remove')}\n {image.inUse === undefined ? null : (\n <span id={why} hidden>\n {image.inUse}\n </span>\n )}\n </button>\n </div>\n )\n })}\n </div>\n )\n}\n","/**\n * The outline: the report as an ARIA tree, a group per region and a row per\n * component or table column; with no row at all, an empty tree and the\n * sentence that says so.\n *\n * Rows are flat within their region and nest by `aria-level`, which is also\n * what report-builder.css indents by, so the nesting drawn and the nesting\n * announced cannot disagree. One row is a tab stop -- the selected one, or\n * the first -- and focus follows the selection: moving focus to a row\n * selects it, and every action that selects moves focus to its row. The\n * keys are report-builder-core's `actionForKey`, which the builder applies\n * to the whole tree; nothing here decides a key.\n */\nimport type { ReactElement, Ref } from 'react'\nimport type { EditorAction, EditorState, EditorText, OutlineNode } from '@formancy/report-builder-core'\nimport type { PointerDrag } from './pointer-drag.js'\n\nexport interface OutlineProps {\n readonly state: EditorState\n readonly t: EditorText\n readonly ids: string\n readonly tree: Ref<HTMLDivElement>\n readonly drag: PointerDrag\n readonly act: (action: EditorAction) => void\n}\n\n/** A node with its place among its siblings, for `aria-posinset` and `aria-setsize`. */\ninterface Row {\n readonly node: OutlineNode\n readonly position: number\n readonly siblings: number\n}\n\nfunction rows(nodes: readonly OutlineNode[], into: Row[] = []): Row[] {\n nodes.forEach((node, at) => {\n into.push({ node, position: at + 1, siblings: nodes.length })\n rows(node.children, into)\n })\n return into\n}\n\n/** The ids of what describes a row: how many problems it has, and that it is wider than its place. */\nfunction described(node: OutlineNode, problems: string, overflow: string): string | undefined {\n const ids = [...(node.problems > 0 ? [problems] : []), ...(node.overflows ? [overflow] : [])]\n return ids.length === 0 ? undefined : ids.join(' ')\n}\n\nfunction selection(node: OutlineNode): EditorAction {\n return node.column === undefined ? { type: 'select', id: node.id } : { type: 'select', id: node.id, column: node.column }\n}\n\nexport function Outline({ state, t, ids, tree, drag, act }: OutlineProps): ReactElement {\n const regions = state.outline.map((region) => ({ region, rows: rows(region.nodes) }))\n const all = regions.flatMap((region) => region.rows)\n // The tree's one tab stop: the selected row, else the first; the tree itself when it has none.\n const stop = all.find((row) => row.node.selected)?.node.key ?? all[0]?.node.key\n const empty = `${ids}-outline-empty`\n\n // With no row at all the tree holds nothing -- a tree owns rows, and a\n // region's name with none under it is not one -- and is itself the tab\n // stop, described by the sentence beside it. With rows it still takes\n // focus from a script, never from Tab: where focus goes when an action\n // leaves nothing selected, since focusing a row would select it.\n if (stop === undefined) {\n return (\n <>\n <div ref={tree} role=\"tree\" aria-label={t('pane.outline')} aria-describedby={empty} data-report-part=\"outline\" tabIndex={0} />\n <p id={empty} data-report-part=\"outline-empty\">\n {t('outline.empty')}\n </p>\n </>\n )\n }\n\n return (\n <div ref={tree} role=\"tree\" aria-label={t('pane.outline')} data-report-part=\"outline\" tabIndex={-1}>\n {regions.map(({ region, rows: list }) => {\n return (\n // Named in the editor's words, not after the label drawn in it:\n // Chromium would put report-builder.css's capitals into that name,\n // \"BODY\". The label is hidden from the tree, which would read it\n // again as a text among the group's rows.\n <div key={region.region} role=\"group\" aria-label={region.label} data-report-part=\"outline-region\">\n <span data-report-part=\"region-label\" aria-hidden=\"true\">\n {region.label}\n </span>\n {list.length === 0 ? <span>{t('outline.empty')}</span> : null}\n {list.map(({ node, position, siblings }) => {\n const problems = `${ids}-problems-${node.key}`\n const overflow = `${ids}-overflow-${node.key}`\n return (\n <div\n key={node.key}\n ref={(element) => drag.row(element, node)}\n role=\"treeitem\"\n aria-level={node.depth + 1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-selected={node.selected}\n aria-describedby={described(node, problems, overflow)}\n tabIndex={node.key === stop ? 0 : -1}\n data-report-part=\"outline-item\"\n data-kind={node.kind}\n onPointerDown={(event) => {\n if (node.column === undefined) drag.press(event, { id: node.id })\n }}\n onFocus={() => {\n if (!node.selected) act(selection(node))\n }}\n onClick={() => {\n if (!drag.swallowClick()) act(selection(node))\n }}\n >\n {node.label}\n {node.problems > 0 ? (\n <>\n {/* The count is drawn, and said as the row's description:\n inside the name it would make \"Introduction\" read\n \"Introduction 1\". */}\n <span data-report-part=\"badge\" data-severity={node.severity} aria-hidden=\"true\">\n {node.problems}\n </span>\n <span id={problems} hidden>\n {t('outline.problems', { count: node.problems })}\n </span>\n </>\n ) : null}\n {/* What the canvas marks on a box too wide for its place,\n said where a keyboard is: on its row. */}\n {node.overflows ? (\n <span id={overflow} hidden>\n {t('canvas.overflow')}\n </span>\n ) : null}\n </div>\n )\n })}\n </div>\n )\n })}\n </div>\n )\n}\n","/**\n * The palette: one button per kind of component the format has.\n *\n * Activating one -- a click, Enter or Space -- opens the place dialog for\n * that kind, the keyboard path every drag has. Pressing one and moving is\n * the pointer path to the same places. An entry the report cannot hold yet\n * (an image with nothing to draw) stays in the list, `aria-disabled` and\n * described by what to declare first, so it is found rather than missed.\n * Where the host keeps images, Add image… stands last (`chooser`, 0033).\n */\nimport type { ReactElement, ReactNode } from 'react'\nimport type { EditorState, EditorText } from '@formancy/report-builder-core'\nimport type { ComponentKind } from '@formancy/report-spec'\nimport type { PointerDrag } from './pointer-drag.js'\n\nexport interface PaletteProps {\n readonly state: EditorState\n readonly t: EditorText\n /** Prefix for the element ids this pane mints, unique to its builder. */\n readonly ids: string\n readonly drag: PointerDrag\n /** Opens the place dialog for a new component of `kind`, focus to return to `from`. */\n readonly place: (kind: ComponentKind, from: HTMLElement) => void\n /** Add image… and its file input, after the entries; nothing where the host keeps no images. */\n readonly chooser?: ReactNode\n}\n\nexport function Palette({ state, t, ids, drag, place, chooser }: PaletteProps): ReactElement {\n return (\n <div role=\"group\" aria-label={t('pane.palette')} data-report-part=\"palette\">\n {state.palette.map((entry) => {\n const why = `${ids}-unavailable-${entry.kind}`\n return (\n <button\n key={entry.kind}\n type=\"button\"\n data-report-part=\"palette-item\"\n data-kind={entry.kind}\n aria-disabled={entry.component === null ? true : undefined}\n aria-describedby={entry.unavailable === undefined ? undefined : why}\n onPointerDown={(event) => drag.press(event, { kind: entry.kind })}\n onClick={(event) => {\n if (!drag.swallowClick()) place(entry.kind, event.currentTarget)\n }}\n >\n {entry.label}\n {entry.unavailable === undefined ? null : (\n <span id={why} hidden>\n {entry.unavailable}\n </span>\n )}\n </button>\n )\n })}\n {chooser}\n </div>\n )\n}\n","/**\n * The place dialog: the keyboard path for every drag (formancy.ai 0046).\n *\n * While the editor's drag is `via: 'keyboard'` it lists the drag's targets\n * -- the places report-core's `validLocations` accepts, named \"Body, after\n * Introduction\" -- as buttons, and Cancel. Focus moves into it when this\n * builder opens it (the builder's `openPlaces`), never merely because it is\n * drawn: a dialog another builder opened stays where the keyboard left it.\n * The place focused is the one the canvas marks, so a sighted keyboard user\n * sees where each choice lands before making it. Escape cancels, through the\n * editor's own key map. Choosing a place, and cancelling, are the builder's\n * to finish: it knows where focus goes next.\n */\nimport type { ReactElement } from 'react'\nimport type { DragState, DropTarget, EditorAction, EditorState, EditorText } from '@formancy/report-builder-core'\n\nexport interface PlacesProps {\n readonly state: EditorState\n readonly drag: DragState\n readonly t: EditorText\n readonly ids: string\n readonly act: (action: EditorAction) => void\n readonly choose: (subject: DragState['subject'], target: DropTarget) => void\n readonly cancel: () => void\n}\n\nexport function Places({ state, drag, t, ids, act, choose, cancel }: PlacesProps): ReactElement {\n const nowhere = `${ids}-nowhere`\n\n return (\n // A floating pane of the workbench, so its buttons are the workbench's.\n // Named in the editor's words, as the header says, never after the\n // header, whose name a host's stylesheet could set in capitals.\n <div role=\"dialog\" aria-label={drag.title} aria-describedby={drag.nowhere === undefined ? undefined : nowhere} data-report-part=\"places\" className=\"wb-pane\">\n <header>{drag.title}</header>\n {drag.nowhere === undefined ? null : (\n <p id={nowhere} className=\"wb-problem\">\n {drag.nowhere}\n </p>\n )}\n {state.dropTargets.map((target) => (\n <button\n key={target.index}\n type=\"button\"\n data-report-part=\"place\"\n onFocus={() => act({ type: 'updateDrag', over: target.index })}\n onClick={() => choose(drag.subject, target)}\n >\n {target.label}\n </button>\n ))}\n <button type=\"button\" onClick={cancel}>\n {t('places.cancel')}\n </button>\n </div>\n )\n}\n","/**\n * Dragging with a pointer: a palette entry, a box on the canvas or an outline\n * row, dropped on the canvas or beside an outline row.\n *\n * The drag itself is the editor's state machine (`startDrag`, `updateDrag`,\n * `drop`, `cancelDrag`), and where a drop may land is its `dropTargets`,\n * which are report-core's `validLocations`; this file only turns pointer\n * positions into a target's index with `targetNear` and `targetBeside`. So a\n * pointer is never offered a place the session would refuse, and the\n * keyboard path -- the place dialog -- offers exactly the same places\n * (formancy.ai 0046: every drag has a keyboard path, built first).\n *\n * A press becomes a drag only once it has moved, so a click stays a click:\n * activating a palette entry opens the place dialog, and clicking a box\n * selects it. Mouse and pen drag; a touch scrolls, as the page needs it to,\n * and a tap is a click.\n */\nimport { useEffect, useRef } from 'react'\nimport type { PointerEvent as ReactPointerEvent, RefObject } from 'react'\nimport { targetBeside, targetNear } from '@formancy/report-builder-core'\nimport type { DragSubject, OutlineNode, ReportEditor } from '@formancy/report-builder-core'\n\n/**\n * How far a press may wander, in CSS pixels, and still be a click: Windows'\n * default drag rectangle (`SM_CXDRAG`, `SM_CYDRAG`), which is what a person\n * on that system already has in their hands. A convention, not a measurement.\n */\nconst DRAG_DISTANCE = 4\n\n/** Where a drag can land: the outline's tree, and the canvas with its sheet. */\nexport interface DropZones {\n readonly tree: RefObject<HTMLElement | null>\n readonly canvas: RefObject<HTMLElement | null>\n readonly sheet: RefObject<HTMLElement | null>\n}\n\nexport interface PointerDrag {\n /** Watches a press on something that can be dragged; it becomes a drag once it moves. */\n press(event: ReactPointerEvent<HTMLElement>, subject: DragSubject): void\n /** True, once, for the click a drag ended in, before any key or press: that click must not also select or open what it ended on. */\n swallowClick(): boolean\n /** Remembers which node an outline row draws, so a drag over the row can find the places beside it. */\n row(element: HTMLElement | null, node: OutlineNode): void\n}\n\ninterface Press {\n readonly subject: DragSubject\n readonly x: number\n readonly y: number\n}\n\nexport function usePointerDrag(editor: ReportEditor, zones: DropZones, placed: () => void): PointerDrag {\n const pressed = useRef<Press | null>(null)\n const dragging = useRef(false)\n const swallow = useRef(false)\n const rows = useRef(new WeakMap<Element, OutlineNode>())\n // The latest of each, read when an event arrives, so a re-render never\n // re-subscribes -- which would cancel a drag in flight.\n const onPlaced = useRef(placed)\n onPlaced.current = placed\n const where = useRef(zones)\n where.current = zones\n\n useEffect(() => {\n /** The target under the pointer: beside the outline row it is over, else the nearest on the sheet, else none. */\n function over(event: PointerEvent): number | null {\n const targets = editor.state().dropTargets\n const zones = where.current\n const at = event.target instanceof Element ? event.target : null\n if (at === null) return null\n const row = at.closest('[role=\"treeitem\"]')\n if (row !== null && zones.tree.current?.contains(row) === true) {\n const node = rows.current.get(row)\n if (node === undefined || node.column !== undefined) return null\n const box = row.getBoundingClientRect()\n return targetBeside(targets, node.id, event.clientY < box.top + box.height / 2 ? 'before' : 'after')\n }\n const sheet = zones.sheet.current\n if (sheet === null || zones.canvas.current?.contains(at) !== true) return null\n // The targets are in pixels from the sheet's padding edge, where its\n // absolutely placed children start: inside its border.\n const box = sheet.getBoundingClientRect()\n return targetNear(targets, { x: event.clientX - box.left - sheet.clientLeft, y: event.clientY - box.top - sheet.clientTop })\n }\n\n /** Forgets the press, and says whether it had become a drag the editor still holds. */\n function release(): boolean {\n const was = dragging.current && editor.state().drag?.via === 'pointer'\n pressed.current = null\n dragging.current = false\n return was\n }\n\n function onMove(event: PointerEvent): void {\n const press = pressed.current\n if (press === null) return\n if (!dragging.current) {\n if (Math.hypot(event.clientX - press.x, event.clientY - press.y) < DRAG_DISTANCE) return\n if (!editor.dispatch({ type: 'startDrag', subject: press.subject, via: 'pointer' }).ok) {\n pressed.current = null\n return\n }\n dragging.current = true\n }\n // Ended elsewhere -- Escape, or the subject deleted under it -- and not to be revived.\n if (editor.state().drag?.via !== 'pointer') {\n release()\n return\n }\n editor.dispatch({ type: 'updateDrag', over: over(event) })\n }\n\n function onUp(): void {\n if (!release()) return\n swallow.current = true\n // With nothing under the pointer the editor ends the drag and says nothing moved.\n if (editor.dispatch({ type: 'drop' }).ok) onPlaced.current()\n }\n\n function onCancel(): void {\n if (release()) editor.dispatch({ type: 'cancelDrag' })\n }\n\n // The click a drop ends in comes straight after the release, with no key\n // or press between. A drop that ended away from where it began ends in\n // no click on what it began on; a key or a new press then is the\n // person's next act, whose click is theirs to keep.\n function forget(): void {\n swallow.current = false\n }\n\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onCancel)\n window.addEventListener('keydown', forget, true)\n window.addEventListener('pointerdown', forget, true)\n return () => {\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onCancel)\n window.removeEventListener('keydown', forget, true)\n window.removeEventListener('pointerdown', forget, true)\n // A drag in flight belongs to the builder that started it.\n if (release()) editor.dispatch({ type: 'cancelDrag' })\n }\n }, [editor])\n\n return {\n press(event, subject) {\n swallow.current = false\n if (event.button !== 0 || event.pointerType === 'touch') return\n pressed.current = { subject, x: event.clientX, y: event.clientY }\n },\n swallowClick() {\n const was = swallow.current\n swallow.current = false\n return was\n },\n row(element, node) {\n if (element !== null) rows.current.set(element, node)\n },\n }\n}\n","/**\n * The properties: one native control per field of the selection, or of the\n * report when nothing is selected, each labelled by its field's label.\n *\n * Which control a field gets is `PROPERTY_ROLES`, report-builder-core's, so\n * the role a test finds and the role the Angular builder renders are the\n * same. A typed value is the person's until it is committed -- on leaving\n * the field, or Enter in a single-line one -- and a value the editor refuses\n * stays as typed, `aria-invalid`, with the reason beside it as its\n * description. Escape gives back what the report holds. Under the\n * report's own fields, its images (`library`, 0033).\n */\nimport { useState } from 'react'\nimport type { KeyboardEvent, ReactElement, ReactNode } from 'react'\nimport type { EditorAction, EditorState, EditorText, PropertyField } from '@formancy/report-builder-core'\n\nexport interface PropertiesProps {\n readonly state: EditorState\n readonly ids: string\n readonly act: (action: EditorAction) => void\n /** The report's images, after its fields; nothing while something is selected. */\n readonly library?: ReactNode\n}\n\n/** What the control states about validity: invalid, and why, when the field has an error. */\ninterface Validity {\n readonly 'aria-invalid'?: true\n readonly 'aria-describedby'?: string\n}\n\ninterface ControlProps {\n readonly field: PropertyField\n readonly id: string\n readonly validity: Validity\n readonly commit: (value: string | boolean) => void\n}\n\n/** A text, a colour, an expression, a number or a length: typed, then committed. */\nfunction Typed({ field, id, validity, commit }: ControlProps): ReactElement {\n const held = String(field.value)\n const [draft, setDraft] = useState<string | null>(null)\n const finish = (): void => {\n if (draft !== null && draft !== held) commit(draft)\n setDraft(null)\n }\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>): void => {\n if (event.key === 'Escape') setDraft(null)\n else if (event.key === 'Enter' && field.kind !== 'multiline') {\n event.preventDefault()\n finish()\n }\n }\n const shared = {\n id,\n value: draft ?? held,\n required: field.required,\n ...(field.placeholder === undefined ? {} : { placeholder: field.placeholder }),\n ...validity,\n onBlur: finish,\n onKeyDown,\n }\n if (field.kind === 'multiline') return <textarea {...shared} onChange={(event) => setDraft(event.target.value)} />\n const numeric = field.kind === 'number' || field.kind === 'length'\n return (\n <input\n {...shared}\n type={numeric ? 'number' : 'text'}\n // Any decimal the format stores, not the browser's whole-number default step.\n step={numeric ? 'any' : undefined}\n spellCheck={field.kind === 'text' ? undefined : false}\n onChange={(event) => setDraft(event.target.value)}\n />\n )\n}\n\nfunction Control(props: ControlProps): ReactElement {\n const { field, id, validity, commit } = props\n switch (field.kind) {\n case 'boolean':\n return <input id={id} type=\"checkbox\" checked={field.value === true} {...validity} onChange={(event) => commit(event.target.checked)} />\n case 'select':\n case 'binding':\n case 'style':\n return (\n <select id={id} value={String(field.value)} required={field.required} {...validity} onChange={(event) => commit(event.target.value)}>\n {(field.options ?? []).map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n )\n default:\n return <Typed {...props} />\n }\n}\n\nexport function Properties({ state, ids, act, library }: PropertiesProps): ReactElement {\n return (\n // Named in words, as the pane's heading says, never after the heading,\n // which a stylesheet sets in capitals that Chromium would put in the name.\n <form aria-label={state.properties.heading} data-report-part=\"properties\" onSubmit={(event) => event.preventDefault()}>\n {state.properties.fields.map((field, at) => {\n const id = `${ids}-field-${at}`\n const error = `${id}-error`\n const validity: Validity = field.error === undefined ? {} : { 'aria-invalid': true, 'aria-describedby': error }\n return (\n // A draft never outlives its field: leaving the field commits it, before anything else can be selected.\n <div key={field.key} data-report-part=\"property\" data-kind={field.kind}>\n <label htmlFor={id}>{field.label}</label>\n <Control field={field} id={id} validity={validity} commit={(value) => act({ type: 'setProperty', key: field.key, value })} />\n {field.error === undefined ? null : (\n <p id={error} data-report-part=\"property-error\">\n {field.error}\n </p>\n )}\n </div>\n )\n })}\n {library}\n </form>\n )\n}\n","/**\n * The toolbar: undo and redo, the structural actions on the selection, the\n * zoom, and the panes a narrow screen shows one at a time.\n *\n * One tab stop for the whole bar, the arrow keys moving within it, as the\n * ARIA toolbar pattern has it. A tool with nothing to act on is\n * `aria-disabled` rather than `disabled`: it stays where focus is, so the\n * person who just pressed Redo for the last time keeps their place, and\n * pressing it again says why nothing happened instead of doing nothing.\n */\nimport { useRef, useState } from 'react'\nimport type { KeyboardEvent, ReactElement } from 'react'\nimport type { EditorAction, EditorPanel, EditorState, EditorText } from '@formancy/report-builder-core'\n\n/** What activating a tool does: an action for the editor, the place dialog for the selection, or a pane. */\ntype Use = { readonly action: EditorAction } | { readonly placeSelection: true } | { readonly pane: EditorPanel }\n\ninterface Tool {\n readonly name: string\n readonly use: Use\n readonly available: boolean\n /** Said as its description: what undo or redo would take back. */\n readonly title?: string\n}\n\nexport interface ToolbarProps {\n readonly state: EditorState\n readonly t: EditorText\n readonly act: (action: EditorAction) => void\n /** Opens the place dialog for the selection, focus to return to `from`. */\n readonly placeSelection: (from: HTMLElement) => void\n readonly showPane: (pane: EditorPanel) => void\n}\n\nfunction tools(state: EditorState, t: EditorText): { readonly before: readonly Tool[]; readonly zoom: readonly Tool[]; readonly panes: readonly Tool[] } {\n const { history, can } = state\n const act = (action: EditorAction): Use => ({ action })\n return {\n before: [\n { name: t('action.undo'), use: act({ type: 'undo' }), available: history.canUndo, ...(history.undoLabel === null ? {} : { title: t('action.undoWhat', { label: history.undoLabel }) }) },\n { name: t('action.redo'), use: act({ type: 'redo' }), available: history.canRedo, ...(history.redoLabel === null ? {} : { title: t('action.redoWhat', { label: history.redoLabel }) }) },\n { name: t('action.moveUp'), use: act({ type: 'moveUp' }), available: can.moveUp },\n { name: t('action.moveDown'), use: act({ type: 'moveDown' }), available: can.moveDown },\n { name: t('action.indent'), use: act({ type: 'indent' }), available: can.indent },\n { name: t('action.outdent'), use: act({ type: 'outdent' }), available: can.outdent },\n { name: t('action.moveTo'), use: { placeSelection: true }, available: can.moveTo },\n { name: t('action.duplicate'), use: act({ type: 'duplicate' }), available: can.duplicate },\n { name: t('action.delete'), use: act({ type: 'delete' }), available: can.delete },\n ],\n zoom: [\n { name: t('action.zoomOut'), use: act({ type: 'zoomOut' }), available: can.zoomOut },\n { name: t('action.zoomIn'), use: act({ type: 'zoomIn' }), available: can.zoomIn },\n { name: t('action.zoomReset'), use: act({ type: 'setZoom', zoom: 1 }), available: can.zoomReset },\n ],\n panes: [\n { name: t('pane.outline'), use: { pane: 'outline' }, available: true },\n { name: t('pane.canvas'), use: { pane: 'canvas' }, available: true },\n { name: t('pane.properties'), use: { pane: 'properties' }, available: true },\n { name: t('pane.problems'), use: { pane: 'diagnostics' }, available: true },\n ],\n }\n}\n\n/**\n * Which way the arrow keys step: the reading direction the page declares, so\n * → is \"next\" in a left-to-right page and \"previous\" in a right-to-left one.\n * A key held with a modifier is the browser's or the screen reader's, never\n * the toolbar's.\n */\nfunction step(event: KeyboardEvent<HTMLElement>, at: number, count: number): number | undefined {\n if (event.altKey || event.ctrlKey || event.metaKey) return undefined\n const forwards = event.currentTarget.closest('[dir]')?.getAttribute('dir') === 'rtl' ? -1 : 1\n switch (event.key) {\n case 'ArrowRight':\n return (at + forwards + count) % count\n case 'ArrowLeft':\n return (at - forwards + count) % count\n case 'Home':\n return 0\n case 'End':\n return count - 1\n default:\n return undefined\n }\n}\n\nexport function Toolbar({ state, t, act, placeSelection, showPane }: ToolbarProps): ReactElement {\n const [active, setActive] = useState(0)\n const buttons = useRef<(HTMLButtonElement | null)[]>([])\n const { before, zoom, panes } = tools(state, t)\n const all = [...before, ...zoom, ...panes]\n\n function use(tool: Tool, from: HTMLElement): void {\n if ('pane' in tool.use) return showPane(tool.use.pane)\n // Every other unavailable tool still asks, and the editor says why not;\n // this one has no component to place, only a table's column.\n if ('placeSelection' in tool.use) return tool.available ? placeSelection(from) : undefined\n act(tool.use.action)\n }\n\n function onKeyDown(event: KeyboardEvent<HTMLElement>): void {\n const next = step(event, active, all.length)\n if (next === undefined) return\n event.preventDefault()\n buttons.current[next]?.focus()\n }\n\n const button = (tool: Tool, at: number): ReactElement => (\n <button\n key={tool.name}\n ref={(element) => {\n buttons.current[at] = element\n }}\n type=\"button\"\n tabIndex={at === active ? 0 : -1}\n aria-disabled={tool.available ? undefined : true}\n title={tool.title}\n onFocus={() => setActive(at)}\n onClick={(event) => use(tool, event.currentTarget)}\n >\n {tool.name}\n </button>\n )\n\n return (\n <div role=\"toolbar\" aria-label={t('toolbar.label')} data-report-part=\"toolbar\" className=\"wb-tools\" onKeyDown={onKeyDown}>\n {before.map((tool, at) => button(tool, at))}\n {button(zoom[0] as Tool, before.length)}\n {/* The zoom as a value, named. Off as a live region: the editor's own\n status line already says \"Zoom 125%.\" once, and an <output> is a\n live region of its own that would say it twice. */}\n <output aria-label={t('zoom.label')} aria-live=\"off\" data-report-part=\"zoom\">\n {state.zoomLabel}\n </output>\n {zoom.slice(1).map((tool, at) => button(tool, before.length + 1 + at))}\n {panes.map((tool, at) => button(tool, before.length + zoom.length + at))}\n </div>\n )\n}\n","/**\n * The editor's state as a React value.\n *\n * `editor.state()` is deeply frozen and stays the same object until\n * something changes, which is exactly the snapshot `useSyncExternalStore`\n * compares by identity, so React re-renders once per change and never\n * loops. The subscription is the whole of React's part: what the state\n * holds is report-builder-core's, shared with the Angular builder (plan\n * 11.4).\n */\nimport { useSyncExternalStore } from 'react'\nimport type { EditorState, ReportEditor } from '@formancy/report-builder-core'\n\n/** Re-renders the component on every change to `editor`'s state; unsubscribes when it unmounts or the editor is replaced. */\nexport function useEditorState(editor: ReportEditor): EditorState {\n return useSyncExternalStore(editor.subscribe, editor.state, editor.state)\n}\n","/**\n * The report builder for React: the workbench's three panes over one\n * report-builder-core editor -- the palette and the outline, the design\n * view, the properties and the problems -- with the toolbar above them and\n * the status line below.\n *\n * It renders the editor's state and dispatches what the person did; it\n * decides nothing the editor decides. Keys are `actionForKey`'s, places are\n * the editor's drop targets, words are its catalogue. What is React's is\n * the subscription (`useSyncExternalStore`), the DOM, and focus: where focus\n * goes after an action, which only the builder can know, because only it\n * knows which element the person was on.\n *\n * The document and its history live in the session, so unmounting this and\n * mounting another builder -- React or Angular -- over the same session\n * loses nothing, and leaves no subscription behind.\n *\n * A host may give a view of its own -- the Studio's PDF -- which stands in\n * the design view's place while the editor says so (0029): a bare region,\n * named by the editor's `hostView`, holding what the host gave and nothing\n * of the builder's, its keys the host's.\n *\n * Where the host gave the editor a store for images, the palette ends with\n * Add image…, and the report's own properties list its images (0033): the\n * file a person chooses goes to `editor.addImage`, which says what became\n * of it; nothing here reads it.\n */\nimport { useCallback, useId, useLayoutEffect, useMemo, useRef } from 'react'\nimport type { KeyboardEvent, ReactElement, ReactNode } from 'react'\nimport { actionForKey, editorText } from '@formancy/report-builder-core'\nimport type { DiagnosticEntry, DragSubject, DropTarget, EditorAction, EditorOutcome, EditorPanel, HideablePanel, ReportEditor, Selection } from '@formancy/report-builder-core'\nimport type { ComponentKind } from '@formancy/report-spec'\nimport { Canvas } from './canvas.js'\nimport { Diagnostics } from './diagnostics.js'\nimport { ImageChooser } from './image-chooser.js'\nimport { ImageLibrary } from './image-library.js'\nimport { Outline } from './outline.js'\nimport { Palette } from './palette.js'\nimport { Places } from './places.js'\nimport { usePointerDrag } from './pointer-drag.js'\nimport { Properties } from './properties.js'\nimport { Toolbar } from './toolbar.js'\nimport { useEditorState } from './use-editor-state.js'\n\nexport interface ReportBuilderProps {\n /**\n * The editor to render: one person's view of a report session. The\n * builder subscribes while it is mounted and never disposes the editor;\n * whoever created it does, once no builder shows it.\n */\n readonly editor: ReportEditor\n /**\n * What the builder draws in the design view's place while the editor's\n * `view` is the host's: the host's own view, named by the editor's\n * `hostView`. The builder lends it the middle pane's box and a region's\n * name, none of report-builder.css's rules -- the workbench's `.wb *`\n * reaches it, turning transitions off under reduced motion -- and none of\n * its keys; it is mounted only while drawn.\n */\n readonly hostView?: ReactNode\n}\n\n/**\n * Where focus goes once the result of an action is drawn: the selection's\n * outline row, the place dialog this builder has just opened, the element\n * that opened it, or a pane.\n */\ntype FocusAfter = 'selection' | 'places' | 'opener' | EditorPanel\n\n/** A field that keeps its own keys: Ctrl+Z in it undoes typing, not the report, and its arrows move its caret. A checkbox has no typing to undo. */\nfunction keepsItsKeys(element: EventTarget): boolean {\n if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) return true\n return element instanceof HTMLInputElement && element.type !== 'checkbox'\n}\n\nexport function ReportBuilder({ editor, hostView }: ReportBuilderProps): ReactElement {\n const state = useEditorState(editor)\n const t = useMemo(() => editorText(state.locale), [state.locale])\n // Every id this builder mints starts here, so two builders on one page never share one.\n const ids = useId()\n const tree = useRef<HTMLDivElement>(null)\n const canvas = useRef<HTMLElement>(null)\n /** The host's view's region, while it stands in the design view's place. */\n const view = useRef<HTMLElement>(null)\n /** The last key press the host's view had first: React bubbles one from a portal the host opened there through the view, wherever the portal's DOM is. */\n const hostKey = useRef<Event | null>(null)\n /** The element the keyboard last stood on in this builder, for a middle pane swapped from under it to hand the keyboard on. */\n const lastFocused = useRef<EventTarget | null>(null)\n /** Whether that element stood in the properties form, for a row taken from under it to hand the keyboard to the first field. */\n const lastInProperties = useRef(false)\n const sheet = useRef<HTMLDivElement>(null)\n const fields = useRef<HTMLDivElement>(null)\n const problemList = useRef<HTMLUListElement>(null)\n const root = useRef<HTMLElement>(null)\n const opener = useRef<HTMLElement | null>(null)\n /** What the place dialog was placing when it closed, for focus to find its palette entry. */\n const closed = useRef<DragSubject | null>(null)\n const wanted = useRef<FocusAfter | null>(null)\n\n const focus = useCallback((where: FocusAfter): void => {\n const selectedRow = (): HTMLElement | null => tree.current?.querySelector<HTMLElement>('[role=\"treeitem\"][aria-selected=\"true\"]') ?? null\n switch (where) {\n // After an action that leaves nothing selected -- an undo of an\n // insert -- the tree itself: a row given focus would select itself,\n // and the next Delete would delete what nobody chose.\n case 'selection':\n return (selectedRow() ?? tree.current)?.focus()\n // Shown from the toolbar: the tree's tab stop, as Tab would reach it.\n case 'outline':\n return (selectedRow() ?? tree.current?.querySelector<HTMLElement>('[role=\"treeitem\"][tabindex=\"0\"]') ?? tree.current)?.focus()\n case 'places':\n return root.current?.querySelector<HTMLElement>('[data-report-part=\"places\"] button')?.focus()\n // What opened the place dialog; when another builder opened it -- the\n // drag outlived the builder that started it -- the palette entry of\n // what is being placed, or what is being moved, which stay in the\n // outline pane the dialog floated over.\n case 'opener': {\n const subject = closed.current\n const from =\n opener.current ??\n (subject !== null && 'kind' in subject ? root.current?.querySelector<HTMLElement>(`[data-report-part=\"palette-item\"][data-kind=\"${subject.kind}\"]`) : null) ??\n selectedRow() ??\n tree.current\n opener.current = null\n closed.current = null\n return from?.focus()\n }\n // The design view, or the host's view standing in its place.\n case 'canvas':\n return (canvas.current ?? view.current)?.focus()\n case 'properties':\n return fields.current?.querySelector<HTMLElement>('input, select, textarea')?.focus()\n case 'diagnostics':\n // The list, not its first entry: what is said first is how many there are.\n return problemList.current?.focus()\n }\n }, [])\n\n // After a render, the focus the action that caused it asked for: only now\n // is the row it selected, or the pane it opened, in the document.\n useLayoutEffect(() => {\n const where = wanted.current\n if (where === null) return\n wanted.current = null\n focus(where)\n })\n\n // The middle pane swapped by the host -- its view placed or shown from\n // outside, as the window crosses a width -- takes the keyboard along\n // rather than drop it on the page: where the element it stood on went\n // with the pane, and nothing has taken it since, it goes to what stands\n // in the middle now.\n useLayoutEffect(() => {\n const last = lastFocused.current\n const dropped = document.activeElement === null || document.activeElement === document.body\n if (last instanceof Node && !last.isConnected && dropped) focus('canvas')\n }, [state.view, focus])\n\n // An undo or a redo that takes away the row the keyboard stood on in the\n // properties -- an image's Remove, the add undone or the remove redone --\n // would leave it on the page: it goes to the first field, as a Remove\n // that worked sends it.\n useLayoutEffect(() => {\n const last = lastFocused.current\n const dropped = document.activeElement === null || document.activeElement === document.body\n if (lastInProperties.current && last instanceof Node && !last.isConnected && dropped) focus('properties')\n }, [state, focus])\n\n /** Dispatches `action`; when it succeeds, focus goes to `then` -- at once if nothing changed, else once the change is drawn. */\n function act(action: EditorAction, then?: FocusAfter): EditorOutcome {\n const before = editor.state()\n const outcome = editor.dispatch(action)\n if (then === undefined || !outcome.ok) return outcome\n if (editor.state() === before) focus(then)\n else wanted.current = then\n return outcome\n }\n\n const drag = usePointerDrag(editor, { tree, canvas, sheet }, () => {\n wanted.current = 'selection'\n })\n\n function onKeyDown(event: KeyboardEvent<HTMLElement>): void {\n // A key pressed in the host's view is the host's, as a text field's are its own.\n if (event.defaultPrevented || keepsItsKeys(event.target) || event.nativeEvent === hostKey.current) return\n const inTree = tree.current?.contains(event.target as Node) === true\n const action = actionForKey(event, inTree ? 'outline' : 'editor', state.drag !== null)\n if (action === undefined) return\n event.preventDefault()\n if (action.type === 'cancelDrag' && state.drag?.via === 'keyboard') return cancelPlaces()\n act(action, inTree ? 'selection' : undefined)\n }\n\n /**\n * Opens the place dialog for `subject`, focus to return to `from`, and\n * puts focus on its first place. Only here: a dialog that opened in\n * another builder -- the drag is the editor's, and outlives a builder --\n * is drawn by this one without taking the keyboard from where it is. It\n * floats over the outline pane, so that is the pane a narrow screen shows.\n */\n function openPlaces(subject: DragSubject, from: HTMLElement): void {\n opener.current = from\n if (!act({ type: 'startDrag', subject, via: 'keyboard' }).ok) {\n opener.current = null\n return\n }\n act({ type: 'openPanel', panel: 'outline' })\n // The drag began, so the dialog is drawn next: focus goes there then.\n wanted.current = 'places'\n }\n\n /** Closes the place dialog, Cancel or Escape, focus back to what opened it. */\n function cancelPlaces(): void {\n closed.current = editor.state().drag?.subject ?? null\n act({ type: 'cancelDrag' }, 'opener')\n }\n\n function place(kind: ComponentKind, from: HTMLElement): void {\n openPlaces({ kind }, from)\n }\n\n function placeSelection(from: HTMLElement): void {\n // The toolbar offers this only while `can.moveTo`, which holds only for a selected component.\n openPlaces({ id: (state.selection as Selection).id }, from)\n }\n\n function choose(subject: DragSubject, target: DropTarget): void {\n act('kind' in subject ? { type: 'insert', kind: subject.kind, target: target.location } : { type: 'move', id: subject.id, target: target.location }, 'selection')\n }\n\n function follow(entry: DiagnosticEntry): void {\n const { target } = entry\n if (target === null) act({ type: 'select', id: null })\n else act(target.column === undefined ? { type: 'select', id: target.id } : { type: 'select', id: target.id, column: target.column }, 'selection')\n }\n\n const choosing = state.drag?.via === 'keyboard' ? state.drag : null\n const count = state.diagnostics.length\n const shows = (panel: HideablePanel): boolean => !state.hidden.includes(panel)\n\n /** A side pane's Hide, named after the pane; the design view takes its room and the keyboard. */\n const hide = (panel: HideablePanel, name: string): ReactElement => (\n <button type=\"button\" data-report-part=\"hide-pane\" aria-label={t('action.hidePane', { pane: name })} onClick={() => act({ type: 'hidePanel', panel }, 'canvas')}>\n {t('action.hide')}\n </button>\n )\n\n return (\n <section\n ref={root}\n aria-label={t('editor.label')}\n className=\"wb\"\n data-report-part=\"editor\"\n data-panel={state.panel}\n data-hidden={state.hidden.length === 0 ? undefined : state.hidden.join(' ')}\n onKeyDown={onKeyDown}\n onFocus={(event) => {\n lastFocused.current = event.target\n lastInProperties.current = event.target.closest('[data-report-part=\"properties\"]') !== null\n }}\n >\n {/* A bar across the panes: report-builder.css spans every root child that is no pane. */}\n <div className=\"wb-pane\">\n <header>\n <span data-report-part=\"title\">{state.document.title}</span>\n <Toolbar state={state} t={t} act={act} placeSelection={placeSelection} showPane={(pane) => act({ type: 'openPanel', panel: pane }, pane)} />\n </header>\n </div>\n\n {/* The place dialog floats over this pane: the canvas beside it stays\n in view, with the place the dialog's focus is on marked. Opening\n the dialog shows the pane, were it hidden. */}\n {shows('outline') ? (\n <section className=\"wb-pane\" data-pane=\"outline\">\n <header>\n <span>{t('pane.outline')}</span>\n {hide('outline', t('pane.outline'))}\n </header>\n <div className=\"wb-body\">\n <Palette\n state={state}\n t={t}\n ids={ids}\n drag={drag}\n place={place}\n chooser={<ImageChooser state={state} t={t} ids={ids} choose={() => act({ type: 'chooseImage' }).ok} add={(file) => void editor.addImage(file)} />}\n />\n <Outline state={state} t={t} ids={ids} tree={tree} drag={drag} act={act} />\n </div>\n {choosing === null ? null : <Places state={state} drag={choosing} t={t} ids={ids} act={act} choose={choose} cancel={cancelPlaces} />}\n </section>\n ) : null}\n\n {/* The middle pane: the design view, or the host's view in its place --\n no workbench pane, so no rule of the builder's dresses what the host\n drew. Keyed, so that React draws each its own element rather than\n turn one into the other, the keyboard left on a pane no longer\n focusable. */}\n {state.view === 'host' ? (\n <section\n key=\"view\"\n ref={view}\n aria-label={state.hostView?.name}\n data-pane=\"canvas\"\n data-report-part=\"view\"\n tabIndex={-1}\n onKeyDown={(event) => {\n hostKey.current = event.nativeEvent\n }}\n >\n {hostView}\n </section>\n ) : (\n <section key=\"design\" className=\"wb-pane wb-canvas\" data-pane=\"canvas\">\n <header>{t('pane.canvas')}</header>\n <div className=\"wb-body\">\n <Canvas state={state} t={t} canvas={canvas} sheet={sheet} drag={drag} select={(action) => act(action, 'selection')} />\n </div>\n </section>\n )}\n\n {/* The properties and the problems share the third column. On a narrow\n screen report-builder.css shows the one pane `data-panel` names, so\n this column says it is whichever of its two is asked for, and each\n half carries its own name for the other to be hidden by. Each half\n hides alone; the column goes with the second. */}\n {shows('properties') || shows('diagnostics') ? (\n <section className=\"wb-pane\" data-pane={state.panel === 'diagnostics' || !shows('properties') ? 'diagnostics' : 'properties'}>\n {shows('properties') ? (\n <>\n <header data-pane=\"properties\">\n <span>{state.properties.heading}</span>\n {state.selection === null ? null : (\n <button type=\"button\" onClick={() => act({ type: 'select', id: null }, 'properties')}>\n {t('properties.report')}\n </button>\n )}\n {hide('properties', t('pane.properties'))}\n </header>\n <div ref={fields} className=\"wb-body\" data-pane=\"properties\">\n <Properties\n state={state}\n ids={ids}\n act={act}\n library={state.selection === null ? <ImageLibrary state={state} t={t} ids={ids} remove={(asset) => act({ type: 'removeImage', asset }, 'properties')} /> : null}\n />\n </div>\n </>\n ) : null}\n {shows('diagnostics') ? (\n <>\n <header data-pane=\"diagnostics\">\n {/* A status, so a change in how many problems there are is said\n without taking the person's place: \"Problems 2\". Named in\n words, never after its own heading, which the Studio sets in\n capitals that Chromium would put in the name. */}\n <div role=\"status\" aria-label={t('pane.problems')}>\n <span>{t('pane.problems')}</span>\n {count === 0 ? null : (\n <>\n {' '}\n <span data-report-part=\"badge\" data-severity={state.diagnostics.some((entry) => entry.severity === 'error') ? 'error' : 'warning'}>\n {count}\n </span>\n </>\n )}\n </div>\n {hide('diagnostics', t('pane.problems'))}\n </header>\n <div className=\"wb-body\" data-pane=\"diagnostics\">\n <Diagnostics state={state} t={t} ids={ids} list={problemList} follow={follow} />\n </div>\n </>\n ) : null}\n </section>\n ) : null}\n\n <div className=\"wb-pane\">\n {/* The editor's announcements. Each is a new child, so the same words\n said twice -- \"Nothing to undo.\" -- are two announcements, as the\n state's sequence number means them to be. */}\n <p role=\"status\" data-report-part=\"status\">\n {state.status.text === '' ? null : <span key={state.status.sequence}>{state.status.text}</span>}\n </p>\n </div>\n </section>\n )\n}\n"],"mappings":";;;;;AAgCA,SAAS,OAAO,KAAyB;CACvC,OAAO;EAAE,MAAM,IAAI;EAAG,KAAK,IAAI;EAAG,OAAO,IAAI;EAAO,QAAQ,IAAI;CAAO;AACzE;AAEA,SAAS,MAAM,EAAE,aAAa,OAAO,QAAQ,SAAmK;C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;;AAEb"}
1
+ {"version":3,"file":"index.mjs","names":["described","selection"],"sources":["../src/canvas.tsx","../src/diagnostics.tsx","../src/image-chooser.tsx","../src/image-library.tsx","../src/outline.tsx","../src/palette.tsx","../src/places.tsx","../src/pointer-drag.ts","../src/properties.tsx","../src/toolbar.tsx","../src/use-editor-state.ts","../src/report-builder.tsx"],"sourcesContent":["/**\n * The design view: one sheet as wide as the page, the regions as bands on it,\n * a box per component and table column, a payment part's band at its foot,\n * rulers in millimetres, and while something is being placed, an indicator\n * at every place it may go.\n *\n * It draws the state's geometry and decides none: every left, top, width and\n * height is a number report-builder-core computed in pixels at the zoom. It\n * is labelled as not the PDF, because it is not -- the renderer measures text\n * and breaks pages, and the preview shows what prints.\n *\n * Each box is a picture of where a component stands -- `role=\"img\"`, named\n * by its label, so reading the view says what is on it. A click selects; a\n * box is not a tab stop, because the outline is the keyboard's way to every\n * box and two ways to the same place would double the tabbing. The payment\n * part's band is the same for the bill (0039). The view itself is one\n * stop, so a keyboard can scroll it. A box, or the band, that prints a\n * word not written yet in the language edited is marked, and described by\n * the sentence that says so (0063).\n */\nimport type { CSSProperties, ReactElement, Ref } from 'react'\nimport type { Box, CanvasBox, EditorAction, EditorState, EditorText, RulerTick } from '@formancy/report-builder-core'\nimport type { PointerDrag } from './pointer-drag.js'\n\nexport interface CanvasProps {\n readonly state: EditorState\n readonly t: EditorText\n readonly canvas: Ref<HTMLElement>\n readonly sheet: Ref<HTMLDivElement>\n readonly drag: PointerDrag\n /** Selects a box, focus to follow to its outline row. */\n readonly select: (action: EditorAction) => void\n}\n\n/** A box's place on the sheet: physical left and top, because a page's coordinates run from its top-left whatever the language. */\nfunction placed(box: Box): CSSProperties {\n return { left: box.x, top: box.y, width: box.width, height: box.height }\n}\n\nfunction Ruler({\n orientation,\n ticks,\n length,\n label,\n}: {\n readonly orientation: 'horizontal' | 'vertical'\n readonly ticks: readonly RulerTick[]\n readonly length: number\n readonly label: string\n}): ReactElement {\n const across = orientation === 'horizontal'\n return (\n <div role=\"img\" aria-label={label} data-report-part=\"ruler\" data-orientation={orientation} style={across ? { width: length } : { height: length }}>\n {ticks.map((tick) => (\n <span key={tick.mm} data-report-part=\"ruler-tick\" data-major={tick.major ? 'true' : undefined} style={across ? { left: tick.at } : { top: tick.at }}>\n {tick.label === undefined ? null : <span>{tick.label}</span>}\n </span>\n ))}\n </div>\n )\n}\n\n/** What a box says beyond its name, as its description: that it runs over, and that a word it prints is missing in the language edited. */\nfunction described(box: CanvasBox, t: EditorText): string | undefined {\n const said = [box.overflows ? t('canvas.overflow') : undefined, box.missing].filter((sentence) => sentence !== undefined)\n return said.length === 0 ? undefined : said.join('. ')\n}\n\nfunction selection(box: CanvasBox): EditorAction {\n return box.column === undefined ? { type: 'select', id: box.id } : { type: 'select', id: box.id, column: box.column }\n}\n\nexport function Canvas({ state, t, canvas: canvasRef, sheet: sheetRef, drag, select }: CanvasProps): ReactElement {\n const { canvas, drag: placing, dropTargets } = state\n const moving = placing !== null && 'id' in placing.subject ? placing.subject.id : undefined\n return (\n <section ref={canvasRef} aria-label={canvas.label} data-report-part=\"canvas\" tabIndex={0}>\n <p data-report-part=\"canvas-note\">{canvas.note}</p>\n <Ruler orientation=\"horizontal\" ticks={canvas.rulers.horizontal} length={canvas.sheet.px.width} label={t('ruler.horizontal')} />\n <Ruler orientation=\"vertical\" ticks={canvas.rulers.vertical} length={canvas.sheet.px.height} label={t('ruler.vertical')} />\n <div ref={sheetRef} data-report-part=\"sheet\" style={{ width: canvas.sheet.px.width, height: canvas.sheet.px.height }}>\n {canvas.regions.map((region) => (\n <div key={region.region} data-report-part=\"region\" data-empty={region.empty ? 'true' : undefined} style={placed(region.px)}>\n <span data-report-part=\"region-label\">{region.label}</span>\n </div>\n ))}\n {canvas.boxes.map((box) => (\n <div\n key={box.key}\n role=\"img\"\n aria-label={box.label}\n data-report-part=\"box\"\n data-kind={box.kind}\n data-selected={box.selected ? 'true' : undefined}\n data-overflows={box.overflows ? 'true' : undefined}\n data-missing={box.missing === undefined ? undefined : 'true'}\n data-dragging={box.column === undefined && box.id === moving ? 'true' : undefined}\n title={described(box, t)}\n style={placed(box.px)}\n onPointerDown={(event) => {\n if (box.column === undefined) drag.press(event, { id: box.id })\n }}\n onClick={() => {\n if (!drag.swallowClick()) select(selection(box))\n }}\n >\n <span data-report-part=\"box-label\">{box.label}</span>\n {box.problems > 0 ? (\n <span data-report-part=\"badge\" data-severity={box.severity} aria-hidden=\"true\">\n {box.problems}\n </span>\n ) : null}\n </div>\n ))}\n {/* Where a payment part's slip prints, below every region: a\n picture named as SIX names the part, as a box is named by its\n label, which a click selects the bill by, as it does a box's\n component. */}\n {canvas.paymentPart === null ? null : (\n <div\n role=\"img\"\n aria-label={canvas.paymentPart.label}\n data-report-part=\"payment-part\"\n data-selected={canvas.paymentPart.selected ? 'true' : undefined}\n data-missing={canvas.paymentPart.missing === undefined ? undefined : 'true'}\n title={canvas.paymentPart.missing}\n style={placed(canvas.paymentPart.px)}\n onClick={() => select({ type: 'select', part: 'paymentPart' })}\n >\n <span data-report-part=\"region-label\">{canvas.paymentPart.label}</span>\n {canvas.paymentPart.problems > 0 ? (\n <span data-report-part=\"badge\" data-severity={canvas.paymentPart.severity} aria-hidden=\"true\">\n {canvas.paymentPart.problems}\n </span>\n ) : null}\n </div>\n )}\n {/* Drawn only for the places the session accepts, named as the place\n dialog names them; the one under the pointer, or focused in the\n dialog, is marked. */}\n {placing === null\n ? null\n : dropTargets.map((target) => (\n <div\n key={target.index}\n role=\"img\"\n aria-label={target.label}\n data-report-part=\"drop-indicator\"\n data-over={placing.over === target.index ? 'true' : undefined}\n style={placed(target.px)}\n />\n ))}\n </div>\n </section>\n )\n}\n","/**\n * The problems: report-core's diagnostics, each a button named \"Error:\n * Introduction\" and described by report-core's sentence. Activating one\n * selects what it is about, and the builder moves focus to its outline row;\n * one about the report as a whole selects nothing, which shows the report's\n * own properties.\n *\n * Each entry is keyed by what it is (`DiagnosticEntry.key`), never by its\n * place in the list: a problem listed before the one the keyboard is on\n * leaves that one's button, and the keyboard, where they were.\n */\nimport type { ReactElement, Ref } from 'react'\nimport type { DiagnosticEntry, EditorState, EditorText } from '@formancy/report-builder-core'\n\nexport interface DiagnosticsProps {\n readonly state: EditorState\n readonly t: EditorText\n readonly ids: string\n readonly list: Ref<HTMLUListElement>\n readonly follow: (entry: DiagnosticEntry) => void\n}\n\nexport function Diagnostics({ state, t, ids, list, follow }: DiagnosticsProps): ReactElement {\n return (\n <>\n {/* Not a tab stop: the problems pane's button moves focus here, to say\n how many there are. Named in words, as the pane's heading says. */}\n <ul ref={list} aria-label={t('pane.problems')} data-report-part=\"diagnostics\" tabIndex={-1}>\n {state.diagnostics.map((entry, at) => {\n const message = `${ids}-problem-${at}`\n return (\n <li key={entry.key} data-report-part=\"diagnostic\" data-severity={entry.severity}>\n <button type=\"button\" aria-describedby={message} onClick={() => follow(entry)}>\n {entry.label}\n </button>\n <div id={message}>{entry.message}</div>\n </li>\n )\n })}\n </ul>\n {state.diagnostics.length === 0 ? <p>{t('problems.none')}</p> : null}\n </>\n )\n}\n","/**\n * Add image…: the palette's last button, where the host keeps images\n * (0033), and the file input it opens, hidden beside it.\n *\n * The button sends `chooseImage` and, when the editor will take a file\n * now, calls the input's `click()` at once, in the same activation -- a\n * click, Enter or Space -- which opens the platform's chooser; awaiting\n * anything first would lose the activation, and the browser would open\n * nothing. The input is outside the accessibility tree and never has\n * focus: the keyboard stays on the button throughout.\n *\n * On the input's change the file is taken into a local before `value` is\n * cleared, because in a browser clearing it empties `files`; it is cleared\n * so that the same file chosen again is a change again. A chooser closed\n * without a file changes nothing, and nothing is sent. What the file is,\n * and whether it is added, is the editor's to say, in the live region.\n */\nimport { useRef } from 'react'\nimport type { ReactElement } from 'react'\nimport type { EditorState, EditorText } from '@formancy/report-builder-core'\n\nexport interface ImageChooserProps {\n readonly state: EditorState\n readonly t: EditorText\n /** Prefix for the element ids this pane mints, unique to its builder. */\n readonly ids: string\n /** Sends `chooseImage`: whether the editor takes a file now, else it has said why not. */\n readonly choose: () => boolean\n /** Hands the editor the file a person chose. */\n readonly add: (file: File) => void\n}\n\nexport function ImageChooser({ state, t, ids, choose, add }: ImageChooserProps): ReactElement | null {\n const input = useRef<HTMLInputElement>(null)\n const { images } = state\n if (!images.store) return null\n const why = `${ids}-unavailable-add-image`\n return (\n <>\n <button\n type=\"button\"\n data-report-part=\"palette-item\"\n aria-disabled={state.can.addImage ? undefined : true}\n aria-describedby={images.unavailable === undefined ? undefined : why}\n aria-busy={images.adding === null ? undefined : true}\n onClick={() => {\n if (choose()) input.current?.click()\n }}\n >\n {t('images.add')}\n {images.unavailable === undefined ? null : (\n <span id={why} hidden>\n {images.unavailable}\n </span>\n )}\n </button>\n <input\n ref={input}\n type=\"file\"\n hidden\n accept={images.accept}\n onChange={(event) => {\n const chosen = event.currentTarget\n const file = chosen.files?.[0]\n chosen.value = ''\n if (file !== undefined) add(file)\n }}\n />\n </>\n )\n}\n","/**\n * The report's images, listed under its own properties (0033): a group\n * named by the catalogue, with a row per image the report declares -- its\n * label as text, and a Remove named after the image.\n *\n * A Remove whose image something draws is `aria-disabled`, described by\n * what draws it, and still sends `removeImage`, so the live region says\n * why nothing happened. One that removed its image takes its own button\n * away, so the builder puts the keyboard on the first field, as the way\n * back to the report's properties does.\n */\nimport type { ReactElement } from 'react'\nimport type { EditorState, EditorText } from '@formancy/report-builder-core'\n\nexport interface ImageLibraryProps {\n readonly state: EditorState\n readonly t: EditorText\n /** Prefix for the element ids this pane mints, unique to its builder. */\n readonly ids: string\n readonly remove: (asset: string) => void\n}\n\nexport function ImageLibrary({ state, t, ids, remove }: ImageLibraryProps): ReactElement | null {\n const { assets } = state.images\n if (assets.length === 0) return null\n return (\n <div role=\"group\" aria-label={t('images.heading')}>\n {assets.map((image, at) => {\n const why = `${ids}-image-${String(at)}-in-use`\n return (\n <div key={image.id} data-report-part=\"property\">\n <span>{image.label}</span>\n <button\n type=\"button\"\n aria-label={image.removeLabel}\n aria-disabled={image.inUse === undefined ? undefined : true}\n aria-describedby={image.inUse === undefined ? undefined : why}\n onClick={() => remove(image.id)}\n >\n {t('images.remove')}\n {image.inUse === undefined ? null : (\n <span id={why} hidden>\n {image.inUse}\n </span>\n )}\n </button>\n </div>\n )\n })}\n </div>\n )\n}\n","/**\n * The outline: the report as an ARIA tree, a group per region and a row per\n * component or table column, then a row at the tree's top for each part of\n * the report's own level -- its payment part, after every region, as it\n * prints (0039); with no row at all, an empty tree and the sentence that\n * says so.\n *\n * Rows are flat within their region and nest by `aria-level`, which is also\n * what report-builder.css indents by, so the nesting drawn and the nesting\n * announced cannot disagree. One row is a tab stop -- the selected one, or\n * the first -- and focus follows the selection: moving focus to a row\n * selects it, and every action that selects moves focus to its row. The\n * keys are report-builder-core's `actionForKey`, which the builder applies\n * to the whole tree; nothing here decides a key.\n */\nimport type { ReactElement, Ref } from 'react'\nimport type { EditorAction, EditorState, EditorText, OutlineNode, OutlinePart } from '@formancy/report-builder-core'\nimport type { PointerDrag } from './pointer-drag.js'\n\nexport interface OutlineProps {\n readonly state: EditorState\n readonly t: EditorText\n readonly ids: string\n readonly tree: Ref<HTMLDivElement>\n readonly drag: PointerDrag\n readonly act: (action: EditorAction) => void\n}\n\n/** A node with its place among its siblings, for `aria-posinset` and `aria-setsize`. */\ninterface Row {\n readonly node: OutlineNode\n readonly position: number\n readonly siblings: number\n}\n\nfunction rows(nodes: readonly OutlineNode[], into: Row[] = []): Row[] {\n nodes.forEach((node, at) => {\n into.push({ node, position: at + 1, siblings: nodes.length })\n rows(node.children, into)\n })\n return into\n}\n\n/** The ids of what describes a row: how many problems it has, and that it is wider than its place. */\nfunction described(node: Pick<OutlineNode, 'problems'> & { readonly overflows?: boolean }, problems: string, overflow: string): string | undefined {\n const ids = [...(node.problems > 0 ? [problems] : []), ...(node.overflows === true ? [overflow] : [])]\n return ids.length === 0 ? undefined : ids.join(' ')\n}\n\n/** A row's count of problems: drawn, and said as its description; inside the name it would make \"Introduction\" read \"Introduction 1\". */\nfunction Problems({\n row,\n id,\n t,\n}: {\n readonly row: Pick<OutlineNode, 'problems' | 'severity'>\n readonly id: string\n readonly t: EditorText\n}): ReactElement | null {\n if (row.problems === 0) return null\n return (\n <>\n <span data-report-part=\"badge\" data-severity={row.severity} aria-hidden=\"true\">\n {row.problems}\n </span>\n <span id={id} hidden>\n {t('outline.problems', { count: row.problems })}\n </span>\n </>\n )\n}\n\nfunction selection(node: OutlineNode): EditorAction {\n return node.column === undefined ? { type: 'select', id: node.id } : { type: 'select', id: node.id, column: node.column }\n}\n\nexport function Outline({ state, t, ids, tree, drag, act }: OutlineProps): ReactElement {\n const regions = state.outline.map((region) => ({ region, rows: rows(region.nodes) }))\n const all: readonly { readonly key: string; readonly selected: boolean }[] = [\n ...regions.flatMap((region) => region.rows.map((row) => row.node)),\n ...state.outlineParts,\n ]\n // The tree's one tab stop: the selected row, else the first; the tree itself when it has none.\n const stop = all.find((row) => row.selected)?.key ?? all[0]?.key\n const empty = `${ids}-outline-empty`\n\n // With no row at all the tree holds nothing -- a tree owns rows, and a\n // region's name with none under it is not one -- and is itself the tab\n // stop, described by the sentence beside it. With rows it still takes\n // focus from a script, never from Tab: where focus goes when an action\n // leaves nothing selected, since focusing a row would select it.\n if (stop === undefined) {\n return (\n <>\n <div ref={tree} role=\"tree\" aria-label={t('pane.outline')} aria-describedby={empty} data-report-part=\"outline\" tabIndex={0} />\n <p id={empty} data-report-part=\"outline-empty\">\n {t('outline.empty')}\n </p>\n </>\n )\n }\n\n return (\n <div ref={tree} role=\"tree\" aria-label={t('pane.outline')} data-report-part=\"outline\" tabIndex={-1}>\n {regions.map(({ region, rows: list }) => {\n return (\n // Named in the editor's words, not after the label drawn in it:\n // Chromium would put report-builder.css's capitals into that name,\n // \"BODY\". The label is hidden from the tree, which would read it\n // again as a text among the group's rows.\n <div key={region.region} role=\"group\" aria-label={region.label} data-report-part=\"outline-region\">\n <span data-report-part=\"region-label\" aria-hidden=\"true\">\n {region.label}\n </span>\n {list.length === 0 ? <span>{t('outline.empty')}</span> : null}\n {list.map(({ node, position, siblings }) => {\n const problems = `${ids}-problems-${node.key}`\n const overflow = `${ids}-overflow-${node.key}`\n return (\n <div\n key={node.key}\n ref={(element) => drag.row(element, node)}\n role=\"treeitem\"\n aria-level={node.depth + 1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-selected={node.selected}\n aria-describedby={described(node, problems, overflow)}\n tabIndex={node.key === stop ? 0 : -1}\n data-report-part=\"outline-item\"\n data-kind={node.kind}\n onPointerDown={(event) => {\n if (node.column === undefined) drag.press(event, { id: node.id })\n }}\n onFocus={() => {\n if (!node.selected) act(selection(node))\n }}\n onClick={() => {\n if (!drag.swallowClick()) act(selection(node))\n }}\n >\n {node.label}\n <Problems row={node} id={problems} t={t} />\n {/* What the canvas marks on a box too wide for its place,\n said where a keyboard is: on its row. */}\n {node.overflows ? (\n <span id={overflow} hidden>\n {t('canvas.overflow')}\n </span>\n ) : null}\n </div>\n )\n })}\n </div>\n )\n })}\n {state.outlineParts.map((part, at) => (\n <PartRow key={part.key} part={part} position={at + 1} siblings={state.outlineParts.length} tabbable={part.key === stop} ids={ids} t={t} act={act} />\n ))}\n </div>\n )\n}\n\n/**\n * A part of the report's own level, as a row at the tree's top: selected by\n * focus or a click, as a component's row is, and dragged nowhere, since it\n * has one place.\n */\nfunction PartRow({\n part,\n position,\n siblings,\n tabbable,\n ids,\n t,\n act,\n}: {\n readonly part: OutlinePart\n readonly position: number\n readonly siblings: number\n readonly tabbable: boolean\n readonly ids: string\n readonly t: EditorText\n readonly act: (action: EditorAction) => void\n}): ReactElement {\n const problems = `${ids}-problems-${part.key}`\n const select = (): void => act({ type: 'select', part: part.part })\n return (\n <div\n role=\"treeitem\"\n aria-level={1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-selected={part.selected}\n aria-describedby={described(part, problems, '')}\n tabIndex={tabbable ? 0 : -1}\n data-report-part=\"outline-item\"\n onFocus={() => {\n if (!part.selected) select()\n }}\n onClick={select}\n >\n {part.label}\n <Problems row={part} id={problems} t={t} />\n </div>\n )\n}\n","/**\n * The palette: one button per kind of component the format has.\n *\n * Activating one -- a click, Enter or Space -- opens the place dialog for\n * that kind, the keyboard path every drag has. Pressing one and moving is\n * the pointer path to the same places. An entry the report cannot hold yet\n * (an image with nothing to draw) stays in the list, `aria-disabled` and\n * described by what to declare first, so it is found rather than missed.\n * Where the host keeps images, Add image… stands last (`chooser`, 0033).\n */\nimport type { ReactElement, ReactNode } from 'react'\nimport type { EditorState, EditorText } from '@formancy/report-builder-core'\nimport type { ComponentKind } from '@formancy/report-spec'\nimport type { PointerDrag } from './pointer-drag.js'\n\nexport interface PaletteProps {\n readonly state: EditorState\n readonly t: EditorText\n /** Prefix for the element ids this pane mints, unique to its builder. */\n readonly ids: string\n readonly drag: PointerDrag\n /** Opens the place dialog for a new component of `kind`, focus to return to `from`. */\n readonly place: (kind: ComponentKind, from: HTMLElement) => void\n /** Add image… and its file input, after the entries; nothing where the host keeps no images. */\n readonly chooser?: ReactNode\n}\n\nexport function Palette({ state, t, ids, drag, place, chooser }: PaletteProps): ReactElement {\n return (\n <div role=\"group\" aria-label={t('pane.palette')} data-report-part=\"palette\">\n {state.palette.map((entry) => {\n const why = `${ids}-unavailable-${entry.kind}`\n return (\n <button\n key={entry.kind}\n type=\"button\"\n data-report-part=\"palette-item\"\n data-kind={entry.kind}\n aria-disabled={entry.component === null ? true : undefined}\n aria-describedby={entry.unavailable === undefined ? undefined : why}\n onPointerDown={(event) => drag.press(event, { kind: entry.kind })}\n onClick={(event) => {\n if (!drag.swallowClick()) place(entry.kind, event.currentTarget)\n }}\n >\n {entry.label}\n {entry.unavailable === undefined ? null : (\n <span id={why} hidden>\n {entry.unavailable}\n </span>\n )}\n </button>\n )\n })}\n {chooser}\n </div>\n )\n}\n","/**\n * The place dialog: the keyboard path for every drag (formancy.ai 0046).\n *\n * While the editor's drag is `via: 'keyboard'` it lists the drag's targets\n * -- the places report-core's `validLocations` accepts, named \"Body, after\n * Introduction\" -- as buttons, and Cancel. Focus moves into it when this\n * builder opens it (the builder's `openPlaces`), never merely because it is\n * drawn: a dialog another builder opened stays where the keyboard left it.\n * The place focused is the one the canvas marks, so a sighted keyboard user\n * sees where each choice lands before making it. Escape cancels, through the\n * editor's own key map. Choosing a place, and cancelling, are the builder's\n * to finish: it knows where focus goes next.\n */\nimport type { ReactElement } from 'react'\nimport type { DragState, DropTarget, EditorAction, EditorState, EditorText } from '@formancy/report-builder-core'\n\nexport interface PlacesProps {\n readonly state: EditorState\n readonly drag: DragState\n readonly t: EditorText\n readonly ids: string\n readonly act: (action: EditorAction) => void\n readonly choose: (subject: DragState['subject'], target: DropTarget) => void\n readonly cancel: () => void\n}\n\nexport function Places({ state, drag, t, ids, act, choose, cancel }: PlacesProps): ReactElement {\n const nowhere = `${ids}-nowhere`\n\n return (\n // A floating pane of the workbench, so its buttons are the workbench's.\n // Named in the editor's words, as the header says, never after the\n // header, whose name a host's stylesheet could set in capitals.\n <div\n role=\"dialog\"\n aria-label={drag.title}\n aria-describedby={drag.nowhere === undefined ? undefined : nowhere}\n data-report-part=\"places\"\n className=\"wb-pane\"\n >\n <header>{drag.title}</header>\n {drag.nowhere === undefined ? null : (\n <p id={nowhere} className=\"wb-problem\">\n {drag.nowhere}\n </p>\n )}\n {state.dropTargets.map((target) => (\n <button\n key={target.index}\n type=\"button\"\n data-report-part=\"place\"\n onFocus={() => act({ type: 'updateDrag', over: target.index })}\n onClick={() => choose(drag.subject, target)}\n >\n {target.label}\n </button>\n ))}\n <button type=\"button\" onClick={cancel}>\n {t('places.cancel')}\n </button>\n </div>\n )\n}\n","/**\n * Dragging with a pointer: a palette entry, a box on the canvas or an outline\n * row, dropped on the canvas or beside an outline row.\n *\n * The drag itself is the editor's state machine (`startDrag`, `updateDrag`,\n * `drop`, `cancelDrag`), and where a drop may land is its `dropTargets`,\n * which are report-core's `validLocations`; this file only turns pointer\n * positions into a target's index with `targetNear` and `targetBeside`. So a\n * pointer is never offered a place the session would refuse, and the\n * keyboard path -- the place dialog -- offers exactly the same places\n * (formancy.ai 0046: every drag has a keyboard path, built first).\n *\n * A press becomes a drag only once it has moved, so a click stays a click:\n * activating a palette entry opens the place dialog, and clicking a box\n * selects it. Mouse and pen drag; a touch scrolls, as the page needs it to,\n * and a tap is a click.\n */\nimport { useEffect, useRef } from 'react'\nimport type { PointerEvent as ReactPointerEvent, RefObject } from 'react'\nimport { targetBeside, targetNear } from '@formancy/report-builder-core'\nimport type { DragSubject, OutlineNode, ReportEditor } from '@formancy/report-builder-core'\n\n/**\n * How far a press may wander, in CSS pixels, and still be a click: Windows'\n * default drag rectangle (`SM_CXDRAG`, `SM_CYDRAG`), which is what a person\n * on that system already has in their hands. A convention, not a measurement.\n */\nconst DRAG_DISTANCE = 4\n\n/** Where a drag can land: the outline's tree, and the canvas with its sheet. */\nexport interface DropZones {\n readonly tree: RefObject<HTMLElement | null>\n readonly canvas: RefObject<HTMLElement | null>\n readonly sheet: RefObject<HTMLElement | null>\n}\n\nexport interface PointerDrag {\n /** Watches a press on something that can be dragged; it becomes a drag once it moves. */\n press(event: ReactPointerEvent<HTMLElement>, subject: DragSubject): void\n /** True, once, for the click a drag ended in, before any key or press: that click must not also select or open what it ended on. */\n swallowClick(): boolean\n /** Remembers which node an outline row draws, so a drag over the row can find the places beside it. */\n row(element: HTMLElement | null, node: OutlineNode): void\n}\n\ninterface Press {\n readonly subject: DragSubject\n readonly x: number\n readonly y: number\n}\n\nexport function usePointerDrag(editor: ReportEditor, zones: DropZones, placed: () => void): PointerDrag {\n const pressed = useRef<Press | null>(null)\n const dragging = useRef(false)\n const swallow = useRef(false)\n const rows = useRef(new WeakMap<Element, OutlineNode>())\n // The latest of each, read when an event arrives, so a re-render never\n // re-subscribes -- which would cancel a drag in flight.\n const onPlaced = useRef(placed)\n onPlaced.current = placed\n const where = useRef(zones)\n where.current = zones\n\n useEffect(() => {\n /** The target under the pointer: beside the outline row it is over, else the nearest on the sheet, else none. */\n function over(event: PointerEvent): number | null {\n const targets = editor.state().dropTargets\n const zones = where.current\n const at = event.target instanceof Element ? event.target : null\n if (at === null) return null\n const row = at.closest('[role=\"treeitem\"]')\n if (row !== null && zones.tree.current?.contains(row) === true) {\n const node = rows.current.get(row)\n if (node === undefined || node.column !== undefined) return null\n const box = row.getBoundingClientRect()\n return targetBeside(targets, node.id, event.clientY < box.top + box.height / 2 ? 'before' : 'after')\n }\n const sheet = zones.sheet.current\n if (sheet === null || zones.canvas.current?.contains(at) !== true) return null\n // The targets are in pixels from the sheet's padding edge, where its\n // absolutely placed children start: inside its border.\n const box = sheet.getBoundingClientRect()\n return targetNear(targets, { x: event.clientX - box.left - sheet.clientLeft, y: event.clientY - box.top - sheet.clientTop })\n }\n\n /** Forgets the press, and says whether it had become a drag the editor still holds. */\n function release(): boolean {\n const was = dragging.current && editor.state().drag?.via === 'pointer'\n pressed.current = null\n dragging.current = false\n return was\n }\n\n function onMove(event: PointerEvent): void {\n const press = pressed.current\n if (press === null) return\n if (!dragging.current) {\n if (Math.hypot(event.clientX - press.x, event.clientY - press.y) < DRAG_DISTANCE) return\n if (!editor.dispatch({ type: 'startDrag', subject: press.subject, via: 'pointer' }).ok) {\n pressed.current = null\n return\n }\n dragging.current = true\n }\n // Ended elsewhere -- Escape, or the subject deleted under it -- and not to be revived.\n if (editor.state().drag?.via !== 'pointer') {\n release()\n return\n }\n editor.dispatch({ type: 'updateDrag', over: over(event) })\n }\n\n function onUp(): void {\n if (!release()) return\n swallow.current = true\n // With nothing under the pointer the editor ends the drag and says nothing moved.\n if (editor.dispatch({ type: 'drop' }).ok) onPlaced.current()\n }\n\n function onCancel(): void {\n if (release()) editor.dispatch({ type: 'cancelDrag' })\n }\n\n // The click a drop ends in comes straight after the release, with no key\n // or press between. A drop that ended away from where it began ends in\n // no click on what it began on; a key or a new press then is the\n // person's next act, whose click is theirs to keep.\n function forget(): void {\n swallow.current = false\n }\n\n window.addEventListener('pointermove', onMove)\n window.addEventListener('pointerup', onUp)\n window.addEventListener('pointercancel', onCancel)\n window.addEventListener('keydown', forget, true)\n window.addEventListener('pointerdown', forget, true)\n return () => {\n window.removeEventListener('pointermove', onMove)\n window.removeEventListener('pointerup', onUp)\n window.removeEventListener('pointercancel', onCancel)\n window.removeEventListener('keydown', forget, true)\n window.removeEventListener('pointerdown', forget, true)\n // A drag in flight belongs to the builder that started it.\n if (release()) editor.dispatch({ type: 'cancelDrag' })\n }\n }, [editor])\n\n return {\n press(event, subject) {\n swallow.current = false\n if (event.button !== 0 || event.pointerType === 'touch') return\n pressed.current = { subject, x: event.clientX, y: event.clientY }\n },\n swallowClick() {\n const was = swallow.current\n swallow.current = false\n return was\n },\n row(element, node) {\n if (element !== null) rows.current.set(element, node)\n },\n }\n}\n","/**\n * The properties: one native control per field of the selection, or of the\n * report when nothing is selected, each labelled by its field's label.\n *\n * Which control a field gets is `PROPERTY_ROLES`, report-builder-core's, so\n * the role a test finds and the role the Angular builder renders are the\n * same. A typed value is the person's until it is committed -- on leaving\n * the field, or Enter in a single-line one -- and a value the editor refuses\n * stays as typed, `aria-invalid`, with the reason beside it as its\n * description. Escape gives back what the report holds. Under the\n * report's own fields, its images (`library`, 0033). A field at a word in\n * a language besides the report's own has its note under it, which\n * describes it too, and is marked while the word is missing (0063).\n *\n * Fields the editor groups -- a QR-bill's creditor and debtor (0039), an\n * e-invoice's parties, its VAT categories and its payment instructions\n * (0044) -- are a `group` named in the editor's words, their name drawn and\n * hidden from the tree, which reads the group's own, and the group's\n * buttons after them, one with nowhere to go `aria-disabled` and still\n * sent. A button keeps the keyboard where it is as its words change, Add to\n * Remove and back, unless the editor says where it goes once done (`then`):\n * the same button of the group a VAT category moved to, the list's Add once\n * one is removed, a new one's first field (report-builder.tsx). Add\n * QR-bill, which gives the properties the bill's in place of the report's,\n * takes its own button away, and the keyboard goes to the first field, the\n * bill's IBAN, as it does when a Remove takes its row.\n *\n * Each run of a paragraph is such a group, its buttons Subscript and\n * Superscript, each named after the run, showing only its own word, and\n * `aria-pressed` as the run is set (0061). Pressed, one sends the\n * selection of its group's text field -- its start, its end and the text\n * it is of -- read from the element as the button is pressed: the one\n * thing only the DOM knows, which the editor applies to the text the\n * report holds and to nothing else. The keyboard then goes where the\n * editor's outcome says, the run that holds the text now.\n */\nimport { useRef, useState } from 'react'\nimport type { KeyboardEvent, ReactElement, ReactNode } from 'react'\nimport type { EditorAction, EditorState, PropertyAction, PropertyField, PropertyGroup } from '@formancy/report-builder-core'\n\nexport interface PropertiesProps {\n readonly state: EditorState\n readonly ids: string\n readonly act: (action: EditorAction) => void\n /** A group's button pressed: its action, and where the keyboard goes once it is done. */\n readonly press: (action: PropertyAction) => void\n /** The report's images, after its fields; nothing while something is selected. */\n readonly library?: ReactNode\n}\n\n/** What the control states about validity: invalid, and why, when the field has an error. */\ninterface Validity {\n readonly 'aria-invalid'?: true\n readonly 'aria-describedby'?: string\n}\n\ninterface ControlProps {\n readonly field: PropertyField\n readonly id: string\n readonly validity: Validity\n readonly commit: (value: string | boolean) => void\n}\n\n/** A text, a colour, an expression, a number or a length: typed, then committed. */\nfunction Typed({ field, id, validity, commit }: ControlProps): ReactElement {\n const held = String(field.value)\n const [draft, setDraft] = useState<string | null>(null)\n const finish = (): void => {\n if (draft !== null && draft !== held) commit(draft)\n setDraft(null)\n }\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>): void => {\n if (event.key === 'Escape') setDraft(null)\n else if (event.key === 'Enter' && field.kind !== 'multiline') {\n event.preventDefault()\n finish()\n }\n }\n const shared = {\n id,\n value: draft ?? held,\n required: field.required,\n ...(field.placeholder === undefined ? {} : { placeholder: field.placeholder }),\n ...validity,\n onBlur: finish,\n onKeyDown,\n }\n if (field.kind === 'multiline') return <textarea {...shared} onChange={(event) => setDraft(event.target.value)} />\n const numeric = field.kind === 'number' || field.kind === 'length'\n return (\n <input\n {...shared}\n type={numeric ? 'number' : 'text'}\n // Any decimal the format stores, not the browser's whole-number default step.\n step={numeric ? 'any' : undefined}\n spellCheck={field.kind === 'text' ? undefined : false}\n onChange={(event) => setDraft(event.target.value)}\n />\n )\n}\n\nfunction Control(props: ControlProps): ReactElement {\n const { field, id, validity, commit } = props\n switch (field.kind) {\n case 'boolean':\n return <input id={id} type=\"checkbox\" checked={field.value === true} {...validity} onChange={(event) => commit(event.target.checked)} />\n case 'select':\n case 'binding':\n case 'style':\n return (\n <select id={id} value={String(field.value)} required={field.required} {...validity} onChange={(event) => commit(event.target.value)}>\n {(field.options ?? []).map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n )\n default:\n return <Typed {...props} />\n }\n}\n\n/** One field's row: its label, its control and, after a refusal or about a problem, why. `at` is its place among every field, for its ids. */\nfunction Row({\n field,\n at,\n ids,\n act,\n}: {\n readonly field: PropertyField\n readonly at: number\n readonly ids: string\n readonly act: PropertiesProps['act']\n}): ReactElement {\n const id = `${ids}-field-${at}`\n const error = `${id}-error`\n const note = `${id}-note`\n // Described by why it was refused, and by what its note says of the language it writes.\n const described = [field.error === undefined ? null : error, field.note === undefined ? null : note].filter((part) => part !== null).join(' ')\n const validity: Validity = {\n ...(field.error === undefined ? {} : { 'aria-invalid': true }),\n ...(described === '' ? {} : { 'aria-describedby': described }),\n }\n return (\n <div data-report-part=\"property\" data-kind={field.kind} data-missing={field.missing === true ? 'true' : undefined}>\n <label htmlFor={id}>{field.label}</label>\n <Control field={field} id={id} validity={validity} commit={(value) => act({ type: 'setProperty', key: field.key, value })} />\n {field.error === undefined ? null : (\n <p id={error} data-report-part=\"property-error\">\n {field.error}\n </p>\n )}\n {field.note === undefined ? null : (\n <p id={note} data-report-part=\"property-note\">\n {field.note}\n </p>\n )}\n </div>\n )\n}\n\n/**\n * What a group's button sends: a run's `setBaseline` with what its group's\n * text field has selected, read from the element now, as only the DOM\n * knows it (0061); any other action as the state gives it. A field bound\n * to a value is a select, and has no selection: its run is set whole.\n */\nfunction sent(action: PropertyAction, group: HTMLElement | null): PropertyAction {\n if (action.action.type !== 'setBaseline') return action\n const field = group?.querySelector('input, textarea')\n if (!(field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement) || field.selectionStart === null || field.selectionEnd === null)\n return action\n return { ...action, action: { ...action.action, selected: { start: field.selectionStart, end: field.selectionEnd, text: field.value } } }\n}\n\n/** A group of fields, named in the editor's words, with its buttons after them, each keyed by its place so that it keeps the keyboard as its words change. */\nfunction Group({\n group,\n first,\n ids,\n act,\n press,\n}: {\n readonly group: PropertyGroup\n readonly first: number\n readonly ids: string\n readonly act: PropertiesProps['act']\n readonly press: PropertiesProps['press']\n}): ReactElement {\n const element = useRef<HTMLDivElement>(null)\n return (\n <div ref={element} role=\"group\" aria-label={group.label} data-report-part=\"property-group\">\n <span aria-hidden=\"true\">{group.label}</span>\n {group.fields.map((field, at) => (\n // A draft never outlives its field: leaving the field commits it, before anything else can be selected.\n <Row key={field.key} field={field} at={first + at} ids={ids} act={act} />\n ))}\n {group.actions.map((action, at) => (\n <button\n key={`action-${String(at)}`}\n type=\"button\"\n aria-label={action.text === undefined ? undefined : action.label}\n aria-pressed={action.pressed}\n aria-disabled={action.available ? undefined : true}\n onClick={() => press(sent(action, element.current))}\n >\n {action.text ?? action.label}\n </button>\n ))}\n </div>\n )\n}\n\nexport function Properties({ state, ids, act, press, library }: PropertiesProps): ReactElement {\n // Each field's place among every field, for its ids, groups' fields counted where they stand.\n let next = 0\n return (\n // Named in words, as the pane's heading says, never after the heading,\n // which a stylesheet sets in capitals that Chromium would put in the name.\n <form aria-label={state.properties.heading} data-report-part=\"properties\" onSubmit={(event) => event.preventDefault()}>\n {state.properties.rows.map((row) => {\n const first = next\n if ('group' in row) {\n next += row.group.fields.length\n return <Group key={row.group.key} group={row.group} first={first} ids={ids} act={act} press={press} />\n }\n next += 1\n // A draft never outlives its field: leaving the field commits it, before anything else can be selected.\n return <Row key={row.field.key} field={row.field} at={first} ids={ids} act={act} />\n })}\n {library}\n </form>\n )\n}\n","/**\n * The toolbar: undo and redo, the structural actions on the selection, the\n * zoom, and the panes a narrow screen shows one at a time.\n *\n * One tab stop for the whole bar, the arrow keys moving within it, as the\n * ARIA toolbar pattern has it. A tool with nothing to act on is\n * `aria-disabled` rather than `disabled`: it stays where focus is, so the\n * person who just pressed Redo for the last time keeps their place, and\n * pressing it again says why nothing happened instead of doing nothing.\n */\nimport { useRef, useState } from 'react'\nimport type { KeyboardEvent, ReactElement } from 'react'\nimport type { EditorAction, EditorPanel, EditorState, EditorText } from '@formancy/report-builder-core'\n\n/** What activating a tool does: an action for the editor, the place dialog for the selection, or a pane. */\ntype Use = { readonly action: EditorAction } | { readonly placeSelection: true } | { readonly pane: EditorPanel }\n\ninterface Tool {\n readonly name: string\n readonly use: Use\n readonly available: boolean\n /** Said as its description: what undo or redo would take back. */\n readonly title?: string\n}\n\nexport interface ToolbarProps {\n readonly state: EditorState\n readonly t: EditorText\n readonly act: (action: EditorAction) => void\n /** Opens the place dialog for the selection, focus to return to `from`. */\n readonly placeSelection: (from: HTMLElement) => void\n readonly showPane: (pane: EditorPanel) => void\n}\n\nfunction tools(state: EditorState, t: EditorText): { readonly before: readonly Tool[]; readonly zoom: readonly Tool[]; readonly panes: readonly Tool[] } {\n const { history, can } = state\n const act = (action: EditorAction): Use => ({ action })\n return {\n before: [\n {\n name: t('action.undo'),\n use: act({ type: 'undo' }),\n available: history.canUndo,\n ...(history.undoLabel === null ? {} : { title: t('action.undoWhat', { label: history.undoLabel }) }),\n },\n {\n name: t('action.redo'),\n use: act({ type: 'redo' }),\n available: history.canRedo,\n ...(history.redoLabel === null ? {} : { title: t('action.redoWhat', { label: history.redoLabel }) }),\n },\n { name: t('action.moveUp'), use: act({ type: 'moveUp' }), available: can.moveUp },\n { name: t('action.moveDown'), use: act({ type: 'moveDown' }), available: can.moveDown },\n { name: t('action.indent'), use: act({ type: 'indent' }), available: can.indent },\n { name: t('action.outdent'), use: act({ type: 'outdent' }), available: can.outdent },\n { name: t('action.moveTo'), use: { placeSelection: true }, available: can.moveTo },\n { name: t('action.duplicate'), use: act({ type: 'duplicate' }), available: can.duplicate },\n { name: t('action.delete'), use: act({ type: 'delete' }), available: can.delete },\n ],\n zoom: [\n { name: t('action.zoomOut'), use: act({ type: 'zoomOut' }), available: can.zoomOut },\n { name: t('action.zoomIn'), use: act({ type: 'zoomIn' }), available: can.zoomIn },\n { name: t('action.zoomReset'), use: act({ type: 'setZoom', zoom: 1 }), available: can.zoomReset },\n ],\n panes: [\n { name: t('pane.outline'), use: { pane: 'outline' }, available: true },\n { name: t('pane.canvas'), use: { pane: 'canvas' }, available: true },\n { name: t('pane.properties'), use: { pane: 'properties' }, available: true },\n { name: t('pane.problems'), use: { pane: 'diagnostics' }, available: true },\n ],\n }\n}\n\n/**\n * Which way the arrow keys step: the reading direction the page declares, so\n * → is \"next\" in a left-to-right page and \"previous\" in a right-to-left one.\n * A key held with a modifier is the browser's or the screen reader's, never\n * the toolbar's.\n */\nfunction step(event: KeyboardEvent<HTMLElement>, at: number, count: number): number | undefined {\n if (event.altKey || event.ctrlKey || event.metaKey) return undefined\n const forwards = event.currentTarget.closest('[dir]')?.getAttribute('dir') === 'rtl' ? -1 : 1\n switch (event.key) {\n case 'ArrowRight':\n return (at + forwards + count) % count\n case 'ArrowLeft':\n return (at - forwards + count) % count\n case 'Home':\n return 0\n case 'End':\n return count - 1\n default:\n return undefined\n }\n}\n\nexport function Toolbar({ state, t, act, placeSelection, showPane }: ToolbarProps): ReactElement {\n const [active, setActive] = useState(0)\n const buttons = useRef<(HTMLButtonElement | null)[]>([])\n const { before, zoom, panes } = tools(state, t)\n const all = [...before, ...zoom, ...panes]\n\n function use(tool: Tool, from: HTMLElement): void {\n if ('pane' in tool.use) return showPane(tool.use.pane)\n // Every other unavailable tool still asks, and the editor says why not;\n // this one has no component to place, only a table's column.\n if ('placeSelection' in tool.use) return tool.available ? placeSelection(from) : undefined\n act(tool.use.action)\n }\n\n function onKeyDown(event: KeyboardEvent<HTMLElement>): void {\n const next = step(event, active, all.length)\n if (next === undefined) return\n event.preventDefault()\n buttons.current[next]?.focus()\n }\n\n const button = (tool: Tool, at: number): ReactElement => (\n <button\n key={tool.name}\n ref={(element) => {\n buttons.current[at] = element\n }}\n type=\"button\"\n tabIndex={at === active ? 0 : -1}\n aria-disabled={tool.available ? undefined : true}\n title={tool.title}\n onFocus={() => setActive(at)}\n onClick={(event) => use(tool, event.currentTarget)}\n >\n {tool.name}\n </button>\n )\n\n return (\n <div role=\"toolbar\" aria-label={t('toolbar.label')} data-report-part=\"toolbar\" className=\"wb-tools\" onKeyDown={onKeyDown}>\n {before.map((tool, at) => button(tool, at))}\n {button(zoom[0] as Tool, before.length)}\n {/* The zoom as a value, named. Off as a live region: the editor's own\n status line already says \"Zoom 125%.\" once, and an <output> is a\n live region of its own that would say it twice. */}\n <output aria-label={t('zoom.label')} aria-live=\"off\" data-report-part=\"zoom\">\n {state.zoomLabel}\n </output>\n {zoom.slice(1).map((tool, at) => button(tool, before.length + 1 + at))}\n {panes.map((tool, at) => button(tool, before.length + zoom.length + at))}\n </div>\n )\n}\n","/**\n * The editor's state as a React value.\n *\n * `editor.state()` is deeply frozen and stays the same object until\n * something changes, which is exactly the snapshot `useSyncExternalStore`\n * compares by identity, so React re-renders once per change and never\n * loops. The subscription is the whole of React's part: what the state\n * holds is report-builder-core's, shared with the Angular builder (plan\n * 11.4).\n */\nimport { useSyncExternalStore } from 'react'\nimport type { EditorState, ReportEditor } from '@formancy/report-builder-core'\n\n/** Re-renders the component on every change to `editor`'s state; unsubscribes when it unmounts or the editor is replaced. */\nexport function useEditorState(editor: ReportEditor): EditorState {\n return useSyncExternalStore(editor.subscribe, editor.state, editor.state)\n}\n","/**\n * The report builder for React: the workbench's three panes over one\n * report-builder-core editor -- the palette and the outline, the design\n * view, the properties and the problems -- with the toolbar above them and\n * the status line below.\n *\n * It renders the editor's state and dispatches what the person did; it\n * decides nothing the editor decides. Keys are `actionForKey`'s, places are\n * the editor's drop targets, words are its catalogue. What is React's is\n * the subscription (`useSyncExternalStore`), the DOM, and focus: where focus\n * goes after an action, which only the builder can know, because only it\n * knows which element the person was on.\n *\n * The document and its history live in the session, so unmounting this and\n * mounting another builder -- React or Angular -- over the same session\n * loses nothing, and leaves no subscription behind.\n *\n * A host may give a view of its own -- the Studio's PDF -- which stands in\n * the design view's place while the editor says so (0029): a bare region,\n * named by the editor's `hostView`, holding what the host gave and nothing\n * of the builder's, its keys the host's.\n *\n * A report written in more than one language has a switch between them\n * beside its title, which shows and edits the words of the one chosen\n * (0063).\n *\n * Where the host gave the editor a store for images, the palette ends with\n * Add image…, and the report's own properties list its images (0033): the\n * file a person chooses goes to `editor.addImage`, which says what became\n * of it; nothing here reads it.\n */\nimport { useCallback, useId, useLayoutEffect, useMemo, useRef } from 'react'\nimport type { KeyboardEvent, ReactElement, ReactNode } from 'react'\nimport { actionForKey, editorText } from '@formancy/report-builder-core'\nimport type {\n ComponentSelection,\n DiagnosticEntry,\n DragSubject,\n DropTarget,\n EditorAction,\n EditorOutcome,\n EditorPanel,\n HideablePanel,\n PropertyAction,\n ReportEditor,\n} from '@formancy/report-builder-core'\nimport type { ComponentKind } from '@formancy/report-spec'\nimport { Canvas } from './canvas.js'\nimport { Diagnostics } from './diagnostics.js'\nimport { ImageChooser } from './image-chooser.js'\nimport { ImageLibrary } from './image-library.js'\nimport { Outline } from './outline.js'\nimport { Palette } from './palette.js'\nimport { Places } from './places.js'\nimport { usePointerDrag } from './pointer-drag.js'\nimport { Properties } from './properties.js'\nimport { Toolbar } from './toolbar.js'\nimport { useEditorState } from './use-editor-state.js'\n\nexport interface ReportBuilderProps {\n /**\n * The editor to render: one person's view of a report session. The\n * builder subscribes while it is mounted and never disposes the editor;\n * whoever created it does, once no builder shows it.\n */\n readonly editor: ReportEditor\n /**\n * What the builder draws in the design view's place while the editor's\n * `view` is the host's: the host's own view, named by the editor's\n * `hostView`. The builder lends it the middle pane's box and a region's\n * name, none of report-builder.css's rules -- the workbench's `.wb *`\n * reaches it, turning transitions off under reduced motion -- and none of\n * its keys; it is mounted only while drawn.\n */\n readonly hostView?: ReactNode\n}\n\n/**\n * Where focus goes once the result of an action is drawn: the selection's\n * outline row, the place dialog this builder has just opened, the element\n * that opened it, a pane, or where a group's button says (`then`): a button\n * of the group with that key, or its first field.\n */\ntype FocusAfter = 'selection' | 'places' | 'opener' | EditorPanel | NonNullable<PropertyAction['then']>\n\n/** A field that keeps its own keys: Ctrl+Z in it undoes typing, not the report, and its arrows move its caret. A checkbox has no typing to undo. */\nfunction keepsItsKeys(element: EventTarget): boolean {\n if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) return true\n return element instanceof HTMLInputElement && element.type !== 'checkbox'\n}\n\nexport function ReportBuilder({ editor, hostView }: ReportBuilderProps): ReactElement {\n const state = useEditorState(editor)\n const t = useMemo(() => editorText(state.locale), [state.locale])\n // Every id this builder mints starts here, so two builders on one page never share one.\n const ids = useId()\n const tree = useRef<HTMLDivElement>(null)\n const canvas = useRef<HTMLElement>(null)\n /** The host's view's region, while it stands in the design view's place. */\n const view = useRef<HTMLElement>(null)\n /** The last key press the host's view had first: React bubbles one from a portal the host opened there through the view, wherever the portal's DOM is. */\n const hostKey = useRef<Event | null>(null)\n /** The element the keyboard last stood on in this builder, for a middle pane swapped from under it to hand the keyboard on. */\n const lastFocused = useRef<EventTarget | null>(null)\n /** Whether that element stood in the properties form, for a row taken from under it to hand the keyboard to the first field. */\n const lastInProperties = useRef(false)\n const sheet = useRef<HTMLDivElement>(null)\n const fields = useRef<HTMLDivElement>(null)\n const problemList = useRef<HTMLUListElement>(null)\n const root = useRef<HTMLElement>(null)\n const opener = useRef<HTMLElement | null>(null)\n /** What the place dialog was placing when it closed, for focus to find its palette entry. */\n const closed = useRef<DragSubject | null>(null)\n const wanted = useRef<FocusAfter | null>(null)\n\n const focus = useCallback(\n (where: FocusAfter): void => {\n const selectedRow = (): HTMLElement | null => tree.current?.querySelector<HTMLElement>('[role=\"treeitem\"][aria-selected=\"true\"]') ?? null\n if (typeof where === 'object') {\n // The groups stand in the form in the order of the state's rows: the one with the key, by its place among them.\n const groups = editor.state().properties.rows.flatMap((row) => ('group' in row ? [row.group.key] : []))\n const element = fields.current?.querySelectorAll<HTMLElement>('[data-report-part=\"property-group\"]')[groups.indexOf(where.group)]\n return (\n where.button === undefined\n ? element?.querySelector<HTMLElement>('input, select, textarea')\n : element?.querySelectorAll<HTMLElement>(':scope > button')[where.button]\n )?.focus()\n }\n switch (where) {\n // After an action that leaves nothing selected -- an undo of an\n // insert -- the tree itself: a row given focus would select itself,\n // and the next Delete would delete what nobody chose.\n case 'selection':\n return (selectedRow() ?? tree.current)?.focus()\n // Shown from the toolbar: the tree's tab stop, as Tab would reach it.\n case 'outline':\n return (selectedRow() ?? tree.current?.querySelector<HTMLElement>('[role=\"treeitem\"][tabindex=\"0\"]') ?? tree.current)?.focus()\n case 'places':\n return root.current?.querySelector<HTMLElement>('[data-report-part=\"places\"] button')?.focus()\n // What opened the place dialog; when another builder opened it -- the\n // drag outlived the builder that started it -- the palette entry of\n // what is being placed, or what is being moved, which stay in the\n // outline pane the dialog floated over.\n case 'opener': {\n const subject = closed.current\n const from =\n opener.current ??\n (subject !== null && 'kind' in subject\n ? root.current?.querySelector<HTMLElement>(`[data-report-part=\"palette-item\"][data-kind=\"${subject.kind}\"]`)\n : null) ??\n selectedRow() ??\n tree.current\n opener.current = null\n closed.current = null\n return from?.focus()\n }\n // The design view, or the host's view standing in its place.\n case 'canvas':\n return (canvas.current ?? view.current)?.focus()\n case 'properties':\n return fields.current?.querySelector<HTMLElement>('input, select, textarea')?.focus()\n case 'diagnostics':\n // The list, not its first entry: what is said first is how many there are.\n return problemList.current?.focus()\n }\n },\n [editor],\n )\n\n // After a render, the focus the action that caused it asked for: only now\n // is the row it selected, or the pane it opened, in the document.\n useLayoutEffect(() => {\n const where = wanted.current\n if (where === null) return\n wanted.current = null\n focus(where)\n })\n\n // The middle pane swapped by the host -- its view placed or shown from\n // outside, as the window crosses a width -- takes the keyboard along\n // rather than drop it on the page: where the element it stood on went\n // with the pane, and nothing has taken it since, it goes to what stands\n // in the middle now.\n useLayoutEffect(() => {\n const last = lastFocused.current\n const dropped = document.activeElement === null || document.activeElement === document.body\n if (last instanceof Node && !last.isConnected && dropped) focus('canvas')\n }, [state.view, focus])\n\n // An undo or a redo that takes away the row the keyboard stood on in the\n // properties -- an image's Remove, the add undone or the remove redone --\n // would leave it on the page: it goes to the first field, as a Remove\n // that worked sends it.\n useLayoutEffect(() => {\n const last = lastFocused.current\n const dropped = document.activeElement === null || document.activeElement === document.body\n if (lastInProperties.current && last instanceof Node && !last.isConnected && dropped) focus('properties')\n }, [state, focus])\n\n /**\n * Dispatches `action`; when it succeeds, focus goes to `then` -- at once\n * if nothing changed, else once the change is drawn -- or where the\n * outcome says, where the action decided it only once done: a run's\n * button, whose run a split moved (0061).\n */\n function act(action: EditorAction, then?: FocusAfter): EditorOutcome {\n const before = editor.state()\n const outcome = editor.dispatch(action)\n const where = outcome.ok ? (outcome.then ?? then) : undefined\n if (where === undefined) return outcome\n if (editor.state() === before) focus(where)\n else wanted.current = where\n return outcome\n }\n\n const drag = usePointerDrag(editor, { tree, canvas, sheet }, () => {\n wanted.current = 'selection'\n })\n\n function onKeyDown(event: KeyboardEvent<HTMLElement>): void {\n // A key pressed in the host's view is the host's, as a text field's are its own.\n if (event.defaultPrevented || keepsItsKeys(event.target) || event.nativeEvent === hostKey.current) return\n const inTree = tree.current?.contains(event.target as Node) === true\n const action = actionForKey(event, inTree ? 'outline' : 'editor', state.drag !== null)\n if (action === undefined) return\n event.preventDefault()\n if (action.type === 'cancelDrag' && state.drag?.via === 'keyboard') return cancelPlaces()\n act(action, inTree ? 'selection' : undefined)\n }\n\n /**\n * Opens the place dialog for `subject`, focus to return to `from`, and\n * puts focus on its first place. Only here: a dialog that opened in\n * another builder -- the drag is the editor's, and outlives a builder --\n * is drawn by this one without taking the keyboard from where it is. It\n * floats over the outline pane, so that is the pane a narrow screen shows.\n */\n function openPlaces(subject: DragSubject, from: HTMLElement): void {\n opener.current = from\n if (!act({ type: 'startDrag', subject, via: 'keyboard' }).ok) {\n opener.current = null\n return\n }\n act({ type: 'openPanel', panel: 'outline' })\n // The drag began, so the dialog is drawn next: focus goes there then.\n wanted.current = 'places'\n }\n\n /** Closes the place dialog, Cancel or Escape, focus back to what opened it. */\n function cancelPlaces(): void {\n closed.current = editor.state().drag?.subject ?? null\n act({ type: 'cancelDrag' }, 'opener')\n }\n\n function place(kind: ComponentKind, from: HTMLElement): void {\n openPlaces({ kind }, from)\n }\n\n function placeSelection(from: HTMLElement): void {\n // The toolbar offers this only while `can.moveTo`, which holds only for a selected component.\n openPlaces({ id: (state.selection as ComponentSelection).id }, from)\n }\n\n function choose(subject: DragSubject, target: DropTarget): void {\n act(\n 'kind' in subject ? { type: 'insert', kind: subject.kind, target: target.location } : { type: 'move', id: subject.id, target: target.location },\n 'selection',\n )\n }\n\n function follow(entry: DiagnosticEntry): void {\n const { target } = entry\n if (target === null) act({ type: 'select', id: null })\n else if ('part' in target) act({ type: 'select', part: target.part }, 'selection')\n else act(target.column === undefined ? { type: 'select', id: target.id } : { type: 'select', id: target.id, column: target.column }, 'selection')\n }\n\n const choosing = state.drag?.via === 'keyboard' ? state.drag : null\n const count = state.diagnostics.length\n const shows = (panel: HideablePanel): boolean => !state.hidden.includes(panel)\n\n /** A side pane's Hide, named after the pane; the design view takes its room and the keyboard. */\n const hide = (panel: HideablePanel, name: string): ReactElement => (\n <button\n type=\"button\"\n data-report-part=\"hide-pane\"\n aria-label={t('action.hidePane', { pane: name })}\n onClick={() => act({ type: 'hidePanel', panel }, 'canvas')}\n >\n {t('action.hide')}\n </button>\n )\n\n return (\n <section\n ref={root}\n aria-label={t('editor.label')}\n className=\"wb\"\n data-report-part=\"editor\"\n data-panel={state.panel}\n data-hidden={state.hidden.length === 0 ? undefined : state.hidden.join(' ')}\n onKeyDown={onKeyDown}\n onFocus={(event) => {\n lastFocused.current = event.target\n lastInProperties.current = event.target.closest('[data-report-part=\"properties\"]') !== null\n }}\n >\n {/* A bar across the panes: report-builder.css spans every root child that is no pane. */}\n <div className=\"wb-pane\">\n <header>\n <span data-report-part=\"title\">{state.document.title}</span>\n {/* The language whose words the builder shows (0063): there only for a report written in more than one. */}\n {state.languages.declared.length > 1 ? (\n <select\n aria-label={t('language.label')}\n data-report-part=\"language\"\n value={state.languages.edited}\n onChange={(event) => act({ type: 'setLanguage', locale: event.target.value })}\n >\n {state.languages.declared.map((language) => (\n <option key={language.locale} value={language.locale}>\n {language.label}\n </option>\n ))}\n </select>\n ) : null}\n <Toolbar state={state} t={t} act={act} placeSelection={placeSelection} showPane={(pane) => act({ type: 'openPanel', panel: pane }, pane)} />\n </header>\n </div>\n\n {/* The place dialog floats over this pane: the canvas beside it stays\n in view, with the place the dialog's focus is on marked. Opening\n the dialog shows the pane, were it hidden. */}\n {shows('outline') ? (\n <section className=\"wb-pane\" data-pane=\"outline\">\n <header>\n <span>{t('pane.outline')}</span>\n {hide('outline', t('pane.outline'))}\n </header>\n <div className=\"wb-body\">\n <Palette\n state={state}\n t={t}\n ids={ids}\n drag={drag}\n place={place}\n chooser={<ImageChooser state={state} t={t} ids={ids} choose={() => act({ type: 'chooseImage' }).ok} add={(file) => void editor.addImage(file)} />}\n />\n <Outline state={state} t={t} ids={ids} tree={tree} drag={drag} act={act} />\n </div>\n {choosing === null ? null : <Places state={state} drag={choosing} t={t} ids={ids} act={act} choose={choose} cancel={cancelPlaces} />}\n </section>\n ) : null}\n\n {/* The middle pane: the design view, or the host's view in its place --\n no workbench pane, so no rule of the builder's dresses what the host\n drew. Keyed, so that React draws each its own element rather than\n turn one into the other, the keyboard left on a pane no longer\n focusable. */}\n {state.view === 'host' ? (\n <section\n key=\"view\"\n ref={view}\n aria-label={state.hostView?.name}\n data-pane=\"canvas\"\n data-report-part=\"view\"\n tabIndex={-1}\n onKeyDown={(event) => {\n hostKey.current = event.nativeEvent\n }}\n >\n {hostView}\n </section>\n ) : (\n <section key=\"design\" className=\"wb-pane wb-canvas\" data-pane=\"canvas\">\n <header>{t('pane.canvas')}</header>\n <div className=\"wb-body\">\n <Canvas state={state} t={t} canvas={canvas} sheet={sheet} drag={drag} select={(action) => act(action, 'selection')} />\n </div>\n </section>\n )}\n\n {/* The properties and the problems share the third column. On a narrow\n screen report-builder.css shows the one pane `data-panel` names, so\n this column says it is whichever of its two is asked for, and each\n half carries its own name for the other to be hidden by. Each half\n hides alone; the column goes with the second. */}\n {shows('properties') || shows('diagnostics') ? (\n <section className=\"wb-pane\" data-pane={state.panel === 'diagnostics' || !shows('properties') ? 'diagnostics' : 'properties'}>\n {shows('properties') ? (\n <>\n <header data-pane=\"properties\">\n <span>{state.properties.heading}</span>\n {state.selection === null ? null : (\n <button type=\"button\" onClick={() => act({ type: 'select', id: null }, 'properties')}>\n {t('properties.report')}\n </button>\n )}\n {hide('properties', t('pane.properties'))}\n </header>\n <div ref={fields} className=\"wb-body\" data-pane=\"properties\">\n <Properties\n state={state}\n ids={ids}\n act={act}\n press={(action) => act(action.action, action.then)}\n library={\n state.selection === null ? (\n <ImageLibrary state={state} t={t} ids={ids} remove={(asset) => act({ type: 'removeImage', asset }, 'properties')} />\n ) : null\n }\n />\n </div>\n </>\n ) : null}\n {shows('diagnostics') ? (\n <>\n <header data-pane=\"diagnostics\">\n {/* A status, so a change in how many problems there are is said\n without taking the person's place: \"Problems 2\". Named in\n words, never after its own heading, which the Studio sets in\n capitals that Chromium would put in the name. */}\n <div role=\"status\" aria-label={t('pane.problems')}>\n <span>{t('pane.problems')}</span>\n {count === 0 ? null : (\n <>\n {' '}\n <span data-report-part=\"badge\" data-severity={state.diagnostics.some((entry) => entry.severity === 'error') ? 'error' : 'warning'}>\n {count}\n </span>\n </>\n )}\n </div>\n {hide('diagnostics', t('pane.problems'))}\n </header>\n <div className=\"wb-body\" data-pane=\"diagnostics\">\n <Diagnostics state={state} t={t} ids={ids} list={problemList} follow={follow} />\n </div>\n </>\n ) : null}\n </section>\n ) : null}\n\n <div className=\"wb-pane\">\n {/* The editor's announcements. Each is a new child, so the same words\n said twice -- \"Nothing to undo.\" -- are two announcements, as the\n state's sequence number means them to be. */}\n <p role=\"status\" data-report-part=\"status\">\n {state.status.text === '' ? null : <span key={state.status.sequence}>{state.status.text}</span>}\n </p>\n </div>\n </section>\n )\n}\n"],"mappings":";;;;;AAmCA,SAAS,OAAO,KAAyB;CACvC,OAAO;EAAE,MAAM,IAAI;EAAG,KAAK,IAAI;EAAG,OAAO,IAAI;EAAO,QAAQ,IAAI;CAAO;AACzE;AAEA,SAAS,MAAM,EACb,aACA,OACA,QACA,SAMe;CACf,MAAM,SAAS,gBAAgB;CAC/B,OACE,oBAAC,OAAD;EAAK,MAAK;EAAM,cAAY;EAAO,oBAAiB;EAAQ,oBAAkB;EAAa,OAAO,SAAS,EAAE,OAAO,OAAO,IAAI,EAAE,QAAQ,OAAO;EAC7I,UAAA,MAAM,KAAK,SACV,oBAAC,QAAD;GAAoB,oBAAiB;GAAa,cAAY,KAAK,QAAQ,SAAS,KAAA;GAAW,OAAO,SAAS,EAAE,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,KAAK,GAAG;GAC/I,UAAA,KAAK,UAAU,KAAA,IAAY,OAAO,oBAAC,QAAD,EAAA,UAAO,KAAK,MAAY,CAAA;EACvD,GAFK,KAAK,EAEV,CACP;CACE,CAAA;AAET;;AAGA,SAASA,YAAU,KAAgB,GAAmC;CACpE,MAAM,OAAO,CAAC,IAAI,YAAY,EAAE,iBAAiB,IAAI,KAAA,GAAW,IAAI,OAAO,CAAC,CAAC,QAAQ,aAAa,aAAa,KAAA,CAAS;CACxH,OAAO,KAAK,WAAW,IAAI,KAAA,IAAY,KAAK,KAAK,IAAI;AACvD;AAEA,SAASC,YAAU,KAA8B;CAC/C,OAAO,IAAI,WAAW,KAAA,IAAY;EAAE,MAAM;EAAU,IAAI,IAAI;CAAG,IAAI;EAAE,MAAM;EAAU,IAAI,IAAI;EAAI,QAAQ,IAAI;CAAO;AACtH;AAE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AE,eAAe;MAAhD,UAAA,CACE,oBAAC,QAAD,EAAA,UAAO,EAAE,eAAe,EAAQ,CAAA,GAC/B,UAAU,IAAI,OACb,qBAAA,UAAA,EAAA,UAAA,CACG,KACD,oBAAC,QAAD;OAAM,oBAAiB;OAAQ,iBAAe,MAAM,YAAY,MAAM,UAAU,MAAM,aAAa,OAAO,IAAI,UAAU;OACrH,UAAA;MACG,CAAA,CACN,EAAA,CAAA,CAED;KACJ,CAAA,GAAA,KAAK,eAAe,EAAE,eAAe,CAAC,CACjC;IACR,CAAA,GAAA,oBAAC,OAAD;KAAK,WAAU;KAAU,aAAU;KACjC,UAAA,oBAAC,aAAD;MAAoB;MAAU;MAAQ;MAAK,MAAM;MAAqB;KAAS,CAAA;IAC5E,CAAA,CACL,EAAA,CAAA,IACA,IACG;GACP,CAAA,IAAA;GAEJ,oBAAC,OAAD;IAAK,WAAU;IAIb,UAAA,oBAAC,KAAD;KAAG,MAAK;KAAS,oBAAiB;KAC/B,UAAA,MAAM,OAAO,SAAS,KAAK,OAAO,oBAAC,QAAD,EAAA,UAAmC,MAAM,OAAO,KAAW,GAAhD,MAAM,OAAO,QAAmC;IAC7F,CAAA;GACA,CAAA;EACE;;AAEb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formancy/report-builder-react",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Formancy Report Studio for React: the native report editor over report-builder-core and one report-core session.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
@@ -22,9 +22,9 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@formancy/report-builder-core": "0.2.0",
26
- "@formancy/report-core": "0.2.0",
27
- "@formancy/report-spec": "0.2.0"
25
+ "@formancy/report-builder-core": "0.3.0",
26
+ "@formancy/report-core": "0.3.0",
27
+ "@formancy/report-spec": "0.3.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "react": "^19.0.0",