UNPKG

@zeplin/extension-model

Version:

Models exposed to Zeplin extensions

239 lines (238 loc) 5.88 kB
import { Blur } from "./blur.js"; import { Border } from "./border.js"; import { Fill } from "./fill.js"; import { Shadow } from "./shadow.js"; import { TextStyle } from "./textStyle.js"; import { Layout } from "./layout.js"; import { LayerConstraints } from "./layerConstraints.js"; import { CornerRadius } from "./cornerRadius.js"; import { Asset, AssetContent, Version } from "./version.js"; export declare const LAYER_TYPES: Record<string, string>; export declare const LAYER_SHAPE_TYPES: Record<string, string>; export interface Rect { x: number; y: number; width: number; height: number; } export interface TextStyleWithRange { range: { start: number; end: number; }; textStyle: TextStyle; } export interface LayerData { type: string; name: string; rect: Rect; opacity: number; fills: any[]; borders: any[]; borderRadius: number | number[]; shadows: any[]; blur?: any; textStyles?: any[]; content?: string; layers?: any[]; exportable?: boolean; blendMode?: string; assets?: Asset[]; sourceId?: string; layout?: any; rotation?: number; layoutAlignment?: string; layoutGrow?: number; inspectable?: boolean; constraints?: any; cornerRadius?: any; styleName?: string; styleSourceId?: string; textStyleName?: string; textStyleSourceId?: string; shapeType?: string; maxHeight?: number; maxWidth?: number; minHeight?: number; minWidth?: number; maxLines?: number; textTruncation?: string; componentName?: string; componentId?: string; componentSourceId?: string; interactionLevel?: boolean; } /** * An interface that represents a Layer. */ export declare class Layer { /** * Type of the layer. Possible values are defined in {@link Layer.TYPE} */ type: string; /** * Name of the layer */ name: string; /** * Bounding rectangle of the layer. */ rect: Rect; /** * Opacity of the layer. A number in interval [0, 1]. */ opacity: number; /** * Fills applied to the layer. */ fills: Fill[]; /** * Borders of the layer. */ borders: Border[]; /** * Border radius of the layer. */ borderRadius: number | number[]; /** * Shadows applied to the layer. */ shadows: Shadow[]; /** * Blur applied to the layer. */ blur?: Blur; /** * List of text styles used in the layer. */ textStyles?: TextStyleWithRange[]; /** * Text content of the layer. */ content?: string; /** * Layers contained by the layer. */ layers?: Layer[]; /** * Indicates whether the layer is exportable or not. */ exportable?: boolean; /** * Blend mode of the layer. Possible values are defined in {@link Fill.BLEND_MODE} */ blendMode?: string; /** * Asset contents of the layer. */ assets?: AssetContent[]; /** * Id of the layer in the source design document. */ sourceId?: string; /** * Layout properties of the layer. */ layout?: Layout; /** * Rotation applied to the layer. */ rotation?: number; /** * Alignment of the layer. Possible values are defined in {@link Layout.ALIGNMENT} */ layoutAlignment?: string; /** * Grow rate of the layer. This property specifies how much of the remaining space in the parent layer should be assigned to the item. Can be zero or a positive number. */ layoutGrow?: number; /** * Whether the layer is inspectable in Zeplin. */ inspectable?: boolean; /** * Constraints of the layer. */ constraints?: LayerConstraints; /** * Corner radius of the layer. */ cornerRadius?: CornerRadius; /** * Shared style name of the layer. */ styleName?: string; /** * Shared style source identifier of the layer. */ styleSourceId?: string; /** * Shared text style name of the layer. */ textStyleName?: string; /** * Shared text style identifier of the layer. */ textStyleSourceId?: string; /** * Shape type of the shape layer. Possible values are defined in {@link Layer.SHAPE_TYPE} */ shapeType?: string; /** * Max height of the layer. */ maxHeight?: number; /** * Max width of the layer. */ maxWidth?: number; /** * Min height of the layer. */ minHeight?: number; /** * Min width of the layer. */ minWidth?: number; /** * Max lines of the text layer. */ maxLines?: number; /** * Determines how long text should be truncated for the text layers. Possible value is "end". */ textTruncation?: string; /** * Component name of the layer. */ componentName?: string; /** * Component source identifier of the layer. */ componentSourceId?: string; /** * Parent layer of the layer. */ parent: Layer | null; /** * Version containing the layer. */ version?: Version; static get TYPE(): Record<string, string>; static get SHAPE_TYPE(): Record<string, string>; static get ALLOWED_FIELDS(): string[]; constructor(layerData: LayerData, parent: Layer | null, version?: Version); /** * Creates a Layer instance from a JSON string * * @param json JSON string representing a layer * @returns A new Layer instance */ static fromJSON(json: string): Layer; /** * Gets the default text style of the layer * * @returns The default text style of the layer, or undefined if the layer is not a text layer or has no text styles */ get defaultTextStyle(): TextStyle | undefined; }