UNPKG

@yandex/ymaps3-types

Version:

Types for ymaps3 maps library

44 lines (43 loc) 1.93 kB
import { Context, GenericComplexEntity, GenericEntity } from "./Entities"; import { YMapEntity, YMapGroupEntity } from "./YMapEnities"; export type DomDetach = () => void; type DomContext = { attach(entity: GenericEntity<unknown>, element: Element): DomDetach; }; export declare const DomContext: Context<DomContext>; export type DomContextDestroy = () => void; /** * @ignore * Creates DomContext for specified container for entity. * NB: Does not allow to change container element on the fly. */ export declare function createDomContext(containerEntity: GenericComplexEntity<unknown>, containerElement: Element, containerEndElement?: Element): [ DomContext, DomContextDestroy ]; /** * Hook for providing DOM context in entity * @param entity - Entity to provide the DomContext * @param element - DOM element to attach * @param container - DOM element to provide to descendants in new DomContext * @returns Function that detaches the DOM element and DomContext from the entity */ export declare function useDomContext(entity: GenericComplexEntity<unknown>, element: Element, container: Element | null): DomDetach; /** @deprecated Use {@link useDomContext} instead. */ export declare abstract class DomEntity<TProps, TElement extends Element = HTMLElement, DefaultProps extends {} = {}> extends YMapGroupEntity<TProps, DefaultProps> { protected _element?: TElement; private _detachDom?; private _destroyDomCtx?; constructor(props: TProps, children?: YMapEntity<unknown>[]); protected _onAttach(): void; protected _onDetach(): void; protected _onUpdate(props: Partial<TProps>): void; protected abstract _createDom(): TElement | { element: TElement; container: Element; containerEndElement?: Element; }; protected abstract _updateDom(element: TElement, props: Partial<TProps>): void; protected _destroyDom(_element: TElement): void; } export {};