ngx-vest-forms 2.2.0 → 2.3.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 +46 -16
- package/fesm2022/ngx-vest-forms.mjs +92 -33
- package/fesm2022/ngx-vest-forms.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ngx-vest-forms.d.ts +61 -17
package/package.json
CHANGED
|
@@ -92,8 +92,23 @@ declare class FormControlStateDirective {
|
|
|
92
92
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<FormControlStateDirective, "[formControlState], [ngxControlState]", ["formControlState", "ngxControlState"], {}, {}, ["contentNgModel", "contentNgModelGroup"], never, true, never>;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Error display modes for form controls.
|
|
97
|
+
* - 'on-blur': Show errors after field is touched/blurred
|
|
98
|
+
* - 'on-submit': Show errors after form submission
|
|
99
|
+
* - 'on-blur-or-submit': Show errors after blur or form submission (default)
|
|
100
|
+
* - 'on-dirty': Show errors as soon as the field value changes
|
|
101
|
+
* - 'always': Show errors immediately, even on pristine fields
|
|
102
|
+
*/
|
|
103
|
+
type ScErrorDisplayMode = 'on-blur' | 'on-submit' | 'on-blur-or-submit' | 'on-dirty' | 'always';
|
|
104
|
+
/**
|
|
105
|
+
* Warning display modes for form controls.
|
|
106
|
+
* - 'on-touch': Show warnings after field is touched/blurred
|
|
107
|
+
* - 'on-validated-or-touch': Show warnings after validation runs or field is touched (default)
|
|
108
|
+
* - 'on-dirty': Show warnings as soon as the field value changes
|
|
109
|
+
* - 'always': Show warnings immediately, even on pristine fields
|
|
110
|
+
*/
|
|
111
|
+
type NgxWarningDisplayMode = 'on-touch' | 'on-validated-or-touch' | 'on-dirty' | 'always';
|
|
97
112
|
declare class FormErrorDisplayDirective {
|
|
98
113
|
#private;
|
|
99
114
|
/**
|
|
@@ -159,6 +174,19 @@ declare class FormErrorDisplayDirective {
|
|
|
159
174
|
* Excludes pristine+untouched controls to prevent "Validating..." on initial load
|
|
160
175
|
*/
|
|
161
176
|
readonly isPending: Signal<boolean>;
|
|
177
|
+
/**
|
|
178
|
+
* Determines if warnings should be shown based on the specified display mode
|
|
179
|
+
* and the control's state (touched/validated/dirty).
|
|
180
|
+
*
|
|
181
|
+
* NOTE: Unlike errors, warnings can exist on VALID fields (warnings-only scenario).
|
|
182
|
+
* We don't require isInvalid() because Vest warn() tests don't affect field validity.
|
|
183
|
+
*
|
|
184
|
+
* UX Note: We include `hasBeenValidated` for `on-validated-or-touch` mode to support
|
|
185
|
+
* cross-field validation. If Field A triggers validation on Field B (via validationConfig),
|
|
186
|
+
* Field B should show warnings if it has them, even if the user hasn't touched Field B yet.
|
|
187
|
+
* Unlike errors (which block submission), warnings are informational and safe to show.
|
|
188
|
+
*/
|
|
189
|
+
readonly shouldShowWarnings: Signal<boolean>;
|
|
162
190
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormErrorDisplayDirective, never>;
|
|
163
191
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<FormErrorDisplayDirective, "[formErrorDisplay], [ngxErrorDisplay]", ["formErrorDisplay", "ngxErrorDisplay"], { "errorDisplayMode": { "alias": "errorDisplayMode"; "required": false; "isSignal": true; }; "warningDisplayMode": { "alias": "warningDisplayMode"; "required": false; "isSignal": true; }; }, {}, never, never, true, [{ directive: typeof FormControlStateDirective; inputs: {}; outputs: {}; }]>;
|
|
164
192
|
}
|
|
@@ -184,6 +212,8 @@ declare class FormErrorDisplayDirective {
|
|
|
184
212
|
* - `'on-blur-or-submit'` (default): Show errors after blur OR form submit
|
|
185
213
|
* - `'on-blur'`: Show errors only after blur
|
|
186
214
|
* - `'on-submit'`: Show errors only after form submit
|
|
215
|
+
* - `'on-dirty'`: Show errors as soon as the field value changes
|
|
216
|
+
* - `'always'`: Show errors immediately, even on pristine fields
|
|
187
217
|
*
|
|
188
218
|
* ```html
|
|
189
219
|
* <ngx-control-wrapper [errorDisplayMode]="'on-submit'">
|
|
@@ -191,6 +221,19 @@ declare class FormErrorDisplayDirective {
|
|
|
191
221
|
* </ngx-control-wrapper>
|
|
192
222
|
* ```
|
|
193
223
|
*
|
|
224
|
+
* ### Warning Display Modes
|
|
225
|
+
* Control when warnings appear using the `warningDisplayMode` input:
|
|
226
|
+
* - `'on-validated-or-touch'` (default): Show warnings after validation runs or touch
|
|
227
|
+
* - `'on-touch'`: Show warnings only after touch/blur
|
|
228
|
+
* - `'on-dirty'`: Show warnings as soon as the field value changes
|
|
229
|
+
* - `'always'`: Show warnings immediately, even on pristine fields
|
|
230
|
+
*
|
|
231
|
+
* ```html
|
|
232
|
+
* <ngx-control-wrapper [warningDisplayMode]="'on-dirty'">
|
|
233
|
+
* <input name="email" [ngModel]="formValue().email" />
|
|
234
|
+
* </ngx-control-wrapper>
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
194
237
|
* ### Accessibility Features (Automatic)
|
|
195
238
|
* - Unique IDs for error/warning/pending regions
|
|
196
239
|
* - `aria-describedby` linking errors to form controls
|
|
@@ -223,9 +266,9 @@ declare class FormErrorDisplayDirective {
|
|
|
223
266
|
*
|
|
224
267
|
* Error & Warning Display Behavior:
|
|
225
268
|
* - The error display mode can be configured globally using the NGX_ERROR_DISPLAY_MODE_TOKEN injection token, or per instance using the `errorDisplayMode` input on FormErrorDisplayDirective (which this component uses as a hostDirective).
|
|
226
|
-
* - Possible values: 'on-blur' | 'on-submit' | 'on-blur-or-submit' (default: 'on-blur-or-submit')
|
|
269
|
+
* - Possible error display values: 'on-blur' | 'on-submit' | 'on-blur-or-submit' | 'on-dirty' | 'always' (default: 'on-blur-or-submit')
|
|
227
270
|
* - The warning display mode can be configured globally using NGX_WARNING_DISPLAY_MODE_TOKEN, or per instance using the `warningDisplayMode` input on FormErrorDisplayDirective.
|
|
228
|
-
* - Possible values: 'on-touch' | 'on-validated-or-touch' (default: 'on-validated-or-touch')
|
|
271
|
+
* - Possible warning display values: 'on-touch' | 'on-validated-or-touch' | 'on-dirty' | 'always' (default: 'on-validated-or-touch')
|
|
229
272
|
*
|
|
230
273
|
* Example (per instance):
|
|
231
274
|
* <div ngxControlWrapper>
|
|
@@ -296,18 +339,10 @@ declare class ControlWrapperComponent implements AfterContentInit, OnDestroy {
|
|
|
296
339
|
protected readonly showPendingMessage: _angular_core.Signal<boolean>;
|
|
297
340
|
/**
|
|
298
341
|
* Whether to display warnings.
|
|
299
|
-
*
|
|
300
|
-
* 1. The field has been touched (user has interacted with it)
|
|
301
|
-
* 2. The field has warnings to display
|
|
302
|
-
* 3. The field is not currently pending validation
|
|
303
|
-
*
|
|
304
|
-
* NOTE: Unlike errors, warnings can exist on VALID fields (warnings-only scenario).
|
|
305
|
-
* We don't require isInvalid() because Vest warn() tests don't affect field validity.
|
|
342
|
+
* Delegates to FormErrorDisplayDirective's centralized shouldShowWarnings signal.
|
|
306
343
|
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* show warnings if it has them, even if the user hasn't touched Field B yet.
|
|
310
|
-
* Unlike errors (which block submission), warnings are informational and safe to safe to show.
|
|
344
|
+
* This ensures consistent warning display behavior across all form components
|
|
345
|
+
* and supports the new 'on-dirty' and 'always' display modes.
|
|
311
346
|
*/
|
|
312
347
|
protected readonly shouldShowWarnings: _angular_core.Signal<boolean>;
|
|
313
348
|
/**
|
|
@@ -2374,12 +2409,21 @@ declare function fastDeepEqual(obj1: unknown, obj2: unknown, maxDepth?: number):
|
|
|
2374
2409
|
declare const SC_ERROR_DISPLAY_MODE_TOKEN: InjectionToken<ScErrorDisplayMode>;
|
|
2375
2410
|
/**
|
|
2376
2411
|
* Injection token for configuring the default error display mode.
|
|
2377
|
-
* Values:
|
|
2412
|
+
* Values:
|
|
2413
|
+
* - 'on-blur': Show errors after field is touched/blurred
|
|
2414
|
+
* - 'on-submit': Show errors after form submission
|
|
2415
|
+
* - 'on-blur-or-submit': Show errors after blur or form submission (default)
|
|
2416
|
+
* - 'on-dirty': Show errors as soon as the field value changes
|
|
2417
|
+
* - 'always': Show errors immediately, even on pristine fields
|
|
2378
2418
|
*/
|
|
2379
2419
|
declare const NGX_ERROR_DISPLAY_MODE_TOKEN: InjectionToken<ScErrorDisplayMode>;
|
|
2380
2420
|
/**
|
|
2381
2421
|
* Injection token for configuring the default warning display mode.
|
|
2382
|
-
* Values:
|
|
2422
|
+
* Values:
|
|
2423
|
+
* - 'on-touch': Show warnings after field is touched/blurred
|
|
2424
|
+
* - 'on-validated-or-touch': Show warnings after validation runs or field is touched (default)
|
|
2425
|
+
* - 'on-dirty': Show warnings as soon as the field value changes
|
|
2426
|
+
* - 'always': Show warnings immediately, even on pristine fields
|
|
2383
2427
|
*/
|
|
2384
2428
|
declare const NGX_WARNING_DISPLAY_MODE_TOKEN: InjectionToken<NgxWarningDisplayMode>;
|
|
2385
2429
|
|