@wemake4u/form-player 2.0.2 → 2.0.3

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/package.json CHANGED
@@ -1,33 +1,25 @@
1
1
  {
2
2
  "name": "@wemake4u/form-player",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "license": "MIT",
5
5
  "peerDependencies": {
6
- "@angular/cdk": "^22.2.0",
7
6
  "@angular/common": "^22.2.0",
8
7
  "@angular/core": "^22.2.0",
9
- "@angular/material": "22.2.2",
8
+ "@angular/forms": "^22.2.0",
9
+ "@angular/platform-browser": "^22.2.0",
10
+ "@angular/router": "^22.2.0",
10
11
  "rxjs": "~7.8.0",
11
- "bootstrap": "5.3.3",
12
- "ag-grid-angular": "^33.0.4",
13
- "@ag-grid-community/angular": "^32.3.7",
14
- "@ag-grid-community/locale": "^33.1.0",
15
12
  "ag-charts-angular": "^11.3.2",
16
13
  "ag-charts-community": "^11.3.2",
17
- "util": "^0.12.5",
18
14
  "@wemake4u/interact": "^1.0.6",
19
- "@wemake4u/form-controls": "^2.0.2"
15
+ "@wemake4u/form-controls": "^2.0.3"
20
16
  },
21
17
  "dependencies": {
22
18
  "tslib": "^2.3.0",
23
- "@types/mime-db": "1.43.5",
24
- "@types/sanitize-html": "2.13.0",
25
19
  "feelers": "^1.5.1",
26
20
  "feelin": "6.2.0",
27
21
  "marked": "15.0.7",
28
- "mime-db": "1.53.0",
29
- "sanitize-html": "^2.13.0",
30
- "date-fns": "4.3.0"
22
+ "dompurify": "^3.4.0"
31
23
  },
32
24
  "sideEffects": false,
33
25
  "module": "fesm2022/wemake4u-form-player.mjs",
@@ -3,11 +3,10 @@ import { ChangeDetectorRef, DestroyRef, ElementRef, EnvironmentInjector, EventEm
3
3
  import { ActivatedRoute, Params, Router } from "@angular/router";
4
4
  import { AbstractControl, AbstractControlOptions, AsyncValidatorFn, FormControlStatus, FormGroup, ValidationErrors, ValidatorFn } from "@angular/forms";
5
5
  import { Observable, Subject } from "rxjs";
6
- import { SirioButtonVariant, SirioDialogSize, SirioSidenavItem, SirioStep, SirioToastService } from "@wemake4u/form-controls";
6
+ import { SirioButtonVariant, SirioDialogSize, SirioGridFilterType, SirioGridFilters, SirioGridSort, SirioSidenavItem, SirioStep, SirioToastService } from "@wemake4u/form-controls";
7
7
  import { ConfirmationController, LanguageService, Message, MessageFactory, NotificationController, NotifyTypes, PromptController } from "@wemake4u/interact";
8
8
  import { DomSanitizer, SafeHtml, SafeResourceUrl } from "@angular/platform-browser";
9
9
  import { HttpClient } from "@angular/common/http";
10
- import { FilterModel, IGetRowsParams } from "ag-grid-community";
11
10
  declare class FormGroupEx<TControl extends { [K in keyof TControl]: AbstractControl<any>; }> extends FormGroup<TControl> {
12
11
  constructor(controls: TControl, mode: FormGroupMode, validatorOrOpts?: ValidatorFn | ValidatorFn[] | AbstractControlOptions | null, asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null);
13
12
  getMode(): FormGroupMode;
@@ -611,6 +610,8 @@ declare class StatusCollection<TKey = any> {
611
610
  constructor(key?: any | undefined);
612
611
  readonly controls: Set<AbstractControl<any, any, any>>;
613
612
  readonly children: Map<TKey, StatusCollection<TKey>>;
613
+ /** Key of the root collection this collection belongs to (set on child collections). */
614
+ rootKey?: any;
614
615
  add(control: AbstractControl): this;
615
616
  remove(control: AbstractControl): this;
616
617
  has(control: AbstractControl): boolean;
@@ -808,6 +809,8 @@ export declare class DynamicFormComponent implements OnInit, OnChanges, OnDestro
808
809
  SomethingWentWrong: string;
809
810
  TimeoutOccurred: string;
810
811
  GenericError: string;
812
+ ServiceUnreachable: string;
813
+ GridNavigationHint: string;
811
814
  ItemPosition: string;
812
815
  ItemAdded: string;
813
816
  ItemRemoved: string;
@@ -875,6 +878,8 @@ export declare class DynamicFormComponent implements OnInit, OnChanges, OnDestro
875
878
  SomethingWentWrong: string;
876
879
  TimeoutOccurred: string;
877
880
  GenericError: string;
881
+ ServiceUnreachable: string;
882
+ GridNavigationHint: string;
878
883
  ItemPosition: string;
879
884
  ItemAdded: string;
880
885
  ItemRemoved: string;
@@ -942,6 +947,8 @@ export declare class DynamicFormComponent implements OnInit, OnChanges, OnDestro
942
947
  SomethingWentWrong: string;
943
948
  TimeoutOccurred: string;
944
949
  GenericError: string;
950
+ ServiceUnreachable: string;
951
+ GridNavigationHint: string;
945
952
  ItemPosition: string;
946
953
  ItemAdded: string;
947
954
  ItemRemoved: string;
@@ -1009,6 +1016,8 @@ export declare class DynamicFormComponent implements OnInit, OnChanges, OnDestro
1009
1016
  SomethingWentWrong: string;
1010
1017
  TimeoutOccurred: string;
1011
1018
  GenericError: string;
1019
+ ServiceUnreachable: string;
1020
+ GridNavigationHint: string;
1012
1021
  ItemPosition: string;
1013
1022
  ItemAdded: string;
1014
1023
  ItemRemoved: string;
@@ -1076,6 +1085,8 @@ export declare class DynamicFormComponent implements OnInit, OnChanges, OnDestro
1076
1085
  SomethingWentWrong: string;
1077
1086
  TimeoutOccurred: string;
1078
1087
  GenericError: string;
1088
+ ServiceUnreachable: string;
1089
+ GridNavigationHint: string;
1079
1090
  ItemPosition: string;
1080
1091
  ItemAdded: string;
1081
1092
  ItemRemoved: string;
@@ -1143,6 +1154,8 @@ export declare class DynamicFormComponent implements OnInit, OnChanges, OnDestro
1143
1154
  SomethingWentWrong: string;
1144
1155
  TimeoutOccurred: string;
1145
1156
  GenericError: string;
1157
+ ServiceUnreachable: string;
1158
+ GridNavigationHint: string;
1146
1159
  ItemPosition: string;
1147
1160
  ItemAdded: string;
1148
1161
  ItemRemoved: string;
@@ -1210,6 +1223,8 @@ export declare class DynamicFormComponent implements OnInit, OnChanges, OnDestro
1210
1223
  SomethingWentWrong: string;
1211
1224
  TimeoutOccurred: string;
1212
1225
  GenericError: string;
1226
+ ServiceUnreachable: string;
1227
+ GridNavigationHint: string;
1213
1228
  ItemPosition: string;
1214
1229
  ItemAdded: string;
1215
1230
  ItemRemoved: string;
@@ -1446,7 +1461,8 @@ export declare class SanitizeService {
1446
1461
  sanitizeSafeHtml(html: string): SafeHtml;
1447
1462
  sanitizeSafeUrl(url: string): SafeResourceUrl;
1448
1463
  toString(safeHtml: SafeHtml): string;
1449
- private sanitizeOption;
1464
+ private readonly purify;
1465
+ private readonly sanitizeOption;
1450
1466
  static ɵfac: i0.ɵɵFactoryDeclaration<SanitizeService, never>;
1451
1467
  static ɵprov: i0.ɵɵInjectableDeclaration<any>;
1452
1468
  }
@@ -1472,10 +1488,60 @@ declare class RestDataSource<T, T2 = T> {
1472
1488
  getParams(): Record<string, any>;
1473
1489
  getData(): Observable<T2[]>;
1474
1490
  }
1475
- interface IRowsSource {
1476
- getRows: (params: IGetRowsParams) => void;
1491
+ /**
1492
+ * Filter model by column key, in the ag-grid format: `{ filterType, type, filter, filterTo }`,
1493
+ * `{ filterType: 'date', type, dateFrom, dateTo }` or `{ operator: 'AND' | 'OR', conditions }`.
1494
+ */
1495
+ type FilterModel = Record<string, any>;
1496
+ /** Sort criterion of a table: column key and direction. */
1497
+ interface OrderModelItem {
1498
+ colId: string;
1499
+ sort: 'asc' | 'desc';
1477
1500
  }
1478
- interface IDataSource {
1501
+ /** Sort criteria of a table, in priority order. */
1502
+ interface OrderModel extends Array<OrderModelItem> {}
1503
+ /** A column of the data grid as seen by the conversion: filter key and filter type. */
1504
+ interface GridModelColumn {
1505
+ /** Key of the column in the grid filters (unique also for columns on the same field, `data~2`). */
1506
+ key: string;
1507
+ /** Field of the column, the name known by a server source (default: the key). */
1508
+ field?: string;
1509
+ filter: SirioGridFilterType | null;
1510
+ }
1511
+ /**
1512
+ * ag-grid filter model → data grid filters. Conditions combined with AND / OR cannot be represented
1513
+ * (one condition per column): an OR of "equals" on a select column becomes "is one of", the other
1514
+ * combinations keep only the first condition and are reported in the console.
1515
+ */
1516
+ declare function filterModelToSirio(model: FilterModel | null | undefined, columns: readonly GridModelColumn[]): SirioGridFilters;
1517
+ /** Data grid filters → ag-grid filter model (the format of `TableControl.getFilter()`). */
1518
+ declare function sirioFiltersToModel(filters: SirioGridFilters, columns: readonly GridModelColumn[]): FilterModel;
1519
+ /** ag-grid sort model of `TableControl` → data grid sort. */
1520
+ declare function orderModelToSirio(order: readonly OrderModelItem[] | null | undefined): SirioGridSort[];
1521
+ /** Data grid sort → ag-grid sort model of `TableControl`. */
1522
+ declare function sirioSortToOrderModel(sort: readonly SirioGridSort[]): OrderModelItem[];
1523
+ /**
1524
+ * Request of a block of rows to an `IRowsSource`. Same shape as the `IGetRowsParams` of the ag-grid
1525
+ * infinite row model, so the sources written for it (e.g. `queryRows` of `@wemake4u/remoting`) keep
1526
+ * working.
1527
+ */
1528
+ export interface RowsRequest {
1529
+ /** First row of the block (0-based). */
1530
+ startRow: number;
1531
+ /** Row after the last one of the block. */
1532
+ endRow: number;
1533
+ sortModel: OrderModelItem[];
1534
+ filterModel: FilterModel;
1535
+ context: any;
1536
+ /** Rows of the block and, when known, the total row count. */
1537
+ successCallback(rowsThisBlock: any[], lastRow?: number): void;
1538
+ failCallback(): void;
1539
+ }
1540
+ /** Server data source of a table, reading the rows by blocks. */
1541
+ export interface IRowsSource {
1542
+ getRows: (params: RowsRequest) => void;
1543
+ }
1544
+ export interface IDataSource {
1479
1545
  getData(params: Record<string, any>): Observable<any>;
1480
1546
  }
1481
1547
  export declare class DataService {
@@ -1521,14 +1587,22 @@ export declare class DefaultPromptController implements PromptController {
1521
1587
  static ɵfac: i0.ɵɵFactoryDeclaration<DefaultPromptController, never>;
1522
1588
  static ɵprov: i0.ɵɵInjectableDeclaration<any>;
1523
1589
  }
1590
+ /**
1591
+ * Global properties (GlobalService) that override the default texts of the error messages,
1592
+ * so that an application can use the same texts of its server (WCAG 3.2.4).
1593
+ */
1594
+ export declare const ERROR_TITLE_PROPERTY = "errorTitle";
1595
+ export declare const ERROR_DETAIL_PROPERTY = "errorDetail";
1524
1596
  export declare class DefaultMessageFactory implements MessageFactory {
1525
1597
  languageService: LanguageService;
1598
+ private readonly global;
1526
1599
  constructor(languageService: LanguageService);
1527
1600
  createError(err: any): Message;
1528
1601
  private get language();
1529
1602
  private locale;
1530
1603
  private getTitleText;
1531
1604
  private getTimeoutText;
1605
+ private getUnreachableText;
1532
1606
  private getDetailText;
1533
1607
  static ɵfac: i0.ɵɵFactoryDeclaration<DefaultMessageFactory, never>;
1534
1608
  static ɵprov: i0.ɵɵInjectableDeclaration<any>;
@@ -1653,60 +1727,37 @@ export declare class AccordionControl extends ContainerControl {
1653
1727
  }
1654
1728
  export declare class DynamicListControl extends ContainerControl {}
1655
1729
  export declare class GroupControl extends ContainerControl {}
1656
- export declare class TableControl extends Control {
1657
- setFilter(filter: FilterModel): void;
1658
- getFilter(): FilterModel;
1659
- clearFilter(): void;
1660
- getOrder(): OrderModel;
1661
- setOrder(order: OrderModel): void;
1662
- refresh(): void;
1663
- redraw(): void;
1664
- private currentState;
1665
- onLoadState(): void;
1666
- onSaveState(): void;
1667
- private createState;
1668
- private applyState;
1669
- private applyPagination;
1670
- private applyPageSize;
1671
- private applyPageNumber;
1672
- private get grid();
1673
- private paginationEnabled;
1674
- }
1675
- export interface OrderModelItem {
1676
- colId: string;
1677
- sort: 'asc' | 'desc';
1678
- }
1679
- export interface OrderModel extends Array<OrderModelItem> {}
1680
1730
  /**
1681
- * Control of a `table` component rendered by the Sirio data grid (`DynamicFieldsComponent.useDataGrid`).
1682
- * Same API as `TableControl` (ag-grid), so the form expressions work with both grids: filters and
1683
- * sort use the ag-grid models, converted to the data grid ones (`ag-grid-model.ts`).
1684
- *
1685
- * It extends `TableControl` (overriding every method, nothing of ag-grid is used) so the code that
1686
- * looks for the control by type (`getControlAs(name, TableControl)`) keeps working with both grids.
1687
- *
1688
- * When ag-grid is removed this content moves to `TableControl` (without the conversion, once the
1689
- * forms use the data grid models) and `DataGridControl` is deleted.
1731
+ * Control of a `table` component, rendered by the Sirio data grid (`@wemake4u/form-controls`).
1732
+ * Filters and sort use the models of the forms (ag-grid format, `grid-models.ts`), converted to the
1733
+ * data grid ones.
1690
1734
  */
1691
- export declare class DataGridControl extends TableControl {
1735
+ export declare class TableControl extends Control {
1692
1736
  setFilter(filter: FilterModel): void;
1693
1737
  getFilter(): FilterModel;
1694
1738
  clearFilter(): void;
1695
1739
  getOrder(): OrderModel;
1696
1740
  setOrder(order: OrderModel): void;
1697
- /** Evaluates the data source expression again (as `TableControl`) and reloads a server source. */
1741
+ /** Evaluates the data source expression again and reloads a server source. */
1698
1742
  refresh(): void;
1699
1743
  /** The data grid renders its rows from the data: nothing to redraw. */
1700
1744
  redraw(): void;
1701
1745
  private gridState;
1702
1746
  onLoadState(): void;
1703
1747
  onSaveState(): void;
1704
- /** Restores the saved state; a state saved by ag-grid (`TableControl`) is ignored. */
1748
+ /** Restores the saved state; a state saved by the former ag-grid table is ignored. */
1705
1749
  private restoreState;
1706
1750
  private get dataGrid();
1707
- /** Filter keys and types of the grid columns, for the ag-grid model conversion. */
1751
+ /** Filter keys and types of the grid columns, for the model conversion. */
1708
1752
  private modelColumns;
1709
1753
  }
1754
+ /**
1755
+ * @deprecated The `table` control is always rendered by the Sirio data grid: use `TableControl`.
1756
+ * Kept as an alias for the code written while ag-grid and the data grid coexisted.
1757
+ */
1758
+ export declare const DataGridControl: typeof TableControl;
1759
+ /** @deprecated Use `TableControl`. */
1760
+ export type DataGridControl = TableControl;
1710
1761
  export declare class ButtonControl extends Control {
1711
1762
  /** The registered element is the native button (wmSirioButton of @wemake4u/form-controls). */
1712
1763
  focus(): void;
@@ -1716,4 +1767,4 @@ export declare class SpacerControl extends Control {}
1716
1767
  export declare class IFrameControl extends Control {}
1717
1768
  export declare class TooltipControl extends Control {}
1718
1769
  export declare class DisplayFieldControl extends Control {}
1719
- export {};
1770
+ export type { FilterModel, OrderModel, OrderModelItem };