UNPKG

5.22 kBTypeScriptView Raw
1import type { Placement, ModifierPhases } from "./enums";
2import type { PopperOffsetsModifier } from "./modifiers/popperOffsets";
3import type { FlipModifier } from "./modifiers/flip";
4import type { HideModifier } from "./modifiers/hide";
5import type { OffsetModifier } from "./modifiers/offset";
6import type { EventListenersModifier } from "./modifiers/eventListeners";
7import type { ComputeStylesModifier } from "./modifiers/computeStyles";
8import type { ArrowModifier } from "./modifiers/arrow";
9import type { PreventOverflowModifier } from "./modifiers/preventOverflow";
10import type { ApplyStylesModifier } from "./modifiers/applyStyles";
11export declare type Obj = {
12 [key: string]: any;
13};
14export declare type VisualViewport = EventTarget & {
15 width: number;
16 height: number;
17 offsetLeft: number;
18 offsetTop: number;
19 scale: number;
20};
21export declare type Window = {
22 innerHeight: number;
23 offsetHeight: number;
24 innerWidth: number;
25 offsetWidth: number;
26 pageXOffset: number;
27 pageYOffset: number;
28 getComputedStyle: typeof getComputedStyle;
29 addEventListener(type: any, listener: any, optionsOrUseCapture?: any): void;
30 removeEventListener(type: any, listener: any, optionsOrUseCapture?: any): void;
31 Element: Element;
32 HTMLElement: HTMLElement;
33 Node: Node;
34 toString(): "[object Window]";
35 devicePixelRatio: number;
36 visualViewport?: VisualViewport;
37 ShadowRoot: ShadowRoot;
38};
39export declare type Rect = {
40 width: number;
41 height: number;
42 x: number;
43 y: number;
44};
45export declare type Offsets = {
46 y: number;
47 x: number;
48};
49export declare type PositioningStrategy = "absolute" | "fixed";
50export declare type StateRects = {
51 reference: Rect;
52 popper: Rect;
53};
54export declare type StateOffsets = {
55 popper: Offsets;
56 arrow?: Offsets;
57};
58declare type OffsetData = {
59 [key in Placement]?: Offsets;
60};
61export declare type State = {
62 elements: {
63 reference: Element | VirtualElement;
64 popper: HTMLElement;
65 arrow?: HTMLElement;
66 };
67 options: OptionsGeneric<any>;
68 placement: Placement;
69 strategy: PositioningStrategy;
70 orderedModifiers: Array<Modifier<any, any>>;
71 rects: StateRects;
72 scrollParents: {
73 reference: Array<Element | Window | VisualViewport>;
74 popper: Array<Element | Window | VisualViewport>;
75 };
76 styles: {
77 [key: string]: Partial<CSSStyleDeclaration>;
78 };
79 attributes: {
80 [key: string]: {
81 [key: string]: string | boolean;
82 };
83 };
84 modifiersData: {
85 arrow?: {
86 x?: number;
87 y?: number;
88 centerOffset: number;
89 };
90 hide?: {
91 isReferenceHidden: boolean;
92 hasPopperEscaped: boolean;
93 referenceClippingOffsets: SideObject;
94 popperEscapeOffsets: SideObject;
95 };
96 offset?: OffsetData;
97 preventOverflow?: Offsets;
98 popperOffsets?: Offsets;
99 [key: string]: any;
100 };
101 reset: boolean;
102};
103declare type SetAction<S> = S | ((prev: S) => S);
104export declare type Instance = {
105 state: State;
106 destroy: () => void;
107 forceUpdate: () => void;
108 update: () => Promise<Partial<State>>;
109 setOptions: (setOptionsAction: SetAction<Partial<OptionsGeneric<any>>>) => Promise<Partial<State>>;
110};
111export declare type ModifierArguments<Options extends Obj> = {
112 state: State;
113 instance: Instance;
114 options: Partial<Options>;
115 name: string;
116};
117export declare type Modifier<Name, Options extends Obj> = {
118 name: Name;
119 enabled: boolean;
120 phase: ModifierPhases;
121 requires?: Array<string>;
122 requiresIfExists?: Array<string>;
123 fn: (arg0: ModifierArguments<Options>) => State | void;
124 effect?: (arg0: ModifierArguments<Options>) => (() => void) | void;
125 options?: Partial<Options>;
126 data?: Obj;
127};
128export declare type StrictModifiers = Partial<OffsetModifier> | Partial<ApplyStylesModifier> | Partial<ArrowModifier> | Partial<HideModifier> | Partial<ComputeStylesModifier> | Partial<EventListenersModifier> | Partial<FlipModifier> | Partial<PreventOverflowModifier> | Partial<PopperOffsetsModifier>;
129export declare type EventListeners = {
130 scroll: boolean;
131 resize: boolean;
132};
133export declare type Options = {
134 placement: Placement;
135 modifiers: Array<Partial<Modifier<any, any>>>;
136 strategy: PositioningStrategy;
137 onFirstUpdate?: (arg0: Partial<State>) => void;
138};
139export declare type OptionsGeneric<TModifier> = {
140 placement: Placement;
141 modifiers: Array<TModifier>;
142 strategy: PositioningStrategy;
143 onFirstUpdate?: (arg0: Partial<State>) => void;
144};
145export declare type UpdateCallback = (arg0: State) => void;
146export declare type ClientRectObject = {
147 x: number;
148 y: number;
149 top: number;
150 left: number;
151 right: number;
152 bottom: number;
153 width: number;
154 height: number;
155};
156export declare type SideObject = {
157 top: number;
158 left: number;
159 right: number;
160 bottom: number;
161};
162export declare type Padding = number | Partial<SideObject>;
163export declare type VirtualElement = {
164 getBoundingClientRect: () => ClientRect | DOMRect;
165 contextElement?: Element;
166};
167export {};