@enigmatry/entry-components 17.0.0-preview.5 → 17.0.0-preview.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -32
- package/assets/nswag-templates/Client.RequestBody.liquid +95 -95
- package/assets/nswag-templates/Client.RequestUrl.liquid +67 -67
- package/assets/nswag-templates/ConvertToClass.liquid +64 -64
- package/assets/nswag-templates/original/Client.RequestBody.liquid +89 -89
- package/assets/nswag-templates/original/Client.RequestUrl.liquid +59 -59
- package/assets/nswag-templates/original/ConvertToClass.liquid +65 -65
- package/assets/nswag-templates/original/File.FormatDate.liquid +4 -4
- package/assets/nswag-templates/original/File.ParseDateOnly.liquid +4 -4
- package/button/README.md +45 -45
- package/date-time-picker/README.md +69 -69
- package/dialog/README.md +73 -73
- package/esm2022/button/entry-button.directive.mjs +1 -1
- package/esm2022/button/entry-button.module.mjs +1 -1
- package/esm2022/button/public-api.mjs +1 -1
- package/esm2022/common/common.module.mjs +1 -1
- package/esm2022/common/date-time/entry-date-time-adapter.mjs +1 -1
- package/esm2022/common/date-time/entry-date-time-formats.mjs +1 -1
- package/esm2022/common/date-time/entry-time-adapter.mjs +1 -1
- package/esm2022/common/date-time/native-time-adapter.mjs +1 -1
- package/esm2022/common/directives/auto-disable-button.directive.mjs +1 -1
- package/esm2022/common/directives/ng-control-accessor.directive.mjs +1 -1
- package/esm2022/common/directives/noop-control-value-accessor.mjs +1 -1
- package/esm2022/common/interceptors/accept-language.interceptor.mjs +1 -1
- package/esm2022/common/public-api.mjs +1 -1
- package/esm2022/date-time-picker/date-time-picker.component.mjs +3 -3
- package/esm2022/date-time-picker/date-time-picker.module.mjs +1 -1
- package/esm2022/date-time-picker/public-api.mjs +1 -1
- package/esm2022/date-time-picker/time-picker.component.mjs +3 -3
- package/esm2022/dialog/dialogs/alert/entry-alert-dialog-data.interface.mjs +1 -1
- package/esm2022/dialog/dialogs/alert/entry-alert-dialog.component.mjs +3 -3
- package/esm2022/dialog/dialogs/confirm/entry-confirm-dialog-data.interface.mjs +1 -1
- package/esm2022/dialog/dialogs/confirm/entry-confirm-dialog.component.mjs +3 -3
- package/esm2022/dialog/dialogs/entry-dialog.component.mjs +3 -3
- package/esm2022/dialog/dialogs/error/entry-error-dialog-data.interface.mjs +1 -1
- package/esm2022/dialog/dialogs/error/entry-error-dialog.component.mjs +3 -3
- package/esm2022/dialog/entry-dialog-buttons-alignment.type.mjs +1 -1
- package/esm2022/dialog/entry-dialog-config.model.mjs +1 -1
- package/esm2022/dialog/entry-dialog.module.mjs +1 -1
- package/esm2022/dialog/entry-dialog.service.mjs +1 -1
- package/esm2022/dialog/public-api.mjs +1 -1
- package/esm2022/file-input/entry-file-input.component.mjs +1 -1
- package/esm2022/file-input/entry-file-input.module.mjs +1 -1
- package/esm2022/file-input/public-api.mjs +1 -1
- package/esm2022/permissions/permission-type.mjs +1 -1
- package/esm2022/permissions/permission.directive.mjs +1 -1
- package/esm2022/permissions/permission.module.mjs +1 -1
- package/esm2022/permissions/permission.pipe.mjs +1 -1
- package/esm2022/permissions/public-api.mjs +1 -1
- package/esm2022/public-api.mjs +1 -1
- package/esm2022/search-filter/autocomplete/autocomplete-search-filter.component.mjs +3 -3
- package/esm2022/search-filter/autocomplete/autocomplete-search-filter.model.mjs +1 -1
- package/esm2022/search-filter/control-type.mjs +1 -1
- package/esm2022/search-filter/date/date-search-filter.component.mjs +3 -3
- package/esm2022/search-filter/date/date-search-filter.model.mjs +1 -1
- package/esm2022/search-filter/date-time/date-time-search-filter.component.mjs +3 -3
- package/esm2022/search-filter/date-time/date-time-search-filter.model.mjs +1 -1
- package/esm2022/search-filter/public-api.mjs +1 -1
- package/esm2022/search-filter/search-filter-base.model.mjs +1 -1
- package/esm2022/search-filter/search-filter-config.model.mjs +1 -1
- package/esm2022/search-filter/search-filter-params.type.mjs +1 -1
- package/esm2022/search-filter/select/select-search-filter.component.mjs +3 -3
- package/esm2022/search-filter/select/select-search-filter.model.mjs +1 -1
- package/esm2022/search-filter/select-option.model.mjs +1 -1
- package/esm2022/search-filter/text/text-search-filter.component.mjs +3 -3
- package/esm2022/search-filter/text/text-search-filter.model.mjs +1 -1
- package/esm2022/spinner/entry-spinner/spinner.component.mjs +1 -1
- package/esm2022/spinner/public-api.mjs +1 -1
- package/esm2022/spinner/spinner.module.mjs +1 -1
- package/esm2022/table/components/entry-cell/entry-cell.component.mjs +1 -1
- package/esm2022/table/components/entry-cell-context-menu/entry-cell-context-menu.component.mjs +3 -3
- package/esm2022/table/components/entry-cell-formatted-value/entry-cell-formatted-value.component.mjs +3 -3
- package/esm2022/table/components/entry-table/entry-table.component.mjs +3 -3
- package/esm2022/table/entry-table.module.mjs +1 -1
- package/esm2022/table/interfaces/entry-table-config.mjs +1 -1
- package/esm2022/table/interfaces/paged-query.mjs +1 -1
- package/esm2022/table/interfaces/pagination.mjs +1 -1
- package/esm2022/table/public-api.mjs +1 -1
- package/esm2022/validation/entry-display-control-validation.directive.mjs +1 -1
- package/esm2022/validation/entry-form-errors.component.mjs +13 -13
- package/esm2022/validation/entry-validation-config.model.mjs +1 -1
- package/esm2022/validation/entry-validation.mjs +1 -1
- package/esm2022/validation/entry-validation.module.mjs +1 -1
- package/esm2022/validation/public-api.mjs +1 -1
- package/esm2022/validation/validation-problem-details.interface.mjs +1 -1
- package/fesm2022/enigmatry-entry-components-button.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-common.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-date-time-picker.mjs +4 -4
- package/fesm2022/enigmatry-entry-components-date-time-picker.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-dialog.mjs +8 -8
- package/fesm2022/enigmatry-entry-components-dialog.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-file-input.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-permissions.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-search-filter.mjs +10 -10
- package/fesm2022/enigmatry-entry-components-search-filter.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-spinner.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-table.mjs +6 -6
- package/fesm2022/enigmatry-entry-components-table.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components-validation.mjs +12 -12
- package/fesm2022/enigmatry-entry-components-validation.mjs.map +1 -1
- package/fesm2022/enigmatry-entry-components.mjs.map +1 -1
- package/file-input/README.md +70 -70
- package/package.json +1 -1
- package/permissions/README.md +67 -67
- package/search-filter/README.md +132 -132
- package/styles/_generator.scss +25 -25
- package/styles/modules/_default-theme.scss +91 -91
- package/styles/modules/components/buttons/_generator.scss +10 -10
- package/styles/modules/components/buttons/_radio.scss +18 -18
- package/styles/modules/components/checkboxes/_generator.scss +31 -31
- package/styles/modules/components/dialogs/_generator.scss +13 -13
- package/styles/modules/components/forms/_generator.scss +14 -14
- package/styles/modules/components/inputs/_generator.scss +14 -14
- package/styles/modules/components/search-filter/_generator.scss +14 -14
- package/styles/modules/components/tables/_cells.scss +25 -25
- package/styles/modules/components/tables/_generator.scss +6 -6
- package/styles/modules/components/tables/_header.scss +10 -10
- package/styles/modules/components/tables/_no-result.scss +9 -9
- package/styles/modules/components/tables/_rows.scss +39 -39
- package/styles/modules/components/tables/_sorting.scss +10 -10
- package/styles/modules/components/tables/_table-body.scss +12 -12
- package/styles/modules/components/toggle/_generator.scss +47 -47
- package/styles/modules/typography/_fonts.scss +64 -64
- package/styles/modules/vendors/angular-material/_generator.scss +46 -46
- package/styles/modules/vendors/angular-material/_palette-generator.scss +32 -32
- package/styles/modules/vendors/angular-material/_typography-generator.scss +107 -107
- package/styles/partials/core/components/_index.scss +4 -4
- package/styles/partials/core/components/date-time-picker/_general.scss +64 -64
- package/styles/partials/core/components/dialogs/_general.scss +23 -23
- package/styles/partials/core/components/forms/_general.scss +21 -21
- package/styles/partials/core/components/search-filter/_general.scss +8 -8
- package/styles/partials/core/components/tables/_general.scss +17 -17
- package/styles/partials/generator-test.scss +41 -41
- package/styles/partials/theming.scss +1 -1
- package/table/README.md +76 -76
- package/validation/README.md +108 -108
package/validation/README.md
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
# Entry Validation
|
|
2
|
-
|
|
3
|
-
Enables configuring forms (Reactive or [Formly](https://formly.dev/)) so that server or client side validation errors are displayed correctly. To accomplish this, it offers the following features:
|
|
4
|
-
|
|
5
|
-
* `setServerSideValidationErrors(error, form)` - a method that maps received server side validation errors to the form and its fields.
|
|
6
|
-
* `entryDisplayControlValidation` - a directive that displays field level validation errors.
|
|
7
|
-
* `<entry-form-errors>` - a component that displays form level validation errors.
|
|
8
|
-
* `ENTRY_VALIDATION_CONFIG` - configuration provider used to configure default client side validation messages on module level.
|
|
9
|
-
|
|
10
|
-
## Integration
|
|
11
|
-
|
|
12
|
-
```npm
|
|
13
|
-
npm i @enigmatry/entry-components
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Import component package:
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import { EntryValidationModule } from '@enigmatry/entry-components/validation';
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Styles import:
|
|
23
|
-
|
|
24
|
-
```css
|
|
25
|
-
@use '@enigmatry/entry-components/styles/generate' as entry;
|
|
26
|
-
|
|
27
|
-
@include entry.generate(APP_THEME, APP_TYPOGRAPHY);
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Where `APP_THEME` represents application theming configuration, while `APP_TYPOGRAPHY` represents application fonts configuration.
|
|
31
|
-
|
|
32
|
-
## Basic usage
|
|
33
|
-
|
|
34
|
-
Add `entryDisplayControlValidation` & `<entry-form-errors>` elements to the form to support validation error messages:
|
|
35
|
-
|
|
36
|
-
```html
|
|
37
|
-
<form [formGroup]="form" (ngSubmit)="submitForm()">
|
|
38
|
-
<mat-form-field class="example-form-field">
|
|
39
|
-
<mat-label>First name</mat-label>
|
|
40
|
-
<input matInput type="text" formControlName="firstName">
|
|
41
|
-
<mat-error entryDisplayControlValidation [control]="form.controls.firstName"></mat-error>
|
|
42
|
-
</mat-form-field>
|
|
43
|
-
|
|
44
|
-
<entry-form-errors [form]="form"></entry-form-errors>
|
|
45
|
-
|
|
46
|
-
<button mat-flat-button color="accent" type="submit">Submit</button>
|
|
47
|
-
</form>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
On submit handle _BadRequest (400)_ response using `setServerSideValidationErrors(error, form)` method:
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
import { IValidationProblemDetails, setServerSideValidationErrors } from '@enigmatry/entry-components/validation';
|
|
54
|
-
|
|
55
|
-
// ...
|
|
56
|
-
submitForm() {
|
|
57
|
-
this._apiService.post()
|
|
58
|
-
.subscribe({
|
|
59
|
-
error: (error: IValidationProblemDetails) => setServerSideValidationErrors(error, this.form)
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Configuration
|
|
65
|
-
|
|
66
|
-
Optionally, when using Reactive form, client side validation messages can be configured on module level:
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
// ...
|
|
70
|
-
import { AbstractControl } from '@angular/forms';
|
|
71
|
-
import { EntryValidationModule, provideEntryValidationConfig } from '@enigmatry/entry-components/validation';
|
|
72
|
-
|
|
73
|
-
@NgModule({
|
|
74
|
-
imports: [
|
|
75
|
-
// ...
|
|
76
|
-
EntryValidationModule
|
|
77
|
-
]
|
|
78
|
-
providers: [
|
|
79
|
-
provideEntryValidationConfig({
|
|
80
|
-
validationMessages: [
|
|
81
|
-
{ name: 'required', message: 'This field is mandatory!' },
|
|
82
|
-
{ name: 'minlength', message: (control: AbstractControl) => `Minimal length is ${control.errors.minlength.requiredLength}!` }
|
|
83
|
-
]
|
|
84
|
-
})
|
|
85
|
-
]
|
|
86
|
-
})
|
|
87
|
-
export class AppModule { }
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Microsoft WEB.API & NSwag configuration
|
|
91
|
-
|
|
92
|
-
To configure REST API (_Microsoft WEB.API_) to return _Bad Request_ responses in uniform format, decorate all end-points that trigger validation with `ProducesResponseType` attribute that maps [ValidationProblemDetails](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.validationproblemdetails?view=aspnetcore-7.0) to _Bad Request_ responses:
|
|
93
|
-
|
|
94
|
-
```csharp
|
|
95
|
-
using Microsoft.AspNetCore.Mvc;
|
|
96
|
-
|
|
97
|
-
// ...
|
|
98
|
-
|
|
99
|
-
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
|
100
|
-
public async Task<ActionResult<Response>> Post([FromBody] Command command)
|
|
101
|
-
{
|
|
102
|
-
// ...
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
When set like this, generated ([NSwag](https://github.com/RicoSuter/NSwag)) client side models for _Bad Request_ responses can be used as input parameter of `setServerSideValidationErrors(error, form)` method.
|
|
107
|
-
|
|
108
|
-
This is because `IValidationProblemDetails` interface is based on [ValidationProblemDetails](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.validationproblemdetails?view=aspnetcore-7.0) class.
|
|
1
|
+
# Entry Validation
|
|
2
|
+
|
|
3
|
+
Enables configuring forms (Reactive or [Formly](https://formly.dev/)) so that server or client side validation errors are displayed correctly. To accomplish this, it offers the following features:
|
|
4
|
+
|
|
5
|
+
* `setServerSideValidationErrors(error, form)` - a method that maps received server side validation errors to the form and its fields.
|
|
6
|
+
* `entryDisplayControlValidation` - a directive that displays field level validation errors.
|
|
7
|
+
* `<entry-form-errors>` - a component that displays form level validation errors.
|
|
8
|
+
* `ENTRY_VALIDATION_CONFIG` - configuration provider used to configure default client side validation messages on module level.
|
|
9
|
+
|
|
10
|
+
## Integration
|
|
11
|
+
|
|
12
|
+
```npm
|
|
13
|
+
npm i @enigmatry/entry-components
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Import component package:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { EntryValidationModule } from '@enigmatry/entry-components/validation';
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Styles import:
|
|
23
|
+
|
|
24
|
+
```css
|
|
25
|
+
@use '@enigmatry/entry-components/styles/generate' as entry;
|
|
26
|
+
|
|
27
|
+
@include entry.generate(APP_THEME, APP_TYPOGRAPHY);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Where `APP_THEME` represents application theming configuration, while `APP_TYPOGRAPHY` represents application fonts configuration.
|
|
31
|
+
|
|
32
|
+
## Basic usage
|
|
33
|
+
|
|
34
|
+
Add `entryDisplayControlValidation` & `<entry-form-errors>` elements to the form to support validation error messages:
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<form [formGroup]="form" (ngSubmit)="submitForm()">
|
|
38
|
+
<mat-form-field class="example-form-field">
|
|
39
|
+
<mat-label>First name</mat-label>
|
|
40
|
+
<input matInput type="text" formControlName="firstName">
|
|
41
|
+
<mat-error entryDisplayControlValidation [control]="form.controls.firstName"></mat-error>
|
|
42
|
+
</mat-form-field>
|
|
43
|
+
|
|
44
|
+
<entry-form-errors [form]="form"></entry-form-errors>
|
|
45
|
+
|
|
46
|
+
<button mat-flat-button color="accent" type="submit">Submit</button>
|
|
47
|
+
</form>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
On submit handle _BadRequest (400)_ response using `setServerSideValidationErrors(error, form)` method:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { IValidationProblemDetails, setServerSideValidationErrors } from '@enigmatry/entry-components/validation';
|
|
54
|
+
|
|
55
|
+
// ...
|
|
56
|
+
submitForm() {
|
|
57
|
+
this._apiService.post()
|
|
58
|
+
.subscribe({
|
|
59
|
+
error: (error: IValidationProblemDetails) => setServerSideValidationErrors(error, this.form)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
Optionally, when using Reactive form, client side validation messages can be configured on module level:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
// ...
|
|
70
|
+
import { AbstractControl } from '@angular/forms';
|
|
71
|
+
import { EntryValidationModule, provideEntryValidationConfig } from '@enigmatry/entry-components/validation';
|
|
72
|
+
|
|
73
|
+
@NgModule({
|
|
74
|
+
imports: [
|
|
75
|
+
// ...
|
|
76
|
+
EntryValidationModule
|
|
77
|
+
]
|
|
78
|
+
providers: [
|
|
79
|
+
provideEntryValidationConfig({
|
|
80
|
+
validationMessages: [
|
|
81
|
+
{ name: 'required', message: 'This field is mandatory!' },
|
|
82
|
+
{ name: 'minlength', message: (control: AbstractControl) => `Minimal length is ${control.errors.minlength.requiredLength}!` }
|
|
83
|
+
]
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
})
|
|
87
|
+
export class AppModule { }
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Microsoft WEB.API & NSwag configuration
|
|
91
|
+
|
|
92
|
+
To configure REST API (_Microsoft WEB.API_) to return _Bad Request_ responses in uniform format, decorate all end-points that trigger validation with `ProducesResponseType` attribute that maps [ValidationProblemDetails](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.validationproblemdetails?view=aspnetcore-7.0) to _Bad Request_ responses:
|
|
93
|
+
|
|
94
|
+
```csharp
|
|
95
|
+
using Microsoft.AspNetCore.Mvc;
|
|
96
|
+
|
|
97
|
+
// ...
|
|
98
|
+
|
|
99
|
+
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
|
100
|
+
public async Task<ActionResult<Response>> Post([FromBody] Command command)
|
|
101
|
+
{
|
|
102
|
+
// ...
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
When set like this, generated ([NSwag](https://github.com/RicoSuter/NSwag)) client side models for _Bad Request_ responses can be used as input parameter of `setServerSideValidationErrors(error, form)` method.
|
|
107
|
+
|
|
108
|
+
This is because `IValidationProblemDetails` interface is based on [ValidationProblemDetails](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.validationproblemdetails?view=aspnetcore-7.0) class.
|