@necto/dom 1.4.0 → 1.4.1

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 CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,l=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,c=(e,t,l,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of r(t))i.call(e,s)||s===l||n(e,s,{get:()=>t[s],enumerable:!(c=o(t,s))||c.enumerable});return e},s={};function a(e){return u(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function u(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&"number"==typeof e.nodeType}function d(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:a(o)?o.host:o.parentNode}return!1}((e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})})(s,{HTMLElements:()=>M,disableTextSelection:()=>A,focusWithoutScrolling:()=>y,getActiveElement:()=>f,getContainmentRect:()=>h,getEventTarget:()=>m,getOwnerDocument:()=>p,getOwnerWindow:()=>g,getScrollableElements:()=>b,isNode:()=>u,nodeContains:()=>d,restoreTextSelection:()=>C,runAfterTransition:()=>O,supportsPreventScroll:()=>E}),module.exports=(e=s,c(n({},"__esModule",{value:!0}),e));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 m(e,t=!0){return t&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}var p=e=>e?.ownerDocument??document,g=e=>{if(e&&"window"in e&&e.window===e)return e;return p(e).defaultView||window},w=null;function E(){if(null==w){w=!1;try{document.createElement("div").focus({get preventScroll(){return w=!0,!0}})}catch{}}return w}function y(e){if(E())e.focus({preventScroll:!0});else{const t=b(e);e.focus();for(const{element:e,scrollTop:n,scrollLeft:o}of t)e.scrollTop=n,e.scrollLeft=o}}function b(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 h(e,t){if(e&&u(e)){const t=e.getBoundingClientRect();return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}{const e=t?p(t):document,n=t?g(t):window;return{top:0,left:0,bottom:n.innerHeight||e.documentElement.clientHeight,right:n.innerWidth||e.documentElement.clientWidth}}}var S=new Map,v=new Set;function T(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",T),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 N=((e,o,r)=>(r=null!=e?t(l(e)):{},c(!o&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)))(require("html-tags")),M=N.default.reduce(((e,t)=>{var n;return e[(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=t,e}),{}),H=require("@necto/platform"),U="default",j="",k=new WeakMap;function A(e){if((0,H.isIOS)()){if("default"===U){const t=p(e);void 0!==t?.documentElement?.style.webkitUserSelect&&(j=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none",U="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";k.has(e)||(k.set(e,t[n]??""),t[n]="none")}}function C(e){if((0,H.isIOS)()){if("disabled"!==U)return;U="restoring",setTimeout((()=>{O((()=>{if("restoring"===U){const t=p(e);"none"===t?.documentElement?.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=j||""),j="",U="default"}}))}),300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&k.has(e)){const t=k.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),k.delete(e)}}
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 h from"html-tags";var w=h.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 v="default",S="",b=new WeakMap;function L(e){if(y()){if("default"===v){const t=i(e);void 0!==t?.documentElement?.style.webkitUserSelect&&(S=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none",v="disabled")}}else if(e instanceof HTMLElement||e instanceof SVGElement){const t=e.style,n="userSelect"in t?"userSelect":"webkitUserSelect";b.has(e)||(b.set(e,t[n]??""),t[n]="none")}}function T(e){if(y()){if("disabled"!==v)return;v="restoring",setTimeout((()=>{E((()=>{if("restoring"===v){const t=i(e);"none"===t?.documentElement?.style.webkitUserSelect&&(t.documentElement.style.webkitUserSelect=S||""),S="",v="default"}}))}),300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&b.has(e)){const t=b.get(e)??"",n=e.style,o="userSelect"in n?"userSelect":"webkitUserSelect";"none"===n[o]&&(n[o]=t),""===e.getAttribute("style")?.trim()&&e.removeAttribute("style"),b.delete(e)}}export{w 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,T as restoreTextSelection,E as runAfterTransition,s as supportsPreventScroll};
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.0",
3
+ "version": "1.4.1",
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.1",
20
21
  "@necto/types": "1.3.0",
21
22
  "@necto/platform": "1.4.0"
22
23
  },