File

libs/core/dynamic-form/input/src/input.model.ts

Extends

DfInputBaseConfig

Index

Properties

Properties

inputType
Type "color" | "email" | "password" | "search" | "tel" | "text" | "url"
Description

The type of input element to use.

Only types supported by NDBX's Input component are permitted.

Explanations for the different kinds of input can be found here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

Careful! When an nxMask is used, only "password", "search", "tel", "text", "url" are supported.

value (Optional)
Type string
Description

The field's initial value as a string.

Example :
formatUpperCase (Optional)
Type boolean
Description

Boolean to determine if input value needs to be formatted to uppercase

inputPrefix (Optional)
Type string
Description

Prefix text to place at the start of this field's input. It's translatable by default and supports string interpolation.

inputSuffix (Optional)
Type string
Description

Suffix text to place at the end of this field's input. It's translatable by default and supports string interpolation.

label
Type string
Description

This field's label. It's translatable by default and supports string interpolation.

Example :
maxLength (Optional)
Type number
Description

The maximum number of characters allowed for user input.

nxMask (Optional)
Type NxMaskConfiguration
Description

Configuration of an ndbx input mask. See the ndbx documentation on how to use the inputs: https://ngx-brand-kit.frameworks.allianz.io/documentation/mask/overview

optionalLabel (Optional)
Type string
Description

Text that is additionally displayed in the label if the field is not mandatory.

Example :
placeholder (Optional)
Type string
Description

Placeholder to be displayed in the field when the input is empty. It's translatable by default and supports string interpolation.

Example :
type
Type typeof DfInputTypeName
Description

Specifies the type of the field as INPUT.

hint (Optional)
Type string
Description

The hint text to be displayed under the field. It's translatable by default and supports string interpolation.

Example :
note (Optional)
Type string
Description

The note text is displayed in an info message box below the field. It's translatable by default and supports string interpolation.

Example :
onBlurEvent (Optional)
Type DfInteractiveEventConfig
Description

Configure either a PFE action or service activator configuration handler for the field's blur event.

onValueChangesEvent (Optional)
Type DfInteractiveEventConfig
Description

Configure either a PFE action or service activator configuration handler for the field's valueChanges event.

validators (Optional)
Type DynamicFormValidationConfig[]
Description

Validators to set on this form field.

acl (Optional)
Type DfFieldAcl[]
Description

ACL rules to be applied to this field.

columnSpan (Optional)
Type number
Description

This field's custom size.

Number of column(s) the element should span. It's only applicable with the "CUSTOM_COLUMN" layout. The value can be 1-12, following the 12-column grid system. The default value is 12.

id
Type string
Description

This field's ID.

The ID will serve as the ACL resource name for the form field. If the field is a form element, it will also be used as a form control name within the FormGroup to which it is added. IDs must be unique within your form.

Example :
infoIcon (Optional)
Type DfInfoIconConfig
Description

Info icon with associated pop-over.

onInitEvent (Optional)
Type DfInteractiveEventConfig
Description

Configure either a PFE action or service activator configuration handler when the field's ngOnInit method is triggered.

renderName (Optional)
Type string
Description

The optional renderName is added as the attribute "data-render-name" to the df-formfield elements in the DOM. It can be used to find the rendered element of a specific field of a form.

spacing (Optional)
Type DfFormfieldSpacing
Description

This field's custom spacing.

If defined, it will be used to set the spacing between this field and the next one.

testId (Optional)
Type string
Description

The id used to select the element in the tests (unit test, e2e testing)

import { DfInteractiveBaseConfig, SingleInputFieldLayout } from '@allianz/taly-core/dynamic-form';
import { MaskConversionTypes } from '@allianz/ng-aquila/mask';

/**
 * The value to use for the `type` attribute of input
 * formfield configs.
 */
export const DfInputTypeName = 'INPUT';

interface NxMaskWithMaskConfig {
  /**
   * 0: digits (0 to 9 numbers)
   * A: letters (uppercase and lowercase), digits
   * S: letters (uppercase and lowercase)
   *
   * Thus, if you write 000-AAA this specifies a mask that consists of three
   * numbers and then three letters, with a separator in the middle
   */
  nxMask: string;

  /**
   * isIban cannot be set when the user set nxMask
   */
  isIban?: never;

  /**
   * The default separators are /, (, ), ., :, -, +, , and space.
   */
  separators?: string[];

  /**
   * Remove special characters in the value output.
   * Default: false
   */
  dropSpecialCharacters?: boolean;

  /**
   * Convert mask, e.g. to upper case.
   * Default: No conversion.
   */
  convertTo?: MaskConversionTypes;

  /**
   * Whether the mask should be part of the validation.
   * Default: true
   */
  validateMask?: boolean;

  /**
   * Custom error message for validation
   */
  errorMessage?: string;
}

interface NxMaskIbanOnlyConfig {
  /**
   * Boolean to determine if input is iban type
   */
  isIban: boolean;

  /**
   * When `isIban` is set, properties such as `nxMask`, `separators`, `dropSpecialCharacters`, `convertTo`, and `validateMask` cannot be set.
   */
  nxMask?: never;
  separators?: never;
  dropSpecialCharacters?: never;
  convertTo?: never;
  validateMask?: never;

  /**
   * Custom error message for validation
   */
  errorMessage?: string;
}

export type NxMaskConfiguration = NxMaskWithMaskConfig | NxMaskIbanOnlyConfig;

/**
 * Configuration for a dynamic input field.
 */
export interface DfInputBaseConfig extends DfInteractiveBaseConfig, SingleInputFieldLayout {
  /**
   * Specifies the type of the field as `INPUT`.
   */
  type: typeof DfInputTypeName;

  /**
   * This field's label.
   * It's translatable by default and supports string interpolation.
   * @examples ["My label", "My label {$['bb-pgr-simple'].person.firstName}"]
   */
  label: string;

  /**
   * Placeholder to be displayed in the field when the input is empty.
   * It's translatable by default and supports string interpolation.
   * @examples ["Placeholder", "Placeholder with dynamic value {$['bb-pgr-simple'].date}"]
   */
  placeholder?: string;
  /**
   * Configuration of an ndbx input mask.
   * See the ndbx documentation on how to use the inputs:
   * https://ngx-brand-kit.frameworks.allianz.io/documentation/mask/overview
   */
  nxMask?: NxMaskConfiguration;

  /**
   * Boolean to determine if input value needs to be formatted to uppercase
   */
  formatUpperCase?: boolean;

  /**
   * The maximum number of characters allowed for user input.
   */
  maxLength?: number;

  /**
   * Prefix text to place at the start of this field's input.
   * It's translatable by default and supports string interpolation.
   */
  inputPrefix?: string;

  /**
   * Suffix text to place at the end of this field's input.
   * It's translatable by default and supports string interpolation.
   */
  inputSuffix?: string;

  /**
   * Text that is additionally displayed in the label if the field is not mandatory.
   * @examples ["Optional"]
   */
  optionalLabel?: string;
}

export interface DfInputNumberConfig extends DfInputBaseConfig {
  /**
   * The type of input element to use.
   *
   * Only types supported by NDBX's Input component are permitted.
   *
   * Explanations for the different kinds of input can be found here:
   * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
   *
   * Careful! When an nxMask is used, only "password", "search", "tel", "text", "url" are supported.
   */
  inputType: 'number';
  /**
   * The field's initial value as a number.
   * @examples [42]
   */
  value?: number;
}

export interface DfInputTextConfig extends DfInputBaseConfig {
  /**
   * The type of input element to use.
   *
   * Only types supported by NDBX's Input component are permitted.
   *
   * Explanations for the different kinds of input can be found here:
   * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
   *
   * Careful! When an nxMask is used, only "password", "search", "tel", "text", "url" are supported.
   */
  inputType: 'color' | 'email' | 'password' | 'search' | 'tel' | 'text' | 'url';
  /**
   * The field's initial value as a string.
   * @examples ["hello@example.com", "#ff0000"]
   */
  value?: string;
}

export type DfInputConfig = DfInputNumberConfig | DfInputTextConfig;

results matching ""

    No results matching ""