@itwin/presentation-hierarchies
Version:
A package for creating hierarchies based on data in iTwin.js iModels.
161 lines • 6.29 kB
TypeScript
import { InstanceKey } from "@itwin/presentation-shared";
/**
* An instance key that may be associated with specific iModel.
* @public
*/
export interface IModelInstanceKey extends InstanceKey {
imodelKey?: string;
}
/**
* A key for a generic node.
* @public
*/
export interface GenericNodeKey {
/** Type of the node */
type: "generic";
/**
* Node key identifier, which uniquely identifies the node within the hierarchy level the node is used.
* The format of the identifier is not specified and is up to the data source.
*/
id: string;
/**
* Optional data source identifier. Useful when a hierarchy is built using multiple hierarchy providers - in that
* case each provider can assign a unique source identifier to its nodes.
*/
source?: string;
}
/**
* A key for a node that represents one or more ECInstances.
* @public
*/
export interface InstancesNodeKey {
/** Type of the node */
type: "instances";
/**
* Keys of ECInstances that are represented by the node. Generally, one node represents a single
* ECInstance, but in some cases (e.g. node merging) there could be more.
*/
instanceKeys: IModelInstanceKey[];
}
/**
* A key for a class-grouping node.
* @public
*/
export interface ClassGroupingNodeKey {
/** Type of the node */
type: "class-grouping";
/** Full name of the ECClass that this grouping node is grouping by. */
className: string;
}
/**
* A key for a label-grouping node.
* @public
*/
export interface LabelGroupingNodeKey {
/** Type of the node */
type: "label-grouping";
/** Node label that this grouping node is grouping by. */
label: string;
/**
* Optional group identifier that is assigned to the node key when multiple nodes
* with the same label shouldn't be grouped together.
*/
groupId?: string;
}
/**
* A key property grouping node that groups nodes whose values don't fall into any other
* property group in the hierarchy level.
* @public
*/
export interface PropertyOtherValuesGroupingNodeKey {
/** Type of the node */
type: "property-grouping:other";
/** Identifiers of properties whose values are grouped under this node. */
properties: Array<{
className: string;
propertyName: string;
}>;
}
/**
* A key for a property grouping node that groups nodes by formatted property value.
* @public
*/
export interface PropertyValueGroupingNodeKey {
/** Type of the node */
type: "property-grouping:value";
/** Name of the property that is used for grouping nodes. */
propertyName: string;
/** Full name of the ECClass containing the property. */
propertyClassName: string;
/** Formatted property value that this node is grouping by. */
formattedPropertyValue: string;
}
/**
* A key for a property grouping node that groups nodes by a range of property values.
* @public
*/
export interface PropertyValueRangeGroupingNodeKey {
/** Type of the node */
type: "property-grouping:range";
/** Name of the property that is used for grouping nodes. */
propertyName: string;
/** Full name of the ECClass containing the property. */
propertyClassName: string;
/** Defines the start of the values' range that this node is grouping by. */
fromValue: number;
/** Defines the end of the values' range that this node is grouping by. */
toValue: number;
}
/**
* A key for a property grouping node.
* @public
*/
export type PropertyGroupingNodeKey = PropertyValueRangeGroupingNodeKey | PropertyValueGroupingNodeKey | PropertyOtherValuesGroupingNodeKey;
/**
* A key for one of the instance grouping nodes.
* @public
*/
export type GroupingNodeKey = ClassGroupingNodeKey | LabelGroupingNodeKey | PropertyGroupingNodeKey;
/**
* A key for either an instance node or one of the instance grouping nodes.
* @public
*/
export type IModelHierarchyNodeKey = InstancesNodeKey | GroupingNodeKey;
/**
* A key that uniquely identifies a node in a hierarchy level.
* @public
*/
export type HierarchyNodeKey = IModelHierarchyNodeKey | GenericNodeKey;
/** @public */
export declare namespace HierarchyNodeKey {
/** Checks whether the given node key is a generic node key. */
function isGeneric(key: HierarchyNodeKey): key is GenericNodeKey;
/** Checks whether the given node key is a `StandardHierarchyNodeKey`. */
function isIModelNodeKey(key: HierarchyNodeKey): key is IModelHierarchyNodeKey;
/** Checks whether the given node key is an `InstancesNodeKey`. */
function isInstances(key: HierarchyNodeKey): key is InstancesNodeKey;
/** Checks whether the given node key is a `GroupingNodeKey`. */
function isGrouping(key: HierarchyNodeKey): key is GroupingNodeKey;
/** Checks whether the given node key is a `ClassGroupingNodeKey`. */
function isClassGrouping(key: HierarchyNodeKey): key is ClassGroupingNodeKey;
/** Checks whether the given node key is a `LabelGroupingNodeKey`. */
function isLabelGrouping(key: HierarchyNodeKey): key is LabelGroupingNodeKey;
/** Checks whether the given node key is a `PropertyOtherValuesGroupingNodeKey`. */
function isPropertyOtherValuesGrouping(key: HierarchyNodeKey): key is PropertyOtherValuesGroupingNodeKey;
/** Checks whether the given node key is a `PropertyValueRangeGroupingNodeKey`. */
function isPropertyValueRangeGrouping(key: HierarchyNodeKey): key is PropertyValueRangeGroupingNodeKey;
/** Checks whether the given node key is a `PropertyValueGroupingNodeKey`. */
function isPropertyValueGrouping(key: HierarchyNodeKey): key is PropertyValueGroupingNodeKey;
/** Checks whether the given node key is a `PropertyGroupingNodeKey`. */
function isPropertyGrouping(key: HierarchyNodeKey): key is PropertyGroupingNodeKey;
/**
* Compares two given keys. Returns:
* - `0` if they are equal,
* - `negative value` if lhs key is less than rhs key,
* - `positive value` if lhs key is more than rhs key.
*/
function compare(lhs: HierarchyNodeKey, rhs: HierarchyNodeKey): number;
/** Checks whether the two given keys are equal. */
function equals(lhs: HierarchyNodeKey, rhs: HierarchyNodeKey): boolean;
}
//# sourceMappingURL=HierarchyNodeKey.d.ts.map