@formancy/report-builder-angular 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.
@@ -58,7 +58,12 @@ var ReportEditorRoot = class ReportEditorRoot {
58
58
  }
59
59
  attempt(action, focus) {
60
60
  const outcome = this.editor().dispatch(action);
61
- if (outcome.ok) this.focusAfter = focus;
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;
62
67
  return outcome;
63
68
  }
64
69
  choosePlace(subject, opener) {
@@ -172,7 +177,14 @@ var ReportEditorRoot = class ReportEditorRoot {
172
177
  this.focusAfter = null;
173
178
  const root = this.host.nativeElement;
174
179
  const first = (selectors) => selectors.reduce((found, selector) => found ?? root.querySelector(selector), null);
175
- (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;
176
188
  }
177
189
  static ɵfac = i0.ɵɵngDeclareFactory({
178
190
  minVersion: "12.0.0",
@@ -254,6 +266,10 @@ var ReportCanvas = class ReportCanvas {
254
266
  const subject = this.state().drag?.subject;
255
267
  return subject !== void 0 && "id" in subject ? subject.id : null;
256
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
+ }
257
273
  select(box) {
258
274
  this.root.dispatch({
259
275
  type: "select",
@@ -261,6 +277,12 @@ var ReportCanvas = class ReportCanvas {
261
277
  ...box.column === void 0 ? {} : { column: box.column }
262
278
  }, { to: "selection" });
263
279
  }
280
+ selectBill() {
281
+ this.root.dispatch({
282
+ type: "select",
283
+ part: "paymentPart"
284
+ }, { to: "selection" });
285
+ }
264
286
  drag(box, event) {
265
287
  event.stopPropagation();
266
288
  this.root.pickUp(event, { id: box.id }, box.label);
@@ -333,8 +355,9 @@ var ReportCanvas = class ReportCanvas {
333
355
  [attr.data-kind]="box.kind"
334
356
  [attr.data-selected]="box.selected ? 'true' : null"
335
357
  [attr.data-overflows]="box.overflows ? 'true' : null"
358
+ [attr.data-missing]="box.missing === undefined ? null : 'true'"
336
359
  [attr.data-dragging]="box.id === dragged() && box.column === undefined ? 'true' : null"
337
- [attr.title]="box.overflows ? t()('canvas.overflow') : null"
360
+ [attr.title]="described(box)"
338
361
  [attr.draggable]="box.column === undefined ? 'true' : null"
339
362
  [style.left.px]="box.px.x"
340
363
  [style.top.px]="box.px.y"
@@ -346,17 +369,22 @@ var ReportCanvas = class ReportCanvas {
346
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>
347
370
  }
348
371
  <!-- Where a payment part's slip prints, below every region: a picture
349
- named as SIX names the part, as a box is named by its label. -->
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. -->
350
374
  @if (canvas().paymentPart; as band) {
351
375
  <div
352
376
  role="img"
353
377
  data-report-part="payment-part"
354
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"
355
382
  [style.left.px]="band.px.x"
356
383
  [style.top.px]="band.px.y"
357
384
  [style.width.px]="band.px.width"
358
385
  [style.height.px]="band.px.height"
359
- ><span data-report-part="region-label">{{ band.label }}</span></div>
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>
360
388
  }
361
389
  <!-- Drawn only for the places the session accepts, named as the place
362
390
  chooser names them; the one under the pointer, or focused in the
@@ -425,8 +453,9 @@ i0.ɵɵngDeclareClassMetadata({
425
453
  [attr.data-kind]="box.kind"
426
454
  [attr.data-selected]="box.selected ? 'true' : null"
427
455
  [attr.data-overflows]="box.overflows ? 'true' : null"
456
+ [attr.data-missing]="box.missing === undefined ? null : 'true'"
428
457
  [attr.data-dragging]="box.id === dragged() && box.column === undefined ? 'true' : null"
429
- [attr.title]="box.overflows ? t()('canvas.overflow') : null"
458
+ [attr.title]="described(box)"
430
459
  [attr.draggable]="box.column === undefined ? 'true' : null"
431
460
  [style.left.px]="box.px.x"
432
461
  [style.top.px]="box.px.y"
@@ -438,17 +467,22 @@ i0.ɵɵngDeclareClassMetadata({
438
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>
439
468
  }
440
469
  <!-- Where a payment part's slip prints, below every region: a picture
441
- named as SIX names the part, as a box is named by its label. -->
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. -->
442
472
  @if (canvas().paymentPart; as band) {
443
473
  <div
444
474
  role="img"
445
475
  data-report-part="payment-part"
446
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"
447
480
  [style.left.px]="band.px.x"
448
481
  [style.top.px]="band.px.y"
449
482
  [style.width.px]="band.px.width"
450
483
  [style.height.px]="band.px.height"
451
- ><span data-report-part="region-label">{{ band.label }}</span></div>
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>
452
486
  }
453
487
  <!-- Drawn only for the places the session accepts, named as the place
454
488
  chooser names them; the one under the pointer, or focused in the
@@ -576,12 +610,13 @@ var ReportOutline = class ReportOutline {
576
610
  rows: rows(region.nodes)
577
611
  })), ...ngDevMode ? [{ debugName: "regions" }] : /* istanbul ignore next */ []);
578
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 */ []);
579
614
  stop = computed(() => {
580
- const all = this.all();
581
- 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;
582
617
  }, ...ngDevMode ? [{ debugName: "stop" }] : /* istanbul ignore next */ []);
583
- problems(node) {
584
- return `${this.root.id}-problems-${node.key}`;
618
+ problems(row) {
619
+ return `${this.root.id}-problems-${row.key}`;
585
620
  }
586
621
  overflow(node) {
587
622
  return `${this.root.id}-overflow-${node.key}`;
@@ -604,6 +639,18 @@ var ReportOutline = class ReportOutline {
604
639
  ...node.column === void 0 ? {} : { column: node.column }
605
640
  });
606
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
+ }
607
654
  drag(node, event) {
608
655
  this.root.pickUp(event, { id: node.id }, node.label);
609
656
  }
@@ -689,6 +736,23 @@ var ReportOutline = class ReportOutline {
689
736
  }
690
737
  </div>
691
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
+ }
692
756
  }
693
757
  `,
694
758
  isInline: true,
@@ -750,6 +814,23 @@ i0.ɵɵngDeclareClassMetadata({
750
814
  }
751
815
  </div>
752
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
+ }
753
834
  }
754
835
  `
755
836
  }]
@@ -1182,38 +1263,278 @@ const CONTROLS = {
1182
1263
  combobox: "select",
1183
1264
  checkbox: "checkbox"
1184
1265
  };
1185
- var ReportProperties = class ReportProperties {
1266
+ var ReportPropertyRow = class ReportPropertyRow {
1186
1267
  root = inject(ReportEditorRoot);
1187
- shown = computed(() => {
1188
- const { selection, properties } = this.root.state();
1189
- const owner = selection === null ? "report" : `${selection.id}${selection.column === void 0 ? "" : `-${selection.column}`}`;
1190
- return properties.fields.map((field, index) => {
1191
- const id = `${this.root.id}-${owner}-${String(index)}`;
1192
- return {
1193
- field,
1194
- control: field.kind === "multiline" ? "textarea" : CONTROLS[PROPERTY_ROLES[field.kind]],
1195
- id,
1196
- errorId: field.error === void 0 ? null : `${id}-error`
1197
- };
1198
- });
1199
- }, ...ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []);
1200
- commit(field, value) {
1201
- 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);
1202
1274
  if (now !== void 0 && now.value === value) return;
1203
1275
  this.root.dispatch({
1204
1276
  type: "setProperty",
1205
1277
  key: field.key,
1206
1278
  value
1207
1279
  });
1280
+ const reads = this.now(field)?.value;
1281
+ if (control !== void 0 && reads !== void 0 && control.value !== String(reads)) control.value = String(reads);
1208
1282
  }
1209
1283
  enter(field, event) {
1210
1284
  event.preventDefault();
1211
- this.commit(field, event.target.value);
1285
+ const control = event.target;
1286
+ this.commit(field, control.value, control);
1212
1287
  }
1213
1288
  giveBack(field, event) {
1214
- const now = this.root.state().properties.fields.find((candidate) => candidate.key === field.key) ?? field;
1289
+ const now = this.now(field) ?? field;
1215
1290
  event.target.value = String(now.value);
1216
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
+ }
1217
1538
  static ɵfac = i0.ɵɵngDeclareFactory({
1218
1539
  minVersion: "12.0.0",
1219
1540
  version: "22.2.2",
@@ -1235,65 +1556,26 @@ var ReportProperties = class ReportProperties {
1235
1556
  },
1236
1557
  ngImport: i0,
1237
1558
  template: `
1238
- @for (shown of shown(); track shown.id) {
1239
- <div data-report-part="property" [attr.data-kind]="shown.field.kind">
1240
- <label [attr.for]="shown.id">{{ shown.field.label }}</label>
1241
- @switch (shown.control) {
1242
- @case ('textarea') {
1243
- <textarea
1244
- [id]="shown.id"
1245
- [value]="shown.field.value"
1246
- [required]="shown.field.required"
1247
- [attr.placeholder]="shown.field.placeholder ?? null"
1248
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1249
- [attr.aria-describedby]="shown.errorId"
1250
- (change)="commit(shown.field, $any($event.target).value)"
1251
- (keydown.escape)="giveBack(shown.field, $event)"
1252
- ></textarea>
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>
1253
1565
  }
1254
- @case ('checkbox') {
1255
- <input
1256
- type="checkbox"
1257
- [id]="shown.id"
1258
- [checked]="shown.field.value === true"
1259
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1260
- [attr.aria-describedby]="shown.errorId"
1261
- (change)="commit(shown.field, $any($event.target).checked)"
1262
- />
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>
1263
1574
  }
1264
- @case ('select') {
1265
- <select
1266
- [id]="shown.id"
1267
- [required]="shown.field.required"
1268
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1269
- [attr.aria-describedby]="shown.errorId"
1270
- (change)="commit(shown.field, $any($event.target).value)"
1271
- >
1272
- @for (option of shown.field.options ?? []; track option.value) {
1273
- <option [value]="option.value" [selected]="option.value === shown.field.value">{{ option.label }}</option>
1274
- }
1275
- </select>
1276
- }
1277
- @default {
1278
- <input
1279
- [type]="shown.control"
1280
- [attr.step]="shown.control === 'number' ? 'any' : null"
1281
- [id]="shown.id"
1282
- [value]="shown.field.value"
1283
- [required]="shown.field.required"
1284
- [attr.placeholder]="shown.field.placeholder ?? null"
1285
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1286
- [attr.aria-describedby]="shown.errorId"
1287
- (change)="commit(shown.field, $any($event.target).value)"
1288
- (keydown.enter)="enter(shown.field, $event)"
1289
- (keydown.escape)="giveBack(shown.field, $event)"
1290
- />
1291
- }
1292
- }
1293
- @if (shown.errorId !== null) {
1294
- <p data-report-part="property-error" class="wb-problem" [id]="shown.errorId">{{ shown.field.error }}</p>
1295
- }
1296
- </div>
1575
+ </div>
1576
+ } @else {
1577
+ <div reportPropertyRow [shown]="fieldOf(row)"></div>
1578
+ }
1297
1579
  }
1298
1580
  @if (root.state().selection === null && root.state().images.assets.length > 0) {
1299
1581
  <div reportImageLibrary></div>
@@ -1304,6 +1586,11 @@ var ReportProperties = class ReportProperties {
1304
1586
  kind: "component",
1305
1587
  type: ReportImageLibrary,
1306
1588
  selector: "div[reportImageLibrary]"
1589
+ }, {
1590
+ kind: "component",
1591
+ type: ReportPropertyRow,
1592
+ selector: "div[reportPropertyRow]",
1593
+ inputs: ["shown"]
1307
1594
  }],
1308
1595
  changeDetection: i0.ChangeDetectionStrategy.OnPush
1309
1596
  });
@@ -1318,72 +1605,33 @@ i0.ɵɵngDeclareClassMetadata({
1318
1605
  args: [{
1319
1606
  selector: "form[reportProperties]",
1320
1607
  changeDetection: ChangeDetectionStrategy.OnPush,
1321
- imports: [ReportImageLibrary],
1608
+ imports: [ReportImageLibrary, ReportPropertyRow],
1322
1609
  host: {
1323
1610
  "data-report-part": "properties",
1324
1611
  "[attr.aria-label]": "root.state().properties.heading",
1325
1612
  "(submit)": "$event.preventDefault()"
1326
1613
  },
1327
1614
  template: `
1328
- @for (shown of shown(); track shown.id) {
1329
- <div data-report-part="property" [attr.data-kind]="shown.field.kind">
1330
- <label [attr.for]="shown.id">{{ shown.field.label }}</label>
1331
- @switch (shown.control) {
1332
- @case ('textarea') {
1333
- <textarea
1334
- [id]="shown.id"
1335
- [value]="shown.field.value"
1336
- [required]="shown.field.required"
1337
- [attr.placeholder]="shown.field.placeholder ?? null"
1338
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1339
- [attr.aria-describedby]="shown.errorId"
1340
- (change)="commit(shown.field, $any($event.target).value)"
1341
- (keydown.escape)="giveBack(shown.field, $event)"
1342
- ></textarea>
1343
- }
1344
- @case ('checkbox') {
1345
- <input
1346
- type="checkbox"
1347
- [id]="shown.id"
1348
- [checked]="shown.field.value === true"
1349
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1350
- [attr.aria-describedby]="shown.errorId"
1351
- (change)="commit(shown.field, $any($event.target).checked)"
1352
- />
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>
1353
1621
  }
1354
- @case ('select') {
1355
- <select
1356
- [id]="shown.id"
1357
- [required]="shown.field.required"
1358
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1359
- [attr.aria-describedby]="shown.errorId"
1360
- (change)="commit(shown.field, $any($event.target).value)"
1361
- >
1362
- @for (option of shown.field.options ?? []; track option.value) {
1363
- <option [value]="option.value" [selected]="option.value === shown.field.value">{{ option.label }}</option>
1364
- }
1365
- </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>
1366
1630
  }
1367
- @default {
1368
- <input
1369
- [type]="shown.control"
1370
- [attr.step]="shown.control === 'number' ? 'any' : null"
1371
- [id]="shown.id"
1372
- [value]="shown.field.value"
1373
- [required]="shown.field.required"
1374
- [attr.placeholder]="shown.field.placeholder ?? null"
1375
- [attr.aria-invalid]="shown.errorId === null ? null : 'true'"
1376
- [attr.aria-describedby]="shown.errorId"
1377
- (change)="commit(shown.field, $any($event.target).value)"
1378
- (keydown.enter)="enter(shown.field, $event)"
1379
- (keydown.escape)="giveBack(shown.field, $event)"
1380
- />
1381
- }
1382
- }
1383
- @if (shown.errorId !== null) {
1384
- <p data-report-part="property-error" class="wb-problem" [id]="shown.errorId">{{ shown.field.error }}</p>
1385
- }
1386
- </div>
1631
+ </div>
1632
+ } @else {
1633
+ <div reportPropertyRow [shown]="fieldOf(row)"></div>
1634
+ }
1387
1635
  }
1388
1636
  @if (root.state().selection === null && root.state().images.assets.length > 0) {
1389
1637
  <div reportImageLibrary></div>
@@ -1484,7 +1732,7 @@ var ReportToolbar = class ReportToolbar {
1484
1732
  if ("pane" in use) return this.root.showPane(use.pane);
1485
1733
  if ("placeSelection" in use) {
1486
1734
  const selection = this.state().selection;
1487
- 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);
1488
1736
  return;
1489
1737
  }
1490
1738
  this.root.dispatch(use.action);
@@ -1626,6 +1874,13 @@ var ReportBuilder = class ReportBuilder {
1626
1874
  <div class="wb-pane">
1627
1875
  <header>
1628
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
+ }
1629
1884
  <div reportToolbar></div>
1630
1885
  </header>
1631
1886
  </div>
@@ -1773,6 +2028,13 @@ i0.ɵɵngDeclareClassMetadata({
1773
2028
  <div class="wb-pane">
1774
2029
  <header>
1775
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
+ }
1776
2038
  <div reportToolbar></div>
1777
2039
  </header>
1778
2040
  </div>