UNPKG

@itwin/presentation-components

Version:

React components based on iTwin.js Presentation library

117 lines 4.4 kB
/** @packageDocumentation * @module Core */ import "../common/DisposePolyfill.js"; import * as mm from "micro-memoize"; import { LegacyRef, MutableRefObject, RefCallback } from "react"; import { PropertyRecord } from "@itwin/appui-abstract"; import { TranslationOptions } from "@itwin/core-common"; import { Descriptor, Field, KeySet, LabelDefinition, Ruleset, Value } from "@itwin/presentation-common"; import { SelectionScopesManager } from "@itwin/presentation-frontend"; import { computeSelection, Selectables } from "@itwin/unified-selection"; /** @internal */ export declare const localizationNamespaceName = "PresentationComponents"; /** * Translate a string with the specified id from `PresentationComponents` * localization namespace. The `stringId` should not contain namespace - it's * prepended automatically. * * @internal */ export declare const translate: (stringId: string, options?: TranslationOptions) => string; /** * Creates a display name for the supplied component * @internal */ export declare const getDisplayName: <P>(component: React.ComponentType<P>) => string; /** * Finds a field given the name of property record created from that field. * @internal */ export declare const findField: (descriptor: Descriptor, recordPropertyName: string) => Field | undefined; /** * Creates property record for label using label definition. * @internal */ export declare const createLabelRecord: (label: LabelDefinition, name: string) => PropertyRecord; /** @internal */ export type RulesetOrId = Ruleset | string; /** * Returns ruleset id from `RulesetOrId`. * @internal */ export declare function getRulesetId(ruleset: RulesetOrId): string; /** * A helper to track ongoing async tasks. Usage: * ``` * { * using _r = tracker.trackAsyncTask(); * await doSomethingAsync(); * } * ``` * * Can be used with `waitForPendingAsyncs` in test helpers to wait for all * async tasks to complete. * * @internal */ export declare class AsyncTasksTracker { private _asyncsInProgress; get pendingAsyncs(): Set<string>; trackAsyncTask(): Disposable; } /** @internal */ export declare function useMergedRefs<T>(...refs: Array<MutableRefObject<T | null> | LegacyRef<T>>): RefCallback<T>; /** * A hook that helps components throw errors in React's render loop so they can be captured by React error * boundaries. * * Usage: simply call the returned function with an error and it will be re-thrown in React render loop. * * @internal */ export declare function useErrorState(): (e: unknown) => void; /** * A hook that rerenders component after some time. * @param delayMilliseconds - milliseconds to delay. Default is 250. * @internal */ export declare function useDelay(delayMilliseconds?: number): boolean; export interface UniqueValue { displayValue: string; groupedRawValues: Value[]; } /** * Function for serializing `UniqueValue`. * Returns an object, which consists of `displayValues` and `groupedRawValues`. */ export declare function serializeUniqueValues(values: UniqueValue[]): { displayValues: string; groupedRawValues: string; }; /** * Function for deserializing `displayValues` and `groupedRawValues`. * Returns an array of `UniqueValue` or undefined if parsing fails. */ export declare function deserializeUniqueValues(serializedDisplayValues: string, serializedGroupedRawValues: string): UniqueValue[] | undefined; export declare function memoize<Fn extends mm.AnyFn>(fn: Fn | mm.Memoized<Fn>, options?: mm.Options<Fn>): mm.Memoized<Fn>; export type WithIModelKey<TObj extends {}> = TObj & { imodelKey?: string; }; export declare function createKeySetFromSelectables(selectables: Selectables): Promise<KeySet>; export declare function mapPresentationFrontendSelectionScopeToUnifiedSelectionScope(scope: SelectionScopesManager["activeScope"]): Parameters<typeof computeSelection>[0]["scope"]; /** * A helper that disposes the given object, if it's disposable. * * The first option is to dispose using the deprecated `dispose` method if it exists on the object. * If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is * considered as non-disposable and nothing is done with it. * * @internal */ export declare function safeDispose(disposable: {} | { [Symbol.dispose]: () => void; } | { dispose: () => void; }): void; //# sourceMappingURL=Utils.d.ts.map