floating-ui.dom.d.mts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. import { AlignedPlacement } from '@floating-ui/core';
  2. import { Alignment } from '@floating-ui/core';
  3. import type { ArrowOptions as ArrowOptions_2 } from '@floating-ui/core';
  4. import type { AutoPlacementOptions as AutoPlacementOptions_2 } from '@floating-ui/core';
  5. import { Axis } from '@floating-ui/core';
  6. import { ClientRectObject } from '@floating-ui/core';
  7. import type { ComputePositionConfig as ComputePositionConfig_2 } from '@floating-ui/core';
  8. import { ComputePositionReturn } from '@floating-ui/core';
  9. import { Coords } from '@floating-ui/core';
  10. import type { Derivable as Derivable_2 } from '@floating-ui/core';
  11. import { detectOverflow } from '@floating-ui/core';
  12. import type { DetectOverflowOptions as DetectOverflowOptions_2 } from '@floating-ui/core';
  13. import { Dimensions } from '@floating-ui/core';
  14. import { ElementContext } from '@floating-ui/core';
  15. import { ElementRects } from '@floating-ui/core';
  16. import type { FlipOptions as FlipOptions_2 } from '@floating-ui/core';
  17. import { getOverflowAncestors } from '@floating-ui/utils/dom';
  18. import type { HideOptions as HideOptions_2 } from '@floating-ui/core';
  19. import { InlineOptions } from '@floating-ui/core';
  20. import { Length } from '@floating-ui/core';
  21. import type { LimitShiftOptions } from '@floating-ui/core';
  22. import type { Middleware as Middleware_2 } from '@floating-ui/core';
  23. import { MiddlewareData } from '@floating-ui/core';
  24. import { MiddlewareReturn } from '@floating-ui/core';
  25. import type { MiddlewareState as MiddlewareState_2 } from '@floating-ui/core';
  26. import { offset } from '@floating-ui/core';
  27. import { OffsetOptions } from '@floating-ui/core';
  28. import { Padding } from '@floating-ui/core';
  29. import { Placement } from '@floating-ui/core';
  30. import { Rect } from '@floating-ui/core';
  31. import { RootBoundary } from '@floating-ui/core';
  32. import type { ShiftOptions as ShiftOptions_2 } from '@floating-ui/core';
  33. import { Side } from '@floating-ui/core';
  34. import { SideObject } from '@floating-ui/core';
  35. import type { SizeOptions as SizeOptions_2 } from '@floating-ui/core';
  36. import { Strategy } from '@floating-ui/core';
  37. export { AlignedPlacement }
  38. export { Alignment }
  39. /**
  40. * Provides data to position an inner element of the floating element so that it
  41. * appears centered to the reference element.
  42. * @see https://floating-ui.com/docs/arrow
  43. */
  44. export declare const arrow: (options: ArrowOptions | Derivable_2<ArrowOptions>) => Middleware;
  45. export declare type ArrowOptions = Prettify<Omit<ArrowOptions_2, 'element'> & {
  46. element: Element;
  47. }>;
  48. /**
  49. * Optimizes the visibility of the floating element by choosing the placement
  50. * that has the most space available automatically, without needing to specify a
  51. * preferred placement. Alternative to `flip`.
  52. * @see https://floating-ui.com/docs/autoPlacement
  53. */
  54. export declare const autoPlacement: (options?: AutoPlacementOptions | Derivable_2<AutoPlacementOptions>) => Middleware;
  55. export declare type AutoPlacementOptions = Prettify<Omit<AutoPlacementOptions_2, 'boundary'> & DetectOverflowOptions>;
  56. /**
  57. * Automatically updates the position of the floating element when necessary.
  58. * Should only be called when the floating element is mounted on the DOM or
  59. * visible on the screen.
  60. * @returns cleanup function that should be invoked when the floating element is
  61. * removed from the DOM or hidden from the screen.
  62. * @see https://floating-ui.com/docs/autoUpdate
  63. */
  64. export declare function autoUpdate(reference: ReferenceElement, floating: FloatingElement, update: () => void, options?: AutoUpdateOptions): () => void;
  65. export declare type AutoUpdateOptions = Partial<{
  66. /**
  67. * Whether to update the position when an overflow ancestor is scrolled.
  68. * @default true
  69. */
  70. ancestorScroll: boolean;
  71. /**
  72. * Whether to update the position when an overflow ancestor is resized. This
  73. * uses the native `resize` event.
  74. * @default true
  75. */
  76. ancestorResize: boolean;
  77. /**
  78. * Whether to update the position when either the reference or floating
  79. * elements resized. This uses a `ResizeObserver`.
  80. * @default true
  81. */
  82. elementResize: boolean;
  83. /**
  84. * Whether to update the position when the reference relocated on the screen
  85. * due to layout shift.
  86. * @default true
  87. */
  88. layoutShift: boolean;
  89. /**
  90. * Whether to update on every animation frame if necessary. Only use if you
  91. * need to update the position in response to an animation using transforms.
  92. * @default false
  93. */
  94. animationFrame: boolean;
  95. }>;
  96. export { Axis }
  97. /**
  98. * The clipping boundary area of the floating element.
  99. */
  100. export declare type Boundary = 'clippingAncestors' | Element | Array<Element> | Rect;
  101. export { ClientRectObject }
  102. /**
  103. * Computes the `x` and `y` coordinates that will place the floating element
  104. * next to a given reference element.
  105. */
  106. export declare const computePosition: (reference: ReferenceElement, floating: FloatingElement, options?: Partial<ComputePositionConfig>) => Promise<ComputePositionReturn>;
  107. export declare type ComputePositionConfig = Prettify<Omit<ComputePositionConfig_2, 'middleware' | 'platform'> & {
  108. /**
  109. * Array of middleware objects to modify the positioning or provide data for
  110. * rendering.
  111. */
  112. middleware?: Array<Middleware | null | undefined | false>;
  113. /**
  114. * Custom or extended platform object.
  115. */
  116. platform?: Platform;
  117. }>;
  118. export { ComputePositionReturn }
  119. export { Coords }
  120. export declare type Derivable<T> = (state: MiddlewareState) => T;
  121. export { detectOverflow }
  122. export declare type DetectOverflowOptions = Prettify<Omit<DetectOverflowOptions_2, 'boundary'> & {
  123. boundary?: Boundary;
  124. }>;
  125. export { Dimensions }
  126. export { ElementContext }
  127. export { ElementRects }
  128. export declare interface Elements {
  129. reference: ReferenceElement;
  130. floating: FloatingElement;
  131. }
  132. /**
  133. * Optimizes the visibility of the floating element by flipping the `placement`
  134. * in order to keep it in view when the preferred placement(s) will overflow the
  135. * clipping boundary. Alternative to `autoPlacement`.
  136. * @see https://floating-ui.com/docs/flip
  137. */
  138. export declare const flip: (options?: FlipOptions | Derivable_2<FlipOptions>) => Middleware;
  139. export declare type FlipOptions = Prettify<Omit<FlipOptions_2, 'boundary'> & DetectOverflowOptions>;
  140. export declare type FloatingElement = HTMLElement;
  141. export { getOverflowAncestors }
  142. /**
  143. * Provides data to hide the floating element in applicable situations, such as
  144. * when it is not in the same clipping context as the reference element.
  145. * @see https://floating-ui.com/docs/hide
  146. */
  147. export declare const hide: (options?: HideOptions | Derivable_2<HideOptions>) => Middleware;
  148. export declare type HideOptions = Prettify<Omit<HideOptions_2, 'boundary'> & DetectOverflowOptions>;
  149. /**
  150. * Provides improved positioning for inline reference elements that can span
  151. * over multiple lines, such as hyperlinks or range selections.
  152. * @see https://floating-ui.com/docs/inline
  153. */
  154. export declare const inline: (options?: InlineOptions | Derivable_2<InlineOptions>) => Middleware;
  155. export { InlineOptions }
  156. export { Length }
  157. /**
  158. * Built-in `limiter` that will stop `shift()` at a certain point.
  159. */
  160. export declare const limitShift: (options?: LimitShiftOptions | Derivable_2<LimitShiftOptions>) => {
  161. options: any;
  162. fn: (state: MiddlewareState) => Coords;
  163. };
  164. export declare type Middleware = Prettify<Omit<Middleware_2, 'fn'> & {
  165. fn(state: MiddlewareState): Promisable<MiddlewareReturn>;
  166. }>;
  167. /**
  168. * @deprecated use `MiddlewareState` instead.
  169. */
  170. export declare type MiddlewareArguments = MiddlewareState;
  171. export { MiddlewareData }
  172. export { MiddlewareReturn }
  173. export declare type MiddlewareState = Prettify<Omit<MiddlewareState_2, 'elements'> & {
  174. elements: Elements;
  175. }>;
  176. export declare interface NodeScroll {
  177. scrollLeft: number;
  178. scrollTop: number;
  179. }
  180. export { offset }
  181. export { OffsetOptions }
  182. export { Padding }
  183. export { Placement }
  184. export declare interface Platform {
  185. getElementRects: (args: {
  186. reference: ReferenceElement;
  187. floating: FloatingElement;
  188. strategy: Strategy;
  189. }) => Promisable<ElementRects>;
  190. getClippingRect: (args: {
  191. element: Element;
  192. boundary: Boundary;
  193. rootBoundary: RootBoundary;
  194. strategy: Strategy;
  195. }) => Promisable<Rect>;
  196. getDimensions: (element: Element) => Promisable<Dimensions>;
  197. convertOffsetParentRelativeRectToViewportRelativeRect: (args: {
  198. elements?: Elements;
  199. rect: Rect;
  200. offsetParent: Element;
  201. strategy: Strategy;
  202. }) => Promisable<Rect>;
  203. getOffsetParent: (element: Element, polyfill?: (element: HTMLElement) => Element | null) => Promisable<Element | Window>;
  204. isElement: (value: unknown) => Promisable<boolean>;
  205. getDocumentElement: (element: Element) => Promisable<HTMLElement>;
  206. getClientRects: (element: Element) => Promisable<Array<ClientRectObject>>;
  207. isRTL: (element: Element) => Promisable<boolean>;
  208. getScale: (element: HTMLElement) => Promisable<{
  209. x: number;
  210. y: number;
  211. }>;
  212. }
  213. export declare const platform: Platform;
  214. declare type Prettify<T> = {
  215. [K in keyof T]: T[K];
  216. } & {};
  217. declare type Promisable<T> = T | Promise<T>;
  218. export { Rect }
  219. export declare type ReferenceElement = Element | VirtualElement;
  220. export { RootBoundary }
  221. /**
  222. * Optimizes the visibility of the floating element by shifting it in order to
  223. * keep it in view when it will overflow the clipping boundary.
  224. * @see https://floating-ui.com/docs/shift
  225. */
  226. export declare const shift: (options?: ShiftOptions | Derivable_2<ShiftOptions>) => Middleware;
  227. export declare type ShiftOptions = Prettify<Omit<ShiftOptions_2, 'boundary'> & DetectOverflowOptions>;
  228. export { Side }
  229. export { SideObject }
  230. /**
  231. * Provides data that allows you to change the size of the floating element —
  232. * for instance, prevent it from overflowing the clipping boundary or match the
  233. * width of the reference element.
  234. * @see https://floating-ui.com/docs/size
  235. */
  236. export declare const size: (options?: SizeOptions | Derivable_2<SizeOptions>) => Middleware;
  237. export declare type SizeOptions = Prettify<Omit<SizeOptions_2, 'apply' | 'boundary'> & DetectOverflowOptions & {
  238. /**
  239. * Function that is called to perform style mutations to the floating element
  240. * to change its size.
  241. * @default undefined
  242. */
  243. apply?(args: MiddlewareState & {
  244. availableWidth: number;
  245. availableHeight: number;
  246. }): Promisable<void>;
  247. }>;
  248. export { Strategy }
  249. /**
  250. * Custom positioning reference element.
  251. * @see https://floating-ui.com/docs/virtual-elements
  252. */
  253. export declare interface VirtualElement {
  254. getBoundingClientRect(): ClientRectObject;
  255. contextElement?: Element;
  256. }
  257. export { }