@floating-ui/utils
Advanced tools
@@ -33,3 +33,3 @@ export declare type AlignedPlacement = `${Side}-${Alignment}`; | ||
| export declare function expandPaddingObject(padding: Partial<SideObject>): SideObject; | ||
| export declare function expandPaddingObject(padding: Exclude<Padding, number>): SideObject; | ||
@@ -68,3 +68,5 @@ export declare const floor: (x: number) => number; | ||
| export declare type Padding = number | Prettify<Partial<SideObject>>; | ||
| export declare type Padding = number | Prettify<{ | ||
| [K in Side]?: number | undefined; | ||
| }>; | ||
@@ -101,3 +103,3 @@ export declare type Placement = Prettify<Side | AlignedPlacement>; | ||
| getBoundingClientRect(): ClientRectObject; | ||
| getClientRects?(): Array<ClientRectObject>; | ||
| getClientRects?: (() => Array<ClientRectObject>) | undefined; | ||
| contextElement?: any; | ||
@@ -104,0 +106,0 @@ } |
@@ -33,3 +33,3 @@ export declare type AlignedPlacement = `${Side}-${Alignment}`; | ||
| export declare function expandPaddingObject(padding: Partial<SideObject>): SideObject; | ||
| export declare function expandPaddingObject(padding: Exclude<Padding, number>): SideObject; | ||
@@ -68,3 +68,5 @@ export declare const floor: (x: number) => number; | ||
| export declare type Padding = number | Prettify<Partial<SideObject>>; | ||
| export declare type Padding = number | Prettify<{ | ||
| [K in Side]?: number | undefined; | ||
| }>; | ||
@@ -101,3 +103,3 @@ export declare type Placement = Prettify<Side | AlignedPlacement>; | ||
| getBoundingClientRect(): ClientRectObject; | ||
| getClientRects?(): Array<ClientRectObject>; | ||
| getClientRects?: (() => Array<ClientRectObject>) | undefined; | ||
| contextElement?: any; | ||
@@ -104,0 +106,0 @@ } |
@@ -136,3 +136,3 @@ function hasWindow() { | ||
| if (isLastTraversableNode(parentNode)) { | ||
| return node.ownerDocument ? node.ownerDocument.body : node.body; | ||
| return (node.ownerDocument || node).body; | ||
| } | ||
@@ -139,0 +139,0 @@ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { |
@@ -136,3 +136,3 @@ function hasWindow() { | ||
| if (isLastTraversableNode(parentNode)) { | ||
| return node.ownerDocument ? node.ownerDocument.body : node.body; | ||
| return (node.ownerDocument || node).body; | ||
| } | ||
@@ -139,0 +139,0 @@ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { |
@@ -142,3 +142,3 @@ (function (global, factory) { | ||
| if (isLastTraversableNode(parentNode)) { | ||
| return node.ownerDocument ? node.ownerDocument.body : node.body; | ||
| return (node.ownerDocument || node).body; | ||
| } | ||
@@ -145,0 +145,0 @@ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { |
@@ -1,1 +0,1 @@ | ||
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIUtilsDOM={})}(this,(function(t){"use strict";function e(){return"undefined"!=typeof window}function n(t){return i(t)?(t.nodeName||"").toLowerCase():"#document"}function o(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function r(t){var e;return null==(e=(i(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function i(t){return!!e()&&(t instanceof Node||t instanceof o(t).Node)}function l(t){return!!e()&&(t instanceof Element||t instanceof o(t).Element)}function c(t){return!!e()&&(t instanceof HTMLElement||t instanceof o(t).HTMLElement)}function u(t){return!(!e()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof o(t).ShadowRoot)}function s(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=g(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&"inline"!==r&&"contents"!==r}function f(t){try{if(t.matches(":popover-open"))return!0}catch(t){}try{return t.matches(":modal")}catch(t){return!1}}const a=/transform|translate|scale|rotate|perspective|filter/,d=/paint|layout|strict|content/,m=t=>!!t&&"none"!==t;let p;function w(t){const e=l(t)?g(t):t;return m(e.transform)||m(e.translate)||m(e.scale)||m(e.rotate)||m(e.perspective)||!v()&&(m(e.backdropFilter)||m(e.filter))||a.test(e.willChange||"")||d.test(e.contain||"")}function v(){return null==p&&(p="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),p}function y(t){return/^(html|body|#document)$/.test(n(t))}function g(t){return o(t).getComputedStyle(t)}function h(t){if("html"===n(t))return t;const e=t.assignedSlot||t.parentNode||u(t)&&t.host||r(t);return u(e)?e.host:e}function b(t){const e=h(t);return y(e)?t.ownerDocument?t.ownerDocument.body:t.body:c(e)&&s(e)?e:b(e)}function S(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}t.getComputedStyle=g,t.getContainingBlock=function(t){let e=h(t);for(;c(e)&&!y(e);){if(w(e))return e;if(f(e))return null;e=h(e)}return null},t.getDocumentElement=r,t.getFrameElement=S,t.getNearestOverflowAncestor=b,t.getNodeName=n,t.getNodeScroll=function(t){return l(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}},t.getOverflowAncestors=function t(e,n,r){var i;void 0===n&&(n=[]),void 0===r&&(r=!0);const l=b(e),c=l===(null==(i=e.ownerDocument)?void 0:i.body),u=o(l);if(c){const e=S(u);return n.concat(u,u.visualViewport||[],s(l)?l:[],e&&r?t(e):[])}return n.concat(l,t(l,[],r))},t.getParentNode=h,t.getWindow=o,t.isContainingBlock=w,t.isElement=l,t.isHTMLElement=c,t.isLastTraversableNode=y,t.isNode=i,t.isOverflowElement=s,t.isShadowRoot=u,t.isTableElement=function(t){return/^(table|td|th)$/.test(n(t))},t.isTopLayer=f,t.isWebKit=v})); | ||
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIUtilsDOM={})}(this,(function(t){"use strict";function e(){return"undefined"!=typeof window}function n(t){return i(t)?(t.nodeName||"").toLowerCase():"#document"}function o(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function r(t){var e;return null==(e=(i(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function i(t){return!!e()&&(t instanceof Node||t instanceof o(t).Node)}function l(t){return!!e()&&(t instanceof Element||t instanceof o(t).Element)}function c(t){return!!e()&&(t instanceof HTMLElement||t instanceof o(t).HTMLElement)}function u(t){return!(!e()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof o(t).ShadowRoot)}function s(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=y(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&"inline"!==r&&"contents"!==r}function f(t){try{if(t.matches(":popover-open"))return!0}catch(t){}try{return t.matches(":modal")}catch(t){return!1}}const a=/transform|translate|scale|rotate|perspective|filter/,d=/paint|layout|strict|content/,m=t=>!!t&&"none"!==t;let p;function w(t){const e=l(t)?y(t):t;return m(e.transform)||m(e.translate)||m(e.scale)||m(e.rotate)||m(e.perspective)||!v()&&(m(e.backdropFilter)||m(e.filter))||a.test(e.willChange||"")||d.test(e.contain||"")}function v(){return null==p&&(p="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),p}function g(t){return/^(html|body|#document)$/.test(n(t))}function y(t){return o(t).getComputedStyle(t)}function h(t){if("html"===n(t))return t;const e=t.assignedSlot||t.parentNode||u(t)&&t.host||r(t);return u(e)?e.host:e}function b(t){const e=h(t);return g(e)?(t.ownerDocument||t).body:c(e)&&s(e)?e:b(e)}function S(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}t.getComputedStyle=y,t.getContainingBlock=function(t){let e=h(t);for(;c(e)&&!g(e);){if(w(e))return e;if(f(e))return null;e=h(e)}return null},t.getDocumentElement=r,t.getFrameElement=S,t.getNearestOverflowAncestor=b,t.getNodeName=n,t.getNodeScroll=function(t){return l(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}},t.getOverflowAncestors=function t(e,n,r){var i;void 0===n&&(n=[]),void 0===r&&(r=!0);const l=b(e),c=l===(null==(i=e.ownerDocument)?void 0:i.body),u=o(l);if(c){const e=S(u);return n.concat(u,u.visualViewport||[],s(l)?l:[],e&&r?t(e):[])}return n.concat(l,t(l,[],r))},t.getParentNode=h,t.getWindow=o,t.isContainingBlock=w,t.isElement=l,t.isHTMLElement=c,t.isLastTraversableNode=g,t.isNode=i,t.isOverflowElement=s,t.isShadowRoot=u,t.isTableElement=function(t){return/^(table|td|th)$/.test(n(t))},t.isTopLayer=f,t.isWebKit=v})); |
@@ -101,8 +101,8 @@ /** | ||
| function expandPaddingObject(padding) { | ||
| var _padding$top, _padding$right, _padding$bottom, _padding$left; | ||
| return { | ||
| top: 0, | ||
| right: 0, | ||
| bottom: 0, | ||
| left: 0, | ||
| ...padding | ||
| top: (_padding$top = padding.top) != null ? _padding$top : 0, | ||
| right: (_padding$right = padding.right) != null ? _padding$right : 0, | ||
| bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0, | ||
| left: (_padding$left = padding.left) != null ? _padding$left : 0 | ||
| }; | ||
@@ -109,0 +109,0 @@ } |
@@ -101,8 +101,8 @@ /** | ||
| function expandPaddingObject(padding) { | ||
| var _padding$top, _padding$right, _padding$bottom, _padding$left; | ||
| return { | ||
| top: 0, | ||
| right: 0, | ||
| bottom: 0, | ||
| left: 0, | ||
| ...padding | ||
| top: (_padding$top = padding.top) != null ? _padding$top : 0, | ||
| right: (_padding$right = padding.right) != null ? _padding$right : 0, | ||
| bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0, | ||
| left: (_padding$left = padding.left) != null ? _padding$left : 0 | ||
| }; | ||
@@ -109,0 +109,0 @@ } |
@@ -107,8 +107,8 @@ (function (global, factory) { | ||
| function expandPaddingObject(padding) { | ||
| var _padding$top, _padding$right, _padding$bottom, _padding$left; | ||
| return { | ||
| top: 0, | ||
| right: 0, | ||
| bottom: 0, | ||
| left: 0, | ||
| ...padding | ||
| top: (_padding$top = padding.top) != null ? _padding$top : 0, | ||
| right: (_padding$right = padding.right) != null ? _padding$right : 0, | ||
| bottom: (_padding$bottom = padding.bottom) != null ? _padding$bottom : 0, | ||
| left: (_padding$left = padding.left) != null ? _padding$left : 0 | ||
| }; | ||
@@ -115,0 +115,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIUtils={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],o=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),i=Math.min,r=Math.max,c=Math.round,s=Math.floor,u={left:"right",right:"left",bottom:"top",top:"bottom"};function f(t){return t.split("-")[0]}function l(t){return t.split("-")[1]}function a(t){return"x"===t?"y":"x"}function g(t){return"y"===t?"height":"width"}function p(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function d(t){return a(p(t))}function m(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const h=["left","right"],x=["right","left"],b=["top","bottom"],y=["bottom","top"];function A(t){const e=f(t);return u[e]+t.slice(e.length)}function O(t){return{top:0,right:0,bottom:0,left:0,...t}}t.alignments=n,t.clamp=function(t,e,n){return r(t,i(e,n))},t.createCoords=t=>({x:t,y:t}),t.evaluate=function(t,e){return"function"==typeof t?t(e):t},t.expandPaddingObject=O,t.floor=s,t.getAlignment=l,t.getAlignmentAxis=d,t.getAlignmentSides=function(t,e,n){void 0===n&&(n=!1);const o=l(t),i=d(t),r=g(i);let c="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(c=A(c)),[c,A(c)]},t.getAxisLength=g,t.getExpandedPlacements=function(t){const e=A(t);return[m(t),e,m(e)]},t.getOppositeAlignmentPlacement=m,t.getOppositeAxis=a,t.getOppositeAxisPlacements=function(t,e,n,o){const i=l(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?x:h:e?h:x;case"left":case"right":return e?b:y;default:return[]}}(f(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(m)))),r},t.getOppositePlacement=A,t.getPaddingObject=function(t){return"number"!=typeof t?O(t):{top:t,right:t,bottom:t,left:t}},t.getSide=f,t.getSideAxis=p,t.max=r,t.min=i,t.placements=o,t.rectToClientRect=function(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}},t.round=c,t.sides=e})); | ||
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIUtils={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],o=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),i=Math.min,r=Math.max,c=Math.round,u=Math.floor,l={left:"right",right:"left",bottom:"top",top:"bottom"};function s(t){return t.split("-")[0]}function f(t){return t.split("-")[1]}function a(t){return"x"===t?"y":"x"}function g(t){return"y"===t?"height":"width"}function p(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function d(t){return a(p(t))}function m(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const h=["left","right"],x=["right","left"],b=["top","bottom"],y=["bottom","top"];function A(t){const e=s(t);return l[e]+t.slice(e.length)}function O(t){var e,n,o,i;return{top:null!=(e=t.top)?e:0,right:null!=(n=t.right)?n:0,bottom:null!=(o=t.bottom)?o:0,left:null!=(i=t.left)?i:0}}t.alignments=n,t.clamp=function(t,e,n){return r(t,i(e,n))},t.createCoords=t=>({x:t,y:t}),t.evaluate=function(t,e){return"function"==typeof t?t(e):t},t.expandPaddingObject=O,t.floor=u,t.getAlignment=f,t.getAlignmentAxis=d,t.getAlignmentSides=function(t,e,n){void 0===n&&(n=!1);const o=f(t),i=d(t),r=g(i);let c="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(c=A(c)),[c,A(c)]},t.getAxisLength=g,t.getExpandedPlacements=function(t){const e=A(t);return[m(t),e,m(e)]},t.getOppositeAlignmentPlacement=m,t.getOppositeAxis=a,t.getOppositeAxisPlacements=function(t,e,n,o){const i=f(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?x:h:e?h:x;case"left":case"right":return e?b:y;default:return[]}}(s(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(m)))),r},t.getOppositePlacement=A,t.getPaddingObject=function(t){return"number"!=typeof t?O(t):{top:t,right:t,bottom:t,left:t}},t.getSide=s,t.getSideAxis=p,t.max=r,t.min=i,t.placements=o,t.rectToClientRect=function(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}},t.round=c,t.sides=e})); |
@@ -136,3 +136,3 @@ function hasWindow() { | ||
| if (isLastTraversableNode(parentNode)) { | ||
| return node.ownerDocument ? node.ownerDocument.body : node.body; | ||
| return (node.ownerDocument || node).body; | ||
| } | ||
@@ -139,0 +139,0 @@ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { |
@@ -142,3 +142,3 @@ (function (global, factory) { | ||
| if (isLastTraversableNode(parentNode)) { | ||
| return node.ownerDocument ? node.ownerDocument.body : node.body; | ||
| return (node.ownerDocument || node).body; | ||
| } | ||
@@ -145,0 +145,0 @@ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { |
+2
-2
| { | ||
| "name": "@floating-ui/utils", | ||
| "version": "0.2.11", | ||
| "version": "0.2.12", | ||
| "description": "Utilities for Floating UI", | ||
@@ -60,3 +60,3 @@ "publishConfig": { | ||
| "lint": "eslint .", | ||
| "format": "prettier --write .", | ||
| "format": "prettier --ignore-path ../../.gitignore --write .", | ||
| "clean": "rimraf dist out-tsc dom react", | ||
@@ -63,0 +63,0 @@ "test": "vitest run --globals", |
66066
1.44%1444
0.14%