@ng-forge/dynamic-forms 0.10.0-next.4 → 1.0.0-rc.2
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 +16 -0
- package/fesm2022/{ng-forge-dynamic-forms-array-field.component-BfRH3TBm.mjs → ng-forge-dynamic-forms-array-field.component-8rodySeE.mjs} +47 -26
- package/fesm2022/ng-forge-dynamic-forms-array-field.component-8rodySeE.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-C8kpF0tw.mjs +2347 -0
- package/fesm2022/ng-forge-dynamic-forms-bootstrap-derivation-orchestrator-C8kpF0tw.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-container-field.component-bA-8ICHF.mjs → ng-forge-dynamic-forms-container-field.component-DFgjWEZN.mjs} +22 -14
- package/fesm2022/ng-forge-dynamic-forms-container-field.component-DFgjWEZN.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-container-utils-BvXn8T_i.mjs → ng-forge-dynamic-forms-container-utils-BZFz6ztF.mjs} +3 -2
- package/fesm2022/ng-forge-dynamic-forms-container-utils-BZFz6ztF.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-css-wrapper.component-DjhcONFh.mjs → ng-forge-dynamic-forms-css-wrapper.component-AScQAJTQ.mjs} +8 -6
- package/fesm2022/ng-forge-dynamic-forms-css-wrapper.component-AScQAJTQ.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-group-field.component-D0_nmXf2.mjs → ng-forge-dynamic-forms-group-field.component-Ca4AqdZu.mjs} +42 -24
- package/fesm2022/ng-forge-dynamic-forms-group-field.component-Ca4AqdZu.mjs.map +1 -0
- package/fesm2022/ng-forge-dynamic-forms-integration.mjs +122 -81
- package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -1
- package/fesm2022/ng-forge-dynamic-forms-internal.mjs +297 -56
- package/fesm2022/ng-forge-dynamic-forms-internal.mjs.map +1 -1
- package/fesm2022/{ng-forge-dynamic-forms-ng-forge-dynamic-forms-CNc4a_Xv.mjs → ng-forge-dynamic-forms-ng-forge-dynamic-forms-BJi_rtey.mjs} +535 -3055
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-BJi_rtey.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-page-field.component-BJRNnoz-.mjs → ng-forge-dynamic-forms-page-field.component-IsAtMNjD.mjs} +26 -16
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-IsAtMNjD.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-row-wrapper.component-CwkYn5yl.mjs → ng-forge-dynamic-forms-row-wrapper.component-BlVa801t.mjs} +6 -5
- package/fesm2022/ng-forge-dynamic-forms-row-wrapper.component-BlVa801t.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-text-field.component-DABkT0O7.mjs → ng-forge-dynamic-forms-text-field.component-CNCpmf5_.mjs} +18 -11
- package/fesm2022/{ng-forge-dynamic-forms-text-field.component-DABkT0O7.mjs.map → ng-forge-dynamic-forms-text-field.component-CNCpmf5_.mjs.map} +1 -1
- package/fesm2022/ng-forge-dynamic-forms.mjs +2 -2
- package/package.json +4 -4
- package/types/ng-forge-dynamic-forms-integration.d.ts +5 -5
- package/types/ng-forge-dynamic-forms-internal.d.ts +1943 -1765
- package/types/ng-forge-dynamic-forms.d.ts +59 -267
- package/fesm2022/ng-forge-dynamic-forms-array-field.component-BfRH3TBm.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-container-field.component-bA-8ICHF.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-container-utils-BvXn8T_i.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-css-wrapper.component-DjhcONFh.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-group-field.component-D0_nmXf2.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-CNc4a_Xv.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-BJRNnoz-.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-row-wrapper.component-CwkYn5yl.mjs.map +0 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as rxjs from 'rxjs';
|
|
2
2
|
import * as _angular_core from '@angular/core';
|
|
3
|
-
import { Type, Injector, Signal, EnvironmentInjector, WritableSignal, Provider, EnvironmentProviders, TemplateRef
|
|
3
|
+
import { Type, Injector, Signal, EnvironmentInjector, WritableSignal, Provider, EnvironmentProviders, TemplateRef } from '@angular/core';
|
|
4
4
|
import * as _ng_forge_dynamic_forms_internal from '@ng-forge/dynamic-forms/internal';
|
|
5
|
-
import { FieldDef, FormEvent, RegisteredFieldTypes, InferFormValue as InferFormValue$1, FormConfig, FormOptions, EventBus, LazyComponentLoader, WrapperTypeDefinition, FieldTypeDefinition, DerivationLogLevel, Logger, ValueExclusionConfig, ValidationExecutionConfig,
|
|
6
|
-
export {
|
|
5
|
+
import { FieldDef, FormEvent, RegisteredFieldTypes, InferFormValue as InferFormValue$1, FormConfig, FormOptions, EventBus, LazyComponentLoader, WrapperTypeDefinition, FieldTypeDefinition, DerivationLogLevel, Logger, ValueExclusionConfig, ValidationExecutionConfig, TextAddon, WrapperFieldInputs, TemplateAddon, ComponentAddon, BaseAddon, AddonTypeDefinition, AddonActionHandler, ArrayItemDefinition } from '@ng-forge/dynamic-forms/internal';
|
|
6
|
+
export { AddonActionContext, AddonActionPreset, AddonSlot, AddonTypeDefinition, AnyAddon, ArrayAllowedChildren, ArrayButtonConfig, ArrayField, ArrayItemTemplate, AsyncCondition, AsyncConditionFunction, AsyncCustomValidator, AsyncDerivationFunction, AsyncValidatorConfig, AvailableFieldTypes, BaseAddon, BaseCheckedField, BaseValidatorConfig, BaseValueField, BuiltInValidatorConfig, CheckedFieldComponent, CommonAddonActionPreset, CommonAddonSlot, ComponentAddon, ConditionalExpression, ContainerAllowedChildren, ContainerField, ContainerFieldTypes, CssWrapper, CustomFnConfig, CustomFunction, CustomValidator, CustomValidatorConfig, DF_FIELD_TEMPLATES, DeclarativeHttpValidatorConfig, DynamicFormActionRegistry, DynamicFormAddonActionPresetRegistry, DynamicFormAddonRegistry, DynamicFormAddonSlotRegistry, DynamicFormError, DynamicFormFieldRegistry, DynamicFormLogger, DynamicText, DynamicValue, EvaluationContext, ExtractField, FieldBoundAddonActionContext, FieldComponent, FieldDef, FieldMeta, FieldOption, FieldPathAccess, FieldRegistryContainers, FieldRegistryLeaves, FieldRegistryWrappers, FieldWithValidation, FieldWrapper, FormConfig, FormEvent, FormEventConstructor, FormMode, FormModeDetectionResult, FormOptions, FormStateCondition, GroupAllowedChildren, GroupField, HiddenField, HiddenScalar, HiddenValue, HttpCondition, HttpCustomValidator, HttpRequestConfig, HttpValidationResponseMapping, InferFormValue, LeafFieldTypes, Logger, LogicConfig, NarrowField, NarrowFields, NextButtonOptions, NoopLogger, OrphanAddonActionContext, PageAllowedChildren, PageField, RegisteredActionRef, RegisteredFieldTypes, ResolvedValidationExecutionConfig, ResolvedValueExclusionConfig, RowAllowedChildren, RowField, SchemaApplicationConfig, SchemaDefinition, SimplifiedArrayField, StateLogicConfig, SubmissionActionResult, SubmissionConfig, SubmitButtonOptions, TemplateAddon, TextAddon, TextElementType, TextField, TextProps, TokenContext, ValidationError, ValidationExecutionConfig, ValidationMessages, ValidatorConfig, ValueExclusionConfig, ValueFieldComponent, ValueType, WithInputSignals, WrapperConfig, WrapperTypeDefinition, hasFormValue, isArrayField, isContainerField, isDisplayOnlyField, isFieldBoundContext, isFormStateCondition, isGroupField, isHiddenField, isLeafField, isPageField, isRowField, isSimplifiedArrayField, isValueBearingField, isWrapperTypeDefinition, resolveDynamicValue } from '@ng-forge/dynamic-forms/internal';
|
|
7
7
|
import * as _angular_forms_signals from '@angular/forms/signals';
|
|
8
8
|
import { FieldTree } from '@angular/forms/signals';
|
|
9
9
|
import * as _angular_forms from '@angular/forms';
|
|
10
10
|
import * as _ng_forge_dynamic_forms from '@ng-forge/dynamic-forms';
|
|
11
|
-
import { FormSchema } from '@ng-forge/dynamic-forms/schema';
|
|
12
11
|
|
|
13
12
|
/** Resolved field ready for rendering with ngComponentOutlet / DfFieldOutlet. */
|
|
14
13
|
interface ResolvedField {
|
|
@@ -47,6 +46,7 @@ declare class FormResetEvent implements FormEvent {
|
|
|
47
46
|
readonly type: "form-reset";
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
/** Event emitted when the active page of a paged form changes. */
|
|
50
50
|
declare class PageChangeEvent implements FormEvent {
|
|
51
51
|
/** The current page index (0-based) */
|
|
52
52
|
readonly currentPageIndex: number;
|
|
@@ -85,8 +85,34 @@ declare class PageNavigationStateChangeEvent implements FormEvent {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
88
|
+
* Renders a form from a {@link FormConfig}. Attribute component on a native
|
|
89
|
+
* `<form>` element (selector `form[dynamic-form]`); state management is
|
|
90
|
+
* delegated to `FormStateManager`.
|
|
91
|
+
*
|
|
92
|
+
* Provide a UI adapter once via {@link provideDynamicForm} (for example
|
|
93
|
+
* `provideDynamicForm(...withMaterialFields())`), then bind a config and
|
|
94
|
+
* listen for `submitted`. Field-value types are inferred from the config when
|
|
95
|
+
* it is authored with `as const satisfies FormConfig`.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* @Component({
|
|
100
|
+
* imports: [DynamicForm],
|
|
101
|
+
* template: `<form [dynamic-form]="config" (submitted)="onSubmit($event)"></form>`,
|
|
102
|
+
* })
|
|
103
|
+
* export class SignInComponent {
|
|
104
|
+
* config = {
|
|
105
|
+
* fields: [
|
|
106
|
+
* { key: 'email', type: 'input', value: '', label: 'Email', required: true, email: true },
|
|
107
|
+
* { type: 'submit', key: 'submit', label: 'Sign in' },
|
|
108
|
+
* ],
|
|
109
|
+
* } as const satisfies FormConfig;
|
|
110
|
+
*
|
|
111
|
+
* onSubmit(value: InferFormValue<typeof this.config.fields>) {
|
|
112
|
+
* console.log(value); // inferred: { email: string }
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
90
116
|
*/
|
|
91
117
|
declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFieldTypes[], TModel extends Record<string, unknown> = InferFormValue$1<TFields> & Record<string, unknown>> {
|
|
92
118
|
/** Form configuration defining the structure, validation, and behavior. */
|
|
@@ -97,7 +123,7 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
97
123
|
value: _angular_core.ModelSignal<Partial<TModel> | undefined>;
|
|
98
124
|
/**
|
|
99
125
|
* How lenient the addon validator is on `config.fields[...].addons`.
|
|
100
|
-
* `'inline'` (default) keeps everything; `'json'` drops code-only
|
|
126
|
+
* `'inline'` (default) keeps everything; `'json'` drops code-only types
|
|
101
127
|
* with a warning. Read at form init and on every config swap — change
|
|
102
128
|
* `source` AND the config to force re-validation mid-flight.
|
|
103
129
|
*/
|
|
@@ -147,7 +173,7 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
147
173
|
/** Default values computed from field definitions */
|
|
148
174
|
defaultValues: WritableSignal<TModel>;
|
|
149
175
|
/** The Angular Signal Form instance */
|
|
150
|
-
form: Signal<FieldTree<TModel, string | number>>;
|
|
176
|
+
form: Signal<FieldTree<TModel, string | number, "writable">>;
|
|
151
177
|
/** Current form values (reactive) */
|
|
152
178
|
formValue: Signal<TModel | (TModel extends infer T ? T extends TModel ? T extends _angular_forms.AbstractControl<unknown, infer TValue extends unknown, any> ? TValue : never : never : never)>;
|
|
153
179
|
/** Whether the form is currently valid */
|
|
@@ -167,6 +193,7 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
167
193
|
/** Collects errors from async field component loading for error boundary patterns */
|
|
168
194
|
fieldLoadingErrors: WritableSignal<FieldLoadingError[]>;
|
|
169
195
|
/** Whether to render the form template */
|
|
196
|
+
private derivationReady;
|
|
170
197
|
shouldRender: Signal<boolean>;
|
|
171
198
|
/** Resolved fields ready for rendering */
|
|
172
199
|
protected resolvedFields: Signal<ResolvedField[]>;
|
|
@@ -180,7 +207,7 @@ declare class DynamicForm<TFields extends RegisteredFieldTypes[] = RegisteredFie
|
|
|
180
207
|
validityChange: _angular_core.OutputRef<boolean>;
|
|
181
208
|
/** Emits when form dirty state changes. */
|
|
182
209
|
dirtyChange: _angular_core.OutputRef<boolean>;
|
|
183
|
-
/** Emits form values when submitted (via
|
|
210
|
+
/** Emits form values when submitted (via FormSubmitEvent) and form is valid. */
|
|
184
211
|
submitted: _angular_core.OutputRef<Partial<TModel>>;
|
|
185
212
|
/** Emits when form is reset to default values. */
|
|
186
213
|
reset: _angular_core.OutputRef<FormResetEvent>;
|
|
@@ -451,77 +478,6 @@ declare function withLegacyStatusClasses(): DynamicFormFeature<'legacy-status-cl
|
|
|
451
478
|
/** Zero-cost type carrier used in wrapper registrations. */
|
|
452
479
|
declare function wrapperProps<T>(): T;
|
|
453
480
|
|
|
454
|
-
/**
|
|
455
|
-
* Dispatcher component that renders an addon by looking up its `kind` in
|
|
456
|
-
* `ADDON_KIND_REGISTRY` and instantiating the registered component.
|
|
457
|
-
*/
|
|
458
|
-
declare class DfAddonSlot {
|
|
459
|
-
private readonly registry;
|
|
460
|
-
private readonly logger;
|
|
461
|
-
private readonly hostInjector;
|
|
462
|
-
readonly addon: _angular_core.InputSignal<AnyAddon>;
|
|
463
|
-
/**
|
|
464
|
-
* Optional read-only view of the host field's mapped inputs — same shape
|
|
465
|
-
* wrappers receive (`field?: ReadonlyFieldTree`, `key`, `props`, etc.).
|
|
466
|
-
* Forwarded to kind components so they can read field state without
|
|
467
|
-
* re-injecting `FIELD_SIGNAL_CONTEXT` and rebuilding context themselves.
|
|
468
|
-
*/
|
|
469
|
-
readonly fieldInputs: _angular_core.InputSignal<WrapperFieldInputs | undefined>;
|
|
470
|
-
/**
|
|
471
|
-
* Pre-resolved `hidden` signal supplied by the host field. When provided,
|
|
472
|
-
* the dispatcher reads this instead of re-resolving `addon.hidden` —
|
|
473
|
-
* lets the host (e.g., `prime-input`) share a single subscription per
|
|
474
|
-
* Observable-typed `hidden` between its own visibility filter and the
|
|
475
|
-
* slot's `[style.display]` binding.
|
|
476
|
-
*/
|
|
477
|
-
readonly hidden: _angular_core.InputSignal<Signal<boolean> | undefined>;
|
|
478
|
-
/** `slot` HTML attribute forwarded to host — needed for Ionic shadow projection. */
|
|
479
|
-
protected readonly slotAttr: Signal<_ng_forge_dynamic_forms.AddonSlot>;
|
|
480
|
-
protected readonly className: Signal<string | null>;
|
|
481
|
-
/**
|
|
482
|
-
* Locally-resolved `hidden` signal — always reflects `addon.hidden`
|
|
483
|
-
* regardless of whether the host supplied a pre-resolved signal.
|
|
484
|
-
* Populated via `explicitEffect` so `resolveDynamicValue` (which may call
|
|
485
|
-
* `toSignal` for Observable-typed values) does NOT run inside a reactive
|
|
486
|
-
* context (NG0602). The WeakMap caches per `hidden`-value identity, so
|
|
487
|
-
* swapping `addon` inputs that share the same Observable reuses the
|
|
488
|
-
* subscription instead of leaking a fresh one per swap.
|
|
489
|
-
*/
|
|
490
|
-
private readonly _hiddenByValue;
|
|
491
|
-
private readonly _resolvedHidden;
|
|
492
|
-
/**
|
|
493
|
-
* `hidden` resolved from `DynamicValue<boolean>` to a flat `Signal<boolean>`.
|
|
494
|
-
* Prefers the host-supplied signal when present (avoids duplicate `toSignal`
|
|
495
|
-
* subscriptions for Observable-typed `hidden`); falls back to the locally-
|
|
496
|
-
* resolved signal, which is always populated by the addon-tracking effect.
|
|
497
|
-
*/
|
|
498
|
-
protected readonly isHidden: Signal<boolean>;
|
|
499
|
-
/**
|
|
500
|
-
* Latest async-loaded `{ kind, component }` pair. Tagging the result with
|
|
501
|
-
* its kind lets `resolvedComponent` filter stale loads structurally — no
|
|
502
|
-
* monotonic token needed. When `addon.kind` changes mid-load, the prior
|
|
503
|
-
* load still completes and writes here, but the computed ignores it
|
|
504
|
-
* because the recorded kind no longer matches the current one.
|
|
505
|
-
*/
|
|
506
|
-
private readonly asyncLoaded;
|
|
507
|
-
/**
|
|
508
|
-
* Resolved kind component — composed declaratively from two sources of
|
|
509
|
-
* truth: the registry's synchronous cache (warm hits, e.g., a second
|
|
510
|
-
* `<df-addon-slot>` for an already-loaded kind) and the kind-tagged async
|
|
511
|
-
* loader result. Reading `addon().kind` first makes the computed react to
|
|
512
|
-
* addon swaps and naturally invalidate stale async-load results.
|
|
513
|
-
*/
|
|
514
|
-
protected readonly resolvedComponent: Signal<Type<unknown> | undefined>;
|
|
515
|
-
/** Inputs passed to the kind component — addon plus the wrapper-style host bag. */
|
|
516
|
-
protected readonly kindInputs: Signal<{
|
|
517
|
-
addon: AnyAddon;
|
|
518
|
-
fieldInputs: WrapperFieldInputs | undefined;
|
|
519
|
-
}>;
|
|
520
|
-
constructor();
|
|
521
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<DfAddonSlot, never>;
|
|
522
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<DfAddonSlot, "df-addon-slot", never, { "addon": { "alias": "addon"; "required": true; "isSignal": true; }; "fieldInputs": { "alias": "fieldInputs"; "required": false; "isSignal": true; }; "hidden": { "alias": "hidden"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
481
|
/**
|
|
526
482
|
* Marks an `<ng-template>` projected into `<df-dynamic-form>` content as
|
|
527
483
|
* available to template addons by name.
|
|
@@ -535,7 +491,7 @@ declare class DfTemplate {
|
|
|
535
491
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<DfTemplate, "ng-template[dfTemplate]", ["dfTemplate"], { "dfTemplate": { "alias": "dfTemplate"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
536
492
|
}
|
|
537
493
|
|
|
538
|
-
/** Renderer for the universal `text` addon
|
|
494
|
+
/** Renderer for the universal `text` addon type. */
|
|
539
495
|
declare class TextAddonComponent {
|
|
540
496
|
readonly addon: _angular_core.InputSignal<TextAddon>;
|
|
541
497
|
/** Accepted for contract uniformity — `NgComponentOutlet` setInput is strict; every kind must declare it. */
|
|
@@ -544,7 +500,7 @@ declare class TextAddonComponent {
|
|
|
544
500
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<TextAddonComponent, "df-text-addon", never, { "addon": { "alias": "addon"; "required": true; "isSignal": true; }; "fieldInputs": { "alias": "fieldInputs"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
545
501
|
}
|
|
546
502
|
|
|
547
|
-
/** Renderer for the universal `template` addon
|
|
503
|
+
/** Renderer for the universal `template` addon type. */
|
|
548
504
|
declare class TemplateAddonComponent {
|
|
549
505
|
private readonly templates;
|
|
550
506
|
private readonly logger;
|
|
@@ -562,7 +518,7 @@ declare class TemplateAddonComponent {
|
|
|
562
518
|
}
|
|
563
519
|
|
|
564
520
|
/**
|
|
565
|
-
* Renderer for the universal `component` addon
|
|
521
|
+
* Renderer for the universal `component` addon type.
|
|
566
522
|
*
|
|
567
523
|
* @codeOnly The `component` loader is a function; this kind is dropped in
|
|
568
524
|
* lenient validation when the config originated from JSON.
|
|
@@ -588,107 +544,11 @@ declare class ComponentAddonComponent {
|
|
|
588
544
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ComponentAddonComponent, "df-component-addon", never, { "addon": { "alias": "addon"; "required": true; "isSignal": true; }; "fieldInputs": { "alias": "fieldInputs"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
589
545
|
}
|
|
590
546
|
|
|
591
|
-
/**
|
|
592
|
-
|
|
593
|
-
* by the button kind component which has access to its own DI scope.
|
|
594
|
-
*/
|
|
595
|
-
interface PresetCollaborators {
|
|
596
|
-
/** Per-field input-type override signal — populated only inside an input field. */
|
|
597
|
-
readonly typeOverride?: WritableSignal<string | undefined>;
|
|
598
|
-
/** Writer that pushes a value into the host field's tree. */
|
|
599
|
-
readonly fieldValueSetter?: (next: unknown) => void;
|
|
600
|
-
/**
|
|
601
|
-
* Read the host field's configured default value (from the form's
|
|
602
|
-
* `defaultValues` map keyed by `field.key`). Used by the `'reset'`
|
|
603
|
-
* preset; absent when the addon is rendered outside an active field
|
|
604
|
-
* context, in which case `'reset'` falls back to clearing.
|
|
605
|
-
*/
|
|
606
|
-
readonly fieldDefaultValueGetter?: () => unknown;
|
|
607
|
-
/**
|
|
608
|
-
* Baseline configured input type (from `props().type`), read at preset-run
|
|
609
|
-
* time. Used by `toggle-password-visibility` to refuse to corrupt
|
|
610
|
-
* `'email'`/`'number'`/etc. inputs into `'password'` when no override is
|
|
611
|
-
* yet set.
|
|
612
|
-
*/
|
|
613
|
-
readonly baselineType?: () => string | undefined;
|
|
614
|
-
/** Logger for warnings about presets that can't be fulfilled in this context. */
|
|
615
|
-
readonly logger: Logger;
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Apply a built-in preset action against the addon's host field. Shared
|
|
619
|
-
* across all adapters — each adapter's `ADDON_PRESET_HANDLER` provider
|
|
620
|
-
* delegates here.
|
|
621
|
-
*
|
|
622
|
-
* @param adapterLabel Used in warnings — `'Material'` / `'Bootstrap'` / etc.
|
|
623
|
-
* @param fieldLabel Used in warnings — `'mat-input'` / `'bs-input'` / etc.
|
|
624
|
-
*/
|
|
625
|
-
declare function runPresetAction(preset: AddonActionPreset, ctx: AddonActionContext, collaborators: PresetCollaborators, adapterLabel: string, fieldLabel: string): Promise<void>;
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Cache for resolved addon-kind components.
|
|
629
|
-
*
|
|
630
|
-
* @internal
|
|
631
|
-
*/
|
|
632
|
-
declare const ADDON_KIND_COMPONENT_CACHE: InjectionToken<Map<string, Type<unknown>>>;
|
|
633
|
-
/**
|
|
634
|
-
* Public shape returned by {@link injectAddonKindRegistry}. Pinned explicitly
|
|
635
|
-
* so the API extractor doesn't churn between versions when the inner factory
|
|
636
|
-
* gets refactored.
|
|
637
|
-
*/
|
|
638
|
-
interface AddonKindRegistryRef {
|
|
639
|
-
getKind(kind: string): AddonKindDefinition | undefined;
|
|
640
|
-
hasKind(kind: string): boolean;
|
|
641
|
-
getKindNames(): string[];
|
|
642
|
-
loadKindComponent(kind: string): Promise<Type<unknown>>;
|
|
643
|
-
getLoadedKindComponent(kind: string): Type<unknown> | undefined;
|
|
644
|
-
readonly raw: ReadonlyMap<string, AddonKindDefinition>;
|
|
645
|
-
}
|
|
646
|
-
/** Injection function for accessing the addon kind registry. */
|
|
647
|
-
declare function injectAddonKindRegistry(): AddonKindRegistryRef;
|
|
648
|
-
|
|
649
|
-
/** One entry per field type that declares addon support. */
|
|
650
|
-
interface FieldAddonSupportEntry {
|
|
651
|
-
readonly name: string;
|
|
652
|
-
readonly slots: FieldAddonSupport['slots'];
|
|
653
|
-
readonly allowedKinds: FieldAddonSupport['allowedKinds'];
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Walk `FIELD_REGISTRY` and return every field type that opted into addons
|
|
657
|
-
* (i.e., declared `addons` on its `FieldTypeDefinition`).
|
|
658
|
-
*
|
|
659
|
-
* @Component({ ... })
|
|
660
|
-
* class FormBuilder {
|
|
661
|
-
* protected readonly addonable = injectFieldsSupportingAddons();
|
|
662
|
-
*
|
|
663
|
-
* constructor() {
|
|
664
|
-
* // -> [{ name: 'prime-input', slots: ['prefix', 'suffix'], allowedKinds: [...] }, ...]
|
|
665
|
-
* }
|
|
666
|
-
* }
|
|
667
|
-
* ```
|
|
668
|
-
*/
|
|
669
|
-
declare function injectFieldsSupportingAddons(): FieldAddonSupportEntry[];
|
|
670
|
-
|
|
671
|
-
/** Register a custom addon kind with the form. */
|
|
672
|
-
declare function withCustomAddon<T extends BaseAddon>(definition: AddonKindDefinition<T>): DynamicFormFeature<'addons'>;
|
|
547
|
+
/** Register a custom addon type with the form. */
|
|
548
|
+
declare function withCustomAddon<T extends BaseAddon>(definition: AddonTypeDefinition<T>): DynamicFormFeature<'addons'>;
|
|
673
549
|
|
|
674
|
-
/** Handler signature for user-registered addon actions. */
|
|
675
|
-
type AddonActionHandler<TValue = unknown> = (ctx: AddonActionContext<TValue>) => void;
|
|
676
|
-
/**
|
|
677
|
-
* Multi-provider token populated by `provideAddonActions({...})` calls.
|
|
678
|
-
* `ADDON_ACTION_REGISTRY` aggregates these into a single name → handler map.
|
|
679
|
-
*
|
|
680
|
-
* @internal
|
|
681
|
-
*/
|
|
682
|
-
declare const ADDON_ACTION_HANDLERS: InjectionToken<readonly Record<string, AddonActionHandler<unknown>>[]>;
|
|
683
550
|
/**
|
|
684
|
-
*
|
|
685
|
-
* time for `actionRef: 'name'` lookups. Provided at form scope (not root)
|
|
686
|
-
* because `ADDON_ACTION_HANDLERS` is form-scoped via `provideAddonActions`.
|
|
687
|
-
*/
|
|
688
|
-
declare const ADDON_ACTION_REGISTRY: InjectionToken<ReadonlyMap<string, AddonActionHandler<unknown>>>;
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Typed feature returned by {@link provideAddonActions}. Carries the
|
|
551
|
+
* Typed feature returned by {@link withAddonActions}. Carries the
|
|
692
552
|
* registered handler keys as a phantom type so consumers can derive the
|
|
693
553
|
* `DynamicFormActionRegistry` augmentation in one line instead of hand-typing
|
|
694
554
|
* every key.
|
|
@@ -698,16 +558,7 @@ type AddonActionsFeature<K extends string = string> = DynamicFormFeature<'addon-
|
|
|
698
558
|
readonly __handlerKeys?: K;
|
|
699
559
|
};
|
|
700
560
|
/** Register named action handlers reachable via JSON-driven addon configs. */
|
|
701
|
-
declare function
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* Multi-provider token used by `withCustomAddon(...)` features to contribute
|
|
705
|
-
* addon kind definitions. `provideDynamicForm` aggregates all values into
|
|
706
|
-
* the form-scoped `ADDON_KIND_REGISTRY` map.
|
|
707
|
-
*
|
|
708
|
-
* @internal
|
|
709
|
-
*/
|
|
710
|
-
declare const ADDON_KIND_DEFINITIONS: InjectionToken<readonly AddonKindDefinition<_ng_forge_dynamic_forms.BaseAddon<_ng_forge_dynamic_forms.AddonSlot>>[]>;
|
|
561
|
+
declare function withAddonActions<const H extends Record<string, AddonActionHandler>>(handlers: H): AddonActionsFeature<keyof H & string>;
|
|
711
562
|
|
|
712
563
|
/** Reason an addon was dropped during validation. */
|
|
713
564
|
type AddonWarning = {
|
|
@@ -725,55 +576,30 @@ type AddonWarning = {
|
|
|
725
576
|
slot: string;
|
|
726
577
|
allowedSlots: readonly string[];
|
|
727
578
|
} | {
|
|
728
|
-
type: 'unknown-
|
|
579
|
+
type: 'unknown-type';
|
|
729
580
|
fieldKey: string;
|
|
730
|
-
|
|
731
|
-
|
|
581
|
+
addonType: string;
|
|
582
|
+
registeredTypes: readonly string[];
|
|
732
583
|
} | {
|
|
733
|
-
type: '
|
|
584
|
+
type: 'type-not-allowed';
|
|
734
585
|
fieldKey: string;
|
|
735
586
|
fieldType: string;
|
|
736
|
-
|
|
737
|
-
|
|
587
|
+
addonType: string;
|
|
588
|
+
allowedTypes: readonly string[];
|
|
738
589
|
} | {
|
|
739
590
|
type: 'shape-violation';
|
|
740
591
|
fieldKey: string;
|
|
741
|
-
|
|
592
|
+
addonType: string;
|
|
742
593
|
reason: string;
|
|
743
594
|
} | {
|
|
744
|
-
type: 'code-only-
|
|
595
|
+
type: 'code-only-type-in-json';
|
|
745
596
|
fieldKey: string;
|
|
746
|
-
|
|
597
|
+
addonType: string;
|
|
747
598
|
} | {
|
|
748
599
|
type: 'code-only-action-in-json';
|
|
749
600
|
fieldKey: string;
|
|
750
601
|
reason: string;
|
|
751
602
|
};
|
|
752
|
-
/** Render an `AddonWarning` to a developer-friendly message. */
|
|
753
|
-
declare function formatAddonWarning(w: AddonWarning): string;
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
* Walk a field's addons; return the survivors plus a list of warnings for
|
|
757
|
-
* anything dropped.
|
|
758
|
-
*
|
|
759
|
-
* @param field The field to validate.
|
|
760
|
-
* @param fieldRegistry Snapshot of `FIELD_REGISTRY` map.
|
|
761
|
-
* @param kindRegistry Snapshot of `ADDON_KIND_REGISTRY` map.
|
|
762
|
-
* @param source Whether the config originated from JSON (lenient drop
|
|
763
|
-
* of code-only kinds) or inline TypeScript.
|
|
764
|
-
*/
|
|
765
|
-
declare function validateFieldAddons(field: FieldDef<unknown>, fieldRegistry: ReadonlyMap<string, FieldTypeDefinition>, kindRegistry: ReadonlyMap<string, AddonKindDefinition>, source: 'json' | 'inline'): {
|
|
766
|
-
addons: AnyAddon[];
|
|
767
|
-
warnings: AddonWarning[];
|
|
768
|
-
};
|
|
769
|
-
/**
|
|
770
|
-
* Recursively walk a field tree, validating each field's addons. Returns a
|
|
771
|
-
* sanitized copy of the input field array plus accumulated warnings.
|
|
772
|
-
*/
|
|
773
|
-
declare function walkAndValidateAddons(fields: readonly FieldDef<unknown>[], fieldRegistry: ReadonlyMap<string, FieldTypeDefinition>, kindRegistry: ReadonlyMap<string, AddonKindDefinition>, source: 'json' | 'inline'): {
|
|
774
|
-
fields: FieldDef<unknown>[];
|
|
775
|
-
warnings: AddonWarning[];
|
|
776
|
-
};
|
|
777
603
|
|
|
778
604
|
/** Options accepted by {@link sanitizeFormConfig}. */
|
|
779
605
|
interface SanitizeFormConfigOptions {
|
|
@@ -792,7 +618,7 @@ interface SanitizedFormConfig {
|
|
|
792
618
|
}
|
|
793
619
|
/**
|
|
794
620
|
* Walk a `FormConfig`, validate every field's addons against the active
|
|
795
|
-
* `FIELD_REGISTRY` and `
|
|
621
|
+
* `FIELD_REGISTRY` and `ADDON_TYPE_REGISTRY`, and return a sanitized copy
|
|
796
622
|
* plus a list of dropped-addon warnings.
|
|
797
623
|
*
|
|
798
624
|
* @Component({ ... })
|
|
@@ -808,28 +634,18 @@ interface SanitizedFormConfig {
|
|
|
808
634
|
* ```
|
|
809
635
|
*/
|
|
810
636
|
declare function sanitizeFormConfig(config: FormConfig, options?: SanitizeFormConfigOptions): SanitizedFormConfig;
|
|
811
|
-
/**
|
|
812
|
-
* Default warning sink. Pass a `DynamicFormLogger` to route through the
|
|
813
|
-
* form's configured logger (respects `NoopLogger` opt-out); omit it to
|
|
814
|
-
* fall back to `console.warn` for build-time / admin-UI use cases that
|
|
815
|
-
* run outside an Angular injection context.
|
|
816
|
-
*/
|
|
817
|
-
declare function logAddonWarnings(warnings: readonly AddonWarning[], logger?: Logger): void;
|
|
818
|
-
/**
|
|
819
|
-
* DI-free variant of {@link sanitizeFormConfig} for tooling that lives
|
|
820
|
-
* outside Angular's injector — build-time linters, MCP-side checks, CLI
|
|
821
|
-
* scripts.
|
|
822
|
-
*/
|
|
823
|
-
declare function sanitizeFormConfigPure(config: FormConfig, fieldRegistry: ReadonlyMap<string, _ng_forge_dynamic_forms_internal.FieldTypeDefinition>, kindRegistry: ReadonlyMap<string, _ng_forge_dynamic_forms_internal.AddonKindDefinition>, options?: SanitizeFormConfigOptions): SanitizedFormConfig;
|
|
824
637
|
|
|
825
|
-
|
|
638
|
+
/** Event dispatched to submit the form (the action behind a `submit` button). */
|
|
639
|
+
declare class FormSubmitEvent implements FormEvent {
|
|
826
640
|
readonly type: "submit";
|
|
827
641
|
}
|
|
828
642
|
|
|
643
|
+
/** Event dispatched to advance a paged form to the next page. */
|
|
829
644
|
declare class NextPageEvent implements FormEvent {
|
|
830
645
|
readonly type: "next-page";
|
|
831
646
|
}
|
|
832
647
|
|
|
648
|
+
/** Event dispatched to return a paged form to the previous page. */
|
|
833
649
|
declare class PreviousPageEvent implements FormEvent {
|
|
834
650
|
readonly type: "previous-page";
|
|
835
651
|
}
|
|
@@ -1062,29 +878,5 @@ interface ArrayItemContext {
|
|
|
1062
878
|
formValue?: unknown;
|
|
1063
879
|
}
|
|
1064
880
|
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
*
|
|
1068
|
-
* @typeParam TFields - The field definitions array (narrowed via `as const`)
|
|
1069
|
-
* @typeParam TProps - Optional form-level default props type
|
|
1070
|
-
* @param config - The form configuration object
|
|
1071
|
-
* @returns The same configuration with proper type inference
|
|
1072
|
-
*/
|
|
1073
|
-
declare function formConfig<const TFields extends NarrowFields, TProps extends object = Record<string, unknown>>(config: Omit<FormConfig<TFields, InferFormValue$1<TFields>, TProps>, 'schema'> & {
|
|
1074
|
-
schema?: FormSchema<InferFormValue$1<TFields>>;
|
|
1075
|
-
}): FormConfig<TFields, InferFormValue$1<TFields>, TProps>;
|
|
1076
|
-
|
|
1077
|
-
/**
|
|
1078
|
-
* Creates a typed field configuration with helpful error messages for common mistakes.
|
|
1079
|
-
*
|
|
1080
|
-
* @param type - The field type (e.g., 'input', 'select', 'group')
|
|
1081
|
-
* @param config - The field configuration (excluding the 'type' property)
|
|
1082
|
-
* @returns A properly typed field configuration
|
|
1083
|
-
* @throws DynamicFormError if the configuration contains common mistakes
|
|
1084
|
-
*/
|
|
1085
|
-
declare function createField<T extends AvailableFieldTypes>(type: T, config: Omit<ExtractField<T>, 'type'>): ExtractField<T>;
|
|
1086
|
-
/** Shorthand alias for createField */
|
|
1087
|
-
declare const field: typeof createField;
|
|
1088
|
-
|
|
1089
|
-
export { ADDON_ACTION_HANDLERS, ADDON_ACTION_REGISTRY, ADDON_KIND_COMPONENT_CACHE, ADDON_KIND_DEFINITIONS, AppendArrayItemEvent, BUILT_IN_FIELDS, ComponentAddonComponent, ConsoleLogger, DfAddonSlot, DfTemplate, DynamicForm, EventDispatcher, FormClearEvent, FormResetEvent, InsertArrayItemEvent, MoveArrayItemEvent, NextPageEvent, PageChangeEvent, PopArrayItemEvent, PrependArrayItemEvent, PreviousPageEvent, RemoveAtIndexEvent, ShiftArrayItemEvent, SubmitEvent, TemplateAddonComponent, TextAddonComponent, arrayEvent, createField, createWrappers, field, formConfig, formatAddonWarning, injectAddonKindRegistry, injectFieldsSupportingAddons, isWrappersBundle, logAddonWarnings, provideAddonActions, provideDynamicForm, runPresetAction, sanitizeFormConfig, sanitizeFormConfigPure, validateFieldAddons, walkAndValidateAddons, withCustomAddon, withEventFormValue, withLegacyStatusClasses, withLoggerConfig, withValidationExecutionDefaults, withValueExclusionDefaults, wrapperProps };
|
|
1090
|
-
export type { AddonActionHandler, AddonActionsFeature, AddonWarning, ArrayItemContext, ArrayItemDefinitionTemplate, ExtractFieldDefs, ExtractFormValue, FieldAddonSupportEntry, InferWrapperRegistry, PresetCollaborators, SanitizeFormConfigOptions, SanitizedFormConfig, WrapperRegistration, WrappersBundle };
|
|
881
|
+
export { AppendArrayItemEvent, BUILT_IN_FIELDS, ComponentAddonComponent, ConsoleLogger, DfTemplate, DynamicForm, EventDispatcher, FormClearEvent, FormResetEvent, FormSubmitEvent, InsertArrayItemEvent, MoveArrayItemEvent, NextPageEvent, PageChangeEvent, PopArrayItemEvent, PrependArrayItemEvent, PreviousPageEvent, RemoveAtIndexEvent, ShiftArrayItemEvent, TemplateAddonComponent, TextAddonComponent, arrayEvent, createWrappers, isWrappersBundle, provideDynamicForm, sanitizeFormConfig, withAddonActions, withCustomAddon, withEventFormValue, withLegacyStatusClasses, withLoggerConfig, withValidationExecutionDefaults, withValueExclusionDefaults, wrapperProps };
|
|
882
|
+
export type { AddonActionsFeature, AddonWarning, ArrayItemContext, ArrayItemDefinitionTemplate, ExtractFieldDefs, ExtractFormValue, InferWrapperRegistry, SanitizeFormConfigOptions, SanitizedFormConfig, WrapperRegistration, WrappersBundle };
|