ngx-vest-forms 2.4.0 → 2.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-vest-forms",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "license": "MIT",
5
5
  "author": "Brecht Billiet, Arjen Althoff",
6
6
  "description": "Opinionated template-driven forms library for Angular with Vest.js integration",
@@ -192,6 +192,21 @@ declare class FormErrorDisplayDirective {
192
192
  }
193
193
 
194
194
  type AriaAssociationMode = 'all-controls' | 'single-control' | 'none';
195
+ /**
196
+ * Splits an `aria-describedby` attribute value into normalized token IDs.
197
+ */
198
+ declare function parseAriaIdTokens(value: string | null): string[];
199
+ /**
200
+ * Merges currently-active wrapper IDs into an existing `aria-describedby` value.
201
+ *
202
+ * Existing tokens owned by the wrapper are removed first, then current active IDs
203
+ * are appended while preserving non-owned tokens and token uniqueness.
204
+ */
205
+ declare function mergeAriaDescribedBy(existing: string | null, activeIds: readonly string[], ownedIds: readonly string[]): string | null;
206
+ /**
207
+ * Resolves control targets based on ARIA association mode.
208
+ */
209
+ declare function resolveAssociationTargets(controls: readonly HTMLElement[], mode: AriaAssociationMode): HTMLElement[];
195
210
 
196
211
  /**
197
212
  * Accessible form control wrapper built with WCAG 2.2 AA considerations.
@@ -729,6 +744,27 @@ type LeafFieldPath<T, Prefix extends string = '', Depth extends readonly number[
729
744
  [K in keyof T & string]: T[K] extends Primitive ? `${Prefix}${K}` : T[K] extends ReadonlyArray<infer U> ? U extends Primitive ? never : LeafFieldPath<U, `${Prefix}${K}.`, [...Depth, 1]> : LeafFieldPath<T[K], `${Prefix}${K}.`, [...Depth, 1]>;
730
745
  }[keyof T & string];
731
746
 
747
+ type NgxFirstInvalidOptions = {
748
+ /** Scroll animation behavior (default: `'smooth'`, or `'auto'` when reduced motion is preferred). */
749
+ behavior?: ScrollBehavior;
750
+ /** Vertical alignment when scrolling (default: `'center'`). */
751
+ block?: ScrollLogicalPosition;
752
+ /** Horizontal alignment when scrolling (default: `'nearest'`). */
753
+ inline?: ScrollLogicalPosition;
754
+ /** Whether to focus after scrolling (default: `true`). */
755
+ focus?: boolean;
756
+ /** Passed to `focus()` when focusing (default: `true`). */
757
+ preventScrollOnFocus?: boolean;
758
+ /** Opens ancestor `<details>` elements before scroll/focus (default: `true`). */
759
+ openCollapsedParents?: boolean;
760
+ /** Selector used to locate the first invalid element. */
761
+ invalidSelector?: string;
762
+ /** Selector used to resolve the best focus target within the invalid element. */
763
+ focusSelector?: string;
764
+ };
765
+ declare const DEFAULT_INVALID_SELECTOR: string;
766
+ declare const DEFAULT_FOCUS_SELECTOR: string;
767
+
732
768
  /**
733
769
  * Represents the state of a form managed by scVestForm directive.
734
770
  * This is the structure returned by NgxVestFormDirective.formState() or similar.
@@ -998,6 +1034,7 @@ type NgxValidationConfig<T = unknown> = Record<string, string[]> | ValidationCon
998
1034
  declare class FormDirective<T extends Record<string, unknown>> {
999
1035
  #private;
1000
1036
  readonly ngForm: NgForm;
1037
+ private readonly elementRef;
1001
1038
  private readonly destroyRef;
1002
1039
  private readonly cdr;
1003
1040
  private readonly configDebounceTime;
@@ -1060,6 +1097,11 @@ declare class FormDirective<T extends Record<string, unknown>> {
1060
1097
  * @param v
1061
1098
  */
1062
1099
  readonly validationConfig: InputSignal<NgxValidationConfig<T>>;
1100
+ /**
1101
+ * Emits whenever validation feedback may have changed, even if the aggregate
1102
+ * root form status string stays the same.
1103
+ */
1104
+ private readonly validationFeedback$;
1063
1105
  private readonly pending$;
1064
1106
  /**
1065
1107
  * Emits every time the form status changes in a state
@@ -1209,6 +1251,23 @@ declare class FormDirective<T extends Record<string, unknown>> {
1209
1251
  * ```
1210
1252
  */
1211
1253
  markAllAsTouched(): void;
1254
+ /**
1255
+ * Finds the first invalid element in this form, scrolls it into view, and focuses it.
1256
+ *
1257
+ * Useful in custom submit flows where `markAllAsTouched()` is triggered externally
1258
+ * and the app then wants to guide keyboard and assistive-technology users to the
1259
+ * first failing field.
1260
+ *
1261
+ * @returns The focused element when a focusable target exists, otherwise the first
1262
+ * matched invalid element. Returns `null` when no invalid element is found.
1263
+ */
1264
+ focusFirstInvalidControl(options?: NgxFirstInvalidOptions): HTMLElement | null;
1265
+ /**
1266
+ * Finds and scrolls the first invalid element into view without moving focus.
1267
+ *
1268
+ * @returns The resolved element, or `null` when no invalid element is found.
1269
+ */
1270
+ scrollToFirstInvalidControl(options?: NgxFirstInvalidOptions): HTMLElement | null;
1212
1271
  /**
1213
1272
  * Host handler: called whenever any descendant field loses focus.
1214
1273
  * Used to make touched-path tracking react immediately on blur/tab.
@@ -2506,5 +2565,5 @@ declare const NGX_WARNING_DISPLAY_MODE_TOKEN: InjectionToken<NgxWarningDisplayMo
2506
2565
  */
2507
2566
  declare const NGX_VALIDATION_CONFIG_DEBOUNCE_TOKEN: InjectionToken<number>;
2508
2567
 
2509
- export { ControlWrapperComponent, FormControlStateDirective, FormDirective, FormErrorControlDirective, FormErrorDisplayDirective, FormGroupWrapperComponent, FormModelDirective, FormModelGroupDirective, NGX_ERROR_DISPLAY_MODE_TOKEN, NGX_VALIDATION_CONFIG_DEBOUNCE_TOKEN, NGX_WARNING_DISPLAY_MODE_TOKEN, NgxVestForms, ROOT_FORM, ROOT_FORM as ROOT_FORM_CONSTANT, SC_ERROR_DISPLAY_MODE_TOKEN, ValidateRootFormDirective, ValidationConfigBuilder, arrayToObject, clearFields, clearFieldsWhen, cloneDeep, createDebouncedPendingState, createEmptyFormState, createValidationConfig, deepArrayToObject, fastDeepEqual, getAllFormErrors, getFormControlField, getFormGroupField, keepFieldsWhen, mergeValuesAndRawValues, objectToArray, parseFieldPath, set, setValueAtPath, shallowEqual, stringifyFieldPath, validateShape, vestForms, vestFormsViewProviders };
2510
- export type { DebouncedPendingStateOptions, DebouncedPendingStateResult, DeepPartial, DeepRequired, FieldPath, FieldPathValue, FormCompatibleDeepRequired, FormFieldName, LeafFieldPath, NgxDeepPartial, NgxDeepRequired, NgxFieldKey, NgxFormCompatibleDeepRequired, NgxFormState, NgxTypedVestSuite, NgxValidationConfig, NgxVestSuite, NgxWarningDisplayMode, ScErrorDisplayMode, ValidateFieldPath, ValidationConfigMap, ValidationOptions };
2568
+ export { ControlWrapperComponent, DEFAULT_FOCUS_SELECTOR, DEFAULT_INVALID_SELECTOR, FormControlStateDirective, FormDirective, FormErrorControlDirective, FormErrorDisplayDirective, FormGroupWrapperComponent, FormModelDirective, FormModelGroupDirective, NGX_ERROR_DISPLAY_MODE_TOKEN, NGX_VALIDATION_CONFIG_DEBOUNCE_TOKEN, NGX_WARNING_DISPLAY_MODE_TOKEN, NgxVestForms, ROOT_FORM, ROOT_FORM as ROOT_FORM_CONSTANT, SC_ERROR_DISPLAY_MODE_TOKEN, ValidateRootFormDirective, ValidationConfigBuilder, arrayToObject, clearFields, clearFieldsWhen, cloneDeep, createDebouncedPendingState, createEmptyFormState, createValidationConfig, deepArrayToObject, fastDeepEqual, getAllFormErrors, getFormControlField, getFormGroupField, keepFieldsWhen, mergeAriaDescribedBy, mergeValuesAndRawValues, objectToArray, parseAriaIdTokens, parseFieldPath, resolveAssociationTargets, set, setValueAtPath, shallowEqual, stringifyFieldPath, validateShape, vestForms, vestFormsViewProviders };
2569
+ export type { AriaAssociationMode, DebouncedPendingStateOptions, DebouncedPendingStateResult, DeepPartial, DeepRequired, FieldPath, FieldPathValue, FormCompatibleDeepRequired, FormFieldName, LeafFieldPath, NgxDeepPartial, NgxDeepRequired, NgxFieldKey, NgxFirstInvalidOptions, NgxFormCompatibleDeepRequired, NgxFormState, NgxTypedVestSuite, NgxValidationConfig, NgxVestSuite, NgxWarningDisplayMode, ScErrorDisplayMode, ValidateFieldPath, ValidationConfigMap, ValidationOptions };