@formancy/report-builder-angular 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from "@angular/core";
2
- import { ChangeDetectionStrategy, Component, Directive, ElementRef, afterEveryRender, computed, effect, inject, input, linkedSignal, signal } from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, Directive, ElementRef, TemplateRef, ViewContainerRef, afterEveryRender, computed, contentChild, effect, inject, input, linkedSignal, signal } from "@angular/core";
3
3
  import { PROPERTY_ROLES, actionForKey, editorText, targetBeside, targetNear } from "@formancy/report-builder-core";
4
4
  function injectEditorState(editor) {
5
5
  const state = linkedSignal(() => editor().state(), ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
@@ -28,7 +28,7 @@ const PANE_FOCUS = {
28
28
  "[role=\"treeitem\"][tabindex=\"0\"]",
29
29
  "[role=\"tree\"]"
30
30
  ],
31
- canvas: ["[data-report-part=\"canvas\"]"],
31
+ canvas: ["[data-report-part=\"canvas\"]", "[data-report-part=\"view\"]"],
32
32
  properties: ["[data-report-part=\"properties\"] :is(input, select, textarea)"],
33
33
  diagnostics: ["[data-report-part=\"diagnostics\"]"]
34
34
  };
@@ -42,9 +42,13 @@ var ReportEditorRoot = class ReportEditorRoot {
42
42
  t = computed(() => editorText(this.state().locale), ...ngDevMode ? [{ debugName: "t" }] : /* istanbul ignore next */ []);
43
43
  id = `report-editor-${String(roots += 1)}`;
44
44
  outlineEmpty = `${this.id}-outline-empty`;
45
+ hidden = computed(() => this.state().hidden.length === 0 ? null : this.state().hidden.join(" "), ...ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []);
45
46
  host = inject(ElementRef);
46
47
  focusAfter = null;
47
48
  opener = null;
49
+ lastFocused = null;
50
+ lastInProperties = false;
51
+ view = null;
48
52
  constructor() {
49
53
  afterEveryRender(() => this.moveFocus());
50
54
  }
@@ -52,6 +56,16 @@ var ReportEditorRoot = class ReportEditorRoot {
52
56
  if (focus !== void 0) this.focusAfter = focus;
53
57
  return this.editor().dispatch(action);
54
58
  }
59
+ attempt(action, focus) {
60
+ const outcome = this.editor().dispatch(action);
61
+ if (!outcome.ok) return outcome;
62
+ const then = outcome.then === void 0 ? focus : {
63
+ to: "group",
64
+ ...outcome.then
65
+ };
66
+ if (then !== void 0) this.focusAfter = then;
67
+ return outcome;
68
+ }
55
69
  choosePlace(subject, opener) {
56
70
  this.opener = opener;
57
71
  if (this.dispatch({
@@ -115,9 +129,24 @@ var ReportEditorRoot = class ReportEditorRoot {
115
129
  panel
116
130
  });
117
131
  }
132
+ hidePane(panel) {
133
+ this.dispatch({
134
+ type: "hidePanel",
135
+ panel
136
+ }, {
137
+ to: "pane",
138
+ panel: "canvas"
139
+ });
140
+ }
141
+ focused(event) {
142
+ this.lastFocused = event.target;
143
+ this.lastInProperties = event.target instanceof Element && event.target.closest("[data-report-part=\"properties\"]") !== null;
144
+ }
118
145
  keydown(event) {
119
146
  const target = event.target;
120
147
  if (keepsItsKeys(target)) return;
148
+ const view = target.closest("[data-report-part=\"view\"]");
149
+ if (view !== null && this.host.nativeElement.contains(view)) return;
121
150
  const scope = target.closest("[role=\"tree\"]") === null ? "editor" : "outline";
122
151
  const action = actionForKey(event, scope, this.state().drag !== null);
123
152
  if (action === void 0) return;
@@ -125,13 +154,37 @@ var ReportEditorRoot = class ReportEditorRoot {
125
154
  if (action.type === "cancelDrag") return this.cancelPlacing();
126
155
  this.dispatch(action, scope === "outline" ? { to: "selection" } : void 0);
127
156
  }
157
+ dropped() {
158
+ const view = this.state().view;
159
+ const swapped = this.view !== null && this.view !== view;
160
+ this.view = view;
161
+ const last = this.lastFocused;
162
+ const nowhere = document.activeElement === null || document.activeElement === document.body;
163
+ if (!(last instanceof Node) || last.isConnected || !nowhere) return null;
164
+ if (swapped) return {
165
+ to: "pane",
166
+ panel: "canvas"
167
+ };
168
+ return this.lastInProperties ? {
169
+ to: "pane",
170
+ panel: "properties"
171
+ } : null;
172
+ }
128
173
  moveFocus() {
129
- const focus = this.focusAfter;
174
+ const dropped = this.dropped();
175
+ const focus = this.focusAfter ?? dropped;
130
176
  if (focus === null) return;
131
177
  this.focusAfter = null;
132
178
  const root = this.host.nativeElement;
133
179
  const first = (selectors) => selectors.reduce((found, selector) => found ?? root.querySelector(selector), null);
134
- (focus.to === "element" ? focus.element : focus.to === "places" ? root.querySelector("[data-report-part=\"places\"] button") : first(focus.to === "pane" ? PANE_FOCUS[focus.panel] : SELECTION_FOCUS))?.focus();
180
+ (focus.to === "element" ? focus.element : focus.to === "places" ? root.querySelector("[data-report-part=\"places\"] button") : focus.to === "group" ? this.inGroup(focus.group, focus.button) : first(focus.to === "pane" ? PANE_FOCUS[focus.panel] : SELECTION_FOCUS))?.focus();
181
+ }
182
+ inGroup(key, button) {
183
+ const groups = [];
184
+ for (const row of this.state().properties.rows) if ("group" in row) groups.push(row.group.key);
185
+ const element = this.host.nativeElement.querySelectorAll("[data-report-part=\"property-group\"]")[groups.indexOf(key)];
186
+ if (element === void 0) return null;
187
+ return button === void 0 ? element.querySelector("input, select, textarea") : element.querySelectorAll(":scope > button")[button] ?? null;
135
188
  }
136
189
  static ɵfac = i0.ɵɵngDeclareFactory({
137
190
  minVersion: "12.0.0",
@@ -159,10 +212,14 @@ var ReportEditorRoot = class ReportEditorRoot {
159
212
  "role": "region",
160
213
  "data-report-part": "editor"
161
214
  },
162
- listeners: { "keydown": "keydown($event)" },
215
+ listeners: {
216
+ "keydown": "keydown($event)",
217
+ "focusin": "focused($event)"
218
+ },
163
219
  properties: {
164
220
  "attr.aria-label": "t()(\"editor.label\")",
165
- "attr.data-panel": "state().panel"
221
+ "attr.data-panel": "state().panel",
222
+ "attr.data-hidden": "hidden()"
166
223
  },
167
224
  classAttribute: "wb"
168
225
  },
@@ -184,7 +241,9 @@ i0.ɵɵngDeclareClassMetadata({
184
241
  class: "wb",
185
242
  "[attr.aria-label]": "t()(\"editor.label\")",
186
243
  "[attr.data-panel]": "state().panel",
187
- "(keydown)": "keydown($event)"
244
+ "[attr.data-hidden]": "hidden()",
245
+ "(keydown)": "keydown($event)",
246
+ "(focusin)": "focused($event)"
188
247
  }
189
248
  }]
190
249
  }],
@@ -207,6 +266,10 @@ var ReportCanvas = class ReportCanvas {
207
266
  const subject = this.state().drag?.subject;
208
267
  return subject !== void 0 && "id" in subject ? subject.id : null;
209
268
  }, ...ngDevMode ? [{ debugName: "dragged" }] : /* istanbul ignore next */ []);
269
+ described(box) {
270
+ const said = [box.overflows ? this.t()("canvas.overflow") : void 0, box.missing].filter((sentence) => sentence !== void 0);
271
+ return said.length === 0 ? null : said.join(". ");
272
+ }
210
273
  select(box) {
211
274
  this.root.dispatch({
212
275
  type: "select",
@@ -214,6 +277,12 @@ var ReportCanvas = class ReportCanvas {
214
277
  ...box.column === void 0 ? {} : { column: box.column }
215
278
  }, { to: "selection" });
216
279
  }
280
+ selectBill() {
281
+ this.root.dispatch({
282
+ type: "select",
283
+ part: "paymentPart"
284
+ }, { to: "selection" });
285
+ }
217
286
  drag(box, event) {
218
287
  event.stopPropagation();
219
288
  this.root.pickUp(event, { id: box.id }, box.label);
@@ -286,8 +355,9 @@ var ReportCanvas = class ReportCanvas {
286
355
  [attr.data-kind]="box.kind"
287
356
  [attr.data-selected]="box.selected ? 'true' : null"
288
357
  [attr.data-overflows]="box.overflows ? 'true' : null"
358
+ [attr.data-missing]="box.missing === undefined ? null : 'true'"
289
359
  [attr.data-dragging]="box.id === dragged() && box.column === undefined ? 'true' : null"
290
- [attr.title]="box.overflows ? t()('canvas.overflow') : null"
360
+ [attr.title]="described(box)"
291
361
  [attr.draggable]="box.column === undefined ? 'true' : null"
292
362
  [style.left.px]="box.px.x"
293
363
  [style.top.px]="box.px.y"
@@ -298,6 +368,24 @@ var ReportCanvas = class ReportCanvas {
298
368
  (dragend)="root.dragEnded()"
299
369
  ><span data-report-part="box-label">{{ box.label }}</span>@if (box.problems > 0) {<span data-report-part="badge" [attr.data-severity]="box.severity ?? null" aria-hidden="true">{{ box.problems }}</span>}</div>
300
370
  }
371
+ <!-- Where a payment part's slip prints, below every region: a picture
372
+ named as SIX names the part, as a box is named by its label, which
373
+ a click selects the bill by, as it does a box's component. -->
374
+ @if (canvas().paymentPart; as band) {
375
+ <div
376
+ role="img"
377
+ data-report-part="payment-part"
378
+ [attr.aria-label]="band.label"
379
+ [attr.data-selected]="band.selected ? 'true' : null"
380
+ [attr.data-missing]="band.missing === undefined ? null : 'true'"
381
+ [attr.title]="band.missing ?? null"
382
+ [style.left.px]="band.px.x"
383
+ [style.top.px]="band.px.y"
384
+ [style.width.px]="band.px.width"
385
+ [style.height.px]="band.px.height"
386
+ (click)="selectBill()"
387
+ ><span data-report-part="region-label">{{ band.label }}</span>@if (band.problems > 0) {<span data-report-part="badge" [attr.data-severity]="band.severity ?? null" aria-hidden="true">{{ band.problems }}</span>}</div>
388
+ }
301
389
  <!-- Drawn only for the places the session accepts, named as the place
302
390
  chooser names them; the one under the pointer, or focused in the
303
391
  chooser, is marked. -->
@@ -365,8 +453,9 @@ i0.ɵɵngDeclareClassMetadata({
365
453
  [attr.data-kind]="box.kind"
366
454
  [attr.data-selected]="box.selected ? 'true' : null"
367
455
  [attr.data-overflows]="box.overflows ? 'true' : null"
456
+ [attr.data-missing]="box.missing === undefined ? null : 'true'"
368
457
  [attr.data-dragging]="box.id === dragged() && box.column === undefined ? 'true' : null"
369
- [attr.title]="box.overflows ? t()('canvas.overflow') : null"
458
+ [attr.title]="described(box)"
370
459
  [attr.draggable]="box.column === undefined ? 'true' : null"
371
460
  [style.left.px]="box.px.x"
372
461
  [style.top.px]="box.px.y"
@@ -377,6 +466,24 @@ i0.ɵɵngDeclareClassMetadata({
377
466
  (dragend)="root.dragEnded()"
378
467
  ><span data-report-part="box-label">{{ box.label }}</span>@if (box.problems > 0) {<span data-report-part="badge" [attr.data-severity]="box.severity ?? null" aria-hidden="true">{{ box.problems }}</span>}</div>
379
468
  }
469
+ <!-- Where a payment part's slip prints, below every region: a picture
470
+ named as SIX names the part, as a box is named by its label, which
471
+ a click selects the bill by, as it does a box's component. -->
472
+ @if (canvas().paymentPart; as band) {
473
+ <div
474
+ role="img"
475
+ data-report-part="payment-part"
476
+ [attr.aria-label]="band.label"
477
+ [attr.data-selected]="band.selected ? 'true' : null"
478
+ [attr.data-missing]="band.missing === undefined ? null : 'true'"
479
+ [attr.title]="band.missing ?? null"
480
+ [style.left.px]="band.px.x"
481
+ [style.top.px]="band.px.y"
482
+ [style.width.px]="band.px.width"
483
+ [style.height.px]="band.px.height"
484
+ (click)="selectBill()"
485
+ ><span data-report-part="region-label">{{ band.label }}</span>@if (band.problems > 0) {<span data-report-part="badge" [attr.data-severity]="band.severity ?? null" aria-hidden="true">{{ band.problems }}</span>}</div>
486
+ }
380
487
  <!-- Drawn only for the places the session accepts, named as the place
381
488
  chooser names them; the one under the pointer, or focused in the
382
489
  chooser, is marked. -->
@@ -397,6 +504,91 @@ i0.ɵɵngDeclareClassMetadata({
397
504
  }]
398
505
  }]
399
506
  });
507
+ var ReportHostView = class ReportHostView {
508
+ template = inject(TemplateRef);
509
+ static ɵfac = i0.ɵɵngDeclareFactory({
510
+ minVersion: "12.0.0",
511
+ version: "22.2.2",
512
+ ngImport: i0,
513
+ type: ReportHostView,
514
+ deps: [],
515
+ target: i0.ɵɵFactoryTarget.Directive
516
+ });
517
+ static ɵdir = i0.ɵɵngDeclareDirective({
518
+ minVersion: "14.0.0",
519
+ version: "22.2.2",
520
+ type: ReportHostView,
521
+ isStandalone: true,
522
+ selector: "ng-template[reportHostView]",
523
+ ngImport: i0
524
+ });
525
+ };
526
+ i0.ɵɵngDeclareClassMetadata({
527
+ minVersion: "12.0.0",
528
+ version: "22.2.2",
529
+ ngImport: i0,
530
+ type: ReportHostView,
531
+ decorators: [{
532
+ type: Directive,
533
+ args: [{ selector: "ng-template[reportHostView]" }]
534
+ }]
535
+ });
536
+ var ReportHostOutlet = class ReportHostOutlet {
537
+ template = input.required({
538
+ ...ngDevMode ? { debugName: "template" } : /* istanbul ignore next */ {},
539
+ alias: "reportHostOutlet"
540
+ });
541
+ container = inject(ViewContainerRef);
542
+ constructor() {
543
+ effect(() => {
544
+ const template = this.template();
545
+ this.container.clear();
546
+ if (template !== null) this.container.createEmbeddedView(template);
547
+ });
548
+ }
549
+ static ɵfac = i0.ɵɵngDeclareFactory({
550
+ minVersion: "12.0.0",
551
+ version: "22.2.2",
552
+ ngImport: i0,
553
+ type: ReportHostOutlet,
554
+ deps: [],
555
+ target: i0.ɵɵFactoryTarget.Directive
556
+ });
557
+ static ɵdir = i0.ɵɵngDeclareDirective({
558
+ minVersion: "17.1.0",
559
+ version: "22.2.2",
560
+ type: ReportHostOutlet,
561
+ isStandalone: true,
562
+ selector: "[reportHostOutlet]",
563
+ inputs: { template: {
564
+ classPropertyName: "template",
565
+ publicName: "reportHostOutlet",
566
+ isSignal: true,
567
+ isRequired: true,
568
+ transformFunction: null
569
+ } },
570
+ ngImport: i0
571
+ });
572
+ };
573
+ i0.ɵɵngDeclareClassMetadata({
574
+ minVersion: "12.0.0",
575
+ version: "22.2.2",
576
+ ngImport: i0,
577
+ type: ReportHostOutlet,
578
+ decorators: [{
579
+ type: Directive,
580
+ args: [{ selector: "[reportHostOutlet]" }]
581
+ }],
582
+ ctorParameters: () => [],
583
+ propDecorators: { template: [{
584
+ type: i0.Input,
585
+ args: [{
586
+ isSignal: true,
587
+ alias: "reportHostOutlet",
588
+ required: true
589
+ }]
590
+ }] }
591
+ });
400
592
  function rows(nodes, into = []) {
401
593
  nodes.forEach((node, at) => {
402
594
  into.push({
@@ -418,12 +610,13 @@ var ReportOutline = class ReportOutline {
418
610
  rows: rows(region.nodes)
419
611
  })), ...ngDevMode ? [{ debugName: "regions" }] : /* istanbul ignore next */ []);
420
612
  all = computed(() => this.regions().reduce((nodes, region) => nodes.concat(region.rows.map((row) => row.node)), []), ...ngDevMode ? [{ debugName: "all" }] : /* istanbul ignore next */ []);
613
+ parts = computed(() => this.root.state().outlineParts, ...ngDevMode ? [{ debugName: "parts" }] : /* istanbul ignore next */ []);
421
614
  stop = computed(() => {
422
- const all = this.all();
423
- return (all.find((node) => node.selected) ?? all[0])?.key;
615
+ const all = [...this.all(), ...this.parts()];
616
+ return (all.find((row) => row.selected) ?? all[0])?.key;
424
617
  }, ...ngDevMode ? [{ debugName: "stop" }] : /* istanbul ignore next */ []);
425
- problems(node) {
426
- return `${this.root.id}-problems-${node.key}`;
618
+ problems(row) {
619
+ return `${this.root.id}-problems-${row.key}`;
427
620
  }
428
621
  overflow(node) {
429
622
  return `${this.root.id}-overflow-${node.key}`;
@@ -446,6 +639,18 @@ var ReportOutline = class ReportOutline {
446
639
  ...node.column === void 0 ? {} : { column: node.column }
447
640
  });
448
641
  }
642
+ selectPart(part) {
643
+ this.root.dispatch({
644
+ type: "select",
645
+ part: part.part
646
+ }, { to: "selection" });
647
+ }
648
+ focusedPart(part) {
649
+ if (!part.selected) this.root.dispatch({
650
+ type: "select",
651
+ part: part.part
652
+ });
653
+ }
449
654
  drag(node, event) {
450
655
  this.root.pickUp(event, { id: node.id }, node.label);
451
656
  }
@@ -531,6 +736,23 @@ var ReportOutline = class ReportOutline {
531
736
  }
532
737
  </div>
533
738
  }
739
+ @for (part of parts(); track part.key; let at = $index) {
740
+ <div
741
+ role="treeitem"
742
+ data-report-part="outline-item"
743
+ aria-level="1"
744
+ [attr.aria-posinset]="at + 1"
745
+ [attr.aria-setsize]="parts().length"
746
+ [attr.aria-selected]="part.selected"
747
+ [attr.aria-describedby]="part.problems > 0 ? problems(part) : null"
748
+ [tabIndex]="part.key === stop() ? 0 : -1"
749
+ (focus)="focusedPart(part)"
750
+ (click)="selectPart(part)"
751
+ >{{ part.label }}@if (part.problems > 0) {
752
+ <span data-report-part="badge" [attr.data-severity]="part.severity ?? null" aria-hidden="true">{{ part.problems }}</span>
753
+ <span [id]="problems(part)" hidden>{{ t()('outline.problems', { count: part.problems }) }}</span>
754
+ }</div>
755
+ }
534
756
  }
535
757
  `,
536
758
  isInline: true,
@@ -592,15 +814,90 @@ i0.ɵɵngDeclareClassMetadata({
592
814
  }
593
815
  </div>
594
816
  }
817
+ @for (part of parts(); track part.key; let at = $index) {
818
+ <div
819
+ role="treeitem"
820
+ data-report-part="outline-item"
821
+ aria-level="1"
822
+ [attr.aria-posinset]="at + 1"
823
+ [attr.aria-setsize]="parts().length"
824
+ [attr.aria-selected]="part.selected"
825
+ [attr.aria-describedby]="part.problems > 0 ? problems(part) : null"
826
+ [tabIndex]="part.key === stop() ? 0 : -1"
827
+ (focus)="focusedPart(part)"
828
+ (click)="selectPart(part)"
829
+ >{{ part.label }}@if (part.problems > 0) {
830
+ <span data-report-part="badge" [attr.data-severity]="part.severity ?? null" aria-hidden="true">{{ part.problems }}</span>
831
+ <span [id]="problems(part)" hidden>{{ t()('outline.problems', { count: part.problems }) }}</span>
832
+ }</div>
833
+ }
595
834
  }
596
835
  `
597
836
  }]
598
837
  }]
599
838
  });
839
+ var ReportImageChooser = class ReportImageChooser {
840
+ root = inject(ReportEditorRoot);
841
+ input = inject(ElementRef);
842
+ open() {
843
+ if (this.root.dispatch({ type: "chooseImage" }).ok) this.input.nativeElement.click();
844
+ }
845
+ take() {
846
+ const input = this.input.nativeElement;
847
+ const file = input.files?.[0];
848
+ input.value = "";
849
+ if (file !== void 0) this.root.editor().addImage(file);
850
+ }
851
+ static ɵfac = i0.ɵɵngDeclareFactory({
852
+ minVersion: "12.0.0",
853
+ version: "22.2.2",
854
+ ngImport: i0,
855
+ type: ReportImageChooser,
856
+ deps: [],
857
+ target: i0.ɵɵFactoryTarget.Directive
858
+ });
859
+ static ɵdir = i0.ɵɵngDeclareDirective({
860
+ minVersion: "14.0.0",
861
+ version: "22.2.2",
862
+ type: ReportImageChooser,
863
+ isStandalone: true,
864
+ selector: "input[reportImageChooser]",
865
+ host: {
866
+ attributes: {
867
+ "type": "file",
868
+ "hidden": ""
869
+ },
870
+ listeners: { "change": "take()" },
871
+ properties: { "accept": "root.state().images.accept" }
872
+ },
873
+ exportAs: ["reportImageChooser"],
874
+ ngImport: i0
875
+ });
876
+ };
877
+ i0.ɵɵngDeclareClassMetadata({
878
+ minVersion: "12.0.0",
879
+ version: "22.2.2",
880
+ ngImport: i0,
881
+ type: ReportImageChooser,
882
+ decorators: [{
883
+ type: Directive,
884
+ args: [{
885
+ selector: "input[reportImageChooser]",
886
+ exportAs: "reportImageChooser",
887
+ host: {
888
+ type: "file",
889
+ hidden: "",
890
+ "[accept]": "root.state().images.accept",
891
+ "(change)": "take()"
892
+ }
893
+ }]
894
+ }]
895
+ });
600
896
  var ReportPalette = class ReportPalette {
601
897
  root = inject(ReportEditorRoot);
602
898
  state = this.root.state;
603
899
  t = this.root.t;
900
+ addWhy = `${this.root.id}-unavailable-add-image`;
604
901
  why(entry) {
605
902
  return `${this.root.id}-unavailable-${entry.kind}`;
606
903
  }
@@ -646,8 +943,25 @@ var ReportPalette = class ReportPalette {
646
943
  (dragend)="root.dragEnded()"
647
944
  >{{ entry.label }}@if (entry.unavailable !== undefined) {<span [id]="why(entry)" hidden>{{ entry.unavailable }}</span>}</button>
648
945
  }
946
+ @if (state().images.store) {
947
+ <button
948
+ type="button"
949
+ data-report-part="palette-item"
950
+ [attr.aria-disabled]="state().can.addImage ? null : 'true'"
951
+ [attr.aria-describedby]="state().images.unavailable === undefined ? null : addWhy"
952
+ [attr.aria-busy]="state().images.adding === null ? null : 'true'"
953
+ (click)="file.open()"
954
+ >{{ t()('images.add') }}@if (state().images.unavailable !== undefined) {<span [id]="addWhy" hidden>{{ state().images.unavailable }}</span>}</button>
955
+ <input reportImageChooser #file="reportImageChooser" />
956
+ }
649
957
  `,
650
958
  isInline: true,
959
+ dependencies: [{
960
+ kind: "directive",
961
+ type: ReportImageChooser,
962
+ selector: "input[reportImageChooser]",
963
+ exportAs: ["reportImageChooser"]
964
+ }],
651
965
  changeDetection: i0.ChangeDetectionStrategy.OnPush
652
966
  });
653
967
  };
@@ -661,6 +975,7 @@ i0.ɵɵngDeclareClassMetadata({
661
975
  args: [{
662
976
  selector: "div[reportPalette]",
663
977
  changeDetection: ChangeDetectionStrategy.OnPush,
978
+ imports: [ReportImageChooser],
664
979
  host: {
665
980
  role: "group",
666
981
  "data-report-part": "palette",
@@ -680,6 +995,17 @@ i0.ɵɵngDeclareClassMetadata({
680
995
  (dragend)="root.dragEnded()"
681
996
  >{{ entry.label }}@if (entry.unavailable !== undefined) {<span [id]="why(entry)" hidden>{{ entry.unavailable }}</span>}</button>
682
997
  }
998
+ @if (state().images.store) {
999
+ <button
1000
+ type="button"
1001
+ data-report-part="palette-item"
1002
+ [attr.aria-disabled]="state().can.addImage ? null : 'true'"
1003
+ [attr.aria-describedby]="state().images.unavailable === undefined ? null : addWhy"
1004
+ [attr.aria-busy]="state().images.adding === null ? null : 'true'"
1005
+ (click)="file.open()"
1006
+ >{{ t()('images.add') }}@if (state().images.unavailable !== undefined) {<span [id]="addWhy" hidden>{{ state().images.unavailable }}</span>}</button>
1007
+ <input reportImageChooser #file="reportImageChooser" />
1008
+ }
683
1009
  `
684
1010
  }]
685
1011
  }]
@@ -849,44 +1175,366 @@ i0.ɵɵngDeclareClassMetadata({
849
1175
  }]
850
1176
  }]
851
1177
  });
1178
+ var ReportImageLibrary = class ReportImageLibrary {
1179
+ root = inject(ReportEditorRoot);
1180
+ why(at) {
1181
+ return `${this.root.id}-image-${String(at)}-in-use`;
1182
+ }
1183
+ remove(asset) {
1184
+ this.root.attempt({
1185
+ type: "removeImage",
1186
+ asset
1187
+ }, {
1188
+ to: "pane",
1189
+ panel: "properties"
1190
+ });
1191
+ }
1192
+ static ɵfac = i0.ɵɵngDeclareFactory({
1193
+ minVersion: "12.0.0",
1194
+ version: "22.2.2",
1195
+ ngImport: i0,
1196
+ type: ReportImageLibrary,
1197
+ deps: [],
1198
+ target: i0.ɵɵFactoryTarget.Component
1199
+ });
1200
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1201
+ minVersion: "17.0.0",
1202
+ version: "22.2.2",
1203
+ type: ReportImageLibrary,
1204
+ isStandalone: true,
1205
+ selector: "div[reportImageLibrary]",
1206
+ host: {
1207
+ attributes: { "role": "group" },
1208
+ properties: { "attr.aria-label": "root.t()(\"images.heading\")" }
1209
+ },
1210
+ ngImport: i0,
1211
+ template: `
1212
+ @for (image of root.state().images.assets; track image.id; let at = $index) {
1213
+ <div data-report-part="property">
1214
+ <span>{{ image.label }}</span>
1215
+ <button
1216
+ type="button"
1217
+ [attr.aria-label]="image.removeLabel"
1218
+ [attr.aria-disabled]="image.inUse === undefined ? null : 'true'"
1219
+ [attr.aria-describedby]="image.inUse === undefined ? null : why(at)"
1220
+ (click)="remove(image.id)"
1221
+ >{{ root.t()('images.remove') }}@if (image.inUse !== undefined) {<span [id]="why(at)" hidden>{{ image.inUse }}</span>}</button>
1222
+ </div>
1223
+ }
1224
+ `,
1225
+ isInline: true,
1226
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1227
+ });
1228
+ };
1229
+ i0.ɵɵngDeclareClassMetadata({
1230
+ minVersion: "12.0.0",
1231
+ version: "22.2.2",
1232
+ ngImport: i0,
1233
+ type: ReportImageLibrary,
1234
+ decorators: [{
1235
+ type: Component,
1236
+ args: [{
1237
+ selector: "div[reportImageLibrary]",
1238
+ changeDetection: ChangeDetectionStrategy.OnPush,
1239
+ host: {
1240
+ role: "group",
1241
+ "[attr.aria-label]": "root.t()(\"images.heading\")"
1242
+ },
1243
+ template: `
1244
+ @for (image of root.state().images.assets; track image.id; let at = $index) {
1245
+ <div data-report-part="property">
1246
+ <span>{{ image.label }}</span>
1247
+ <button
1248
+ type="button"
1249
+ [attr.aria-label]="image.removeLabel"
1250
+ [attr.aria-disabled]="image.inUse === undefined ? null : 'true'"
1251
+ [attr.aria-describedby]="image.inUse === undefined ? null : why(at)"
1252
+ (click)="remove(image.id)"
1253
+ >{{ root.t()('images.remove') }}@if (image.inUse !== undefined) {<span [id]="why(at)" hidden>{{ image.inUse }}</span>}</button>
1254
+ </div>
1255
+ }
1256
+ `
1257
+ }]
1258
+ }]
1259
+ });
852
1260
  const CONTROLS = {
853
1261
  textbox: "text",
854
1262
  spinbutton: "number",
855
1263
  combobox: "select",
856
1264
  checkbox: "checkbox"
857
1265
  };
858
- var ReportProperties = class ReportProperties {
1266
+ var ReportPropertyRow = class ReportPropertyRow {
859
1267
  root = inject(ReportEditorRoot);
860
- shown = computed(() => {
861
- const { selection, properties } = this.root.state();
862
- const owner = selection === null ? "report" : `${selection.id}${selection.column === void 0 ? "" : `-${selection.column}`}`;
863
- return properties.fields.map((field, index) => {
864
- const id = `${this.root.id}-${owner}-${String(index)}`;
865
- return {
866
- field,
867
- control: field.kind === "multiline" ? "textarea" : CONTROLS[PROPERTY_ROLES[field.kind]],
868
- id,
869
- errorId: field.error === void 0 ? null : `${id}-error`
870
- };
871
- });
872
- }, ...ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []);
873
- commit(field, value) {
874
- const now = this.root.state().properties.fields.find((candidate) => candidate.key === field.key);
1268
+ shown = input.required(...ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []);
1269
+ now(field) {
1270
+ return this.root.state().properties.fields.find((candidate) => candidate.key === field.key);
1271
+ }
1272
+ commit(field, value, control) {
1273
+ const now = this.now(field);
875
1274
  if (now !== void 0 && now.value === value) return;
876
1275
  this.root.dispatch({
877
1276
  type: "setProperty",
878
1277
  key: field.key,
879
1278
  value
880
1279
  });
1280
+ const reads = this.now(field)?.value;
1281
+ if (control !== void 0 && reads !== void 0 && control.value !== String(reads)) control.value = String(reads);
881
1282
  }
882
1283
  enter(field, event) {
883
1284
  event.preventDefault();
884
- this.commit(field, event.target.value);
1285
+ const control = event.target;
1286
+ this.commit(field, control.value, control);
885
1287
  }
886
1288
  giveBack(field, event) {
887
- const now = this.root.state().properties.fields.find((candidate) => candidate.key === field.key) ?? field;
1289
+ const now = this.now(field) ?? field;
888
1290
  event.target.value = String(now.value);
889
1291
  }
1292
+ static ɵfac = i0.ɵɵngDeclareFactory({
1293
+ minVersion: "12.0.0",
1294
+ version: "22.2.2",
1295
+ ngImport: i0,
1296
+ type: ReportPropertyRow,
1297
+ deps: [],
1298
+ target: i0.ɵɵFactoryTarget.Component
1299
+ });
1300
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1301
+ minVersion: "17.0.0",
1302
+ version: "22.2.2",
1303
+ type: ReportPropertyRow,
1304
+ isStandalone: true,
1305
+ selector: "div[reportPropertyRow]",
1306
+ inputs: { shown: {
1307
+ classPropertyName: "shown",
1308
+ publicName: "shown",
1309
+ isSignal: true,
1310
+ isRequired: true,
1311
+ transformFunction: null
1312
+ } },
1313
+ host: {
1314
+ attributes: { "data-report-part": "property" },
1315
+ properties: {
1316
+ "attr.data-kind": "shown().field.kind",
1317
+ "attr.data-missing": "shown().field.missing === true ? 'true' : null"
1318
+ }
1319
+ },
1320
+ ngImport: i0,
1321
+ template: `
1322
+ <label [attr.for]="shown().id">{{ shown().field.label }}</label>
1323
+ @switch (shown().control) {
1324
+ @case ('textarea') {
1325
+ <textarea
1326
+ [id]="shown().id"
1327
+ [value]="shown().field.value"
1328
+ [required]="shown().field.required"
1329
+ [attr.placeholder]="shown().field.placeholder ?? null"
1330
+ [attr.aria-invalid]="shown().errorId === null ? null : 'true'"
1331
+ [attr.aria-describedby]="shown().describedBy"
1332
+ (change)="commit(shown().field, $any($event.target).value, $any($event.target))"
1333
+ (keydown.escape)="giveBack(shown().field, $event)"
1334
+ ></textarea>
1335
+ }
1336
+ @case ('checkbox') {
1337
+ <input
1338
+ type="checkbox"
1339
+ [id]="shown().id"
1340
+ [checked]="shown().field.value === true"
1341
+ [attr.aria-invalid]="shown().errorId === null ? null : 'true'"
1342
+ [attr.aria-describedby]="shown().describedBy"
1343
+ (change)="commit(shown().field, $any($event.target).checked)"
1344
+ />
1345
+ }
1346
+ @case ('select') {
1347
+ <select
1348
+ [id]="shown().id"
1349
+ [required]="shown().field.required"
1350
+ [attr.aria-invalid]="shown().errorId === null ? null : 'true'"
1351
+ [attr.aria-describedby]="shown().describedBy"
1352
+ (change)="commit(shown().field, $any($event.target).value)"
1353
+ >
1354
+ @for (option of shown().field.options ?? []; track option.value) {
1355
+ <option [value]="option.value" [selected]="option.value === shown().field.value">{{ option.label }}</option>
1356
+ }
1357
+ </select>
1358
+ }
1359
+ @default {
1360
+ <input
1361
+ [type]="shown().control"
1362
+ [attr.step]="shown().control === 'number' ? 'any' : null"
1363
+ [id]="shown().id"
1364
+ [value]="shown().field.value"
1365
+ [required]="shown().field.required"
1366
+ [attr.placeholder]="shown().field.placeholder ?? null"
1367
+ [attr.aria-invalid]="shown().errorId === null ? null : 'true'"
1368
+ [attr.aria-describedby]="shown().describedBy"
1369
+ (change)="commit(shown().field, $any($event.target).value, $any($event.target))"
1370
+ (keydown.enter)="enter(shown().field, $event)"
1371
+ (keydown.escape)="giveBack(shown().field, $event)"
1372
+ />
1373
+ }
1374
+ }
1375
+ @if (shown().errorId !== null) {
1376
+ <p data-report-part="property-error" class="wb-problem" [id]="shown().errorId">{{ shown().field.error }}</p>
1377
+ }
1378
+ @if (shown().noteId !== null) {
1379
+ <p data-report-part="property-note" [id]="shown().noteId">{{ shown().field.note }}</p>
1380
+ }
1381
+ `,
1382
+ isInline: true,
1383
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1384
+ });
1385
+ };
1386
+ i0.ɵɵngDeclareClassMetadata({
1387
+ minVersion: "12.0.0",
1388
+ version: "22.2.2",
1389
+ ngImport: i0,
1390
+ type: ReportPropertyRow,
1391
+ decorators: [{
1392
+ type: Component,
1393
+ args: [{
1394
+ selector: "div[reportPropertyRow]",
1395
+ changeDetection: ChangeDetectionStrategy.OnPush,
1396
+ host: {
1397
+ "data-report-part": "property",
1398
+ "[attr.data-kind]": "shown().field.kind",
1399
+ "[attr.data-missing]": "shown().field.missing === true ? 'true' : null"
1400
+ },
1401
+ template: `
1402
+ <label [attr.for]="shown().id">{{ shown().field.label }}</label>
1403
+ @switch (shown().control) {
1404
+ @case ('textarea') {
1405
+ <textarea
1406
+ [id]="shown().id"
1407
+ [value]="shown().field.value"
1408
+ [required]="shown().field.required"
1409
+ [attr.placeholder]="shown().field.placeholder ?? null"
1410
+ [attr.aria-invalid]="shown().errorId === null ? null : 'true'"
1411
+ [attr.aria-describedby]="shown().describedBy"
1412
+ (change)="commit(shown().field, $any($event.target).value, $any($event.target))"
1413
+ (keydown.escape)="giveBack(shown().field, $event)"
1414
+ ></textarea>
1415
+ }
1416
+ @case ('checkbox') {
1417
+ <input
1418
+ type="checkbox"
1419
+ [id]="shown().id"
1420
+ [checked]="shown().field.value === true"
1421
+ [attr.aria-invalid]="shown().errorId === null ? null : 'true'"
1422
+ [attr.aria-describedby]="shown().describedBy"
1423
+ (change)="commit(shown().field, $any($event.target).checked)"
1424
+ />
1425
+ }
1426
+ @case ('select') {
1427
+ <select
1428
+ [id]="shown().id"
1429
+ [required]="shown().field.required"
1430
+ [attr.aria-invalid]="shown().errorId === null ? null : 'true'"
1431
+ [attr.aria-describedby]="shown().describedBy"
1432
+ (change)="commit(shown().field, $any($event.target).value)"
1433
+ >
1434
+ @for (option of shown().field.options ?? []; track option.value) {
1435
+ <option [value]="option.value" [selected]="option.value === shown().field.value">{{ option.label }}</option>
1436
+ }
1437
+ </select>
1438
+ }
1439
+ @default {
1440
+ <input
1441
+ [type]="shown().control"
1442
+ [attr.step]="shown().control === 'number' ? 'any' : null"
1443
+ [id]="shown().id"
1444
+ [value]="shown().field.value"
1445
+ [required]="shown().field.required"
1446
+ [attr.placeholder]="shown().field.placeholder ?? null"
1447
+ [attr.aria-invalid]="shown().errorId === null ? null : 'true'"
1448
+ [attr.aria-describedby]="shown().describedBy"
1449
+ (change)="commit(shown().field, $any($event.target).value, $any($event.target))"
1450
+ (keydown.enter)="enter(shown().field, $event)"
1451
+ (keydown.escape)="giveBack(shown().field, $event)"
1452
+ />
1453
+ }
1454
+ }
1455
+ @if (shown().errorId !== null) {
1456
+ <p data-report-part="property-error" class="wb-problem" [id]="shown().errorId">{{ shown().field.error }}</p>
1457
+ }
1458
+ @if (shown().noteId !== null) {
1459
+ <p data-report-part="property-note" [id]="shown().noteId">{{ shown().field.note }}</p>
1460
+ }
1461
+ `
1462
+ }]
1463
+ }],
1464
+ propDecorators: { shown: [{
1465
+ type: i0.Input,
1466
+ args: [{
1467
+ isSignal: true,
1468
+ alias: "shown",
1469
+ required: true
1470
+ }]
1471
+ }] }
1472
+ });
1473
+ function sent(action, group) {
1474
+ if (action.type !== "setBaseline") return action;
1475
+ const field = group.querySelector("input, textarea");
1476
+ if (!(field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement) || field.selectionStart === null || field.selectionEnd === null) return action;
1477
+ return {
1478
+ ...action,
1479
+ selected: {
1480
+ start: field.selectionStart,
1481
+ end: field.selectionEnd,
1482
+ text: field.value
1483
+ }
1484
+ };
1485
+ }
1486
+ var ReportProperties = class ReportProperties {
1487
+ root = inject(ReportEditorRoot);
1488
+ rows = computed(() => {
1489
+ const { selection, properties } = this.root.state();
1490
+ const owner = selection === null ? "report" : "part" in selection ? selection.part : `${selection.id}${selection.column === void 0 ? "" : `-${selection.column}`}`;
1491
+ let index = 0;
1492
+ const shown = (field) => {
1493
+ const id = `${this.root.id}-${owner}-${String(index)}`;
1494
+ index += 1;
1495
+ const control = field.kind === "multiline" ? "textarea" : CONTROLS[PROPERTY_ROLES[field.kind]];
1496
+ const errorId = field.error === void 0 ? null : `${id}-error`;
1497
+ const noteId = field.note === void 0 ? null : `${id}-note`;
1498
+ const described = [errorId, noteId].filter((part) => part !== null).join(" ");
1499
+ return {
1500
+ field,
1501
+ control,
1502
+ id,
1503
+ errorId,
1504
+ noteId,
1505
+ describedBy: described === "" ? null : described
1506
+ };
1507
+ };
1508
+ return properties.rows.map((row) => {
1509
+ if ("field" in row) {
1510
+ const field = shown(row.field);
1511
+ return {
1512
+ key: field.id,
1513
+ field,
1514
+ group: null
1515
+ };
1516
+ }
1517
+ const { group } = row;
1518
+ return {
1519
+ key: `${this.root.id}-${owner}-${group.key}`,
1520
+ field: null,
1521
+ group: {
1522
+ label: group.label,
1523
+ fields: group.fields.map(shown),
1524
+ actions: group.actions
1525
+ }
1526
+ };
1527
+ });
1528
+ }, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
1529
+ fieldOf(row) {
1530
+ return row.field;
1531
+ }
1532
+ press(action, group) {
1533
+ this.root.attempt(sent(action.action, group), action.then === void 0 ? void 0 : {
1534
+ to: "group",
1535
+ ...action.then
1536
+ });
1537
+ }
890
1538
  static ɵfac = i0.ɵɵngDeclareFactory({
891
1539
  minVersion: "12.0.0",
892
1540
  version: "22.2.2",
@@ -908,68 +1556,42 @@ var ReportProperties = class ReportProperties {
908
1556
  },
909
1557
  ngImport: i0,
910
1558
  template: `
911
- @for (shown of shown(); track shown.id) {
912
- <div data-report-part="property" [attr.data-kind]="shown.field.kind">
913
- <label [attr.for]="shown.id">{{ shown.field.label }}</label>
914
- @switch (shown.control) {
915
- @case ('textarea') {
916
- <textarea
917
- [id]="shown.id"
918
- [value]="shown.field.value"
919
- [required]="shown.field.required"
920
- [attr.placeholder]="shown.field.placeholder ?? null"
921
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
922
- [attr.aria-describedby]="shown.errorId"
923
- (change)="commit(shown.field, $any($event.target).value)"
924
- (keydown.escape)="giveBack(shown.field, $event)"
925
- ></textarea>
926
- }
927
- @case ('checkbox') {
928
- <input
929
- type="checkbox"
930
- [id]="shown.id"
931
- [checked]="shown.field.value === true"
932
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
933
- [attr.aria-describedby]="shown.errorId"
934
- (change)="commit(shown.field, $any($event.target).checked)"
935
- />
1559
+ @for (row of rows(); track row.key) {
1560
+ @if (row.group; as group) {
1561
+ <div #element role="group" data-report-part="property-group" [attr.aria-label]="group.label">
1562
+ <span aria-hidden="true">{{ group.label }}</span>
1563
+ @for (shown of group.fields; track shown.id) {
1564
+ <div reportPropertyRow [shown]="shown"></div>
936
1565
  }
937
- @case ('select') {
938
- <select
939
- [id]="shown.id"
940
- [required]="shown.field.required"
941
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
942
- [attr.aria-describedby]="shown.errorId"
943
- (change)="commit(shown.field, $any($event.target).value)"
944
- >
945
- @for (option of shown.field.options ?? []; track option.value) {
946
- <option [value]="option.value" [selected]="option.value === shown.field.value">{{ option.label }}</option>
947
- }
948
- </select>
1566
+ @for (action of group.actions; track $index) {
1567
+ <button
1568
+ type="button"
1569
+ [attr.aria-label]="action.text === undefined ? null : action.label"
1570
+ [attr.aria-pressed]="action.pressed === undefined ? null : action.pressed"
1571
+ [attr.aria-disabled]="action.available ? null : 'true'"
1572
+ (click)="press(action, element)"
1573
+ >{{ action.text ?? action.label }}</button>
949
1574
  }
950
- @default {
951
- <input
952
- [type]="shown.control"
953
- [attr.step]="shown.control === 'number' ? 'any' : null"
954
- [id]="shown.id"
955
- [value]="shown.field.value"
956
- [required]="shown.field.required"
957
- [attr.placeholder]="shown.field.placeholder ?? null"
958
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
959
- [attr.aria-describedby]="shown.errorId"
960
- (change)="commit(shown.field, $any($event.target).value)"
961
- (keydown.enter)="enter(shown.field, $event)"
962
- (keydown.escape)="giveBack(shown.field, $event)"
963
- />
964
- }
965
- }
966
- @if (shown.errorId !== null) {
967
- <p data-report-part="property-error" class="wb-problem" [id]="shown.errorId">{{ shown.field.error }}</p>
968
- }
969
- </div>
1575
+ </div>
1576
+ } @else {
1577
+ <div reportPropertyRow [shown]="fieldOf(row)"></div>
1578
+ }
1579
+ }
1580
+ @if (root.state().selection === null && root.state().images.assets.length > 0) {
1581
+ <div reportImageLibrary></div>
970
1582
  }
971
1583
  `,
972
1584
  isInline: true,
1585
+ dependencies: [{
1586
+ kind: "component",
1587
+ type: ReportImageLibrary,
1588
+ selector: "div[reportImageLibrary]"
1589
+ }, {
1590
+ kind: "component",
1591
+ type: ReportPropertyRow,
1592
+ selector: "div[reportPropertyRow]",
1593
+ inputs: ["shown"]
1594
+ }],
973
1595
  changeDetection: i0.ChangeDetectionStrategy.OnPush
974
1596
  });
975
1597
  };
@@ -983,71 +1605,36 @@ i0.ɵɵngDeclareClassMetadata({
983
1605
  args: [{
984
1606
  selector: "form[reportProperties]",
985
1607
  changeDetection: ChangeDetectionStrategy.OnPush,
1608
+ imports: [ReportImageLibrary, ReportPropertyRow],
986
1609
  host: {
987
1610
  "data-report-part": "properties",
988
1611
  "[attr.aria-label]": "root.state().properties.heading",
989
1612
  "(submit)": "$event.preventDefault()"
990
1613
  },
991
1614
  template: `
992
- @for (shown of shown(); track shown.id) {
993
- <div data-report-part="property" [attr.data-kind]="shown.field.kind">
994
- <label [attr.for]="shown.id">{{ shown.field.label }}</label>
995
- @switch (shown.control) {
996
- @case ('textarea') {
997
- <textarea
998
- [id]="shown.id"
999
- [value]="shown.field.value"
1000
- [required]="shown.field.required"
1001
- [attr.placeholder]="shown.field.placeholder ?? null"
1002
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1003
- [attr.aria-describedby]="shown.errorId"
1004
- (change)="commit(shown.field, $any($event.target).value)"
1005
- (keydown.escape)="giveBack(shown.field, $event)"
1006
- ></textarea>
1007
- }
1008
- @case ('checkbox') {
1009
- <input
1010
- type="checkbox"
1011
- [id]="shown.id"
1012
- [checked]="shown.field.value === true"
1013
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1014
- [attr.aria-describedby]="shown.errorId"
1015
- (change)="commit(shown.field, $any($event.target).checked)"
1016
- />
1615
+ @for (row of rows(); track row.key) {
1616
+ @if (row.group; as group) {
1617
+ <div #element role="group" data-report-part="property-group" [attr.aria-label]="group.label">
1618
+ <span aria-hidden="true">{{ group.label }}</span>
1619
+ @for (shown of group.fields; track shown.id) {
1620
+ <div reportPropertyRow [shown]="shown"></div>
1017
1621
  }
1018
- @case ('select') {
1019
- <select
1020
- [id]="shown.id"
1021
- [required]="shown.field.required"
1022
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1023
- [attr.aria-describedby]="shown.errorId"
1024
- (change)="commit(shown.field, $any($event.target).value)"
1025
- >
1026
- @for (option of shown.field.options ?? []; track option.value) {
1027
- <option [value]="option.value" [selected]="option.value === shown.field.value">{{ option.label }}</option>
1028
- }
1029
- </select>
1622
+ @for (action of group.actions; track $index) {
1623
+ <button
1624
+ type="button"
1625
+ [attr.aria-label]="action.text === undefined ? null : action.label"
1626
+ [attr.aria-pressed]="action.pressed === undefined ? null : action.pressed"
1627
+ [attr.aria-disabled]="action.available ? null : 'true'"
1628
+ (click)="press(action, element)"
1629
+ >{{ action.text ?? action.label }}</button>
1030
1630
  }
1031
- @default {
1032
- <input
1033
- [type]="shown.control"
1034
- [attr.step]="shown.control === 'number' ? 'any' : null"
1035
- [id]="shown.id"
1036
- [value]="shown.field.value"
1037
- [required]="shown.field.required"
1038
- [attr.placeholder]="shown.field.placeholder ?? null"
1039
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1040
- [attr.aria-describedby]="shown.errorId"
1041
- (change)="commit(shown.field, $any($event.target).value)"
1042
- (keydown.enter)="enter(shown.field, $event)"
1043
- (keydown.escape)="giveBack(shown.field, $event)"
1044
- />
1045
- }
1046
- }
1047
- @if (shown.errorId !== null) {
1048
- <p data-report-part="property-error" class="wb-problem" [id]="shown.errorId">{{ shown.field.error }}</p>
1049
- }
1050
- </div>
1631
+ </div>
1632
+ } @else {
1633
+ <div reportPropertyRow [shown]="fieldOf(row)"></div>
1634
+ }
1635
+ }
1636
+ @if (root.state().selection === null && root.state().images.assets.length > 0) {
1637
+ <div reportImageLibrary></div>
1051
1638
  }
1052
1639
  `
1053
1640
  }]
@@ -1145,7 +1732,7 @@ var ReportToolbar = class ReportToolbar {
1145
1732
  if ("pane" in use) return this.root.showPane(use.pane);
1146
1733
  if ("placeSelection" in use) {
1147
1734
  const selection = this.state().selection;
1148
- if (tool.available && selection !== null) this.root.choosePlace({ id: selection.id }, event.currentTarget);
1735
+ if (tool.available && selection !== null && "id" in selection) this.root.choosePlace({ id: selection.id }, event.currentTarget);
1149
1736
  return;
1150
1737
  }
1151
1738
  this.root.dispatch(use.action);
@@ -1251,8 +1838,12 @@ var ReportBuilder = class ReportBuilder {
1251
1838
  state = this.root.state;
1252
1839
  t = this.root.t;
1253
1840
  count = computed(() => this.state().diagnostics.length, ...ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []);
1841
+ hostView = contentChild(ReportHostView, ...ngDevMode ? [{ debugName: "hostView" }] : /* istanbul ignore next */ []);
1254
1842
  empty = computed(() => this.state().outline.every((region) => region.nodes.length === 0), ...ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []);
1255
1843
  severity = computed(() => this.state().diagnostics.some((entry) => entry.severity === "error") ? "error" : "warning", ...ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []);
1844
+ shows(panel) {
1845
+ return !this.state().hidden.includes(panel);
1846
+ }
1256
1847
  static ɵfac = i0.ɵɵngDeclareFactory({
1257
1848
  minVersion: "12.0.0",
1258
1849
  version: "22.2.2",
@@ -1267,6 +1858,13 @@ var ReportBuilder = class ReportBuilder {
1267
1858
  type: ReportBuilder,
1268
1859
  isStandalone: true,
1269
1860
  selector: "report-builder",
1861
+ queries: [{
1862
+ propertyName: "hostView",
1863
+ first: true,
1864
+ predicate: ReportHostView,
1865
+ descendants: true,
1866
+ isSignal: true
1867
+ }],
1270
1868
  hostDirectives: [{
1271
1869
  directive: ReportEditorRoot,
1272
1870
  inputs: ["reportEditor", "editor"]
@@ -1276,49 +1874,75 @@ var ReportBuilder = class ReportBuilder {
1276
1874
  <div class="wb-pane">
1277
1875
  <header>
1278
1876
  <span data-report-part="title">{{ state().document.title }}</span>
1877
+ @if (state().languages.declared.length > 1) {
1878
+ <select data-report-part="language" [attr.aria-label]="t()('language.label')" (change)="root.dispatch({ type: 'setLanguage', locale: $any($event.target).value })">
1879
+ @for (language of state().languages.declared; track language.locale) {
1880
+ <option [value]="language.locale" [selected]="language.locale === state().languages.edited">{{ language.label }}</option>
1881
+ }
1882
+ </select>
1883
+ }
1279
1884
  <div reportToolbar></div>
1280
1885
  </header>
1281
1886
  </div>
1282
- <section class="wb-pane" data-pane="outline">
1283
- <header>{{ t()('pane.outline') }}</header>
1284
- <div class="wb-body">
1285
- <div reportPalette></div>
1286
- <div reportOutline></div>
1287
- @if (empty()) {
1288
- <p data-report-part="outline-empty" [id]="root.outlineEmpty">{{ t()('outline.empty') }}</p>
1887
+ @if (shows('outline')) {
1888
+ <section class="wb-pane" data-pane="outline">
1889
+ <header>
1890
+ <span>{{ t()('pane.outline') }}</span>
1891
+ <button type="button" data-report-part="hide-pane" [attr.aria-label]="t()('action.hidePane', { pane: t()('pane.outline') })" (click)="root.hidePane('outline')">{{ t()('action.hide') }}</button>
1892
+ </header>
1893
+ <div class="wb-body">
1894
+ <div reportPalette></div>
1895
+ <div reportOutline></div>
1896
+ @if (empty()) {
1897
+ <p data-report-part="outline-empty" [id]="root.outlineEmpty">{{ t()('outline.empty') }}</p>
1898
+ }
1899
+ </div>
1900
+ <div reportPlaces></div>
1901
+ </section>
1902
+ }
1903
+ @if (state().view === 'host') {
1904
+ <section data-pane="canvas" data-report-part="view" tabindex="-1" [attr.aria-label]="state().hostView?.name">
1905
+ <ng-container [reportHostOutlet]="hostView()?.template ?? null"></ng-container>
1906
+ </section>
1907
+ } @else {
1908
+ <section class="wb-pane wb-canvas" data-pane="canvas">
1909
+ <header>{{ t()('pane.canvas') }}</header>
1910
+ <div class="wb-body">
1911
+ <section reportCanvas></section>
1912
+ </div>
1913
+ </section>
1914
+ }
1915
+ @if (shows('properties') || shows('diagnostics')) {
1916
+ <section class="wb-pane" [attr.data-pane]="state().panel === 'diagnostics' || !shows('properties') ? 'diagnostics' : 'properties'">
1917
+ @if (shows('properties')) {
1918
+ <header data-pane="properties">
1919
+ <span>{{ state().properties.heading }}</span>
1920
+ @if (state().selection !== null) {
1921
+ <button type="button" (click)="root.dispatch({ type: 'select', id: null }, { to: 'pane', panel: 'properties' })">{{ t()('properties.report') }}</button>
1922
+ }
1923
+ <button type="button" data-report-part="hide-pane" [attr.aria-label]="t()('action.hidePane', { pane: t()('pane.properties') })" (click)="root.hidePane('properties')">{{ t()('action.hide') }}</button>
1924
+ </header>
1925
+ <div class="wb-body" data-pane="properties">
1926
+ <form reportProperties></form>
1927
+ </div>
1289
1928
  }
1290
- </div>
1291
- <div reportPlaces></div>
1292
- </section>
1293
- <section class="wb-pane wb-canvas" data-pane="canvas">
1294
- <header>{{ t()('pane.canvas') }}</header>
1295
- <div class="wb-body">
1296
- <section reportCanvas></section>
1297
- </div>
1298
- </section>
1299
- <section class="wb-pane" [attr.data-pane]="state().panel === 'diagnostics' ? 'diagnostics' : 'properties'">
1300
- <header data-pane="properties">
1301
- <span>{{ state().properties.heading }}</span>
1302
- @if (state().selection !== null) {
1303
- <button type="button" (click)="root.dispatch({ type: 'select', id: null }, { to: 'pane', panel: 'properties' })">{{ t()('properties.report') }}</button>
1929
+ @if (shows('diagnostics')) {
1930
+ <header data-pane="diagnostics">
1931
+ <!-- A status, so a change in how many problems there are is said
1932
+ without taking the person's place: "Problems 2". Named in
1933
+ words, never after its own heading, which the Studio sets in
1934
+ capitals that Chromium would put in the name. -->
1935
+ <div role="status" [attr.aria-label]="t()('pane.problems')">
1936
+ <span>{{ t()('pane.problems') }}</span>{{ count() > 0 ? ' ' : '' }}@if (count() > 0) {<span data-report-part="badge" [attr.data-severity]="severity()">{{ count() }}</span>}
1937
+ </div>
1938
+ <button type="button" data-report-part="hide-pane" [attr.aria-label]="t()('action.hidePane', { pane: t()('pane.problems') })" (click)="root.hidePane('diagnostics')">{{ t()('action.hide') }}</button>
1939
+ </header>
1940
+ <div class="wb-body" data-pane="diagnostics">
1941
+ <div reportProblems></div>
1942
+ </div>
1304
1943
  }
1305
- </header>
1306
- <div class="wb-body" data-pane="properties">
1307
- <form reportProperties></form>
1308
- </div>
1309
- <header data-pane="diagnostics">
1310
- <!-- A status, so a change in how many problems there are is said
1311
- without taking the person's place: "Problems 2". Named in
1312
- words, never after its own heading, which the Studio sets in
1313
- capitals that Chromium would put in the name. -->
1314
- <div role="status" [attr.aria-label]="t()('pane.problems')">
1315
- <span>{{ t()('pane.problems') }}</span>{{ count() > 0 ? ' ' : '' }}@if (count() > 0) {<span data-report-part="badge" [attr.data-severity]="severity()">{{ count() }}</span>}
1316
- </div>
1317
- </header>
1318
- <div class="wb-body" data-pane="diagnostics">
1319
- <div reportProblems></div>
1320
- </div>
1321
- </section>
1944
+ </section>
1945
+ }
1322
1946
  <div class="wb-pane">
1323
1947
  <p reportStatus></p>
1324
1948
  </div>
@@ -1330,6 +1954,12 @@ var ReportBuilder = class ReportBuilder {
1330
1954
  type: ReportCanvas,
1331
1955
  selector: "section[reportCanvas]"
1332
1956
  },
1957
+ {
1958
+ kind: "directive",
1959
+ type: ReportHostOutlet,
1960
+ selector: "[reportHostOutlet]",
1961
+ inputs: ["reportHostOutlet"]
1962
+ },
1333
1963
  {
1334
1964
  kind: "component",
1335
1965
  type: ReportOutline,
@@ -1385,6 +2015,7 @@ i0.ɵɵngDeclareClassMetadata({
1385
2015
  }],
1386
2016
  imports: [
1387
2017
  ReportCanvas,
2018
+ ReportHostOutlet,
1388
2019
  ReportOutline,
1389
2020
  ReportPalette,
1390
2021
  ReportPlaces,
@@ -1397,56 +2028,86 @@ i0.ɵɵngDeclareClassMetadata({
1397
2028
  <div class="wb-pane">
1398
2029
  <header>
1399
2030
  <span data-report-part="title">{{ state().document.title }}</span>
2031
+ @if (state().languages.declared.length > 1) {
2032
+ <select data-report-part="language" [attr.aria-label]="t()('language.label')" (change)="root.dispatch({ type: 'setLanguage', locale: $any($event.target).value })">
2033
+ @for (language of state().languages.declared; track language.locale) {
2034
+ <option [value]="language.locale" [selected]="language.locale === state().languages.edited">{{ language.label }}</option>
2035
+ }
2036
+ </select>
2037
+ }
1400
2038
  <div reportToolbar></div>
1401
2039
  </header>
1402
2040
  </div>
1403
- <section class="wb-pane" data-pane="outline">
1404
- <header>{{ t()('pane.outline') }}</header>
1405
- <div class="wb-body">
1406
- <div reportPalette></div>
1407
- <div reportOutline></div>
1408
- @if (empty()) {
1409
- <p data-report-part="outline-empty" [id]="root.outlineEmpty">{{ t()('outline.empty') }}</p>
2041
+ @if (shows('outline')) {
2042
+ <section class="wb-pane" data-pane="outline">
2043
+ <header>
2044
+ <span>{{ t()('pane.outline') }}</span>
2045
+ <button type="button" data-report-part="hide-pane" [attr.aria-label]="t()('action.hidePane', { pane: t()('pane.outline') })" (click)="root.hidePane('outline')">{{ t()('action.hide') }}</button>
2046
+ </header>
2047
+ <div class="wb-body">
2048
+ <div reportPalette></div>
2049
+ <div reportOutline></div>
2050
+ @if (empty()) {
2051
+ <p data-report-part="outline-empty" [id]="root.outlineEmpty">{{ t()('outline.empty') }}</p>
2052
+ }
2053
+ </div>
2054
+ <div reportPlaces></div>
2055
+ </section>
2056
+ }
2057
+ @if (state().view === 'host') {
2058
+ <section data-pane="canvas" data-report-part="view" tabindex="-1" [attr.aria-label]="state().hostView?.name">
2059
+ <ng-container [reportHostOutlet]="hostView()?.template ?? null"></ng-container>
2060
+ </section>
2061
+ } @else {
2062
+ <section class="wb-pane wb-canvas" data-pane="canvas">
2063
+ <header>{{ t()('pane.canvas') }}</header>
2064
+ <div class="wb-body">
2065
+ <section reportCanvas></section>
2066
+ </div>
2067
+ </section>
2068
+ }
2069
+ @if (shows('properties') || shows('diagnostics')) {
2070
+ <section class="wb-pane" [attr.data-pane]="state().panel === 'diagnostics' || !shows('properties') ? 'diagnostics' : 'properties'">
2071
+ @if (shows('properties')) {
2072
+ <header data-pane="properties">
2073
+ <span>{{ state().properties.heading }}</span>
2074
+ @if (state().selection !== null) {
2075
+ <button type="button" (click)="root.dispatch({ type: 'select', id: null }, { to: 'pane', panel: 'properties' })">{{ t()('properties.report') }}</button>
2076
+ }
2077
+ <button type="button" data-report-part="hide-pane" [attr.aria-label]="t()('action.hidePane', { pane: t()('pane.properties') })" (click)="root.hidePane('properties')">{{ t()('action.hide') }}</button>
2078
+ </header>
2079
+ <div class="wb-body" data-pane="properties">
2080
+ <form reportProperties></form>
2081
+ </div>
1410
2082
  }
1411
- </div>
1412
- <div reportPlaces></div>
1413
- </section>
1414
- <section class="wb-pane wb-canvas" data-pane="canvas">
1415
- <header>{{ t()('pane.canvas') }}</header>
1416
- <div class="wb-body">
1417
- <section reportCanvas></section>
1418
- </div>
1419
- </section>
1420
- <section class="wb-pane" [attr.data-pane]="state().panel === 'diagnostics' ? 'diagnostics' : 'properties'">
1421
- <header data-pane="properties">
1422
- <span>{{ state().properties.heading }}</span>
1423
- @if (state().selection !== null) {
1424
- <button type="button" (click)="root.dispatch({ type: 'select', id: null }, { to: 'pane', panel: 'properties' })">{{ t()('properties.report') }}</button>
2083
+ @if (shows('diagnostics')) {
2084
+ <header data-pane="diagnostics">
2085
+ <!-- A status, so a change in how many problems there are is said
2086
+ without taking the person's place: "Problems 2". Named in
2087
+ words, never after its own heading, which the Studio sets in
2088
+ capitals that Chromium would put in the name. -->
2089
+ <div role="status" [attr.aria-label]="t()('pane.problems')">
2090
+ <span>{{ t()('pane.problems') }}</span>{{ count() > 0 ? ' ' : '' }}@if (count() > 0) {<span data-report-part="badge" [attr.data-severity]="severity()">{{ count() }}</span>}
2091
+ </div>
2092
+ <button type="button" data-report-part="hide-pane" [attr.aria-label]="t()('action.hidePane', { pane: t()('pane.problems') })" (click)="root.hidePane('diagnostics')">{{ t()('action.hide') }}</button>
2093
+ </header>
2094
+ <div class="wb-body" data-pane="diagnostics">
2095
+ <div reportProblems></div>
2096
+ </div>
1425
2097
  }
1426
- </header>
1427
- <div class="wb-body" data-pane="properties">
1428
- <form reportProperties></form>
1429
- </div>
1430
- <header data-pane="diagnostics">
1431
- <!-- A status, so a change in how many problems there are is said
1432
- without taking the person's place: "Problems 2". Named in
1433
- words, never after its own heading, which the Studio sets in
1434
- capitals that Chromium would put in the name. -->
1435
- <div role="status" [attr.aria-label]="t()('pane.problems')">
1436
- <span>{{ t()('pane.problems') }}</span>{{ count() > 0 ? ' ' : '' }}@if (count() > 0) {<span data-report-part="badge" [attr.data-severity]="severity()">{{ count() }}</span>}
1437
- </div>
1438
- </header>
1439
- <div class="wb-body" data-pane="diagnostics">
1440
- <div reportProblems></div>
1441
- </div>
1442
- </section>
2098
+ </section>
2099
+ }
1443
2100
  <div class="wb-pane">
1444
2101
  <p reportStatus></p>
1445
2102
  </div>
1446
2103
  `
1447
2104
  }]
1448
- }]
2105
+ }],
2106
+ propDecorators: { hostView: [{
2107
+ type: i0.ContentChild,
2108
+ args: [i0.forwardRef(() => ReportHostView), { isSignal: true }]
2109
+ }] }
1449
2110
  });
1450
- export { ReportBuilder, ReportCanvas, ReportEditorRoot, ReportOutline, ReportPalette, ReportPlaces, ReportProblems, ReportProperties, ReportStatus, ReportToolbar, injectEditorState };
2111
+ export { ReportBuilder, ReportCanvas, ReportEditorRoot, ReportHostView, ReportOutline, ReportPalette, ReportPlaces, ReportProblems, ReportProperties, ReportStatus, ReportToolbar, injectEditorState };
1451
2112
 
1452
2113
  //# sourceMappingURL=formancy-report-builder-angular.mjs.map