import * as react from 'react'; import { RefObject, LegacyRef, MutableRefObject } from 'react'; import { Maybe, AnyFunction } from 'yummies/types'; declare const attachRefs: (value: T | null, ...refs: Maybe | RefObject | LegacyRef>[]) => void; declare const useAbortController: () => AbortController; declare const useAbortSignal: () => AbortSignal; type ClickOutsideInput = { contentRef: MutableRefObject; onClick: VoidFunction; options?: AddEventListenerOptions; }; declare const useClickOutside: ({ contentRef, onClick, options, }: ClickOutsideInput) => void; /** * React hook for creating a value exactly once. * useMemo doesn't give this guarantee unfortunately - * https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily * https://reactjs.org/docs/hooks-reference.html#usememo * @param defineValue Function which returns defined value. */ declare const useConstant: (defineValue: () => T) => T; /** * React hook for creating a value exactly once. * useMemo doesn't give this guarantee unfortunately - * https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily * https://reactjs.org/docs/hooks-reference.html#usememo * @param defineFn Function which returns defined value. */ declare const useDefineRef: (defineFn: () => T) => MutableRefObject; declare const useElementRef: (selector: () => T) => react.MutableRefObject; declare const useEvent: (handler: H) => H; declare const useEventListener: ({ event, handler, options, deps, debounce, node, }: { event: EventName; handler: (e: HTMLElementEventMap[EventName]) => void; options?: boolean | AddEventListenerOptions; deps?: unknown[]; debounce?: number; node?: HTMLElement | Document | Window; }) => void; interface FlagHook { enabled: boolean; toggle: VoidFunction; enable: VoidFunction; disable: VoidFunction; } declare const useFlag: (defaultValue?: boolean) => FlagHook; declare const useForceUpdate: () => () => void; declare const useInitialHeight: () => { ref: react.MutableRefObject; initialHeight: number | undefined; }; type InstanceCreateConfig = TExtension & { abortSignal: AbortSignal; payload: TPayload; }; declare const createUseInstanceHook: (extension?: TExtension) => (factory: (config: InstanceCreateConfig, TExtension>) => TInstance, config?: { payload?: TPayload; onUpdate?: (payload: TPayload) => void; }) => TInstance; /** * The `useInstance` hook is used to create and manage an instance of an object * that requires access to the root store and an abort signal. * * You can create YOUR OWN CUSTOM `useInstance` hook using `createUseInstanceHook` if you need * to provide some specific data * * @param factory - A factory function that takes a configuration and returns an instance. * @param config - An optional configuration containing additional input parameters and an update function. * @returns An instance created by the factory function. */ declare const useInstance: (factory: (config: { abortSignal: AbortSignal; payload: NoInfer; }) => TInstance, config?: { payload?: TPayload | undefined; onUpdate?: ((payload: TPayload) => void) | undefined; } | undefined) => TInstance; declare const useIntersectionObserver: (callback: IntersectionObserverCallback, options?: IntersectionObserverInit) => IntersectionObserver; declare const useLastDefinedValue: (value: T) => T; declare const useLastValueRef: (value: T | null | undefined) => react.MutableRefObject; declare const useLifeCycle: (fn: () => { mount?: VoidFunction; unmount?: VoidFunction; }) => void; declare const useResizeObserver: (callback: ResizeObserverCallback) => react.MutableRefObject; declare const useSyncRef: (value: T) => react.MutableRefObject; declare const useToggle: (initialState?: boolean) => readonly [boolean, () => void, react.Dispatch>]; declare const useValue: (defaults: T | (() => T)) => { value: T; set: react.Dispatch>; }; declare const useVisibilityState: () => DocumentVisibilityState | undefined; export { attachRefs, createUseInstanceHook, useAbortController, useAbortSignal, useClickOutside, useConstant, useDefineRef, useElementRef, useEvent, useEventListener, useFlag, useForceUpdate, useInitialHeight, useInstance, useIntersectionObserver, useLastDefinedValue, useLastValueRef, useLifeCycle, useResizeObserver, useSyncRef, useToggle, useValue, useVisibilityState }; export type { FlagHook, InstanceCreateConfig };