@floating-ui/react-dom
Advanced tools
Comparing version 0.7.0 to 0.7.1
import { computePosition, arrow as arrow$1 } from '@floating-ui/dom'; | ||
export * from '@floating-ui/dom'; | ||
import { useLayoutEffect, useEffect, useRef, useState, useCallback, useMemo } from 'react'; | ||
import { flushSync } from 'react-dom'; | ||
import * as React from 'react'; | ||
import { useLayoutEffect, useEffect } from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
@@ -10,3 +11,2 @@ var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect; | ||
// functions | ||
// @ts-nocheck | ||
function deepEqual(a, b) { | ||
@@ -73,3 +73,3 @@ if (a === b) { | ||
function useLatestRef(value) { | ||
const ref = useRef(value); | ||
const ref = React.useRef(value); | ||
index(() => { | ||
@@ -88,7 +88,7 @@ ref.current = value; | ||
} = _temp === void 0 ? {} : _temp; | ||
const reference = useRef(null); | ||
const floating = useRef(null); | ||
const reference = React.useRef(null); | ||
const floating = React.useRef(null); | ||
const whileElementsMountedRef = useLatestRef(whileElementsMounted); | ||
const cleanupRef = useRef(null); | ||
const [data, setData] = useState({ | ||
const cleanupRef = React.useRef(null); | ||
const [data, setData] = React.useState({ | ||
// Setting these to `null` will allow the consumer to determine if | ||
@@ -102,3 +102,3 @@ // `computePosition()` has run yet | ||
}); | ||
const [latestMiddleware, setLatestMiddleware] = useState(middleware); | ||
const [latestMiddleware, setLatestMiddleware] = React.useState(middleware); | ||
@@ -119,10 +119,3 @@ if (!deepEqual(latestMiddleware == null ? void 0 : latestMiddleware.map(_ref => { | ||
const isMountedRef = useRef(true); | ||
index(() => { | ||
isMountedRef.current = true; | ||
return () => { | ||
isMountedRef.current = false; | ||
}; | ||
}, []); | ||
const update = useCallback(() => { | ||
const update = React.useCallback(() => { | ||
if (!reference.current || !floating.current) { | ||
@@ -138,3 +131,3 @@ return; | ||
if (isMountedRef.current) { | ||
flushSync(() => { | ||
ReactDOM.flushSync(() => { | ||
setData(data); | ||
@@ -145,4 +138,16 @@ }); | ||
}, [latestMiddleware, placement, strategy]); | ||
index(update, [update]); | ||
const runElementMountCallback = useCallback(() => { | ||
index(() => { | ||
// Skip first update | ||
if (isMountedRef.current) { | ||
update(); | ||
} | ||
}, [update]); | ||
const isMountedRef = React.useRef(false); | ||
index(() => { | ||
isMountedRef.current = true; | ||
return () => { | ||
isMountedRef.current = false; | ||
}; | ||
}, []); | ||
const runElementMountCallback = React.useCallback(() => { | ||
if (typeof cleanupRef.current === 'function') { | ||
@@ -153,21 +158,24 @@ cleanupRef.current(); | ||
if (reference.current && floating.current && whileElementsMountedRef.current) { | ||
cleanupRef.current = whileElementsMountedRef.current(reference.current, floating.current, update); | ||
if (reference.current && floating.current) { | ||
if (whileElementsMountedRef.current) { | ||
const cleanupFn = whileElementsMountedRef.current(reference.current, floating.current, update); | ||
cleanupRef.current = cleanupFn; | ||
} else { | ||
update(); | ||
} | ||
} | ||
}, [update, whileElementsMountedRef]); | ||
const setReference = useCallback(node => { | ||
const setReference = React.useCallback(node => { | ||
reference.current = node; | ||
runElementMountCallback(); | ||
update(); | ||
}, [update, runElementMountCallback]); | ||
const setFloating = useCallback(node => { | ||
}, [runElementMountCallback]); | ||
const setFloating = React.useCallback(node => { | ||
floating.current = node; | ||
runElementMountCallback(); | ||
update(); | ||
}, [update, runElementMountCallback]); | ||
const refs = useMemo(() => ({ | ||
}, [runElementMountCallback]); | ||
const refs = React.useMemo(() => ({ | ||
reference, | ||
floating | ||
}), []); | ||
return useMemo(() => ({ ...data, | ||
return React.useMemo(() => ({ ...data, | ||
update, | ||
@@ -179,2 +187,10 @@ refs, | ||
} | ||
/** | ||
* Positions an inner element of the floating element such that it is centered | ||
* to the reference element. | ||
* This wraps the core `arrow` middleware to allow React refs as the element. | ||
* @see https://floating-ui.com/docs/arrow | ||
*/ | ||
const arrow = options => { | ||
@@ -181,0 +197,0 @@ const { |
@@ -1,1 +0,1 @@ | ||
import{computePosition as r,arrow as t}from"@floating-ui/dom";export*from"@floating-ui/dom";import{useLayoutEffect as e,useEffect as n,useRef as o,useState as u,useCallback as c,useMemo as l}from"react";import{flushSync as i}from"react-dom";var f="undefined"!=typeof document?e:n;function a(r,t){if(r===t)return!0;if(typeof r!=typeof t)return!1;if("function"==typeof r&&r.toString()===t.toString())return!0;let e,n,o;if(r&&t&&"object"==typeof r){if(Array.isArray(r)){if(e=r.length,e!=t.length)return!1;for(n=e;0!=n--;)if(!a(r[n],t[n]))return!1;return!0}if(o=Object.keys(r),e=o.length,e!==Object.keys(t).length)return!1;for(n=e;0!=n--;)if(!Object.prototype.hasOwnProperty.call(t,o[n]))return!1;for(n=e;0!=n--;){const e=o[n];if(("_owner"!==e||!r.$$typeof)&&!a(r[e],t[e]))return!1}return!0}return r!=r&&t!=t}function p(t){let{middleware:e,placement:n="bottom",strategy:p="absolute",whileElementsMounted:m}=void 0===t?{}:t;const d=o(null),s=o(null),y=function(r){const t=o(r);return f((()=>{t.current=r})),t}(m),g=o(null),[w,h]=u({x:null,y:null,strategy:p,placement:n,middlewareData:{}}),[b,O]=u(e);a(null==b?void 0:b.map((r=>{let{options:t}=r;return t})),null==e?void 0:e.map((r=>{let{options:t}=r;return t})))||O(e);const j=o(!0);f((()=>(j.current=!0,()=>{j.current=!1})),[]);const v=c((()=>{d.current&&s.current&&r(d.current,s.current,{middleware:b,placement:n,strategy:p}).then((r=>{j.current&&i((()=>{h(r)}))}))}),[b,n,p]);f(v,[v]);const x=c((()=>{"function"==typeof g.current&&(g.current(),g.current=null),d.current&&s.current&&y.current&&(g.current=y.current(d.current,s.current,v))}),[v,y]),k=c((r=>{d.current=r,x(),v()}),[v,x]),A=c((r=>{s.current=r,x(),v()}),[v,x]),P=l((()=>({reference:d,floating:s})),[]);return l((()=>({...w,update:v,refs:P,reference:k,floating:A})),[w,v,P,k,A])}const m=r=>{const{element:e,padding:n}=r;return{name:"arrow",options:r,fn(r){return o=e,Object.prototype.hasOwnProperty.call(o,"current")?null!=e.current?t({element:e.current,padding:n}).fn(r):{}:e?t({element:e,padding:n}).fn(r):{};var o}}};export{m as arrow,p as useFloating}; | ||
import{computePosition as e,arrow as r}from"@floating-ui/dom";export*from"@floating-ui/dom";import*as t from"react";import{useLayoutEffect as n,useEffect as u}from"react";import*as o from"react-dom";var c="undefined"!=typeof document?n:u;function l(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if("function"==typeof e&&e.toString()===r.toString())return!0;let t,n,u;if(e&&r&&"object"==typeof e){if(Array.isArray(e)){if(t=e.length,t!=r.length)return!1;for(n=t;0!=n--;)if(!l(e[n],r[n]))return!1;return!0}if(u=Object.keys(e),t=u.length,t!==Object.keys(r).length)return!1;for(n=t;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,u[n]))return!1;for(n=t;0!=n--;){const t=u[n];if(("_owner"!==t||!e.$$typeof)&&!l(e[t],r[t]))return!1}return!0}return e!=e&&r!=r}function a(r){let{middleware:n,placement:u="bottom",strategy:a="absolute",whileElementsMounted:f}=void 0===r?{}:r;const i=t.useRef(null),s=t.useRef(null),p=function(e){const r=t.useRef(e);return c((()=>{r.current=e})),r}(f),m=t.useRef(null),[d,y]=t.useState({x:null,y:null,strategy:a,placement:u,middlewareData:{}}),[g,b]=t.useState(n);l(null==g?void 0:g.map((e=>{let{options:r}=e;return r})),null==n?void 0:n.map((e=>{let{options:r}=e;return r})))||b(n);const h=t.useCallback((()=>{i.current&&s.current&&e(i.current,s.current,{middleware:g,placement:u,strategy:a}).then((e=>{w.current&&o.flushSync((()=>{y(e)}))}))}),[g,u,a]);c((()=>{w.current&&h()}),[h]);const w=t.useRef(!1);c((()=>(w.current=!0,()=>{w.current=!1})),[]);const k=t.useCallback((()=>{if("function"==typeof m.current&&(m.current(),m.current=null),i.current&&s.current)if(p.current){const e=p.current(i.current,s.current,h);m.current=e}else h()}),[h,p]),O=t.useCallback((e=>{i.current=e,k()}),[k]),j=t.useCallback((e=>{s.current=e,k()}),[k]),v=t.useMemo((()=>({reference:i,floating:s})),[]);return t.useMemo((()=>({...d,update:h,refs:v,reference:O,floating:j})),[d,h,v,O,j])}const f=e=>{const{element:t,padding:n}=e;return{name:"arrow",options:e,fn(e){return u=t,Object.prototype.hasOwnProperty.call(u,"current")?null!=t.current?r({element:t.current,padding:n}).fn(e):{}:t?r({element:t,padding:n}).fn(e):{};var u}}};export{f as arrow,a as useFloating}; |
@@ -5,9 +5,29 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIReactDOM = {}, global.FloatingUIDOM, global.React, global.ReactDOM)); | ||
})(this, (function (exports, dom, react, reactDom) { 'use strict'; | ||
})(this, (function (exports, dom, React, ReactDOM) { 'use strict'; | ||
var index = typeof document !== 'undefined' ? react.useLayoutEffect : react.useEffect; | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n["default"] = e; | ||
return Object.freeze(n); | ||
} | ||
var React__namespace = /*#__PURE__*/_interopNamespace(React); | ||
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM); | ||
var index = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect; | ||
// Fork of `fast-deep-equal` that only does the comparisons we need and compares | ||
// functions | ||
// @ts-nocheck | ||
function deepEqual(a, b) { | ||
@@ -74,3 +94,3 @@ if (a === b) { | ||
function useLatestRef(value) { | ||
const ref = react.useRef(value); | ||
const ref = React__namespace.useRef(value); | ||
index(() => { | ||
@@ -89,7 +109,7 @@ ref.current = value; | ||
} = _temp === void 0 ? {} : _temp; | ||
const reference = react.useRef(null); | ||
const floating = react.useRef(null); | ||
const reference = React__namespace.useRef(null); | ||
const floating = React__namespace.useRef(null); | ||
const whileElementsMountedRef = useLatestRef(whileElementsMounted); | ||
const cleanupRef = react.useRef(null); | ||
const [data, setData] = react.useState({ | ||
const cleanupRef = React__namespace.useRef(null); | ||
const [data, setData] = React__namespace.useState({ | ||
// Setting these to `null` will allow the consumer to determine if | ||
@@ -103,3 +123,3 @@ // `computePosition()` has run yet | ||
}); | ||
const [latestMiddleware, setLatestMiddleware] = react.useState(middleware); | ||
const [latestMiddleware, setLatestMiddleware] = React__namespace.useState(middleware); | ||
@@ -120,10 +140,3 @@ if (!deepEqual(latestMiddleware == null ? void 0 : latestMiddleware.map(_ref => { | ||
const isMountedRef = react.useRef(true); | ||
index(() => { | ||
isMountedRef.current = true; | ||
return () => { | ||
isMountedRef.current = false; | ||
}; | ||
}, []); | ||
const update = react.useCallback(() => { | ||
const update = React__namespace.useCallback(() => { | ||
if (!reference.current || !floating.current) { | ||
@@ -139,3 +152,3 @@ return; | ||
if (isMountedRef.current) { | ||
reactDom.flushSync(() => { | ||
ReactDOM__namespace.flushSync(() => { | ||
setData(data); | ||
@@ -146,4 +159,16 @@ }); | ||
}, [latestMiddleware, placement, strategy]); | ||
index(update, [update]); | ||
const runElementMountCallback = react.useCallback(() => { | ||
index(() => { | ||
// Skip first update | ||
if (isMountedRef.current) { | ||
update(); | ||
} | ||
}, [update]); | ||
const isMountedRef = React__namespace.useRef(false); | ||
index(() => { | ||
isMountedRef.current = true; | ||
return () => { | ||
isMountedRef.current = false; | ||
}; | ||
}, []); | ||
const runElementMountCallback = React__namespace.useCallback(() => { | ||
if (typeof cleanupRef.current === 'function') { | ||
@@ -154,21 +179,24 @@ cleanupRef.current(); | ||
if (reference.current && floating.current && whileElementsMountedRef.current) { | ||
cleanupRef.current = whileElementsMountedRef.current(reference.current, floating.current, update); | ||
if (reference.current && floating.current) { | ||
if (whileElementsMountedRef.current) { | ||
const cleanupFn = whileElementsMountedRef.current(reference.current, floating.current, update); | ||
cleanupRef.current = cleanupFn; | ||
} else { | ||
update(); | ||
} | ||
} | ||
}, [update, whileElementsMountedRef]); | ||
const setReference = react.useCallback(node => { | ||
const setReference = React__namespace.useCallback(node => { | ||
reference.current = node; | ||
runElementMountCallback(); | ||
update(); | ||
}, [update, runElementMountCallback]); | ||
const setFloating = react.useCallback(node => { | ||
}, [runElementMountCallback]); | ||
const setFloating = React__namespace.useCallback(node => { | ||
floating.current = node; | ||
runElementMountCallback(); | ||
update(); | ||
}, [update, runElementMountCallback]); | ||
const refs = react.useMemo(() => ({ | ||
}, [runElementMountCallback]); | ||
const refs = React__namespace.useMemo(() => ({ | ||
reference, | ||
floating | ||
}), []); | ||
return react.useMemo(() => ({ ...data, | ||
return React__namespace.useMemo(() => ({ ...data, | ||
update, | ||
@@ -180,2 +208,10 @@ refs, | ||
} | ||
/** | ||
* Positions an inner element of the floating element such that it is centered | ||
* to the reference element. | ||
* This wraps the core `arrow` middleware to allow React refs as the element. | ||
* @see https://floating-ui.com/docs/arrow | ||
*/ | ||
const arrow = options => { | ||
@@ -182,0 +218,0 @@ const { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@floating-ui/dom"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/dom","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.FloatingUIDOM,e.React,e.ReactDOM)}(this,(function(e,t,r,n){"use strict";var u="undefined"!=typeof document?r.useLayoutEffect:r.useEffect;function o(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let r,n,u;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(n=r;0!=n--;)if(!o(e[n],t[n]))return!1;return!0}if(u=Object.keys(e),r=u.length,r!==Object.keys(t).length)return!1;for(n=r;0!=n--;)if(!Object.prototype.hasOwnProperty.call(t,u[n]))return!1;for(n=r;0!=n--;){const r=u[n];if(("_owner"!==r||!e.$$typeof)&&!o(e[r],t[r]))return!1}return!0}return e!=e&&t!=t}e.arrow=e=>{const{element:r,padding:n}=e;return{name:"arrow",options:e,fn(e){return u=r,Object.prototype.hasOwnProperty.call(u,"current")?null!=r.current?t.arrow({element:r.current,padding:n}).fn(e):{}:r?t.arrow({element:r,padding:n}).fn(e):{};var u}}},e.useFloating=function(e){let{middleware:c,placement:l="bottom",strategy:f="absolute",whileElementsMounted:a}=void 0===e?{}:e;const i=r.useRef(null),s=r.useRef(null),d=function(e){const t=r.useRef(e);return u((()=>{t.current=e})),t}(a),p=r.useRef(null),[y,m]=r.useState({x:null,y:null,strategy:f,placement:l,middlewareData:{}}),[g,b]=r.useState(c);o(null==g?void 0:g.map((e=>{let{options:t}=e;return t})),null==c?void 0:c.map((e=>{let{options:t}=e;return t})))||b(c);const h=r.useRef(!0);u((()=>(h.current=!0,()=>{h.current=!1})),[]);const O=r.useCallback((()=>{i.current&&s.current&&t.computePosition(i.current,s.current,{middleware:g,placement:l,strategy:f}).then((e=>{h.current&&n.flushSync((()=>{m(e)}))}))}),[g,l,f]);u(O,[O]);const w=r.useCallback((()=>{"function"==typeof p.current&&(p.current(),p.current=null),i.current&&s.current&&d.current&&(p.current=d.current(i.current,s.current,O))}),[O,d]),j=r.useCallback((e=>{i.current=e,w(),O()}),[O,w]),R=r.useCallback((e=>{s.current=e,w(),O()}),[O,w]),k=r.useMemo((()=>({reference:i,floating:s})),[]);return r.useMemo((()=>({...y,update:O,refs:k,reference:j,floating:R})),[y,O,k,j,R])},Object.keys(t).forEach((function(r){"default"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@floating-ui/dom"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/dom","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.FloatingUIDOM,e.React,e.ReactDOM)}(this,(function(e,t,r,n){"use strict";function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=u(r),c=u(n),f="undefined"!=typeof document?r.useLayoutEffect:r.useEffect;function l(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let r,n,u;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(n=r;0!=n--;)if(!l(e[n],t[n]))return!1;return!0}if(u=Object.keys(e),r=u.length,r!==Object.keys(t).length)return!1;for(n=r;0!=n--;)if(!Object.prototype.hasOwnProperty.call(t,u[n]))return!1;for(n=r;0!=n--;){const r=u[n];if(("_owner"!==r||!e.$$typeof)&&!l(e[r],t[r]))return!1}return!0}return e!=e&&t!=t}e.arrow=e=>{const{element:r,padding:n}=e;return{name:"arrow",options:e,fn(e){return u=r,Object.prototype.hasOwnProperty.call(u,"current")?null!=r.current?t.arrow({element:r.current,padding:n}).fn(e):{}:r?t.arrow({element:r,padding:n}).fn(e):{};var u}}},e.useFloating=function(e){let{middleware:r,placement:n="bottom",strategy:u="absolute",whileElementsMounted:a}=void 0===e?{}:e;const i=o.useRef(null),s=o.useRef(null),d=function(e){const t=o.useRef(e);return f((()=>{t.current=e})),t}(a),p=o.useRef(null),[y,m]=o.useState({x:null,y:null,strategy:u,placement:n,middlewareData:{}}),[g,b]=o.useState(r);l(null==g?void 0:g.map((e=>{let{options:t}=e;return t})),null==r?void 0:r.map((e=>{let{options:t}=e;return t})))||b(r);const O=o.useCallback((()=>{i.current&&s.current&&t.computePosition(i.current,s.current,{middleware:g,placement:n,strategy:u}).then((e=>{h.current&&c.flushSync((()=>{m(e)}))}))}),[g,n,u]);f((()=>{h.current&&O()}),[O]);const h=o.useRef(!1);f((()=>(h.current=!0,()=>{h.current=!1})),[]);const j=o.useCallback((()=>{if("function"==typeof p.current&&(p.current(),p.current=null),i.current&&s.current)if(d.current){const e=d.current(i.current,s.current,O);p.current=e}else O()}),[O,d]),w=o.useCallback((e=>{i.current=e,j()}),[j]),k=o.useCallback((e=>{s.current=e,j()}),[j]),v=o.useMemo((()=>({reference:i,floating:s})),[]);return o.useMemo((()=>({...y,update:O,refs:v,reference:w,floating:k})),[y,O,v,w,k])},Object.keys(t).forEach((function(r){"default"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@floating-ui/react-dom", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"@rollingversions": { | ||
@@ -63,3 +63,3 @@ "baseVersion": [ | ||
"dependencies": { | ||
"@floating-ui/dom": "^0.5.0", | ||
"@floating-ui/dom": "^0.5.1", | ||
"use-isomorphic-layout-effect": "^1.1.1" | ||
@@ -66,0 +66,0 @@ }, |
@@ -1,25 +0,3 @@ | ||
import type { ComputePositionConfig, ComputePositionReturn, Middleware, SideObject, VirtualElement } from '@floating-ui/core'; | ||
import { MutableRefObject } from 'react'; | ||
export * from '@floating-ui/dom'; | ||
declare type Data = Omit<ComputePositionReturn, 'x' | 'y'> & { | ||
x: number | null; | ||
y: number | null; | ||
}; | ||
declare type ReferenceType = Element | VirtualElement; | ||
export declare type UseFloatingReturn<RT extends ReferenceType = ReferenceType> = Data & { | ||
update: () => void; | ||
reference: (node: RT | null) => void; | ||
floating: (node: HTMLElement | null) => void; | ||
refs: { | ||
reference: MutableRefObject<RT | null>; | ||
floating: MutableRefObject<HTMLElement | null>; | ||
}; | ||
}; | ||
export declare type UseFloatingProps<RT extends ReferenceType = ReferenceType> = Omit<Partial<ComputePositionConfig>, 'platform'> & { | ||
whileElementsMounted?: (reference: RT, floating: HTMLElement, update: () => void) => void | (() => void); | ||
}; | ||
export declare function useFloating<RT extends ReferenceType = ReferenceType>({ middleware, placement, strategy, whileElementsMounted, }?: UseFloatingProps): UseFloatingReturn<RT>; | ||
export declare const arrow: (options: { | ||
element: MutableRefObject<HTMLElement | null> | HTMLElement; | ||
padding?: number | SideObject; | ||
}) => Middleware; | ||
export { useFloating } from './useFloating'; | ||
export { arrow } from './arrow'; |
@@ -0,5 +1,22 @@ | ||
import * as React from 'react'; | ||
import type { ComputePositionReturn, ComputePositionConfig, VirtualElement } from '@floating-ui/dom'; | ||
export * from '@floating-ui/dom'; | ||
export { useFloating } from './'; | ||
export { arrow } from './'; | ||
export type { UseFloatingReturn } from './'; | ||
export * from '@floating-ui/dom'; | ||
export type { Platform, Placement, Strategy, Middleware, Alignment, Side, AlignedPlacement, Axis, Length, Coords, SideObject, Dimensions, Rect, ElementRects, ElementContext, ClientRectObject, Padding, RootBoundary, MiddlewareArguments, MiddlewareReturn, MiddlewareData, ComputePositionConfig, ComputePositionReturn, VirtualElement, } from '@floating-ui/dom'; | ||
export declare type UseFloatingData = Omit<ComputePositionReturn, 'x' | 'y'> & { | ||
x: number | null; | ||
y: number | null; | ||
}; | ||
export declare type ReferenceType = Element | VirtualElement; | ||
export declare type UseFloatingReturn<RT extends ReferenceType = ReferenceType> = UseFloatingData & { | ||
update: () => void; | ||
reference: (node: RT | null) => void; | ||
floating: (node: HTMLElement | null) => void; | ||
refs: { | ||
reference: React.MutableRefObject<RT | null>; | ||
floating: React.MutableRefObject<HTMLElement | null>; | ||
}; | ||
}; | ||
export declare type UseFloatingProps<RT extends ReferenceType = ReferenceType> = Omit<Partial<ComputePositionConfig>, 'platform'> & { | ||
whileElementsMounted?: (reference: RT, floating: HTMLElement, update: () => void) => void | (() => void); | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27813
15
671
Updated@floating-ui/dom@^0.5.1