@progress/sitefinity-widget-designers-sdk
Version:
This package aims to create a parity for widget designer generation similar to the [autogenerated widget designers](https://www.progress.com/documentation/sitefinity-cms/autogenerated-field-types) in Sitefinity. Due to some limitations in Typescript and J
81 lines (80 loc) • 2.92 kB
TypeScript
/**
* Generates the metadata for the widget designer based on a decorated widget entity.
*/
export declare class EntityMetadataGenerator {
/**
* Compiles the designer metadata from the widget entity.
* The passed class should be decorated with {@link WidgetEntity}.
* @param widgetEntityClass The widget enitity class.
* @returns The generated designer metadata.
*/
static extractMetadata(widgetEntityClass: any): MetadataModel | undefined;
/**
* Extracts the entity's default values according to the widget designer metadata.
* The designer metadata (the {@link DefaultValue} decorator) takes precedence over the defaults set in the entity class definition.
* Handles special scenarios such as complex objects, booleans, numbers.
* @param {MetadataModel} metadata The designer metadata.
*/
static extractDefaultValues(metadata: MetadataModel): {
[key: string]: any;
};
/**
* Deserializes the values for widget properties. Parses JSON objects, turns boolean properties from string to true boolean, parses numbers.
* @param serializedValues The values assigned to the widget's properties that are received from the server.
* @param metadata The widget designer metadata.
*/
static parseValues(serializedValues: {
[key: string]: any;
}, metadata: MetadataModel): any;
private static getPropertyDefaultValue;
private static getDefaultValuesForComplexType;
private static deserializeProperties;
private static buildMetadata;
private static pushIfHasSections;
private static compileProperty;
private static unpackDataModel;
private static assignIfEmpty;
private static modifyPropertyMeta;
private static compileSpecialProperties;
private static generateCategory;
private static generateSection;
private static capitalize;
private static parseBooleanValue;
private static parseChoiceBooleanValue;
private static parseMultipleChoicesValue;
private static isMultipleChoice;
private static extractPropertiesMetadataFromHierarchy;
private static skipMetaKeyword;
private static mergePrototypes;
private static isChoiceKey;
}
export interface MetadataModel {
Name: string;
Caption: string;
PropertyMetadata: CategoryModel[];
PropertyMetadataFlat?: PropertyModel[];
}
export interface CategoryModel {
Name: string;
Sections: SectionModel[];
}
export interface SectionModel {
Name: string;
Title: string | null;
Properties: PropertyModel[];
CategoryName?: string;
}
export interface PropertyModel {
Name: string;
DefaultValue: any;
Title: string;
SectionName: string | null;
CategoryName: string | null;
Type: string | null;
Properties: {
[key: string]: any;
};
TypeChildProperties: PropertyModel[];
Position: number;
[key: string]: any;
}