@ng-forge/dynamic-forms 0.1.3 → 0.2.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/fesm2022/ng-forge-dynamic-forms-integration.mjs +48 -4
- package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -1
- package/fesm2022/{ng-forge-dynamic-forms-ng-forge-dynamic-forms-B_676NHl.mjs → ng-forge-dynamic-forms-ng-forge-dynamic-forms-CZBdtTAU.mjs} +302 -301
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-CZBdtTAU.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-page-field.component-YHFQcpCS.mjs → ng-forge-dynamic-forms-page-field.component-BM32StxL.mjs} +6 -6
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-BM32StxL.mjs.map +1 -0
- package/fesm2022/{ng-forge-dynamic-forms-testing-test-button.harness-BenmCFcM.mjs → ng-forge-dynamic-forms-testing-test-button.harness-CbctXjtc.mjs} +4 -4
- package/fesm2022/{ng-forge-dynamic-forms-testing-test-button.harness-BenmCFcM.mjs.map → ng-forge-dynamic-forms-testing-test-button.harness-CbctXjtc.mjs.map} +1 -1
- package/fesm2022/ng-forge-dynamic-forms-testing.mjs +32 -29
- package/fesm2022/ng-forge-dynamic-forms-testing.mjs.map +1 -1
- package/fesm2022/{ng-forge-dynamic-forms-text-field.component-CiYq73aF.mjs → ng-forge-dynamic-forms-text-field.component-C0I8jf9T.mjs} +5 -5
- package/fesm2022/{ng-forge-dynamic-forms-text-field.component-CiYq73aF.mjs.map → ng-forge-dynamic-forms-text-field.component-C0I8jf9T.mjs.map} +1 -1
- package/fesm2022/ng-forge-dynamic-forms.mjs +1 -1
- package/package.json +4 -4
- package/types/ng-forge-dynamic-forms-integration.d.ts +14 -2
- package/types/ng-forge-dynamic-forms-testing.d.ts +35 -34
- package/types/ng-forge-dynamic-forms.d.ts +66 -89
- package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-B_676NHl.mjs.map +0 -1
- package/fesm2022/ng-forge-dynamic-forms-page-field.component-YHFQcpCS.mjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Provider, Injector, WritableSignal, Type } from '@angular/core';
|
|
1
3
|
import { Mock } from 'vitest';
|
|
2
|
-
import {
|
|
4
|
+
import { Logger, FieldDef, FormConfig, DynamicForm, ValidationMessages, FieldSignalContext, RegisteredFieldTypes } from '@ng-forge/dynamic-forms';
|
|
3
5
|
import { ComponentFixture } from '@angular/core/testing';
|
|
4
6
|
import { ValidationError, form, FieldTree } from '@angular/forms/signals';
|
|
5
|
-
import * as _angular_core from '@angular/core';
|
|
6
|
-
import { Injector, WritableSignal, Type } from '@angular/core';
|
|
7
7
|
import { Observable } from 'rxjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -31,7 +31,7 @@ declare function delay(ms?: number): Promise<void>;
|
|
|
31
31
|
/**
|
|
32
32
|
* Mock logger with vitest spies for testing.
|
|
33
33
|
*/
|
|
34
|
-
interface MockLogger extends
|
|
34
|
+
interface MockLogger extends Logger {
|
|
35
35
|
debug: Mock;
|
|
36
36
|
info: Mock;
|
|
37
37
|
warn: Mock;
|
|
@@ -43,10 +43,10 @@ interface MockLogger extends DynamicFormLogger {
|
|
|
43
43
|
*/
|
|
44
44
|
declare function createMockLogger(): MockLogger;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* Provider for a console logger in tests.
|
|
47
|
+
* Add this to TestBed.configureTestingModule providers when not using provideDynamicForm().
|
|
48
48
|
*/
|
|
49
|
-
declare function
|
|
49
|
+
declare function provideTestLogger(): Provider;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Configuration for creating a dynamic form test
|
|
@@ -68,7 +68,7 @@ interface DynamicFormTestResult {
|
|
|
68
68
|
*/
|
|
69
69
|
declare class FormConfigBuilder {
|
|
70
70
|
private fields;
|
|
71
|
-
field(field: FieldDef<
|
|
71
|
+
field(field: FieldDef<unknown>): FormConfigBuilder;
|
|
72
72
|
inputField(key: string, props?: Record<string, unknown>): FormConfigBuilder;
|
|
73
73
|
requiredInputField(key: string, props?: Record<string, unknown>): FormConfigBuilder;
|
|
74
74
|
selectField(key: string, options: Array<{
|
|
@@ -76,10 +76,10 @@ declare class FormConfigBuilder {
|
|
|
76
76
|
label: string;
|
|
77
77
|
}>, props?: Record<string, unknown>): FormConfigBuilder;
|
|
78
78
|
checkboxField(key: string, props?: Record<string, unknown>): FormConfigBuilder;
|
|
79
|
-
rowField(key: string, fields: FieldDef<
|
|
80
|
-
groupField(key: string, fields: FieldDef<
|
|
79
|
+
rowField(key: string, fields: FieldDef<unknown>[]): FormConfigBuilder;
|
|
80
|
+
groupField(key: string, fields: FieldDef<unknown>[]): FormConfigBuilder;
|
|
81
81
|
buttonField(key: string, props?: Record<string, unknown>): FormConfigBuilder;
|
|
82
|
-
pageField(key: string, fields: FieldDef<
|
|
82
|
+
pageField(key: string, fields: FieldDef<unknown>[], title?: string): FormConfigBuilder;
|
|
83
83
|
build(): FormConfig;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
@@ -257,7 +257,7 @@ declare function createTestFieldContext<TModel extends Record<string, unknown> =
|
|
|
257
257
|
* Simple form configuration interface for testing
|
|
258
258
|
*/
|
|
259
259
|
interface TestFormConfig$1 {
|
|
260
|
-
fields: FieldDef<
|
|
260
|
+
fields: FieldDef<unknown>[];
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
263
263
|
* Configuration for creating a dynamic form test
|
|
@@ -267,18 +267,19 @@ interface SimpleTestConfig<T = Record<string, unknown>> {
|
|
|
267
267
|
initialValue?: T;
|
|
268
268
|
}
|
|
269
269
|
/**
|
|
270
|
-
* Result of creating a dynamic form test
|
|
270
|
+
* Result of creating a dynamic form test.
|
|
271
|
+
* Uses the base DynamicForm type without generic constraints for flexibility in tests.
|
|
271
272
|
*/
|
|
272
273
|
interface SimpleTestResult {
|
|
273
|
-
component:
|
|
274
|
-
fixture:
|
|
274
|
+
component: DynamicForm<RegisteredFieldTypes[]>;
|
|
275
|
+
fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[]>>;
|
|
275
276
|
}
|
|
276
277
|
/**
|
|
277
278
|
* Fluent API for building form configurations using existing field structure
|
|
278
279
|
*/
|
|
279
280
|
declare class TestFormConfigBuilder<T = Record<string, unknown>> {
|
|
280
281
|
private fields;
|
|
281
|
-
field(field: FieldDef<
|
|
282
|
+
field(field: FieldDef<unknown>): TestFormConfigBuilder<T>;
|
|
282
283
|
inputField(key: string, props?: Record<string, unknown>): TestFormConfigBuilder<T>;
|
|
283
284
|
requiredInputField(key: string, props?: Record<string, unknown>): TestFormConfigBuilder<T>;
|
|
284
285
|
checkboxField(key: string, props?: Record<string, unknown>): TestFormConfigBuilder<T>;
|
|
@@ -299,58 +300,58 @@ declare class SimpleTestUtils {
|
|
|
299
300
|
/**
|
|
300
301
|
* Waits for the dynamic form to initialize
|
|
301
302
|
*/
|
|
302
|
-
static waitForInit(fixture:
|
|
303
|
+
static waitForInit(fixture: ComponentFixture<DynamicForm>): Promise<void>;
|
|
303
304
|
/**
|
|
304
305
|
* Simulates user input on a field element
|
|
305
306
|
*/
|
|
306
|
-
static simulateInput(fixture:
|
|
307
|
+
static simulateInput(fixture: ComponentFixture<DynamicForm>, selector: string, value: string): Promise<void>;
|
|
307
308
|
/**
|
|
308
309
|
* Simulates checkbox toggle
|
|
309
310
|
*/
|
|
310
|
-
static simulateCheckbox(fixture:
|
|
311
|
+
static simulateCheckbox(fixture: ComponentFixture<DynamicForm>, selector: string, checked: boolean): Promise<void>;
|
|
311
312
|
/**
|
|
312
313
|
* Gets the current form value from the component
|
|
313
314
|
*/
|
|
314
|
-
static getFormValue(component:
|
|
315
|
+
static getFormValue(component: DynamicForm): Record<string, unknown> | undefined;
|
|
315
316
|
/**
|
|
316
317
|
* Checks if the form is valid
|
|
317
318
|
*/
|
|
318
|
-
static isFormValid(component:
|
|
319
|
+
static isFormValid(component: DynamicForm): boolean;
|
|
319
320
|
/**
|
|
320
321
|
* Asserts that the form has a specific value
|
|
321
322
|
*/
|
|
322
|
-
static assertFormValue(component:
|
|
323
|
+
static assertFormValue(component: DynamicForm, expectedValue: Record<string, unknown>): void;
|
|
323
324
|
}
|
|
324
325
|
declare class TestFieldComponent {
|
|
325
|
-
|
|
326
|
+
field: _angular_core.InputSignal<unknown>;
|
|
326
327
|
key: _angular_core.InputSignal<string>;
|
|
327
328
|
label: _angular_core.InputSignal<string>;
|
|
328
329
|
className: _angular_core.InputSignal<string>;
|
|
329
330
|
tabIndex: _angular_core.InputSignal<number | undefined>;
|
|
330
331
|
props: _angular_core.InputSignal<Record<string, unknown> | undefined>;
|
|
331
332
|
placeholder: _angular_core.InputSignal<string>;
|
|
332
|
-
fields: _angular_core.InputSignal<unknown[]>;
|
|
333
333
|
arrayContext: _angular_core.InputSignal<unknown>;
|
|
334
|
+
fields: _angular_core.InputSignal<unknown[]>;
|
|
334
335
|
validationMessages: _angular_core.InputSignal<Record<string, string> | undefined>;
|
|
335
336
|
defaultValidationMessages: _angular_core.InputSignal<Record<string, string> | undefined>;
|
|
336
|
-
|
|
337
|
+
value: _angular_core.WritableSignal<string>;
|
|
337
338
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TestFieldComponent, never>;
|
|
338
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<TestFieldComponent, "df-test-field", never, { "
|
|
339
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<TestFieldComponent, "df-test-field", never, { "field": { "alias": "field"; "required": false; "isSignal": true; }; "key": { "alias": "key"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "className": { "alias": "className"; "required": false; "isSignal": true; }; "tabIndex": { "alias": "tabIndex"; "required": false; "isSignal": true; }; "props": { "alias": "props"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "arrayContext": { "alias": "arrayContext"; "required": false; "isSignal": true; }; "fields": { "alias": "fields"; "required": false; "isSignal": true; }; "validationMessages": { "alias": "validationMessages"; "required": false; "isSignal": true; }; "defaultValidationMessages": { "alias": "defaultValidationMessages"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
339
340
|
}
|
|
340
341
|
/**
|
|
341
342
|
* Configuration for setting up a simple component test
|
|
342
343
|
*/
|
|
343
|
-
interface SimpleComponentTestConfig<T =
|
|
344
|
-
field: FieldDef<
|
|
344
|
+
interface SimpleComponentTestConfig<T = unknown> {
|
|
345
|
+
field: FieldDef<unknown>;
|
|
345
346
|
value?: T;
|
|
346
347
|
pageIndex?: number;
|
|
347
348
|
isVisible?: boolean;
|
|
348
|
-
[key: string]:
|
|
349
|
+
[key: string]: unknown;
|
|
349
350
|
}
|
|
350
351
|
/**
|
|
351
352
|
* Result of setting up a simple component test
|
|
352
353
|
*/
|
|
353
|
-
interface SimpleComponentTestResult<T =
|
|
354
|
+
interface SimpleComponentTestResult<T = unknown> {
|
|
354
355
|
component: T;
|
|
355
356
|
fixture: ComponentFixture<T>;
|
|
356
357
|
}
|
|
@@ -361,13 +362,13 @@ declare function setupSimpleTest<T>(componentType: Type<T>, config: SimpleCompon
|
|
|
361
362
|
/**
|
|
362
363
|
* Creates a simple test field definition
|
|
363
364
|
*/
|
|
364
|
-
declare function createSimpleTestField(key: string, label: string): FieldDef<
|
|
365
|
+
declare function createSimpleTestField(key: string, label: string): FieldDef<unknown>;
|
|
365
366
|
|
|
366
367
|
/**
|
|
367
368
|
* Simple form configuration interface for testing
|
|
368
369
|
*/
|
|
369
370
|
interface TestFormConfig {
|
|
370
|
-
fields: FieldDef<
|
|
371
|
+
fields: FieldDef<unknown>[];
|
|
371
372
|
}
|
|
372
373
|
/**
|
|
373
374
|
* Unified configuration for creating dynamic form tests
|
|
@@ -390,7 +391,7 @@ interface TestResult<T = unknown> {
|
|
|
390
391
|
* Configuration for setting up individual field component tests
|
|
391
392
|
*/
|
|
392
393
|
interface ComponentTestConfig<T = unknown> {
|
|
393
|
-
field: FieldDef<
|
|
394
|
+
field: FieldDef<unknown>;
|
|
394
395
|
value?: T;
|
|
395
396
|
}
|
|
396
397
|
/**
|
|
@@ -561,5 +562,5 @@ declare const SPANISH_TEST_TRANSLATIONS: {
|
|
|
561
562
|
*/
|
|
562
563
|
declare function createTestTranslationService(initialTranslations?: Record<string, string>): FakeTranslationService;
|
|
563
564
|
|
|
564
|
-
export { DEFAULT_TEST_TRANSLATIONS, DynamicFormTestUtils, FakeTranslationService, FormConfigBuilder, SPANISH_TEST_TRANSLATIONS, TestFormConfigBuilder as SimpleFormConfigBuilder, SimpleTestUtils, TestCheckboxHarness as TestCheckboxHarnessComponent, TestFieldComponent, TestInputHarness as TestInputHarnessComponent, TestSelectHarness as TestSelectHarnessComponent, createMockLogger,
|
|
565
|
+
export { DEFAULT_TEST_TRANSLATIONS, DynamicFormTestUtils, FakeTranslationService, FormConfigBuilder, SPANISH_TEST_TRANSLATIONS, TestFormConfigBuilder as SimpleFormConfigBuilder, SimpleTestUtils, TestCheckboxHarness as TestCheckboxHarnessComponent, TestFieldComponent, TestInputHarness as TestInputHarnessComponent, TestSelectHarness as TestSelectHarnessComponent, createMockLogger, createSimpleTestField, createTestFieldContext, createTestFormInjector, createTestTranslationService, delay, provideTestLogger, setupSimpleTest, testMapper };
|
|
565
566
|
export type { ComponentTestConfig, ComponentTestResult, DynamicFormTestConfig, DynamicFormTestResult, MockLogger, SimpleComponentTestConfig, SimpleComponentTestResult, SimpleTestConfig, SimpleTestResult, TestConfig, TestFieldContextConfig, TestFormConfig, TestResult };
|
|
@@ -236,7 +236,7 @@ type IncludedKeys = 'label' | 'className' | 'hidden' | 'tabIndex';
|
|
|
236
236
|
*
|
|
237
237
|
* @public
|
|
238
238
|
*/
|
|
239
|
-
type FieldComponent<T extends FieldDef<
|
|
239
|
+
type FieldComponent<T extends FieldDef<Record<string, unknown> | unknown>> = Prettify<WithInputSignals<Pick<T, IncludedKeys>>>;
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
242
|
* Re-export Angular's ValidationError for consistency
|
|
@@ -707,10 +707,10 @@ type NarrowField<T> = T extends {
|
|
|
707
707
|
type NarrowFields = readonly NarrowField<RegisteredFieldTypes>[];
|
|
708
708
|
|
|
709
709
|
/**
|
|
710
|
-
* Helper type to convert union to intersection
|
|
711
|
-
*
|
|
710
|
+
* Helper type to convert union to intersection.
|
|
711
|
+
* Uses `U extends U` to trigger distributive conditional type behavior.
|
|
712
712
|
*/
|
|
713
|
-
type UnionToIntersection<U> = (U extends
|
|
713
|
+
type UnionToIntersection<U> = (U extends U ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
714
714
|
/**
|
|
715
715
|
* Depth counter for recursion limiting (prevents infinite type instantiation)
|
|
716
716
|
*/
|
|
@@ -928,8 +928,8 @@ interface SchemaDefinition {
|
|
|
928
928
|
* - Field state: `ctx.state` (errors, touched, dirty, etc.)
|
|
929
929
|
* - Other field values: `ctx.valueOf(path)` where path is a FieldPath
|
|
930
930
|
* - Other field states: `ctx.stateOf(path)`
|
|
931
|
-
* - Other fields: `ctx.
|
|
932
|
-
* - Current field tree: `ctx.
|
|
931
|
+
* - Other fields: `ctx.fieldTreeOf(path)`
|
|
932
|
+
* - Current field tree: `ctx.fieldTree`
|
|
933
933
|
*
|
|
934
934
|
* **Return Types:**
|
|
935
935
|
* - Single error: `{ kind: 'errorKind' }` for field-level validation
|
|
@@ -1184,7 +1184,7 @@ interface HttpCustomValidator<TValue = unknown, TResult = unknown> {
|
|
|
1184
1184
|
* Interface for dynamic forms logger implementations.
|
|
1185
1185
|
* Allows custom logging integrations (Sentry, DataDog, etc.)
|
|
1186
1186
|
*/
|
|
1187
|
-
interface
|
|
1187
|
+
interface Logger {
|
|
1188
1188
|
/**
|
|
1189
1189
|
* Log a debug message.
|
|
1190
1190
|
* Use for detailed diagnostic information during development.
|
|
@@ -1217,7 +1217,7 @@ interface EvaluationContext<TValue = unknown> {
|
|
|
1217
1217
|
/** Custom evaluation functions */
|
|
1218
1218
|
customFunctions?: Record<string, (context: EvaluationContext) => unknown>;
|
|
1219
1219
|
/** Logger for diagnostic output */
|
|
1220
|
-
logger:
|
|
1220
|
+
logger: Logger;
|
|
1221
1221
|
/** Allow additional properties for flexible expression evaluation */
|
|
1222
1222
|
[key: string]: unknown;
|
|
1223
1223
|
}
|
|
@@ -1956,7 +1956,10 @@ interface FieldTypeDefinition<T extends FieldDef<any> = any> {
|
|
|
1956
1956
|
name: string;
|
|
1957
1957
|
/** Field definition type marker (internal use) */
|
|
1958
1958
|
_fieldDef?: T;
|
|
1959
|
-
/**
|
|
1959
|
+
/**
|
|
1960
|
+
* Function to load the component (supports lazy loading)
|
|
1961
|
+
* Returns a Promise that resolves to the component class or module with default export
|
|
1962
|
+
*/
|
|
1960
1963
|
loadComponent?: () => Promise<any>;
|
|
1961
1964
|
/** Mapper function that converts field definition to component bindings */
|
|
1962
1965
|
mapper: MapperFn<T>;
|
|
@@ -2330,9 +2333,11 @@ type ExtractFieldDef<T> = T extends FieldTypeDefinition<infer F> ? F : never;
|
|
|
2330
2333
|
type FieldDefUnion<T extends FieldTypeDefinition[]> = ExtractFieldDef<T[number]>;
|
|
2331
2334
|
/**
|
|
2332
2335
|
* Infer form value type from field definitions
|
|
2336
|
+
* Note: Full value type inference requires complex recursive type mapping.
|
|
2337
|
+
* Using unknown as placeholder until full inference is implemented.
|
|
2333
2338
|
*/
|
|
2334
|
-
type InferFormValue<TFieldDefs extends FieldDef<
|
|
2335
|
-
[K in TFieldDefs[number]['key']]:
|
|
2339
|
+
type InferFormValue<TFieldDefs extends FieldDef<unknown>[]> = {
|
|
2340
|
+
[K in TFieldDefs[number]['key']]: unknown;
|
|
2336
2341
|
};
|
|
2337
2342
|
/**
|
|
2338
2343
|
* Provider result with type inference
|
|
@@ -2357,7 +2362,7 @@ type ExtractFieldTypes<T extends FieldTypeOrFeature[]> = {
|
|
|
2357
2362
|
* This function creates environment providers that can be used at application or route level
|
|
2358
2363
|
* to register field types. It provides type-safe field registration with automatic type inference.
|
|
2359
2364
|
*
|
|
2360
|
-
* @param items - Field type definitions and/or features (like
|
|
2365
|
+
* @param items - Field type definitions and/or features (like withLoggerConfig)
|
|
2361
2366
|
* @returns Environment providers for dependency injection with type inference
|
|
2362
2367
|
*
|
|
2363
2368
|
* @example
|
|
@@ -2372,12 +2377,12 @@ type ExtractFieldTypes<T extends FieldTypeOrFeature[]> = {
|
|
|
2372
2377
|
*
|
|
2373
2378
|
* @example
|
|
2374
2379
|
* ```typescript
|
|
2375
|
-
* //
|
|
2380
|
+
* // Disable logging
|
|
2376
2381
|
* bootstrapApplication(AppComponent, {
|
|
2377
2382
|
* providers: [
|
|
2378
2383
|
* provideDynamicForm(
|
|
2379
2384
|
* ...withMaterialFields(),
|
|
2380
|
-
*
|
|
2385
|
+
* withLoggerConfig(false)
|
|
2381
2386
|
* )
|
|
2382
2387
|
* ]
|
|
2383
2388
|
* });
|
|
@@ -2385,18 +2390,6 @@ type ExtractFieldTypes<T extends FieldTypeOrFeature[]> = {
|
|
|
2385
2390
|
*
|
|
2386
2391
|
* @example
|
|
2387
2392
|
* ```typescript
|
|
2388
|
-
* // Route-level setup
|
|
2389
|
-
* const routes: Routes = [
|
|
2390
|
-
* {
|
|
2391
|
-
* path: 'form',
|
|
2392
|
-
* component: FormComponent,
|
|
2393
|
-
* providers: [provideDynamicForm(...withMaterialFields())]
|
|
2394
|
-
* }
|
|
2395
|
-
* ];
|
|
2396
|
-
* ```
|
|
2397
|
-
*
|
|
2398
|
-
* @example
|
|
2399
|
-
* ```typescript
|
|
2400
2393
|
* // Custom field types with type inference
|
|
2401
2394
|
* import { CustomFieldType, AnotherFieldType } from './custom-fields';
|
|
2402
2395
|
*
|
|
@@ -2456,93 +2449,65 @@ type ExtractFormValue<T> = T extends {
|
|
|
2456
2449
|
* { type: 'page', key: 'step1', fields: [...] }
|
|
2457
2450
|
* ```
|
|
2458
2451
|
*/
|
|
2459
|
-
declare const BUILT_IN_FIELDS: FieldTypeDefinition[];
|
|
2460
|
-
|
|
2461
2452
|
/**
|
|
2462
|
-
*
|
|
2463
|
-
* Each level includes all levels above it (more severe).
|
|
2453
|
+
* Built-in field types provided by the dynamic form library.
|
|
2464
2454
|
*
|
|
2465
|
-
*
|
|
2466
|
-
*
|
|
2467
|
-
*
|
|
2468
|
-
* - Info: Errors + warnings + info
|
|
2469
|
-
* - Debug: All messages including debug
|
|
2455
|
+
* Each field type is validated at compile time using satisfies, ensuring
|
|
2456
|
+
* type safety of the mapper function while allowing the array to be typed
|
|
2457
|
+
* as FieldTypeDefinition[] for consumer flexibility.
|
|
2470
2458
|
*/
|
|
2471
|
-
declare
|
|
2472
|
-
/** Disable all logging */
|
|
2473
|
-
Off = 0,
|
|
2474
|
-
/** Only log errors */
|
|
2475
|
-
Error = 1,
|
|
2476
|
-
/** Log errors and warnings */
|
|
2477
|
-
Warn = 2,
|
|
2478
|
-
/** Log errors, warnings, and info messages */
|
|
2479
|
-
Info = 3,
|
|
2480
|
-
/** Log all messages including debug */
|
|
2481
|
-
Debug = 4
|
|
2482
|
-
}
|
|
2459
|
+
declare const BUILT_IN_FIELDS: FieldTypeDefinition[];
|
|
2483
2460
|
|
|
2484
|
-
/**
|
|
2485
|
-
* Configuration options for the logger feature
|
|
2486
|
-
*/
|
|
2487
|
-
interface LoggerFeatureOptions {
|
|
2488
|
-
/**
|
|
2489
|
-
* Log level to use. Messages below this level will be filtered.
|
|
2490
|
-
* @default LogLevel.Warn in dev, LogLevel.Off in prod
|
|
2491
|
-
*/
|
|
2492
|
-
level?: LogLevel;
|
|
2493
|
-
/**
|
|
2494
|
-
* Custom logger implementation.
|
|
2495
|
-
* Use this to integrate with external logging services (Sentry, DataDog, etc.)
|
|
2496
|
-
* If provided, `level` is ignored - your implementation controls filtering.
|
|
2497
|
-
*/
|
|
2498
|
-
logger?: DynamicFormLogger;
|
|
2499
|
-
}
|
|
2500
2461
|
/**
|
|
2501
2462
|
* Configure logging for dynamic forms.
|
|
2502
2463
|
*
|
|
2464
|
+
* By default, logging is enabled (ConsoleLogger). Use this feature to disable logging
|
|
2465
|
+
* or configure it conditionally.
|
|
2466
|
+
*
|
|
2503
2467
|
* @example
|
|
2504
2468
|
* ```typescript
|
|
2505
|
-
* //
|
|
2506
|
-
* provideDynamicForm(
|
|
2507
|
-
* ...withMaterialFields(),
|
|
2508
|
-
* withLogger({ level: LogLevel.Debug })
|
|
2509
|
-
* )
|
|
2510
|
-
*
|
|
2511
|
-
* // Disable logging entirely
|
|
2469
|
+
* // Disable logging
|
|
2512
2470
|
* provideDynamicForm(
|
|
2513
2471
|
* ...withMaterialFields(),
|
|
2514
|
-
*
|
|
2472
|
+
* withLoggerConfig(false)
|
|
2515
2473
|
* )
|
|
2516
2474
|
*
|
|
2517
|
-
* //
|
|
2475
|
+
* // Conditional logging (e.g., only in dev mode)
|
|
2518
2476
|
* provideDynamicForm(
|
|
2519
2477
|
* ...withMaterialFields(),
|
|
2520
|
-
*
|
|
2478
|
+
* withLoggerConfig(() => isDevMode())
|
|
2521
2479
|
* )
|
|
2522
2480
|
* ```
|
|
2523
2481
|
*
|
|
2524
|
-
* @param
|
|
2482
|
+
* @param enabled - Whether logging is enabled. Can be a boolean or a function that returns a boolean. Defaults to true.
|
|
2525
2483
|
* @returns A DynamicFormFeature that configures logging
|
|
2526
2484
|
*/
|
|
2527
|
-
declare function
|
|
2485
|
+
declare function withLoggerConfig(enabled?: boolean | (() => boolean)): DynamicFormFeature<'logger'>;
|
|
2528
2486
|
|
|
2529
2487
|
/**
|
|
2530
2488
|
* Injection token for the dynamic forms logger.
|
|
2531
2489
|
*
|
|
2532
|
-
*
|
|
2533
|
-
*
|
|
2534
|
-
* - Production mode: NoopLogger (silent)
|
|
2535
|
-
*
|
|
2536
|
-
* Override by providing a custom logger via withLogger() feature
|
|
2537
|
-
* or by providing directly to this token.
|
|
2490
|
+
* Provided by provideDynamicForm() with ConsoleLogger as default.
|
|
2491
|
+
* Override with withLoggerConfig(false) to disable logging.
|
|
2538
2492
|
*/
|
|
2539
|
-
declare const
|
|
2493
|
+
declare const DynamicFormLogger: InjectionToken<Logger>;
|
|
2494
|
+
|
|
2495
|
+
/**
|
|
2496
|
+
* Console-based logger implementation.
|
|
2497
|
+
*/
|
|
2498
|
+
declare class ConsoleLogger implements Logger {
|
|
2499
|
+
private readonly prefix;
|
|
2500
|
+
debug(message: string, ...args: unknown[]): void;
|
|
2501
|
+
info(message: string, ...args: unknown[]): void;
|
|
2502
|
+
warn(message: string, ...args: unknown[]): void;
|
|
2503
|
+
error(message: string, ...args: unknown[]): void;
|
|
2504
|
+
}
|
|
2540
2505
|
|
|
2541
2506
|
/**
|
|
2542
2507
|
* No-operation logger implementation.
|
|
2543
2508
|
* All methods are no-ops - used in production by default.
|
|
2544
2509
|
*/
|
|
2545
|
-
declare class NoopLogger implements
|
|
2510
|
+
declare class NoopLogger implements Logger {
|
|
2546
2511
|
debug(): void;
|
|
2547
2512
|
info(): void;
|
|
2548
2513
|
warn(): void;
|
|
@@ -2626,7 +2591,7 @@ interface ButtonLogicContext {
|
|
|
2626
2591
|
/** Current form value for evaluating conditional expressions */
|
|
2627
2592
|
formValue?: unknown;
|
|
2628
2593
|
/** Optional logger for diagnostic output. Falls back to no-op logger if not provided. */
|
|
2629
|
-
logger?:
|
|
2594
|
+
logger?: Logger;
|
|
2630
2595
|
}
|
|
2631
2596
|
/**
|
|
2632
2597
|
* Resolves the disabled state for a submit button.
|
|
@@ -2711,7 +2676,7 @@ interface BaseValueField<TProps, TValue> extends FieldDef<TProps>, FieldWithVali
|
|
|
2711
2676
|
}
|
|
2712
2677
|
declare function isValueField<TProps>(field: FieldDef<TProps>): field is BaseValueField<TProps, ValueType>;
|
|
2713
2678
|
type ExcludedKeys$1 = 'type' | 'conditionals' | 'value' | 'valueType' | 'disabled' | 'readonly' | 'hidden' | 'col' | 'minValue' | 'maxValue' | 'step' | 'required' | 'email' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern' | 'validators' | 'logic' | 'schemas';
|
|
2714
|
-
type ValueFieldComponent<T extends BaseValueField<
|
|
2679
|
+
type ValueFieldComponent<T extends BaseValueField<Record<string, unknown> | unknown, unknown>> = Prettify<WithInputSignals<Omit<T, ExcludedKeys$1>>>;
|
|
2715
2680
|
|
|
2716
2681
|
interface BaseCheckedField<TProps> extends FieldDef<TProps>, FieldWithValidation {
|
|
2717
2682
|
value?: boolean;
|
|
@@ -2724,7 +2689,7 @@ interface BaseCheckedField<TProps> extends FieldDef<TProps>, FieldWithValidation
|
|
|
2724
2689
|
}
|
|
2725
2690
|
declare function isCheckedField<TProps>(field: FieldDef<TProps>): field is BaseCheckedField<TProps>;
|
|
2726
2691
|
type ExcludedKeys = 'type' | 'conditionals' | 'value' | 'disabled' | 'readonly' | 'hidden' | 'col' | keyof FieldWithValidation;
|
|
2727
|
-
type CheckedFieldComponent<T extends BaseCheckedField<
|
|
2692
|
+
type CheckedFieldComponent<T extends BaseCheckedField<Record<string, unknown> | unknown>> = Prettify<WithInputSignals<Omit<T, ExcludedKeys>>>;
|
|
2728
2693
|
|
|
2729
2694
|
declare function applyValidator(config: ValidatorConfig, fieldPath: SchemaPath<any> | SchemaPathTree<any>): void;
|
|
2730
2695
|
declare function applyValidators(configs: ValidatorConfig[], fieldPath: SchemaPath<any> | SchemaPathTree<any>): void;
|
|
@@ -2865,7 +2830,7 @@ declare class EventBus {
|
|
|
2865
2830
|
* eventBus.dispatch(CustomFormEvent);
|
|
2866
2831
|
* ```
|
|
2867
2832
|
*/
|
|
2868
|
-
dispatch<T extends FormEventConstructor>(eventConstructor: T, ...args:
|
|
2833
|
+
dispatch<T extends FormEventConstructor>(eventConstructor: T, ...args: ConstructorParameters<T>): void;
|
|
2869
2834
|
/**
|
|
2870
2835
|
* Subscribes to events of a specific type.
|
|
2871
2836
|
*
|
|
@@ -2935,6 +2900,18 @@ interface ArrayItemContext {
|
|
|
2935
2900
|
formValue?: unknown;
|
|
2936
2901
|
}
|
|
2937
2902
|
|
|
2903
|
+
/**
|
|
2904
|
+
* Base error class for all Dynamic Forms errors.
|
|
2905
|
+
*
|
|
2906
|
+
* This class centralizes the `[Dynamic Forms]` prefix, ensuring consistent
|
|
2907
|
+
* error messaging across the library without requiring each error site to
|
|
2908
|
+
* manually include the prefix.
|
|
2909
|
+
*/
|
|
2910
|
+
declare class DynamicFormError extends Error {
|
|
2911
|
+
private static readonly PREFIX;
|
|
2912
|
+
constructor(message: string);
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2938
2915
|
/**
|
|
2939
2916
|
* Builds base input properties from a field definition.
|
|
2940
2917
|
*
|
|
@@ -3226,5 +3203,5 @@ declare function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): O
|
|
|
3226
3203
|
*/
|
|
3227
3204
|
declare function interpolateParams(message: string, error: ValidationError): string;
|
|
3228
3205
|
|
|
3229
|
-
export { ARRAY_CONTEXT, AddArrayItemEvent, ArrayFieldComponent, BUILT_IN_FIELDS,
|
|
3230
|
-
export type { ArrayAllowedChildren, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemContext, AsyncCustomValidator, AsyncValidatorConfig, AvailableFieldTypes, BaseCheckedField, BaseValidatorConfig, BaseValueField, BuiltInValidatorConfig, ButtonLogicContext, CheckedFieldComponent, ConditionalExpression, ContainerFieldTypes, CustomFnConfig, CustomValidator, CustomValidatorConfig, DynamicFormFieldRegistry,
|
|
3206
|
+
export { ARRAY_CONTEXT, AddArrayItemEvent, ArrayFieldComponent, BUILT_IN_FIELDS, ConsoleLogger, DynamicForm, DynamicFormError, DynamicFormLogger, DynamicTextPipe, EventBus, FIELD_REGISTRY, FIELD_SIGNAL_CONTEXT, FormClearEvent, FormResetEvent, GroupFieldComponent, NextPageEvent, NoopLogger, PageChangeEvent, PreviousPageEvent, RemoveArrayItemEvent, RowFieldComponent, SubmitEvent, applyValidator, applyValidators, arrayFieldMapper, baseFieldMapper, buildBaseInputs, dynamicTextToObservable, getArrayLength, groupFieldMapper, interpolateParams, isArrayField, isCheckedField, isContainerField, isDisplayOnlyField, isFormStateCondition, isGroupField, isLeafField, isPageField, isRowField, isValueBearingField, isValueField, omit, pageFieldMapper, provideDynamicForm, resolveNextButtonDisabled, resolveSubmitButtonDisabled, resolveTokens, rowFieldMapper, textFieldMapper, withLoggerConfig };
|
|
3207
|
+
export type { ArrayAllowedChildren, ArrayContext, ArrayField, ArrayFieldTree, ArrayItemContext, AsyncCustomValidator, AsyncValidatorConfig, AvailableFieldTypes, BaseCheckedField, BaseValidatorConfig, BaseValueField, BuiltInValidatorConfig, ButtonLogicContext, CheckedFieldComponent, ConditionalExpression, ContainerFieldTypes, CustomFnConfig, CustomValidator, CustomValidatorConfig, DynamicFormFieldRegistry, DynamicText, EvaluationContext, ExtractField, ExtractFieldDefs, ExtractFormValue, FieldComponent, FieldDef, FieldOption, FieldPathAccess, FieldRegistryContainers, FieldRegistryLeaves, FieldSignalContext, FieldTypeDefinition, FieldWithValidation, FormConfig, FormEvent, FormEventConstructor, FormMode, FormModeDetectionResult, FormOptions, FormStateCondition, GroupAllowedChildren, GroupField, HttpCustomValidator, HttpResourceRequest, HttpValidatorConfig, InferFormValue$1 as InferFormValue, LeafFieldTypes, Logger, LogicConfig, MapperFn, NarrowField, NarrowFields, NextButtonOptions, PageAllowedChildren, PageField, Prettify, RegisteredFieldTypes, RowAllowedChildren, RowField, SchemaApplicationConfig, SchemaDefinition, SubmissionActionResult, SubmissionConfig, SubmitButtonOptions, TextElementType, TextField, TextProps, TokenContext, ValidationError, ValidationMessages, ValidatorConfig, ValueFieldComponent, ValueHandlingMode, ValueType, WithInputSignals };
|