@itwin/presentation-common
Version:
Common pieces for iModel.js presentation packages
65 lines • 2.54 kB
TypeScript
/** @packageDocumentation
* @module Content
*/
import { UnitSystemKey } from "@itwin/core-quantity";
import { FormatOptions } from "../KoqPropertyValueFormatter.js";
import { Content } from "./Content.js";
import { Descriptor } from "./Descriptor.js";
import { Field } from "./Fields.js";
import { Item } from "./Item.js";
import { DisplayValue, Value } from "./Value.js";
/**
* An interface for something that can format `Content` and its `Item`s.
* @public
*/
interface ContentFormatter {
/** Format content in place and return it. */
formatContent(content: Content): Promise<Content>;
/** Format content `Item`s in place and return them. */
formatContentItems(items: Item[], descriptor: Descriptor): Promise<Item[]>;
}
/**
* Props for `createContentFormatter`.
* @public
*/
interface ContentFormatterProps {
/**
* An interface for something that knows how to format a single numeric value using
* a given kind-of-quantity (contained within the options object argument).
*/
propertyValueFormatter: {
format(value: number, options: FormatOptions): Promise<string | undefined>;
};
/** An optional unit system to format content in. */
unitSystem?: UnitSystemKey;
}
/**
* Create a `ContentFormatter` that knows how to format `Content` and its `Item`s.
* @public
*/
export declare function createContentFormatter(props: ContentFormatterProps): ContentFormatter;
export declare class ContentFormatterImpl implements ContentFormatter {
private _propertyValueFormatter;
private _unitSystem?;
constructor(_propertyValueFormatter: {
formatPropertyValue: (field: Field, value: Value, unitSystem?: UnitSystemKey) => Promise<DisplayValue>;
}, _unitSystem?: UnitSystemKey | undefined);
formatContent(content: Content): Promise<Content>;
formatContentItems(items: Item[], descriptor: Descriptor): Promise<Item[]>;
private formatValues;
private formatNestedContentDisplayValues;
private formatPropertyValue;
private formatArrayItems;
private formatStructMembers;
}
export declare class ContentPropertyValueFormatter {
private _propertyValueFormatter;
constructor(_propertyValueFormatter: ContentFormatterProps["propertyValueFormatter"]);
formatPropertyValue(field: Field, value: Value, unitSystem?: UnitSystemKey): Promise<DisplayValue>;
private formatValue;
private formatPrimitiveValue;
private formatStructValue;
private formatArrayValue;
}
export {};
//# sourceMappingURL=PropertyValueFormatter.d.ts.map