UNPKG

@zeplin/extension-model

Version:

Models exposed to Zeplin extensions

77 lines (76 loc) 1.92 kB
import { Version } from "./version.js"; import { ComponentVariant } from "./componentVariant.js"; /** * Interface for component property */ export interface ComponentProperty { id: string; name: string; value: string; } /** * Interface for component data */ export interface ComponentData { name: string; description?: string; sourceId: string; latestVersion: any; properties?: ComponentProperty[]; } /** * An interface that represents a Component. */ export declare class Component { /** * Name of the component. */ name: string; /** * Description of the component. */ description?: string; /** * Identifier from design tool. */ sourceId: string; /** * Latest version of the component. */ latestVersion: Version | null; /** * Variant properties of the component. */ properties?: ComponentProperty[]; /** * Variant that the component is part of. */ variant?: ComponentVariant; /** * Map of properties by id and name */ private _propertyMap; static get ALLOWED_FIELDS(): string[]; constructor(componentData: ComponentData, variant?: ComponentVariant); /** * Creates a Component instance from a JSON string * * @param json JSON string representing a component * @returns A new Component instance */ static fromJSON(json: string): Component; /** * Finds property by unique identifier * * @param propertyId Unique identifier of the property * @returns The property or undefined if not found */ findPropertyById(propertyId: string): ComponentProperty | undefined; /** * Finds property by name * * @param name Name of the property * @returns The property or undefined if not found */ findPropertyByName(name: string): ComponentProperty | undefined; }