/** @packageDocumentation * @module Content */ import { Id64String } from "@bentley/bentleyjs-core"; import { ClassInfo, ClassInfoJSON, CompressedClassInfoJSON, RelationshipPath, RelationshipPathJSON, StrippedRelationshipPath } from "../EC"; import { RelationshipMeaning } from "../rules/content/modifiers/RelatedPropertiesSpecification"; import { CategoryDescription, CategoryDescriptionJSON } from "./Category"; import { EditorDescription } from "./Editor"; import { Property, PropertyJSON } from "./Property"; import { RendererDescription } from "./Renderer"; import { TypeDescription } from "./TypeDescription"; /** * Data structure for a [[Field]] serialized to JSON. * @public */ export interface BaseFieldJSON { category: CategoryDescriptionJSON | string; name: string; label: string; type: TypeDescription; isReadonly: boolean; priority: number; renderer?: RendererDescription; editor?: EditorDescription; } /** * Data structure for a [[PropertiesField]] serialized to JSON. * @public */ export interface PropertiesFieldJSON extends BaseFieldJSON { properties: PropertyJSON[]; } /** * Data structure for a [[NestedContentField]] serialized to JSON. * @public */ export interface NestedContentFieldJSON extends BaseFieldJSON { contentClassInfo: TClassInfoJSON; pathToPrimaryClass: RelationshipPathJSON; /** @alpha */ relationshipMeaning?: RelationshipMeaning; /** @alpha */ actualPrimaryClassIds?: Id64String[]; autoExpand?: boolean; nestedFields: FieldJSON[]; } /** * JSON representation of a [[Field]] * @public */ export declare type FieldJSON = BaseFieldJSON | PropertiesFieldJSON | NestedContentFieldJSON; /** * Describes a single content field. A field is usually represented as a grid column * or a property pane row. * * @public */ export declare class Field { /** Category information */ category: CategoryDescription; /** Unique name */ name: string; /** Display label */ label: string; /** Description of this field's values data type */ type: TypeDescription; /** Are values in this field read-only */ isReadonly: boolean; /** Priority of the field. Higher priority fields should appear first in the UI */ priority: number; /** Property renderer used to render values of this field */ renderer?: RendererDescription; /** Property editor used to edit values of this field */ editor?: EditorDescription; /** Parent field */ private _parent?; /** * Creates an instance of Field. * @param category Category information * @param name Unique name * @param label Display label * @param type Description of this field's values data type * @param isReadonly Are values in this field read-only * @param priority Priority of the field * @param editor Property editor used to edit values of this field * @param renderer Property renderer used to render values of this field */ constructor(category: CategoryDescription, name: string, label: string, type: TypeDescription, isReadonly: boolean, priority: number, editor?: EditorDescription, renderer?: RendererDescription); /** * Is this a [[PropertiesField]] */ isPropertiesField(): this is PropertiesField; /** * Is this a [[NestedContentField]] */ isNestedContentField(): this is NestedContentField; /** * Get parent */ get parent(): NestedContentField | undefined; clone(): Field; /** Serialize this object to JSON */ toJSON(): FieldJSON; /** Serialize this object to compressed JSON */ toCompressedJSON(classesMap: { [id: string]: CompressedClassInfoJSON; }): FieldJSON; /** Deserialize [[Field]] from JSON */ static fromJSON(json: FieldJSON | undefined, categories: CategoryDescription[]): Field | undefined; /** * Deserialize [[Field]] from JSON * @deprecated Use an overload that takes a list of categories */ static fromJSON(json: FieldJSON | string | undefined): Field | undefined; /** Deserialize [[Field]] from compressed JSON */ static fromCompressedJSON(json: FieldJSON, classesMap: { [id: string]: CompressedClassInfoJSON; }): FieldJSON | undefined; protected static getCategoryFromFieldJson(fieldJson: FieldJSON, categories?: CategoryDescription[]): CategoryDescription; /** * Reviver function that can be used as a second argument for * `JSON.parse` method when parsing Field objects. * * @internal * @deprecated Use [[fromJSON]] */ static reviver(key: string, value: any): any; /** @internal */ resetParentship(): void; /** @internal */ rebuildParentship(parentField?: NestedContentField): void; /** * Get descriptor for this field. * @public */ getFieldDescriptor(): FieldDescriptor; } /** * Describes a content field that's based on one or more similar * EC properties. * * @public */ export declare class PropertiesField extends Field { /** A list of properties this field is created from */ properties: Property[]; /** * Creates an instance of PropertiesField. * @param category Category information * @param name Unique name * @param label Display label * @param type Description of this field's values data type * @param isReadonly Are values in this field read-only * @param priority Priority of the field * @param properties A list of properties this field is created from * @param editor Property editor used to edit values of this field * @param renderer Property renderer used to render values of this field */ constructor(category: CategoryDescription, name: string, label: string, description: TypeDescription, isReadonly: boolean, priority: number, properties: Property[], editor?: EditorDescription, renderer?: RendererDescription); clone(): PropertiesField; /** Serialize this object to JSON */ toJSON(): PropertiesFieldJSON; /** Deserialize [[PropertiesField]] from JSON */ static fromJSON(json: PropertiesFieldJSON | undefined, categories: CategoryDescription[]): PropertiesField | undefined; /** * Deserialize [[PropertiesField]] from JSON * @deprecated Use an overload that takes a list of categories */ static fromJSON(json: PropertiesFieldJSON | string | undefined): PropertiesField | undefined; /** * Get descriptor for this field. * @public */ getFieldDescriptor(): FieldDescriptor; } /** * Describes a content field that contains [Nested content]($docs/learning/presentation/Content/Terminology#nested-content). * * @public */ export declare class NestedContentField extends Field { /** Information about an ECClass whose properties are nested inside this field */ contentClassInfo: ClassInfo; /** Relationship path to [Primary class]($docs/learning/presentation/Content/Terminology#primary-class) */ pathToPrimaryClass: RelationshipPath; /** @alpha */ relationshipMeaning: RelationshipMeaning; /** @alpha */ actualPrimaryClassIds: Id64String[]; /** Contained nested fields */ nestedFields: Field[]; /** Flag specifying whether field should be expanded */ autoExpand?: boolean; /** * Creates an instance of NestedContentField. * @param category Category information * @param name Unique name * @param label Display label * @param type Description of this field's values data type * @param isReadonly Are values in this field read-only * @param priority Priority of the field * @param contentClassInfo Information about an ECClass whose properties are nested inside this field * @param pathToPrimaryClass Relationship path to [Primary class]($docs/learning/presentation/Content/Terminology#primary-class) * @param nestedFields Contained nested fields * @param editor Property editor used to edit values of this field * @param autoExpand Flag specifying whether field should be expanded * @param relationshipMeaning RelationshipMeaning of the field * @param renderer Property renderer used to render values of this field */ constructor(category: CategoryDescription, name: string, label: string, description: TypeDescription, isReadonly: boolean, priority: number, contentClassInfo: ClassInfo, pathToPrimaryClass: RelationshipPath, nestedFields: Field[], editor?: EditorDescription, autoExpand?: boolean, renderer?: RendererDescription); clone(): NestedContentField; /** * Get field by its name * @param name Name of the field to find * @param recurse Recurse into nested fields */ getFieldByName(name: string, recurse?: boolean): Field | undefined; /** Serialize this object to JSON */ toJSON(): NestedContentFieldJSON; /** Deserialize [[NestedContentField]] from JSON */ static fromJSON(json: NestedContentFieldJSON | undefined, categories: CategoryDescription[]): NestedContentField | undefined; /** * Deserialize [[NestedContentField]] from JSON * @deprecated Use an overload that takes a list of categories */ static fromJSON(json: NestedContentFieldJSON | string | undefined): NestedContentField | undefined; /** @internal */ resetParentship(): void; /** @internal */ rebuildParentship(parentField?: NestedContentField): void; } /** @internal */ export declare const getFieldByName: (fields: Field[], name: string, recurse?: boolean | undefined) => Field | undefined; /** * Types of different field descriptors. * @public */ export declare enum FieldDescriptorType { Name = "name", Properties = "properties" } /** * Base for a field descriptor * @public */ export interface FieldDescriptorBase { type: FieldDescriptorType; } /** * A union of all possible field descriptor types * @public */ export declare type FieldDescriptor = NamedFieldDescriptor | PropertiesFieldDescriptor; /** @public */ export declare namespace FieldDescriptor { /** Is this a named field descriptor */ function isNamed(d: FieldDescriptor): d is NamedFieldDescriptor; /** Is this a properties field descriptor */ function isProperties(d: FieldDescriptor): d is PropertiesFieldDescriptor; } /** * Field descriptor that identifies a content field by its unique name. * @public */ export interface NamedFieldDescriptor extends FieldDescriptorBase { type: FieldDescriptorType.Name; fieldName: string; } /** * Field descriptor that identifies a properties field using a list of * properties that the field contains. * @public */ export interface PropertiesFieldDescriptor extends FieldDescriptorBase { type: FieldDescriptorType.Properties; pathFromSelectToPropertyClass: StrippedRelationshipPath; /** * A list of properties that describe the field. At least one property in the list must * match at least one property in the field for the descriptor to be considered matching. */ properties: Array<{ /** Full class name */ class: string; /** Property name */ name: string; }>; /** @deprecated Use [[properties]] array */ propertyClass?: string; /** @deprecated Use [[properties]] array */ propertyName?: string; } //# sourceMappingURL=Fields.d.ts.map