@necto/dom 1.9.0 → 1.9.2

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i={};function l(e){if(void 0!==e)return"number"==typeof e?`${e}px`:e}function c(e){return e?.ownerDocument?e.ownerDocument:"undefined"!=typeof document?document:null}function s(e){if(e&&"window"in e&&e.window===e)return e;const t=c(e);return t?.defaultView?t.defaultView:"undefined"!=typeof window?window:null}((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})(i,{ALL_ARIA_PROPS:()=>W,ARIA_PROPS_SET:()=>j,AriaProps:()=>x,HTMLElements:()=>N,disableTextSelection:()=>k,focusWithoutScrolling:()=>y,getActiveElement:()=>g,getContainmentRect:()=>v,getEventTarget:()=>w,getOwnerDocument:()=>c,getOwnerWindow:()=>s,hasAriaPrefix:()=>V,injectStyle:()=>S,isAriaAttribute:()=>B,isNode:()=>m,nodeContains:()=>p,restoreTextSelection:()=>D,runAfterTransition:()=>P,scrollIntoView:()=>f,supportsPreventScroll:()=>d,toPx:()=>l}),module.exports=(e=i,((e,i,l,c)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of o(i))r.call(e,s)||s===l||t(e,s,{get:()=>i[s],enumerable:!(c=n(i,s))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var u=null;function d(){if(null==u&&(u=!1,"undefined"!=typeof document))try{document.createElement("div").focus({get preventScroll(){return u=!0,!0}})}catch{}return u}function f(e,t,n){const{block:o="nearest",inline:r="nearest"}=n??{},i=e.getBoundingClientRect(),l=t.getBoundingClientRect(),c=l.top<i.top,s=l.bottom>i.bottom,u=l.left<i.left,d=l.right>i.right;if(c||s){let t=e.scrollTop;if("start"===o||"nearest"===o&&c)t=e.scrollTop+(l.top-i.top);else if("end"===o||"nearest"===o&&s)t=e.scrollTop+(l.bottom-i.bottom);else if("center"===o){const n=i.top+i.height/2,o=l.top+l.height/2;t=e.scrollTop+(o-n)}e.scrollTop=t}if(u||d){let t=e.scrollLeft;if("start"===r||"nearest"===r&&u)t=e.scrollLeft+(l.left-i.left);else if("end"===r||"nearest"===r&&d)t=e.scrollLeft+(l.right-i.right);else if("center"===r){const n=i.left+i.width/2,o=l.left+l.width/2;t=e.scrollLeft+(o-n)}e.scrollLeft=t}}function a(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function m(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function p(e,t,n=!0){if(!e||!t)return!1;if(!n)return e.contains(t);let o=t;for(;o;){if(o===e)return!0;o=o instanceof Element&&"SLOT"===o.tagName&&o.assignedSlot?o.assignedSlot?.parentNode??null:a(o)?o.host:o.parentNode}return!1}var g=(e=("undefined"!=typeof document?document:null),t=!0)=>{if(!e)return null;if(!t)return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&n.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n};function w(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function y(e){if(d())e.focus({preventScroll:!0});else{let t=e.parentNode;const n=[],o="undefined"!=typeof document?document.scrollingElement||document.documentElement:null;for(;t instanceof HTMLElement&&t!==o;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),e.focus();for(const{element:e,scrollTop:t,scrollLeft:o}of n)e.scrollTop=t,e.scrollLeft=o}}var h="necto-style-id",T=new WeakMap;function b(){return`ncto-<:${Math.random().toString(36).slice(2,9)}:>`}function E(e,t={}){const{id:n,internalId:o,insertionPoint:r}=t,i=r?c(r):"undefined"!=typeof document?document:null;if(!i)return null;const l=i.createElement("style");return l.setAttribute("type","text/css"),l.setAttribute(h,o??b()),n&&(l.id=n),l.textContent=e,r?i.head.insertBefore(l,r):i.head.appendChild(l),l}function S(e,t={}){const{id:n,window:o=("undefined"!=typeof window?window:null),insertionPoint:r}=t;if(!o||!e)return()=>{};const i=function(e){let t=T.get(e);return t||(t=new Map,T.set(e,t)),t}(o),l=`${n??"necto"}:${e}`;let c=i.get(l);if(c)c.element&&(c.element.textContent=e,c.count++);else{c={element:E(e,{id:n,internalId:b(),insertionPoint:r}),count:1},i.set(l,c)}return()=>{const e=i.get(l);e?.element&&(e.count--,e.count<1&&(e.element.remove(),e.element=null,i.delete(l)))}}function v(e,t){if(e&&m(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=t?c(t):"undefined"!=typeof document?document:null,n=t?s(t):"undefined"!=typeof window?window:null;return{top:0,left:0,bottom:n?.innerHeight||e?.documentElement?.clientHeight||0,right:n?.innerWidth||e?.documentElement?.clientWidth||0}}}var A=new Map,L=new Set;function O(e){if(!("propertyName"in e)||!e.target)return;let t=A.get(e.target);t||(t=new Set,A.set(e.target,t),e.target.addEventListener("transitioncancel",M,{once:!0})),t.add(e.propertyName)}function M(e){if(!("propertyName"in e)||!e.target)return;const t=A.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",M),A.delete(e.target)),0===A.size)){for(const e of L)e();L.clear()}}if("undefined"!=typeof window&&"undefined"!=typeof document){const e=()=>{const e=document.body;e&&(e.addEventListener("transitionrun",O),e.addEventListener("transitionend",M))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function P(e){requestAnimationFrame(()=>{for(const[e]of A)"isConnected"in e&&!e.isConnected&&A.delete(e);0===A.size?e():L.add(e)})}var R=require("@necto/constants"),N=R.DOM.HTML_TAGS.reduce((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e},{}),C=require("@necto/platform"),U="",I="default",_=new WeakMap;function k(e){if((0,C.isIOS)()){if("default"===I){const t=c(e);void 0!==t?.documentElement?.style.webkitUserSelect&&(U=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none",I="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";_.has(e)||(_.set(e,t[n]??""),t[n]="none")}}function D(e){if((0,C.isIOS)()){if("disabled"!==I)return;I="restoring",setTimeout(()=>{P(()=>{if("restoring"===I){const t=c(e);"none"===t?.documentElement?.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=U||""),U="",I="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&_.has(e)){const t=_.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),_.delete(e)}}var H=require("@necto/constants"),x=H.DOM.ARIA_ATTRIBUTES.reduce((e,t)=>(e[(e=>{const t=e.replace("aria-","");return t.charAt(0).toUpperCase()+t.slice(1)})(t)]=t,e),{}),W=H.DOM.ARIA_ATTRIBUTES,j=new Set(W),B=e=>j.has(e),V=e=>e.startsWith("aria-");
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i={};function l(e){if(void 0!==e)return"number"==typeof e?`${e}px`:e}function c(e){return e?.ownerDocument?e.ownerDocument:"undefined"!=typeof document?document:null}function s(e){if(e&&"window"in e&&e.window===e)return e;const t=c(e);return t?.defaultView?t.defaultView:"undefined"!=typeof window?window:null}((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})(i,{ALL_ARIA_PROPS:()=>x,ARIA_PROPS_SET:()=>I,AriaProps:()=>H,HTMLElements:()=>R,disableTextSelection:()=>_,focusWithoutScrolling:()=>y,getActiveElement:()=>g,getContainmentRect:()=>E,getEventTarget:()=>w,getOwnerDocument:()=>c,getOwnerWindow:()=>s,hasAriaPrefix:()=>j,injectStyle:()=>b,isAriaAttribute:()=>W,isNode:()=>m,nodeContains:()=>p,restoreTextSelection:()=>k,runAfterTransition:()=>O,scrollIntoView:()=>f,supportsPreventScroll:()=>d,toPx:()=>l}),module.exports=(e=i,((e,i,l,c)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of o(i))r.call(e,s)||s===l||t(e,s,{get:()=>i[s],enumerable:!(c=n(i,s))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var u=null;function d(){if(null==u&&(u=!1,"undefined"!=typeof document))try{document.createElement("div").focus({get preventScroll(){return u=!0,!0}})}catch{}return u}function f(e,t,n){const{block:o="nearest",inline:r="nearest"}=n??{},i=e.getBoundingClientRect(),l=t.getBoundingClientRect(),c=l.top<i.top,s=l.bottom>i.bottom,u=l.left<i.left,d=l.right>i.right;if(c||s){let t=e.scrollTop;if("start"===o||"nearest"===o&&c)t=e.scrollTop+(l.top-i.top);else if("end"===o||"nearest"===o&&s)t=e.scrollTop+(l.bottom-i.bottom);else if("center"===o){const n=i.top+i.height/2,o=l.top+l.height/2;t=e.scrollTop+(o-n)}e.scrollTop=t}if(u||d){let t=e.scrollLeft;if("start"===r||"nearest"===r&&u)t=e.scrollLeft+(l.left-i.left);else if("end"===r||"nearest"===r&&d)t=e.scrollLeft+(l.right-i.right);else if("center"===r){const n=i.left+i.width/2,o=l.left+l.width/2;t=e.scrollLeft+(o-n)}e.scrollLeft=t}}function a(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function m(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function p(e,t,n=!0){if(!e||!t)return!1;if(!n)return e.contains(t);let o=t;for(;o;){if(o===e)return!0;o=o instanceof Element&&"SLOT"===o.tagName&&o.assignedSlot?o.assignedSlot?.parentNode??null:a(o)?o.host:o.parentNode}return!1}var g=(e=("undefined"!=typeof document?document:null),t=!0)=>{if(!e)return null;if(!t)return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&n.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n};function w(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function y(e){if(d())e.focus({preventScroll:!0});else{let t=e.parentNode;const n=[],o="undefined"!=typeof document?document.scrollingElement||document.documentElement:null;for(;t instanceof HTMLElement&&t!==o;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),e.focus();for(const{element:e,scrollTop:t,scrollLeft:o}of n)e.scrollTop=t,e.scrollLeft=o}}var h="data-style-id",T=new WeakMap;function b(e,t={}){const{id:n,insertionPoint:o,window:r=("undefined"!=typeof window?window:null)}=t;if(!r||!e)return()=>{};let i=T.get(r);i||(i=new Map,T.set(r,i));const l=`${n??"necto"}:${e}`;let s=i.get(l);if(s)s.element&&(s.element.textContent=e,s.count++);else{const t=o?c(o):"undefined"!=typeof document?document:null;if(!t)return()=>{};const r=`necto-<:${Math.random().toString(36).slice(2,9)}:>`,u=t.createElement("style");u.setAttribute("type","text/css"),u.setAttribute(h,r),n&&(u.id=n),u.textContent=e,o?t.head.insertBefore(u,o):t.head.appendChild(u),s={element:u,count:1},i.set(l,s)}return()=>{const e=i.get(l);e?.element&&(e.count--,e.count<1&&(e.element.remove(),e.element=null,i.delete(l)))}}function E(e,t){if(e&&m(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=t?c(t):"undefined"!=typeof document?document:null,n=t?s(t):"undefined"!=typeof window?window:null;return{top:0,left:0,bottom:n?.innerHeight||e?.documentElement?.clientHeight||0,right:n?.innerWidth||e?.documentElement?.clientWidth||0}}}var S=new Map,v=new Set;function A(e){if(!("propertyName"in e)||!e.target)return;let t=S.get(e.target);t||(t=new Set,S.set(e.target,t),e.target.addEventListener("transitioncancel",L,{once:!0})),t.add(e.propertyName)}function L(e){if(!("propertyName"in e)||!e.target)return;const t=S.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",L),S.delete(e.target)),0===S.size)){for(const e of v)e();v.clear()}}if("undefined"!=typeof window&&"undefined"!=typeof document){const e=()=>{const e=document.body;e&&(e.addEventListener("transitionrun",A),e.addEventListener("transitionend",L))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function O(e){requestAnimationFrame(()=>{for(const[e]of S)"isConnected"in e&&!e.isConnected&&S.delete(e);0===S.size?e():v.add(e)})}var M=require("@necto/constants"),R=M.DOM.HTML_TAGS.reduce((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e},{}),N=require("@necto/platform"),P="",C="default",U=new WeakMap;function _(e){if((0,N.isIOS)()){if("default"===C){const t=c(e);void 0!==t?.documentElement?.style.webkitUserSelect&&(P=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none",C="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";U.has(e)||(U.set(e,t[n]??""),t[n]="none")}}function k(e){if((0,N.isIOS)()){if("disabled"!==C)return;C="restoring",setTimeout(()=>{O(()=>{if("restoring"===C){const t=c(e);"none"===t?.documentElement?.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=P||""),P="",C="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&U.has(e)){const t=U.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),U.delete(e)}}var D=require("@necto/constants"),H=D.DOM.ARIA_ATTRIBUTES.reduce((e,t)=>(e[(e=>{const t=e.replace("aria-","");return t.charAt(0).toUpperCase()+t.slice(1)})(t)]=t,e),{}),x=D.DOM.ARIA_ATTRIBUTES,I=new Set(x),W=e=>I.has(e),j=e=>e.startsWith("aria-");
package/dist/index.d.cts CHANGED
@@ -97,6 +97,14 @@ interface InjectStyleOptions {
97
97
  *
98
98
  */
99
99
 
100
+ /**
101
+ * Injects a CSS string into the document head as a `<style>` element.
102
+ * Deduplicates by id + css content, reference-counted, and auto-removes when all consumers unmount.
103
+ *
104
+ * @param css - The CSS string to inject.
105
+ * @param options - Configuration options (id, window, insertionPoint).
106
+ * @returns A cleanup function that decrements the reference count and removes the style when no longer needed.
107
+ */
100
108
  declare function injectStyle(css: string, options?: InjectStyleOptions): () => void;
101
109
 
102
110
  /**
package/dist/index.d.ts CHANGED
@@ -97,6 +97,14 @@ interface InjectStyleOptions {
97
97
  *
98
98
  */
99
99
 
100
+ /**
101
+ * Injects a CSS string into the document head as a `<style>` element.
102
+ * Deduplicates by id + css content, reference-counted, and auto-removes when all consumers unmount.
103
+ *
104
+ * @param css - The CSS string to inject.
105
+ * @param options - Configuration options (id, window, insertionPoint).
106
+ * @returns A cleanup function that decrements the reference count and removes the style when no longer needed.
107
+ */
100
108
  declare function injectStyle(css: string, options?: InjectStyleOptions): () => void;
101
109
 
102
110
  /**
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function e(e){if(void 0!==e)return"number"==typeof e?`${e}px`:e}function t(e){return e?.ownerDocument?e.ownerDocument:"undefined"!=typeof document?document:null}function n(e){if(e&&"window"in e&&e.window===e)return e;const n=t(e);return n?.defaultView?n.defaultView:"undefined"!=typeof window?window:null}var o=null;function r(){if(null==o&&(o=!1,"undefined"!=typeof document))try{document.createElement("div").focus({get preventScroll(){return o=!0,!0}})}catch{}return o}function i(e,t,n){const{block:o="nearest",inline:r="nearest"}=n??{},i=e.getBoundingClientRect(),l=t.getBoundingClientRect(),c=l.top<i.top,s=l.bottom>i.bottom,d=l.left<i.left,u=l.right>i.right;if(c||s){let t=e.scrollTop;if("start"===o||"nearest"===o&&c)t=e.scrollTop+(l.top-i.top);else if("end"===o||"nearest"===o&&s)t=e.scrollTop+(l.bottom-i.bottom);else if("center"===o){const n=i.top+i.height/2,o=l.top+l.height/2;t=e.scrollTop+(o-n)}e.scrollTop=t}if(d||u){let t=e.scrollLeft;if("start"===r||"nearest"===r&&d)t=e.scrollLeft+(l.left-i.left);else if("end"===r||"nearest"===r&&u)t=e.scrollLeft+(l.right-i.right);else if("center"===r){const n=i.left+i.width/2,o=l.left+l.width/2;t=e.scrollLeft+(o-n)}e.scrollLeft=t}}function l(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function c(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function s(e,t,n=!0){if(!e||!t)return!1;if(!n)return e.contains(t);let o=t;for(;o;){if(o===e)return!0;o=o instanceof Element&&"SLOT"===o.tagName&&o.assignedSlot?o.assignedSlot?.parentNode??null:l(o)?o.host:o.parentNode}return!1}var d=(e=("undefined"!=typeof document?document:null),t=!0)=>{if(!e)return null;if(!t)return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&n.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n};function u(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function f(e){if(r())e.focus({preventScroll:!0});else{let t=e.parentNode;const n=[],o="undefined"!=typeof document?document.scrollingElement||document.documentElement:null;for(;t instanceof HTMLElement&&t!==o;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),e.focus();for(const{element:e,scrollTop:t,scrollLeft:o}of n)e.scrollTop=t,e.scrollLeft=o}}var a=new WeakMap;function m(){return`ncto-<:${Math.random().toString(36).slice(2,9)}:>`}function p(e,n={}){const{id:o,internalId:r,insertionPoint:i}=n,l=i?t(i):"undefined"!=typeof document?document:null;if(!l)return null;const c=l.createElement("style");return c.setAttribute("type","text/css"),c.setAttribute("necto-style-id",r??m()),o&&(c.id=o),c.textContent=e,i?l.head.insertBefore(c,i):l.head.appendChild(c),c}function g(e,t={}){const{id:n,window:o=("undefined"!=typeof window?window:null),insertionPoint:r}=t;if(!o||!e)return()=>{};const i=function(e){let t=a.get(e);return t||(t=new Map,a.set(e,t)),t}(o),l=`${n??"necto"}:${e}`;let c=i.get(l);if(c)c.element&&(c.element.textContent=e,c.count++);else{c={element:p(e,{id:n,internalId:m(),insertionPoint:r}),count:1},i.set(l,c)}return()=>{const e=i.get(l);e?.element&&(e.count--,e.count<1&&(e.element.remove(),e.element=null,i.delete(l)))}}function w(e,o){if(e&&c(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=o?t(o):"undefined"!=typeof document?document:null,r=o?n(o):"undefined"!=typeof window?window:null;return{top:0,left:0,bottom:r?.innerHeight||e?.documentElement?.clientHeight||0,right:r?.innerWidth||e?.documentElement?.clientWidth||0}}}var h=new Map,y=new Set;function E(e){if(!("propertyName"in e)||!e.target)return;let t=h.get(e.target);t||(t=new Set,h.set(e.target,t),e.target.addEventListener("transitioncancel",T,{once:!0})),t.add(e.propertyName)}function T(e){if(!("propertyName"in e)||!e.target)return;const t=h.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",T),h.delete(e.target)),0===h.size)){for(const e of y)e();y.clear()}}if("undefined"!=typeof window&&"undefined"!=typeof document){const e=()=>{const e=document.body;e&&(e.addEventListener("transitionrun",E),e.addEventListener("transitionend",T))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function b(e){requestAnimationFrame(()=>{for(const[e]of h)"isConnected"in e&&!e.isConnected&&h.delete(e);0===h.size?e():y.add(e)})}import{DOM as S}from"@necto/constants";var v=S.HTML_TAGS.reduce((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e},{});import{isIOS as L}from"@necto/platform";var A="",M="default",N=new WeakMap;function C(e){if(L()){if("default"===M){const n=t(e);void 0!==n?.documentElement?.style.webkitUserSelect&&(A=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none",M="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";N.has(e)||(N.set(e,t[n]??""),t[n]="none")}}function R(e){if(L()){if("disabled"!==M)return;M="restoring",setTimeout(()=>{b(()=>{if("restoring"===M){const n=t(e);"none"===n?.documentElement?.style.webkitUserSelect&&(n.documentElement.style.webkitUserSelect=A||""),A="",M="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&N.has(e)){const t=N.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),N.delete(e)}}import{DOM as U}from"@necto/constants";var k=U.ARIA_ATTRIBUTES.reduce((e,t)=>(e[(e=>{const t=e.replace("aria-","");return t.charAt(0).toUpperCase()+t.slice(1)})(t)]=t,e),{}),H=U.ARIA_ATTRIBUTES,W=new Set(H),B=e=>W.has(e),D=e=>e.startsWith("aria-");export{H as ALL_ARIA_PROPS,W as ARIA_PROPS_SET,k as AriaProps,v as HTMLElements,C as disableTextSelection,f as focusWithoutScrolling,d as getActiveElement,w as getContainmentRect,u as getEventTarget,t as getOwnerDocument,n as getOwnerWindow,D as hasAriaPrefix,g as injectStyle,B as isAriaAttribute,c as isNode,s as nodeContains,R as restoreTextSelection,b as runAfterTransition,i as scrollIntoView,r as supportsPreventScroll,e as toPx};
1
+ function e(e){if(void 0!==e)return"number"==typeof e?`${e}px`:e}function t(e){return e?.ownerDocument?e.ownerDocument:"undefined"!=typeof document?document:null}function n(e){if(e&&"window"in e&&e.window===e)return e;const n=t(e);return n?.defaultView?n.defaultView:"undefined"!=typeof window?window:null}var o=null;function r(){if(null==o&&(o=!1,"undefined"!=typeof document))try{document.createElement("div").focus({get preventScroll(){return o=!0,!0}})}catch{}return o}function l(e,t,n){const{block:o="nearest",inline:r="nearest"}=n??{},l=e.getBoundingClientRect(),i=t.getBoundingClientRect(),c=i.top<l.top,s=i.bottom>l.bottom,d=i.left<l.left,f=i.right>l.right;if(c||s){let t=e.scrollTop;if("start"===o||"nearest"===o&&c)t=e.scrollTop+(i.top-l.top);else if("end"===o||"nearest"===o&&s)t=e.scrollTop+(i.bottom-l.bottom);else if("center"===o){const n=l.top+l.height/2,o=i.top+i.height/2;t=e.scrollTop+(o-n)}e.scrollTop=t}if(d||f){let t=e.scrollLeft;if("start"===r||"nearest"===r&&d)t=e.scrollLeft+(i.left-l.left);else if("end"===r||"nearest"===r&&f)t=e.scrollLeft+(i.right-l.right);else if("center"===r){const n=l.left+l.width/2,o=i.left+i.width/2;t=e.scrollLeft+(o-n)}e.scrollLeft=t}}function i(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function c(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function s(e,t,n=!0){if(!e||!t)return!1;if(!n)return e.contains(t);let o=t;for(;o;){if(o===e)return!0;o=o instanceof Element&&"SLOT"===o.tagName&&o.assignedSlot?o.assignedSlot?.parentNode??null:i(o)?o.host:o.parentNode}return!1}var d=(e=("undefined"!=typeof document?document:null),t=!0)=>{if(!e)return null;if(!t)return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&n.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n};function f(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function u(e){if(r())e.focus({preventScroll:!0});else{let t=e.parentNode;const n=[],o="undefined"!=typeof document?document.scrollingElement||document.documentElement:null;for(;t instanceof HTMLElement&&t!==o;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),e.focus();for(const{element:e,scrollTop:t,scrollLeft:o}of n)e.scrollTop=t,e.scrollLeft=o}}var a=new WeakMap;function m(e,n={}){const{id:o,insertionPoint:r,window:l=("undefined"!=typeof window?window:null)}=n;if(!l||!e)return()=>{};let i=a.get(l);i||(i=new Map,a.set(l,i));const c=`${o??"necto"}:${e}`;let s=i.get(c);if(s)s.element&&(s.element.textContent=e,s.count++);else{const n=r?t(r):"undefined"!=typeof document?document:null;if(!n)return()=>{};const l=`necto-<:${Math.random().toString(36).slice(2,9)}:>`,d=n.createElement("style");d.setAttribute("type","text/css"),d.setAttribute("data-style-id",l),o&&(d.id=o),d.textContent=e,r?n.head.insertBefore(d,r):n.head.appendChild(d),s={element:d,count:1},i.set(c,s)}return()=>{const e=i.get(c);e?.element&&(e.count--,e.count<1&&(e.element.remove(),e.element=null,i.delete(c)))}}function p(e,o){if(e&&c(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=o?t(o):"undefined"!=typeof document?document:null,r=o?n(o):"undefined"!=typeof window?window:null;return{top:0,left:0,bottom:r?.innerHeight||e?.documentElement?.clientHeight||0,right:r?.innerWidth||e?.documentElement?.clientWidth||0}}}var g=new Map,w=new Set;function h(e){if(!("propertyName"in e)||!e.target)return;let t=g.get(e.target);t||(t=new Set,g.set(e.target,t),e.target.addEventListener("transitioncancel",y,{once:!0})),t.add(e.propertyName)}function y(e){if(!("propertyName"in e)||!e.target)return;const t=g.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",y),g.delete(e.target)),0===g.size)){for(const e of w)e();w.clear()}}if("undefined"!=typeof window&&"undefined"!=typeof document){const e=()=>{const e=document.body;e&&(e.addEventListener("transitionrun",h),e.addEventListener("transitionend",y))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function E(e){requestAnimationFrame(()=>{for(const[e]of g)"isConnected"in e&&!e.isConnected&&g.delete(e);0===g.size?e():w.add(e)})}import{DOM as T}from"@necto/constants";var b=T.HTML_TAGS.reduce((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e},{});import{isIOS as S}from"@necto/platform";var v="",L="default",A=new WeakMap;function M(e){if(S()){if("default"===L){const n=t(e);void 0!==n?.documentElement?.style.webkitUserSelect&&(v=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none",L="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";A.has(e)||(A.set(e,t[n]??""),t[n]="none")}}function N(e){if(S()){if("disabled"!==L)return;L="restoring",setTimeout(()=>{E(()=>{if("restoring"===L){const n=t(e);"none"===n?.documentElement?.style.webkitUserSelect&&(n.documentElement.style.webkitUserSelect=v||""),v="",L="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&A.has(e)){const t=A.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),A.delete(e)}}import{DOM as C}from"@necto/constants";var R=C.ARIA_ATTRIBUTES.reduce((e,t)=>(e[(e=>{const t=e.replace("aria-","");return t.charAt(0).toUpperCase()+t.slice(1)})(t)]=t,e),{}),U=C.ARIA_ATTRIBUTES,k=new Set(U),H=e=>k.has(e),W=e=>e.startsWith("aria-");export{U as ALL_ARIA_PROPS,k as ARIA_PROPS_SET,R as AriaProps,b as HTMLElements,M as disableTextSelection,u as focusWithoutScrolling,d as getActiveElement,p as getContainmentRect,f as getEventTarget,t as getOwnerDocument,n as getOwnerWindow,W as hasAriaPrefix,m as injectStyle,H as isAriaAttribute,c as isNode,s as nodeContains,N as restoreTextSelection,E as runAfterTransition,l as scrollIntoView,r as supportsPreventScroll,e as toPx};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necto/dom",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "Necto's library for providing helpers and tools to interact with the DOM.",
5
5
  "author": "Corinvo OSS Team",
6
6
  "license": "MIT",