@ng-forge/dynamic-forms 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/README.md +3 -0
  2. package/fesm2022/ng-forge-dynamic-forms-integration.mjs +18 -52
  3. package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -1
  4. package/fesm2022/{ng-forge-dynamic-forms-ng-forge-dynamic-forms-DHxoGouT.mjs → ng-forge-dynamic-forms-ng-forge-dynamic-forms-WGww2nXx.mjs} +3401 -294
  5. package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-WGww2nXx.mjs.map +1 -0
  6. package/fesm2022/{ng-forge-dynamic-forms-page-field.component-Bt6blv9I.mjs → ng-forge-dynamic-forms-page-field.component-CrO9WTDw.mjs} +2 -2
  7. package/fesm2022/{ng-forge-dynamic-forms-page-field.component-Bt6blv9I.mjs.map → ng-forge-dynamic-forms-page-field.component-CrO9WTDw.mjs.map} +1 -1
  8. package/fesm2022/ng-forge-dynamic-forms-schema.mjs +92 -0
  9. package/fesm2022/ng-forge-dynamic-forms-schema.mjs.map +1 -0
  10. package/fesm2022/{ng-forge-dynamic-forms-text-field.component-DKCx7Z_U.mjs → ng-forge-dynamic-forms-text-field.component-BcFx_kOz.mjs} +2 -2
  11. package/fesm2022/{ng-forge-dynamic-forms-text-field.component-DKCx7Z_U.mjs.map → ng-forge-dynamic-forms-text-field.component-BcFx_kOz.mjs.map} +1 -1
  12. package/fesm2022/ng-forge-dynamic-forms.mjs +1 -1
  13. package/package.json +5 -4
  14. package/types/ng-forge-dynamic-forms-integration.d.ts +3 -14
  15. package/types/ng-forge-dynamic-forms-schema.d.ts +178 -0
  16. package/types/ng-forge-dynamic-forms.d.ts +766 -35
  17. package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-DHxoGouT.mjs.map +0 -1
  18. package/fesm2022/ng-forge-dynamic-forms-testing-test-button.harness-C79EBW0o.mjs +0 -31
  19. package/fesm2022/ng-forge-dynamic-forms-testing-test-button.harness-C79EBW0o.mjs.map +0 -1
  20. package/fesm2022/ng-forge-dynamic-forms-testing.mjs +0 -973
  21. package/fesm2022/ng-forge-dynamic-forms-testing.mjs.map +0 -1
  22. package/types/ng-forge-dynamic-forms-testing.d.ts +0 -603
@@ -1,603 +0,0 @@
1
- import * as _angular_core from '@angular/core';
2
- import { Provider, Injector, WritableSignal, Type } from '@angular/core';
3
- import { Mock } from 'vitest';
4
- import { Logger, FieldDef, FormConfig, DynamicForm, ValidationMessages, FormOptions, FieldSignalContext, RegisteredFieldTypes } from '@ng-forge/dynamic-forms';
5
- import { ComponentFixture } from '@angular/core/testing';
6
- import { ValidationError, form, FieldTree } from '@angular/forms/signals';
7
- import { Observable } from 'rxjs';
8
-
9
- /**
10
- * Creates a promise that resolves after the specified delay.
11
- *
12
- * Utility function for testing scenarios where you need to wait for
13
- * asynchronous operations, animations, or timing-dependent behavior.
14
- *
15
- * @param ms - Delay in milliseconds (defaults to 0 for next tick)
16
- * @returns Promise that resolves after the specified delay
17
- *
18
- * @example
19
- * ```typescript
20
- * // Wait for async operations in tests
21
- * await delay(100);
22
- * expect(component.isLoaded).toBe(true);
23
- *
24
- * // Wait for next tick (micro-task)
25
- * await delay();
26
- * fixture.detectChanges();
27
- * ```
28
- */
29
- declare function delay(ms?: number): Promise<void>;
30
-
31
- /**
32
- * Mock logger with vitest spies for testing.
33
- */
34
- interface MockLogger extends Logger {
35
- debug: Mock;
36
- info: Mock;
37
- warn: Mock;
38
- error: Mock;
39
- }
40
- /**
41
- * Creates a mock logger with vitest spies for all methods.
42
- * Useful for testing code that uses the logger.
43
- */
44
- declare function createMockLogger(): MockLogger;
45
- /**
46
- * Provider for a console logger in tests.
47
- * Add this to TestBed.configureTestingModule providers when not using provideDynamicForm().
48
- */
49
- declare function provideTestLogger(): Provider;
50
-
51
- /**
52
- * Configuration for creating a dynamic form test
53
- */
54
- interface DynamicFormTestConfig {
55
- config: FormConfig;
56
- initialValue?: Record<string, unknown>;
57
- registerTestFields?: boolean;
58
- }
59
- /**
60
- * Result of creating a dynamic form test
61
- */
62
- interface DynamicFormTestResult {
63
- component: DynamicForm;
64
- fixture: ComponentFixture<DynamicForm>;
65
- }
66
- /**
67
- * Fluent API for building form configurations
68
- */
69
- declare class FormConfigBuilder {
70
- private fields;
71
- field(field: FieldDef<unknown>): FormConfigBuilder;
72
- inputField(key: string, props?: Record<string, unknown>): FormConfigBuilder;
73
- requiredInputField(key: string, props?: Record<string, unknown>): FormConfigBuilder;
74
- selectField(key: string, options: Array<{
75
- value: string;
76
- label: string;
77
- }>, props?: Record<string, unknown>): FormConfigBuilder;
78
- checkboxField(key: string, props?: Record<string, unknown>): FormConfigBuilder;
79
- rowField(key: string, fields: FieldDef<unknown>[]): FormConfigBuilder;
80
- groupField(key: string, fields: FieldDef<unknown>[]): FormConfigBuilder;
81
- buttonField(key: string, props?: Record<string, unknown>): FormConfigBuilder;
82
- pageField(key: string, fields: FieldDef<unknown>[], title?: string): FormConfigBuilder;
83
- build(): FormConfig;
84
- }
85
- /**
86
- * Utility class for testing dynamic forms
87
- */
88
- declare class DynamicFormTestUtils {
89
- /**
90
- * Creates a new form config builder
91
- */
92
- static builder(): FormConfigBuilder;
93
- /**
94
- * Creates a dynamic form test setup with optional test field registration
95
- */
96
- static createTest(testConfig: DynamicFormTestConfig): Promise<DynamicFormTestResult>;
97
- /**
98
- * Registers common test field types including built-in types like page, row, group
99
- * @internal
100
- */
101
- private static registerTestFields;
102
- /**
103
- * Waits for the dynamic form to initialize.
104
- * Uses the initialized$ observable directly which has shareReplay for late subscribers.
105
- * @param fixture - The component fixture
106
- * @param timeoutMs - Maximum time to wait for initialization (default: 100ms)
107
- */
108
- static waitForInit(fixture: ComponentFixture<DynamicForm>, timeoutMs?: number): Promise<void>;
109
- /**
110
- * Waits for an element to appear in the DOM with retries
111
- */
112
- private static waitForElement;
113
- /**
114
- * Simulates user input on a field element
115
- */
116
- static simulateInput(fixture: ComponentFixture<DynamicForm>, selector: string, value: string): Promise<void>;
117
- /**
118
- * Simulates user blur on a field element
119
- */
120
- static simulateBlur(fixture: ComponentFixture<DynamicForm>, selector: string): Promise<void>;
121
- /**
122
- * Simulates user selection on a select element
123
- */
124
- static simulateSelect(fixture: ComponentFixture<DynamicForm>, selector: string, value: string): Promise<void>;
125
- /**
126
- * Simulates checkbox toggle
127
- */
128
- static simulateCheckbox(fixture: ComponentFixture<DynamicForm>, selector: string, checked: boolean): Promise<void>;
129
- /**
130
- * Simulates button click
131
- */
132
- static simulateButtonClick(fixture: ComponentFixture<DynamicForm>, selector: string): Promise<void>;
133
- /**
134
- * Gets the current form value from the component
135
- */
136
- static getFormValue(component: DynamicForm): Record<string, unknown> | undefined;
137
- /**
138
- * Gets validation errors from the component
139
- */
140
- static getFormErrors(component: DynamicForm): ValidationError[];
141
- /**
142
- * Checks if the form is valid
143
- */
144
- static isFormValid(component: DynamicForm): boolean;
145
- /**
146
- * Gets all field elements from the fixture
147
- */
148
- static getFieldElements(fixture: ComponentFixture<DynamicForm>, fieldType: string): NodeListOf<Element>;
149
- /**
150
- * Asserts that a field has a specific value
151
- */
152
- static assertFieldValue(fixture: ComponentFixture<DynamicForm>, fieldSelector: string, expectedValue: string): Promise<void>;
153
- /**
154
- * Asserts that the form has a specific value
155
- */
156
- static assertFormValue(component: DynamicForm, expectedValue: Record<string, unknown>): void;
157
- }
158
-
159
- /**
160
- * Configuration for creating a test form injector with field signal context
161
- */
162
- interface TestFieldContextConfig<TModel extends Record<string, unknown> = Record<string, unknown>> {
163
- /**
164
- * Parent injector to use. If not provided, uses an empty injector.
165
- */
166
- parentInjector?: Injector;
167
- /**
168
- * Initial value for the form. If not provided, uses an empty object.
169
- */
170
- initialValue?: Partial<TModel>;
171
- /**
172
- * Default values function. If not provided, returns the initial value.
173
- */
174
- defaultValues?: () => TModel;
175
- /**
176
- * Default validation messages for the form.
177
- * Provided via DEFAULT_VALIDATION_MESSAGES injection token.
178
- */
179
- defaultValidationMessages?: ValidationMessages;
180
- /**
181
- * Form options for button disabled state defaults.
182
- * Provided via FORM_OPTIONS injection token.
183
- */
184
- formOptions?: FormOptions;
185
- /**
186
- * Custom value signal. If provided, this will be used instead of creating a new one.
187
- */
188
- valueSignal?: WritableSignal<Partial<TModel> | undefined>;
189
- /**
190
- * Custom form instance. If provided, this will be used instead of creating a new one.
191
- */
192
- form?: ReturnType<typeof form<TModel>>;
193
- }
194
- /**
195
- * Creates a test injector with FIELD_SIGNAL_CONTEXT provided.
196
- *
197
- * This utility simplifies testing of mappers and components that inject FIELD_SIGNAL_CONTEXT.
198
- *
199
- * @example
200
- * ```typescript
201
- * // Basic usage
202
- * const testInjector = createTestFormInjector();
203
- *
204
- * // With custom initial value
205
- * const testInjector = createTestFormInjector({
206
- * initialValue: { username: 'test' }
207
- * });
208
- *
209
- * // With validation messages
210
- * const testInjector = createTestFormInjector({
211
- * defaultValidationMessages: { required: 'This field is required' }
212
- * });
213
- * ```
214
- */
215
- declare function createTestFormInjector<TModel extends Record<string, unknown> = Record<string, unknown>>(config?: TestFieldContextConfig<TModel>): Injector;
216
- /**
217
- * Runs a mapper function in a test injection context.
218
- *
219
- * This is a convenience wrapper that creates a test injector and runs the mapper
220
- * function within it, returning the result.
221
- *
222
- * @example
223
- * ```typescript
224
- * // Test a mapper without context overrides
225
- * const bindings = testMapper(() => mapValueField(fieldDef));
226
- *
227
- * // Test a mapper with custom context
228
- * const bindings = testMapper(
229
- * () => mapValueField(fieldDef),
230
- * { initialValue: { username: 'test' } }
231
- * );
232
- *
233
- * // Test a mapper with validation messages
234
- * const bindings = testMapper(
235
- * () => mapValueField(fieldDef),
236
- * { defaultValidationMessages: { required: 'Required field' } }
237
- * );
238
- * ```
239
- */
240
- declare function testMapper<T>(mapperFn: () => T, context?: TestFieldContextConfig<Record<string, unknown>>): T;
241
- /**
242
- * Creates a field signal context for testing without creating an injector.
243
- *
244
- * Useful when you need to manually provide the context or test context creation logic.
245
- *
246
- * @example
247
- * ```typescript
248
- * const context = createTestFieldContext({
249
- * initialValue: { name: 'test' }
250
- * });
251
- *
252
- * // Use in your own injector
253
- * const injector = Injector.create({
254
- * providers: [
255
- * { provide: FIELD_SIGNAL_CONTEXT, useValue: context }
256
- * ]
257
- * });
258
- * ```
259
- */
260
- declare function createTestFieldContext<TModel extends Record<string, unknown> = Record<string, unknown>>(config?: TestFieldContextConfig<TModel>): FieldSignalContext<TModel>;
261
-
262
- /**
263
- * Simple form configuration interface for testing
264
- */
265
- interface TestFormConfig$1 {
266
- fields: FieldDef<unknown>[];
267
- }
268
- /**
269
- * Configuration for creating a dynamic form test
270
- */
271
- interface SimpleTestConfig<T = Record<string, unknown>> {
272
- config: TestFormConfig$1;
273
- initialValue?: T;
274
- }
275
- /**
276
- * Result of creating a dynamic form test.
277
- * Uses the base DynamicForm type without generic constraints for flexibility in tests.
278
- */
279
- interface SimpleTestResult {
280
- component: DynamicForm<RegisteredFieldTypes[]>;
281
- fixture: ComponentFixture<DynamicForm<RegisteredFieldTypes[]>>;
282
- }
283
- /**
284
- * Fluent API for building form configurations using existing field structure
285
- */
286
- declare class TestFormConfigBuilder<T = Record<string, unknown>> {
287
- private fields;
288
- field(field: FieldDef<unknown>): TestFormConfigBuilder<T>;
289
- inputField(key: string, props?: Record<string, unknown>): TestFormConfigBuilder<T>;
290
- requiredInputField(key: string, props?: Record<string, unknown>): TestFormConfigBuilder<T>;
291
- checkboxField(key: string, props?: Record<string, unknown>): TestFormConfigBuilder<T>;
292
- build(): TestFormConfig$1;
293
- }
294
- /**
295
- * Simple utility class for testing dynamic forms
296
- */
297
- declare class SimpleTestUtils {
298
- /**
299
- * Creates a new form config builder
300
- */
301
- static builder<T = Record<string, unknown>>(): TestFormConfigBuilder<T>;
302
- /**
303
- * Creates a simple test component - assumes TestBed is already configured
304
- */
305
- static createComponent<T = Record<string, unknown>>(config?: TestFormConfig$1, initialValue?: T): SimpleTestResult;
306
- /**
307
- * Waits for the dynamic form to initialize
308
- */
309
- static waitForInit(fixture: ComponentFixture<DynamicForm>): Promise<void>;
310
- /**
311
- * Simulates user input on a field element
312
- */
313
- static simulateInput(fixture: ComponentFixture<DynamicForm>, selector: string, value: string): Promise<void>;
314
- /**
315
- * Simulates checkbox toggle
316
- */
317
- static simulateCheckbox(fixture: ComponentFixture<DynamicForm>, selector: string, checked: boolean): Promise<void>;
318
- /**
319
- * Gets the current form value from the component
320
- */
321
- static getFormValue(component: DynamicForm): Record<string, unknown> | undefined;
322
- /**
323
- * Checks if the form is valid
324
- */
325
- static isFormValid(component: DynamicForm): boolean;
326
- /**
327
- * Asserts that the form has a specific value
328
- */
329
- static assertFormValue(component: DynamicForm, expectedValue: Record<string, unknown>): void;
330
- }
331
- declare class TestFieldComponent {
332
- field: _angular_core.InputSignal<unknown>;
333
- key: _angular_core.InputSignal<string>;
334
- label: _angular_core.InputSignal<string>;
335
- className: _angular_core.InputSignal<string>;
336
- tabIndex: _angular_core.InputSignal<number | undefined>;
337
- props: _angular_core.InputSignal<Record<string, unknown> | undefined>;
338
- placeholder: _angular_core.InputSignal<string>;
339
- arrayContext: _angular_core.InputSignal<unknown>;
340
- fields: _angular_core.InputSignal<unknown[]>;
341
- validationMessages: _angular_core.InputSignal<Record<string, string> | undefined>;
342
- defaultValidationMessages: _angular_core.InputSignal<Record<string, string> | undefined>;
343
- value: _angular_core.WritableSignal<string>;
344
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<TestFieldComponent, never>;
345
- 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>;
346
- }
347
- /**
348
- * Configuration for setting up a simple component test
349
- */
350
- interface SimpleComponentTestConfig<T = unknown> {
351
- field: FieldDef<unknown>;
352
- value?: T;
353
- pageIndex?: number;
354
- isVisible?: boolean;
355
- [key: string]: unknown;
356
- }
357
- /**
358
- * Result of setting up a simple component test
359
- */
360
- interface SimpleComponentTestResult<T = unknown> {
361
- component: T;
362
- fixture: ComponentFixture<T>;
363
- }
364
- /**
365
- * Creates a simple test setup for individual field components
366
- */
367
- declare function setupSimpleTest<T>(componentType: Type<T>, config: SimpleComponentTestConfig): SimpleComponentTestResult<T>;
368
- /**
369
- * Creates a simple test field definition
370
- */
371
- declare function createSimpleTestField(key: string, label: string): FieldDef<unknown>;
372
-
373
- /**
374
- * Simple form configuration interface for testing
375
- */
376
- interface TestFormConfig {
377
- fields: FieldDef<unknown>[];
378
- }
379
- /**
380
- * Unified configuration for creating dynamic form tests
381
- * Replaces DynamicFormTestConfig and SimpleTestConfig
382
- */
383
- interface TestConfig<T = Record<string, unknown>> {
384
- config: FormConfig | TestFormConfig;
385
- initialValue?: T;
386
- registerTestFields?: boolean;
387
- }
388
- /**
389
- * Unified result interface for dynamic form tests
390
- * Replaces DynamicFormTestResult and SimpleTestResult
391
- */
392
- interface TestResult<T = unknown> {
393
- component: T;
394
- fixture: ComponentFixture<T>;
395
- }
396
- /**
397
- * Configuration for setting up individual field component tests
398
- */
399
- interface ComponentTestConfig<T = unknown> {
400
- field: FieldDef<unknown>;
401
- value?: T;
402
- }
403
- /**
404
- * Result of setting up individual field component tests
405
- */
406
- interface ComponentTestResult<T = unknown> {
407
- component: T;
408
- fixture: ComponentFixture<T>;
409
- }
410
-
411
- /**
412
- * Type utilities for exhaustive whitelist type testing.
413
- *
414
- * These utilities help ensure that type definitions remain stable by detecting
415
- * when properties are added, removed, or changed.
416
- */
417
- /**
418
- * Extracts only the required keys from a type.
419
- *
420
- * @example
421
- * ```typescript
422
- * interface Example { a: string; b?: number; }
423
- * type Required = RequiredKeys<Example>; // 'a'
424
- * ```
425
- */
426
- type RequiredKeys<T> = {
427
- [K in keyof T]-?: object extends Pick<T, K> ? never : K;
428
- }[keyof T];
429
- /**
430
- * Extracts only the optional keys from a type.
431
- *
432
- * @example
433
- * ```typescript
434
- * interface Example { a: string; b?: number; }
435
- * type Optional = OptionalKeys<Example>; // 'b'
436
- * ```
437
- */
438
- type OptionalKeys<T> = {
439
- [K in keyof T]-?: object extends Pick<T, K> ? K : never;
440
- }[keyof T];
441
-
442
- declare class TestInputHarness {
443
- readonly field: _angular_core.InputSignal<FieldTree<string>>;
444
- readonly key: _angular_core.InputSignal<string>;
445
- readonly label: _angular_core.InputSignal<string>;
446
- readonly placeholder: _angular_core.InputSignal<string>;
447
- readonly type: _angular_core.InputSignal<string>;
448
- readonly props: _angular_core.InputSignal<Record<string, unknown>>;
449
- readonly className: _angular_core.InputSignal<string>;
450
- readonly validationMessages: _angular_core.InputSignal<ValidationMessages | undefined>;
451
- readonly defaultValidationMessages: _angular_core.InputSignal<ValidationMessages | undefined>;
452
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<TestInputHarness, never>;
453
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TestInputHarness, "df-test-input", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; "key": { "alias": "key"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "props": { "alias": "props"; "required": false; "isSignal": true; }; "className": { "alias": "className"; "required": false; "isSignal": true; }; "validationMessages": { "alias": "validationMessages"; "required": false; "isSignal": true; }; "defaultValidationMessages": { "alias": "defaultValidationMessages"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
454
- }
455
-
456
- declare class TestCheckboxHarness {
457
- readonly field: _angular_core.InputSignal<FieldTree<boolean>>;
458
- readonly key: _angular_core.InputSignal<string>;
459
- readonly label: _angular_core.InputSignal<string>;
460
- readonly props: _angular_core.InputSignal<Record<string, unknown>>;
461
- readonly className: _angular_core.InputSignal<string>;
462
- readonly validationMessages: _angular_core.InputSignal<ValidationMessages | undefined>;
463
- readonly defaultValidationMessages: _angular_core.InputSignal<ValidationMessages | undefined>;
464
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<TestCheckboxHarness, never>;
465
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TestCheckboxHarness, "df-test-checkbox", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; "key": { "alias": "key"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "props": { "alias": "props"; "required": false; "isSignal": true; }; "className": { "alias": "className"; "required": false; "isSignal": true; }; "validationMessages": { "alias": "validationMessages"; "required": false; "isSignal": true; }; "defaultValidationMessages": { "alias": "defaultValidationMessages"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
466
- }
467
-
468
- /**
469
- * Test harness component for select fields
470
- */
471
- declare class TestSelectHarness {
472
- readonly field: _angular_core.InputSignal<FieldTree<string>>;
473
- readonly key: _angular_core.InputSignal<string>;
474
- readonly label: _angular_core.InputSignal<string>;
475
- readonly options: _angular_core.InputSignal<{
476
- value: string;
477
- label: string;
478
- }[]>;
479
- readonly className: _angular_core.InputSignal<string>;
480
- readonly tabIndex: _angular_core.InputSignal<number | undefined>;
481
- readonly hidden: _angular_core.InputSignal<boolean>;
482
- readonly readonly: _angular_core.InputSignal<boolean>;
483
- readonly props: _angular_core.InputSignal<Record<string, unknown>>;
484
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<TestSelectHarness, never>;
485
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TestSelectHarness, "df-test-select", never, { "field": { "alias": "field"; "required": true; "isSignal": true; }; "key": { "alias": "key"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "className": { "alias": "className"; "required": false; "isSignal": true; }; "tabIndex": { "alias": "tabIndex"; "required": false; "isSignal": true; }; "hidden": { "alias": "hidden"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "props": { "alias": "props"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
486
- }
487
-
488
- /**
489
- * Fake translation service for testing dynamic text functionality.
490
- * Provides Observable-based translation methods with language switching simulation.
491
- *
492
- * @example
493
- * ```typescript
494
- * TestBed.configureTestingModule({
495
- * providers: [
496
- * { provide: TranslationService, useClass: FakeTranslationService }
497
- * ]
498
- * });
499
- *
500
- * const service = TestBed.inject(FakeTranslationService);
501
- * service.setTranslations({
502
- * 'form.username.label': 'Username',
503
- * 'validation.required': 'This field is required'
504
- * });
505
- * ```
506
- *
507
- * @public
508
- */
509
- declare class FakeTranslationService {
510
- private readonly translations;
511
- private readonly currentLanguage;
512
- /**
513
- * Set the translation dictionary
514
- */
515
- setTranslations(translations: Record<string, string>): void;
516
- /**
517
- * Add translations to the existing dictionary
518
- */
519
- addTranslations(translations: Record<string, string>): void;
520
- /**
521
- * Simulate language change
522
- */
523
- setLanguage(language: string): void;
524
- /**
525
- * Get current language as signal
526
- */
527
- getLanguage(): _angular_core.WritableSignal<string>;
528
- /**
529
- * Translate a key and return an Observable
530
- * Supports parameter interpolation using {{param}} syntax
531
- */
532
- translate(key: string, params?: Record<string, unknown>): Observable<string>;
533
- /**
534
- * Get instant translation (synchronous)
535
- * Supports parameter interpolation using {{param}} syntax
536
- */
537
- instant(key: string, params?: Record<string, unknown>): string;
538
- /**
539
- * Simulate translation for validation errors
540
- * Uses validation.${errorKind} pattern
541
- */
542
- translateValidationError(errorKind: string, params?: Record<string, unknown>): Observable<string>;
543
- /**
544
- * Get all current translations
545
- */
546
- getTranslations(): Record<string, string>;
547
- /**
548
- * Clear all translations
549
- */
550
- clearTranslations(): void;
551
- private interpolateParams;
552
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<FakeTranslationService, never>;
553
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<FakeTranslationService>;
554
- }
555
- /**
556
- * Default translations for common form fields and validation messages
557
- * Useful for quick testing setup
558
- */
559
- declare const DEFAULT_TEST_TRANSLATIONS: {
560
- 'form.username.label': string;
561
- 'form.email.label': string;
562
- 'form.password.label': string;
563
- 'form.firstName.label': string;
564
- 'form.lastName.label': string;
565
- 'form.phone.label': string;
566
- 'form.address.label': string;
567
- 'form.username.placeholder': string;
568
- 'form.email.placeholder': string;
569
- 'form.password.placeholder': string;
570
- 'validation.required': string;
571
- 'validation.email': string;
572
- 'validation.min': string;
573
- 'validation.max': string;
574
- 'validation.minLength': string;
575
- 'validation.maxLength': string;
576
- 'validation.pattern': string;
577
- 'buttons.submit': string;
578
- 'buttons.cancel': string;
579
- 'buttons.save': string;
580
- 'buttons.delete': string;
581
- 'buttons.edit': string;
582
- greeting: string;
583
- goodbye: string;
584
- };
585
- /**
586
- * Alternative translations for testing language switching
587
- */
588
- declare const SPANISH_TEST_TRANSLATIONS: {
589
- 'form.username.label': string;
590
- 'form.email.label': string;
591
- 'form.password.label': string;
592
- 'validation.required': string;
593
- 'validation.email': string;
594
- greeting: string;
595
- goodbye: string;
596
- };
597
- /**
598
- * Test utility to create a configured FakeTranslationService with default translations
599
- */
600
- declare function createTestTranslationService(initialTranslations?: Record<string, string>): FakeTranslationService;
601
-
602
- 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 };
603
- export type { ComponentTestConfig, ComponentTestResult, DynamicFormTestConfig, DynamicFormTestResult, MockLogger, OptionalKeys, RequiredKeys, SimpleComponentTestConfig, SimpleComponentTestResult, SimpleTestConfig, SimpleTestResult, TestConfig, TestFieldContextConfig, TestFormConfig, TestResult };