@necto/dom 1.6.8 → 1.6.9
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 +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
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
|
|
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){if(e?.ownerDocument)return e.ownerDocument;if("undefined"!=typeof document)return document;throw new Error("getOwnerDocument called in an environment without document")}function s(e){return e&&"window"in e&&e.window===e?e:c(e).defaultView||("undefined"!=typeof window?window:void 0)}((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:()=>c,getOwnerWindow:()=>s,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:()=>N,scrollIntoView:()=>a,scrollIntoViewport:()=>d,supportsPreventScroll:()=>f,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 f(){if(null==u){u=!1;try{if("undefined"==typeof document)return!1;document.createElement("div").focus({get preventScroll(){return u=!0,!0}})}catch{}}return u}function a(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,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(u||f){let t=e.scrollLeft;if("start"===r||"nearest"===r&&u)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 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,t=!0)=>{if(e||(e="undefined"!=typeof document?document:void 0),!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 y(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function h(e){if(f())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="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;return o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),n}var v="necto-style-id",E="necto-style",b=new WeakMap;function T(e){let t=b.get(e);return t||(t=new Map,b.set(e,t)),t}function L(e,t={}){const{id:n=E,insertionPoint:o}=t,r=o?c(o):"undefined"!=typeof document?document:void 0;if(!r)throw new Error("createStyleElement called without document");const i=r.createElement("style");return i.setAttribute("type","text/css"),i.setAttribute(v,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 c=i.get(l);return c?c.element&&(c.element.textContent=e,c.count++):(c={element:L(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 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?c(t):"undefined"!=typeof document?document:void 0,n=t?s(t):"undefined"!=typeof window?window:void 0;return e&&n?{top:0,left:0,bottom:n.innerHeight||e.documentElement.clientHeight,right:n.innerWidth||e.documentElement.clientWidth}:{top:0,left:0,bottom:0,right:0}}}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",D,{once:!0})),t.add(e.propertyName)}function D(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",D),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",D))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function N(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=c(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(()=>{N(()=>{if("restoring"===H){const t=c(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
|
|
1
|
+
function e(e){if(void 0!==e)return"number"==typeof e?`${e}px`:e}function t(e){if(e?.ownerDocument)return e.ownerDocument;if("undefined"!=typeof document)return document;throw new Error("getOwnerDocument called in an environment without document")}function n(e){return e&&"window"in e&&e.window===e?e:t(e).defaultView||("undefined"!=typeof window?window:void 0)}var o=null;function r(){if(null==o){o=!1;try{if("undefined"==typeof document)return!1;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,f=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(f||d){let t=e.scrollLeft;if("start"===r||"nearest"===r&&f)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 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 f(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 d=(e,t=!0)=>{if(e||(e="undefined"!=typeof document?document:void 0),!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 a(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="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;return o instanceof HTMLElement&&n.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),n}var p="necto-style",w=new WeakMap;function g(e){let t=w.get(e);return t||(t=new Map,w.set(e,t)),t}function y(e,n={}){const{id:o=p,insertionPoint:r}=n,i=r?t(r):"undefined"!=typeof document?document:void 0;if(!i)throw new Error("createStyleElement called without document");const 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 h(e,t={}){const{id:n=p,window:o=("undefined"!=typeof window?window:null),insertionPoint:r}=t;if(!o||!e)return()=>{};const i=g(o),l=`${n}:${e}`;let c=i.get(l);return c?c.element&&(c.element.textContent=e,c.count++):(c={element:y(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 v(e){e.remove()}function E(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):"undefined"!=typeof document?document:void 0,r=o?n(o):"undefined"!=typeof window?window:void 0;return e&&r?{top:0,left:0,bottom:r.innerHeight||e.documentElement.clientHeight,right:r.innerWidth||e.documentElement.clientWidth}:{top:0,left:0,bottom:0,right:0}}}var b=new Map,T=new Set;function S(e){if(!("propertyName"in e)||!e.target)return;let t=b.get(e.target);t||(t=new Set,b.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=b.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",L),b.delete(e.target)),0===b.size)){for(const e of T)e();T.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 b)"isConnected"in e&&!e.isConnected&&b.delete(e);0===b.size?e():T.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="",O="default",U=new WeakMap;function D(e){if(P()){if("default"===O){const n=t(e);void 0!==n?.documentElement?.style.webkitUserSelect&&(k=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none",O="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 x(e){if(P()){if("disabled"!==O)return;O="restoring",setTimeout(()=>{R(()=>{if("restoring"===O){const n=t(e);"none"===n?.documentElement?.style.webkitUserSelect&&(n.documentElement.style.webkitUserSelect=k||""),k="",O="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)}}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,y as createStyleElement,D as disableTextSelection,a as focusWithoutScrolling,d as getActiveElement,E as getContainmentRect,u as getEventTarget,t as getOwnerDocument,n as getOwnerWindow,m as getScrollableElements,g as getStyleMap,K as hasAriaPrefix,h 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,f as nodeContains,v as removeStyleElement,x 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.
|
|
3
|
+
"version": "1.6.9",
|
|
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/types": "1.3.1",
|
|
29
28
|
"@necto/constants": "1.4.4",
|
|
30
|
-
"@necto/
|
|
31
|
-
"@necto/
|
|
29
|
+
"@necto/file": "1.0.0",
|
|
30
|
+
"@necto/types": "1.3.1",
|
|
31
|
+
"@necto/platform": "1.5.1"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsup --minify terser"
|