@ozen-ui/kit
Version:
React component library
20 lines (19 loc) • 798 B
TypeScript
import { type RefObject } from 'react';
export type PortalManagerItem = {
key: number;
ref: RefObject<HTMLElement>;
};
export type PortalManagerItems = Array<PortalManagerItem>;
export type PortalManager = {
get: () => PortalManagerItems;
add: (portalItem: PortalManagerItem) => void;
remove: (portalRef: PortalManagerItem['ref']) => void;
subscribe: (func: (portalItems: PortalManagerItems) => void) => void;
unsubscribe: (func: (portalItems: PortalManagerItems) => void) => void;
};
export declare const createPortalManager: () => PortalManager;
export declare const portalManager: PortalManager;
export type UsePortalManager = {
portals: PortalManagerItems;
} & Pick<PortalManager, 'add' | 'remove'>;
export declare function usePortalManager(): UsePortalManager;