@ng-forge/dynamic-forms 0.1.2 → 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.
Files changed (19) hide show
  1. package/fesm2022/ng-forge-dynamic-forms-integration.mjs +313 -0
  2. package/fesm2022/ng-forge-dynamic-forms-integration.mjs.map +1 -0
  3. package/fesm2022/{ng-forge-dynamic-forms-ng-forge-dynamic-forms-BWj75LVN.mjs → ng-forge-dynamic-forms-ng-forge-dynamic-forms-CZBdtTAU.mjs} +977 -1198
  4. package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-CZBdtTAU.mjs.map +1 -0
  5. package/fesm2022/{ng-forge-dynamic-forms-page-field.component-ZVrJUMNb.mjs → ng-forge-dynamic-forms-page-field.component-BM32StxL.mjs} +18 -25
  6. package/fesm2022/ng-forge-dynamic-forms-page-field.component-BM32StxL.mjs.map +1 -0
  7. package/fesm2022/ng-forge-dynamic-forms-testing-test-button.harness-CbctXjtc.mjs +31 -0
  8. package/fesm2022/ng-forge-dynamic-forms-testing-test-button.harness-CbctXjtc.mjs.map +1 -0
  9. package/fesm2022/ng-forge-dynamic-forms-testing.mjs +971 -0
  10. package/fesm2022/ng-forge-dynamic-forms-testing.mjs.map +1 -0
  11. package/fesm2022/{ng-forge-dynamic-forms-text-field.component-BKTbxAKn.mjs → ng-forge-dynamic-forms-text-field.component-C0I8jf9T.mjs} +5 -5
  12. package/fesm2022/{ng-forge-dynamic-forms-text-field.component-BKTbxAKn.mjs.map → ng-forge-dynamic-forms-text-field.component-C0I8jf9T.mjs.map} +1 -1
  13. package/fesm2022/ng-forge-dynamic-forms.mjs +1 -1
  14. package/package.json +12 -4
  15. package/types/ng-forge-dynamic-forms-integration.d.ts +327 -0
  16. package/types/ng-forge-dynamic-forms-testing.d.ts +566 -0
  17. package/types/ng-forge-dynamic-forms.d.ts +217 -495
  18. package/fesm2022/ng-forge-dynamic-forms-ng-forge-dynamic-forms-BWj75LVN.mjs.map +0 -1
  19. package/fesm2022/ng-forge-dynamic-forms-page-field.component-ZVrJUMNb.mjs.map +0 -1
@@ -0,0 +1,971 @@
1
+ import { vi } from 'vitest';
2
+ import { ConsoleLogger, DynamicFormLogger, DynamicForm, BUILT_IN_FIELDS, FIELD_SIGNAL_CONTEXT, provideDynamicForm, EventBus, FIELD_REGISTRY } from '@ng-forge/dynamic-forms';
3
+ import { TestBed } from '@angular/core/testing';
4
+ import * as i0 from '@angular/core';
5
+ import { computed, signal, Injector, runInInjectionContext, input, Component, ChangeDetectionStrategy, Injectable } from '@angular/core';
6
+ import { firstValueFrom, race, timer, BehaviorSubject } from 'rxjs';
7
+ import { map } from 'rxjs/operators';
8
+ import { valueFieldMapper, checkboxFieldMapper } from '@ng-forge/dynamic-forms/integration';
9
+ import { form, Field } from '@angular/forms/signals';
10
+
11
+ /**
12
+ * Creates a promise that resolves after the specified delay.
13
+ *
14
+ * Utility function for testing scenarios where you need to wait for
15
+ * asynchronous operations, animations, or timing-dependent behavior.
16
+ *
17
+ * @param ms - Delay in milliseconds (defaults to 0 for next tick)
18
+ * @returns Promise that resolves after the specified delay
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Wait for async operations in tests
23
+ * await delay(100);
24
+ * expect(component.isLoaded).toBe(true);
25
+ *
26
+ * // Wait for next tick (micro-task)
27
+ * await delay();
28
+ * fixture.detectChanges();
29
+ * ```
30
+ */
31
+ function delay(ms = 0) {
32
+ return new Promise((resolve) => setTimeout(resolve, ms));
33
+ }
34
+
35
+ /**
36
+ * Creates a mock logger with vitest spies for all methods.
37
+ * Useful for testing code that uses the logger.
38
+ */
39
+ function createMockLogger() {
40
+ return {
41
+ debug: vi.fn(),
42
+ info: vi.fn(),
43
+ warn: vi.fn(),
44
+ error: vi.fn(),
45
+ };
46
+ }
47
+ /**
48
+ * Provider for a console logger in tests.
49
+ * Add this to TestBed.configureTestingModule providers when not using provideDynamicForm().
50
+ */
51
+ function provideTestLogger() {
52
+ return { provide: DynamicFormLogger, useValue: new ConsoleLogger() };
53
+ }
54
+
55
+ /**
56
+ * Fluent API for building form configurations
57
+ */
58
+ class FormConfigBuilder {
59
+ fields = [];
60
+ field(field) {
61
+ this.fields.push(field);
62
+ return this;
63
+ }
64
+ inputField(key, props) {
65
+ return this.field({
66
+ key,
67
+ type: 'input',
68
+ label: key.charAt(0).toUpperCase() + key.slice(1),
69
+ props: { placeholder: `Enter ${key}`, ...props },
70
+ });
71
+ }
72
+ requiredInputField(key, props) {
73
+ const inputField = {
74
+ key,
75
+ type: 'input',
76
+ label: key.charAt(0).toUpperCase() + key.slice(1),
77
+ required: true,
78
+ props: { placeholder: `Enter ${key}`, ...props },
79
+ };
80
+ return this.field(inputField);
81
+ }
82
+ selectField(key, options, props) {
83
+ const selectField = {
84
+ key,
85
+ type: 'select',
86
+ label: key.charAt(0).toUpperCase() + key.slice(1),
87
+ options,
88
+ props: props || {},
89
+ };
90
+ return this.field(selectField);
91
+ }
92
+ checkboxField(key, props) {
93
+ return this.field({
94
+ key,
95
+ type: 'checkbox',
96
+ label: key.charAt(0).toUpperCase() + key.slice(1),
97
+ props: props || {},
98
+ });
99
+ }
100
+ rowField(key, fields) {
101
+ return this.field({
102
+ key,
103
+ type: 'row',
104
+ fields,
105
+ });
106
+ }
107
+ groupField(key, fields) {
108
+ return this.field({
109
+ key,
110
+ type: 'group',
111
+ fields,
112
+ });
113
+ }
114
+ buttonField(key, props) {
115
+ return this.field({
116
+ key,
117
+ type: 'button',
118
+ label: key.charAt(0).toUpperCase() + key.slice(1),
119
+ props: props || {},
120
+ });
121
+ }
122
+ pageField(key, fields, title) {
123
+ const pageFields = title ? [{ key: `${key}-title`, type: 'text', label: title }, ...fields] : fields;
124
+ return this.field({
125
+ key,
126
+ type: 'page',
127
+ fields: pageFields,
128
+ });
129
+ }
130
+ build() {
131
+ return { fields: this.fields };
132
+ }
133
+ }
134
+ /**
135
+ * Utility class for testing dynamic forms
136
+ */
137
+ class DynamicFormTestUtils {
138
+ /**
139
+ * Creates a new form config builder
140
+ */
141
+ static builder() {
142
+ return new FormConfigBuilder();
143
+ }
144
+ /**
145
+ * Creates a dynamic form test setup with optional test field registration
146
+ */
147
+ static async createTest(testConfig) {
148
+ const fixture = TestBed.createComponent(DynamicForm);
149
+ const component = fixture.componentInstance;
150
+ // Access fieldRegistry from the component instance (injected by Angular DI)
151
+ const fieldRegistry = component['fieldRegistry'];
152
+ // Register test fields if requested
153
+ if (testConfig.registerTestFields !== false) {
154
+ DynamicFormTestUtils.registerTestFields(fieldRegistry);
155
+ }
156
+ // Set up the component - use 'dynamic-form' as the input name since config uses alias: 'dynamic-form'
157
+ fixture.componentRef.setInput('dynamic-form', testConfig.config);
158
+ if (testConfig.initialValue !== undefined) {
159
+ fixture.componentRef.setInput('value', testConfig.initialValue);
160
+ }
161
+ fixture.detectChanges();
162
+ await DynamicFormTestUtils.waitForInit(fixture);
163
+ return {
164
+ component: component,
165
+ fixture: fixture,
166
+ };
167
+ }
168
+ /**
169
+ * Registers common test field types including built-in types like page, row, group
170
+ * @internal
171
+ */
172
+ static registerTestFields(fieldRegistry) {
173
+ // Input field mapper that extends value field mapper (returns Signal)
174
+ const inputMapper = (fieldDef) => {
175
+ const baseInputsSignal = valueFieldMapper(fieldDef);
176
+ // Return computed signal that adds input-specific inputs
177
+ return computed(() => ({
178
+ ...baseInputsSignal(),
179
+ type: fieldDef.props?.['type'] || 'text',
180
+ placeholder: fieldDef.props?.['placeholder'] || '',
181
+ }));
182
+ };
183
+ // Select field mapper that extends value field mapper (returns Signal)
184
+ const selectMapper = (fieldDef) => {
185
+ const baseInputsSignal = valueFieldMapper(fieldDef);
186
+ // Return computed signal that adds select-specific inputs
187
+ return computed(() => ({
188
+ ...baseInputsSignal(),
189
+ options: fieldDef.options || [], // Safe cast: SelectField extends FieldDef with options property
190
+ }));
191
+ };
192
+ // Checkbox field mapper - uses checked instead of value (already returns Signal)
193
+ const checkboxMapper = (fieldDef) => {
194
+ return checkboxFieldMapper(fieldDef);
195
+ };
196
+ // Button field mapper that extends value field mapper (already returns Signal)
197
+ const buttonMapper = (fieldDef) => {
198
+ return valueFieldMapper(fieldDef);
199
+ };
200
+ // Register built-in fields first (page, row, group)
201
+ fieldRegistry.registerTypes(BUILT_IN_FIELDS);
202
+ // Then register test field types
203
+ fieldRegistry.registerTypes([
204
+ {
205
+ name: 'input',
206
+ loadComponent: () => Promise.resolve().then(function () { return testInput_harness; }),
207
+ mapper: inputMapper,
208
+ },
209
+ {
210
+ name: 'select',
211
+ loadComponent: () => Promise.resolve().then(function () { return testSelect_harness; }),
212
+ mapper: selectMapper,
213
+ },
214
+ {
215
+ name: 'checkbox',
216
+ loadComponent: () => Promise.resolve().then(function () { return testCheckbox_harness; }),
217
+ mapper: checkboxMapper,
218
+ },
219
+ {
220
+ name: 'button',
221
+ loadComponent: () => import('./ng-forge-dynamic-forms-testing-test-button.harness-CbctXjtc.mjs'),
222
+ mapper: buttonMapper,
223
+ },
224
+ ]);
225
+ }
226
+ /**
227
+ * Waits for the dynamic form to initialize.
228
+ * Uses the initialized$ observable directly which has shareReplay for late subscribers.
229
+ * @param fixture - The component fixture
230
+ * @param timeoutMs - Maximum time to wait for initialization (default: 100ms)
231
+ */
232
+ static async waitForInit(fixture, timeoutMs = 100) {
233
+ const component = fixture.componentInstance;
234
+ // Trigger initial change detection
235
+ fixture.detectChanges();
236
+ TestBed.flushEffects();
237
+ // Use the initialized$ observable directly (with shareReplay) for proper replay behavior
238
+ // Race against a timeout to prevent hanging if initialization already happened
239
+ await firstValueFrom(race(component.initialized$.pipe(map(() => true)), timer(timeoutMs).pipe(map(() => false))));
240
+ // Stabilization cycles for async components
241
+ for (let i = 0; i < 2; i++) {
242
+ TestBed.flushEffects();
243
+ fixture.detectChanges();
244
+ await delay(0);
245
+ }
246
+ await fixture.whenStable();
247
+ TestBed.flushEffects();
248
+ fixture.detectChanges();
249
+ }
250
+ /**
251
+ * Waits for an element to appear in the DOM with retries
252
+ */
253
+ static async waitForElement(fixture, selector, maxAttempts = 10) {
254
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
255
+ const element = fixture.nativeElement.querySelector(selector);
256
+ if (element) {
257
+ return element;
258
+ }
259
+ // Wait and retry
260
+ TestBed.flushEffects();
261
+ fixture.detectChanges();
262
+ await delay(50);
263
+ }
264
+ throw new Error(`[Dynamic Forms] Element not found with selector: ${selector} after ${maxAttempts} attempts`);
265
+ }
266
+ /**
267
+ * Simulates user input on a field element
268
+ */
269
+ static async simulateInput(fixture, selector, value) {
270
+ const input = await DynamicFormTestUtils.waitForElement(fixture, selector);
271
+ input.value = value;
272
+ input.dispatchEvent(new Event('input', { bubbles: true }));
273
+ fixture.detectChanges();
274
+ await delay(0);
275
+ }
276
+ /**
277
+ * Simulates user blur on a field element
278
+ */
279
+ static async simulateBlur(fixture, selector) {
280
+ const element = await DynamicFormTestUtils.waitForElement(fixture, selector);
281
+ element.dispatchEvent(new Event('blur', { bubbles: true }));
282
+ fixture.detectChanges();
283
+ await delay(0);
284
+ }
285
+ /**
286
+ * Simulates user selection on a select element
287
+ */
288
+ static async simulateSelect(fixture, selector, value) {
289
+ const select = await DynamicFormTestUtils.waitForElement(fixture, selector);
290
+ select.value = value;
291
+ select.dispatchEvent(new Event('change', { bubbles: true }));
292
+ fixture.detectChanges();
293
+ await delay(0);
294
+ }
295
+ /**
296
+ * Simulates checkbox toggle
297
+ */
298
+ static async simulateCheckbox(fixture, selector, checked) {
299
+ const checkbox = await DynamicFormTestUtils.waitForElement(fixture, selector);
300
+ checkbox.checked = checked;
301
+ checkbox.dispatchEvent(new Event('input', { bubbles: true }));
302
+ checkbox.dispatchEvent(new Event('change', { bubbles: true }));
303
+ fixture.detectChanges();
304
+ await delay(0);
305
+ }
306
+ /**
307
+ * Simulates button click
308
+ */
309
+ static async simulateButtonClick(fixture, selector) {
310
+ const button = await DynamicFormTestUtils.waitForElement(fixture, selector);
311
+ button.click();
312
+ fixture.detectChanges();
313
+ await delay(0);
314
+ }
315
+ /**
316
+ * Gets the current form value from the component
317
+ */
318
+ static getFormValue(component) {
319
+ return component.formValue();
320
+ }
321
+ /**
322
+ * Gets validation errors from the component
323
+ */
324
+ static getFormErrors(component) {
325
+ return component.errors();
326
+ }
327
+ /**
328
+ * Checks if the form is valid
329
+ */
330
+ static isFormValid(component) {
331
+ return component.valid();
332
+ }
333
+ /**
334
+ * Gets all field elements from the fixture
335
+ */
336
+ static getFieldElements(fixture, fieldType) {
337
+ return fixture.nativeElement.querySelectorAll(`df-test-${fieldType}`);
338
+ }
339
+ /**
340
+ * Asserts that a field has a specific value
341
+ */
342
+ static async assertFieldValue(fixture, fieldSelector, expectedValue) {
343
+ const element = await DynamicFormTestUtils.waitForElement(fixture, fieldSelector);
344
+ const actualValue = element.type === 'checkbox' ? element.checked.toString() : element.value;
345
+ if (actualValue !== expectedValue) {
346
+ throw new Error(`[Dynamic Forms] Expected field value to be "${expectedValue}", but got "${actualValue}"`);
347
+ }
348
+ }
349
+ /**
350
+ * Asserts that the form has a specific value
351
+ */
352
+ static assertFormValue(component, expectedValue) {
353
+ const actualValue = component.formValue();
354
+ if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) {
355
+ throw new Error(`[Dynamic Forms] Expected form value to be ${JSON.stringify(expectedValue)}, but got ${JSON.stringify(actualValue)}`);
356
+ }
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Creates a test injector with FIELD_SIGNAL_CONTEXT provided.
362
+ *
363
+ * This utility simplifies testing of mappers and components that inject FIELD_SIGNAL_CONTEXT.
364
+ *
365
+ * @example
366
+ * ```typescript
367
+ * // Basic usage
368
+ * const testInjector = createTestFormInjector();
369
+ *
370
+ * // With custom initial value
371
+ * const testInjector = createTestFormInjector({
372
+ * initialValue: { username: 'test' }
373
+ * });
374
+ *
375
+ * // With validation messages
376
+ * const testInjector = createTestFormInjector({
377
+ * defaultValidationMessages: { required: 'This field is required' }
378
+ * });
379
+ * ```
380
+ */
381
+ function createTestFormInjector(config = {}) {
382
+ const { parentInjector, initialValue = {}, defaultValues = () => initialValue, defaultValidationMessages, valueSignal, form: customForm, } = config;
383
+ // Create value signal
384
+ const value = valueSignal ?? signal(initialValue);
385
+ // Create form instance in injection context
386
+ let formInstance;
387
+ if (customForm) {
388
+ formInstance = customForm;
389
+ }
390
+ else {
391
+ const tempInjector = parentInjector || Injector.create({ providers: [] });
392
+ formInstance = runInInjectionContext(tempInjector, () => form(value));
393
+ }
394
+ // Create field signal context
395
+ const fieldSignalContext = {
396
+ injector: parentInjector || Injector.create({ providers: [] }),
397
+ value,
398
+ defaultValues,
399
+ form: formInstance,
400
+ defaultValidationMessages,
401
+ };
402
+ // Create injector with context
403
+ return Injector.create({
404
+ parent: parentInjector,
405
+ providers: [
406
+ {
407
+ provide: FIELD_SIGNAL_CONTEXT,
408
+ useValue: fieldSignalContext,
409
+ },
410
+ ],
411
+ });
412
+ }
413
+ /**
414
+ * Runs a mapper function in a test injection context.
415
+ *
416
+ * This is a convenience wrapper that creates a test injector and runs the mapper
417
+ * function within it, returning the result.
418
+ *
419
+ * @example
420
+ * ```typescript
421
+ * // Test a mapper without context overrides
422
+ * const bindings = testMapper(() => mapValueField(fieldDef));
423
+ *
424
+ * // Test a mapper with custom context
425
+ * const bindings = testMapper(
426
+ * () => mapValueField(fieldDef),
427
+ * { initialValue: { username: 'test' } }
428
+ * );
429
+ *
430
+ * // Test a mapper with validation messages
431
+ * const bindings = testMapper(
432
+ * () => mapValueField(fieldDef),
433
+ * { defaultValidationMessages: { required: 'Required field' } }
434
+ * );
435
+ * ```
436
+ */
437
+ function testMapper(mapperFn, context) {
438
+ const testInjector = createTestFormInjector(context);
439
+ return runInInjectionContext(testInjector, mapperFn);
440
+ }
441
+ /**
442
+ * Creates a field signal context for testing without creating an injector.
443
+ *
444
+ * Useful when you need to manually provide the context or test context creation logic.
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * const context = createTestFieldContext({
449
+ * initialValue: { name: 'test' }
450
+ * });
451
+ *
452
+ * // Use in your own injector
453
+ * const injector = Injector.create({
454
+ * providers: [
455
+ * { provide: FIELD_SIGNAL_CONTEXT, useValue: context }
456
+ * ]
457
+ * });
458
+ * ```
459
+ */
460
+ function createTestFieldContext(config = {}) {
461
+ const { parentInjector, initialValue = {}, defaultValues = () => initialValue, defaultValidationMessages, valueSignal, form: customForm, } = config;
462
+ const injector = parentInjector || Injector.create({ providers: [] });
463
+ const value = valueSignal ?? signal(initialValue);
464
+ let formInstance;
465
+ if (customForm) {
466
+ formInstance = customForm;
467
+ }
468
+ else {
469
+ formInstance = runInInjectionContext(injector, () => form(value));
470
+ }
471
+ return {
472
+ injector,
473
+ value,
474
+ defaultValues,
475
+ form: formInstance,
476
+ defaultValidationMessages,
477
+ };
478
+ }
479
+
480
+ /**
481
+ * Fluent API for building form configurations using existing field structure
482
+ */
483
+ class TestFormConfigBuilder {
484
+ fields = [];
485
+ field(field) {
486
+ this.fields.push(field);
487
+ return this;
488
+ }
489
+ inputField(key, props) {
490
+ return this.field({
491
+ key,
492
+ type: 'input',
493
+ label: key.charAt(0).toUpperCase() + key.slice(1),
494
+ ...props,
495
+ });
496
+ }
497
+ requiredInputField(key, props) {
498
+ return this.inputField(key, { required: true, ...props });
499
+ }
500
+ checkboxField(key, props) {
501
+ return this.field({
502
+ key,
503
+ type: 'checkbox',
504
+ label: key.charAt(0).toUpperCase() + key.slice(1),
505
+ ...props,
506
+ });
507
+ }
508
+ build() {
509
+ return { fields: this.fields };
510
+ }
511
+ }
512
+ /**
513
+ * Simple utility class for testing dynamic forms
514
+ */
515
+ class SimpleTestUtils {
516
+ /**
517
+ * Creates a new form config builder
518
+ */
519
+ static builder() {
520
+ return new TestFormConfigBuilder();
521
+ }
522
+ /**
523
+ * Creates a simple test component - assumes TestBed is already configured
524
+ */
525
+ static createComponent(config = { fields: [] }, initialValue) {
526
+ const fixture = TestBed.createComponent(DynamicForm);
527
+ const component = fixture.componentInstance;
528
+ // Use 'dynamic-form' as the input name since config uses alias: 'dynamic-form'
529
+ fixture.componentRef.setInput('dynamic-form', config);
530
+ if (initialValue !== undefined) {
531
+ fixture.componentRef.setInput('value', initialValue);
532
+ }
533
+ fixture.detectChanges();
534
+ TestBed.flushEffects();
535
+ // Cast to SimpleTestResult - type variance in DynamicForm generics doesn't affect runtime behavior
536
+ return { component, fixture };
537
+ }
538
+ /**
539
+ * Waits for the dynamic form to initialize
540
+ */
541
+ static async waitForInit(fixture) {
542
+ await delay(0);
543
+ fixture.detectChanges();
544
+ TestBed.flushEffects();
545
+ await delay(0);
546
+ }
547
+ /**
548
+ * Simulates user input on a field element
549
+ */
550
+ static async simulateInput(fixture, selector, value) {
551
+ const input = fixture.nativeElement.querySelector(selector);
552
+ if (!input) {
553
+ throw new Error(`[Dynamic Forms] Input element not found with selector: ${selector}`);
554
+ }
555
+ input.value = value;
556
+ input.dispatchEvent(new Event('input', { bubbles: true }));
557
+ fixture.detectChanges();
558
+ await delay(0);
559
+ }
560
+ /**
561
+ * Simulates checkbox toggle
562
+ */
563
+ static async simulateCheckbox(fixture, selector, checked) {
564
+ const checkbox = fixture.nativeElement.querySelector(selector);
565
+ if (!checkbox) {
566
+ throw new Error(`[Dynamic Forms] Checkbox element not found with selector: ${selector}`);
567
+ }
568
+ checkbox.checked = checked;
569
+ checkbox.dispatchEvent(new Event('change', { bubbles: true }));
570
+ fixture.detectChanges();
571
+ await delay(0);
572
+ }
573
+ /**
574
+ * Gets the current form value from the component
575
+ */
576
+ static getFormValue(component) {
577
+ return component.formValue();
578
+ }
579
+ /**
580
+ * Checks if the form is valid
581
+ */
582
+ static isFormValid(component) {
583
+ return component.valid();
584
+ }
585
+ /**
586
+ * Asserts that the form has a specific value
587
+ */
588
+ static assertFormValue(component, expectedValue) {
589
+ const actualValue = component.formValue();
590
+ if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) {
591
+ throw new Error(`[Dynamic Forms] Expected form value to be ${JSON.stringify(expectedValue)}, but got ${JSON.stringify(actualValue)}`);
592
+ }
593
+ }
594
+ }
595
+ // Mock field component for testing
596
+ // Includes all inputs that baseFieldMapper and valueFieldMapper might create bindings for
597
+ class TestFieldComponent {
598
+ // Field tree input
599
+ field = input(...(ngDevMode ? [undefined, { debugName: "field" }] : []));
600
+ // Required inputs from baseFieldMapper
601
+ key = input('', ...(ngDevMode ? [{ debugName: "key" }] : []));
602
+ label = input('', ...(ngDevMode ? [{ debugName: "label" }] : []));
603
+ className = input('', ...(ngDevMode ? [{ debugName: "className" }] : []));
604
+ tabIndex = input(undefined, ...(ngDevMode ? [{ debugName: "tabIndex" }] : []));
605
+ props = input(undefined, ...(ngDevMode ? [{ debugName: "props" }] : []));
606
+ placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
607
+ // Array-related inputs
608
+ arrayContext = input(undefined, ...(ngDevMode ? [{ debugName: "arrayContext" }] : []));
609
+ fields = input([], ...(ngDevMode ? [{ debugName: "fields" }] : []));
610
+ // Validation inputs from valueFieldMapper
611
+ validationMessages = input(undefined, ...(ngDevMode ? [{ debugName: "validationMessages" }] : []));
612
+ defaultValidationMessages = input(undefined, ...(ngDevMode ? [{ debugName: "defaultValidationMessages" }] : []));
613
+ value = signal('test', ...(ngDevMode ? [{ debugName: "value" }] : []));
614
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TestFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
615
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: TestFieldComponent, isStandalone: true, selector: "df-test-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: false, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: true, isRequired: false, transformFunction: null }, tabIndex: { classPropertyName: "tabIndex", publicName: "tabIndex", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, arrayContext: { classPropertyName: "arrayContext", publicName: "arrayContext", isSignal: true, isRequired: false, transformFunction: null }, fields: { classPropertyName: "fields", publicName: "fields", isSignal: true, isRequired: false, transformFunction: null }, validationMessages: { classPropertyName: "validationMessages", publicName: "validationMessages", isSignal: true, isRequired: false, transformFunction: null }, defaultValidationMessages: { classPropertyName: "defaultValidationMessages", publicName: "defaultValidationMessages", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: '<div>Test Field: {{ value() }}</div>', isInline: true });
616
+ }
617
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TestFieldComponent, decorators: [{
618
+ type: Component,
619
+ args: [{
620
+ selector: 'df-test-field',
621
+ template: '<div>Test Field: {{ value() }}</div>',
622
+ }]
623
+ }], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "field", required: false }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], className: [{ type: i0.Input, args: [{ isSignal: true, alias: "className", required: false }] }], tabIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabIndex", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], arrayContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "arrayContext", required: false }] }], fields: [{ type: i0.Input, args: [{ isSignal: true, alias: "fields", required: false }] }], validationMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "validationMessages", required: false }] }], defaultValidationMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultValidationMessages", required: false }] }] } });
624
+ /**
625
+ * Creates a simple test setup for individual field components
626
+ */
627
+ function setupSimpleTest(componentType, config) {
628
+ const mockFieldType = {
629
+ name: 'test',
630
+ loadComponent: async () => TestFieldComponent,
631
+ mapper: () => computed(() => ({})), // Simple mapper that returns empty inputs signal for testing
632
+ };
633
+ TestBed.configureTestingModule({
634
+ imports: [componentType],
635
+ providers: [
636
+ provideDynamicForm(),
637
+ EventBus,
638
+ {
639
+ provide: FIELD_REGISTRY,
640
+ useValue: new Map([['test', mockFieldType]]),
641
+ },
642
+ {
643
+ provide: FIELD_SIGNAL_CONTEXT,
644
+ useFactory: (injector) => {
645
+ // Create test context using factory
646
+ return runInInjectionContext(injector, () => {
647
+ const defaultValue = (config.value || {});
648
+ const valueSignal = signal(defaultValue, ...(ngDevMode ? [{ debugName: "valueSignal" }] : []));
649
+ const formInstance = form(valueSignal);
650
+ return {
651
+ injector,
652
+ value: valueSignal,
653
+ defaultValues: () => defaultValue,
654
+ form: formInstance,
655
+ defaultValidationMessages: undefined,
656
+ };
657
+ });
658
+ },
659
+ deps: [Injector],
660
+ },
661
+ ],
662
+ });
663
+ const fixture = TestBed.createComponent(componentType);
664
+ const component = fixture.componentInstance;
665
+ fixture.componentRef.setInput('field', config.field);
666
+ fixture.componentRef.setInput('key', config.field.key);
667
+ if (config.value !== undefined) {
668
+ fixture.componentRef.setInput('value', config.value);
669
+ }
670
+ if (config.pageIndex !== undefined) {
671
+ fixture.componentRef.setInput('pageIndex', config.pageIndex);
672
+ }
673
+ if (config.isVisible !== undefined) {
674
+ fixture.componentRef.setInput('isVisible', config.isVisible);
675
+ }
676
+ // Set any additional inputs provided in config
677
+ Object.keys(config).forEach((key) => {
678
+ if (!['field', 'value', 'pageIndex', 'isVisible'].includes(key) && config[key] !== undefined) {
679
+ fixture.componentRef.setInput(key, config[key]);
680
+ }
681
+ });
682
+ fixture.detectChanges();
683
+ return { component, fixture };
684
+ }
685
+ /**
686
+ * Creates a simple test field definition
687
+ */
688
+ function createSimpleTestField(key, label) {
689
+ return {
690
+ key,
691
+ type: 'test',
692
+ label,
693
+ };
694
+ }
695
+
696
+ class TestInputHarness {
697
+ field = input.required(...(ngDevMode ? [{ debugName: "field" }] : []));
698
+ key = input.required(...(ngDevMode ? [{ debugName: "key" }] : []));
699
+ // Field-specific properties
700
+ label = input('', ...(ngDevMode ? [{ debugName: "label" }] : []));
701
+ placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
702
+ type = input('text', ...(ngDevMode ? [{ debugName: "type" }] : []));
703
+ props = input({}, ...(ngDevMode ? [{ debugName: "props" }] : []));
704
+ className = input('', ...(ngDevMode ? [{ debugName: "className" }] : []));
705
+ validationMessages = input(...(ngDevMode ? [undefined, { debugName: "validationMessages" }] : []));
706
+ defaultValidationMessages = input(...(ngDevMode ? [undefined, { debugName: "defaultValidationMessages" }] : []));
707
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TestInputHarness, deps: [], target: i0.ɵɵFactoryTarget.Component });
708
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: TestInputHarness, isStandalone: true, selector: "df-test-input", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: true, isRequired: false, transformFunction: null }, validationMessages: { classPropertyName: "validationMessages", publicName: "validationMessages", isSignal: true, isRequired: false, transformFunction: null }, defaultValidationMessages: { classPropertyName: "defaultValidationMessages", publicName: "defaultValidationMessages", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<input [type]="type()" [field]="field()" />`, isInline: true, dependencies: [{ kind: "directive", type: Field, selector: "[field]", inputs: ["field"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
709
+ }
710
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TestInputHarness, decorators: [{
711
+ type: Component,
712
+ args: [{
713
+ selector: 'df-test-input',
714
+ template: `<input [type]="type()" [field]="field()" />`,
715
+ changeDetection: ChangeDetectionStrategy.OnPush,
716
+ imports: [Field],
717
+ }]
718
+ }], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "field", required: true }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], className: [{ type: i0.Input, args: [{ isSignal: true, alias: "className", required: false }] }], validationMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "validationMessages", required: false }] }], defaultValidationMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultValidationMessages", required: false }] }] } });
719
+
720
+ var testInput_harness = /*#__PURE__*/Object.freeze({
721
+ __proto__: null,
722
+ default: TestInputHarness
723
+ });
724
+
725
+ class TestCheckboxHarness {
726
+ field = input.required(...(ngDevMode ? [{ debugName: "field" }] : []));
727
+ key = input.required(...(ngDevMode ? [{ debugName: "key" }] : []));
728
+ // Field-specific properties
729
+ label = input('', ...(ngDevMode ? [{ debugName: "label" }] : []));
730
+ props = input({}, ...(ngDevMode ? [{ debugName: "props" }] : []));
731
+ className = input('', ...(ngDevMode ? [{ debugName: "className" }] : []));
732
+ validationMessages = input(...(ngDevMode ? [undefined, { debugName: "validationMessages" }] : []));
733
+ defaultValidationMessages = input(...(ngDevMode ? [undefined, { debugName: "defaultValidationMessages" }] : []));
734
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TestCheckboxHarness, deps: [], target: i0.ɵɵFactoryTarget.Component });
735
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.6", type: TestCheckboxHarness, isStandalone: true, selector: "df-test-checkbox", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: true, isRequired: false, transformFunction: null }, validationMessages: { classPropertyName: "validationMessages", publicName: "validationMessages", isSignal: true, isRequired: false, transformFunction: null }, defaultValidationMessages: { classPropertyName: "defaultValidationMessages", publicName: "defaultValidationMessages", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: ` <input type="checkbox" [field]="field()" /> `, isInline: true, dependencies: [{ kind: "directive", type: Field, selector: "[field]", inputs: ["field"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
736
+ }
737
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TestCheckboxHarness, decorators: [{
738
+ type: Component,
739
+ args: [{
740
+ selector: 'df-test-checkbox',
741
+ template: ` <input type="checkbox" [field]="field()" /> `,
742
+ changeDetection: ChangeDetectionStrategy.OnPush,
743
+ imports: [Field],
744
+ }]
745
+ }], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "field", required: true }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }], className: [{ type: i0.Input, args: [{ isSignal: true, alias: "className", required: false }] }], validationMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "validationMessages", required: false }] }], defaultValidationMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultValidationMessages", required: false }] }] } });
746
+
747
+ var testCheckbox_harness = /*#__PURE__*/Object.freeze({
748
+ __proto__: null,
749
+ default: TestCheckboxHarness
750
+ });
751
+
752
+ /**
753
+ * Test harness component for select fields
754
+ */
755
+ class TestSelectHarness {
756
+ field = input.required(...(ngDevMode ? [{ debugName: "field" }] : []));
757
+ key = input.required(...(ngDevMode ? [{ debugName: "key" }] : []));
758
+ // Field-specific properties
759
+ label = input('', ...(ngDevMode ? [{ debugName: "label" }] : []));
760
+ options = input([], ...(ngDevMode ? [{ debugName: "options" }] : []));
761
+ className = input('', ...(ngDevMode ? [{ debugName: "className" }] : []));
762
+ tabIndex = input(undefined, ...(ngDevMode ? [{ debugName: "tabIndex" }] : []));
763
+ hidden = input(false, ...(ngDevMode ? [{ debugName: "hidden" }] : []));
764
+ readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : []));
765
+ props = input({}, ...(ngDevMode ? [{ debugName: "props" }] : []));
766
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TestSelectHarness, deps: [], target: i0.ɵɵFactoryTarget.Component });
767
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.6", type: TestSelectHarness, isStandalone: true, selector: "df-test-select", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, className: { classPropertyName: "className", publicName: "className", isSignal: true, isRequired: false, transformFunction: null }, tabIndex: { classPropertyName: "tabIndex", publicName: "tabIndex", isSignal: true, isRequired: false, transformFunction: null }, hidden: { classPropertyName: "hidden", publicName: "hidden", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
768
+ @let f = field();
769
+ <select [field]="f">
770
+ <option value="">Select...</option>
771
+ @for (option of options(); track option.value) {
772
+ <option [value]="option.value">{{ option.label }}</option>
773
+ }
774
+ </select>
775
+ `, isInline: true, dependencies: [{ kind: "directive", type: Field, selector: "[field]", inputs: ["field"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
776
+ }
777
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: TestSelectHarness, decorators: [{
778
+ type: Component,
779
+ args: [{
780
+ selector: 'df-test-select',
781
+ template: `
782
+ @let f = field();
783
+ <select [field]="f">
784
+ <option value="">Select...</option>
785
+ @for (option of options(); track option.value) {
786
+ <option [value]="option.value">{{ option.label }}</option>
787
+ }
788
+ </select>
789
+ `,
790
+ changeDetection: ChangeDetectionStrategy.OnPush,
791
+ imports: [Field],
792
+ }]
793
+ }], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "field", required: true }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], className: [{ type: i0.Input, args: [{ isSignal: true, alias: "className", required: false }] }], tabIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabIndex", required: false }] }], hidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "hidden", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: false }] }] } });
794
+
795
+ var testSelect_harness = /*#__PURE__*/Object.freeze({
796
+ __proto__: null,
797
+ default: TestSelectHarness
798
+ });
799
+
800
+ /**
801
+ * Fake translation service for testing dynamic text functionality.
802
+ * Provides Observable-based translation methods with language switching simulation.
803
+ *
804
+ * @example
805
+ * ```typescript
806
+ * TestBed.configureTestingModule({
807
+ * providers: [
808
+ * { provide: TranslationService, useClass: FakeTranslationService }
809
+ * ]
810
+ * });
811
+ *
812
+ * const service = TestBed.inject(FakeTranslationService);
813
+ * service.setTranslations({
814
+ * 'form.username.label': 'Username',
815
+ * 'validation.required': 'This field is required'
816
+ * });
817
+ * ```
818
+ *
819
+ * @public
820
+ */
821
+ class FakeTranslationService {
822
+ translations = new BehaviorSubject({});
823
+ currentLanguage = signal('en', ...(ngDevMode ? [{ debugName: "currentLanguage" }] : []));
824
+ /**
825
+ * Set the translation dictionary
826
+ */
827
+ setTranslations(translations) {
828
+ this.translations.next(translations);
829
+ }
830
+ /**
831
+ * Add translations to the existing dictionary
832
+ */
833
+ addTranslations(translations) {
834
+ const current = this.translations.value;
835
+ this.translations.next({ ...current, ...translations });
836
+ }
837
+ /**
838
+ * Simulate language change
839
+ */
840
+ setLanguage(language) {
841
+ this.currentLanguage.set(language);
842
+ // Trigger translation updates by emitting current translations
843
+ this.translations.next(this.translations.value);
844
+ }
845
+ /**
846
+ * Get current language as signal
847
+ */
848
+ getLanguage() {
849
+ return this.currentLanguage;
850
+ }
851
+ /**
852
+ * Translate a key and return an Observable
853
+ * Supports parameter interpolation using {{param}} syntax
854
+ */
855
+ translate(key, params) {
856
+ return this.translations.pipe(map((translations) => {
857
+ const translatedValue = translations[key] || key;
858
+ return this.interpolateParams(translatedValue, params);
859
+ }));
860
+ }
861
+ /**
862
+ * Get instant translation (synchronous)
863
+ * Supports parameter interpolation using {{param}} syntax
864
+ */
865
+ instant(key, params) {
866
+ const translations = this.translations.value;
867
+ const translatedValue = translations[key] || key;
868
+ return this.interpolateParams(translatedValue, params);
869
+ }
870
+ /**
871
+ * Simulate translation for validation errors
872
+ * Uses validation.${errorKind} pattern
873
+ */
874
+ translateValidationError(errorKind, params) {
875
+ const key = `validation.${errorKind}`;
876
+ return this.translate(key, params);
877
+ }
878
+ /**
879
+ * Get all current translations
880
+ */
881
+ getTranslations() {
882
+ return this.translations.value;
883
+ }
884
+ /**
885
+ * Clear all translations
886
+ */
887
+ clearTranslations() {
888
+ this.translations.next({});
889
+ }
890
+ interpolateParams(template, params) {
891
+ if (!params) {
892
+ return template;
893
+ }
894
+ let result = template;
895
+ Object.entries(params).forEach(([key, value]) => {
896
+ const placeholder = new RegExp(`{{\\s*${key}\\s*}}`, 'g');
897
+ result = result.replace(placeholder, String(value));
898
+ });
899
+ return result;
900
+ }
901
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FakeTranslationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
902
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FakeTranslationService, providedIn: 'root' });
903
+ }
904
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: FakeTranslationService, decorators: [{
905
+ type: Injectable,
906
+ args: [{
907
+ providedIn: 'root',
908
+ }]
909
+ }] });
910
+ /**
911
+ * Default translations for common form fields and validation messages
912
+ * Useful for quick testing setup
913
+ */
914
+ const DEFAULT_TEST_TRANSLATIONS = {
915
+ // Form field labels
916
+ 'form.username.label': 'Username',
917
+ 'form.email.label': 'Email Address',
918
+ 'form.password.label': 'Password',
919
+ 'form.firstName.label': 'First Name',
920
+ 'form.lastName.label': 'Last Name',
921
+ 'form.phone.label': 'Phone Number',
922
+ 'form.address.label': 'Address',
923
+ // Form field placeholders
924
+ 'form.username.placeholder': 'Enter your username',
925
+ 'form.email.placeholder': 'Enter your email address',
926
+ 'form.password.placeholder': 'Enter your password',
927
+ // Validation messages
928
+ 'validation.required': 'This field is required',
929
+ 'validation.email': 'Please enter a valid email address',
930
+ 'validation.min': 'Value must be at least {{min}}',
931
+ 'validation.max': 'Value must be at most {{max}}',
932
+ 'validation.minLength': 'Must be at least {{requiredLength}} characters',
933
+ 'validation.maxLength': 'Must be at most {{requiredLength}} characters',
934
+ 'validation.pattern': 'Invalid format',
935
+ // Button labels
936
+ 'buttons.submit': 'Submit',
937
+ 'buttons.cancel': 'Cancel',
938
+ 'buttons.save': 'Save',
939
+ 'buttons.delete': 'Delete',
940
+ 'buttons.edit': 'Edit',
941
+ // Multi-language examples for testing language switching
942
+ greeting: 'Hello',
943
+ goodbye: 'Goodbye',
944
+ };
945
+ /**
946
+ * Alternative translations for testing language switching
947
+ */
948
+ const SPANISH_TEST_TRANSLATIONS = {
949
+ 'form.username.label': 'Nombre de usuario',
950
+ 'form.email.label': 'Dirección de correo electrónico',
951
+ 'form.password.label': 'Contraseña',
952
+ 'validation.required': 'Este campo es obligatorio',
953
+ 'validation.email': 'Por favor ingrese una dirección de correo válida',
954
+ greeting: 'Hola',
955
+ goodbye: 'Adiós',
956
+ };
957
+ /**
958
+ * Test utility to create a configured FakeTranslationService with default translations
959
+ */
960
+ function createTestTranslationService(initialTranslations = DEFAULT_TEST_TRANSLATIONS) {
961
+ const service = new FakeTranslationService();
962
+ service.setTranslations(initialTranslations);
963
+ return service;
964
+ }
965
+
966
+ /**
967
+ * Generated bundle index. Do not edit.
968
+ */
969
+
970
+ 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 };
971
+ //# sourceMappingURL=ng-forge-dynamic-forms-testing.mjs.map