import type { Instance, Modifier as PopperModifier, Options, Placement, PositioningStrategy, State, StrictModifiers, VirtualElement, } from '@popperjs/core'; import type { OctaneNode } from 'octane'; import type { CSSProperties } from 'react'; export type RefObject = { current: T | null }; export type RefCallback = (value: T | null) => void; export type Ref = RefCallback | RefObject | null | undefined; export type RefHandler = (ref: HTMLElement | null) => void; export type Style = CSSProperties; // OCTANE DIVERGENCE[popper-octane-node-and-ref-types][types:popper-adapted-main] // OCTANE DIVERGENCE[popper-octane-node-and-ref-types][types:popper-adapted-svg] export interface ManagerProps { children: OctaneNode; } export interface ReferenceChildrenProps { ref: Ref; } export interface ReferenceProps { children: (props: ReferenceChildrenProps) => OctaneNode; innerRef?: Ref; } export interface PopperArrowProps { ref: Ref; style: Style; } export interface PopperChildrenProps { ref: Ref; style: Style; placement: Placement; isReferenceHidden?: boolean; hasPopperEscaped?: boolean; update: () => Promise>; forceUpdate: () => Partial; arrowProps: PopperArrowProps; } type UnionWhere = U extends M ? U : never; type StrictModifierNames = NonNullable; export type StrictModifier = UnionWhere< StrictModifiers, { name?: Name } >; export type Modifier< Name, ModifierOptions extends object = object, > = Name extends StrictModifierNames ? StrictModifier : Partial>; export interface PopperProps { children: (props: PopperChildrenProps) => OctaneNode; innerRef?: Ref; modifiers?: ReadonlyArray>; placement?: Placement; strategy?: PositioningStrategy; referenceElement?: HTMLElement | VirtualElement; onFirstUpdate?: (state: Partial) => void; } export type UsePopperOptions = Omit, 'modifiers'> & { createPopper?: typeof import('@popperjs/core').createPopper; modifiers?: ReadonlyArray>; }; export interface UsePopperResult { styles: Record; attributes: Record | undefined>; state: State | null; update: Instance['update'] | null; forceUpdate: Instance['forceUpdate'] | null; }