You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.5 KiB

4 months ago
import type { BaseStyleProps, DisplayObject, DisplayObjectConfig, Group, IAnimation } from '@antv/g';
import { CustomElement } from '@antv/g';
import type { Keyframe } from '../../types';
export interface BaseShapeStyleProps extends BaseStyleProps {
}
/**
* <zh/>
*
* <en/> Base class for shapes
*/
export declare abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends CustomElement<StyleProps> {
constructor(options: DisplayObjectConfig<StyleProps>);
/**
* <zh/>
*
* <en/> parsed attributes
* @returns <zh/> | <en/> parsed attributes
* @internal
*/
protected get parsedAttributes(): Required<StyleProps>;
/**
* <zh/>
*
* <en/> shape instance map
* @internal
*/
protected shapeMap: Record<string, DisplayObject>;
/**
* <zh/>
*
* <en/> animation instance map
* @internal
*/
protected animateMap: Record<string, IAnimation>;
/**
* <zh/>
*
* <en/> create, update or remove shape
* @param className - <zh/> | <en/> shape name
* @param Ctor - <zh/> | <en/> shape type
* @param style - <zh/> false | <en/> shape style. Pass false to remove the shape
* @param container - <zh/> | <en/> container
* @param hooks - <zh/> | <en/> hooks
* @returns <zh/> | <en/> shape instance
*/
protected upsert<T extends DisplayObject>(className: string, Ctor: string | {
new (...args: any[]): T;
}, style: T['attributes'] | false, container: DisplayObject, hooks?: UpsertHooks): T | undefined;
update(attr?: Partial<StyleProps>): void;
/**
* <zh/>
*
* <en/> will be called automatically when initializing
* @param attributes
* @param container
*/
abstract render(attributes: Required<StyleProps>, container: Group): void;
bindEvents(): void;
/**
* <zh/>
*
* <en/> Extracts the shape styles from a given attribute object.
* Removes specific styles like position, transformation, and class name.
* @param style - <zh/> | <en/> attribute object
* @returns <zh/> | <en/> An object containing only the style properties.
*/
getGraphicStyle<T extends Record<string, any>>(style: T): Omit<T, 'x' | 'y' | 'z' | 'transform' | 'transformOrigin' | 'className' | 'class' | 'zIndex' | 'visibility'>;
/**
* Get the prefix pairs for composite shapes used to handle animation
* @returns tuples array where each tuple contains a key corresponding to a method `get${key}Style` and its shape prefix
* @internal
*/
protected get compositeShapes(): [string, string][];
animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions): IAnimation | null;
getShape<T extends DisplayObject>(name: string): T;
private setVisibility;
destroy(): void;
}
/**
* <zh/> upsert
*
* <en/> Shape upsert method lifecycle hooks
*/
export interface UpsertHooks {
/**
* <zh/>
*
* <en/> Before creating the shape
*/
beforeCreate?: () => void;
/**
* <zh/>
*
* <en/> After creating the shape
* @param instance - <zh/> | <en/> shape instance
*/
afterCreate?: (instance: DisplayObject) => void;
/**
* <zh/>
*
* <en/> Before updating the shape
* @param instance - <zh/> | <en/> shape instance
*/
beforeUpdate?: (instance: DisplayObject) => void;
/**
* <zh/>
*
* <en/> After updating the shape
* @param instance - <zh/> | <en/> shape instance
*/
afterUpdate?: (instance: DisplayObject) => void;
/**
* <zh/>
*
* <en/> Before destroying the shape
* @param instance - <zh/> | <en/> shape instance
*/
beforeDestroy?: (instance: DisplayObject) => void;
/**
* <zh/>
*
* <en/> After destroying the shape
* @param instance - <zh/> | <en/> shape instance
*/
afterDestroy?: (instance: DisplayObject) => void;
}