ngx-i18n-input
Version:
Angular library for internationalized input fields
52 lines (51 loc) • 2.27 kB
TypeScript
import { InjectionToken, Provider, TemplateRef, Type } from "@angular/core";
import { FormControl, ValidatorFn } from "@angular/forms";
export type Lang = string;
export type Langs = Lang[];
export declare const NgxI18nInputLayouts: readonly ["vertical", "tabs"];
export type NgxI18nInputLayout = typeof NgxI18nInputLayouts[number];
export interface NgxI18nInputConfig {
availableLangs: Langs;
languageDetails: Record<Lang, {
name: string;
}>;
stringifyLang: (lang: string) => string;
formatLabel: (lang: Lang, label: string | Record<Lang, string> | null) => string;
layout: NgxI18nInputLayout;
labelTemplate: TemplateRef<unknown> | null;
inputTemplate: TemplateRef<unknown> | null;
hideLabels: boolean;
autofocus: boolean | string;
required: boolean;
label: string | Record<Lang, string> | null;
validators: ValidatorFn[];
defaultInputComponent: Type<any> | null | undefined;
formatOutput: (formValue: Record<Lang, any | null>) => Record<Lang, any | null>;
}
export declare const NGX_I18N_INPUT_DEFAULT_CONFIGS: NgxI18nInputConfig;
export declare const NGX_I18N_INPUT_CONFIG: InjectionToken<NgxI18nInputConfig>;
export declare function mergeNgxI18nConfigs(configs: Partial<NgxI18nInputConfig> | null | undefined): NgxI18nInputConfig;
export declare function provideNgxI18nConfigs(configs: Partial<NgxI18nInputConfig>): Provider;
export declare function ngxI18nDefaultFormatOutput<T>(formValue: Record<Lang, T | null>): Record<Lang, T | null>;
export declare function generateUid(): string;
export interface NgxI18nInputContext {
/**
* Unique identifier for the input.
* In particolar, you can use this value for the id of the input element.
* @example
* ```html
* <ng-template #inputTemp let-context>
* <input [id]="context.id">
* </ng-template>
*
* <ngx-i18n-input [inputTemplate]="inputTemp"></ngx-i18n-input>
* ```
*/
id: string;
configs: NgxI18nInputConfig;
control: FormControl<any>;
lang: Lang;
emitCustomEvent: (name: string, value: any) => void;
}
export declare const NGX_I18N_INPUT_CONTEXT: InjectionToken<NgxI18nInputContext>;
export declare function isNgxI18nInputContext(v: unknown): v is NgxI18nInputContext;