@necto/dom 1.4.0 → 1.4.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.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i={};function l(e){return c(e)&&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:l(o)?o.host:o.parentNode}return!1}((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})(i,{HTMLElements:()=>L,disableTextSelection:()=>A,focusWithoutScrolling:()=>g,getActiveElement:()=>a,getContainmentRect:()=>E,getEventTarget:()=>u,getOwnerDocument:()=>d,getOwnerWindow:()=>f,getScrollableElements:()=>w,isNode:()=>c,nodeContains:()=>s,restoreTextSelection:()=>U,runAfterTransition:()=>v,supportsPreventScroll:()=>p}),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 a=(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}var d=e=>e?.ownerDocument??document,f=e=>{if(e&&"window"in e&&e.window===e)return e;return d(e).defaultView||window},m=null;function p(){if(null==m){m=!1;try{document.createElement("div").focus({get preventScroll(){return m=!0,!0}})}catch{}}return m}function g(e){if(p())e.focus({preventScroll:!0});else{const t=w(e);e.focus();for(const{element:e,scrollTop:n,scrollLeft:o}of t)e.scrollTop=n,e.scrollLeft=o}}function w(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}function E(e,t){if(e&&c(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=t?d(t):document,n=t?f(t):window;return{top:0,left:0,bottom:n.innerHeight||e.documentElement.clientHeight,right:n.innerWidth||e.documentElement.clientWidth}}}var y=new Map,S=new Set;function h(e){if(!("propertyName"in e)||!e.target)return;let t=y.get(e.target);t||(t=new Set,y.set(e.target,t),e.target.addEventListener("transitioncancel",b,{once:!0})),t.add(e.propertyName)}function b(e){if(!("propertyName"in e)||!e.target)return;const t=y.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",b),y.delete(e.target)),0===y.size)){for(const e of S)e();S.clear()}}if("undefined"!=typeof window&&"undefined"!=typeof document){const e=()=>{const e=document.body;e&&(e.addEventListener("transitionrun",h),e.addEventListener("transitionend",b))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function v(e){requestAnimationFrame((()=>{for(const[e]of y)"isConnected"in e&&!e.isConnected&&y.delete(e);0===y.size?e():S.add(e)}))}var T=require("@necto/constants"),L=T.DOM.HTML_TAGS.reduce(((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e}),{}),O=require("@necto/platform"),N="default",M="",H=new WeakMap;function A(e){if((0,O.isIOS)()){if("default"===N){const t=d(e);void 0!==t?.documentElement?.style.webkitUserSelect&&(M=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none",N="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";H.has(e)||(H.set(e,t[n]??""),t[n]="none")}}function U(e){if((0,O.isIOS)()){if("disabled"!==N)return;N="restoring",setTimeout((()=>{v((()=>{if("restoring"===N){const t=d(e);"none"===t?.documentElement?.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=M||""),M="",N="default"}}))}),300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&H.has(e)){const t=H.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),H.delete(e)}}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return t(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function t(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function n(t,n,o=!0){if(!t||!n)return!1;if(!o)return t.contains(n);let r=n;for(;r;){if(r===t)return!0;r=r instanceof Element&&"SLOT"===r.tagName&&r.assignedSlot?r.assignedSlot.parentNode:e(r)?r.host:r.parentNode}return!1}var o=(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 r(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}var i=e=>e?.ownerDocument??document,l=e=>{if(e&&"window"in e&&e.window===e)return e;return i(e).defaultView||window},c=null;function s(){if(null==c){c=!1;try{document.createElement("div").focus({get preventScroll(){return c=!0,!0}})}catch{}}return c}function a(e){if(s())e.focus({preventScroll:!0});else{const t=d(e);e.focus();for(const{element:e,scrollTop:n,scrollLeft:o}of t)e.scrollTop=n,e.scrollLeft=o}}function d(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}function f(e,n){if(e&&t(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=n?i(n):document,t=n?l(n):window;return{top:0,left:0,bottom:t.innerHeight||e.documentElement.clientHeight,right:t.innerWidth||e.documentElement.clientWidth}}}var u=new Map,m=new Set;function p(e){if(!("propertyName"in e)||!e.target)return;let t=u.get(e.target);t||(t=new Set,u.set(e.target,t),e.target.addEventListener("transitioncancel",g,{once:!0})),t.add(e.propertyName)}function g(e){if(!("propertyName"in e)||!e.target)return;const t=u.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",g),u.delete(e.target)),0===u.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",p),e.addEventListener("transitionend",g))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function E(e){requestAnimationFrame((()=>{for(const[e]of u)"isConnected"in e&&!e.isConnected&&u.delete(e);0===u.size?e():m.add(e)}))}import
|
|
1
|
+
function e(e){return t(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function t(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function n(t,n,o=!0){if(!t||!n)return!1;if(!o)return t.contains(n);let r=n;for(;r;){if(r===t)return!0;r=r instanceof Element&&"SLOT"===r.tagName&&r.assignedSlot?r.assignedSlot.parentNode:e(r)?r.host:r.parentNode}return!1}var o=(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 r(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}var i=e=>e?.ownerDocument??document,l=e=>{if(e&&"window"in e&&e.window===e)return e;return i(e).defaultView||window},c=null;function s(){if(null==c){c=!1;try{document.createElement("div").focus({get preventScroll(){return c=!0,!0}})}catch{}}return c}function a(e){if(s())e.focus({preventScroll:!0});else{const t=d(e);e.focus();for(const{element:e,scrollTop:n,scrollLeft:o}of t)e.scrollTop=n,e.scrollLeft=o}}function d(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}function f(e,n){if(e&&t(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=n?i(n):document,t=n?l(n):window;return{top:0,left:0,bottom:t.innerHeight||e.documentElement.clientHeight,right:t.innerWidth||e.documentElement.clientWidth}}}var u=new Map,m=new Set;function p(e){if(!("propertyName"in e)||!e.target)return;let t=u.get(e.target);t||(t=new Set,u.set(e.target,t),e.target.addEventListener("transitioncancel",g,{once:!0})),t.add(e.propertyName)}function g(e){if(!("propertyName"in e)||!e.target)return;const t=u.get(e.target);if(t&&(t.delete(e.propertyName),0===t.size&&(e.target.removeEventListener("transitioncancel",g),u.delete(e.target)),0===u.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",p),e.addEventListener("transitionend",g))};"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}function E(e){requestAnimationFrame((()=>{for(const[e]of u)"isConnected"in e&&!e.isConnected&&u.delete(e);0===u.size?e():m.add(e)}))}import{DOM as w}from"@necto/constants";var h=w.HTML_TAGS.reduce(((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e}),{});import{isIOS as y}from"@necto/platform";var S="default",v="",T=new WeakMap;function L(e){if(y()){if("default"===S){const t=i(e);void 0!==t?.documentElement?.style.webkitUserSelect&&(v=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none",S="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";T.has(e)||(T.set(e,t[n]??""),t[n]="none")}}function b(e){if(y()){if("disabled"!==S)return;S="restoring",setTimeout((()=>{E((()=>{if("restoring"===S){const t=i(e);"none"===t?.documentElement?.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=v||""),v="",S="default"}}))}),300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&T.has(e)){const t=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"),T.delete(e)}}export{h as HTMLElements,L as disableTextSelection,a as focusWithoutScrolling,o as getActiveElement,f as getContainmentRect,r as getEventTarget,i as getOwnerDocument,l as getOwnerWindow,d as getScrollableElements,t as isNode,n as nodeContains,b as restoreTextSelection,E as runAfterTransition,s as supportsPreventScroll};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@necto/dom",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.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",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"module": "./dist/index.mjs",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"html-tags": "^4.0.0",
|
|
20
|
+
"@necto/constants": "1.4.2",
|
|
20
21
|
"@necto/types": "1.3.0",
|
|
21
22
|
"@necto/platform": "1.4.0"
|
|
22
23
|
},
|