/** @packageDocumentation * @module Core */ import { FormatProps, FormatsProvider, FormatterSpec, ParserSpec, UnitSystemKey } from "@itwin/core-quantity"; import { SchemaContext } from "@itwin/ecschema-metadata"; /** * A data structure that associates unit systems with property value formatting props. The associations are used for * assigning formatting props for specific phenomenon and unit system combinations (see [[FormatsMap]]). * * @public * * @deprecated in 5.1 - might be removed in next major version. `FormatsMap` and related APIs have been deprecated in favor of [FormatsProvider]($core-quantity). */ export interface UnitSystemFormat { unitSystems: UnitSystemKey[]; format: FormatProps; } /** * A data structure that associates specific phenomenon with one or more formatting props for specific unit system. * * Example: * ```json * { * length: [{ * unitSystems: ["metric"], * format: formatForCentimeters, * }, { * unitSystems: ["imperial", "usCustomary"], * format: formatForInches, * }, { * unitSystems: ["usSurvey"], * format: formatForUsSurveyInches, * }] * } * ``` * * @public * * @deprecated in 5.1 - might be removed in next major version. `FormatsMap` and related APIs have been deprecated in favor of [FormatsProvider]($core-quantity). */ export interface FormatsMap { [phenomenon: string]: UnitSystemFormat | UnitSystemFormat[]; } /** * Options for finding a formatter spec to use in [[KoqPropertyValueFormatter]]. * @public */ export interface FormatOptions { /** Full name of the `KindOfQuantity`, e.g. `SchemaName:KoqName`. */ koqName: string; /** Unit system to use for formatting. */ unitSystem?: UnitSystemKey; /** Optional overrides for the format used to parse or format values. */ formatOverride?: Partial>; } /** * Props for creating [[KoqPropertyValueFormatter]]. * @public */ interface KoqPropertyValueFormatterProps { /** Schema context to use for locating units, formats, etc. Generally retrieved through the `schemaContext` getter on an iModel. */ schemaContext: SchemaContext; /** Formats provider to use for finding formatting props. Defaults to [SchemaFormatsProvider]($ecschema-metadata) when not supplied. */ formatsProvider?: FormatsProvider; } /** * An utility for formatting property values based on `KindOfQuantity` and unit system. * @public */ export declare class KoqPropertyValueFormatter { #private; private _schemaContext; private _unitsProvider; private _formatsProvider?; private _defaultFormats?; /** @deprecated in 5.1 - might be removed in next major version. Use the overload that takes a props object. */ constructor(schemaContext: SchemaContext, defaultFormats?: FormatsMap, formatsProvider?: FormatsProvider); constructor(props: KoqPropertyValueFormatterProps); /** @internal */ get defaultFormats(): FormatsMap | undefined; set defaultFormats(value: FormatsMap | undefined); format(value: number, options: FormatOptions): Promise; /** * Creates a formatter that reuses formatter specs for repeated formatting options. * Each call creates an independent cache that lasts as long as the returned formatter. * Cached specs and missing-format results are not invalidated by changes to formats, * default formats, or schemas. Create a new formatter to pick up those changes. * Failed spec lookups are not cached and may be retried by subsequent calls. * @returns A formatter with its own cache, suitable for a single content-formatting operation. */ createCachedFormatter(): { format(value: number, options: FormatOptions): Promise; }; getFormatterSpec(options: FormatOptions): Promise; getParserSpec(options: FormatOptions): Promise; } export {}; //# sourceMappingURL=KoqPropertyValueFormatter.d.ts.map