/*!
 * Copyright 2020 VMware, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */
import { ChangeDetectorRef, ElementRef, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { FormBuilder, NgControl, ValidationErrors, ValidatorFn } from '@angular/forms';
import { TranslationService } from '@vcd/i18n';
import { SelectOption } from '../../common/interfaces';
import { Unit } from '../../utils/unit/unit';
import { UnitFormatter } from '../../utils/unit/unit-formatter';
import { BaseFormControl } from '../base-form-control';
/**
 * -1 is the number to specify a value of unlimited.
 */
export declare const UNLIMITED = -1;
/**
 * A numerical form input component with unit selection and unlimited checkbox.
 *
 * If a single element array is provided for the units, then there is no unit selection
 * but rather a string notation for the unit. If the array is empty then there are no units at all.
 *
 * The display of unlimited checkbox is configurable.
 */
export declare class NumberWithUnitFormInputComponent extends BaseFormControl implements OnChanges, OnInit {
    private fb;
    private translationService;
    private unitFormatter;
    private changeDetector;
    /**
     * List of available units. Consider the following options for the array:
     * # array with more than one elements
     *    - a dropdown unit selection is shown. You must also provide {@link inputValueUnit}
     * # single element array
     *    - a string notation for no dropdown, {@link inputValueUnit} is derived from the element
     * # empty array
     *    - no units at all
     */
    set unitOptions(unitOptions: Unit[]);
    get unitOptions(): Unit[];
    /**
     * The base unit of the component. The value of this FormControl is calculated based on this property.
     * Required when a multi element array is provided for {@link unitOptions} and it should be one of those values.
     */
    inputValueUnit: Unit;
    /**
     * The initial display unit.
     * This is useful if you want to prevent finding best match when displaying a value for the first time.
     * For example if you provide 1024 MB and you want it to be displayed as 1024MB instead of 1GB
     */
    initialValueUnit: Unit;
    /**
     * Show the Unlimited checkbox. Can be set just once only at render time.
     */
    showUnlimitedOption: boolean;
    /**
     * The value when the component is set to unlimited. Default is -1.
     */
    unlimitedValue: number;
    /**
     * Minimum value allowed relevant to {@link inputValueUnit}. Default is 0.
     */
    min: number;
    /**
     * Maximum value allowed relevant to {@link inputValueUnit}. Default is {@link Number.MAX_SAFE_INTEGER}.
     */
    max: number;
    /**
     * Input 'placeholder' field.
     */
    placeholder: string;
    /**
     * Input 'size' field.
     */
    size: number;
    /**
     * Maximum number of characters (in UTF-16 code units) that the user can enter.
     */
    maxlength: number;
    /**
     * Hint to display in the content of a signpost
     */
    hint: string;
    /**
     * The direction for displaying the hint
     */
    hintPosition: string;
    private _unitOptions;
    /**
     * The input field element, where numbers are entered. Null if readonly.
     */
    textInput: ElementRef;
    private get textInputEl();
    /** ngModel for the number input */
    textInputValue: string;
    /** ngModel for the unit selector */
    unitsControlValue: string;
    /** ngModel for the unlimited checkbox */
    unlimitedControlValue: boolean;
    /**
     * A drop down of available units
     *
     * This list is constructed from list of
     * available units in {@link unitOptions}
     */
    comboOptions: SelectOption[];
    /**
     * Map of SelectOption and Unit which is used to
     * extract Unit for a given SelectOption.
     */
    private comboOptionUnitMap;
    private bestValue;
    private bestUnit;
    /**
     * The minimum value calculated from the {@link min} value converted to the currently selected unit
     */
    unitMin: number;
    /**
     * The maximum value calculated from the {@link max} value converted to the currently selected unit
     */
    unitMax: number;
    /**
     * This is the last real value for the input. Used in case when user toggles the unlimited checkbox twice in a row.
     * When unlimited is checked the value of the input is cleared, then when toggled again, the input value should be
     * set to the last value.
     */
    lastRealValue: number;
    /**
     * Should this functionality be provided at the base class?
     */
    private ngOnInitCalled;
    /**
     * Set the unit in the dropdown.
     * @param value Should be one of the value that you pass in {@link #unitOptions} to select the Unit.
     */
    set selectedUnit(value: number);
    constructor(controlDirective: NgControl, fb: FormBuilder, translationService: TranslationService, unitFormatter: UnitFormatter, changeDetector: ChangeDetectorRef);
    ngOnInit(): void;
    /**
     * Fires a change event reading the value from the current state of the UI
     */
    fireUiChange(): void;
    ngOnChanges(changes: SimpleChanges): void;
    onUnlimitedCheckboxChange(unlimitedChecked: boolean): void;
    /**
     * Called when the unit dropdown changes
     */
    onUnitChange(value: string): void;
    /**
     * Called when user types into the textfield
     */
    onTextInputChange(value: string): void;
    get shouldDisableNumberAndUnitControls(): true | null;
    /**
     * Whether the current value is unlimited
     */
    private isUnlimitedValue;
    /**
     * Delegate the number parsing to the number input
     */
    private validateNumber;
    writeValue(value: number): void;
    private computeBestUnitAndValue;
    /**
     * Figures out the control value accessor's value based on the UI state
     */
    private getValue;
    /**
     * Reads the selected unit from the UI
     */
    private getSelectedUnit;
    /**
     * Returns the SelectOption for the given value
     * @param value The value which we're trying to match within the component's combo options
     */
    private getSelectedComboUnit;
    private recalculateUnitMinMax;
    get displayValue(): string;
    /**
     * Up to now (when this function has been introduced) all our form errors were in the form
     * `{ [key]: true }` which made it quite impossible to add custom parameters for translation.
     *  `errorLabels` are a perfect example for this use case
     *
     * Now the errors are in format `{ [key]: any }` where any can be either an array [] for positional
     * based message format or `{msgKey: string}` for a named message format.
     *
     * For `errorLabels` we
     *
     */
    get errors(): ValidationErrors;
    getErrorTranslationParams(errorObjectValue: any): any;
}
export declare class NumberWithUnitsFormValidatorsFactory {
    private unitFormatter;
    constructor(unitFormatter: UnitFormatter);
    isInRange(min: number, max: number, inputUnit: Unit, availableUnits: Unit[], unlimited?: number): ValidatorFn;
}
