import * as i0 from '@angular/core'; import { EnvironmentInjector, InjectionToken, PipeTransform } from '@angular/core'; import * as rxjs from 'rxjs'; /** * Object formatter function type. * @param obj The object to format. * @param params Additional parameters for formatting. * @returns The formatted value. */ type ObjectFormatter = (obj: any, ...params: any[]) => any; /** * Object formatter-like types. */ type ObjectFormatterLike = ObjectFormatter | string | number | Array; /** * Default object formatter function. * @param value The item to format. * @returns The formatted string. */ declare function defaultFormatter(obj: any): string; /** * Creates a field formatter that retrieves the value of a specified field from an object. * @param field The field name to retrieve. Supports nested fields using dot notation (e.g., "user.name"). * @returns An ObjectFormatter function. */ declare function createFieldFormatter(field: string): ObjectFormatter; /** * Creates an index formatter that retrieves the value at a specified index from an array. * @param index The index to retrieve (number or boolean). * @returns An ObjectFormatter function. */ declare function createIndexFormatter(index: number | boolean): ObjectFormatter; /** * Creates a number formatter. * @param minimumIntegerDigits * @param minimumFractionDigits * @param maximumFractionDigits * @param useGrouping * @returns An ObjectFormatter function. */ declare function createNumberFormatter(minimumIntegerDigits?: number, minimumFractionDigits?: number, maximumFractionDigits?: number, useGrouping?: boolean): ObjectFormatter; /** * Creates a currency formatter. * @param currency The ISO 4217 currency code (e.g., "USD", "EUR", "IRR"). * @param minimumIntegerDigits Minimum number of integer digits to use. Default is 1. * @param minimumFractionDigits Minimum number of fraction digits to use. Default is 1. * @param maximumFractionDigits Maximum number of fraction digits to use. Default is 2. * @param notation The notation to use. Default is 'standard'. * @param currencySign The currency sign to use. Default is 'standard'. * @returns An ObjectFormatter function. */ declare function createCurrencyFormatter(currency?: string, notation?: 'standard' | 'scientific' | 'engineering' | 'compact', minimumIntegerDigits?: number, minimumFractionDigits?: number, maximumFractionDigits?: number, currencySign?: 'standard' | 'accounting'): ObjectFormatter; /** * Creates a date formatter. * The formatter can be created using predefined styles or custom Intl.DateTimeFormatOptions. * Predefined styles: * - dateStyle: 'short' | 'medium' | 'long' | 'full' * - timeStyle: 'short' | 'medium' | 'long' | 'full' * - zone: [name, display?] (e.g., ['UTC', 'short']) * - calendar: string (e.g., 'gregory', 'persian', 'islamic') * #### Custom options: * - Any valid Intl.DateTimeFormatOptions can be used for custom formatting. * @returns An ObjectFormatter function. */ declare function createDateFormatter(dateStyle?: 'short' | 'medium' | 'long' | 'full', timeStyle?: 'short' | 'medium' | 'long' | 'full', zone?: string[], // zone[0]: name, zone[1]: display ('long' | 'short' | 'shortOffset' | 'longOffset' | 'narrowOffset' | 'longGeneric' | 'shortGeneric') calendar?: string): ObjectFormatter; declare function createDateFormatter(options?: Intl.DateTimeFormatOptions): ObjectFormatter; /** * Creates a locale-based formatter. * @param locale The Locale object. * @param formatterName The format string in the form of "formatterName:param1:param2:..." * @returns A ValueFormatterFunction * @private */ declare function createLocaleFormatter(formatterName: string): ObjectFormatter; /** * Creates a composite formatter that applies multiple formatters in sequence. * @param formatters The list of ObjectFormatterLike values to compose. * @returns An ObjectFormatter function. */ declare function createCompositeFormatter(...formatters: ObjectFormatterLike[]): ObjectFormatter; /** * Creates an ObjectFormatter from various ObjectFormatterLike types. * @param formatter The ObjectFormatterLike value to convert. * A formatter can be: * - A function: used directly as the formatter. * - A number: creates an index formatter that retrieves the value at the specified index from an array. * - A string: can be a field name (e.g., "user.name"), a predefined formatter symbol ("#", "$", "@"), or a locale formatter name (e.g., "*date"). * - An array: if the first element is a predefined formatter symbol, it creates a formatter using that symbol and the rest of the elements as parameters. * Otherwise, it creates a composite formatter that applies each element in sequence. * @param params Additional parameters for the formatter. * @returns An ObjectFormatter function. */ declare function createObjectFormatter(formatter: ObjectFormatterLike, ...params: any[]): ObjectFormatter; /** * Creates a transform function that converts a ObjectFormatterLike value into a ObjectFormatter. * @param injector The EnvironmentInjector to use for dependency injection. * @returns A function that takes a ObjectFormatterLike and returns a ObjectFormatter. */ declare function objectFormatterAttribute(injector: EnvironmentInjector): ((v: ObjectFormatterLike) => ObjectFormatter); /** Locale dictionary */ type LocaleDictionary = { [key: string]: string; }; type LocaleEnums = { [enumName: string]: { [enumValue: string]: string; }; }; /** Locale Error Translator */ type LocaleValidationErrorTranslator = (error: any) => string; /** Locale validation error translator functions */ type LocaleValidationErrorTranslators = { [key: string]: LocaleValidationErrorTranslator; }; /** * A function to format the paging info of a table. * */ type TableComponentPagingFormatter = (info: { /** * The first record in the current page. */ firstRecord: number; /** * The last record in the current page. */ lastRecord: number; /** * The total number of records. */ totalRecords?: number; /** * The current page index. */ currentPage: number; }) => string; /** * Locale definition */ interface LocaleDefinition { /** Locale name */ readonly name: string; /** Does this locale belongs to a RTL language */ readonly rtl?: boolean; /** Intl API default options */ date?: { /** * Default options for Intl.DateTimeFormat API. * For more info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat#parameters */ options?: Intl.DateTimeFormatOptions; }; /** Locale dictionary */ dictionary?: LocaleDictionary; enums?: LocaleEnums; form?: { validation?: { /** Form validation error translators. */ errors?: LocaleValidationErrorTranslators; }; }; data?: { logicalOperators?: { [operator: string]: string; }; }; components?: { table?: { /** * No records found message. */ noRecords?: string; /** * Error message displayed when loading data fails. */ loadError?: string; /** * A format function to format the paging info. */ pagingInfo?: TableComponentPagingFormatter; }; select?: { placeholder?: string; }; }; formatters?: { [formatterName: string]: ObjectFormatter | string[] | { [value: string]: string; }; }; } declare class LocalizationService { private _locales; private _activeLocale?; private _changeSubject; readonly change: rxjs.Observable; constructor(); /** * Adds a Locale */ add(locale: Locale): void; /** Adds an array of Locales to this LocaleProvider */ add(locales: Locale[]): void; /** Changes the active locale */ set(localeName: string): void; /** Gets the active locale */ get(): Locale | undefined; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare const LOCALE: InjectionToken; interface TranslatedValidationError { /** Error key */ key: string; /** Error object */ value: any; /** localized error text */ text?: string; } interface LocaleChangeEvent { old?: Locale; new: Locale; } /** Locale */ declare class Locale { readonly definition: LocaleDefinition; constructor(definition: LocaleDefinition); /** * Returns the name of the locale * @returns The name of the locale */ get name(): string; /** * Translates a key in the dictionary * @param key The key to look up * @param fallback Optional fallback value if the key is not found * @returns The translated string or the fallbackValue if not found */ translate(key: string, fallback?: string): string | undefined; /** * Translates an enum value * @param enumName The name of the enum * @param enumValue The value of the enum to translate * @param fallback * @returns The translated string or the enum value itself if not found */ translateEnum(enumName: string, enumValue: string | number | null | undefined, fallback?: string): string | undefined; /** * Translates a form validation error * @param errorKey The key of the error to translate * @param error The error object */ translateError(errorKey: string, error: any, fallbackMessage?: string | undefined): string | undefined; /** * Translates validation errors * @param errors Validation errors object * @returns Array of translated validation errors */ translateErrors(errors: any): TranslatedValidationError[]; /** * Translates the first error in the validation errors object * @param errors Validation errors object * @returns TranslatedValidationError or undefined if no errors */ translateFirstError(errors: any, fallbackMessage?: string | undefined): TranslatedValidationError | undefined; /** * Clones and extends this object and returns a new Locale (without modifying this object). */ extend(definition?: Omit): Locale; /** * * @param date Date string or timestamp * @returns Formatted date string based on the locale */ formatDate(date: Date | string | number, format?: string): string; format(object: any, formatterName: string, ...params: any[]): string; } /** * Pipe to translate a dictionary key into a localized string. * It uses the LocalizationService to fetch the translation. * If the translation is not found, it returns the fallback string if provided. */ declare class TranslatePipe implements PipeTransform { private _ls; constructor(_ls: LocalizationService); transform(dictionaryKey: string, fallback?: string): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class TranslateEnumPipe implements PipeTransform { private _ls; constructor(_ls: LocalizationService); /** * * @param enumValue * @param enumName * @param nullValueKey * @param returnEnumAsFallback * @param fallbackKey * @returns */ transform(enumValue: string | number | null | undefined, enumName: string, fallback?: string): any; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class TranslateBooleanPipe implements PipeTransform { private localeProvider; constructor(localeProvider: LocalizationService); transform(value: any, falseKey?: string, trueKey?: string): any; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class DatePipe implements PipeTransform { private _injector; transform(value: Date | string | number, dateStyle?: 'short' | 'medium' | 'long' | 'full', timeStyle?: 'short' | 'medium' | 'long' | 'full', zone?: string[], calendar?: string): string; transform(value: Date | string | number, options?: Intl.DateTimeFormatOptions): string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } /** * Format pipe to format objects using various formatter types. */ declare class FormatPipe implements PipeTransform { private readonly _injector; transform(obj: any, formatter: ObjectFormatterLike, ...params: any[]): any; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class LocalizePipe implements PipeTransform { private _ls; constructor(_ls: LocalizationService); transform(dictionaryKey: string): string | undefined; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class LocalizeEnumPipe implements PipeTransform { private _ls; private _recompute; private _value?; constructor(_ls: LocalizationService); /** * * @param enumValue * @param enumName * @param nullValueKey * @param returnEnumAsFallback * @param fallbackKey * @returns */ transform(enumValue: string | number | null | undefined, enumName: string, fallback?: string): any; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class LocalizeBooleanPipe implements PipeTransform { private _ls; constructor(_ls: LocalizationService); transform(value: any, falseKey: string | undefined, trueKey: 'false'): string | undefined; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class LocalizeDatePipe implements PipeTransform { private _ls; private _value?; private _recompute; constructor(_ls: LocalizationService); transform(value: number | string, format?: string): string | undefined; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵpipe: i0.ɵɵPipeDeclaration; } declare class LocalizationModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { DatePipe, FormatPipe, LOCALE, Locale, LocalizationModule, LocalizationService, LocalizeBooleanPipe, LocalizeDatePipe, LocalizeEnumPipe, LocalizePipe, TranslateBooleanPipe, TranslateEnumPipe, TranslatePipe, createCompositeFormatter, createCurrencyFormatter, createDateFormatter, createFieldFormatter, createIndexFormatter, createLocaleFormatter, createNumberFormatter, createObjectFormatter, defaultFormatter, objectFormatterAttribute }; export type { LocaleChangeEvent, LocaleDefinition, LocaleDictionary, LocaleEnums, LocaleValidationErrorTranslator, LocaleValidationErrorTranslators, ObjectFormatter, ObjectFormatterLike, TableComponentPagingFormatter, TranslatedValidationError };