All files / src/lib/dynamic-form-input dynamic-form-input.module.ts

100% Statements 4/4
50% Branches 1/2
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                                      1x                           1x         2x           2x              
import { MAT_FORM_FIELD_DEFAULT_OPTIONS, MatFormFieldDefaultOptions } from '@angular/material/form-field';
import {
  DynamicFormsFeature,
  withDynamicFormFileValidators,
  withDynamicFormInputs,
  withDynamicFormTextboxActionHandlers,
} from '@dynamic-forms/core';
import { matDynamicFormCheckboxType } from './dynamic-form-checkbox/dynamic-form-checkbox-type';
import { matDynamicFormComboboxType } from './dynamic-form-combobox/dynamic-form-combobox-type';
import { matDynamicFormDatepickerType } from './dynamic-form-datepicker/dynamic-form-datepicker-type';
import { matDynamicFormFileType } from './dynamic-form-file/dynamic-form-file-type';
import { matDynamicFormNumberboxType } from './dynamic-form-numberbox/dynamic-form-numberbox-type';
import { matDynamicFormRadioType } from './dynamic-form-radio/dynamic-form-radio-type';
import { matDynamicFormSelectType } from './dynamic-form-select/dynamic-form-select-type';
import { matDynamicFormSwitchType } from './dynamic-form-switch/dynamic-form-switch-type';
import { matDynamicFormTextareaType } from './dynamic-form-textarea/dynamic-form-textarea-type';
import { matDynamicFormTextboxType } from './dynamic-form-textbox/dynamic-form-textbox-type';
import { matDynamicFormToggleType } from './dynamic-form-toggle/dynamic-form-toggle-type';
 
export const matDynamicFormInputTypes = [
  matDynamicFormCheckboxType,
  matDynamicFormComboboxType,
  matDynamicFormDatepickerType,
  matDynamicFormFileType,
  matDynamicFormNumberboxType,
  matDynamicFormRadioType,
  matDynamicFormSelectType,
  matDynamicFormSwitchType,
  matDynamicFormTextareaType,
  matDynamicFormTextboxType,
  matDynamicFormToggleType,
];
 
export const matDynamicFormFieldDefaultOptions: MatFormFieldDefaultOptions = { floatLabel: 'always' };
 
export function withMatDynamicFormFieldDefaultOptions(
  options: MatFormFieldDefaultOptions = matDynamicFormFieldDefaultOptions,
): DynamicFormsFeature {
  return { providers: [{ provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: options }] };
}
 
export function withMatDynamicFormInputDefaultFeatures(
  options: MatFormFieldDefaultOptions = matDynamicFormFieldDefaultOptions,
): DynamicFormsFeature[] {
  return [
    withDynamicFormInputs(...matDynamicFormInputTypes),
    withDynamicFormTextboxActionHandlers(),
    withDynamicFormFileValidators(),
    withMatDynamicFormFieldDefaultOptions(options),
  ];
}