igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
48 lines (47 loc) • 2.13 kB
TypeScript
import type { DateRangeValue } from '../../../date-range-picker/date-range-picker.js';
import type { FormValueType, IgcFormControl } from './types.js';
type FormValueTransformers<T> = {
setValue: (value: T) => T;
getValue: (value: T) => T;
setDefaultValue: (value: T) => T;
getDefaultValue: (value: T) => T;
setFormValue: (value: T, host: IgcFormControl) => FormValueType;
};
type FormValueConfig<T> = {
initialValue: T;
initialDefaultValue?: T;
transformers?: Partial<FormValueTransformers<T>>;
};
export declare const defaultBooleanTransformers: Partial<FormValueTransformers<boolean>>;
export declare const defaultNumberTransformers: Partial<FormValueTransformers<number>>;
export declare const defaultDateTimeTransformers: Partial<FormValueTransformers<Date | null>>;
export declare const defaultFileListTransformer: Partial<FormValueTransformers<FileList | null>>;
/**
* Converts a DateDateRangeValue object to FormData with
* start and end Date values as ISO 8601 strings.
* The keys are prefixed with the host name
* and suffixed with 'start' or 'end' accordingly.
* In case the host does not have a name, it does not participate in form submission.
*
* If the date values are null or undefined, the form data values
* are empty strings ''.
*/
export declare function getDateRangeFormValue(value: DateRangeValue | null, host: IgcFormControl): FormValueType;
export declare const defaultDateRangeTransformers: Partial<FormValueTransformers<DateRangeValue | null>>;
export declare class FormValue<T> {
private static readonly setFormValueKey;
private _host;
private _value;
private _defaultValue;
private _transformers;
private _setFormValue;
constructor(host: IgcFormControl, config: FormValueConfig<T>);
setValueAndFormState(value: T): void;
set defaultValue(value: T);
get defaultValue(): T;
set value(value: T);
get value(): T;
}
export declare function createFormValueState<T>(host: IgcFormControl, config: FormValueConfig<T>): FormValue<T>;
export type FormValueOf<T> = ReturnType<typeof createFormValueState<T>>;
export {};