@necto/dom 1.6.2 → 1.6.4

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 s(e){return e?.ownerDocument??document}function c(e){return e&&"window"in e&&e.window===e?e:s(e).defaultView||window}((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})(i,{ALL_ARIA_PROPS:()=>G,ARIA_PROPS_SET:()=>F,AriaProps:()=>q,HTMLElements:()=>_,createStyleElement:()=>L,disableTextSelection:()=>V,focusWithoutScrolling:()=>y,getActiveElement:()=>w,getContainmentRect:()=>P,getEventTarget:()=>h,getOwnerDocument:()=>s,getOwnerWindow:()=>c,getScrollableElements:()=>S,getStyleMap:()=>T,hasAriaPrefix:()=>K,injectStyle:()=>A,injectSvgDimensions:()=>Q,isAriaAttribute:()=>z,isElementType:()=>Y,isNode:()=>p,isShadowRoot:()=>m,isSvgContent:()=>J.isSvg,isSvgElement:()=>X,isSvgFast:()=>J.isSvgFast,nodeContains:()=>g,removeStyleElement:()=>O,restoreTextSelection:()=>B,runAfterTransition:()=>k,scrollIntoView:()=>f,scrollIntoViewport:()=>d,supportsPreventScroll:()=>u,toPx:()=>l}),module.exports=(e=i,((e,i,l,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of o(i))r.call(e,c)||c===l||t(e,c,{get:()=>i[c],enumerable:!(s=n(i,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a=null;function u(){if(null==a){a=!1;try{document.createElement("div").focus({get preventScroll(){return a=!0,!0}})}catch{}}return a}function f(e,t,n){const{block:o="nearest",inline:r="nearest"}=n??{},i=e.getBoundingClientRect(),l=t.getBoundingClientRect(),s=l.top<i.top,c=l.bottom>i.bottom,a=l.left<i.left,u=l.right>i.right;if(s||c){let t=e.scrollTop;if("start"===o||"nearest"===o&&s)t=e.scrollTop+(l.top-i.top);else if("end"===o||"nearest"===o&&c)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(a||u){let t=e.scrollLeft;if("start"===r||"nearest"===r&&a)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 d(e,t){const{containingElement:n}=t??{};e.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),n&&n.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})}function m(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function p(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function g(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:m(o)?o.host:o.parentNode}return!1}var w=(e=document,t=!0)=>{if(!t)return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&n.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n};function h(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function y(e){if(u())e.focus({preventScroll:!0});else{const t=S(e);e.focus();for(const{element:e,scrollTop:n,scrollLeft:o}of t)e.scrollTop=n,e.scrollLeft=o}}function S(e){let t=e.parentNode;const n=Array.from({length:0}),o=document.scrollingElement||document.documentElement;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;return o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),n}var b="necto-style-id",E="necto-style",v=new WeakMap;function T(e){let t=v.get(e);return t||(t=new Map,v.set(e,t)),t}function L(e,t={}){const{id:n=E,insertionPoint:o}=t,r=o?s(o):document,i=r.createElement("style");return i.setAttribute("type","text/css"),i.setAttribute(b,n),i.textContent=e,o?r.head.insertBefore(i,o):r.head.appendChild(i),i}function A(e,t={}){const{id:n=E,window:o=("undefined"!=typeof window?window:null),insertionPoint:r}=t;if(!o||!e)return()=>{};const i=T(o),l=`${n}:${e}`;let s=i.get(l);return s?s.element&&(s.element.textContent=e,s.count++):(s={element:L(e,{id:n,insertionPoint:r}),count:1},i.set(l,s)),()=>{const e=i.get(l);e?.element&&(e.count--,e.count<1&&(e.element.remove(),e.element=null,i.delete(l)))}}function O(e){e.remove()}function P(e,t){if(e&&p(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=t?s(t):document,n=t?c(t):window;return{top:0,left:0,bottom:n.innerHeight||e.documentElement.clientHeight,right:n.innerWidth||e.documentElement.clientWidth}}}var R=new Map,M=new Set;function C(e){if(!("propertyName"in e)||!e.target)return;let t=R.get(e.target);t||(t=new Set,R.set(e.target,t),e.target.addEventListener("transitioncancel",N,{once:!0})),t.add(e.propertyName)}function N(e){if(!("propertyName"in e)||!e.target)return;const t=R.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",N),R.delete(e.target)),0===R.size)){for(const e of M)e();M.clear()}}if("undefined"!=typeof window&&"undefined"!=typeof document){const e=()=>{const e=document.body;e&&(e.addEventListener("transitionrun",C),e.addEventListener("transitionend",N))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function k(e){requestAnimationFrame(()=>{for(const[e]of R)"isConnected"in e&&!e.isConnected&&R.delete(e);0===R.size?e():M.add(e)})}var D,I=require("@necto/constants"),U=()=>I.DOM.HTML_TAGS.reduce((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e},{}),_=new Proxy({},{get:(e,t,n)=>(D||(D=U()),Reflect.get(D,t,n)),ownKeys:()=>(D||(D=U()),Reflect.ownKeys(D)),getOwnPropertyDescriptor:(e,t)=>(D||(D=U()),Object.getOwnPropertyDescriptor(D,t))}),j=require("@necto/platform"),x="",H="default",W=new WeakMap;function V(e){if((0,j.isIOS)()){if("default"===H){const t=s(e);void 0!==t?.documentElement?.style.webkitUserSelect&&(x=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none",H="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";W.has(e)||(W.set(e,t[n]??""),t[n]="none")}}function B(e){if((0,j.isIOS)()){if("disabled"!==H)return;H="restoring",setTimeout(()=>{k(()=>{if("restoring"===H){const t=s(e);"none"===t?.documentElement?.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=x||""),x="",H="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&W.has(e)){const t=W.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),W.delete(e)}}var $=require("@necto/constants"),q=$.DOM.ARIA_ATTRIBUTES.reduce((e,t)=>(e[(e=>{const t=e.replace("aria-","");return t.charAt(0).toUpperCase()+t.slice(1)})(t)]=t,e),{}),G=$.DOM.ARIA_ATTRIBUTES,F=new Set(G),z=e=>F.has(e),K=e=>e.startsWith("aria-"),J=require("@necto/file");function Q(e,t="100%",n="100%"){return e.replace(/<svg([^>]*)>/,`<svg$1 width="${t}" height="${n}">`)}function X(e){return e instanceof SVGElement}function Y(e,t){return e.tagName.toLowerCase()===t.toLowerCase()}
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 s(e){return e?.ownerDocument??document}function c(e){return e&&"window"in e&&e.window===e?e:s(e).defaultView||window}((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})(i,{ALL_ARIA_PROPS:()=>J,ARIA_PROPS_SET:()=>Q,AriaProps:()=>z,HTMLElements:()=>U,createStyleElement:()=>L,disableTextSelection:()=>V,focusWithoutScrolling:()=>h,getActiveElement:()=>w,getContainmentRect:()=>P,getEventTarget:()=>y,getOwnerDocument:()=>s,getOwnerWindow:()=>c,getScrollableElements:()=>S,getStyleMap:()=>T,hasAriaPrefix:()=>Y,injectStyle:()=>A,injectSvgDimensions:()=>ee,isAriaAttribute:()=>X,isElementType:()=>ne,isNode:()=>p,isShadowRoot:()=>m,isSvgContent:()=>Z.isSvg,isSvgElement:()=>te,isSvgFast:()=>Z.isSvgFast,nodeContains:()=>g,removeStyleElement:()=>O,restoreTextSelection:()=>B,runAfterTransition:()=>D,scrollIntoView:()=>f,scrollIntoViewport:()=>d,supportsPreventScroll:()=>u,toPx:()=>l}),module.exports=(e=i,((e,i,l,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of o(i))r.call(e,c)||c===l||t(e,c,{get:()=>i[c],enumerable:!(s=n(i,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a=null;function u(){if(null==a){a=!1;try{document.createElement("div").focus({get preventScroll(){return a=!0,!0}})}catch{}}return a}function f(e,t,n){const{block:o="nearest",inline:r="nearest"}=n??{},i=e.getBoundingClientRect(),l=t.getBoundingClientRect(),s=l.top<i.top,c=l.bottom>i.bottom,a=l.left<i.left,u=l.right>i.right;if(s||c){let t=e.scrollTop;if("start"===o||"nearest"===o&&s)t=e.scrollTop+(l.top-i.top);else if("end"===o||"nearest"===o&&c)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(a||u){let t=e.scrollLeft;if("start"===r||"nearest"===r&&a)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 d(e,t){const{containingElement:n}=t??{};e.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),n&&n.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})}function m(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function p(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function g(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:m(o)?o.host:o.parentNode}return!1}var w=(e=document,t=!0)=>{if(!t)return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&n.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return n};function y(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function h(e){if(u())e.focus({preventScroll:!0});else{const t=S(e);e.focus();for(const{element:e,scrollTop:n,scrollLeft:o}of t)e.scrollTop=n,e.scrollLeft=o}}function S(e){let t=e.parentNode;const n=Array.from({length:0}),o=document.scrollingElement||document.documentElement;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;return o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),n}var b="necto-style-id",E="necto-style",v=new WeakMap;function T(e){let t=v.get(e);return t||(t=new Map,v.set(e,t)),t}function L(e,t={}){const{id:n=E,insertionPoint:o}=t,r=o?s(o):document,i=r.createElement("style");return i.setAttribute("type","text/css"),i.setAttribute(b,n),i.textContent=e,o?r.head.insertBefore(i,o):r.head.appendChild(i),i}function A(e,t={}){const{id:n=E,window:o=("undefined"!=typeof window?window:null),insertionPoint:r}=t;if(!o||!e)return()=>{};const i=T(o),l=`${n}:${e}`;let s=i.get(l);return s?s.element&&(s.element.textContent=e,s.count++):(s={element:L(e,{id:n,insertionPoint:r}),count:1},i.set(l,s)),()=>{const e=i.get(l);e?.element&&(e.count--,e.count<1&&(e.element.remove(),e.element=null,i.delete(l)))}}function O(e){e.remove()}function P(e,t){if(e&&p(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=t?s(t):document,n=t?c(t):window;return{top:0,left:0,bottom:n.innerHeight||e.documentElement.clientHeight,right:n.innerWidth||e.documentElement.clientWidth}}}var R=new Map,M=new Set;function C(e){if(!("propertyName"in e)||!e.target)return;let t=R.get(e.target);t||(t=new Set,R.set(e.target,t),e.target.addEventListener("transitioncancel",N,{once:!0})),t.add(e.propertyName)}function N(e){if(!("propertyName"in e)||!e.target)return;const t=R.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",N),R.delete(e.target)),0===R.size)){for(const e of M)e();M.clear()}}if("undefined"!=typeof window&&"undefined"!=typeof document){const e=()=>{const e=document.body;e&&(e.addEventListener("transitionrun",C),e.addEventListener("transitionend",N))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function D(e){requestAnimationFrame(()=>{for(const[e]of R)"isConnected"in e&&!e.isConnected&&R.delete(e);0===R.size?e():M.add(e)})}var x,k=require("@necto/constants"),I=()=>k.DOM.HTML_TAGS.reduce((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e},{}),U=new Proxy({},{get:(e,t,n)=>(x||(x=I()),Reflect.get(x,t,n)),ownKeys:()=>(x||(x=I()),Reflect.ownKeys(x)),getOwnPropertyDescriptor:(e,t)=>(x||(x=I()),Object.getOwnPropertyDescriptor(x,t))}),j=require("@necto/platform"),_="",H="default",W=new WeakMap;function V(e){if((0,j.isIOS)()){if("default"===H){const t=s(e);void 0!==t?.documentElement?.style.webkitUserSelect&&(_=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none",H="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";W.has(e)||(W.set(e,t[n]??""),t[n]="none")}}function B(e){if((0,j.isIOS)()){if("disabled"!==H)return;H="restoring",setTimeout(()=>{D(()=>{if("restoring"===H){const t=s(e);"none"===t?.documentElement?.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=_||""),_="",H="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&W.has(e)){const t=W.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),W.delete(e)}}var $,q,G,F=require("@necto/constants"),K=()=>{$||($=F.DOM.ARIA_ATTRIBUTES.reduce((e,t)=>(e[(e=>{const t=e.replace("aria-","");return t.charAt(0).toUpperCase()+t.slice(1)})(t)]=t,e),{}),q=F.DOM.ARIA_ATTRIBUTES,G=new Set(q))},z=new Proxy({},{get:(e,t,n)=>(K(),Reflect.get($,t,n)),ownKeys:()=>(K(),Reflect.ownKeys($)),getOwnPropertyDescriptor:(e,t)=>(K(),Object.getOwnPropertyDescriptor($,t))}),J=new Proxy([],{get:(e,t,n)=>(K(),Reflect.get(q,t,n))}),Q=new Proxy(new Set,{get:(e,t,n)=>(K(),Reflect.get(G,t,n))}),X=e=>(K(),G.has(e)),Y=e=>e.startsWith("aria-"),Z=require("@necto/file");function ee(e,t="100%",n="100%"){return e.replace(/<svg([^>]*)>/,`<svg$1 width="${t}" height="${n}">`)}function te(e){return e instanceof SVGElement}function ne(e,t){return e.tagName.toLowerCase()===t.toLowerCase()}
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??document}function n(e){return e&&"window"in e&&e.window===e?e:t(e).defaultView||window}var o=null;function r(){if(null==o){o=!1;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,a=l.left<i.left,f=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(a||f){let t=e.scrollLeft;if("start"===r||"nearest"===r&&a)t=e.scrollLeft+(l.left-i.left);else if("end"===r||"nearest"===r&&f)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,t){const{containingElement:n}=t??{};e.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),n&&n.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})}function c(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function s(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function a(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:c(o)?o.host:o.parentNode}return!1}var f=(e=document,t=!0)=>{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 d(e){if(r())e.focus({preventScroll:!0});else{const t=m(e);e.focus();for(const{element:e,scrollTop:n,scrollLeft:o}of t)e.scrollTop=n,e.scrollLeft=o}}function m(e){let t=e.parentNode;const n=Array.from({length:0}),o=document.scrollingElement||document.documentElement;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;return o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),n}var p="necto-style",g=new WeakMap;function w(e){let t=g.get(e);return t||(t=new Map,g.set(e,t)),t}function h(e,n={}){const{id:o=p,insertionPoint:r}=n,i=r?t(r):document,l=i.createElement("style");return l.setAttribute("type","text/css"),l.setAttribute("necto-style-id",o),l.textContent=e,r?i.head.insertBefore(l,r):i.head.appendChild(l),l}function y(e,t={}){const{id:n=p,window:o=("undefined"!=typeof window?window:null),insertionPoint:r}=t;if(!o||!e)return()=>{};const i=w(o),l=`${n}:${e}`;let c=i.get(l);return c?c.element&&(c.element.textContent=e,c.count++):(c={element:h(e,{id:n,insertionPoint:r}),count:1},i.set(l,c)),()=>{const e=i.get(l);e?.element&&(e.count--,e.count<1&&(e.element.remove(),e.element=null,i.delete(l)))}}function E(e){e.remove()}function b(e,o){if(e&&s(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=o?t(o):document,r=o?n(o):window;return{top:0,left:0,bottom:r.innerHeight||e.documentElement.clientHeight,right:r.innerWidth||e.documentElement.clientWidth}}}var T=new Map,v=new Set;function S(e){if(!("propertyName"in e)||!e.target)return;let t=T.get(e.target);t||(t=new Set,T.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=T.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",L),T.delete(e.target)),0===T.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",S),e.addEventListener("transitionend",L))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function A(e){requestAnimationFrame(()=>{for(const[e]of T)"isConnected"in e&&!e.isConnected&&T.delete(e);0===T.size?e():v.add(e)})}import{DOM as C}from"@necto/constants";var N,R=()=>C.HTML_TAGS.reduce((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e},{}),M=new Proxy({},{get:(e,t,n)=>(N||(N=R()),Reflect.get(N,t,n)),ownKeys:()=>(N||(N=R()),Reflect.ownKeys(N)),getOwnPropertyDescriptor:(e,t)=>(N||(N=R()),Object.getOwnPropertyDescriptor(N,t))});import{isIOS as k}from"@necto/platform";var U="",H="default",O=new WeakMap;function P(e){if(k()){if("default"===H){const n=t(e);void 0!==n?.documentElement?.style.webkitUserSelect&&(U=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none",H="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";O.has(e)||(O.set(e,t[n]??""),t[n]="none")}}function D(e){if(k()){if("disabled"!==H)return;H="restoring",setTimeout(()=>{A(()=>{if("restoring"===H){const n=t(e);"none"===n?.documentElement?.style.webkitUserSelect&&(n.documentElement.style.webkitUserSelect=U||""),U="",H="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&O.has(e)){const t=O.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),O.delete(e)}}import{DOM as W}from"@necto/constants";var x=W.ARIA_ATTRIBUTES.reduce((e,t)=>(e[(e=>{const t=e.replace("aria-","");return t.charAt(0).toUpperCase()+t.slice(1)})(t)]=t,e),{}),B=W.ARIA_ATTRIBUTES,I=new Set(B),V=e=>I.has(e),$=e=>e.startsWith("aria-");import{isSvg as G,isSvgFast as _}from"@necto/file";function j(e,t="100%",n="100%"){return e.replace(/<svg([^>]*)>/,`<svg$1 width="${t}" height="${n}">`)}function z(e){return e instanceof SVGElement}function F(e,t){return e.tagName.toLowerCase()===t.toLowerCase()}export{B as ALL_ARIA_PROPS,I as ARIA_PROPS_SET,x as AriaProps,M as HTMLElements,h as createStyleElement,P as disableTextSelection,d as focusWithoutScrolling,f as getActiveElement,b as getContainmentRect,u as getEventTarget,t as getOwnerDocument,n as getOwnerWindow,m as getScrollableElements,w as getStyleMap,$ as hasAriaPrefix,y as injectStyle,j as injectSvgDimensions,V as isAriaAttribute,F as isElementType,s as isNode,c as isShadowRoot,G as isSvgContent,z as isSvgElement,_ as isSvgFast,a as nodeContains,E as removeStyleElement,D as restoreTextSelection,A as runAfterTransition,i as scrollIntoView,l as scrollIntoViewport,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??document}function n(e){return e&&"window"in e&&e.window===e?e:t(e).defaultView||window}var o=null;function r(){if(null==o){o=!1;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,a=l.left<i.left,f=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(a||f){let t=e.scrollLeft;if("start"===r||"nearest"===r&&a)t=e.scrollLeft+(l.left-i.left);else if("end"===r||"nearest"===r&&f)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,t){const{containingElement:n}=t??{};e.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),n&&n.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})}function c(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function s(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function a(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:c(o)?o.host:o.parentNode}return!1}var f=(e=document,t=!0)=>{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 d(e){if(r())e.focus({preventScroll:!0});else{const t=m(e);e.focus();for(const{element:e,scrollTop:n,scrollLeft:o}of t)e.scrollTop=n,e.scrollLeft=o}}function m(e){let t=e.parentNode;const n=Array.from({length:0}),o=document.scrollingElement||document.documentElement;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;return o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),n}var p="necto-style",g=new WeakMap;function w(e){let t=g.get(e);return t||(t=new Map,g.set(e,t)),t}function h(e,n={}){const{id:o=p,insertionPoint:r}=n,i=r?t(r):document,l=i.createElement("style");return l.setAttribute("type","text/css"),l.setAttribute("necto-style-id",o),l.textContent=e,r?i.head.insertBefore(l,r):i.head.appendChild(l),l}function y(e,t={}){const{id:n=p,window:o=("undefined"!=typeof window?window:null),insertionPoint:r}=t;if(!o||!e)return()=>{};const i=w(o),l=`${n}:${e}`;let c=i.get(l);return c?c.element&&(c.element.textContent=e,c.count++):(c={element:h(e,{id:n,insertionPoint:r}),count:1},i.set(l,c)),()=>{const e=i.get(l);e?.element&&(e.count--,e.count<1&&(e.element.remove(),e.element=null,i.delete(l)))}}function E(e){e.remove()}function b(e,o){if(e&&s(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=o?t(o):document,r=o?n(o):window;return{top:0,left:0,bottom:r.innerHeight||e.documentElement.clientHeight,right:r.innerWidth||e.documentElement.clientWidth}}}var T=new Map,v=new Set;function S(e){if(!("propertyName"in e)||!e.target)return;let t=T.get(e.target);t||(t=new Set,T.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=T.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",L),T.delete(e.target)),0===T.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",S),e.addEventListener("transitionend",L))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function R(e){requestAnimationFrame(()=>{for(const[e]of T)"isConnected"in e&&!e.isConnected&&T.delete(e);0===T.size?e():v.add(e)})}import{DOM as A}from"@necto/constants";var C,N=()=>A.HTML_TAGS.reduce((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e},{}),M=new Proxy({},{get:(e,t,n)=>(C||(C=N()),Reflect.get(C,t,n)),ownKeys:()=>(C||(C=N()),Reflect.ownKeys(C)),getOwnPropertyDescriptor:(e,t)=>(C||(C=N()),Object.getOwnPropertyDescriptor(C,t))});import{isIOS as P}from"@necto/platform";var k="",U="default",O=new WeakMap;function x(e){if(P()){if("default"===U){const n=t(e);void 0!==n?.documentElement?.style.webkitUserSelect&&(k=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none",U="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";O.has(e)||(O.set(e,t[n]??""),t[n]="none")}}function D(e){if(P()){if("disabled"!==U)return;U="restoring",setTimeout(()=>{R(()=>{if("restoring"===U){const n=t(e);"none"===n?.documentElement?.style.webkitUserSelect&&(n.documentElement.style.webkitUserSelect=k||""),k="",U="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&O.has(e)){const t=O.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),O.delete(e)}}import{DOM as H}from"@necto/constants";var W,B,I,V=()=>{W||(W=H.ARIA_ATTRIBUTES.reduce((e,t)=>(e[(e=>{const t=e.replace("aria-","");return t.charAt(0).toUpperCase()+t.slice(1)})(t)]=t,e),{}),B=H.ARIA_ATTRIBUTES,I=new Set(B))},$=new Proxy({},{get:(e,t,n)=>(V(),Reflect.get(W,t,n)),ownKeys:()=>(V(),Reflect.ownKeys(W)),getOwnPropertyDescriptor:(e,t)=>(V(),Object.getOwnPropertyDescriptor(W,t))}),G=new Proxy([],{get:(e,t,n)=>(V(),Reflect.get(B,t,n))}),_=new Proxy(new Set,{get:(e,t,n)=>(V(),Reflect.get(I,t,n))}),j=e=>(V(),I.has(e)),K=e=>e.startsWith("aria-");import{isSvg as z,isSvgFast as F}from"@necto/file";function q(e,t="100%",n="100%"){return e.replace(/<svg([^>]*)>/,`<svg$1 width="${t}" height="${n}">`)}function J(e){return e instanceof SVGElement}function Q(e,t){return e.tagName.toLowerCase()===t.toLowerCase()}export{G as ALL_ARIA_PROPS,_ as ARIA_PROPS_SET,$ as AriaProps,M as HTMLElements,h as createStyleElement,x as disableTextSelection,d as focusWithoutScrolling,f as getActiveElement,b as getContainmentRect,u as getEventTarget,t as getOwnerDocument,n as getOwnerWindow,m as getScrollableElements,w as getStyleMap,K as hasAriaPrefix,y as injectStyle,q as injectSvgDimensions,j as isAriaAttribute,Q as isElementType,s as isNode,c as isShadowRoot,z as isSvgContent,J as isSvgElement,F as isSvgFast,a as nodeContains,E as removeStyleElement,D as restoreTextSelection,R as runAfterTransition,i as scrollIntoView,l as scrollIntoViewport,r as supportsPreventScroll,e as toPx};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necto/dom",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
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",
@@ -25,10 +25,10 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "html-tags": "^4.0.0",
28
- "@necto/constants": "1.4.3",
29
- "@necto/platform": "1.5.0",
28
+ "@necto/constants": "1.4.4",
29
+ "@necto/file": "1.0.0",
30
30
  "@necto/types": "1.3.0",
31
- "@necto/file": "1.0.0"
31
+ "@necto/platform": "1.5.0"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "tsup --minify terser"