@theredhead — Frontend Library - v1.0.0
    Preparing search index...

    Adapter for decimal numbers with configurable precision.

    Strips non-numeric characters, parses to a number, and displays with locale-based formatting up to the configured decimal places. Shows a decimals prefix icon.

    // Allow up to 4 decimal places
    readonly adapter = new DecimalTextAdapter(4);

    Implements

    Index

    Constructors

    • Parameters

      • maxDecimals: number = 2

        Maximum number of digits after the decimal point. Defaults to 2.

      • Optionallocale: string

        BCP 47 locale tag. Defaults to navigator.language.

      Returns DecimalTextAdapter

    Properties

    maxDecimals: number = 2

    Maximum number of digits after the decimal point. Defaults to 2.

    prefixIcon: "<path d=\"M10 18h10\" /><path d=\"m17 21 3-3-3-3\" /><path d=\"M3 11h.01\" /><rect x=\"15\" y=\"3\" width=\"5\" height=\"8\" rx=\"2.5\" /><rect x=\"6\" y=\"3\" width=\"5\" height=\"8\" rx=\"2.5\" />" = UIIcons.Lucide.Math.DecimalsArrowRight

    Optional SVG icon content to display before the input.

    Should be a Lucide SVG inner-content string (e.g. UIIcons.Lucide.Text.AtSign).

    Methods

    • Optional display formatter.

      When present, the native input element shows the string returned by this method instead of the raw toValue result. Use this to add locale-specific formatting (e.g. thousands separators) while keeping value() as the clean programmatic output.

      Parameters

      • value: string

        The adapted value produced by toValue.

      Returns string

      Formatted string to display in the input element.

    • Transform the raw text into the adapted value.

      Called on every input event. The result is stored in the value model and written back to the native input element, so the user sees the adapted text. The original keystrokes are preserved in the text model.

      Parameters

      • text: string

        Raw text from the input element.

      Returns string

      Adapted value string (displayed in the field and emitted via value).

    • Validate the raw text and return a result indicating whether the current input is valid.

      When present, UIInput exposes a valid signal and applies the invalid host class when validation fails.

      Parameters

      • text: string

        Raw text from the input element.

      Returns TextAdapterValidationResult

      Validation result with valid flag and error messages.