@smallpearl/ngx-helper 0.29.23

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.
Files changed (117) hide show
  1. package/README.md +230 -0
  2. package/core/index.d.ts +2 -0
  3. package/core/src/ngx-helper.d.ts +7 -0
  4. package/core/src/version.d.ts +1 -0
  5. package/entity-field/index.d.ts +2 -0
  6. package/entity-field/src/entity-field-spec.d.ts +69 -0
  7. package/entity-field/src/provider.d.ts +27 -0
  8. package/fesm2022/smallpearl-ngx-helper-core.mjs +23 -0
  9. package/fesm2022/smallpearl-ngx-helper-core.mjs.map +1 -0
  10. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs +112 -0
  11. package/fesm2022/smallpearl-ngx-helper-entity-field.mjs.map +1 -0
  12. package/fesm2022/smallpearl-ngx-helper-forms.mjs +112 -0
  13. package/fesm2022/smallpearl-ngx-helper-forms.mjs.map +1 -0
  14. package/fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs +108 -0
  15. package/fesm2022/smallpearl-ngx-helper-hover-dropdown.mjs.map +1 -0
  16. package/fesm2022/smallpearl-ngx-helper-locale.mjs +296 -0
  17. package/fesm2022/smallpearl-ngx-helper-locale.mjs.map +1 -0
  18. package/fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs +504 -0
  19. package/fesm2022/smallpearl-ngx-helper-mat-busy-wheel.mjs.map +1 -0
  20. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs +184 -0
  21. package/fesm2022/smallpearl-ngx-helper-mat-context-menu.mjs.map +1 -0
  22. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs +1486 -0
  23. package/fesm2022/smallpearl-ngx-helper-mat-entity-crud.mjs.map +1 -0
  24. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs +800 -0
  25. package/fesm2022/smallpearl-ngx-helper-mat-entity-list.mjs.map +1 -0
  26. package/fesm2022/smallpearl-ngx-helper-mat-file-input.mjs +328 -0
  27. package/fesm2022/smallpearl-ngx-helper-mat-file-input.mjs.map +1 -0
  28. package/fesm2022/smallpearl-ngx-helper-mat-form-error.mjs +468 -0
  29. package/fesm2022/smallpearl-ngx-helper-mat-form-error.mjs.map +1 -0
  30. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs +854 -0
  31. package/fesm2022/smallpearl-ngx-helper-mat-select-entity.mjs.map +1 -0
  32. package/fesm2022/smallpearl-ngx-helper-mat-side-menu-layout.mjs +930 -0
  33. package/fesm2022/smallpearl-ngx-helper-mat-side-menu-layout.mjs.map +1 -0
  34. package/fesm2022/smallpearl-ngx-helper-mat-tel-input.mjs +926 -0
  35. package/fesm2022/smallpearl-ngx-helper-mat-tel-input.mjs.map +1 -0
  36. package/fesm2022/smallpearl-ngx-helper-sideload.mjs +111 -0
  37. package/fesm2022/smallpearl-ngx-helper-sideload.mjs.map +1 -0
  38. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs +384 -0
  39. package/fesm2022/smallpearl-ngx-helper-stationary-with-line-items.mjs.map +1 -0
  40. package/fesm2022/smallpearl-ngx-helper.mjs +13 -0
  41. package/fesm2022/smallpearl-ngx-helper.mjs.map +1 -0
  42. package/forms/index.d.ts +1 -0
  43. package/forms/src/validation-error-handler.d.ts +52 -0
  44. package/hover-dropdown/index.d.ts +1 -0
  45. package/hover-dropdown/src/hover-dropdown.directive.d.ts +41 -0
  46. package/index.d.ts +5 -0
  47. package/locale/index.d.ts +5 -0
  48. package/locale/src/currency.pipe.d.ts +14 -0
  49. package/locale/src/date.pipe.d.ts +14 -0
  50. package/locale/src/format-currency.d.ts +1 -0
  51. package/locale/src/format-date.d.ts +2 -0
  52. package/locale/src/is-empty.d.ts +1 -0
  53. package/locale/src/providers.d.ts +20 -0
  54. package/mat-busy-wheel/index.d.ts +4 -0
  55. package/mat-busy-wheel/src/busy-wheel-op.d.ts +65 -0
  56. package/mat-busy-wheel/src/busy-wheel.component.d.ts +12 -0
  57. package/mat-busy-wheel/src/busy-wheel.service.d.ts +42 -0
  58. package/mat-busy-wheel/src/host-busy-wheel.directive.d.ts +35 -0
  59. package/mat-context-menu/index.d.ts +1 -0
  60. package/mat-context-menu/src/mat-context-menu.component.d.ts +54 -0
  61. package/mat-entity-crud/index.d.ts +5 -0
  62. package/mat-entity-crud/src/default-config.d.ts +9 -0
  63. package/mat-entity-crud/src/form-view-host.component.d.ts +34 -0
  64. package/mat-entity-crud/src/mat-entity-crud-form-base.d.ts +95 -0
  65. package/mat-entity-crud/src/mat-entity-crud-internal-types.d.ts +66 -0
  66. package/mat-entity-crud/src/mat-entity-crud-types.d.ts +141 -0
  67. package/mat-entity-crud/src/mat-entity-crud.component.d.ts +267 -0
  68. package/mat-entity-crud/src/preview-host.component.d.ts +19 -0
  69. package/mat-entity-crud/src/preview-pane.component.d.ts +27 -0
  70. package/mat-entity-crud/src/providers.d.ts +3 -0
  71. package/mat-entity-list/index.d.ts +3 -0
  72. package/mat-entity-list/src/config.d.ts +6 -0
  73. package/mat-entity-list/src/mat-entity-list-types.d.ts +53 -0
  74. package/mat-entity-list/src/mat-entity-list.component.d.ts +209 -0
  75. package/mat-entity-list/src/providers.d.ts +3 -0
  76. package/mat-file-input/README.md +63 -0
  77. package/mat-file-input/index.d.ts +1 -0
  78. package/mat-file-input/src/mat-file-input.component.d.ts +58 -0
  79. package/mat-form-error/README.md +306 -0
  80. package/mat-form-error/index.d.ts +6 -0
  81. package/mat-form-error/src/locales/en.d.ts +4 -0
  82. package/mat-form-error/src/locales/hu.d.ts +4 -0
  83. package/mat-form-error/src/locales/index.d.ts +3 -0
  84. package/mat-form-error/src/locales/pt-br.d.ts +4 -0
  85. package/mat-form-error/src/ngx-error-list.component.d.ts +9 -0
  86. package/mat-form-error/src/ngx-mat-error-control.d.ts +17 -0
  87. package/mat-form-error/src/ngx-mat-error-def.directive.d.ts +30 -0
  88. package/mat-form-error/src/ngx-mat-errors-for-date-range-picker.directive.d.ts +8 -0
  89. package/mat-form-error/src/ngx-mat-errors.component.d.ts +23 -0
  90. package/mat-form-error/src/types.d.ts +68 -0
  91. package/mat-form-error/src/utils/coerce-to-observable.d.ts +3 -0
  92. package/mat-form-error/src/utils/distinct-until-error-changed.d.ts +2 -0
  93. package/mat-form-error/src/utils/find-error-for-control.d.ts +9 -0
  94. package/mat-form-error/src/utils/get-abstract-controls.d.ts +3 -0
  95. package/mat-form-error/src/utils/get-control-with-error.d.ts +3 -0
  96. package/mat-select-entity/index.d.ts +2 -0
  97. package/mat-select-entity/src/mat-select-entity.component.d.ts +207 -0
  98. package/mat-select-entity/src/providers.d.ts +9 -0
  99. package/mat-side-menu-layout/index.d.ts +6 -0
  100. package/mat-side-menu-layout/src/layout.service.d.ts +23 -0
  101. package/mat-side-menu-layout/src/mat-menu-layout.component.d.ts +39 -0
  102. package/mat-side-menu-layout/src/mat-menu-layout.module.d.ts +18 -0
  103. package/mat-side-menu-layout/src/mat-menu-list-item.component.d.ts +36 -0
  104. package/mat-side-menu-layout/src/mat-menu-pane.component.d.ts +66 -0
  105. package/mat-side-menu-layout/src/nav-item.d.ts +10 -0
  106. package/mat-tel-input/README.md +18 -0
  107. package/mat-tel-input/index.d.ts +2 -0
  108. package/mat-tel-input/src/country-codes.d.ts +5 -0
  109. package/mat-tel-input/src/mat-telephone.component.d.ts +129 -0
  110. package/mat-tel-input/src/providers.d.ts +38 -0
  111. package/ngx-helper.d.ts +2 -0
  112. package/package.json +114 -0
  113. package/public-api.d.ts +1 -0
  114. package/sideload/index.d.ts +1 -0
  115. package/sideload/src/sideload.d.ts +17 -0
  116. package/stationary-with-line-items/index.d.ts +1 -0
  117. package/stationary-with-line-items/src/stationary-with-line-items.component.d.ts +74 -0
@@ -0,0 +1,63 @@
1
+ # QQMatFileInputComponent (qq-mat-file-input)
2
+
3
+ A file input control, that shows the file's thumbnail, if the selected file is
4
+ an image files. Supported image files are PNG, JPEG, GIF & WEBP.
5
+
6
+ # Dependencies
7
+
8
+ * Angular
9
+ - ReactiveFormsModule
10
+ * Material
11
+ - MatIconModule
12
+ - MatFormFieldModule
13
+
14
+ # How to use
15
+
16
+ For the reactive form:-
17
+
18
+ ```
19
+ form: FormGroup = formBuilder.group({
20
+ image: [imageUrl, Validators.required]
21
+ })
22
+ ```
23
+
24
+ Place the component inside a mat-form-field element as below:
25
+
26
+ ```
27
+ <mat-form-field class="w-100 pb-0" [formGroup]="createUpdateForm">
28
+ <qq-mat-file-input
29
+ formControlName="image"
30
+ accept="image/jpeg,image/png,image/gif"
31
+ class="w-100"
32
+ ></qq-mat-file-input>
33
+ <mat-hint>{{ 'communityImageHint' | transloco }}</mat-hint>
34
+ </mat-form-field>
35
+ ```
36
+
37
+ This will display an input control which the user can click (or tap) to select
38
+ a file from the local machine. The selected file will be loaded into a `File`
39
+ object, which will be set as the value of `form.controls['image']`.
40
+
41
+ This also marks the parent form's state as `touched`.
42
+
43
+ # Inputs
44
+ The control provides the follwing inputs:
45
+
46
+ | Input | Desc |
47
+ |--------|-------------------------------------------------------- |
48
+ | accept | File mime types, to be accepted in the file open dialog. Defaults to all files. |
49
+ | imageFile | If set to true, set's accept to common image file types. |
50
+ | thumbnailImageUrl | URL to the file thumbnail, if its different from the control's value. |
51
+ | multiple | Wheter to select a single file or multiple files. Defaults to false. |
52
+ | placeholder | Place holder string, displayed if control doesn't have a value. |
53
+ | required | If the control input is required. |
54
+ | disabled | If the control is disabled. |
55
+
56
+ # Events
57
+ This control does not raise any events.
58
+
59
+ # Notes
60
+ The control's current value may be initialized to the full URL of the existing
61
+ file. In this case, if the URL is for an image file (determined by its
62
+ extension) and if the `thumbnailImageUrl` property is not set, then that will be
63
+ used as the thumbnail image for the file.
@@ -0,0 +1 @@
1
+ export * from './src/mat-file-input.component';
@@ -0,0 +1,58 @@
1
+ import { ElementRef, OnDestroy, OnInit } from '@angular/core';
2
+ import { ControlValueAccessor, NgControl, UntypedFormControl } from '@angular/forms';
3
+ import { MatFormField, MatFormFieldControl } from '@angular/material/form-field';
4
+ import { Subject } from 'rxjs';
5
+ import * as i0 from "@angular/core";
6
+ export declare class QQMatFileInputComponent implements ControlValueAccessor, MatFormFieldControl<File[]>, OnInit, OnDestroy {
7
+ _formField: MatFormField;
8
+ ngControl: NgControl;
9
+ accept: string;
10
+ thumbnailImageUrl: string;
11
+ imageFile: boolean;
12
+ _fileName: string;
13
+ inputFileUpload: ElementRef | undefined;
14
+ fileControl: UntypedFormControl;
15
+ static nextId: number;
16
+ stateChanges: Subject<void>;
17
+ focused: boolean;
18
+ errorState: boolean;
19
+ controlType: string;
20
+ id: string;
21
+ describedBy: string;
22
+ private _multiple;
23
+ ariaDescribedby: string | undefined;
24
+ _value: File[] | null;
25
+ get empty(): boolean;
26
+ get shouldLabelFloat(): boolean;
27
+ get acceptedFileTypes(): string;
28
+ get multiple(): boolean;
29
+ set multiple(value: boolean | string);
30
+ get placeholder(): string;
31
+ set placeholder(value: string);
32
+ private _placeholder;
33
+ get required(): boolean;
34
+ set required(value: boolean);
35
+ private _required;
36
+ private _disabled;
37
+ private destroy$;
38
+ get disabled(): boolean;
39
+ set disabled(value: boolean);
40
+ get fileName(): string;
41
+ get value(): File[] | null;
42
+ set value(files: File[] | string | null);
43
+ constructor(_formField: MatFormField, ngControl: NgControl);
44
+ setDescribedByIds(ids: string[]): void;
45
+ handleKeyboardEvent(event: KeyboardEvent): void;
46
+ onContainerClick(event: MouseEvent | KeyboardEvent): void;
47
+ writeValue(files: File[]): void;
48
+ registerOnChange(fn: any): void;
49
+ registerOnTouched(fn: any): void;
50
+ onTouched: () => void;
51
+ setDisabledState(isDisabled: boolean): void;
52
+ onFileSelected(event: any): void;
53
+ ngOnInit(): void;
54
+ ngOnDestroy(): void;
55
+ generateLocalThumbnail(file: File): void;
56
+ static ɵfac: i0.ɵɵFactoryDeclaration<QQMatFileInputComponent, [{ optional: true; }, { optional: true; self: true; }]>;
57
+ static ɵcmp: i0.ɵɵComponentDeclaration<QQMatFileInputComponent, "qq-mat-file-input", never, { "accept": { "alias": "accept"; "required": false; }; "thumbnailImageUrl": { "alias": "thumbnailImageUrl"; "required": false; }; "imageFile": { "alias": "imageFile"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "required": { "alias": "required"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, {}, never, never, true, never>;
58
+ }
@@ -0,0 +1,306 @@
1
+ # NgxMatErrors
2
+
3
+ ## What Does It Do?
4
+
5
+ NgxMatErrors provides an easy yet flexible solution for displaying error messages in a `MatFormField`.
6
+
7
+ ## Try It
8
+
9
+ See it in action on [StackBlitz](https://stackblitz.com/edit/ngx-mat-errors-angular-18?file=src%2Fapp%2Fapp.component.html).
10
+
11
+ ## How to Use It
12
+
13
+ Install `ngx-mat-errors` in your project:
14
+
15
+ ```sh
16
+ npm install ngx-mat-errors
17
+ ```
18
+
19
+ Import `NgxMatErrorsModule` and provide `NGX_MAT_ERROR_CONFIG_EN` (or your custom error messages) in your `app.module.ts`.
20
+
21
+ ```typescript
22
+ import { NgxMatErrorsModule, NGX_MAT_ERROR_CONFIG_EN } from "ngx-mat-errors";
23
+
24
+ @NgModule({
25
+ imports: [
26
+ ...,
27
+ NgxMatErrorsModule
28
+ ],
29
+ providers: [NGX_MAT_ERROR_CONFIG_EN],
30
+ })
31
+ export class AppModule {}
32
+ ```
33
+
34
+ Or you can import only `NgxMatErrors` and `NgxMatErrorDef` as they are marked standalone.
35
+
36
+ ```typescript
37
+ import { NgxMatErrors, NgxMatErrorDef, NGX_MAT_ERROR_CONFIG_EN } from "ngx-mat-errors";
38
+
39
+ @NgModule({
40
+ imports: [
41
+ ...,
42
+ NgxMatErrors,
43
+ NgxMatErrorDef
44
+ ],
45
+ providers: [NGX_MAT_ERROR_CONFIG_EN],
46
+ })
47
+ export class AppModule {}
48
+ ```
49
+
50
+ Add `[ngx-mat-errors]` to your `mat-error` in your `mat-form-field`.
51
+
52
+ ```html
53
+ <mat-form-field>
54
+ <mat-label>Label</mat-label>
55
+ <input type="text" matInput [formControl]="control" />
56
+ <mat-error ngx-mat-errors></mat-error>
57
+ </mat-form-field>
58
+ ```
59
+
60
+ ### Outside a `MatFormField` or Override the Control
61
+
62
+ `ngx-mat-errors` can be used as an `@Input()` to assign a control manually.
63
+
64
+ #### Reactive Forms
65
+
66
+ ```html
67
+ <mat-form-field>
68
+ <mat-label>Label</mat-label>
69
+ <input type="text" matInput [formControl]="control" autocomplete="off" />
70
+ </mat-form-field>
71
+ <mat-error [ngx-mat-errors]="control"></mat-error>
72
+ ```
73
+
74
+ #### Template-Driven Forms
75
+
76
+ ```html
77
+ <mat-form-field>
78
+ <mat-label>Label</mat-label>
79
+ <input type="text" matInput #control="ngModel" [(ngModel)]="input" autocomplete="off" />
80
+ </mat-form-field>
81
+ <mat-error [ngx-mat-errors]="control"></mat-error>
82
+ ```
83
+
84
+ ### Multiple Controls
85
+
86
+ It can display errors for multiple controls, one at a time. The order of the controls is important; the first control with an error will be displayed.
87
+
88
+ ```html
89
+ <mat-form-field>
90
+ <mat-label>Label</mat-label>
91
+ <mat-date-range-input [rangePicker]="dateRangePicker">
92
+ <input matStartDate [formControl]="startControl" />
93
+ <input matEndDate [formControl]="endControl" />
94
+ </mat-date-range-input>
95
+ <mat-date-range-picker #dateRangePicker></mat-date-range-picker>
96
+ <mat-error [ngx-mat-errors]="[startControl, endControl]"></mat-error>
97
+ </mat-form-field>
98
+ ```
99
+
100
+ #### `NgxMatErrorsForDateRangePicker` Directive
101
+
102
+ ```typescript
103
+ import { NgxMatErrorsForDateRangePicker } from "ngx-mat-errors";
104
+ ```
105
+
106
+ You can use the `[forDateRangePicker]` standalone directive to display errors for the `MatDateRangePicker` component. The directive assigns the controls used in the `MatDateRangeInput` to the `NgxMatErrors` component.
107
+
108
+ ```html
109
+ <mat-form-field>
110
+ <mat-label>Label</mat-label>
111
+ <mat-date-range-input [rangePicker]="dateRangePicker">
112
+ <input matStartDate formControlName="start" />
113
+ <input matEndDate formControlName="end" />
114
+ </mat-date-range-input>
115
+ <mat-date-range-picker #dateRangePicker></mat-date-range-picker>
116
+ <mat-error ngx-mat-errors forDateRangePicker></mat-error>
117
+ </mat-form-field>
118
+ ```
119
+
120
+ You can easily create directives like this to display errors in a `MatFormField` with multiple controls.
121
+
122
+ ## Customize
123
+
124
+ There are two ways to customize your error messages.
125
+
126
+ ### Injection Token
127
+
128
+ There is the `NGX_MAT_ERROR_DEFAULT_OPTIONS` injection token. You can provide it in your `app.module.ts` with `useClass` or `useFactory` and customize your error messages globally.
129
+
130
+ This example changes only the `min` error message.
131
+
132
+ ```typescript
133
+ import {
134
+ errorMessagesEnFactory,
135
+ NGX_MAT_ERROR_DEFAULT_OPTIONS
136
+ } from 'ngx-mat-errors';
137
+ import { FactoryProvider, LOCALE_ID } from '@angular/core';
138
+
139
+ export const NGX_MAT_ERROR_DEFAULT_CONFIG: FactoryProvider = {
140
+ useFactory: (locale: string) => ({
141
+ ...errorMessagesEnFactory(locale),
142
+ min: (error: MinError) =>
143
+ `Min value is ${error.min}, actual is ${error.actual}`,
144
+ }),
145
+ provide: NGX_MAT_ERROR_DEFAULT_OPTIONS,
146
+ deps: [LOCALE_ID],
147
+ };
148
+
149
+ @NgModule({
150
+ ...
151
+ providers: [NGX_MAT_ERROR_DEFAULT_CONFIG],
152
+ })
153
+ export class AppModule {}
154
+ ```
155
+
156
+ You can provide an `Observable<ErrorMessages>` too, which allows changes of error messages. This comes in handy when your app supports JIT localization with libraries like `@ngx-translate`.
157
+
158
+ ```typescript
159
+ import {
160
+ NGX_MAT_ERROR_DEFAULT_OPTIONS
161
+ } from 'ngx-mat-errors';
162
+ import { FactoryProvider, LOCALE_ID } from '@angular/core';
163
+ import { TranslateModule, TranslateService } from '@ngx-translate/core';
164
+ import { Observable, startWith, map } from 'rxjs';
165
+
166
+ export const NGX_MAT_ERROR_DEFAULT_CONFIG: FactoryProvider = {
167
+ useFactory: (
168
+ locale: string,
169
+ translateService: TranslateService
170
+ ): Observable<ErrorMessages> => translateService.onLangChange.pipe(
171
+ startWith(null),
172
+ map(() => ({
173
+ required: translateService.instant('core.validations.required'),
174
+ minlength: (error: MinError) => translateService.instant('core.validations.minlength', error),
175
+ ...
176
+ }))
177
+ ),
178
+ provide: NGX_MAT_ERROR_DEFAULT_OPTIONS,
179
+ deps: [LOCALE_ID, TranslateService],
180
+ };
181
+
182
+ @NgModule({
183
+ ...
184
+ providers: [NGX_MAT_ERROR_DEFAULT_CONFIG],
185
+ })
186
+ export class AppModule {}
187
+ ```
188
+
189
+ ### \*ngxMatErrorDef
190
+
191
+ You can customize your error messages even more with the `*ngxMatErrorDef` directive.
192
+
193
+ ```html
194
+ <mat-form-field>
195
+ <mat-label>Label</mat-label>
196
+ <input type="text" matInput [formControl]="control1" />
197
+ <mat-error ngx-mat-errors>
198
+ <span *ngxMatErrorDef="let error; for: 'pattern'"> Only digits are allowed, up to 12 digits. </span>
199
+ <ng-container *ngxMatErrorDef="let error; for: 'min'"> The minimum value is {{ error.min }}. </ng-container>
200
+ </mat-error>
201
+ </mat-form-field>
202
+ ```
203
+
204
+ When used with multiple controls, you can specify the control for which the error message is intended.
205
+
206
+ ```html
207
+ <mat-form-field>
208
+ <mat-label>Label</mat-label>
209
+ <mat-date-range-input [rangePicker]="dateRangePicker">
210
+ <input matStartDate formControlName="start" />
211
+ <input matEndDate [formControl]="endControl" />
212
+ </mat-date-range-input>
213
+ <mat-date-range-picker #dateRangePicker></mat-date-range-picker>
214
+ <mat-error ngx-mat-errors forDateRangePicker>
215
+ <span *ngxMatErrorDef="let error; for: 'required', withControl: 'start'">Start date is required.</span>
216
+ <span *ngxMatErrorDef="let error; for: 'required', withControl: endControl">End date is required.</span>
217
+ </mat-error>
218
+ </mat-form-field>
219
+ ```
220
+
221
+ ## Compatibility
222
+
223
+ - `@angular/core: ^18.0.0 || ^19.0.0`
224
+ - `@angular/material: ^18.0.0 || ^19.0.0`
225
+
226
+ ### Reactive Forms
227
+
228
+ #### Errors Inside a `MatFormField`
229
+
230
+ ```html
231
+ <mat-form-field>
232
+ <mat-label>Label</mat-label>
233
+ <input type="text" matInput [formControl]="control" />
234
+ <mat-error ngx-mat-errors></mat-error>
235
+ </mat-form-field>
236
+ ```
237
+
238
+ #### Errors Outside a `MatFormField`
239
+
240
+ ```html
241
+ <mat-error [ngx-mat-errors]="control"></mat-error>
242
+ <mat-form-field>
243
+ <mat-label>Label</mat-label>
244
+ <input type="text" matInput [formControl]="control" />
245
+ </mat-form-field>
246
+ ```
247
+
248
+ #### Errors for Multiple Controls
249
+
250
+ ```html
251
+ <mat-form-field>
252
+ <mat-label>Label</mat-label>
253
+ <mat-date-range-input [rangePicker]="dateRangePicker">
254
+ <input matStartDate [formControl]="startControl" />
255
+ <input matEndDate [formControl]="endControl" />
256
+ </mat-date-range-input>
257
+ <mat-date-range-picker #dateRangePicker></mat-date-range-picker>
258
+ <mat-error [ngx-mat-errors]="[startControl, endControl]"></mat-error>
259
+ </mat-form-field>
260
+ ```
261
+
262
+ ### Template-Driven Forms
263
+
264
+ #### Errors Inside a `MatFormField`
265
+
266
+ ```html
267
+ <mat-form-field>
268
+ <mat-label>Label</mat-label>
269
+ <input type="text" matInput [(ngModel)]="value" />
270
+ <mat-error ngx-mat-errors></mat-error>
271
+ </mat-form-field>
272
+ ```
273
+
274
+ #### Errors Outside a `MatFormField`
275
+
276
+ ```html
277
+ <mat-error [ngx-mat-errors]="control"></mat-error>
278
+ <mat-form-field>
279
+ <mat-label>Label</mat-label>
280
+ <input type="text" matInput #control="ngModel" [(ngModel)]="value" />
281
+ </mat-form-field>
282
+ ```
283
+
284
+ #### Errors for Multiple Controls
285
+
286
+ ```html
287
+ <mat-form-field>
288
+ <mat-label>Label</mat-label>
289
+ <mat-date-range-input [rangePicker]="dateRangePicker">
290
+ <input matStartDate #startControl="ngModel" [(ngModel)]="start" />
291
+ <input matEndDate #endControl="ngModel" [(ngModel)]="end" />
292
+ </mat-date-range-input>
293
+ <mat-date-range-picker #dateRangePicker></mat-date-range-picker>
294
+ <mat-error [ngx-mat-errors]="[startControl, endControl]"></mat-error>
295
+ </mat-form-field>
296
+ ```
297
+
298
+ ## Development
299
+
300
+ ### Library Build / NPM Package
301
+
302
+ Run `npm run develop` to build the library and generate an NPM package. The build artifacts will be stored in the `dist/ngx-mat-errors` folder.
303
+
304
+ ### Development Server
305
+
306
+ Run `npm start` for a dev server. Navigate to `http://localhost:4202/`. The app will automatically reload if you change any of the source files.
@@ -0,0 +1,6 @@
1
+ export * from './src/locales';
2
+ export * from './src/ngx-mat-error-def.directive';
3
+ export * from './src/ngx-mat-errors-for-date-range-picker.directive';
4
+ export * from './src/ngx-mat-errors.component';
5
+ export * from './src/ngx-error-list.component';
6
+ export type * from './src/types';
@@ -0,0 +1,4 @@
1
+ import { type FactoryProvider } from '@angular/core';
2
+ import type { ErrorMessages } from '../types';
3
+ export declare function errorMessagesEnFactory(locale: string, dateFormat?: string, timeFormat?: string): ErrorMessages;
4
+ export declare const NGX_MAT_ERROR_CONFIG_EN: FactoryProvider;
@@ -0,0 +1,4 @@
1
+ import { type FactoryProvider } from '@angular/core';
2
+ import type { ErrorMessages } from '../types';
3
+ export declare function errorMessagesHuFactory(locale: string, dateFormat?: string, timeFormat?: string): ErrorMessages;
4
+ export declare const NGX_MAT_ERROR_CONFIG_HU: FactoryProvider;
@@ -0,0 +1,3 @@
1
+ export * from './en';
2
+ export * from './hu';
3
+ export * from './pt-br';
@@ -0,0 +1,4 @@
1
+ import { type FactoryProvider } from '@angular/core';
2
+ import type { ErrorMessages } from '../types';
3
+ export declare function errorMessagesPtBtFactory(locale: string, dateFormat?: string, timeFormat?: string): ErrorMessages;
4
+ export declare const NGX_MAT_ERROR_CONFIG_PT_BR: FactoryProvider;
@@ -0,0 +1,9 @@
1
+ import { NgxMatErrors } from './ngx-mat-errors.component';
2
+ import { NgxMatErrorControls } from './types';
3
+ import * as i0 from "@angular/core";
4
+ export declare class NgxErrorList extends NgxMatErrors {
5
+ isArray(e: string | string[]): e is string[];
6
+ set control(control: NgxMatErrorControls);
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxErrorList, never>;
8
+ static ɵcmp: i0.ɵɵComponentDeclaration<NgxErrorList, "ngx-error-list, [ngx-error-list]", never, { "control": { "alias": "ngx-error-list"; "required": false; }; }, {}, never, never, true, never>;
9
+ }
@@ -0,0 +1,17 @@
1
+ import { type Provider } from '@angular/core';
2
+ import type { FormFieldControl } from './types';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * This class contains the logic of getting the default control of a MatFormField.
6
+ * Extend it to implement a custom getter method.
7
+ */
8
+ export declare class NgxMatErrorControl {
9
+ protected readonly matFormField: import("@angular/material/form-field").MatFormField | null;
10
+ get(): undefined | FormFieldControl | FormFieldControl[];
11
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatErrorControl, never>;
12
+ static ɵprov: i0.ɵɵInjectableDeclaration<NgxMatErrorControl>;
13
+ }
14
+ /**
15
+ * Provides the default control accessor of a MatFormField.
16
+ */
17
+ export declare function provideDefaultNgxMatErrorControl(): Provider;
@@ -0,0 +1,30 @@
1
+ import { InjectionToken, TemplateRef } from '@angular/core';
2
+ import { AbstractControl, type AbstractControlDirective } from '@angular/forms';
3
+ import * as i0 from "@angular/core";
4
+ export interface INgxMatErrorDef {
5
+ ngxMatErrorDefFor: string;
6
+ ngxMatErrorDefWithControl?: AbstractControlDirective | AbstractControl | string | null;
7
+ template: TemplateRef<any>;
8
+ control?: AbstractControl;
9
+ }
10
+ /**
11
+ * Lightweight injection token. When NgxMatErrorDef is not used, only this token will remain, the directive will be tree-shaken.
12
+ */
13
+ export declare const NGX_MAT_ERROR_DEF: InjectionToken<INgxMatErrorDef>;
14
+ export declare class NgxMatErrorDef implements INgxMatErrorDef {
15
+ /**
16
+ * Specify the error key to be used for error matching.
17
+ * @required
18
+ */
19
+ ngxMatErrorDefFor: string;
20
+ /**
21
+ * Specify the control to be used for error matching.
22
+ * @optional
23
+ */
24
+ ngxMatErrorDefWithControl?: AbstractControlDirective | AbstractControl | string | null;
25
+ readonly template: TemplateRef<any>;
26
+ private readonly controlContainer;
27
+ get control(): AbstractControl | undefined;
28
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatErrorDef, never>;
29
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgxMatErrorDef, "[ngxMatErrorDef]", never, { "ngxMatErrorDefFor": { "alias": "ngxMatErrorDefFor"; "required": true; }; "ngxMatErrorDefWithControl": { "alias": "ngxMatErrorDefWithControl"; "required": false; }; }, {}, never, never, true, never>;
30
+ }
@@ -0,0 +1,8 @@
1
+ import { NgxMatErrorControl } from './ngx-mat-error-control';
2
+ import * as i0 from "@angular/core";
3
+ export declare class NgxMatErrorsForDateRangePicker<D> extends NgxMatErrorControl {
4
+ /** Returns start and end controls of the date range picker. */
5
+ get(): (import("@angular/material/datepicker").MatStartDate<D> | import("@angular/material/datepicker").MatEndDate<D>)[];
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatErrorsForDateRangePicker<any>, never>;
7
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgxMatErrorsForDateRangePicker<any>, "[ngx-mat-errors][forDateRangePicker]", never, {}, {}, never, never, true, never>;
8
+ }
@@ -0,0 +1,23 @@
1
+ import { InjectionToken, type OnDestroy, type QueryList } from '@angular/core';
2
+ import { type Observable } from 'rxjs';
3
+ import { type INgxMatErrorDef } from './ngx-mat-error-def.directive';
4
+ import type { ErrorMessages, ErrorTemplate, NgxMatErrorControls } from './types';
5
+ import * as i0 from "@angular/core";
6
+ export declare const NGX_MAT_ERROR_DEFAULT_OPTIONS: InjectionToken<ErrorMessages | Observable<ErrorMessages>>;
7
+ export declare class NgxMatErrors implements OnDestroy {
8
+ private readonly messages$;
9
+ private readonly defaultControl;
10
+ private readonly controlChangedSubject;
11
+ protected error$: Observable<ErrorTemplate>;
12
+ protected set customErrorMessages(queryList: QueryList<INgxMatErrorDef>);
13
+ /**
14
+ * @deprecated will be changed to a signal and it won't be possible to set the property from TS.
15
+ * Instead of setting it in a directive, the directive should extend the {@link NgxMatErrorControl } class
16
+ * and provide itself as it.
17
+ */
18
+ set control(control: NgxMatErrorControls);
19
+ /** @ignore */
20
+ ngOnDestroy(): void;
21
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxMatErrors, never>;
22
+ static ɵcmp: i0.ɵɵComponentDeclaration<NgxMatErrors, "ngx-mat-errors, [ngx-mat-errors]", never, { "control": { "alias": "ngx-mat-errors"; "required": false; }; }, {}, ["customErrorMessages"], never, true, never>;
23
+ }
@@ -0,0 +1,68 @@
1
+ import type { TemplateRef } from '@angular/core';
2
+ import type { AbstractControl, AbstractControlDirective, ValidationErrors } from '@angular/forms';
3
+ import type { MatFormFieldControl } from '@angular/material/form-field';
4
+ export type ErrorTemplate = {
5
+ template: TemplateRef<any>;
6
+ $implicit: ValidationErrors;
7
+ } | {
8
+ template: undefined;
9
+ $implicit: string | string[];
10
+ } | undefined;
11
+ export type FormFieldControl = Pick<MatFormFieldControl<any>, 'ngControl'>;
12
+ export type NgxMatErrorControls = FormFieldControl | AbstractControl | AbstractControlDirective | (FormFieldControl | AbstractControl | AbstractControlDirective)[] | undefined | null | '';
13
+ export type ErrorTransform = (error: any) => string;
14
+ export interface ErrorMessages {
15
+ [key: string]: string | ErrorTransform;
16
+ }
17
+ /**
18
+ * For errors: 'min', 'matDatepickerMin'
19
+ */
20
+ export interface MinError<T = number> {
21
+ min: T;
22
+ actual: T;
23
+ }
24
+ /**
25
+ * For errors: 'max', 'matDatepickerMax'
26
+ */
27
+ export interface MaxError<T = number> {
28
+ max: T;
29
+ actual: T;
30
+ }
31
+ /**
32
+ * For errors: 'minlength', 'maxlength'
33
+ */
34
+ export interface LengthError {
35
+ requiredLength: number;
36
+ actualLength: number;
37
+ }
38
+ /**
39
+ * For errors: 'pattern'
40
+ */
41
+ export interface PatternValidator {
42
+ requiredPattern: string;
43
+ actualValue: string;
44
+ }
45
+ /**
46
+ * For errors: 'matStartDateInvalid'
47
+ */
48
+ export interface StartDateError<D> {
49
+ end: D;
50
+ actual: D;
51
+ }
52
+ /**
53
+ * For errors: 'matEndDateInvalid'
54
+ */
55
+ export interface EndDateError<D> {
56
+ start: D;
57
+ actual: D;
58
+ }
59
+ /**
60
+ * For errors: 'matDatepickerParse', 'matTimepickerParse'
61
+ */
62
+ export interface ParseError {
63
+ text: string;
64
+ }
65
+ /**
66
+ * @deprecated to be removed in version 20. Please use ParseError instead
67
+ */
68
+ export type DatepickerParseError = ParseError;
@@ -0,0 +1,3 @@
1
+ import { type Observable } from 'rxjs';
2
+ import type { ErrorMessages } from '../types';
3
+ export declare function coerceToObservable(errorMessages: ErrorMessages | Observable<ErrorMessages>): Observable<ErrorMessages>;
@@ -0,0 +1,2 @@
1
+ import type { ErrorTemplate } from '../types';
2
+ export declare function distinctUntilErrorChanged<P extends ErrorTemplate>(prev: P, curr: P): boolean;
@@ -0,0 +1,9 @@
1
+ import type { AbstractControl } from '@angular/forms';
2
+ import type { INgxMatErrorDef } from '../ngx-mat-error-def.directive';
3
+ import { ErrorMessages } from '../types';
4
+ /**
5
+ * Finds the error key or custom error for a control. The original function
6
+ * has been modified
7
+ * @returns INgxMatErrorDef | undefined
8
+ */
9
+ export declare function findErrorsForControl(control: AbstractControl, messages: ErrorMessages, customErrorMessages: readonly INgxMatErrorDef[]): string[] | INgxMatErrorDef;
@@ -0,0 +1,3 @@
1
+ import { AbstractControl } from '@angular/forms';
2
+ import type { NgxMatErrorControls } from '../types';
3
+ export declare function getAbstractControls(controls: NgxMatErrorControls): AbstractControl[] | undefined;
@@ -0,0 +1,3 @@
1
+ import type { AbstractControl } from '@angular/forms';
2
+ import { type Observable } from 'rxjs';
3
+ export declare function getControlWithError(controls: AbstractControl[]): Observable<AbstractControl | undefined>;
@@ -0,0 +1,2 @@
1
+ export * from './src/providers';
2
+ export * from './src/mat-select-entity.component';