import { RefCallback } from 'react';
import { PortalContext, DOMContextSnapshot, ZIndexLayer, UsePortalContextReturn } from '../types';
/**
* Hook to access portal context information.
*
* @remarks
* This hook provides information about whether the component is
* inside a portal, the source context, and z-index management utilities.
*
* @returns Portal context information and utilities
*
* @example
* ```tsx
* function ModalContent() {
* const {
* portal,
* isInPortal,
* sourceContext,
* layer,
* getLayerZIndex,
* } = usePortalContext();
*
* return (
*
* {isInPortal && (
*
* This is in a portal at z-index layer: {layer}
* (z-index: {getLayerZIndex(layer)})
*
* )}
* {sourceContext && (
*
* Source viewport width: {sourceContext.viewport.width}px
*
* )}
*
* );
* }
* ```
*/
export declare function usePortalContext(): UsePortalContextReturn;
/**
* Hook to check if inside a portal.
*
* @returns Whether inside a portal
*
* @example
* ```tsx
* function ConditionalComponent() {
* const isInPortal = useIsInPortal();
*
* if (isInPortal) {
* return ;
* }
*
* return ;
* }
* ```
*/
export declare function useIsInPortal(): boolean;
/**
* Hook to get the source context from before the portal.
*
* @returns Source context snapshot or null
*
* @example
* ```tsx
* function ContextAwareModal() {
* const sourceContext = useSourceContext();
*
* if (sourceContext) {
* // Use source viewport for positioning calculations
* const { viewport } = sourceContext;
* // ...
* }
*
* return ;
* }
* ```
*/
export declare function useSourceContext(): DOMContextSnapshot | null;
/**
* Hook to get the current portal nesting depth.
*
* @returns Nesting depth (0 if not in portal)
*
* @example
* ```tsx
* function NestedModal() {
* const nestingDepth = usePortalNestingDepth();
*
* return (
*
* Nested modal at depth {nestingDepth}
*
* );
* }
* ```
*/
export declare function usePortalNestingDepth(): number;
/**
* Hook to get the portal hierarchy.
*
* @returns Array of portal contexts from innermost to outermost
*
* @example
* ```tsx
* function PortalDebug() {
* const hierarchy = usePortalHierarchy();
*
* return (
*
*
Portal depth: {hierarchy.length}
* {hierarchy.map((portal, i) => (
*
Level {i}: {portal.portalId}
* ))}
*
* );
* }
* ```
*/
export declare function usePortalHierarchy(): PortalContext[];
/**
* Hook to get z-index value for a specific layer.
*
* @param layer - Z-index layer
* @returns Z-index value
*
* @example
* ```tsx
* function FloatingElement() {
* const zIndex = useZIndexForLayer('popover');
*
* return (
*
* Floating content
*
* );
* }
* ```
*/
export declare function useZIndexForLayer(layer: ZIndexLayer): number;
/**
* Hook to get the current element's z-index context.
*
* @returns Z-index context from DOM context
*
* @example
* ```tsx
* function StackingAwareComponent() {
* const zIndexContext = useZIndexContext();
*
* return (
*
* Current z-index: {zIndexContext.zIndex}
* Layer: {zIndexContext.layer}
* Creates stacking context: {zIndexContext.createsStackingContext ? 'yes' : 'no'}
*
* );
* }
* ```
*/
export declare function useZIndexContext(): {
zIndex: number;
layer: ZIndexLayer;
createsStackingContext: boolean;
};
/**
* Hook to register an element with the z-index manager.
*
* @param layer - Z-index layer to register in
* @returns Registration info and utilities
*
* @example
* ```tsx
* function ManagedOverlay() {
* const { ref, zIndex, bringToFront } = useZIndexRegistration('modal');
*
* return (
*
* Click to bring to front
*
* );
* }
* ```
*/
export declare function useZIndexRegistration(layer?: ZIndexLayer): {
ref: RefCallback;
zIndex: number;
bringToFront: () => void;
sendToBack: () => void;
};
/**
* Hook to get all z-index layers for reference.
*
* @returns Record of layer names to z-index values
*
* @example
* ```tsx
* function ZIndexReference() {
* const layers = useZIndexLayers();
*
* return (
*
* {Object.entries(layers).map(([name, value]) => (
* - {name}: {value}
* ))}
*
* );
* }
* ```
*/
export declare function useZIndexLayers(): Record;