UNPKG

@zeplin/extension-model

Version:

Models exposed to Zeplin extensions

62 lines (61 loc) 1.78 kB
import { Component } from "./component.js"; /** * Interface for component property descriptor */ export interface ComponentPropertyDescriptor { id: string; name: string; values: string[]; } /** * Interface for component variant data */ export interface ComponentVariantData { name: string; propertyDescriptors?: ComponentPropertyDescriptor[]; components?: any[]; } /** * An interface that represents component variant. */ export declare class ComponentVariant { /** * Name of the variant. */ name: string; /** * Details of the properties that components in this variant can take. */ propertyDescriptors: ComponentPropertyDescriptor[]; /** * Components included in the variant. */ components?: Component[]; /** * Map of property descriptors by id and name */ private _propertyMap; static get ALLOWED_FIELDS(): string[]; constructor(variantData: ComponentVariantData); /** * Creates a ComponentVariant instance from a JSON string * * @param json JSON string representing a component variant * @returns A new ComponentVariant instance */ static fromJSON(json: string): ComponentVariant; /** * Finds property descriptor by unique identifier * * @param propertyId Unique identifier of the property * @returns The property descriptor or undefined if not found */ findPropertyDescriptorById(propertyId: string): ComponentPropertyDescriptor | undefined; /** * Finds property descriptor by name * * @param name Name of the property * @returns The property descriptor or undefined if not found */ findPropertyDescriptorByName(name: string): ComponentPropertyDescriptor | undefined; }