@entry-ui/utilities 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-5BI2X7JA.js +2 -0
- package/dist/chunk-5BI2X7JA.js.map +1 -0
- package/dist/{chunk-JW4DI4Q2.js → chunk-BVBN4VWU.js} +2 -2
- package/dist/{chunk-JW4DI4Q2.js.map → chunk-BVBN4VWU.js.map} +1 -1
- package/dist/chunk-H2U5U7XY.js +2 -0
- package/dist/chunk-H2U5U7XY.js.map +1 -0
- package/dist/chunk-KSDRQLOI.js +2 -0
- package/dist/chunk-KSDRQLOI.js.map +1 -0
- package/dist/chunk-RZEIOZGJ.js +2 -0
- package/dist/chunk-RZEIOZGJ.js.map +1 -0
- package/dist/chunk-TJWADQ7V.js +2 -0
- package/dist/chunk-TJWADQ7V.js.map +1 -0
- package/dist/chunk-V3434ODU.js +2 -0
- package/dist/chunk-V3434ODU.js.map +1 -0
- package/dist/clamp/index.js +1 -1
- package/dist/get-computed-style/index.d.ts +17 -0
- package/dist/get-computed-style/index.js +2 -0
- package/dist/get-computed-style/index.js.map +1 -0
- package/dist/get-css-dimensions/index.d.ts +42 -0
- package/dist/get-css-dimensions/index.js +2 -0
- package/dist/get-css-dimensions/index.js.map +1 -0
- package/dist/get-hidden-element-height/index.d.ts +23 -0
- package/dist/get-hidden-element-height/index.js +2 -0
- package/dist/get-hidden-element-height/index.js.map +1 -0
- package/dist/get-window/index.d.ts +20 -0
- package/dist/get-window/index.js +2 -0
- package/dist/get-window/index.js.map +1 -0
- package/dist/has-window/index.d.ts +17 -0
- package/dist/has-window/index.js +2 -0
- package/dist/has-window/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/dist/is-html-element/index.d.ts +25 -0
- package/dist/is-html-element/index.js +2 -0
- package/dist/is-html-element/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/get-computed-style/get-computed-style.ts"],"names":["getComputedStyle","element","getWindow"],"mappings":"oCAgBO,IAAMA,EAAoBC,CAAAA,EACxBC,CAAAA,CAAUD,CAAO,CAAA,CAAE,iBAAiBA,CAAO","file":"chunk-5BI2X7JA.js","sourcesContent":["import { getWindow } from '../get-window';\n\n/**\n * Retrieves the computed style properties for a specified HTML element.\n *\n * This function provides a reliable way to access an element's computed styles,\n * automatically resolving the correct window context. This ensures accurate\n * results even when the element is located within a different document context,\n * such as an iframe or a popup window.\n *\n * @example\n * ```ts\n * getComputedStyle(document.body);\n * // Returns: CSSStyleDeclaration object\n * ```\n */\nexport const getComputedStyle = (element: Element) => {\n return getWindow(element).getComputedStyle(element);\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a}from'./chunk-TAV72HQS.js';import {a as a$1}from'./chunk-O4WYO5SA.js';var s=r=>{let{value:m,min:e,max:i}=r;return a(m)||a$1({prefix:"[Entry UI Utilities]",messages:["Invalid 'value' parameter in 'clamp' utility.",`Expected a finite number, but received: ${m}`]}),a(e)||a$1({prefix:"[Entry UI Utilities]",messages:["Invalid 'min' parameter in 'clamp' utility.",`Expected a finite number, but received: ${e}`]}),a(i)||a$1({prefix:"[Entry UI Utilities]",messages:["Invalid 'max' parameter in 'clamp' utility.",`Expected a finite number, but received: ${i}`]}),e>i&&a$1({prefix:"[Entry UI Utilities]",messages:["Invalid range for 'clamp' utility.",`The 'min' parameter (${e}) must be less than or equal to the 'max' parameter (${i}).`]}),Math.min(i,Math.max(e,m))};export{s as a};//# sourceMappingURL=chunk-BVBN4VWU.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-BVBN4VWU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/clamp/clamp.ts"],"names":["clamp","params","value","min","max","isValidNumber","fail"],"mappings":"+EA2BO,IAAMA,EAASC,CAAAA,EAAwB,CAC5C,GAAM,CAAE,KAAA,CAAAC,EAAO,GAAA,CAAAC,CAAAA,CAAK,GAAA,CAAAC,CAAI,EAAIH,CAAAA,CAE5B,OAAKI,EAAcH,CAAK,CAAA,EACtBI,IAAK,CACH,MAAA,CAAQ,sBAAA,CACR,QAAA,CAAU,CAAC,+CAAA,CAAiD,CAAA,wCAAA,EAA2CJ,CAAK,CAAA,CAAE,CAChH,CAAC,CAAA,CAGEG,CAAAA,CAAcF,CAAG,CAAA,EACpBG,GAAAA,CAAK,CACH,MAAA,CAAQ,sBAAA,CACR,SAAU,CAAC,6CAAA,CAA+C,2CAA2CH,CAAG,CAAA,CAAE,CAC5G,CAAC,EAGEE,CAAAA,CAAcD,CAAG,GACpBE,GAAAA,CAAK,CACH,OAAQ,sBAAA,CACR,QAAA,CAAU,CAAC,6CAAA,CAA+C,CAAA,wCAAA,EAA2CF,CAAG,CAAA,CAAE,CAC5G,CAAC,CAAA,CAGCD,CAAAA,CAAMC,GACRE,GAAAA,CAAK,CACH,MAAA,CAAQ,sBAAA,CACR,SAAU,CACR,oCAAA,CACA,wBAAwBH,CAAG,CAAA,qDAAA,EAAwDC,CAAG,CAAA,EAAA,CACxF,CACF,CAAC,CAAA,CAGI,IAAA,CAAK,IAAIA,CAAAA,CAAK,IAAA,CAAK,IAAID,CAAAA,CAAKD,CAAK,CAAC,CAC3C","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/clamp/clamp.ts"],"names":["clamp","params","value","min","max","isValidNumber","fail"],"mappings":"+EA2BO,IAAMA,EAASC,CAAAA,EAAwB,CAC5C,GAAM,CAAE,KAAA,CAAAC,EAAO,GAAA,CAAAC,CAAAA,CAAK,GAAA,CAAAC,CAAI,EAAIH,CAAAA,CAE5B,OAAKI,EAAcH,CAAK,CAAA,EACtBI,IAAK,CACH,MAAA,CAAQ,sBAAA,CACR,QAAA,CAAU,CAAC,+CAAA,CAAiD,CAAA,wCAAA,EAA2CJ,CAAK,CAAA,CAAE,CAChH,CAAC,CAAA,CAGEG,CAAAA,CAAcF,CAAG,CAAA,EACpBG,GAAAA,CAAK,CACH,MAAA,CAAQ,sBAAA,CACR,SAAU,CAAC,6CAAA,CAA+C,2CAA2CH,CAAG,CAAA,CAAE,CAC5G,CAAC,EAGEE,CAAAA,CAAcD,CAAG,GACpBE,GAAAA,CAAK,CACH,OAAQ,sBAAA,CACR,QAAA,CAAU,CAAC,6CAAA,CAA+C,CAAA,wCAAA,EAA2CF,CAAG,CAAA,CAAE,CAC5G,CAAC,CAAA,CAGCD,CAAAA,CAAMC,GACRE,GAAAA,CAAK,CACH,MAAA,CAAQ,sBAAA,CACR,SAAU,CACR,oCAAA,CACA,wBAAwBH,CAAG,CAAA,qDAAA,EAAwDC,CAAG,CAAA,EAAA,CACxF,CACF,CAAC,CAAA,CAGI,IAAA,CAAK,IAAIA,CAAAA,CAAK,IAAA,CAAK,IAAID,CAAAA,CAAKD,CAAK,CAAC,CAC3C","file":"chunk-BVBN4VWU.js","sourcesContent":["import type { ClampParams } from './clamp.types';\nimport { isValidNumber } from '../is-valid-number';\nimport { fail } from '../fail';\n\n/**\n * Clamps a number between a minimum and maximum value.\n *\n * This utility ensures that the returned value is restricted to a specified range.\n * If the input value is smaller than the minimum boundary, the minimum value is\n * returned. If it exceeds the maximum boundary, the maximum value is returned.\n *\n * This function will throw an error if:\n * - Any of the input parameters are not finite numbers.\n * - The `min` value is greater than the `max` value.\n *\n * @example\n * ```ts\n * clamp({ value: 150, min: 0, max: 100 });\n * // Returns: 100\n *\n * clamp({ value: -20, min: 0, max: 100 });\n * Returns: 0\n *\n * clamp({ value: 50, min: 0, max: 100 });\n * // Returns: 50\n * ```\n */\nexport const clamp = (params: ClampParams) => {\n const { value, min, max } = params;\n\n if (!isValidNumber(value)) {\n fail({\n prefix: '[Entry UI Utilities]',\n messages: [`Invalid 'value' parameter in 'clamp' utility.`, `Expected a finite number, but received: ${value}`],\n });\n }\n\n if (!isValidNumber(min)) {\n fail({\n prefix: '[Entry UI Utilities]',\n messages: [`Invalid 'min' parameter in 'clamp' utility.`, `Expected a finite number, but received: ${min}`],\n });\n }\n\n if (!isValidNumber(max)) {\n fail({\n prefix: '[Entry UI Utilities]',\n messages: [`Invalid 'max' parameter in 'clamp' utility.`, `Expected a finite number, but received: ${max}`],\n });\n }\n\n if (min > max) {\n fail({\n prefix: '[Entry UI Utilities]',\n messages: [\n `Invalid range for 'clamp' utility.`,\n `The 'min' parameter (${min}) must be less than or equal to the 'max' parameter (${max}).`,\n ],\n });\n }\n\n return Math.min(max, Math.max(min, value));\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/get-window/get-window.ts"],"names":["getWindow","node"],"mappings":"AAkBO,IAAMA,CAAAA,CAAaC,CAAAA,EACjBA,CAAAA,EAAM,aAAA,EAAe,WAAA,EAAe","file":"chunk-H2U5U7XY.js","sourcesContent":["/**\n * Retrieves the window object associated with a given DOM node, ensuring the correct execution context.\n *\n * This utility identifies the correct execution context (global window) for a specific\n * node. It is particularly useful when working with applications that utilize iframes\n * or multiple windows, as it ensures that window-level APIs and properties are\n * accessed from the node's owner document rather than the current top-level window.\n *\n * @example\n * ```ts\n * getWindow(document.getElementById(\"my-element\"));\n * // Returns: the window object where the element resides\n *\n * getWindow(null);\n * // Returns: the global window object as a fallback\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const getWindow = (node: any): typeof window => {\n return node?.ownerDocument?.defaultView || window;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/is-html-element/is-html-element.ts"],"names":["isHTMLElement","value","hasWindow","getWindow"],"mappings":"+EAyBO,IAAMA,CAAAA,CAAiBC,CAAAA,EACvBC,CAAAA,EAAU,CAIRD,CAAAA,YAAiB,aAAeA,CAAAA,YAAiBE,GAAAA,CAAUF,CAAK,CAAA,CAAE,WAAA,CAHhE","file":"chunk-KSDRQLOI.js","sourcesContent":["import { hasWindow } from '../has-window';\nimport { getWindow } from '../get-window';\n\n/**\n * Verifies whether a given value is an instance of `HTMLElement`, with support for cross-realm environments.\n *\n * This utility provides a cross-realm safe check to determine if a value is a\n * standard HTML element. It first ensures a window environment is available\n * and then checks the instance against both the current global `HTMLElement`\n * and the `HTMLElement` constructor from the node's specific window context.\n * This prevents false negatives when elements are passed between different\n * frames or windows.\n *\n * @example\n * ```ts\n * isHTMLElement(document.createElement('div'));\n * // Returns: true\n *\n * isHTMLElement(null);\n * // Returns: false\n *\n * isHTMLElement(iframeElement.contentDocument.body);\n * // Returns: true (even if the instance comes from another window context)\n * ```\n */\nexport const isHTMLElement = (value: unknown): value is HTMLElement => {\n if (!hasWindow()) {\n return false;\n }\n\n return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;\n};\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a}from'./chunk-TJWADQ7V.js';var r=t=>{let e=t.cloneNode(true);e.setAttribute("aria-hidden","true"),Object.assign(e.style,{pointerEvents:"none",userSelect:"none",overflow:"visible",height:"auto",maxHeight:"none",opacity:"0",visibility:"hidden",display:"block",contentVisibility:"visible",transition:"none",animation:"none",position:"absolute",top:"-9999px"}),t.after(e);let{height:n}=a(e);return e.remove(),n};export{r as a};//# sourceMappingURL=chunk-RZEIOZGJ.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-RZEIOZGJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/get-hidden-element-height/get-hidden-element-height.ts"],"names":["getHiddenElementHeight","element","cloneElement","height","getCssDimensions"],"mappings":"oCAsBO,IAAMA,CAAAA,CAA0BC,CAAAA,EAAyB,CAC9D,IAAMC,CAAAA,CAAeD,CAAAA,CAAQ,SAAA,CAAU,IAAI,CAAA,CAE3CC,CAAAA,CAAa,YAAA,CAAa,aAAA,CAAe,MAAM,CAAA,CAE/C,MAAA,CAAO,MAAA,CAAOA,CAAAA,CAAa,KAAA,CAAO,CAChC,aAAA,CAAe,MAAA,CACf,UAAA,CAAY,MAAA,CACZ,QAAA,CAAU,SAAA,CACV,MAAA,CAAQ,MAAA,CACR,SAAA,CAAW,OACX,OAAA,CAAS,GAAA,CACT,UAAA,CAAY,QAAA,CACZ,OAAA,CAAS,OAAA,CACT,iBAAA,CAAmB,SAAA,CACnB,UAAA,CAAY,MAAA,CACZ,SAAA,CAAW,MAAA,CACX,QAAA,CAAU,UAAA,CACV,GAAA,CAAK,SACP,CAAC,CAAA,CAEDD,CAAAA,CAAQ,KAAA,CAAMC,CAAY,CAAA,CAE1B,GAAM,CAAE,MAAA,CAAAC,CAAO,CAAA,CAAIC,CAAAA,CAAiBF,CAAY,CAAA,CAEhD,OAAAA,CAAAA,CAAa,MAAA,GAENC,CACT","file":"chunk-RZEIOZGJ.js","sourcesContent":["import { getCssDimensions } from '../get-css-dimensions';\n\n/**\n * Calculates the natural height of an element that is otherwise hidden from the layout.\n *\n * This function handles cases where an element's dimensions cannot be accurately measured\n * (e.g., when it is set to `display: none` and occupies no space in the document). It\n * works by creating an invisible, deep clone of the element and temporarily injecting\n * it into the DOM at a position far outside the visible viewport.\n *\n * The clone is styled to be non-interactive and layout-neutral by overriding its display,\n * positioning, and visibility properties. This ensures that its presence does not\n * interfere with the user experience, trigger unintended layout shifts, or affect\n * accessibility trees. Once the height is captured, the clone is immediately removed\n * from the document to maintain DOM cleanliness.\n *\n * @example\n * ```ts\n * getHiddenElementHeight(myHiddenElement);\n * // Returns: 42\n * ```\n */\nexport const getHiddenElementHeight = (element: HTMLElement) => {\n const cloneElement = element.cloneNode(true) as HTMLElement;\n\n cloneElement.setAttribute('aria-hidden', 'true');\n\n Object.assign(cloneElement.style, {\n pointerEvents: 'none',\n userSelect: 'none',\n overflow: 'visible',\n height: 'auto',\n maxHeight: 'none',\n opacity: '0',\n visibility: 'hidden',\n display: 'block',\n contentVisibility: 'visible',\n transition: 'none',\n animation: 'none',\n position: 'absolute',\n top: '-9999px',\n });\n\n element.after(cloneElement);\n\n const { height } = getCssDimensions(cloneElement);\n\n cloneElement.remove();\n\n return height;\n};\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-KSDRQLOI.js';import {a}from'./chunk-5BI2X7JA.js';var l=s=>{let o=a(s),t=parseFloat(o.width)||0,e=parseFloat(o.height)||0,i=a$1(s),n=i?s.offsetWidth:t,r=i?s.offsetHeight:e;return (Math.round(t)!==n||Math.round(e)!==r)&&(t=n,e=r),{width:t,height:e}};export{l as a};//# sourceMappingURL=chunk-TJWADQ7V.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-TJWADQ7V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/get-css-dimensions/get-css-dimensions.ts"],"names":["getCssDimensions","element","css","getComputedStyle","width","height","hasOffset","isHTMLElement","offsetWidth","offsetHeight"],"mappings":"+EAoBO,IAAMA,CAAAA,CAAoBC,CAAAA,EAAkD,CACjF,IAAMC,CAAAA,CAAMC,EAAiBF,CAAO,CAAA,CAIhCG,CAAAA,CAAQ,UAAA,CAAWF,CAAAA,CAAI,KAAK,GAAK,CAAA,CACjCG,CAAAA,CAAS,UAAA,CAAWH,CAAAA,CAAI,MAAM,CAAA,EAAK,CAAA,CAEjCI,CAAAA,CAAYC,GAAAA,CAAcN,CAAO,CAAA,CACjCO,CAAAA,CAAcF,CAAAA,CAAYL,CAAAA,CAAQ,YAAcG,CAAAA,CAChDK,CAAAA,CAAeH,CAAAA,CAAYL,CAAAA,CAAQ,YAAA,CAAeI,CAAAA,CAGxD,QAFuB,IAAA,CAAK,KAAA,CAAMD,CAAK,CAAA,GAAMI,CAAAA,EAAe,IAAA,CAAK,MAAMH,CAAM,CAAA,GAAMI,CAAAA,IAGjFL,CAAAA,CAAQI,CAAAA,CACRH,CAAAA,CAASI,CAAAA,CAAAA,CAGJ,CACL,KAAA,CAAAL,CAAAA,CACA,MAAA,CAAAC,CACF,CACF","file":"chunk-TJWADQ7V.js","sourcesContent":["import type { GetCssDimensionsReturnValue } from './get-css-dimensions.types';\nimport { getComputedStyle } from '../get-computed-style';\nimport { isHTMLElement } from '../is-html-element';\n\n/**\n * Calculates the visual dimensions of an element, reconciling CSS styles with layout geometry.\n *\n * This utility determines the most accurate width and height of an element by\n * comparing its computed CSS values with its offset dimensions. It accounts for\n * edge cases where `getComputedStyle` might return inconsistent results, such as\n * in testing environments or when dealing with SVG elements. If a significant\n * discrepancy is detected between the CSS-defined size and the actual offset size,\n * it prioritizes the offset dimensions to ensure layout accuracy.\n *\n * @example\n * ```ts\n * getCssDimensions(myElement);\n * // Returns: { width: 150, height: 42 }\n * ```\n */\nexport const getCssDimensions = (element: Element): GetCssDimensionsReturnValue => {\n const css = getComputedStyle(element);\n\n // In testing environments, the `width` and `height` properties are empty\n // strings for SVG elements, returning NaN. Fallback to `0` in this case.\n let width = parseFloat(css.width) || 0;\n let height = parseFloat(css.height) || 0;\n\n const hasOffset = isHTMLElement(element);\n const offsetWidth = hasOffset ? element.offsetWidth : width;\n const offsetHeight = hasOffset ? element.offsetHeight : height;\n const shouldFallback = Math.round(width) !== offsetWidth || Math.round(height) !== offsetHeight;\n\n if (shouldFallback) {\n width = offsetWidth;\n height = offsetHeight;\n }\n\n return {\n width,\n height,\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/has-window/has-window.ts"],"names":["hasWindow"],"mappings":"AAcO,IAAMA,CAAAA,CAAY,IAChB,OAAO,MAAA,CAAW","file":"chunk-V3434ODU.js","sourcesContent":["/**\n * Checks whether the `window` object is defined in the current execution environment.\n *\n * This utility is primarily used to detect if the code is running in a browser\n * environment versus a server-side environment (like Node.js or during SSR).\n * It helps prevent \"window is not defined\" errors by ensuring browser-specific\n * APIs are only accessed when available.\n *\n * @example\n * ```ts\n * hasWindow()\n * // Returns: true if the window object is available, false otherwise\n * ```\n */\nexport const hasWindow = () => {\n return typeof window !== 'undefined';\n};\n"]}
|
package/dist/clamp/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as clamp}from'../chunk-
|
|
1
|
+
export{a as clamp}from'../chunk-BVBN4VWU.js';import'../chunk-TAV72HQS.js';import'../chunk-O4WYO5SA.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the computed style properties for a specified HTML element.
|
|
3
|
+
*
|
|
4
|
+
* This function provides a reliable way to access an element's computed styles,
|
|
5
|
+
* automatically resolving the correct window context. This ensures accurate
|
|
6
|
+
* results even when the element is located within a different document context,
|
|
7
|
+
* such as an iframe or a popup window.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* getComputedStyle(document.body);
|
|
12
|
+
* // Returns: CSSStyleDeclaration object
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare const getComputedStyle: (element: Element) => CSSStyleDeclaration;
|
|
16
|
+
|
|
17
|
+
export { getComputedStyle };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The geometric results of an element's dimension calculation.
|
|
3
|
+
*
|
|
4
|
+
* This interface represents the reconciled spatial measurements of a DOM element.
|
|
5
|
+
* It provides a normalized output that bridges the gap between computed CSS
|
|
6
|
+
* properties and actual layout geometry, ensuring consistency regardless of
|
|
7
|
+
* whether the element is a standard HTML component or an SVG.
|
|
8
|
+
*/
|
|
9
|
+
interface GetCssDimensionsReturnValue {
|
|
10
|
+
/**
|
|
11
|
+
* The calculated horizontal size of the element in pixels.
|
|
12
|
+
* This value prioritizes the actual rendered offset width while falling back
|
|
13
|
+
* to computed CSS values where layout geometry is unavailable or inconsistent.
|
|
14
|
+
*/
|
|
15
|
+
width: number;
|
|
16
|
+
/**
|
|
17
|
+
* The calculated vertical size of the element in pixels.
|
|
18
|
+
* Similar to the width, this property reflects the most accurate height
|
|
19
|
+
* by reconciling layout-driven dimensions with the styles defined in the CSS cascade.
|
|
20
|
+
*/
|
|
21
|
+
height: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Calculates the visual dimensions of an element, reconciling CSS styles with layout geometry.
|
|
26
|
+
*
|
|
27
|
+
* This utility determines the most accurate width and height of an element by
|
|
28
|
+
* comparing its computed CSS values with its offset dimensions. It accounts for
|
|
29
|
+
* edge cases where `getComputedStyle` might return inconsistent results, such as
|
|
30
|
+
* in testing environments or when dealing with SVG elements. If a significant
|
|
31
|
+
* discrepancy is detected between the CSS-defined size and the actual offset size,
|
|
32
|
+
* it prioritizes the offset dimensions to ensure layout accuracy.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* getCssDimensions(myElement);
|
|
37
|
+
* // Returns: { width: 150, height: 42 }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare const getCssDimensions: (element: Element) => GetCssDimensionsReturnValue;
|
|
41
|
+
|
|
42
|
+
export { type GetCssDimensionsReturnValue, getCssDimensions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the natural height of an element that is otherwise hidden from the layout.
|
|
3
|
+
*
|
|
4
|
+
* This function handles cases where an element's dimensions cannot be accurately measured
|
|
5
|
+
* (e.g., when it is set to `display: none` and occupies no space in the document). It
|
|
6
|
+
* works by creating an invisible, deep clone of the element and temporarily injecting
|
|
7
|
+
* it into the DOM at a position far outside the visible viewport.
|
|
8
|
+
*
|
|
9
|
+
* The clone is styled to be non-interactive and layout-neutral by overriding its display,
|
|
10
|
+
* positioning, and visibility properties. This ensures that its presence does not
|
|
11
|
+
* interfere with the user experience, trigger unintended layout shifts, or affect
|
|
12
|
+
* accessibility trees. Once the height is captured, the clone is immediately removed
|
|
13
|
+
* from the document to maintain DOM cleanliness.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* getHiddenElementHeight(myHiddenElement);
|
|
18
|
+
* // Returns: 42
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const getHiddenElementHeight: (element: HTMLElement) => number;
|
|
22
|
+
|
|
23
|
+
export { getHiddenElementHeight };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the window object associated with a given DOM node, ensuring the correct execution context.
|
|
3
|
+
*
|
|
4
|
+
* This utility identifies the correct execution context (global window) for a specific
|
|
5
|
+
* node. It is particularly useful when working with applications that utilize iframes
|
|
6
|
+
* or multiple windows, as it ensures that window-level APIs and properties are
|
|
7
|
+
* accessed from the node's owner document rather than the current top-level window.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* getWindow(document.getElementById("my-element"));
|
|
12
|
+
* // Returns: the window object where the element resides
|
|
13
|
+
*
|
|
14
|
+
* getWindow(null);
|
|
15
|
+
* // Returns: the global window object as a fallback
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const getWindow: (node: any) => typeof window;
|
|
19
|
+
|
|
20
|
+
export { getWindow };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the `window` object is defined in the current execution environment.
|
|
3
|
+
*
|
|
4
|
+
* This utility is primarily used to detect if the code is running in a browser
|
|
5
|
+
* environment versus a server-side environment (like Node.js or during SSR).
|
|
6
|
+
* It helps prevent "window is not defined" errors by ensuring browser-specific
|
|
7
|
+
* APIs are only accessed when available.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* hasWindow()
|
|
12
|
+
* // Returns: true if the window object is available, false otherwise
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare const hasWindow: () => boolean;
|
|
16
|
+
|
|
17
|
+
export { hasWindow };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ export { AddEventListenerOnceParams, AllEventMaps, addEventListenerOnce } from '
|
|
|
2
2
|
export { ClampParams, clamp } from './clamp/index.js';
|
|
3
3
|
export { ErrorParams, error } from './error/index.js';
|
|
4
4
|
export { FailParams, fail } from './fail/index.js';
|
|
5
|
+
export { getComputedStyle } from './get-computed-style/index.js';
|
|
6
|
+
export { GetCssDimensionsReturnValue, getCssDimensions } from './get-css-dimensions/index.js';
|
|
7
|
+
export { getHiddenElementHeight } from './get-hidden-element-height/index.js';
|
|
8
|
+
export { getWindow } from './get-window/index.js';
|
|
9
|
+
export { hasWindow } from './has-window/index.js';
|
|
10
|
+
export { isHTMLElement } from './is-html-element/index.js';
|
|
5
11
|
export { isValidNumber } from './is-valid-number/index.js';
|
|
6
12
|
export { PossibleStyle, mergeStyles } from './merge-styles/index.js';
|
|
7
13
|
export { visuallyHiddenInputStyle } from './visually-hidden-input-style/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as visuallyHiddenStyle}from'./chunk-YRBGPPKC.js';export{a as wait}from'./chunk-OUZ54COH.js';export{a as warn}from'./chunk-6L6DIP5N.js';export{a as addEventListenerOnce}from'./chunk-GLPQ4KOF.js';export{a as clamp}from'./chunk-
|
|
1
|
+
export{a as mergeStyles}from'./chunk-NBN5PUZ6.js';export{a as visuallyHiddenStyle}from'./chunk-YRBGPPKC.js';export{a as visuallyHiddenInputStyle}from'./chunk-AYHMR4G2.js';export{a as wait}from'./chunk-OUZ54COH.js';export{a as warn}from'./chunk-6L6DIP5N.js';export{a as addEventListenerOnce}from'./chunk-GLPQ4KOF.js';export{a as clamp}from'./chunk-BVBN4VWU.js';export{a as isValidNumber}from'./chunk-TAV72HQS.js';export{a as error}from'./chunk-GG6DRWSS.js';export{a as fail}from'./chunk-O4WYO5SA.js';export{a as getHiddenElementHeight}from'./chunk-RZEIOZGJ.js';export{a as getCssDimensions}from'./chunk-TJWADQ7V.js';export{a as isHTMLElement}from'./chunk-KSDRQLOI.js';export{a as hasWindow}from'./chunk-V3434ODU.js';export{a as getComputedStyle}from'./chunk-5BI2X7JA.js';export{a as getWindow}from'./chunk-H2U5U7XY.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies whether a given value is an instance of `HTMLElement`, with support for cross-realm environments.
|
|
3
|
+
*
|
|
4
|
+
* This utility provides a cross-realm safe check to determine if a value is a
|
|
5
|
+
* standard HTML element. It first ensures a window environment is available
|
|
6
|
+
* and then checks the instance against both the current global `HTMLElement`
|
|
7
|
+
* and the `HTMLElement` constructor from the node's specific window context.
|
|
8
|
+
* This prevents false negatives when elements are passed between different
|
|
9
|
+
* frames or windows.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* isHTMLElement(document.createElement('div'));
|
|
14
|
+
* // Returns: true
|
|
15
|
+
*
|
|
16
|
+
* isHTMLElement(null);
|
|
17
|
+
* // Returns: false
|
|
18
|
+
*
|
|
19
|
+
* isHTMLElement(iframeElement.contentDocument.body);
|
|
20
|
+
* // Returns: true (even if the instance comes from another window context)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const isHTMLElement: (value: unknown) => value is HTMLElement;
|
|
24
|
+
|
|
25
|
+
export { isHTMLElement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|