@ng-forge/dynamic-forms-material 0.5.1 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-forge/dynamic-forms-material",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Angular Material integration for @ng-forge/dynamic-forms. Pre-built Material Design form components.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "@angular/core": "~21.1.0",
33
33
  "@angular/forms": "~21.1.0",
34
34
  "@angular/material": "~21.1.0",
35
- "@ng-forge/dynamic-forms": "~0.5.0",
35
+ "@ng-forge/dynamic-forms": "~0.6.0",
36
36
  "rxjs": ">=7.0.0"
37
37
  },
38
38
  "module": "fesm2022/ng-forge-dynamic-forms-material.mjs",
@@ -3,7 +3,7 @@ import { CheckboxField, DatepickerField, DatepickerProps, InputMeta, InputField,
3
3
  import * as _angular_core from '@angular/core';
4
4
  import { InjectionToken, Provider } from '@angular/core';
5
5
  import { FieldTree } from '@angular/forms/signals';
6
- import { DynamicText, CheckedFieldComponent, FieldMeta, ValidationMessages, ValueFieldComponent, ValueType, FieldOption, FormEvent, FieldDef, LogicConfig, FieldComponent, FormEventConstructor, ArrayItemContext, FieldTypeDefinition, NarrowFields, RegisteredFieldTypes, InferFormValue, FormConfig } from '@ng-forge/dynamic-forms';
6
+ import { DynamicText, CheckedFieldComponent, FieldMeta, ValidationMessages, ValueFieldComponent, ValueType, FieldOption, FormEvent, NextPageEvent, PreviousPageEvent, AppendArrayItemEvent, ArrayAllowedChildren, PrependArrayItemEvent, InsertArrayItemEvent, RemoveAtIndexEvent, PopArrayItemEvent, ShiftArrayItemEvent, FieldComponent, FormEventConstructor, ArrayItemContext, FieldTypeDefinition, NarrowFields, RegisteredFieldTypes, InferFormValue, FormConfig } from '@ng-forge/dynamic-forms';
7
7
  import { ThemePalette } from '@angular/material/core';
8
8
  import * as _angular_material_form_field from '@angular/material/form-field';
9
9
  import { MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field';
@@ -365,66 +365,97 @@ type MatButtonComponent<TEvent extends FormEvent> = FieldComponent<MatButtonFiel
365
365
  * Specific button field types with preconfigured events
366
366
  */
367
367
  /** Submit button field - automatically disabled when form is invalid */
368
- interface MatSubmitButtonField extends Omit<FieldDef<MatButtonProps>, 'event'> {
368
+ type MatSubmitButtonField = Omit<MatButtonField<SubmitEvent>, 'event' | 'type' | 'eventArgs'> & {
369
369
  type: 'submit';
370
- key: string;
371
- label: string;
372
- disabled?: boolean;
373
- className?: string;
374
- props?: MatButtonProps;
375
- /** Logic rules for dynamic disabled state (overrides form-level defaults) */
376
- logic?: LogicConfig[];
377
- }
370
+ };
378
371
  /** Next page button field - with preconfigured NextPageEvent */
379
- interface MatNextButtonField extends Omit<FieldDef<MatButtonProps>, 'event'> {
372
+ type MatNextButtonField = Omit<MatButtonField<NextPageEvent>, 'event' | 'type' | 'eventArgs'> & {
380
373
  type: 'next';
381
- key: string;
382
- label: string;
383
- disabled?: boolean;
384
- className?: string;
385
- props?: MatButtonProps;
386
- /** Logic rules for dynamic disabled state (overrides form-level defaults) */
387
- logic?: LogicConfig[];
388
- }
374
+ };
389
375
  /** Previous page button field - with preconfigured PreviousPageEvent */
390
- interface MatPreviousButtonField extends Omit<FieldDef<MatButtonProps>, 'event'> {
376
+ type MatPreviousButtonField = Omit<MatButtonField<PreviousPageEvent>, 'event' | 'type' | 'eventArgs'> & {
391
377
  type: 'previous';
392
- key: string;
393
- label: string;
394
- disabled?: boolean;
395
- className?: string;
396
- props?: MatButtonProps;
397
- }
398
- /** Add array item button field - with preconfigured AddArrayItemEvent */
399
- interface AddArrayItemButtonField extends Omit<FieldDef<MatButtonProps>, 'event'> {
378
+ };
379
+ /** Add array item button field - dispatches AppendArrayItemEvent */
380
+ type AddArrayItemButtonField = Omit<MatButtonField<AppendArrayItemEvent>, 'event' | 'type' | 'eventArgs'> & {
400
381
  type: 'addArrayItem';
401
- key: string;
402
- label: string;
403
- disabled?: boolean;
404
- className?: string;
405
- props?: MatButtonProps;
406
382
  /**
407
383
  * The key of the array field to add items to.
408
384
  * Required when the button is placed outside the array.
409
385
  * When inside an array, this is automatically determined from context.
410
386
  */
411
387
  arrayKey?: string;
412
- }
413
- /** Remove array item button field - with preconfigured RemoveArrayItemEvent */
414
- interface RemoveArrayItemButtonField extends Omit<FieldDef<MatButtonProps>, 'event'> {
388
+ /**
389
+ * Template for the new array item. REQUIRED.
390
+ * - Single field (ArrayAllowedChildren): Creates a primitive item (field's value is extracted directly)
391
+ * - Array of fields (ArrayAllowedChildren[]): Creates an object item (fields merged into object)
392
+ */
393
+ template: ArrayAllowedChildren | readonly ArrayAllowedChildren[];
394
+ };
395
+ /** Prepend array item button field - dispatches PrependArrayItemEvent (adds at beginning) */
396
+ type PrependArrayItemButtonField = Omit<MatButtonField<PrependArrayItemEvent>, 'event' | 'type' | 'eventArgs'> & {
397
+ type: 'prependArrayItem';
398
+ /**
399
+ * The key of the array field to prepend items to.
400
+ * Required when the button is placed outside the array.
401
+ * When inside an array, this is automatically determined from context.
402
+ */
403
+ arrayKey?: string;
404
+ /**
405
+ * Template for the new array item. REQUIRED.
406
+ * - Single field (ArrayAllowedChildren): Creates a primitive item (field's value is extracted directly)
407
+ * - Array of fields (ArrayAllowedChildren[]): Creates an object item (fields merged into object)
408
+ */
409
+ template: ArrayAllowedChildren | readonly ArrayAllowedChildren[];
410
+ };
411
+ /** Insert array item button field - dispatches InsertArrayItemEvent (adds at specific index) */
412
+ type InsertArrayItemButtonField = Omit<MatButtonField<InsertArrayItemEvent>, 'event' | 'type' | 'eventArgs'> & {
413
+ type: 'insertArrayItem';
414
+ /**
415
+ * The key of the array field to insert items into.
416
+ * Required when the button is placed outside the array.
417
+ * When inside an array, this is automatically determined from context.
418
+ */
419
+ arrayKey?: string;
420
+ /**
421
+ * The index at which to insert the new item.
422
+ */
423
+ index: number;
424
+ /**
425
+ * Template for the new array item. REQUIRED.
426
+ * - Single field (ArrayAllowedChildren): Creates a primitive item (field's value is extracted directly)
427
+ * - Array of fields (ArrayAllowedChildren[]): Creates an object item (fields merged into object)
428
+ */
429
+ template: ArrayAllowedChildren | readonly ArrayAllowedChildren[];
430
+ };
431
+ /** Remove array item button field - dispatches RemoveAtIndexEvent or PopArrayItemEvent */
432
+ type RemoveArrayItemButtonField = Omit<MatButtonField<RemoveAtIndexEvent>, 'event' | 'type' | 'eventArgs'> & {
415
433
  type: 'removeArrayItem';
416
- key: string;
417
- label: string;
418
- disabled?: boolean;
419
- className?: string;
420
- props?: MatButtonProps;
421
434
  /**
422
435
  * The key of the array field to remove items from.
423
436
  * Required when the button is placed outside the array.
424
437
  * When inside an array, this is automatically determined from context.
425
438
  */
426
439
  arrayKey?: string;
427
- }
440
+ };
441
+ /** Pop array item button field - dispatches PopArrayItemEvent (removes last item) */
442
+ type PopArrayItemButtonField = Omit<MatButtonField<PopArrayItemEvent>, 'event' | 'type' | 'eventArgs'> & {
443
+ type: 'popArrayItem';
444
+ /**
445
+ * The key of the array field to remove the last item from.
446
+ * REQUIRED - must specify which array to pop from.
447
+ */
448
+ arrayKey: string;
449
+ };
450
+ /** Shift array item button field - dispatches ShiftArrayItemEvent (removes first item) */
451
+ type ShiftArrayItemButtonField = Omit<MatButtonField<ShiftArrayItemEvent>, 'event' | 'type' | 'eventArgs'> & {
452
+ type: 'shiftArrayItem';
453
+ /**
454
+ * The key of the array field to remove the first item from.
455
+ * REQUIRED - must specify which array to shift from.
456
+ */
457
+ arrayKey: string;
458
+ };
428
459
 
429
460
  declare class MatButtonFieldComponent<TEvent extends FormEvent> implements MatButtonComponent<TEvent> {
430
461
  private readonly eventBus;
@@ -672,7 +703,11 @@ declare const MatField: {
672
703
  readonly Next: "next";
673
704
  readonly Previous: "previous";
674
705
  readonly AddArrayItem: "addArrayItem";
706
+ readonly PrependArrayItem: "prependArrayItem";
707
+ readonly InsertArrayItem: "insertArrayItem";
675
708
  readonly RemoveArrayItem: "removeArrayItem";
709
+ readonly PopArrayItem: "popArrayItem";
710
+ readonly ShiftArrayItem: "shiftArrayItem";
676
711
  readonly Textarea: "textarea";
677
712
  readonly Radio: "radio";
678
713
  readonly MultiCheckbox: "multi-checkbox";
@@ -743,7 +778,11 @@ declare module '@ng-forge/dynamic-forms' {
743
778
  next: MatNextButtonField;
744
779
  previous: MatPreviousButtonField;
745
780
  addArrayItem: AddArrayItemButtonField;
781
+ prependArrayItem: PrependArrayItemButtonField;
782
+ insertArrayItem: InsertArrayItemButtonField;
746
783
  removeArrayItem: RemoveArrayItemButtonField;
784
+ popArrayItem: PopArrayItemButtonField;
785
+ shiftArrayItem: ShiftArrayItemButtonField;
747
786
  textarea: MatTextareaField;
748
787
  radio: MatRadioField<unknown>;
749
788
  'multi-checkbox': MatMultiCheckboxField<unknown>;
@@ -820,4 +859,4 @@ declare module '@ng-forge/dynamic-forms' {
820
859
  }
821
860
 
822
861
  export { MATERIAL_CONFIG, MATERIAL_FIELD_TYPES, MatButtonFieldComponent, MatCheckboxFieldComponent, MatDatepickerFieldComponent, MatField, MatInputFieldComponent, MatMultiCheckboxFieldComponent, MatRadioFieldComponent, MatSelectFieldComponent, MatSliderFieldComponent, MatTextareaFieldComponent, MatToggleFieldComponent, withMaterialFields };
823
- export type { AddArrayItemButtonField, MatButtonField, MatButtonProps, MatCheckboxComponent, MatCheckboxField, MatCheckboxProps, MatDatepickerComponent, MatDatepickerField, MatDatepickerProps, MatFieldType, MatFormConfig, MatFormProps, MatInputComponent, MatInputField, MatInputProps, MatMultiCheckboxComponent, MatMultiCheckboxField, MatMultiCheckboxProps, MatNextButtonField, MatPreviousButtonField, MatRadioComponent, MatRadioField, MatRadioProps, MatSelectComponent, MatSelectField, MatSelectProps, MatSliderComponent, MatSliderField, MatSliderProps, MatSubmitButtonField, MatTextareaComponent, MatTextareaField, MatTextareaProps, MatToggleComponent, MatToggleField, MatToggleProps, MaterialConfig, RemoveArrayItemButtonField };
862
+ export type { AddArrayItemButtonField, InsertArrayItemButtonField, MatButtonField, MatButtonProps, MatCheckboxComponent, MatCheckboxField, MatCheckboxProps, MatDatepickerComponent, MatDatepickerField, MatDatepickerProps, MatFieldType, MatFormConfig, MatFormProps, MatInputComponent, MatInputField, MatInputProps, MatMultiCheckboxComponent, MatMultiCheckboxField, MatMultiCheckboxProps, MatNextButtonField, MatPreviousButtonField, MatRadioComponent, MatRadioField, MatRadioProps, MatSelectComponent, MatSelectField, MatSelectProps, MatSliderComponent, MatSliderField, MatSliderProps, MatSubmitButtonField, MatTextareaComponent, MatTextareaField, MatTextareaProps, MatToggleComponent, MatToggleField, MatToggleProps, MaterialConfig, PopArrayItemButtonField, PrependArrayItemButtonField, RemoveArrayItemButtonField, ShiftArrayItemButtonField };