@ng-forge/dynamic-forms 1.2.0-next.5 → 1.2.0-next.6
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/fesm2022/{ng-forge-dynamic-forms-array-field.component-D-VWBM-t.mjs → ng-forge-dynamic-forms-array-field.component-NTHLPjau.mjs} +2 -2
- package/fesm2022/{ng-forge-dynamic-forms-array-field.component-D-VWBM-t.mjs.map → ng-forge-dynamic-forms-array-field.component-NTHLPjau.mjs.map} +1 -1
- package/fesm2022/{ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-OBDy6qd9.mjs → ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-CNCeWAeJ.mjs} +2 -2
- package/fesm2022/{ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-OBDy6qd9.mjs.map → ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-CNCeWAeJ.mjs.map} +1 -1
- package/fesm2022/{ng-forge-dynamic-forms-container-field.component-BpeFyhAt.mjs → ng-forge-dynamic-forms-container-field.component-ByGdzAsk.mjs} +5 -4
- package/fesm2022/ng-forge-dynamic-forms-container-field.component-ByGdzAsk.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-field-errors-wrapper.component-ZdaC4Bit.mjs +25 -0
- package/fesm2022/ng-forge-dynamic-forms-field-errors-wrapper.component-ZdaC4Bit.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-group-field.component-BNjYMTqT.mjs → ng-forge-dynamic-forms-group-field.component-DnLZdj8v.mjs} +2 -2
- package/fesm2022/{ng-forge-dynamic-forms-group-field.component-BNjYMTqT.mjs.map → ng-forge-dynamic-forms-group-field.component-DnLZdj8v.mjs.map} +1 -1
- package/fesm2022/ng-forge-dynamic-forms-integration.mjs +10 -72
- package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -1
- package/fesm2022/ng-forge-dynamic-forms-internal.mjs +221 -91
- package/fesm2022/ng-forge-dynamic-forms-internal.mjs.map +1 -1
- package/fesm2022/{ng-forge-dynamic-forms-ng-forge-dynamic-forms-DSXZJHcu.mjs → ng-forge-dynamic-forms-ng-forge-dynamic-forms-B2C_WAMP.mjs} +91 -34
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-B2C_WAMP.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-page-field.component-B92kLZkH.mjs → ng-forge-dynamic-forms-page-field.component-CwH22lRl.mjs} +2 -2
- package/fesm2022/{ng-forge-dynamic-forms-page-field.component-B92kLZkH.mjs.map → ng-forge-dynamic-forms-page-field.component-CwH22lRl.mjs.map} +1 -1
- package/fesm2022/ng-forge-dynamic-forms.mjs +2 -2
- package/package.json +2 -2
- package/types/ng-forge-dynamic-forms-integration.d.ts +7 -31
- package/types/ng-forge-dynamic-forms-internal.d.ts +420 -218
- package/types/ng-forge-dynamic-forms.d.ts +1 -1
- package/fesm2022/ng-forge-dynamic-forms-container-field.component-BpeFyhAt.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-DSXZJHcu.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _ng_forge_dynamic_forms_internal from '@ng-forge/dynamic-forms/internal';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Signal, Type, ResourceRef, ViewContainerRef, InjectionToken, WritableSignal, Injector, TemplateRef, PipeTransform, Resource } from '@angular/core';
|
|
3
|
+
import { Signal, Type, ResourceRef, ViewContainerRef, InjectionToken, WritableSignal, Injector, TemplateRef, PipeTransform, Resource, Provider } from '@angular/core';
|
|
4
4
|
import { Observable, OperatorFunction } from 'rxjs';
|
|
5
|
-
import { FieldContext,
|
|
5
|
+
import { FieldContext, ValidationError as ValidationError$1, TreeValidationResult, FieldTree, ReadonlyFieldState, LogicFn, SchemaPath, SchemaPathTree } from '@angular/forms/signals';
|
|
6
6
|
import { FormSchema } from '@ng-forge/dynamic-forms/schema';
|
|
7
7
|
|
|
8
8
|
type DynamicText = string | Observable<string> | Signal<string>;
|
|
@@ -480,12 +480,242 @@ interface RowField<TFields extends readonly RowAllowedChildren[] = readonly RowA
|
|
|
480
480
|
declare function isRowField(field: FieldDef<any>): field is RowField;
|
|
481
481
|
type RowComponent = FieldComponent<RowField<RowAllowedChildren[]>>;
|
|
482
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Custom validator function signature using Angular's public FieldContext API
|
|
485
|
+
*
|
|
486
|
+
* @template TValue The type of value stored in the field being validated
|
|
487
|
+
*/
|
|
488
|
+
type CustomValidator<TValue = unknown> = (ctx: FieldContext<TValue>, params?: Record<string, unknown>) => ValidationError$1 | ValidationError$1[] | null;
|
|
489
|
+
/**
|
|
490
|
+
* Async custom validator configuration using Angular's resource-based API
|
|
491
|
+
*
|
|
492
|
+
* @template TValue The type of value stored in the field being validated
|
|
493
|
+
* @template TParams The type of params passed to the resource
|
|
494
|
+
* @template TResult The type of result returned by the resource
|
|
495
|
+
*/
|
|
496
|
+
interface AsyncCustomValidator<TValue = unknown, TParams = unknown, TResult = unknown> {
|
|
497
|
+
/**
|
|
498
|
+
* Function that receives field context and returns resource params.
|
|
499
|
+
* Params will be tracked as a signal and trigger resource reload when changed.
|
|
500
|
+
*/
|
|
501
|
+
readonly params: (ctx: FieldContext<TValue>, config?: Record<string, unknown>) => TParams;
|
|
502
|
+
/**
|
|
503
|
+
* Function that creates a ResourceRef from the params signal.
|
|
504
|
+
* The resource will be automatically managed by Angular's lifecycle.
|
|
505
|
+
*/
|
|
506
|
+
readonly factory: (params: Signal<TParams | undefined>) => ResourceRef<TResult | undefined>;
|
|
507
|
+
/**
|
|
508
|
+
* Optional function to map successful resource result to validation errors.
|
|
509
|
+
* Return null if validation passes, or ValidationError/ValidationError[] if validation fails.
|
|
510
|
+
*/
|
|
511
|
+
readonly onSuccess?: (result: TResult, ctx: FieldContext<TValue>) => TreeValidationResult;
|
|
512
|
+
/**
|
|
513
|
+
* Optional error handler for resource errors (network failures, etc.).
|
|
514
|
+
* Return null to ignore the error, or ValidationError to display it to the user.
|
|
515
|
+
*/
|
|
516
|
+
readonly onError?: (error: unknown, ctx: FieldContext<TValue>) => ValidationError$1 | ValidationError$1[] | null;
|
|
517
|
+
}
|
|
518
|
+
/** HTTP request configuration for validateHttp API */
|
|
519
|
+
interface HttpResourceRequest {
|
|
520
|
+
url: string;
|
|
521
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
522
|
+
body?: unknown;
|
|
523
|
+
headers?: Record<string, string | string[]>;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* HTTP-based validator configuration for Angular's validateHttp API
|
|
527
|
+
*
|
|
528
|
+
* @template TValue The type of value stored in the field being validated
|
|
529
|
+
* @template TResult The type of HTTP response
|
|
530
|
+
*/
|
|
531
|
+
interface HttpCustomValidator<TValue = unknown, TResult = unknown> {
|
|
532
|
+
/**
|
|
533
|
+
* Function that returns the HTTP request configuration.
|
|
534
|
+
* Can return:
|
|
535
|
+
* - `undefined` to skip validation (e.g., if field is empty)
|
|
536
|
+
* - `string` for simple GET requests (just the URL)
|
|
537
|
+
* - `HttpResourceRequest` for full control (method, body, headers)
|
|
538
|
+
*/
|
|
539
|
+
readonly request: (ctx: FieldContext<TValue>, config?: Record<string, unknown>) => string | HttpResourceRequest | undefined;
|
|
540
|
+
/** REQUIRED function to map successful HTTP response to validation errors. */
|
|
541
|
+
readonly onSuccess: (result: TResult, ctx: FieldContext<TValue>) => TreeValidationResult;
|
|
542
|
+
/**
|
|
543
|
+
* Optional error handler for HTTP errors (network failures, 4xx/5xx status codes).
|
|
544
|
+
* Return null to ignore the error, or ValidationError to display it to the user.
|
|
545
|
+
*/
|
|
546
|
+
readonly onError?: (error: unknown, ctx: FieldContext<TValue>) => ValidationError$1 | ValidationError$1[] | null;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** Mapping configuration for interpreting HTTP responses as validation results. */
|
|
550
|
+
interface HttpValidationResponseMapping {
|
|
551
|
+
/** Expression evaluated with scope `{ response }`. Must evaluate to `true` (strict boolean) to be valid. */
|
|
552
|
+
validWhen: string;
|
|
553
|
+
/** Error kind returned when validation fails — maps to field-level `validationMessages` */
|
|
554
|
+
errorKind: string;
|
|
555
|
+
/**
|
|
556
|
+
* Parameters to include in the validation error for message interpolation.
|
|
557
|
+
* Map of parameter names to expressions evaluated against `{ response }`.
|
|
558
|
+
*/
|
|
559
|
+
errorParams?: Record<string, string>;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/** Base configuration shared by all validators */
|
|
563
|
+
interface BaseValidatorConfig {
|
|
564
|
+
/** Conditional logic for when validator applies */
|
|
565
|
+
when?: ConditionalExpression;
|
|
566
|
+
}
|
|
567
|
+
/** Built-in validator configuration (required, email, min, max, etc.) */
|
|
568
|
+
interface BuiltInValidatorConfig extends BaseValidatorConfig {
|
|
569
|
+
/** Validator type identifier */
|
|
570
|
+
type: 'required' | 'email' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern';
|
|
571
|
+
/** Static value for the validator (e.g., min value, pattern) */
|
|
572
|
+
value?: number | string | RegExp;
|
|
573
|
+
/** Dynamic value expression that evaluates to validator parameter */
|
|
574
|
+
expression?: string;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Custom validator configuration using Angular's public FieldContext API.
|
|
578
|
+
* Returns ValidationError | ValidationError[] | null synchronously.
|
|
579
|
+
*/
|
|
580
|
+
interface CustomValidatorConfig extends BaseValidatorConfig {
|
|
581
|
+
/** Validator type identifier */
|
|
582
|
+
type: 'custom';
|
|
583
|
+
/** Name of registered validator function (function-based pattern) */
|
|
584
|
+
functionName?: string;
|
|
585
|
+
/**
|
|
586
|
+
* Inline custom validator (code-only authoring).
|
|
587
|
+
* Mutually exclusive with `functionName`. NOT JSON-serializable.
|
|
588
|
+
*/
|
|
589
|
+
fn?: CustomValidator;
|
|
590
|
+
/** Optional parameters to pass to validator function */
|
|
591
|
+
params?: Record<string, unknown>;
|
|
592
|
+
/** JavaScript expression to evaluate (expression-based pattern) */
|
|
593
|
+
expression?: string;
|
|
594
|
+
/** Error kind for expression-based validators - links to validationMessages */
|
|
595
|
+
kind?: string;
|
|
596
|
+
/**
|
|
597
|
+
* Parameters to include in error object for message interpolation (expression-based pattern)
|
|
598
|
+
* Map of parameter names to expressions that will be evaluated in the same context as the validation expression
|
|
599
|
+
*/
|
|
600
|
+
errorParams?: Record<string, string>;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Shared fields for both branches of {@link AsyncValidatorConfig}.
|
|
604
|
+
*
|
|
605
|
+
* @internal
|
|
606
|
+
*/
|
|
607
|
+
interface AsyncValidatorConfigShared extends BaseValidatorConfig {
|
|
608
|
+
/** Validator type identifier. */
|
|
609
|
+
type: 'async';
|
|
610
|
+
/** Optional parameters to pass to validator function */
|
|
611
|
+
params?: Record<string, unknown>;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Async custom validator configuration using Angular's `validateAsync` API.
|
|
615
|
+
* Returns Observable<ValidationError | ValidationError[] | null>.
|
|
616
|
+
*/
|
|
617
|
+
type AsyncValidatorConfig = (AsyncValidatorConfigShared & {
|
|
618
|
+
/** Name of registered async validator function */
|
|
619
|
+
functionName: string;
|
|
620
|
+
/** Inline form is forbidden when `functionName` is set */
|
|
621
|
+
fn?: never;
|
|
622
|
+
}) | (AsyncValidatorConfigShared & {
|
|
623
|
+
/** Inline async validator. Mutually exclusive with `functionName`. */
|
|
624
|
+
fn: AsyncCustomValidator;
|
|
625
|
+
/** Registered form is forbidden when `fn` is set */
|
|
626
|
+
functionName?: never;
|
|
627
|
+
});
|
|
628
|
+
/**
|
|
629
|
+
* Shared fields for both branches of {@link FunctionHttpValidatorConfig}.
|
|
630
|
+
*
|
|
631
|
+
* @internal
|
|
632
|
+
*/
|
|
633
|
+
interface FunctionHttpValidatorConfigShared extends BaseValidatorConfig {
|
|
634
|
+
/** Validator type identifier. */
|
|
635
|
+
type: 'http';
|
|
636
|
+
/** Optional parameters to pass to HTTP validator */
|
|
637
|
+
params?: Record<string, unknown>;
|
|
638
|
+
}
|
|
639
|
+
/** Function-based HTTP validator configuration. Uses Angular's `validateHttp` API. */
|
|
640
|
+
type FunctionHttpValidatorConfig = (FunctionHttpValidatorConfigShared & {
|
|
641
|
+
/** Name of registered HTTP validator configuration */
|
|
642
|
+
functionName: string;
|
|
643
|
+
/** Inline form is forbidden when `functionName` is set */
|
|
644
|
+
fn?: never;
|
|
645
|
+
}) | (FunctionHttpValidatorConfigShared & {
|
|
646
|
+
/** Inline HTTP validator. Mutually exclusive with `functionName`. */
|
|
647
|
+
fn: HttpCustomValidator;
|
|
648
|
+
/** Registered form is forbidden when `fn` is set */
|
|
649
|
+
functionName?: never;
|
|
650
|
+
});
|
|
651
|
+
/** Declarative HTTP validator configuration — fully JSON-serializable, no function registration required. */
|
|
652
|
+
interface DeclarativeHttpValidatorConfig extends BaseValidatorConfig {
|
|
653
|
+
/** Validator type identifier */
|
|
654
|
+
type: 'http';
|
|
655
|
+
/** HTTP request configuration with expression-based query params and body */
|
|
656
|
+
http: HttpRequestConfig;
|
|
657
|
+
/** Mapping that interprets the HTTP response as a validation result */
|
|
658
|
+
responseMapping: HttpValidationResponseMapping;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Configuration for signal forms validator functions that can be serialized from API.
|
|
662
|
+
* Discriminated union type for type-safe validator configuration.
|
|
663
|
+
*/
|
|
664
|
+
type ValidatorConfig = BuiltInValidatorConfig | CustomValidatorConfig | AsyncValidatorConfig | FunctionHttpValidatorConfig | DeclarativeHttpValidatorConfig;
|
|
665
|
+
/** Type guard to distinguish function-based HTTP validators from declarative ones. */
|
|
666
|
+
declare function isFunctionHttpValidator(config: FunctionHttpValidatorConfig | DeclarativeHttpValidatorConfig): config is FunctionHttpValidatorConfig;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Re-export Angular's ValidationError for consistency
|
|
670
|
+
* This replaces our custom ValidationError interface
|
|
671
|
+
*/
|
|
672
|
+
type ValidationError = ValidationError$1;
|
|
673
|
+
/**
|
|
674
|
+
* Resolves a validation message from the validation error, so error params
|
|
675
|
+
* (e.g. maxLength, min) can be passed to an i18n layer natively.
|
|
676
|
+
*/
|
|
677
|
+
type ValidationMessageResolver = (error: ValidationError) => DynamicText;
|
|
678
|
+
/** A validation message: static or reactive text, or a function of the validation error. */
|
|
679
|
+
type ValidationMessage = DynamicText | ValidationMessageResolver;
|
|
680
|
+
interface ValidationMessages {
|
|
681
|
+
required?: ValidationMessage;
|
|
682
|
+
email?: ValidationMessage;
|
|
683
|
+
min?: ValidationMessage;
|
|
684
|
+
max?: ValidationMessage;
|
|
685
|
+
minLength?: ValidationMessage;
|
|
686
|
+
maxLength?: ValidationMessage;
|
|
687
|
+
pattern?: ValidationMessage;
|
|
688
|
+
[key: string]: ValidationMessage | undefined;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Tree-level validation for container fields (`group` / `array`).
|
|
693
|
+
*
|
|
694
|
+
* A validator here runs against the container's own subtree: `ctx.value()` is the group's
|
|
695
|
+
* object or the array's item list. Layout containers (`page`, `row`, `container`) flatten
|
|
696
|
+
* into their parent and have no schema path, so they are excluded.
|
|
697
|
+
*/
|
|
698
|
+
interface ContainerValidation {
|
|
699
|
+
/**
|
|
700
|
+
* Marks every descendant required. An inherited default, not a rule on the container —
|
|
701
|
+
* a descendant's own `required` wins, including `false`. Use `minLength` for array size.
|
|
702
|
+
*/
|
|
703
|
+
readonly required?: boolean;
|
|
704
|
+
/** Validators applied to the container's own schema path. Gated by `validateWhenHidden`. */
|
|
705
|
+
readonly validators?: ValidatorConfig[];
|
|
706
|
+
/**
|
|
707
|
+
* Messages keyed by error `kind`. Rendered by the `field-errors` wrapper, attached
|
|
708
|
+
* automatically when the container declares `validators`.
|
|
709
|
+
*/
|
|
710
|
+
readonly validationMessages?: ValidationMessages;
|
|
711
|
+
}
|
|
712
|
+
|
|
483
713
|
/**
|
|
484
714
|
* Group field interface for creating logical field groupings that map to object values
|
|
485
715
|
* Groups create nested form structures where child field values are collected into an object
|
|
486
716
|
* This is a programmatic grouping only - users cannot customize this field type
|
|
487
717
|
*/
|
|
488
|
-
interface GroupField<TFields extends readonly GroupAllowedChildren[] = readonly GroupAllowedChildren[]> extends FieldDef<never
|
|
718
|
+
interface GroupField<TFields extends readonly GroupAllowedChildren[] = readonly GroupAllowedChildren[]> extends FieldDef<never>, ContainerValidation {
|
|
489
719
|
type: 'group';
|
|
490
720
|
readonly fields: TFields;
|
|
491
721
|
/** Groups do not have a label property - they are logical containers only * */
|
|
@@ -573,7 +803,7 @@ type ArrayItemTemplate = readonly ArrayAllowedChildren[];
|
|
|
573
803
|
*/
|
|
574
804
|
type ArrayItemDefinition = ArrayAllowedChildren | ArrayItemTemplate;
|
|
575
805
|
/** Array field interface for creating dynamic field collections that map to array values. */
|
|
576
|
-
interface ArrayField<TFields extends readonly ArrayItemDefinition[] = readonly ArrayItemDefinition[]> extends FieldDef<never
|
|
806
|
+
interface ArrayField<TFields extends readonly ArrayItemDefinition[] = readonly ArrayItemDefinition[]> extends FieldDef<never>, ContainerValidation {
|
|
577
807
|
type: 'array';
|
|
578
808
|
/**
|
|
579
809
|
* Array of item definitions. Each element defines one array item:
|
|
@@ -619,7 +849,7 @@ interface ArrayButtonConfig {
|
|
|
619
849
|
readonly props?: Record<string, unknown>;
|
|
620
850
|
}
|
|
621
851
|
/** Simplified array field interface for common use cases. */
|
|
622
|
-
interface SimplifiedArrayField extends FieldDef<never
|
|
852
|
+
interface SimplifiedArrayField extends FieldDef<never>, ContainerValidation {
|
|
623
853
|
type: 'array';
|
|
624
854
|
/**
|
|
625
855
|
* Template defining the structure of a single array item.
|
|
@@ -887,191 +1117,6 @@ type InferFormValue<T> = ExtractFields<T> extends readonly RegisteredFieldTypes[
|
|
|
887
1117
|
*/
|
|
888
1118
|
type InferFormModel<T, M = InferFormValue<T>> = M extends Record<string, unknown> ? M : Record<string, unknown>;
|
|
889
1119
|
|
|
890
|
-
/**
|
|
891
|
-
* Custom validator function signature using Angular's public FieldContext API
|
|
892
|
-
*
|
|
893
|
-
* @template TValue The type of value stored in the field being validated
|
|
894
|
-
*/
|
|
895
|
-
type CustomValidator<TValue = unknown> = (ctx: FieldContext<TValue>, params?: Record<string, unknown>) => ValidationError$1 | ValidationError$1[] | null;
|
|
896
|
-
/**
|
|
897
|
-
* Async custom validator configuration using Angular's resource-based API
|
|
898
|
-
*
|
|
899
|
-
* @template TValue The type of value stored in the field being validated
|
|
900
|
-
* @template TParams The type of params passed to the resource
|
|
901
|
-
* @template TResult The type of result returned by the resource
|
|
902
|
-
*/
|
|
903
|
-
interface AsyncCustomValidator<TValue = unknown, TParams = unknown, TResult = unknown> {
|
|
904
|
-
/**
|
|
905
|
-
* Function that receives field context and returns resource params.
|
|
906
|
-
* Params will be tracked as a signal and trigger resource reload when changed.
|
|
907
|
-
*/
|
|
908
|
-
readonly params: (ctx: FieldContext<TValue>, config?: Record<string, unknown>) => TParams;
|
|
909
|
-
/**
|
|
910
|
-
* Function that creates a ResourceRef from the params signal.
|
|
911
|
-
* The resource will be automatically managed by Angular's lifecycle.
|
|
912
|
-
*/
|
|
913
|
-
readonly factory: (params: Signal<TParams | undefined>) => ResourceRef<TResult | undefined>;
|
|
914
|
-
/**
|
|
915
|
-
* Optional function to map successful resource result to validation errors.
|
|
916
|
-
* Return null if validation passes, or ValidationError/ValidationError[] if validation fails.
|
|
917
|
-
*/
|
|
918
|
-
readonly onSuccess?: (result: TResult, ctx: FieldContext<TValue>) => TreeValidationResult;
|
|
919
|
-
/**
|
|
920
|
-
* Optional error handler for resource errors (network failures, etc.).
|
|
921
|
-
* Return null to ignore the error, or ValidationError to display it to the user.
|
|
922
|
-
*/
|
|
923
|
-
readonly onError?: (error: unknown, ctx: FieldContext<TValue>) => ValidationError$1 | ValidationError$1[] | null;
|
|
924
|
-
}
|
|
925
|
-
/** HTTP request configuration for validateHttp API */
|
|
926
|
-
interface HttpResourceRequest {
|
|
927
|
-
url: string;
|
|
928
|
-
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
929
|
-
body?: unknown;
|
|
930
|
-
headers?: Record<string, string | string[]>;
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* HTTP-based validator configuration for Angular's validateHttp API
|
|
934
|
-
*
|
|
935
|
-
* @template TValue The type of value stored in the field being validated
|
|
936
|
-
* @template TResult The type of HTTP response
|
|
937
|
-
*/
|
|
938
|
-
interface HttpCustomValidator<TValue = unknown, TResult = unknown> {
|
|
939
|
-
/**
|
|
940
|
-
* Function that returns the HTTP request configuration.
|
|
941
|
-
* Can return:
|
|
942
|
-
* - `undefined` to skip validation (e.g., if field is empty)
|
|
943
|
-
* - `string` for simple GET requests (just the URL)
|
|
944
|
-
* - `HttpResourceRequest` for full control (method, body, headers)
|
|
945
|
-
*/
|
|
946
|
-
readonly request: (ctx: FieldContext<TValue>, config?: Record<string, unknown>) => string | HttpResourceRequest | undefined;
|
|
947
|
-
/** REQUIRED function to map successful HTTP response to validation errors. */
|
|
948
|
-
readonly onSuccess: (result: TResult, ctx: FieldContext<TValue>) => TreeValidationResult;
|
|
949
|
-
/**
|
|
950
|
-
* Optional error handler for HTTP errors (network failures, 4xx/5xx status codes).
|
|
951
|
-
* Return null to ignore the error, or ValidationError to display it to the user.
|
|
952
|
-
*/
|
|
953
|
-
readonly onError?: (error: unknown, ctx: FieldContext<TValue>) => ValidationError$1 | ValidationError$1[] | null;
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
/** Mapping configuration for interpreting HTTP responses as validation results. */
|
|
957
|
-
interface HttpValidationResponseMapping {
|
|
958
|
-
/** Expression evaluated with scope `{ response }`. Must evaluate to `true` (strict boolean) to be valid. */
|
|
959
|
-
validWhen: string;
|
|
960
|
-
/** Error kind returned when validation fails — maps to field-level `validationMessages` */
|
|
961
|
-
errorKind: string;
|
|
962
|
-
/**
|
|
963
|
-
* Parameters to include in the validation error for message interpolation.
|
|
964
|
-
* Map of parameter names to expressions evaluated against `{ response }`.
|
|
965
|
-
*/
|
|
966
|
-
errorParams?: Record<string, string>;
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
/** Base configuration shared by all validators */
|
|
970
|
-
interface BaseValidatorConfig {
|
|
971
|
-
/** Conditional logic for when validator applies */
|
|
972
|
-
when?: ConditionalExpression;
|
|
973
|
-
}
|
|
974
|
-
/** Built-in validator configuration (required, email, min, max, etc.) */
|
|
975
|
-
interface BuiltInValidatorConfig extends BaseValidatorConfig {
|
|
976
|
-
/** Validator type identifier */
|
|
977
|
-
type: 'required' | 'email' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern';
|
|
978
|
-
/** Static value for the validator (e.g., min value, pattern) */
|
|
979
|
-
value?: number | string | RegExp;
|
|
980
|
-
/** Dynamic value expression that evaluates to validator parameter */
|
|
981
|
-
expression?: string;
|
|
982
|
-
}
|
|
983
|
-
/**
|
|
984
|
-
* Custom validator configuration using Angular's public FieldContext API.
|
|
985
|
-
* Returns ValidationError | ValidationError[] | null synchronously.
|
|
986
|
-
*/
|
|
987
|
-
interface CustomValidatorConfig extends BaseValidatorConfig {
|
|
988
|
-
/** Validator type identifier */
|
|
989
|
-
type: 'custom';
|
|
990
|
-
/** Name of registered validator function (function-based pattern) */
|
|
991
|
-
functionName?: string;
|
|
992
|
-
/**
|
|
993
|
-
* Inline custom validator (code-only authoring).
|
|
994
|
-
* Mutually exclusive with `functionName`. NOT JSON-serializable.
|
|
995
|
-
*/
|
|
996
|
-
fn?: CustomValidator;
|
|
997
|
-
/** Optional parameters to pass to validator function */
|
|
998
|
-
params?: Record<string, unknown>;
|
|
999
|
-
/** JavaScript expression to evaluate (expression-based pattern) */
|
|
1000
|
-
expression?: string;
|
|
1001
|
-
/** Error kind for expression-based validators - links to validationMessages */
|
|
1002
|
-
kind?: string;
|
|
1003
|
-
/**
|
|
1004
|
-
* Parameters to include in error object for message interpolation (expression-based pattern)
|
|
1005
|
-
* Map of parameter names to expressions that will be evaluated in the same context as the validation expression
|
|
1006
|
-
*/
|
|
1007
|
-
errorParams?: Record<string, string>;
|
|
1008
|
-
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Shared fields for both branches of {@link AsyncValidatorConfig}.
|
|
1011
|
-
*
|
|
1012
|
-
* @internal
|
|
1013
|
-
*/
|
|
1014
|
-
interface AsyncValidatorConfigShared extends BaseValidatorConfig {
|
|
1015
|
-
/** Validator type identifier. */
|
|
1016
|
-
type: 'async';
|
|
1017
|
-
/** Optional parameters to pass to validator function */
|
|
1018
|
-
params?: Record<string, unknown>;
|
|
1019
|
-
}
|
|
1020
|
-
/**
|
|
1021
|
-
* Async custom validator configuration using Angular's `validateAsync` API.
|
|
1022
|
-
* Returns Observable<ValidationError | ValidationError[] | null>.
|
|
1023
|
-
*/
|
|
1024
|
-
type AsyncValidatorConfig = (AsyncValidatorConfigShared & {
|
|
1025
|
-
/** Name of registered async validator function */
|
|
1026
|
-
functionName: string;
|
|
1027
|
-
/** Inline form is forbidden when `functionName` is set */
|
|
1028
|
-
fn?: never;
|
|
1029
|
-
}) | (AsyncValidatorConfigShared & {
|
|
1030
|
-
/** Inline async validator. Mutually exclusive with `functionName`. */
|
|
1031
|
-
fn: AsyncCustomValidator;
|
|
1032
|
-
/** Registered form is forbidden when `fn` is set */
|
|
1033
|
-
functionName?: never;
|
|
1034
|
-
});
|
|
1035
|
-
/**
|
|
1036
|
-
* Shared fields for both branches of {@link FunctionHttpValidatorConfig}.
|
|
1037
|
-
*
|
|
1038
|
-
* @internal
|
|
1039
|
-
*/
|
|
1040
|
-
interface FunctionHttpValidatorConfigShared extends BaseValidatorConfig {
|
|
1041
|
-
/** Validator type identifier. */
|
|
1042
|
-
type: 'http';
|
|
1043
|
-
/** Optional parameters to pass to HTTP validator */
|
|
1044
|
-
params?: Record<string, unknown>;
|
|
1045
|
-
}
|
|
1046
|
-
/** Function-based HTTP validator configuration. Uses Angular's `validateHttp` API. */
|
|
1047
|
-
type FunctionHttpValidatorConfig = (FunctionHttpValidatorConfigShared & {
|
|
1048
|
-
/** Name of registered HTTP validator configuration */
|
|
1049
|
-
functionName: string;
|
|
1050
|
-
/** Inline form is forbidden when `functionName` is set */
|
|
1051
|
-
fn?: never;
|
|
1052
|
-
}) | (FunctionHttpValidatorConfigShared & {
|
|
1053
|
-
/** Inline HTTP validator. Mutually exclusive with `functionName`. */
|
|
1054
|
-
fn: HttpCustomValidator;
|
|
1055
|
-
/** Registered form is forbidden when `fn` is set */
|
|
1056
|
-
functionName?: never;
|
|
1057
|
-
});
|
|
1058
|
-
/** Declarative HTTP validator configuration — fully JSON-serializable, no function registration required. */
|
|
1059
|
-
interface DeclarativeHttpValidatorConfig extends BaseValidatorConfig {
|
|
1060
|
-
/** Validator type identifier */
|
|
1061
|
-
type: 'http';
|
|
1062
|
-
/** HTTP request configuration with expression-based query params and body */
|
|
1063
|
-
http: HttpRequestConfig;
|
|
1064
|
-
/** Mapping that interprets the HTTP response as a validation result */
|
|
1065
|
-
responseMapping: HttpValidationResponseMapping;
|
|
1066
|
-
}
|
|
1067
|
-
/**
|
|
1068
|
-
* Configuration for signal forms validator functions that can be serialized from API.
|
|
1069
|
-
* Discriminated union type for type-safe validator configuration.
|
|
1070
|
-
*/
|
|
1071
|
-
type ValidatorConfig = BuiltInValidatorConfig | CustomValidatorConfig | AsyncValidatorConfig | FunctionHttpValidatorConfig | DeclarativeHttpValidatorConfig;
|
|
1072
|
-
/** Type guard to distinguish function-based HTTP validators from declarative ones. */
|
|
1073
|
-
declare function isFunctionHttpValidator(config: FunctionHttpValidatorConfig | DeclarativeHttpValidatorConfig): config is FunctionHttpValidatorConfig;
|
|
1074
|
-
|
|
1075
1120
|
/** Special form-state conditions for button disabled logic. */
|
|
1076
1121
|
type FormStateCondition =
|
|
1077
1122
|
/** True when form.valid() === false */
|
|
@@ -1454,29 +1499,6 @@ interface SchemaDefinition {
|
|
|
1454
1499
|
subSchemas?: SchemaApplicationConfig[];
|
|
1455
1500
|
}
|
|
1456
1501
|
|
|
1457
|
-
/**
|
|
1458
|
-
* Re-export Angular's ValidationError for consistency
|
|
1459
|
-
* This replaces our custom ValidationError interface
|
|
1460
|
-
*/
|
|
1461
|
-
type ValidationError = ValidationError$1;
|
|
1462
|
-
/**
|
|
1463
|
-
* Resolves a validation message from the validation error, so error params
|
|
1464
|
-
* (e.g. maxLength, min) can be passed to an i18n layer natively.
|
|
1465
|
-
*/
|
|
1466
|
-
type ValidationMessageResolver = (error: ValidationError) => DynamicText;
|
|
1467
|
-
/** A validation message: static or reactive text, or a function of the validation error. */
|
|
1468
|
-
type ValidationMessage = DynamicText | ValidationMessageResolver;
|
|
1469
|
-
interface ValidationMessages {
|
|
1470
|
-
required?: ValidationMessage;
|
|
1471
|
-
email?: ValidationMessage;
|
|
1472
|
-
min?: ValidationMessage;
|
|
1473
|
-
max?: ValidationMessage;
|
|
1474
|
-
minLength?: ValidationMessage;
|
|
1475
|
-
maxLength?: ValidationMessage;
|
|
1476
|
-
pattern?: ValidationMessage;
|
|
1477
|
-
[key: string]: ValidationMessage | undefined;
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
1502
|
/**
|
|
1481
1503
|
* The result type for submission actions.
|
|
1482
1504
|
* Can be either a Promise or an Observable.
|
|
@@ -1850,6 +1872,24 @@ interface RowWrapper {
|
|
|
1850
1872
|
readonly type: 'row';
|
|
1851
1873
|
}
|
|
1852
1874
|
|
|
1875
|
+
/**
|
|
1876
|
+
* Renders the wrapped field's validation errors, for a leaf or a container.
|
|
1877
|
+
*
|
|
1878
|
+
* On a container it is the only thing that can render the message — a `group` / `array`
|
|
1879
|
+
* has no adapter field component — so it is appended automatically when the container
|
|
1880
|
+
* declares `validators`. On a leaf it is opt-in: adding it takes error rendering over
|
|
1881
|
+
* from the field component, which suppresses its own via `FIELD_ERROR_DISPLAY`.
|
|
1882
|
+
*
|
|
1883
|
+
* To restyle it, register a `WrapperTypeDefinition` with the same
|
|
1884
|
+
* `wrapperName: 'field-errors'` — the later registration wins, so an adapter or an app
|
|
1885
|
+
* can swap in its own component without touching config.
|
|
1886
|
+
*/
|
|
1887
|
+
interface FieldErrorsWrapper {
|
|
1888
|
+
readonly type: 'field-errors';
|
|
1889
|
+
/** Messages keyed by error `kind`. Containers forward their own `validationMessages`. */
|
|
1890
|
+
readonly validationMessages?: ValidationMessages;
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1853
1893
|
/** Container fields registry - augment this interface to add custom container fields */
|
|
1854
1894
|
interface FieldRegistryContainers {
|
|
1855
1895
|
page: PageField;
|
|
@@ -1867,6 +1907,7 @@ interface FieldRegistryLeaves {
|
|
|
1867
1907
|
interface FieldRegistryWrappers {
|
|
1868
1908
|
css: CssWrapper;
|
|
1869
1909
|
row: RowWrapper;
|
|
1910
|
+
'field-errors': FieldErrorsWrapper;
|
|
1870
1911
|
}
|
|
1871
1912
|
/**
|
|
1872
1913
|
* Global interface for dynamic form field definitions with categorization
|
|
@@ -1945,6 +1986,12 @@ interface WrapperTypeDefinition<T extends WrapperConfig = WrapperConfig> {
|
|
|
1945
1986
|
loadComponent: LazyComponentLoader;
|
|
1946
1987
|
/** Field types this wrapper should auto-apply to. */
|
|
1947
1988
|
types?: readonly string[];
|
|
1989
|
+
/**
|
|
1990
|
+
* Declares that this wrapper renders the wrapped field's errors, so the default
|
|
1991
|
+
* `field-errors` wrapper is not appended next to it. Needed here as well as via
|
|
1992
|
+
* `provideFieldErrorDisplay`: the chain resolves before any component exists to ask.
|
|
1993
|
+
*/
|
|
1994
|
+
rendersFieldErrors?: boolean;
|
|
1948
1995
|
}
|
|
1949
1996
|
/** Type guard for WrapperTypeDefinition. */
|
|
1950
1997
|
declare function isWrapperTypeDefinition(value: unknown): value is WrapperTypeDefinition;
|
|
@@ -1970,7 +2017,7 @@ interface FieldWrapper {
|
|
|
1970
2017
|
readonly fieldComponent: Signal<ViewContainerRef>;
|
|
1971
2018
|
}
|
|
1972
2019
|
/** Injection token for the wrapper type registry. */
|
|
1973
|
-
declare const WRAPPER_REGISTRY: InjectionToken<Map<string, WrapperTypeDefinition<_ng_forge_dynamic_forms_internal.RowWrapper | _ng_forge_dynamic_forms_internal.CssWrapper>>>;
|
|
2020
|
+
declare const WRAPPER_REGISTRY: InjectionToken<Map<string, WrapperTypeDefinition<_ng_forge_dynamic_forms_internal.RowWrapper | _ng_forge_dynamic_forms_internal.CssWrapper | _ng_forge_dynamic_forms_internal.FieldErrorsWrapper>>>;
|
|
1974
2021
|
/** Component cache for loaded wrapper components. */
|
|
1975
2022
|
declare const WRAPPER_COMPONENT_CACHE: InjectionToken<Map<string, Type<unknown>>>;
|
|
1976
2023
|
/**
|
|
@@ -2948,8 +2995,122 @@ declare class RootFormRegistryService {
|
|
|
2948
2995
|
constructor(formValue: Signal<Record<string, unknown>>, rootForm: Signal<FieldTree<Record<string, unknown>> | undefined>);
|
|
2949
2996
|
}
|
|
2950
2997
|
|
|
2951
|
-
|
|
2952
|
-
|
|
2998
|
+
/** Resolved validation error with interpolated message */
|
|
2999
|
+
interface ResolvedError {
|
|
3000
|
+
kind: string;
|
|
3001
|
+
message: string;
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Factory function that creates a signal of resolved validation errors
|
|
3005
|
+
* Handles async resolution of DynamicText validation messages
|
|
3006
|
+
*
|
|
3007
|
+
* @param field - Signal containing the FieldTree, or `undefined` before it
|
|
3008
|
+
* exists (containers resolve their node lazily from the parent tree)
|
|
3009
|
+
* @param validationMessages - Signal containing custom field-level validation messages
|
|
3010
|
+
* @param defaultValidationMessages - Signal containing default validation messages (fallback)
|
|
3011
|
+
* @param injector - Optional injector for DynamicText resolution
|
|
3012
|
+
* @returns Signal<ResolvedError[]> - Reactively resolved error messages
|
|
3013
|
+
*/
|
|
3014
|
+
declare function createResolvedErrorsSignal<T>(field: Signal<FieldTree<T> | undefined>, validationMessages: Signal<ValidationMessages | undefined>, defaultValidationMessages?: Signal<ValidationMessages | undefined>, injector?: Injector): Signal<ResolvedError[]>;
|
|
3015
|
+
|
|
3016
|
+
/** A wrapper's claim to render errors, scoped to the one field key it wraps. */
|
|
3017
|
+
interface FieldErrorDisplayClaim {
|
|
3018
|
+
/** Key of the field whose errors this wrapper renders; `undefined` before inputs bind. */
|
|
3019
|
+
readonly claimedKey: Signal<string | undefined>;
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Marks that a wrapper is rendering a field's errors, so that field's component stops
|
|
3023
|
+
* rendering its own and the message appears once.
|
|
3024
|
+
*
|
|
3025
|
+
* The claim carries a key because a wrapper's providers reach every descendant: a wrapper
|
|
3026
|
+
* around an `array` would otherwise silence the errors of every input inside it. A field
|
|
3027
|
+
* suppresses its own rendering only when the claimed key is its own.
|
|
3028
|
+
*
|
|
3029
|
+
* Not `multi` — element injectors shadow rather than merge, so a nested claim would hide
|
|
3030
|
+
* the outer one regardless.
|
|
3031
|
+
*/
|
|
3032
|
+
declare const FIELD_ERROR_DISPLAY: InjectionToken<FieldErrorDisplayClaim>;
|
|
3033
|
+
/** The error surface a wrapper gets, mirroring what `NgForgeField` exposes to field components. */
|
|
3034
|
+
interface FieldErrors {
|
|
3035
|
+
/** Every resolved error, regardless of whether it should be shown yet. */
|
|
3036
|
+
readonly errors: Signal<ResolvedError[]>;
|
|
3037
|
+
/** Whether errors are ready to show — invalid, touched, and non-empty. */
|
|
3038
|
+
readonly showErrors: Signal<boolean>;
|
|
3039
|
+
/** `errors()` gated by `showErrors()`. This is what a template should render. */
|
|
3040
|
+
readonly errorsToDisplay: Signal<ResolvedError[]>;
|
|
3041
|
+
/** `{key}-error`, for wiring `aria-describedby` on the wrapped control. */
|
|
3042
|
+
readonly errorId: Signal<string>;
|
|
3043
|
+
}
|
|
3044
|
+
interface FieldErrorsOptions {
|
|
3045
|
+
/** The wrapper's `fieldInputs` input. */
|
|
3046
|
+
readonly fieldInputs: Signal<WrapperFieldInputs | undefined>;
|
|
3047
|
+
/** Overrides the messages in `fieldInputs` — containers pass their own. */
|
|
3048
|
+
readonly validationMessages?: Signal<ValidationMessages | undefined>;
|
|
3049
|
+
/** Defaults to the current injection context. */
|
|
3050
|
+
readonly injector?: Injector;
|
|
3051
|
+
}
|
|
3052
|
+
/**
|
|
3053
|
+
* Resolves the wrapped field's errors for a wrapper component, for a leaf or a container.
|
|
3054
|
+
*
|
|
3055
|
+
* A wrapper cannot `inject(NgForgeField)` — the chain is built before the field component
|
|
3056
|
+
* exists — so this reads the same information out of the `fieldInputs` bag it already has.
|
|
3057
|
+
* A leaf carries its own `field`; a container has none, so its node is resolved by key
|
|
3058
|
+
* against the parent tree in `FIELD_SIGNAL_CONTEXT`.
|
|
3059
|
+
*
|
|
3060
|
+
* Must be called in an injection context.
|
|
3061
|
+
*/
|
|
3062
|
+
declare function injectFieldErrors(options: FieldErrorsOptions): FieldErrors;
|
|
3063
|
+
|
|
3064
|
+
/** The error to raise, minus the `fieldTree` that {@link rowError} fills in. */
|
|
3065
|
+
interface RowErrorSpec {
|
|
3066
|
+
/** Error kind, matched against `validationMessages`. */
|
|
3067
|
+
readonly kind: string;
|
|
3068
|
+
/**
|
|
3069
|
+
* Message shown for this error. A row-targeted error needs its own, because the
|
|
3070
|
+
* container's `validationMessages` are keyed to the container, not to the child the
|
|
3071
|
+
* error moves to.
|
|
3072
|
+
*/
|
|
3073
|
+
readonly message?: string;
|
|
3074
|
+
readonly [param: string]: unknown;
|
|
3075
|
+
}
|
|
3076
|
+
/**
|
|
3077
|
+
* Targets a validation error at one field of one row, from a validator declared on the
|
|
3078
|
+
* array (issue #568).
|
|
3079
|
+
*
|
|
3080
|
+
* A container validator sees the whole item list, which is what makes per-row rules
|
|
3081
|
+
* expressible at all — but one message for the list cannot say which row is wrong.
|
|
3082
|
+
* Returning the result of this helper puts the error on that row's own input, where the
|
|
3083
|
+
* adapter renders it like any other field error.
|
|
3084
|
+
*
|
|
3085
|
+
* ```typescript
|
|
3086
|
+
* const periodOrder: CustomValidator = (ctx) => {
|
|
3087
|
+
* const rows = (ctx.value() ?? []) as { from?: string; to?: string }[];
|
|
3088
|
+
* return rows.flatMap((row, i) =>
|
|
3089
|
+
* row.from && row.to && row.to < row.from
|
|
3090
|
+
* ? [rowError(ctx, i, 'to', { kind: 'periodOrder', message: 'The end must not be before the start.' })]
|
|
3091
|
+
* : [],
|
|
3092
|
+
* );
|
|
3093
|
+
* };
|
|
3094
|
+
* ```
|
|
3095
|
+
*
|
|
3096
|
+
* Returns the error untargeted when the row or field cannot be resolved, so it still
|
|
3097
|
+
* surfaces on the container rather than vanishing.
|
|
3098
|
+
*/
|
|
3099
|
+
declare function rowError(ctx: FieldContext<unknown>, index: number, key: string, error: RowErrorSpec): ValidationError$1;
|
|
3100
|
+
|
|
3101
|
+
/**
|
|
3102
|
+
* Computed signal that determines if errors should be displayed.
|
|
3103
|
+
* Based on field's invalid, touched, and error count.
|
|
3104
|
+
*
|
|
3105
|
+
* @param field - Signal containing the FieldTree, or `undefined` before it exists
|
|
3106
|
+
* @returns Signal<boolean> - True if errors should be displayed
|
|
3107
|
+
*/
|
|
3108
|
+
declare function shouldShowErrors<T>(field: Signal<FieldTree<T> | undefined>): Signal<boolean>;
|
|
3109
|
+
|
|
3110
|
+
/** `field` = `validate()`; `tree` = `validateTree()`, which re-homes errors carrying a `fieldTree`. */
|
|
3111
|
+
type ValidatorAttachment = 'field' | 'tree';
|
|
3112
|
+
declare function applyValidator(config: ValidatorConfig, fieldPath: SchemaPath<any> | SchemaPathTree<any>, attachment?: ValidatorAttachment): void;
|
|
3113
|
+
declare function applyValidators(configs: ValidatorConfig[], fieldPath: SchemaPath<any> | SchemaPathTree<any>, attachment?: ValidatorAttachment): void;
|
|
2953
3114
|
|
|
2954
3115
|
/**
|
|
2955
3116
|
* Create a dynamic value function from an expression string.
|
|
@@ -3685,5 +3846,46 @@ declare function assertNever(value: never): never;
|
|
|
3685
3846
|
*/
|
|
3686
3847
|
declare function withPreviousValue<T>(input: Resource<T>): Resource<T>;
|
|
3687
3848
|
|
|
3688
|
-
|
|
3689
|
-
|
|
3849
|
+
/**
|
|
3850
|
+
* Plumbing shared by every `field-errors` wrapper: the slot, the inputs, the resolved
|
|
3851
|
+
* error surface, and the key this wrapper claims. Subclasses supply only a template —
|
|
3852
|
+
* which is the only thing that actually differs between the core default and each
|
|
3853
|
+
* adapter's native markup.
|
|
3854
|
+
*
|
|
3855
|
+
* ```typescript
|
|
3856
|
+
* @Component({
|
|
3857
|
+
* selector: 'df-mat-field-errors',
|
|
3858
|
+
* imports: [MatError],
|
|
3859
|
+
* template: `
|
|
3860
|
+
* <ng-container #fieldComponent></ng-container>
|
|
3861
|
+
* @if (ngf.errorsToDisplay()[0]; as error) {
|
|
3862
|
+
* <mat-error [id]="ngf.errorId()">{{ error.message }}</mat-error>
|
|
3863
|
+
* }
|
|
3864
|
+
* `,
|
|
3865
|
+
* providers: [provideFieldErrorDisplay(() => MatFieldErrorsWrapperComponent)],
|
|
3866
|
+
* })
|
|
3867
|
+
* export default class MatFieldErrorsWrapperComponent extends FieldErrorsWrapperBase {}
|
|
3868
|
+
* ```
|
|
3869
|
+
*/
|
|
3870
|
+
declare abstract class FieldErrorsWrapperBase implements FieldWrapper, FieldErrorDisplayClaim {
|
|
3871
|
+
readonly fieldComponent: i0.Signal<ViewContainerRef>;
|
|
3872
|
+
/** Overrides the messages in `fieldInputs`. Containers forward their own. */
|
|
3873
|
+
readonly validationMessages: i0.InputSignal<ValidationMessages | undefined>;
|
|
3874
|
+
readonly fieldInputs: i0.InputSignal<WrapperFieldInputs | undefined>;
|
|
3875
|
+
/** The field whose errors this wrapper renders — see `FieldErrorDisplayClaim`. */
|
|
3876
|
+
readonly claimedKey: i0.Signal<string | undefined>;
|
|
3877
|
+
/** Resolved error surface, mirroring what `injectNgForgeField()` gives a field component. */
|
|
3878
|
+
protected readonly ngf: _ng_forge_dynamic_forms_internal.FieldErrors;
|
|
3879
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FieldErrorsWrapperBase, never>;
|
|
3880
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<FieldErrorsWrapperBase, never, never, { "validationMessages": { "alias": "validationMessages"; "required": false; "isSignal": true; }; "fieldInputs": { "alias": "fieldInputs"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
3881
|
+
}
|
|
3882
|
+
/**
|
|
3883
|
+
* Declares that a wrapper renders the wrapped field's errors, so that field's component
|
|
3884
|
+
* renders none of its own.
|
|
3885
|
+
*
|
|
3886
|
+
* Takes a thunk because the class is still being defined when the decorator evaluates.
|
|
3887
|
+
*/
|
|
3888
|
+
declare function provideFieldErrorDisplay(wrapper: () => Type<FieldErrorDisplayClaim>): Provider;
|
|
3889
|
+
|
|
3890
|
+
export { ADDON_ACTION_HANDLERS, ADDON_ACTION_REGISTRY, ADDON_TYPE_COMPONENT_CACHE, ADDON_TYPE_DEFINITIONS, ADDON_TYPE_REGISTRY, ARRAY_CONTEXT, AsyncConditionFunctionCacheService, ComponentInitializedEvent, DEFAULT_PROPS, DEFAULT_VALIDATION_MESSAGES, DEFAULT_WRAPPERS, DEPRECATION_WARNING_TRACKER, DF_FIELD_TEMPLATES, DfAddonSlot, DynamicFormError, DynamicFormLogger, DynamicTextPipe, DynamicValueFunctionCacheService, EMIT_FORM_VALUE_ON_EVENTS, EXTERNAL_DATA, EventBus, ExpressionParser, ExpressionParserError, FIELD_ERROR_DISPLAY, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FORM_ID_PREFIX, FORM_OPTIONS, FieldContextRegistryService, FieldErrorsWrapperBase, FunctionRegistryService, GROUP_CONTEXT, HTTP_CONDITION_CACHE, HttpConditionCache, HttpConditionFunctionCacheService, INITIALIZATION_TIMEOUT_MS, LogicFunctionCacheService, NoopLogger, READONLY_FIELD_TREE_CACHE, RootFormRegistryService, TokenType, WRAPPER_AUTO_ASSOCIATIONS, WRAPPER_COMPONENT_CACHE, WRAPPER_REGISTRY, applyMetaToElement, applyValidator, applyValidators, arrayFieldMapper, assertNever, baseFieldMapper, buildBaseInputs, buildClassName, compareValues, containerFieldMapper, createAddonActionRegistry, createDebouncedLogicFunction, createDefaultDerivationLogConfig, createDynamicValueFunction, createFieldValueProxy, createFormFieldStateMap, createFormStateLogicFunction, createInitializationTracker, createLogicFunction, createResolvedErrorsSignal, createWarningTracker, deepMergeDefaults, derivedFromDeferred, detectFormMode, dynamicTextToObservable, evaluateCondition, evaluateNonFieldDisabled, evaluateNonFieldHidden, extractExpressionDependencies, extractStringDependencies, getArrayLength, getChangedKeys, getFieldValueHandling, getGridClassString, getNestedValue, groupFieldMapper, hasChildFields, hasCrossFieldWhenCondition, hasFormValue, hasNestedProperty, hasTargetProperty, injectAddonTypeRegistry, injectFieldErrors, injectFieldSignalContext, injectFieldsSupportingAddons, injectNonFieldEvaluationContext, interpolateParams, isArrayField, isCheckedField, isContainerField, isCrossFieldBuiltInValidator, isCrossFieldExpression, isCrossFieldSchema, isCrossFieldStateLogic, isCrossFieldValidator, isDerivationLogicConfig, isDisplayOnlyField, isEqual, isFieldBoundContext, isFormStateCondition, isFunctionHttpValidator, isGenericContainerField, isGroupField, isHiddenField, isLeafField, isNonPagedForm, isPageField, isPagedForm, isResourceBasedValidator, isRowField, isSimplifiedArrayField, isStateLogicConfig, isValidNonPagedForm, isValidPagedForm, isValueBearingField, isValueField, isWrapperTypeDefinition, keyBy, mapValues, memoize, normalizeFieldsArray, omit, pageFieldMapper, provideFieldErrorDisplay, readFieldStateInfo, resolveDynamicValue, resolveHttpRequest, resolveNextButtonDisabled, resolveNonFieldDisabled, resolveNonFieldHidden, resolveSubmitButtonDisabled, resolveTokens, rowError, rowFieldMapper, runPresetAction, setupInitializationTracking, shouldLog, shouldShowErrors, textFieldMapper, toReadonlyFieldTree, toReadonlyFieldTreeCached, validatePageNesting, withPreviousValue, writeToFieldValue };
|
|
3891
|
+
export type { ASTNode, AddonActionContext, AddonActionHandler, AddonActionPreset, AddonShapeValidator, AddonSlot, AddonTypeDefinition, AddonTypeRegistryRef, AddonTypeSchema, AndCondition, AnyAddon, ArrayAllowedChildren, ArrayButtonConfig, ArrayComponent, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemDefinition, ArrayItemTemplate, ArrayLiteralNode, ArrowFunctionNode, AsyncCondition, AsyncConditionFunction, AsyncCustomValidator, AsyncDerivationFunction, AsyncValidatorConfig, AvailableFieldTypes, BaseAddon, BaseCheckedField, BaseValidatorConfig, BaseValueField, BinaryOpNode, BuiltInValidatorConfig, ButtonLogicContext, CallExpressionNode, CheckedFieldComponent, CommonAddonActionPreset, CommonAddonSlot, ComparisonOperator, ComponentAddon, ComputedMemberAccessNode, ConditionalExpression, ConditionalNode, ContainerAllowedChildren, ContainerComponent, ContainerField, ContainerFieldTypes, ContainerLogicConfig, ContainerValidation, CrossFieldDetectionContext, CssWrapper, CustomCondition, CustomFnConfig, CustomFunction, CustomFunctionOptions, CustomFunctionScope, CustomValidator, CustomValidatorConfig, DeclarativeHttpValidatorConfig, DerivationLogConfig, DerivationLogLevel, DerivationLogicConfig, DerivedFromDeferredOptions, DynamicFormActionRegistry, DynamicFormAddonActionPresetRegistry, DynamicFormAddonRegistry, DynamicFormAddonSlotRegistry, DynamicFormFieldRegistry, DynamicText, DynamicValue, EvaluationContext, ExtractField, FieldAddonSupport, FieldAddonSupportEntry, FieldBoundAddonActionContext, FieldComponent, FieldDef, FieldErrorDisplayClaim, FieldErrors, FieldErrorsOptions, FieldErrorsWrapper, FieldMeta, FieldOption, FieldPathAccess, FieldRegistryContainers, FieldRegistryLeaves, FieldRegistryWrappers, FieldScope, FieldSignalContext, FieldStateContext, FieldStateInfo, FieldTreeRecord, FieldTypeDefinition, FieldValueCondition, FieldWithValidation, FieldWrapper, FormConfig, FormEvent, FormEventConstructor, FormFieldStateMap, FormMode, FormModeDetectionResult, FormOptions, FormStateCondition, FunctionHttpValidatorConfig, GroupAllowedChildren, GroupComponent, GroupContext, GroupField, HiddenField, HiddenScalar, HiddenValue, HttpCondition, HttpCustomValidator, HttpRequestConfig, HttpResourceRequest, HttpValidationResponseMapping, IdentifierNode, InferFormModel, InferFormValue, InitialPageConfig, InitializationTrackingOptions, JavascriptCondition, LazyComponentLoader, LeafFieldTypes, LiteralNode, Logger, LogicConfig, LogicTrigger, MapperFn, MemberAccessNode, MemoizeOptions, NarrowField, NarrowFields, NextButtonOptions, NonFieldLogicConfig, NonFieldLogicContext, NonFieldLogicType, ObjectLiteralNode, OrCondition, OrphanAddonActionContext, PageAllowedChildren, PageField, PresetCollaborators, Prettify, ReadonlyFieldTree, RegisteredActionRef, RegisteredFieldTypes, RegisteredWrapperTypes, RenderReadyInput, ResolvedError, ResolvedValidationExecutionConfig, ResolvedValueExclusionConfig, RowAllowedChildren, RowComponent, RowErrorSpec, RowField, RowWrapper, SchemaApplicationConfig, SchemaDefinition, SimplifiedArrayField, StateLogicConfig, StateLogicType, SubmissionActionResult, SubmissionConfig, SubmitButtonOptions, TemplateAddon, TextAddon, TextElementType, TextField, TextProps, Token, TokenContext, UnaryOpNode, ValidationError, ValidationExecutionConfig, ValidationMessage, ValidationMessageResolver, ValidationMessages, ValidatorAttachment, ValidatorConfig, ValueExclusionConfig, ValueFieldComponent, ValueHandlingMode, ValueType, WarningTracker, WithInputSignals, WrapperAutoAssociations, WrapperConfig, WrapperFieldInputs, WrapperTypeDefinition };
|