import type { CollectionEvents, ObjectEvents, TPointerEvent } from '../EventTypeDefs'; import type { TClassProperties, TSVGReviver, TOptions, Abortable, TCacheCanvasDimensions } from '../typedefs'; import { FabricObject } from './Object/FabricObject'; import type { FabricObjectProps, SerializedObjectProps } from './Object/types'; import type { ImperativeLayoutOptions, LayoutBeforeEvent, LayoutAfterEvent } from '../LayoutManager/types'; import { LayoutManager } from '../LayoutManager/LayoutManager'; import type { SerializedLayoutManager } from '../LayoutManager/LayoutManager'; import type { DrawContext } from './Object/Object'; import type { Table } from './Table'; export interface GroupEvents extends ObjectEvents, CollectionEvents { 'layout:before': LayoutBeforeEvent; 'layout:after': LayoutAfterEvent; } export interface GroupOwnProps { subTargetCheck: boolean; interactive: boolean; caterCacheForTextChildren: boolean; selected: boolean; useSelectedFlag: boolean; } export interface SerializedGroupProps extends SerializedObjectProps, GroupOwnProps { objects: SerializedObjectProps[]; layoutManager: SerializedLayoutManager; } export interface GroupProps extends FabricObjectProps, GroupOwnProps { layoutManager: LayoutManager; } export declare const groupDefaultValues: Partial>; declare const Group_base: { new (...args: any[]): { _objects: FabricObject[]; _onObjectAdded(object: FabricObject): void; _onObjectRemoved(object: FabricObject): void; _onStackOrderChanged(object: FabricObject): void; add(...objects: FabricObject[]): number; insertAt(index: number, ...objects: FabricObject[]): number; remove(...objects: FabricObject[]): FabricObject, SerializedObjectProps, ObjectEvents>[]; forEachObject(callback: (object: FabricObject, index: number, array: FabricObject[]) => any): void; getObjects(...types: string[]): FabricObject, SerializedObjectProps, ObjectEvents>[]; item(index: number): FabricObject, SerializedObjectProps, ObjectEvents>; isEmpty(): boolean; size(): number; contains(object: FabricObject, deep?: boolean): boolean; complexity(): number; sendObjectToBack(object: FabricObject): boolean; bringObjectToFront(object: FabricObject): boolean; sendObjectBackwards(object: FabricObject, intersecting?: boolean): boolean; bringObjectForward(object: FabricObject, intersecting?: boolean): boolean; moveObjectTo(object: FabricObject, index: number): boolean; findNewLowerIndex(object: FabricObject, idx: number, intersecting?: boolean): number; findNewUpperIndex(object: FabricObject, idx: number, intersecting?: boolean): number; collectObjects({ left, top, width, height }: import("../typedefs").TBBox, { includeIntersecting }?: { includeIntersecting?: boolean; }): import("./Object/InteractiveObject").InteractiveFabricObject, SerializedObjectProps, ObjectEvents>[]; }; } & { new (options?: GroupProps | undefined): FabricObject; ownDefaults: Partial, SerializedObjectProps, ObjectEvents>>>; getDefaults(): Record; createControls(): { controls: Record; }; stateProperties: string[]; cacheProperties: string[]; type: string; colorProperties: string[]; customProperties: string[]; _fromObject({ type, ...serializedObjectOptions }: Record, { extraParam, ...options }?: Abortable & { extraParam?: string; }): Promise; fromObject>(object: T, options?: Abortable): Promise, SerializedObjectProps, ObjectEvents>>; }; /** * @fires object:added * @fires object:removed * @fires layout:before * @fires layout:after */ export declare class Group extends Group_base implements GroupProps { /** * Used to optimize performance * set to `false` if you don't need contained objects to be targets of events * @default * @type boolean */ subTargetCheck: boolean; /** * *PMW property added* * Whether to cater to the text children objects for caching. */ caterCacheForTextChildren: boolean; /** * *PMW property added* * Whether the object is currently selected. * This is being used in GraphicItemSlideshowMediator to handle text editing. * The editing mode is entered on single click when the item is selected. So we use this flag to determine if the item is selected. */ selected: boolean; /** * *PMW property added* * Whether the PMW added selected flag should be used. */ useSelectedFlag: boolean; /** * Used to allow targeting of object inside groups. * set to true if you want to select an object inside a group.\ * **REQUIRES** `subTargetCheck` set to true * This will be not removed but slowly replaced with a method setInteractive * that will take care of enabling subTargetCheck and necessary object events. * There is too much attached to group interactivity to just be evaluated by a * boolean in the code * @default * @deprecated * @type boolean */ interactive: boolean; layoutManager: LayoutManager; /** * Used internally to optimize performance * Once an object is selected, instance is rendered without the selected object. * This way instance is cached only once for the entire interaction with the selected object. * @private */ protected _activeObjects: FabricObject[]; static type: string; static ownDefaults: Record; private __objectSelectionTracker; private __objectSelectionDisposer; static getDefaults(): Record; /** * Constructor * * @param {FabricObject[]} [objects] instance objects * @param {Object} [options] Options object */ constructor(objects?: FabricObject[], options?: Partial); /** * *PMW function added* * Called everytime a group object is deselected. The useSelectedFlag is used and only true when the group object is slideshow item. See docs of 'selected' property. */ onDeselect(options?: { e?: TPointerEvent; object?: any; }): boolean; /** * *PMW* function added * Expands cache dimensions to cater to any text children objects present inside the group. * This is to prevent any part of the font rendering outside the selector box getting cut. * @private * @return {Object}.x width of object to be cached * @return {Object}.y height of object to be cached * @return {Object}.width width of canvas * @return {Object}.height height of canvas * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache */ _getCacheCanvasDimensions(): TCacheCanvasDimensions; /** * *PMW funtion added* * Scans itself for children text items and returns the max font size from them. Multiplies the expansion factor with the fontsize if it exists for the font family. If there's no text, returns 0. * @private */ _getMaxExpandedFontSizeFromTextChildren(): number; /** * Shared code between group and active selection * Meant to be used by the constructor. */ protected groupInit(objects: FabricObject[], options: { layoutManager?: LayoutManager; top?: number; left?: number; }): void; /** * Checks if object can enter group and logs relevant warnings * @private * @param {FabricObject} object * @returns */ canEnterGroup(object: FabricObject): boolean; /** * Override this method to enhance performance (for groups with a lot of objects). * If Overriding, be sure not pass illegal objects to group - it will break your app. * @private */ protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]): FabricObject, SerializedObjectProps, ObjectEvents>[]; /** * Add objects * @param {...FabricObject[]} objects */ add(...objects: FabricObject[]): number; /** * Inserts an object into collection at specified index * @param {FabricObject[]} objects Object to insert * @param {Number} index Index to insert object at */ insertAt(index: number, ...objects: FabricObject[]): number; /** * Remove objects * @param {...FabricObject[]} objects * @returns {FabricObject[]} removed objects */ remove(...objects: FabricObject[]): FabricObject, SerializedObjectProps, ObjectEvents>[]; _onObjectAdded(object: FabricObject): void; /** * @private * @param {FabricObject} object * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it */ _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean): void; /** * @private * @param {'added'|'removed'} type * @param {FabricObject[]} targets */ _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]): void; _onStackOrderChanged(): void; /** * @private * @param {string} key * @param {*} value */ _set(key: string, value: any): this; /** * @private */ _shouldSetNestedCoords(): boolean; /** * Remove all objects * @returns {FabricObject[]} removed objects */ removeAll(): FabricObject, SerializedObjectProps, ObjectEvents>[]; /** * keeps track of the selected objects * @private */ __objectSelectionMonitor(selected: T, { target: object, }: ObjectEvents[T extends true ? 'selected' : 'deselected']): void; /** * @private * @param {boolean} watch * @param {FabricObject} object */ _watchObject(watch: boolean, object: FabricObject): void; /** * @private * @param {FabricObject} object * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane */ enterGroup(object: FabricObject, removeParentTransform?: boolean): void; /** * @private * @param {FabricObject} object * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane */ _enterGroup(object: FabricObject, removeParentTransform?: boolean): void; /** * @private * @param {FabricObject} object * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it */ exitGroup(object: FabricObject, removeParentTransform?: boolean): void; /** * Executes the inner fabric logic of exiting a group. * - Stop watching the object * - Remove the object from the optimization map this._activeObjects * - unset the group property of the object * @protected * @param {FabricObject} object * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it */ _exitGroup(object: FabricObject, removeParentTransform?: boolean): void; /** * Decide if the group should cache or not. Create its own cache level * needsItsOwnCache should be used when the object drawing method requires * a cache step. * Generally you do not cache objects in groups because the group is already cached. * @return {Boolean} */ shouldCache(): boolean; /** * Check if this object or a child object will cast a shadow * @return {Boolean} */ willDrawShadow(): boolean; isGroup(): this is Group; /** * Check if instance or its group are caching, recursively up * @return {Boolean} */ isOnACache(): boolean; /** * Execute the drawing operation for an object on a specified context * @param {CanvasRenderingContext2D} ctx Context to render on */ drawObject(ctx: CanvasRenderingContext2D, forClipping: boolean | undefined, context: DrawContext): void; /** * @override * @return {Boolean} */ setCoords(): void; triggerLayout(options?: ImperativeLayoutOptions): void; /** * Renders instance on a given context * @param {CanvasRenderingContext2D} ctx context to render instance on */ render(ctx: CanvasRenderingContext2D): void; isTable(): this is Table; /** * * @private * @param {'toObject'|'toDatalessObject'} [method] * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output * @returns {FabricObject[]} serialized objects */ __serializeObjects(method: 'toObject' | 'toDatalessObject', propertiesToInclude?: string[]): any[]; /** * Returns object representation of an instance * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output * @return {Object} object representation of an instance */ toObject, keyof SerializedGroupProps>, K extends keyof T = never>(propertiesToInclude?: K[]): Pick & SerializedGroupProps; toString(): string; dispose(): void; /** * @private */ _createSVGBgRect(reviver?: TSVGReviver): string; /** * Returns svg representation of an instance * @param {TSVGReviver} [reviver] Method for further parsing of svg representation. * @return {String} svg representation of an instance */ _toSVG(reviver?: TSVGReviver): string[]; /** * Returns styles-string for svg-export, specific version for group * @return {String} */ getSvgStyles(): string; /** * Returns svg clipPath representation of an instance * @param {Function} [reviver] Method for further parsing of svg representation. * @return {String} svg representation of an instance */ toClipPathSVG(reviver?: TSVGReviver): string; /** * *PMW* * Aligns the items in the group horizontally. * @param {String} type Must be either 'left', 'right' or 'center' */ horizontalAlignment(type: 'left' | 'right' | 'center'): void; /** * *PMW* Aligns the items in the group vertically. * @param {String} type Must be either 'top', 'bottom' or 'center' */ verticalAlignment(type: 'top' | 'bottom' | 'center'): void; /** * @todo support loading from svg * @private * @static * @memberOf Group * @param {Object} object Object to create a group from * @returns {Promise} */ static fromObject>({ type, objects, layoutManager, ...options }: T, abortable?: Abortable): Promise; } export {}; //# sourceMappingURL=Group.d.ts.map