UNPKG

@redocly/theme

Version:

Shared UI components lib

33 lines (32 loc) 1.29 kB
/** * Based on https://github.com/roginfarrer/collapsed/blob/main/packages/react-collapsed/src/index.ts * Simplified for our usecase. */ import type React from 'react'; import type { RefObject } from 'react'; export interface UseCollapseProps { isExpanded?: boolean; collapseElRef: React.RefObject<HTMLElement | null>; onTransitionStateChange?: (state: 'collapseEnd' | 'expandEnd' | 'collapseStart' | 'expandStart' | 'collapsing' | 'expanding') => void; } export declare function useCollapse({ isExpanded, collapseElRef, onTransitionStateChange: configOnTransitionStateChange, }: UseCollapseProps): { isExpanded: boolean | undefined; style: { display: string; height: string; overflow: string; } | { display?: undefined; height?: undefined; overflow?: undefined; }; }; export declare function getAutoHeightDuration(height: number | string): number; export declare function getElementHeight(el: RefObject<HTMLElement | null>): number; export declare function setAnimationTimeout(callback: () => void, timeout: number): { id?: number; }; export declare function clearAnimationTimeout(frame: { id?: number; }): void; export declare function useEvent<T extends (...args: any[]) => any>(callback?: T): T;