UNPKG

@itwin/presentation-common

Version:

Common pieces for iModel.js presentation packages

85 lines 3.22 kB
/** @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 - will not be removed until after 2026-08-08. `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 - will not be removed until after 2026-08-08. `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; } /** * 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 - will not be removed until after 2026-08-08. 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<string | undefined>; getFormatterSpec(options: FormatOptions): Promise<FormatterSpec | undefined>; getParserSpec(options: FormatOptions): Promise<ParserSpec | undefined>; } export {}; //# sourceMappingURL=KoqPropertyValueFormatter.d.ts.map